MOBILE-2567 quiz: Fix single multichoice without answer

main
Dani Palou 2018-09-06 12:39:54 +02:00
parent 97bb43604b
commit 3fe4d02bc1
2 changed files with 22 additions and 0 deletions

View File

@ -7,4 +7,8 @@ ion-app.app-root page-addon-mod-quiz-player {
.core-has-fixed-timer form {
padding-top: 56px;
}
.toolbar-ios .bar-buttons-ios .bar-button {
@include padding-horizontal($content-padding);
}
}

View File

@ -151,4 +151,22 @@ export class AddonQtypeMultichoiceHandler implements CoreQuestionHandler {
isSameResponseSingle(prevAnswers: any, newAnswers: any): boolean {
return this.utils.sameAtKeyMissingIsBlank(prevAnswers, newAnswers, 'answer');
}
/**
* Prepare and add to answers the data to send to server based in the input. Return promise if async.
*
* @param {any} question Question.
* @param {any} answers The answers retrieved from the form. Prepared answers must be stored in this object.
* @param {boolean} [offline] Whether the data should be saved in offline.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {void|Promise<any>} Return a promise resolved when done if async, void if sync.
*/
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
sending an empty string (default value) will mark the first option as selected. */
delete answers[question.optionsName];
delete answers[question.optionsName.replace('answer', ':sequencecheck')];
}
}
}