MDL-69165 Questions: Incorrect id used in init_submit_button function

This commit is contained in:
Huong Nguyen
2020-07-08 11:48:56 +07:00
parent 035f5d9423
commit 82ddfd7ea6
2 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -179,9 +179,9 @@ M.mod_quiz.nav.init = function(Y) {
pageno = 0;
}
var questionidmatch = this.get('href').match(/#q(\d+)/);
var questionidmatch = this.get('href').match(/#question-(\d+)-(\d+)/);
if (questionidmatch) {
form.set('action', form.get('action') + '#q' + questionidmatch[1]);
form.set('action', form.get('action') + questionidmatch[0]);
}
nav_to_page(pageno);
+6 -1
View File
@@ -127,10 +127,15 @@ M.core_question_engine.questionformalreadysubmitted = false;
* @param slot the number of the question_attempt within the usage.
*/
M.core_question_engine.init_submit_button = function(Y, button, slot) {
var totalQuestionsInPage = document.querySelectorAll('div.que').length;
var buttonel = document.getElementById(button);
var outeruniqueid = buttonel.closest('.que').id;
Y.on('click', function(e) {
M.core_scroll_manager.save_scroll_pos(Y, button);
buttonel.form.action = buttonel.form.action + '#q' + slot;
if (totalQuestionsInPage > 1) {
// Only change the form action if the page have more than one question.
buttonel.form.action = buttonel.form.action + '#' + outeruniqueid;
}
}, buttonel);
}