Suppose you have two load-balanced servers with badly-synchronised clocks, and
a student does a really quick quiz attempt.
Then it is possible that quiz_attemtp.timestart is greater than quiz_attemtp.timefinish.
And these columns are unsigned (on MySQL) so timefinish - timestart is compulted as
a number close to 2^64, which is about 42 times the age of the universe.
Do the subtraction in PHP instead. (But we still need to compute a duration columnin PHP
because sometimes we sort on it.)
function col_duration($attempt){
if ($attempt->timefinish) {
- return format_time($attempt->duration);
+ return format_time($attempt->timefinish - $attempt->timestart);
} elseif ($attempt->timestart) {
return get_string('unfinished', 'quiz');
} else {
function col_duration($attempt){
if ($attempt->timefinish) {
- return format_time($attempt->duration);
+ return format_time($attempt->timefinish - $attempt->timestart);
} elseif ($attempt->timestart) {
return get_string('unfinished', 'quiz');
} else {
return '-';
}
}
+
function col_sumgrades($attempt){
if ($attempt->timefinish) {
$grade = quiz_rescale_grade($attempt->sumgrades, $this->quiz);