diff --git a/src/addon/mod/quiz/pages/player/player.ts b/src/addon/mod/quiz/pages/player/player.ts index 611fc59e9..5d91f73e6 100644 --- a/src/addon/mod/quiz/pages/player/player.ts +++ b/src/addon/mod/quiz/pages/player/player.ts @@ -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. diff --git a/src/addon/qtype/multichoice/providers/handler.ts b/src/addon/qtype/multichoice/providers/handler.ts index b543e3d97..440ab80e8 100644 --- a/src/addon/qtype/multichoice/providers/handler.ts +++ b/src/addon/qtype/multichoice/providers/handler.ts @@ -163,10 +163,9 @@ export class AddonQtypeMultichoiceHandler implements CoreQuestionHandler { */ prepareAnswers(question: any, answers: any, offline: boolean, siteId?: string): void | Promise { 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')]; } } }