]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9137 Fixing errors in the overview report
authornicolasconnault <nicolasconnault>
Fri, 10 Aug 2007 14:58:21 +0000 (14:58 +0000)
committernicolasconnault <nicolasconnault>
Fri, 10 Aug 2007 14:58:21 +0000 (14:58 +0000)
grade/report/outcomes/index.php
grade/report/overview/db/access.php
grade/report/overview/index.php
lang/en_utf8/gradereport_overview.php
lib/gradelib.php

index 2bf58ac098754e66a9de5ed9f2bbb20b900aae68..7d19b463927266d9de9918f1e19b8db132481b83 100644 (file)
@@ -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 = ' - ';
index e2a2e24bba5fe935a74db6270e51d3f8020ad8af..51c16f9f025a88c77125a4b17832680db9fede1a 100644 (file)
@@ -2,7 +2,7 @@
 
 $gradereport_overview_capabilities = array(
 
-    'gradereport/outcomes:view' => array(
+    'gradereport/overview:view' => array(
         'riskbitmask' => RISK_PERSONAL,
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
index 6ec444621f89e22e2a39e165c931ced7c063a2d0..5129f22b475c1defe3d6e6101e1f98992c035aa2 100644 (file)
@@ -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);
index b3751b0c5fbbe07105a652ce5139bb79d8de0741..85fdf86be0f62b3c48eaf9133b51a473a00b282b 100644 (file)
@@ -1,6 +1,5 @@
 <?PHP // $Id$
 
 $string['modulename'] = 'Overview report';
-$string['user:view'] = 'View your own grade report';
 
 ?>
index 747ab19fdb104e5a5cee5560c54b5357d60c0366..f41f213ccd0c7f1a0eea444e48467f293c9f0c18 100644 (file)
@@ -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