]> git.mjollnir.org Git - moodle.git/commitdiff
Fixing OU report issues
authornicolasconnault <nicolasconnault>
Tue, 25 Sep 2007 19:32:29 +0000 (19:32 +0000)
committernicolasconnault <nicolasconnault>
Tue, 25 Sep 2007 19:32:29 +0000 (19:32 +0000)
grade/report/grader/lib.php
grade/report/grader/preferences_form.php
lib/grade/grade_item.php

index 0ceb6ee6418f5f1f5691bdda54f6d835f8bac305..6b4c4e1ab7d9bb3efa6b49f6eccbc130516796d5 100644 (file)
@@ -806,6 +806,8 @@ class grade_report_grader extends grade_report {
         $meanselection         = $this->get_pref('meanselection');
         $shownumberofgrades    = $this->get_pref('shownumberofgrades');
 
+        $canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
+
         $avghtml = '';
         $avgcssclass = 'avg';
 
@@ -857,6 +859,12 @@ class grade_report_grader extends grade_report {
 
             $columncount=1;
             foreach ($this->items as $item) {
+                // If the user shouldn't see this grade_item, hide the average as well
+                if ($item->is_hidden() && !$canviewhidden) {
+                    $avghtml .= '<td class="cell c' . $columncount++.'"> - </td>';
+                    continue;
+                }
+
                 if (empty($sum_array[$item->id])) {
                     $sum_array[$item->id] = 0;
                 }
@@ -992,6 +1000,9 @@ class grade_report_grader extends grade_report {
                     $decimalpoints = $rangesdecimalpoints;
                 }
 
+                $grademin = 0;
+                $grademax = 100;
+
                 if ($displaytype == GRADE_DISPLAY_TYPE_REAL) {
                     $grademin = format_float($item->grademin, $decimalpoints);
                     $grademax = format_float($item->grademax, $decimalpoints);
index bb8d25b904d7ab6c04a1f1b924d32064f9377e0b..164de20a771367e58767eaf59add61e38493d6ef 100644 (file)
@@ -117,7 +117,7 @@ class grader_report_preferences_form extends moodleform {
                 $help_string = get_string("config$lang_string", 'grades');
 
                 // Replace the 'default' value with the site default language string
-                if (!is_null($options) AND $options[GRADE_REPORT_PREFERENCE_DEFAULT] == 'default') {
+                if (!is_null($options) AND isset($options[GRADE_REPORT_PREFERENCE_DEFAULT]) && $options[GRADE_REPORT_PREFERENCE_DEFAULT] == 'default') {
                     $options[GRADE_REPORT_PREFERENCE_DEFAULT] = get_string('sitedefault', 'grades', $default);
                 } elseif ($type == 'text') {
                     $help_string = get_string("config{$lang_string}default", 'grades', $default);
index e6e493ecd681553223c3abb13c735c3c0a9ee253..febffe8ca80d9e0052edc8e45c05abe6ca052038 100644 (file)
@@ -533,7 +533,7 @@ class grade_item extends grade_object {
      * Returns the hidden state of this grade_item
      * @return boolean hidden state
      */
-    function is_hidden($userid=NULL) {
+    function is_hidden() {
         return ($this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()));
     }