Permalink
Browse files

fix MDL-13047 in which an invalid SQL was generated when the were no …

…attempts which match the conditions for the required HotPot report
  • Loading branch information...
1 parent 4855134 commit 0ee8a5280e015c1e9a0a82854805b0ced2276e32 gbateson committed Jan 21, 2008
Showing with 14 additions and 5 deletions.
  1. +14 −5 mod/hotpot/report.php
View
@@ -193,15 +193,24 @@
$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') {

0 comments on commit 0ee8a52

Please sign in to comment.