Merge branch 'MDL-69165-master' of https://github.com/HuongNV13/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2020-07-15 23:42:35 +02:00 committed by Sara Arjona
commit 5a32562f82
5 changed files with 18 additions and 8 deletions

View File

@ -194,9 +194,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);

View File

@ -66,7 +66,7 @@ class qbehaviour_interactive_renderer extends qbehaviour_renderer {
$output = html_writer::empty_tag('input', $attributes);
if (empty($attributes['disabled'])) {
$this->page->requires->js_init_call('M.core_question_engine.init_submit_button',
array($attributes['id'], $qa->get_slot()));
array($attributes['id']));
}
return $output;
}

View File

@ -243,7 +243,7 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
$output = html_writer::empty_tag('input', $attributes);
if (!$options->readonly) {
$this->page->requires->js_init_call('M.core_question_engine.init_submit_button',
array($attributes['id'], $qa->get_slot()));
array($attributes['id']));
}
return $output;
}

View File

@ -1,5 +1,11 @@
This files describes API changes for question behaviour plugins.
=== 4.0 ===
1) The slot parameter of method M.core_question_engine.init_submit_button now removed.
The method will get the unique id by using the 'Check' button element.
=== 3.1 ===
1) The standard behaviours that use a 'Check' button have all been changed so

View File

@ -123,14 +123,18 @@ M.core_question_engine.questionformalreadysubmitted = false;
/**
* Initialise a question submit button. This saves the scroll position and
* sets the fragment on the form submit URL so the page reloads in the right place.
* @param id the id of the button in the HTML.
* @param slot the number of the question_attempt within the usage.
* @param button the id of the button in the HTML.
*/
M.core_question_engine.init_submit_button = function(Y, button, slot) {
M.core_question_engine.init_submit_button = function(Y, button) {
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);
}