Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/lab/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@
</tr>
<tr>
<th align="left">&nbsp;Total '.$no_ques.' questions</th>
<th align="right">Time spent ';
<th id="time" align="right">Time spent ';
printf("%02d:%02d",(int)($curr_time/60),($curr_time%60));
echo '&nbsp;</th>
</tr></table>

</form>
';
';

} else {
$c_answers=0;
Expand Down Expand Up @@ -204,6 +202,28 @@


?>
<script>
var timeLabel = document.getElementById("time");
var totalSeconds = <?php echo $curr_time ?>;
setInterval(setTime, 1000);
function resetTime(){
totalSeconds = 0;
}
function setTime() {
++totalSeconds;
secondsLabel = pad(totalSeconds % 60);
minutesLabel = pad(parseInt(totalSeconds / 60));
timeLabel.innerHTML = 'Time Spent ' + minutesLabel + ':' + secondsLabel
}
function pad(val) {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}
</script>
</div>
</div>
</body>