mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 20:06:46 +02:00
Merge branch 'MDL-77127_master' of https://github.com/PhilippImhof/moodle
This commit is contained in:
commit
3849e57d52
3 changed files with 34 additions and 0 deletions
|
@ -1620,6 +1620,8 @@ function quiz_get_js_module() {
|
||||||
['functiondisabledbysecuremode', 'quiz'],
|
['functiondisabledbysecuremode', 'quiz'],
|
||||||
['startattempt', 'quiz'],
|
['startattempt', 'quiz'],
|
||||||
['timesup', 'quiz'],
|
['timesup', 'quiz'],
|
||||||
|
['show', 'moodle'],
|
||||||
|
['hide', 'moodle'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,34 @@ M.mod_quiz.timer = {
|
||||||
require(['core_form/changechecker'], function(FormChangeChecker) {
|
require(['core_form/changechecker'], function(FormChangeChecker) {
|
||||||
M.mod_quiz.timer.FormChangeChecker = FormChangeChecker;
|
M.mod_quiz.timer.FormChangeChecker = FormChangeChecker;
|
||||||
});
|
});
|
||||||
|
Y.one('#toggle-timer').on('click', function() {
|
||||||
|
M.mod_quiz.timer.toggleVisibility();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide or show the timer.
|
||||||
|
* @param {boolean} whether we are ultimately displaying the timer and disabling the button
|
||||||
|
*/
|
||||||
|
toggleVisibility: function(finalShow = false) {
|
||||||
|
var Y = M.mod_quiz.timer.Y;
|
||||||
|
var timer = Y.one('#quiz-time-left');
|
||||||
|
var button = Y.one('#toggle-timer');
|
||||||
|
|
||||||
|
// When time is running out, we show the timer and disable the button.
|
||||||
|
if (finalShow) {
|
||||||
|
timer.show();
|
||||||
|
button.setContent(M.util.get_string('hide', 'moodle'));
|
||||||
|
button.setAttribute('disabled', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer.toggleView();
|
||||||
|
if (timer.getAttribute('hidden') === 'hidden') {
|
||||||
|
button.setContent(M.util.get_string('show', 'moodle'));
|
||||||
|
} else {
|
||||||
|
button.setContent(M.util.get_string('hide', 'moodle'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,6 +157,7 @@ M.mod_quiz.timer = {
|
||||||
Y.one('#quiz-timer').removeClass('timeleft' + (secondsleft + 2))
|
Y.one('#quiz-timer').removeClass('timeleft' + (secondsleft + 2))
|
||||||
.removeClass('timeleft' + (secondsleft + 1))
|
.removeClass('timeleft' + (secondsleft + 1))
|
||||||
.addClass('timeleft' + secondsleft);
|
.addClass('timeleft' + secondsleft);
|
||||||
|
M.mod_quiz.timer.toggleVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the time display.
|
// Update the time display.
|
||||||
|
|
|
@ -28,4 +28,7 @@
|
||||||
{{#str}} timeleft, quiz {{/str}}
|
{{#str}} timeleft, quiz {{/str}}
|
||||||
<span id="quiz-time-left"></span>
|
<span id="quiz-time-left"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" class="btn btn-secondary btn-small" id="toggle-timer" aria-controls="quiz-timer" aria-describedby="quiz-timer">
|
||||||
|
{{#str}} hide, core {{/str}}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue