Merge branch 'MDL-33699' of git://github.com/netspotau/moodle-mod_assign
authorDan Poltawski <dan@moodle.com>
Mon, 18 Jun 2012 05:49:16 +0000 (13:49 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 18 Jun 2012 05:49:16 +0000 (13:49 +0800)
1  2 
mod/assign/locallib.php

diff --combined mod/assign/locallib.php
@@@ -361,6 -361,8 +361,6 @@@ class assign 
          } else if ($action == 'nextgrade') {
              $mform = null;
              $o .= $this->view_single_grade_page($mform, 1);
 -        } else if ($action == 'redirect') {
 -            redirect(required_param('url', PARAM_TEXT));
          } else if ($action == 'grade') {
              $o .= $this->view_single_grade_page($mform);
          } else if ($action == 'viewpluginassignfeedback') {
                  $o .= '&nbsp;/&nbsp;' . format_float($this->get_instance()->grade,2);
                  $o .= '<input type="hidden" name="grademodified_' . $userid . '" value="' . $modified . '"/>';
                  return $o;
 -            } else if ($grade == -1 || $grade === null) {
 -                return '-';
              } else {
 -                return format_float(($grade),2) .'&nbsp;/&nbsp;'. format_float($this->get_instance()->grade,2);
 +                if ($grade == -1 || $grade === null) {
 +                    return '-';
 +                } else {
 +                    return format_float(($grade),2) .'&nbsp;/&nbsp;'. format_float($this->get_instance()->grade,2);
 +                }
              }
  
          } else {
  
              // need to send this to the student
              $messagetype = 'feedbackavailable';
 -            $eventtype = 'assign_student_notification';
 +            $eventtype = 'assign_notification';
              $updatetime = $submission->lastmodified;
              $modulename = get_string('modulename', 'assign');
              self::send_assignment_notification($grader, $user, $messagetype, $eventtype, $updatetime, $mod, $contextmodule, $course, $modulename, $submission->name);
          global $USER, $CFG;
          // Include grading options form
          require_once($CFG->dirroot . '/mod/assign/gradingoptionsform.php');
 -        require_once($CFG->dirroot . '/mod/assign/gradingactionsform.php');
          require_once($CFG->dirroot . '/mod/assign/quickgradingform.php');
          require_once($CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php');
          $o = '';
  
          $links = array();
 -        $selecturl = (string)(new moodle_url('/mod/assign/view.php',
 -                                             array('action'=>'grading', 'id'=>$this->get_course_module()->id)));
 -        $links[$selecturl] = get_string('selectlink', 'assign');
          if (has_capability('gradereport/grader:view', $this->get_course_context()) &&
                  has_capability('moodle/grade:viewall', $this->get_course_context())) {
 -            $gradebookurl = (string) (new moodle_url('/grade/report/grader/index.php',
 -                                                     array('id' => $this->get_course()->id)));
 +            $gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
              $links[$gradebookurl] = get_string('viewgradebook', 'assign');
          }
          if ($this->is_any_submission_plugin_enabled()) {
 -            $downloadurl = (string) (new moodle_url('/mod/assign/view.php',
 -                                                    array('id' => $this->get_course_module()->id,
 -                                                          'action' => 'downloadall')));
 +            $downloadurl = '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=downloadall';
              $links[$downloadurl] = get_string('downloadall', 'assign');
          }
 -        $gradingactionsform = new mod_assign_grading_actions_form(null,
 -                                                                  array('links'=>$links,
 -                                                                        'cm'=>$this->get_course_module()->id),
 -                                                                  'post', '',
 -                                                                  array('class'=>'gradingactionsform'));
 +
 +        $gradingactions = new url_select($links);
  
          $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
  
              plagiarism_update_status($this->get_course(), $this->get_course_module());
          }
  
 -        $o .= $this->output->render(new assign_form('gradingactionsform', $gradingactionsform));
 -        $o .= $this->output->render(new assign_form('gradingoptionsform', $gradingoptionsform, 'M.mod_assign.init_grading_options'));
 +        $actionformtext = $this->output->render($gradingactions);
 +        $o .= $this->output->render(new assign_header($this->get_instance(),
 +                                                      $this->get_context(), false, $this->get_course_module()->id, get_string('grading', 'assign'), $actionformtext));
 +        $o .= groups_print_activity_menu($this->get_course_module(), $CFG->wwwroot . '/mod/assign/view.php?id=' . $this->get_course_module()->id.'&action=grading', true);
 +
  
          // load and print the table of submissions
          if ($showquickgrading && $quickgrading) {
              // if no enrolled user in a course then don't display the batch operations feature
              $o .= $this->output->render(new assign_form('gradingbatchoperationsform', $gradingbatchoperationsform));
          }
 +        $o .= $this->output->render(new assign_form('gradingoptionsform', $gradingoptionsform, 'M.mod_assign.init_grading_options'));
          return $o;
      }
  
  
          // only load this if it is
  
 -        $o .= $this->output->render(new assign_header($this->get_instance(),
 -                                                      $this->get_context(), false, $this->get_course_module()->id, get_string('grading', 'assign')));
 -        $o .= groups_print_activity_menu($this->get_course_module(), $CFG->wwwroot . '/mod/assign/view.php?id=' . $this->get_course_module()->id.'&action=grading', true);
 -
 -
          $o .= $this->view_grading_table();
  
          $o .= $this->view_footer();
              return;
          }
          $user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
 -        $this->send_notification($user, $user, 'submissionreceipt', 'assign_student_notification', $submission->timemodified);
 +        $this->send_notification($user, $user, 'submissionreceipt', 'assign_notification', $submission->timemodified);
      }
  
      /**
          $user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
          if ($teachers = $this->get_graders($user->id)) {
              foreach ($teachers as $teacher) {
 -                $this->send_notification($user, $teacher, 'gradersubmissionupdated', 'assign_grader_notification', $submission->timemodified);
 +                $this->send_notification($user, $teacher, 'gradersubmissionupdated', 'assign_notification', $submission->timemodified);
              }
          }
      }
                  // different ways to indicate no grade
                  continue;
              }
-             if ($current->grade != $modified->grade) {
+             // Treat 0 and null as different values
+             if ($current->grade !== null) {
+                 $current->grade = floatval($current->grade);
+             }
+             if ($current->grade !== $modified->grade) {
                  // grade changed
                  if ($this->grading_disabled($modified->userid)) {
                      continue;