Merge branch 'MDL-37646-23' of git://github.com/damyon/moodle into MOODLE_23_STABLE
authorDan Poltawski <dan@moodle.com>
Mon, 4 Feb 2013 05:49:42 +0000 (13:49 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 4 Feb 2013 05:49:42 +0000 (13:49 +0800)
1  2 
mod/assign/locallib.php

diff --combined mod/assign/locallib.php
@@@ -2180,12 -2180,8 +2180,12 @@@ class assign 
                                          $this->get_instance()->id,
                                          $user->id);
  
 -            $gradingitem = $gradinginfo->items[0];
 -            $gradebookgrade = $gradingitem->grades[$user->id];
 +            $gradingitem = null;
 +            $gradebookgrade = '-';
 +            if (isset($gradinginfo->items[0])) {
 +                $gradingitem = $gradinginfo->items[0];
 +                $gradebookgrade = $gradingitem->grades[$user->id];
 +            }
  
              // check to see if all feedback plugins are empty
              $emptyplugins = true;
              }
  
  
 -            if (!($gradebookgrade->hidden) && ($gradebookgrade->grade !== null || !$emptyplugins)) {
 +            $cangrade = has_capability('mod/assign:grade', $this->get_context());
 +            // If there is feedback or a visible grade, show the summary.
 +            if ((!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) ||
 +                    !$emptyplugins) {
  
 -                $gradefordisplay = '';
 +                $gradefordisplay = null;
 +                $gradeddate = null;
 +                $grader = null;
                  $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
  
 -                if ($controller = $gradingmanager->get_active_controller()) {
 -                    $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
 -                    $gradefordisplay = $controller->render_grade($PAGE,
 -                                                                 $grade->id,
 -                                                                 $gradingitem,
 -                                                                 $gradebookgrade->str_long_grade,
 -                                                                 has_capability('mod/assign:grade', $this->get_context()));
 -                } else {
 -                    $gradefordisplay = $this->display_grade($gradebookgrade->grade, false);
 +                // Only show the grade if it is not hidden in gradebook.
 +                if (!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) {
 +                    if ($controller = $gradingmanager->get_active_controller()) {
 +                        $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
 +                        $gradefordisplay = $controller->render_grade($PAGE,
 +                                                                     $grade->id,
 +                                                                     $gradingitem,
 +                                                                     $gradebookgrade->str_long_grade,
 +                                                                     $cangrade);
 +                    } else {
 +                        $gradefordisplay = $this->display_grade($gradebookgrade->grade, false);
 +                    }
 +                    $gradeddate = $gradebookgrade->dategraded;
 +                    if (isset($grade->grader)) {
 +                        $grader = $DB->get_record('user', array('id'=>$grade->grader));
 +                    }
                  }
  
 -                $gradeddate = $gradebookgrade->dategraded;
 -                $grader = $DB->get_record('user', array('id'=>$grade->grader));
  
                  $feedbackstatus = new assign_feedback_status($gradefordisplay,
                                                        $gradeddate,
              $gradevalue = optional_param('quickgrade_' . $userid, '', PARAM_TEXT);
              if($modified >= 0) {
                  $record->grade = unformat_float(optional_param('quickgrade_' . $record->userid, -1, PARAM_TEXT));
+             } else {
+                 // This user was not in the grading table.
+                 continue;
              }
              $record->lastmodified = $modified;
              $record->gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
          }
  
          if (has_all_capabilities(array('gradereport/grader:view', 'moodle/grade:viewall'), $this->get_course_context())) {
 +            $usergrade = '-';
 +            if (isset($gradinginfo->items[0]->grades[$userid]->str_grade)) {
 +                $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
 +            }
              $gradestring = $this->output->action_link(new moodle_url('/grade/report/grader/index.php',
                                                                array('id'=>$this->get_course()->id)),
 -                                                $gradinginfo->items[0]->grades[$userid]->str_grade);
 +                                                      $usergrade);
          } else {
 -            $gradestring = $gradinginfo->items[0]->grades[$userid]->str_grade;
 +            $usergrade = '-';
 +            if (isset($gradinginfo->items[0]->grades[$userid]) &&
 +                    !$grading_info->items[0]->grades[$userid]->hidden) {
 +                $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
 +            }
 +            $gradestring = $usergrade;
          }
          $mform->addElement('static', 'finalgrade', get_string('currentgrade', 'assign').':', $gradestring);