mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
fba3ea31bc
MDL-9451: Quiz answers can be lost if user navigates before page reloads. I am not totally sure I have fixed this, but I hope so. I moved the printing of the hidden form field with the list of questions on the page to the end of the form, so no answers will be processed unless the whole form loaded. Note that you could still lose data, but only if the page takes a really long time to load and you answer the first question and click submit before the whole quiz is loaded. MDL-11463: The quiz uses two different timers, which is silly. I have removed the javascript that was ocasionally used to put a timer in the browser's title bar. Now we only use the one in the page for all cases. Because MDL-8682 also needed javascript, I renamed timer.js to quiz.js so it could be a library of all the quiz's JavaScript, and started including it properly with require_js.
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php // $Id$
|
|
// QuizTimer main routines.
|
|
// This will produce a floating timer that counts
|
|
// how much time is left to answer the quiz.
|
|
//
|
|
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
var timesup = "<?php print_string("timesup","quiz");?>";
|
|
var quizclose = <?php echo ($quiz->timeclose - time()) - $timerstartvalue; ?>; // in seconds
|
|
var quizTimerValue = <?php echo $timerstartvalue; ?>; // in seconds
|
|
parseInt(quizTimerValue);
|
|
|
|
// @EC PF : client time when page was opened
|
|
var ec_page_start = new Date().getTime();
|
|
// @EC PF : client time when quiz should end
|
|
var ec_quiz_finish = ec_page_start + <?php echo ($timerstartvalue * 1000); ?>;
|
|
|
|
//]]>
|
|
</script>
|
|
<div id="timer">
|
|
<!--EDIT BELOW CODE TO YOUR OWN MENU-->
|
|
<table class="generalbox" border="0" cellpadding="0" cellspacing="0" style="width:150px;">
|
|
<tr>
|
|
<td class="generalboxcontent" bgcolor="#ffffff" width="100%">
|
|
<table class="generaltable" border="0" width="150" cellspacing="0" cellpadding="0">
|
|
<tr>
|
|
<th class="generaltableheader" width="100%" scope="col"><?php print_string("timeleft","quiz");?></th>
|
|
</tr>
|
|
<tr>
|
|
<td id="QuizTimer" class="generaltablecell" align="center" width="100%">
|
|
<form id="clock"><div><input onfocus="blur()" type="text" id="time"
|
|
style="background-color: transparent; border: none; width: 70%; font-family: sans-serif; font-size: 14pt; font-weight: bold; text-align: center;" />
|
|
</div>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<!--END OF EDIT-->
|
|
</div>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
|
|
var timerbox = document.getElementById('timer');
|
|
var theTimer = document.getElementById('QuizTimer');
|
|
var theTop = 100;
|
|
var old = theTop;
|
|
|
|
movecounter(timerbox);
|
|
|
|
document.onload = countdown_clock(theTimer);
|
|
//]]>
|
|
</script>
|