mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-58577-statistics-report-header-multilang' of https://github.com/lucaboesch/moodle
This commit is contained in:
commit
1c74ec835b
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
|
||||
$table->width = 'auto';
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$param = stats_get_parameters($time, null, $course->id, $mode); // we only care about the table and the time string (if we have time)
|
||||
$param = stats_get_parameters($time, null, $course->id, $mode, $roleid); // We only care about the table and the time string (if we have time).
|
||||
|
||||
list($sort, $moreparams) = users_order_by_sql('u');
|
||||
$moreparams['courseid'] = $course->id;
|
||||
@ -190,7 +190,7 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
|
||||
print_error('reportnotavailable');
|
||||
}
|
||||
|
||||
$param = stats_get_parameters($time,$report,$course->id,$mode);
|
||||
$param = stats_get_parameters($time, $report, $course->id, $mode, $roleid);
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$param->table = 'user_'.$param->table;
|
||||
@ -220,10 +220,23 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
|
||||
|
||||
$stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2)));
|
||||
|
||||
echo $OUTPUT->heading(format_string($course->shortname).' - '.get_string('statsreport'.$report)
|
||||
.((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : '')
|
||||
.((!empty($roleid)) ? ' '.$DB->get_field('role','name', array('id'=>$roleid)) : ''));
|
||||
$rolename = '';
|
||||
$userdisplayname = '';
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
if (!empty($roleid) && $role = $DB->get_record('role', ['id' => $roleid])) {
|
||||
$rolename = ' ' . role_get_name($role, $coursecontext);
|
||||
}
|
||||
if (!empty($user)) {
|
||||
$userdisplayname = ' ' . fullname($user, true);
|
||||
}
|
||||
echo $OUTPUT->heading(
|
||||
format_string($course->shortname) .
|
||||
' - ' .
|
||||
get_string('statsreport' . $report) .
|
||||
$rolename .
|
||||
$userdisplayname
|
||||
);
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
report_stats_print_chart($course->id, $report, $time, $mode, $userid);
|
||||
@ -354,7 +367,7 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0,
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$param = stats_get_parameters($time, $report, $course->id, $mode);
|
||||
$param = stats_get_parameters($time, $report, $course->id, $mode, $roleid);
|
||||
|
||||
if (!empty($userid)) {
|
||||
$param->table = 'user_' . $param->table;
|
||||
|
Loading…
x
Reference in New Issue
Block a user