MDL-82001 mod_quiz: respect user language in draft save message text.

This commit is contained in:
Paul Holden 2024-05-23 11:32:54 +01:00
parent bcae2164ac
commit a49c099ae5
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
4 changed files with 34 additions and 19 deletions

View File

@ -428,12 +428,17 @@ M.mod_quiz.autosave = {
*/
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();
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(Date.now() / 1000),
format: M.util.get_string('strftimedatetimeshortaccurate', 'langconfig'),
}]).then(function(dateStrs) {
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
infoDiv.set('text', M.util.get_string('lastautosave', 'quiz', dateStrs[0]));
infoDiv.show();
return;
}).catch(Notification.exception);
});
},
is_time_nearly_over: function() {

File diff suppressed because one or more lines are too long

View File

@ -416,12 +416,17 @@ M.mod_quiz.autosave = {
*/
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();
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(Date.now() / 1000),
format: M.util.get_string('strftimedatetimeshortaccurate', 'langconfig'),
}]).then(function(dateStrs) {
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
infoDiv.set('text', M.util.get_string('lastautosave', 'quiz', dateStrs[0]));
infoDiv.show();
return;
}).catch(Notification.exception);
});
},
is_time_nearly_over: function() {

View File

@ -426,12 +426,17 @@ M.mod_quiz.autosave = {
*/
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();
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(Date.now() / 1000),
format: M.util.get_string('strftimedatetimeshortaccurate', 'langconfig'),
}]).then(function(dateStrs) {
var infoDiv = Y.one('#mod_quiz_navblock .othernav .autosave_info');
infoDiv.set('text', M.util.get_string('lastautosave', 'quiz', dateStrs[0]));
infoDiv.show();
return;
}).catch(Notification.exception);
});
},
is_time_nearly_over: function() {