quiz reports MDL-21111 Quiz duration is reported in years if Time Finish is before...
authorTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 5 Aug 2010 12:43:13 +0000 (12:43 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 5 Aug 2010 12:43:13 +0000 (12:43 +0000)
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.)

mod/quiz/report/overview/overview_table.php
mod/quiz/report/responses/responses_table.php

index 0e1a261..623aaf8 100644 (file)
@@ -161,7 +161,7 @@ class quiz_report_overview_table extends table_sql {
 
     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 {
index 6890002..d44b380 100644 (file)
@@ -116,13 +116,14 @@ class quiz_report_responses_table extends table_sql {
 
     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);