Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CheckboxList part answers of a RadioMultiAnswer. #930

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions htdocs/js/RadioMultiAnswer/RadioMultiAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
// If MathQuill is enabled, then this will be the MathQuill input.
const answerInputs = [document.getElementById(`mq-answer-${answerRule}`) ?? input];

// If this is a radio answer, then save the other radio inputs so they can be also be disabled/enabled
// appropriately depending on which radio input in the radio multianswer group is selected.
if (input.type && input.type.toLowerCase() == 'radio') {
// If this is a radio or checkbox answer, then save the other radio or checkbox inputs so they can be also
// be disabled/enabled appropriately depending on which radio input in the radio multianswer group is
// selected.
const type = input.type?.toLowerCase();
if (type && (type === 'radio' || type === 'checkbox')) {
answerInputs.push(
...Array.from(document.querySelectorAll(`input[type="radio"][name="${answerRule}"]`)).filter(
(radio) => radio.id !== answerRule
...Array.from(document.querySelectorAll(`input[type="${type}"][name="${answerRule}"]`)).filter(
(input) => input.id !== answerRule
)
);
}
Expand Down