mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-67259_main' of https://github.com/PhilippImhof/moodle
This commit is contained in:
commit
e4bfa1498b
@ -100,6 +100,8 @@ if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
|
|||||||
// Set up auto-save if required.
|
// Set up auto-save if required.
|
||||||
$autosaveperiod = get_config('quiz', 'autosaveperiod');
|
$autosaveperiod = get_config('quiz', 'autosaveperiod');
|
||||||
if ($autosaveperiod) {
|
if ($autosaveperiod) {
|
||||||
|
$PAGE->requires->string_for_js('strftimedatetimeshortaccurate', 'langconfig');
|
||||||
|
$PAGE->requires->string_for_js('lastautosave', 'quiz');
|
||||||
$PAGE->requires->yui_module('moodle-mod_quiz-autosave',
|
$PAGE->requires->yui_module('moodle-mod_quiz-autosave',
|
||||||
'M.mod_quiz.autosave.init', [$autosaveperiod]);
|
'M.mod_quiz.autosave.init', [$autosaveperiod]);
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,15 @@ class navigation_panel_attempt extends navigation_panel_base {
|
|||||||
// Don't link from the summary page to itself.
|
// Don't link from the summary page to itself.
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return html_writer::link($this->attemptobj->summary_url(),
|
|
||||||
|
// We create a hidden div with an information message in order for the student
|
||||||
|
// to known when their answers have been auto-saved.
|
||||||
|
$html = html_writer::div(get_string('lastautosave', 'quiz', '-'), 'autosave_info', ['hidden' => 'hidden']);
|
||||||
|
|
||||||
|
$html .= html_writer::link($this->attemptobj->summary_url(),
|
||||||
get_string('endtest', 'quiz'), ['class' => 'endtestlink aalink']) .
|
get_string('endtest', 'quiz'), ['class' => 'endtestlink aalink']) .
|
||||||
$this->render_restart_preview_link($output);
|
$this->render_restart_preview_link($output);
|
||||||
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,6 +503,7 @@ $string['invalidsource'] = 'The source is not accepted as valid.';
|
|||||||
$string['invalidsourcetype'] = 'Invalid source type.';
|
$string['invalidsourcetype'] = 'Invalid source type.';
|
||||||
$string['invalidstateid'] = 'Invalid state id';
|
$string['invalidstateid'] = 'Invalid state id';
|
||||||
$string['lastanswer'] = 'Your last answer was';
|
$string['lastanswer'] = 'Your last answer was';
|
||||||
|
$string['lastautosave'] = 'Last saved: {$a}';
|
||||||
$string['layout'] = 'Layout';
|
$string['layout'] = 'Layout';
|
||||||
$string['layoutasshown'] = 'Page layout as shown.';
|
$string['layoutasshown'] = 'Page layout as shown.';
|
||||||
$string['layoutasshownwithpages'] = 'Page layout as shown. <small>(Automatic new page every {$a} questions.)</small>';
|
$string['layoutasshownwithpages'] = 'Page layout as shown. <small>(Automatic new page every {$a} questions.)</small>';
|
||||||
|
@ -188,6 +188,10 @@
|
|||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.path-mod-quiz .autosave_info {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
.path-mod-quiz .othernav a,
|
.path-mod-quiz .othernav a,
|
||||||
.path-mod-quiz .othernav input {
|
.path-mod-quiz .othernav input {
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -387,6 +387,8 @@ M.mod_quiz.autosave = {
|
|||||||
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update_saved_time_display();
|
||||||
|
|
||||||
Y.log('Save completed.', 'debug', 'moodle-mod_quiz-autosave');
|
Y.log('Save completed.', 'debug', 'moodle-mod_quiz-autosave');
|
||||||
this.save_transaction = null;
|
this.save_transaction = null;
|
||||||
|
|
||||||
@ -419,6 +421,21 @@ M.mod_quiz.autosave = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inform the user that their answers have been saved.
|
||||||
|
*
|
||||||
|
* @method update_saved_time_display
|
||||||
|
*/
|
||||||
|
update_saved_time_display: function() {
|
||||||
|
// We fetch the current language's preferred time format from the language pack.
|
||||||
|
var timeFormat = M.util.get_string('strftimedatetimeshortaccurate', 'langconfig');
|
||||||
|
var message = M.util.get_string('lastautosave', 'quiz', Y.Date.format(new Date(), {'format': timeFormat}));
|
||||||
|
|
||||||
|
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
|
||||||
|
infoDiv.set('text', message);
|
||||||
|
infoDiv.show();
|
||||||
|
},
|
||||||
|
|
||||||
is_time_nearly_over: function() {
|
is_time_nearly_over: function() {
|
||||||
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
||||||
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
||||||
@ -434,4 +451,14 @@ M.mod_quiz.autosave = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}, '@VERSION@', {"requires": ["base", "node", "event", "event-valuechange", "node-event-delegate", "io-form"]});
|
}, '@VERSION@', {
|
||||||
|
"requires": [
|
||||||
|
"base",
|
||||||
|
"node",
|
||||||
|
"event",
|
||||||
|
"event-valuechange",
|
||||||
|
"node-event-delegate",
|
||||||
|
"io-form",
|
||||||
|
"datatype-date-format"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
File diff suppressed because one or more lines are too long
@ -378,6 +378,8 @@ M.mod_quiz.autosave = {
|
|||||||
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update_saved_time_display();
|
||||||
|
|
||||||
this.save_transaction = null;
|
this.save_transaction = null;
|
||||||
|
|
||||||
if (this.dirty) {
|
if (this.dirty) {
|
||||||
@ -407,6 +409,21 @@ M.mod_quiz.autosave = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inform the user that their answers have been saved.
|
||||||
|
*
|
||||||
|
* @method update_saved_time_display
|
||||||
|
*/
|
||||||
|
update_saved_time_display: function() {
|
||||||
|
// We fetch the current language's preferred time format from the language pack.
|
||||||
|
var timeFormat = M.util.get_string('strftimedatetimeshortaccurate', 'langconfig');
|
||||||
|
var message = M.util.get_string('lastautosave', 'quiz', Y.Date.format(new Date(), {'format': timeFormat}));
|
||||||
|
|
||||||
|
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
|
||||||
|
infoDiv.set('text', message);
|
||||||
|
infoDiv.show();
|
||||||
|
},
|
||||||
|
|
||||||
is_time_nearly_over: function() {
|
is_time_nearly_over: function() {
|
||||||
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
||||||
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
||||||
@ -422,4 +439,14 @@ M.mod_quiz.autosave = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}, '@VERSION@', {"requires": ["base", "node", "event", "event-valuechange", "node-event-delegate", "io-form"]});
|
}, '@VERSION@', {
|
||||||
|
"requires": [
|
||||||
|
"base",
|
||||||
|
"node",
|
||||||
|
"event",
|
||||||
|
"event-valuechange",
|
||||||
|
"node-event-delegate",
|
||||||
|
"io-form",
|
||||||
|
"datatype-date-format"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
17
mod/quiz/yui/src/autosave/js/autosave.js
vendored
17
mod/quiz/yui/src/autosave/js/autosave.js
vendored
@ -385,6 +385,8 @@ M.mod_quiz.autosave = {
|
|||||||
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
M.mod_quiz.timer.updateEndTime(autosavedata.timeleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update_saved_time_display();
|
||||||
|
|
||||||
Y.log('Save completed.', 'debug', 'moodle-mod_quiz-autosave');
|
Y.log('Save completed.', 'debug', 'moodle-mod_quiz-autosave');
|
||||||
this.save_transaction = null;
|
this.save_transaction = null;
|
||||||
|
|
||||||
@ -417,6 +419,21 @@ M.mod_quiz.autosave = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inform the user that their answers have been saved.
|
||||||
|
*
|
||||||
|
* @method update_saved_time_display
|
||||||
|
*/
|
||||||
|
update_saved_time_display: function() {
|
||||||
|
// We fetch the current language's preferred time format from the language pack.
|
||||||
|
var timeFormat = M.util.get_string('strftimedatetimeshortaccurate', 'langconfig');
|
||||||
|
var message = M.util.get_string('lastautosave', 'quiz', Y.Date.format(new Date(), {'format': timeFormat}));
|
||||||
|
|
||||||
|
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
|
||||||
|
infoDiv.set('text', message);
|
||||||
|
infoDiv.show();
|
||||||
|
},
|
||||||
|
|
||||||
is_time_nearly_over: function() {
|
is_time_nearly_over: function() {
|
||||||
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
return M.mod_quiz.timer && M.mod_quiz.timer.endtime &&
|
||||||
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
(new Date().getTime() + 2 * this.delay) > M.mod_quiz.timer.endtime;
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
"event",
|
"event",
|
||||||
"event-valuechange",
|
"event-valuechange",
|
||||||
"node-event-delegate",
|
"node-event-delegate",
|
||||||
"io-form"
|
"io-form",
|
||||||
|
"datatype-date-format"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user