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.
Fix problem ids displayed for achievement items.
Instead of just storing a max problem id for each achievement set option, store the json encoded list of problem ids. Initially only the options for the first set are provided. The javascript then rebuilds the options list when a new set is selected that only includes the problem ids for that set. This also restructures the way that achievement item data is obtained from the database to be a bit more efficient. When this data is obtained gateway tests are no longer filtered out. The current code for each achievement item that does not act on gateway tests is already set up to filter these out. The achievement items that do act on gateway tests no longer need to load data from the database on their own. They can use the given list and filter out non-gateway sets. There seems to have been a minor bug in the `ResurrectGW` achievement in that it showed all gateway sets to be possibly "resurrected" when it should only show gateway sets that are past due. That has also been fixed, so now it only shows past due gateway sets for "resurrection". This fixes issue openwebwork#2281.
- Loading branch information
Showing
19 changed files
with
118 additions
and
121 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
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.