This commit is contained in:
abgreeve 2021-06-03 09:40:43 +08:00
commit ef1d17c8ba
5 changed files with 37 additions and 7 deletions

View File

@ -756,6 +756,7 @@ M.form_dndupload.init = function(Y, options) {
e.preventDefault();
process_dlg.hide();
if (self.callbackcancel) {
this.triggerUploadCompleted();
self.callbackcancel();
}
}, this);
@ -794,13 +795,26 @@ M.form_dndupload.init = function(Y, options) {
// Destroy the dialog once it has been hidden.
process_dlg.after('visibleChange', function(e) {
if (!process_dlg.get('visible')) {
if (self.callbackcancel) {
this.triggerUploadCompleted();
self.callbackcancel();
}
process_dlg.destroy(true);
}
});
}, this);
process_dlg.show();
},
/**
* Trigger upload completed event.
*/
triggerUploadCompleted: function() {
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(this.filemanagerhelper.filemanager.get('id'));
}.bind(this));
},
/**
* Checks if there is already a file with the given name in the current folder
* or in the list of already uploading files

View File

@ -175,6 +175,12 @@ M.mod_quiz.nav.init = function(Y) {
// Automatically submit the form. We do it this strange way because just
// calling form.submit() does not run the form's submit event handlers.
var submit = form.one('input[name="next"]');
// Navigation when button enable.
if (submit.get('disabled')) {
return;
}
submit.set('name', '');
submit.getDOMNode().click();
};

View File

@ -536,7 +536,9 @@ class mod_quiz_renderer extends plugin_renderer_base {
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
if ($page > 0 && $navmethod == 'free') {
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'previous',
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary'));
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary',
'id' => 'mod_quiz-prev-nav'));
$this->page->requires->js_call_amd('core_form/submit', 'init', ['mod_quiz-prev-nav']);
}
if ($lastpage) {
$nextlabel = get_string('endtest', 'quiz');
@ -544,8 +546,9 @@ class mod_quiz_renderer extends plugin_renderer_base {
$nextlabel = get_string('navigatenext', 'quiz');
}
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next',
'value' => $nextlabel, 'class' => 'mod_quiz-next-nav btn btn-primary'));
'value' => $nextlabel, 'class' => 'mod_quiz-next-nav btn btn-primary', 'id' => 'mod_quiz-next-nav'));
$output .= html_writer::end_tag('div');
$this->page->requires->js_call_amd('core_form/submit', 'init', ['mod_quiz-next-nav']);
return $output;
}

View File

@ -256,12 +256,14 @@ echo $quba->render_question($slot, $options, $displaynumber);
echo html_writer::start_tag('div', array('id' => 'previewcontrols', 'class' => 'controls'));
echo html_writer::empty_tag('input', $restartdisabled + array('type' => 'submit',
'name' => 'restart', 'value' => get_string('restart', 'question'), 'class' => 'btn btn-secondary'));
echo html_writer::empty_tag('input', $finishdisabled + array('type' => 'submit',
'name' => 'save', 'value' => get_string('save', 'question'), 'class' => 'btn btn-secondary'));
echo html_writer::empty_tag('input', $finishdisabled + array('type' => 'submit',
'name' => 'save', 'value' => get_string('save', 'question'), 'class' => 'btn btn-secondary',
'id' => 'id_save_question_preview'));
echo html_writer::empty_tag('input', $filldisabled + array('type' => 'submit',
'name' => 'fill', 'value' => get_string('fillincorrect', 'question'), 'class' => 'btn btn-secondary'));
echo html_writer::empty_tag('input', $finishdisabled + array('type' => 'submit',
'name' => 'finish', 'value' => get_string('submitandfinish', 'question'), 'class' => 'btn btn-secondary'));
echo html_writer::empty_tag('input', $finishdisabled + array('type' => 'submit',
'name' => 'finish', 'value' => get_string('submitandfinish', 'question'), 'class' => 'btn btn-secondary',
'id' => 'id_finish_question_preview'));
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
@ -291,5 +293,7 @@ $PAGE->requires->strings_for_js(array(
'closepreview',
), 'question');
$PAGE->requires->yui_module('moodle-question-preview', 'M.question.preview.init');
$PAGE->requires->js_call_amd('core_form/submit', 'init', ['id_save_question_preview']);
$PAGE->requires->js_call_amd('core_form/submit', 'init', ['id_finish_question_preview']);
echo $OUTPUT->footer();

View File

@ -126,6 +126,9 @@ M.core_question_engine.questionformalreadysubmitted = false;
* @param button the id of the button in the HTML.
*/
M.core_question_engine.init_submit_button = function(Y, button) {
require(['core_form/submit'], function(submit) {
submit.init(button);
});
var totalQuestionsInPage = document.querySelectorAll('div.que').length;
var buttonel = document.getElementById(button);
var outeruniqueid = buttonel.closest('.que').id;