Permalink
Browse files

MDL-15198 "non-standard sql in reportlib.php" using CASE statement to…

… wrap logic in fields list
  • Loading branch information...
1 parent cac9213 commit 65143620aa03ab83aaf757bc42ee5874ba00e4ee jamiesensei committed Jul 20, 2008
Showing with 10 additions and 3 deletions.
  1. +10 −3 mod/quiz/report/overview/report.php
@@ -328,9 +328,16 @@ function display($quiz, $cm, $course) {
// Construct the SQL
- $select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, '.
- ($qmsubselect?$qmsubselect.' AS gradedattempt, ':'').
- 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, '.
+ $select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, ';
+ if ($qmsubselect) {
+ $select .=
+ "(CASE " .
+ " WHEN $qmsubselect THEN 1" .
+ " ELSE 0 " .
+ "END) AS gradedattempt, ";
+ }
+
+ $select .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
// This part is the same for all cases - join users and quiz_attempts tables

0 comments on commit 6514362

Please sign in to comment.