Merge pull request #1866 from dpalou/MOBILE-2817

Mobile 2817
main
Juan Leyva 2019-04-30 20:59:40 +02:00 committed by GitHub
commit dd5a5fc1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 4 deletions

View File

@ -570,10 +570,15 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy {
// Button to continue.
if (this.lesson.review && !result.correctanswer && !result.noanswer && !result.isessayquestion &&
!result.maxattemptsreached) {
this.processData.buttons.push({
label: 'addon.mod_lesson.reviewquestioncontinue',
pageId: result.newpageid
});
/* If both the "Yes, I'd like to try again" and "No, I just want to go on to the next question" point to the
same page then don't show the "No, I just want to go on to the next question" button. It's confusing. */
if (this.pageData.page.id != result.newpageid) {
// Button to continue the lesson (the page to go is configured by the teacher).
this.processData.buttons.push({
label: 'addon.mod_lesson.reviewquestioncontinue',
pageId: result.newpageid
});
}
} else {
this.processData.buttons.push({
label: 'addon.mod_lesson.continue',

View File

@ -156,6 +156,8 @@ export class AddonModLessonProvider {
*/
static MULTIANSWER_DELIMITER = '@^#|';
static LESSON_OTHER_ANSWERS = '@#wronganswer#@';
// Variables for database.
static PASSWORD_TABLE = 'addon_mod_lesson_password';
protected siteSchema: CoreSiteSchema = {
@ -793,6 +795,8 @@ export class AddonModLessonProvider {
break;
}
}
this.checkOtherAnswers(lesson, pageData, result);
}
/**
@ -907,6 +911,8 @@ export class AddonModLessonProvider {
}
}
this.checkOtherAnswers(lesson, pageData, result);
result.userresponse = studentAnswer;
result.studentanswer = this.textUtils.s(studentAnswer); // Clean student answer as it goes to output.
}
@ -945,6 +951,33 @@ export class AddonModLessonProvider {
}
}
/**
* Check the "other answers" value.
*
* @param {any} lesson Lesson.
* @param {any} pageData Result of getPageData for the page to process.
* @param {AddonModLessonCheckAnswerResult} result Object where to store the result.
*/
protected checkOtherAnswers(lesson: any, pageData: any, result: AddonModLessonCheckAnswerResult): void {
// We could check here to see if we have a wrong answer jump to use.
if (result.answerid == 0) {
// Use the all other answers jump details if it is set up.
const lastAnswer = pageData.answers[pageData.answers.length - 1] || {};
// Double check that this is the OTHER_ANSWERS answer.
if (typeof lastAnswer.answer == 'string' &&
lastAnswer.answer.indexOf(AddonModLessonProvider.LESSON_OTHER_ANSWERS) != -1) {
result.newpageid = lastAnswer.jumpto;
result.response = lastAnswer.response;
if (lesson.custom) {
result.correctanswer = lastAnswer.score > 0;
}
result.answerid = lastAnswer.id;
}
}
}
/**
* Create a list of pages indexed by page ID based on a list of pages.
*