]> git.mjollnir.org Git - moodle.git/commitdiff
fix MDL-13047 in which an invalid SQL query was run if no attempts were foudn to...
authorgbateson <gbateson>
Mon, 21 Jan 2008 08:13:46 +0000 (08:13 +0000)
committergbateson <gbateson>
Mon, 21 Jan 2008 08:13:46 +0000 (08:13 +0000)
mod/hotpot/report.php

index faa66f7e72861891a05cd66f23eae13c70305d17..db8c0fc65c6ad936a5708376b88a28a8ee37a816 100644 (file)
         $groupby = 'userid';
         $records = hotpot_get_records_groupby($function, $fieldnames, $table, $select, $groupby);
 
-        $ids = array();
-        foreach ($records as $record) {
-            $ids[] = $record->clickreportid;
+        $select = '';
+        if ($records) {
+            $ids = array();
+            foreach ($records as $record) {
+                $ids[] = $record->clickreportid;
+            }
+            if (count($ids)) {
+                $select = "a.clickreportid IN (".join(',', $ids).")";
+            }
         }
-        $select = "a.clickreportid IN (".join(',', $ids).")";
     }
 
     // pick out last attempt in each clickreport series
-    $cr_attempts = hotpot_get_records_groupby('MAX', array('timefinish', 'id'), $table, $select, 'clickreportid');
+    if ($select) {
+        $cr_attempts = hotpot_get_records_groupby('MAX', array('timefinish', 'id'), $table, $select, 'clickreportid');
+    } else {
+        $cr_attempts = array();
+    }
 
     $fields = 'a.*, u.firstname, u.lastname, u.picture';
     if ($mode=='click') {