Permalink
Browse files

statistics MDL-25822 Fix get_records_sql returning non-unique first c…

…olumn
  • Loading branch information...
1 parent 5b90396 commit f9c2702ece64feaa0d2895ec608c4ca805c95045 @danpoltawski danpoltawski committed Dec 30, 2010
Showing with 3 additions and 3 deletions.
  1. +1 −1 course/report/stats/report.php
  2. +2 −2 lib/statslib.php
@@ -98,7 +98,7 @@
.' ORDER BY timeend DESC';
}
- $stats = $DB->get_records_sql($sql, $params);
+ $stats = $DB->get_records_sql($sql);
if (empty($stats)) {
echo $OUTPUT->notification(get_string('statsnodata'));
View
@@ -1333,8 +1333,8 @@ function stats_get_report_options($courseid,$mode) {
case STATS_MODE_GENERAL:
$reportoptions[STATS_REPORT_ACTIVITY] = get_string('statsreport'.STATS_REPORT_ACTIVITY);
if ($courseid != SITEID && $context = get_context_instance(CONTEXT_COURSE, $courseid)) {
- $sql = 'SELECT r.id,r.name FROM {role} r JOIN {stats_daily} s ON s.roleid = r.id WHERE s.courseid = '.$courseid;
- if ($roles = $DB->get_records_sql($sql)) {
+ $sql = 'SELECT r.id, r.name FROM {role} r JOIN {stats_daily} s ON s.roleid = r.id WHERE s.courseid = :courseid GROUP BY s.roleid';
+ if ($roles = $DB->get_records_sql($sql, array('courseid' => $courseid))) {
foreach ($roles as $role) {
$reportoptions[STATS_REPORT_ACTIVITYBYROLE.$role->id] = get_string('statsreport'.STATS_REPORT_ACTIVITYBYROLE). ' '.$role->name;
}

0 comments on commit f9c2702

Please sign in to comment.