Merge pull request #1632 from dpalou/MOBILE-2743
MOBILE-2743 quiz: Fix first option selected when checking answermain
commit
b580aca8b5
|
@ -166,14 +166,17 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy {
|
|||
behaviourButtonClicked(button: any): void {
|
||||
// Confirm that the user really wants to do it.
|
||||
this.domUtils.showConfirm(this.translate.instant('core.areyousure')).then(() => {
|
||||
const modal = this.domUtils.showModalLoading('core.sending', true),
|
||||
answers = this.getAnswers();
|
||||
const modal = this.domUtils.showModalLoading('core.sending', true);
|
||||
|
||||
// Add the clicked button data.
|
||||
answers[button.name] = button.value;
|
||||
// Get the answers.
|
||||
return this.prepareAnswers().then((answers) => {
|
||||
|
||||
// Behaviour checks are always in online.
|
||||
return this.quizProvider.processAttempt(this.quiz, this.attempt, answers, this.preflightData).then(() => {
|
||||
// Add the clicked button data.
|
||||
answers[button.name] = button.value;
|
||||
|
||||
// Behaviour checks are always in online.
|
||||
return this.quizProvider.processAttempt(this.quiz, this.attempt, answers, this.preflightData);
|
||||
}).then(() => {
|
||||
this.reloadNavigaton = true; // Data sent to server, navigation should be reloaded.
|
||||
|
||||
// Reload the current page.
|
||||
|
|
|
@ -163,10 +163,9 @@ export class AddonQtypeMultichoiceHandler implements CoreQuestionHandler {
|
|||
*/
|
||||
prepareAnswers(question: any, answers: any, offline: boolean, siteId?: string): void | Promise<any> {
|
||||
if (question && !question.multi && typeof answers[question.optionsName] != 'undefined' && !answers[question.optionsName]) {
|
||||
/* It's a single choice and the user hasn't answered. Delete the answer and its sequencecheck because
|
||||
/* It's a single choice and the user hasn't answered. Delete the answer because
|
||||
sending an empty string (default value) will mark the first option as selected. */
|
||||
delete answers[question.optionsName];
|
||||
delete answers[question.optionsName.replace('answer', ':sequencecheck')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue