MOBILE-2567 quiz: Fix render offline answers in multichoice questions

main
Dani Palou 2018-09-07 09:03:19 +02:00
parent 2484605238
commit 081c1555a6
1 changed files with 11 additions and 2 deletions

View File

@ -465,10 +465,19 @@ export class CoreQuestionHelperProvider {
if (selected) { if (selected) {
selected.setAttribute('selected', 'selected'); selected.setAttribute('selected', 'selected');
} }
} else if (element.type == 'radio' || element.type == 'checkbox') { } else if (element.type == 'radio') {
// Check if this radio or checkbox is selected. // Check if this radio is selected.
if (element.value == question.localAnswers[name]) { if (element.value == question.localAnswers[name]) {
element.setAttribute('checked', 'checked'); element.setAttribute('checked', 'checked');
} else {
element.removeAttribute('checked');
}
} else if (element.type == 'checkbox') {
// Check if this checkbox is checked.
if (this.utils.isTrueOrOne(question.localAnswers[name])) {
element.setAttribute('checked', 'checked');
} else {
element.removeAttribute('checked');
} }
} else { } else {
// Put the answer in the value. // Put the answer in the value.