Skip to content

Commit

Permalink
MDL-9137 Fixing errors in the overview report
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Aug 10, 2007
1 parent a8bb516 commit bc430af
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion grade/report/outcomes/index.php
Expand Up @@ -117,7 +117,12 @@

// 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 = ' - ';
Expand Down
2 changes: 1 addition & 1 deletion grade/report/overview/db/access.php
Expand Up @@ -2,7 +2,7 @@

$gradereport_overview_capabilities = array(

'gradereport/outcomes:view' => array(
'gradereport/overview:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
Expand Down
11 changes: 6 additions & 5 deletions grade/report/overview/index.php
Expand Up @@ -27,10 +27,11 @@
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);
Expand Down Expand Up @@ -58,13 +59,13 @@
}

/// 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');
Expand All @@ -77,7 +78,7 @@
'', '', 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) {

Expand All @@ -91,7 +92,7 @@
$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);
Expand Down
1 change: 0 additions & 1 deletion lang/en_utf8/gradereport_overview.php
@@ -1,6 +1,5 @@
<?PHP // $Id$

$string['modulename'] = 'Overview report';
$string['user:view'] = 'View your own grade report';

?>
2 changes: 1 addition & 1 deletion lib/gradelib.php
Expand Up @@ -264,7 +264,7 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance,

/**
* Tells a module whether a grade (or grade_item if $userid is not given) is currently locked or not.
* If it's locked to the current use then the module can print a nice message or prevent editing in the module.
* If it's locked to the current user then the module can print a nice message or prevent editing in the module.
* If no $userid is given, the method will always return the grade_item's locked state.
* If a $userid is given, the method will first check the grade_item's locked state (the column). If it is locked,
* the method will return true no matter the locked state of the specific grade being checked. If unlocked, it will
Expand Down

0 comments on commit bc430af

Please sign in to comment.