mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-71961 Quiz: Disable quiz navigation buttons when files are uploading
This commit is contained in:
parent
1d700796ca
commit
95a82a9f2e
@ -154,6 +154,32 @@ M.mod_quiz.timer = {
|
||||
}
|
||||
};
|
||||
|
||||
M.mod_quiz.filesUpload = {
|
||||
/**
|
||||
* YUI object.
|
||||
*/
|
||||
Y: null,
|
||||
|
||||
/**
|
||||
* Number of files uploading.
|
||||
*/
|
||||
numberFilesUploading: 0,
|
||||
|
||||
/**
|
||||
* Disable navigation block when uploading and enable navigation block when all files are uploaded.
|
||||
*/
|
||||
disableNavPanel: function() {
|
||||
var quizNavigationBlock = document.getElementById('mod_quiz_navblock');
|
||||
if (quizNavigationBlock) {
|
||||
if (M.mod_quiz.filesUpload.numberFilesUploading) {
|
||||
quizNavigationBlock.classList.add('nav-disabled');
|
||||
} else {
|
||||
quizNavigationBlock.classList.remove('nav-disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
M.mod_quiz.nav = M.mod_quiz.nav || {};
|
||||
|
||||
M.mod_quiz.nav.update_flag_state = function(attemptid, questionid, newstate) {
|
||||
@ -181,12 +207,6 @@ 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();
|
||||
};
|
||||
@ -222,6 +242,19 @@ M.mod_quiz.nav.init = function(Y) {
|
||||
}, 'a.endtestlink');
|
||||
}
|
||||
|
||||
// Navigation buttons should be disabled when the files are uploading.
|
||||
require(['core_form/events'], function(formEvent) {
|
||||
document.addEventListener(formEvent.eventTypes.uploadStarted, function() {
|
||||
M.mod_quiz.filesUpload.numberFilesUploading++;
|
||||
M.mod_quiz.filesUpload.disableNavPanel();
|
||||
});
|
||||
|
||||
document.addEventListener(formEvent.eventTypes.uploadCompleted, function() {
|
||||
M.mod_quiz.filesUpload.numberFilesUploading--;
|
||||
M.mod_quiz.filesUpload.disableNavPanel();
|
||||
});
|
||||
});
|
||||
|
||||
if (M.core_question_flags) {
|
||||
M.core_question_flags.add_listener(M.mod_quiz.nav.update_flag_state);
|
||||
}
|
||||
|
@ -196,6 +196,12 @@
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
#mod_quiz_navblock.nav-disabled > * {
|
||||
opacity: .65;
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/** mod quiz mod **/
|
||||
#page-mod-quiz-mod #id_reviewoptionshdr .fitem {
|
||||
width: 23%;
|
||||
|
Loading…
x
Reference in New Issue
Block a user