diff --git a/mod/quiz/module.js b/mod/quiz/module.js index 46f5ab8b98f..8c5264dc508 100644 --- a/mod/quiz/module.js +++ b/mod/quiz/module.js @@ -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); diff --git a/question/qengine.js b/question/qengine.js index dc37efd7702..2b2298ee69a 100644 --- a/question/qengine.js +++ b/question/qengine.js @@ -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); }