diff --git a/course/report/stats/report.php b/course/report/stats/report.php index 65962dd596732..e13f06423b6f6 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.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')); diff --git a/lib/statslib.php b/lib/statslib.php index e987ff9558de8..8a499176ffd12 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -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; }