MDL-26416 avoid subtracting two unsigned ints, which breaks MySQL since 5.5.5.
This commit is contained in:
@@ -149,7 +149,7 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
$fields .= "\n(CASE WHEN $qmsubselect THEN 1 ELSE 0 END) AS gradedattempt,";
|
||||
}
|
||||
|
||||
$fields .= "
|
||||
$fields .= '
|
||||
quiza.uniqueid AS usageid,
|
||||
quiza.id AS attempt,
|
||||
u.id AS userid,
|
||||
@@ -164,7 +164,15 @@ abstract class quiz_attempt_report extends quiz_default_report {
|
||||
quiza.sumgrades,
|
||||
quiza.timefinish,
|
||||
quiza.timestart,
|
||||
quiza.timefinish - quiza.timestart AS duration";
|
||||
CASE WHEN qa.timefinish = 0 THEN null
|
||||
WHEN qa.timefinish > qa.timestart THEN qa.timefinish - qa.timestart
|
||||
ELSE 0 END AS duration';
|
||||
// To explain that last bit, in MySQL, qa.timestart and qa.timefinish
|
||||
// are unsigned. Since MySQL 5.5.5, when they introduced strict mode,
|
||||
// subtracting a larger unsigned int from a smaller one gave an error.
|
||||
// Therefore, we avoid doing that. timefinish can be non-zero and less
|
||||
// than timestart when you have two load-balanced servers with very
|
||||
// badly synchronised clocks, and a student does a really quick attempt.';
|
||||
|
||||
// This part is the same for all cases - join users and quiz_attempts tables
|
||||
$from = "\n{user} u";
|
||||
|
||||
Reference in New Issue
Block a user