Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-26416' of git://github.com/timhunt/moodle

  • Loading branch information...
commit 0797530336368a91cc0c7af18aa66a2d94ef2939 2 parents c5530f4 + 19a9f11
@stronk7 stronk7 authored
Showing with 24 additions and 9 deletions.
  1. +24 −9 mod/quiz/report/overview/report.php
View
33 mod/quiz/report/overview/report.php
@@ -202,18 +202,33 @@ function display($quiz, $cm, $course) {
if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) {
// Construct the SQL
- $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, 0)').' AS uniqueid, ';
+ $fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(qa.attempt, 0)') . ' AS uniqueid,';
if ($qmsubselect) {
- $fields .=
- "(CASE " .
- " WHEN $qmsubselect THEN 1" .
- " ELSE 0 " .
- "END) AS gradedattempt, ";
+ $fields .= "\n(CASE WHEN $qmsubselect THEN 1 ELSE 0 END) AS gradedattempt,";
}
- $fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
- 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email, '.
- 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
+ $fields .= '
+ qa.uniqueid AS attemptuniqueid,
+ qa.id AS attempt,
+ u.id AS userid,
+ u.idnumber,
+ u.firstname,
+ u.lastname,
+ u.picture,
+ u.imagealt,
+ u.email,
+ qa.sumgrades,
+ qa.timefinish,
+ qa.timestart,
+ 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 = '{user} u ';
Please sign in to comment.
Something went wrong with that request. Please try again.