forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openwebwork#2299 from drgrice1/achievement-item-pr…
…oblem-ids Fix achievement issues openwebwork#2281 and openwebwork#2279
- Loading branch information
Showing
19 changed files
with
166 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
(() => { | ||
for (const setSelect of document.querySelectorAll('select[data-problems]')) { | ||
setSelect.addEventListener('change', () => { | ||
const max = parseInt(Array.from(setSelect.querySelectorAll('option')) | ||
.find((option) => option.value === setSelect.value)?.dataset.max ?? '0'); | ||
const problemIds = JSON.parse( | ||
Array.from(setSelect.querySelectorAll('option')).find((option) => option.value === setSelect.value) | ||
?.dataset.problemIds ?? '[]' | ||
); | ||
|
||
document.querySelectorAll(`#${setSelect.dataset.problems} option`).forEach((option, index) => { | ||
option.style.display = index < max ? '' : 'none'; | ||
}); | ||
const problemSelect = document.getElementById(setSelect.dataset.problems); | ||
if (problemSelect) { | ||
for (const option of problemSelect.querySelectorAll('option')) option.remove(); | ||
for (const id of problemIds) { | ||
const option = document.createElement('option'); | ||
option.value = id; | ||
option.text = id; | ||
problemSelect.add(option); | ||
} | ||
} | ||
|
||
// This is only used by the "Box of Transmogrification". | ||
document.querySelectorAll(`#${setSelect.dataset.problems2} option`).forEach((option, index) => { | ||
option.style.display = index < max ? '' : 'none'; | ||
}); | ||
const problemSelect2 = document.getElementById(setSelect.dataset.problems2); | ||
if (problemSelect2) { | ||
for (const option of problemSelect2.querySelectorAll('option')) option.remove(); | ||
for (const id of problemIds) { | ||
const option = document.createElement('option'); | ||
option.value = id; | ||
option.text = id; | ||
problemSelect2.add(option); | ||
} | ||
} | ||
}); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.