mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-9137 Fixing errors in the overview report
This commit is contained in:
parent
a8bb516dce
commit
bc430af20d
5 changed files with 14 additions and 9 deletions
|
@ -117,7 +117,12 @@ foreach ($report_info as $outcomeid => $outcomedata) {
|
|||
|
||||
// Calculate outcome average
|
||||
if (is_array($outcomedata['items'])) {
|
||||
$avg = $outcomedata['outcome']->sum / count($outcomedata['items']);
|
||||
$count = count($outcomedata['items']);
|
||||
if ($count > 0) {
|
||||
$avg = $outcomedata['outcome']->sum / $count;
|
||||
} else {
|
||||
$avg = $outcomedata['outcome']->sum;
|
||||
}
|
||||
$avg_html = $scale->get_nearest_item($avg) . " (" . round($avg, 2) . ")\n";
|
||||
} else {
|
||||
$avg_html = ' - ';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
$gradereport_overview_capabilities = array(
|
||||
|
||||
'gradereport/outcomes:view' => array(
|
||||
'gradereport/overview:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
|
|
|
@ -27,10 +27,11 @@ require_once $CFG->libdir.'/gradelib.php';
|
|||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/overview/lib.php';
|
||||
|
||||
$courseid = optional_param('id', $COURSE->id, PARAM_INT);
|
||||
$userid = optional_param('userid', $USER->id, PARAM_INT);
|
||||
|
||||
/// basic access checks
|
||||
if (!$course = get_record('course', 'id', $COURSE->id)) {
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
|
@ -58,13 +59,13 @@ if (has_capability('moodle/grade:viewall', $context)) {
|
|||
}
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$userid));
|
||||
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'overview', 'courseid'=>$course->id, 'userid'=>$userid));
|
||||
|
||||
/// last selected report session tracking
|
||||
if (!isset($USER->grade_last_report)) {
|
||||
$USER->grade_last_report = array();
|
||||
}
|
||||
$USER->grade_last_report[$course->id] = 'user';
|
||||
$USER->grade_last_report[$course->id] = 'overview';
|
||||
|
||||
/// Build navigation
|
||||
$strgrades = get_string('grades');
|
||||
|
@ -77,7 +78,7 @@ print_header_simple($strgrades.': '.$reportname, ': '.$strgrades, $navigation,
|
|||
'', '', true, '', navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($course->id, 'report', 'user');
|
||||
print_grade_plugin_selector($course->id, 'report', 'overview');
|
||||
|
||||
if ($access) {
|
||||
|
||||
|
@ -91,7 +92,7 @@ if ($access) {
|
|||
$gradesum = 0;
|
||||
|
||||
// print the page
|
||||
print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
|
||||
print_heading(get_string('modulename', 'gradereport_overview'). ' - '.fullname($report->user));
|
||||
|
||||
if ($report->fill_table()) {
|
||||
echo $report->print_table(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue