]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15198 "non-standard sql in reportlib.php" using CASE statement to wrap logic...
authorjamiesensei <jamiesensei>
Sun, 20 Jul 2008 12:52:14 +0000 (12:52 +0000)
committerjamiesensei <jamiesensei>
Sun, 20 Jul 2008 12:52:14 +0000 (12:52 +0000)
mod/quiz/report/overview/report.php

index c436508de4673ab8ea6871be07f36a9a8b6e3fbe..9a467544c95b7e2db23379abab7c9a8afd2fb17f 100644 (file)
@@ -247,9 +247,16 @@ class quiz_overview_report extends quiz_default_report {
     
     
             // Construct the SQL
-            $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, '.
-                ($qmsubselect?"($qmsubselect) AS gradedattempt, ":'').
-                'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
+            $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 .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
                 'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, '.
                 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';