original_string: protected function process_outcomes($userid, $formdata, $sourceuserid = null) {
          global $CFG, $USER;
  
          if (empty($CFG->enableoutcomes)) {
              return;
          }
          if ($this->grading_disabled($userid)) {
              return;
          }
  
          require_once($CFG->libdir.'/gradelib.php');
  
          $data = array();
          $gradinginfo = grade_get_grades($this->get_course()->id,
                                          'mod',
                                          'assign',
                                          $this->get_instance()->id,
                                          $userid);
  
          if (!empty($gradinginfo->outcomes)) {
              foreach ($gradinginfo->outcomes as $index => $oldoutcome) {
                  $name = 'outcome_'.$index;
                  $sourceuserid = $sourceuserid !== null ? $sourceuserid : $userid;
                  if (isset($formdata->{$name}[$sourceuserid]) &&
                          $oldoutcome->grades[$userid]->grade != $formdata->{$name}[$sourceuserid]) {
                      $data[$index] = $formdata->{$name}[$sourceuserid];
                  }
              }
          }
          if (count($data) > 0) {
              grade_update_outcomes('mod/assign',
                                    $this->course->id,
                                    'mod',
                                    'assign',
                                    $this->get_instance()->id,
                                    $userid,
                                    $data);
          }
      }
code: protected function process_outcomes($userid, $formdata, $sourceuserid = null) {
          global $CFG, $USER;
  
          if (empty($CFG->enableoutcomes)) {
              return;
          }
          if ($this->grading_disabled($userid)) {
              return;
          }
  
          require_once($CFG->libdir.'/gradelib.php');
  
          $data = array();
          $gradinginfo = grade_get_grades($this->get_course()->id,
                                          'mod',
                                          'assign',
                                          $this->get_instance()->id,
                                          $userid);
  
          if (!empty($gradinginfo->outcomes)) {
              foreach ($gradinginfo->outcomes as $index => $oldoutcome) {
                  $name = 'outcome_'.$index;
                  $sourceuserid = $sourceuserid !== null ? $sourceuserid : $userid;
                  if (isset($formdata->{$name}[$sourceuserid]) &&
                          $oldoutcome->grades[$userid]->grade != $formdata->{$name}[$sourceuserid]) {
                      $data[$index] = $formdata->{$name}[$sourceuserid];
                  }
              }
          }
          if (count($data) > 0) {
              grade_update_outcomes('mod/assign',
                                    $this->course->id,
                                    'mod',
                                    'assign',
                                    $this->get_instance()->id,
                                    $userid,
                                    $data);
          }
      }
code_tokens: protected function process_outcomes ( $ userid , $ formdata , $ sourceuserid = null ) { global $ CFG , $ USER ; if ( empty ( $ CFG -> enableoutcomes ) ) { return ; } if ( $ this -> grading_disabled ( $ userid ) ) { return ; } require_once ( $ CFG -> libdir . '/gradelib.php' ) ; $ data = array ( ) ; $ gradinginfo = grade_get_grades ( $ this -> get_course ( ) -> id , 'mod' , 'assign' , $ this -> get_instance ( ) -> id , $ userid ) ; if ( ! empty ( $ gradinginfo -> outcomes ) ) { foreach ( $ gradinginfo -> outcomes as $ index => $ oldoutcome ) { $ name = 'outcome_' . $ index ; $ sourceuserid = $ sourceuserid !== null ? $ sourceuserid : $ userid ; if ( isset ( $ formdata -> { $ name } [ $ sourceuserid ] ) && $ oldoutcome -> grades [ $ userid ] -> grade != $ formdata -> { $ name } [ $ sourceuserid ] ) { $ data [ $ index ] = $ formdata -> { $ name } [ $ sourceuserid ] ; } } } if ( count ( $ data ) > 0 ) { grade_update_outcomes ( 'mod/assign' , $ this -> course -> id , 'mod' , 'assign' , $ this -> get_instance ( ) -> id , $ userid , $ data ) ; } }
docstring: Save outcomes submitted from grading form.
  
  @param int $userid
  @param stdClass $formdata
  @param int $sourceuserid The user ID under which the outcome data is accessible. This is relevant
  for an outcome set to a user but applied to an entire group.
docstring_tokens: Save outcomes submitted from grading form .