MDL-58577 stats: Use multilang with role in header

This commit is contained in:
Luca Bösch
2017-05-23 11:12:22 +02:00
committed by =
parent df6749b03b
commit e4eab531bf
2 changed files with 28 additions and 10 deletions
+9 -4
View File
@@ -1156,8 +1156,12 @@ function stats_get_parameters($time,$report,$courseid,$mode,$roleid=0) {
case STATS_REPORT_ACTIVITYBYROLE;
$param->fields = 'stat1 AS line1, stat2 AS line2';
$param->stattype = 'activity';
$role = $DB->get_record('role', array('id' => $roleid));
$rolename = role_get_name($role, context_course::instance($courseid));
$rolename = '';
if ($roleid <> 0) {
if ($role = $DB->get_record('role', ['id' => $roleid])) {
$rolename = role_get_name($role, context_course::instance($courseid)) . ' ';
}
}
$param->line1 = $rolename . get_string('statsreads');
$param->line2 = $rolename . get_string('statswrites');
if ($courseid == SITEID) {
@@ -1397,11 +1401,12 @@ 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 = context_course::instance($courseid)) {
$sql = 'SELECT r.id, r.name FROM {role} r JOIN {stats_daily} s ON s.roleid = r.id WHERE s.courseid = :courseid GROUP BY r.id, r.name';
$sql = 'SELECT r.id, r.name, r.shortname FROM {role} r JOIN {stats_daily} s ON s.roleid = r.id
WHERE s.courseid = :courseid GROUP BY r.id, r.name';
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).
' ' . format_string($role->name, true, ['context' => $context]);
' ' . role_get_name($role, $context);
}
}
}