Merge branch 'MDL-53077' of git://github.com/Dave-B/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 1 Mar 2016 05:10:57 +0000 (13:10 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 1 Mar 2016 05:10:57 +0000 (13:10 +0800)
1  2 
mod/assign/locallib.php

diff --combined mod/assign/locallib.php
@@@ -406,6 -406,7 +406,7 @@@ class assign 
       * @return string - The page output.
       */
      public function view($action='') {
+         global $PAGE;
  
          $o = '';
          $mform = null;
                                'useridlistid' => optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM));
          $this->register_return_link($action, $returnparams);
  
+         // Include any page action as part of the body tag CSS id.
+         if (!empty($action)) {
+             $PAGE->set_pagetype('mod-assign-' . $action);
+         }
          // Now show the right view page.
          if ($action == 'redirect') {
              $nextpageurl = new moodle_url('/mod/assign/view.php', $nextpageparams);
  
          $this->update_submission($submission, $userid, true, $instance->teamsubmission);
  
 +        if ($instance->teamsubmission && !$instance->requireallteammemberssubmit) {
 +            $team = $this->get_submission_group_members($submission->groupid, true);
 +
 +            foreach ($team as $member) {
 +                if ($member->id != $userid) {
 +                    $membersubmission = clone($submission);
 +                    $this->update_submission($membersubmission, $member->id, true, $instance->teamsubmission);
 +                }
 +            }
 +        }
 +
          // Logging.
          if (isset($data->submissionstatement) && ($userid == $USER->id)) {
              \mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();
          $adminconfig = $this->get_admin_config();
          $gradebookplugin = $adminconfig->feedback_plugin_for_gradebook;
  
 +        $feedbackmodified = false;
 +
          // Call save in plugins.
          foreach ($this->feedbackplugins as $plugin) {
              if ($plugin->is_enabled() && $plugin->is_visible()) {
 -                if (!$plugin->save($grade, $formdata)) {
 -                    $result = false;
 -                    print_error($plugin->get_error());
 +                $gradingmodified = $plugin->is_feedback_modified($grade, $formdata);
 +                if ($gradingmodified) {
 +                    if (!$plugin->save($grade, $formdata)) {
 +                        $result = false;
 +                        print_error($plugin->get_error());
 +                    }
 +                    // If $feedbackmodified is true, keep it true.
 +                    $feedbackmodified = $feedbackmodified || $gradingmodified;
                  }
                  if (('assignfeedback_' . $plugin->get_type()) == $gradebookplugin) {
                      // This is the feedback plugin chose to push comments to the gradebook.
                  }
              }
          }
 +
          // We do not want to update the timemodified if no grade was added.
          if (!empty($formdata->addattempt) ||
                  ($originalgrade !== null && $originalgrade != -1) ||
 -                ($grade->grade !== null && $grade->grade != -1)) {
 +                ($grade->grade !== null && $grade->grade != -1) ||
 +                $feedbackmodified) {
              $this->update_grade($grade, !empty($formdata->addattempt));
          }
          // Note the default if not provided for this option is true (e.g. webservices).