Skip to content

Commit

Permalink
statistics MDL-25822 Fix get_records_sql returning non-unique first c…
Browse files Browse the repository at this point in the history
…olumn
  • Loading branch information
danpoltawski committed Dec 30, 2010
1 parent 5b90396 commit f9c2702
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion course/report/stats/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 2 additions & 2 deletions lib/statslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f9c2702

Please sign in to comment.