original_string: protected function process_save_grade(&$mform) {
          global $CFG, $SESSION;
          // Include grade form.
          require_once($CFG->dirroot . '/mod/assign/gradeform.php');
  
          require_sesskey();
  
          $instance = $this->get_instance();
          $rownum = required_param('rownum', PARAM_INT);
          $attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
          $useridlistid = optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM);
          $userid = optional_param('userid', 0, PARAM_INT);
          if (!$userid) {
              if (empty($SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)])) {
                  // If the userid list is not stored we must not save, as it is possible that the user in a
                  // given row position may not be the same now as when the grading page was generated.
                  $url = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id));
                  throw new moodle_exception('useridlistnotcached', 'mod_assign', $url);
              }
              $useridlist = $SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)];
          } else {
              $useridlist = array($userid);
              $rownum = 0;
          }
  
          $last = false;
          $userid = $useridlist[$rownum];
          if ($rownum == count($useridlist) - 1) {
              $last = true;
          }
  
          $data = new stdClass();
  
          $gradeformparams = array('rownum' => $rownum,
                                   'useridlistid' => $useridlistid,
                                   'last' => $last,
                                   'attemptnumber' => $attemptnumber,
                                   'userid' => $userid);
          $mform = new mod_assign_grade_form(null,
                                             array($this, $data, $gradeformparams),
                                             'post',
                                             '',
                                             array('class'=>'gradeform'));
  
          if ($formdata = $mform->get_data()) {
              return $this->save_grade($userid, $formdata);
          } else {
              return false;
          }
      }
code: protected function process_save_grade(&$mform) {
          global $CFG, $SESSION;
          // Include grade form.
          require_once($CFG->dirroot . '/mod/assign/gradeform.php');
  
          require_sesskey();
  
          $instance = $this->get_instance();
          $rownum = required_param('rownum', PARAM_INT);
          $attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
          $useridlistid = optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM);
          $userid = optional_param('userid', 0, PARAM_INT);
          if (!$userid) {
              if (empty($SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)])) {
                  // If the userid list is not stored we must not save, as it is possible that the user in a
                  // given row position may not be the same now as when the grading page was generated.
                  $url = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id));
                  throw new moodle_exception('useridlistnotcached', 'mod_assign', $url);
              }
              $useridlist = $SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)];
          } else {
              $useridlist = array($userid);
              $rownum = 0;
          }
  
          $last = false;
          $userid = $useridlist[$rownum];
          if ($rownum == count($useridlist) - 1) {
              $last = true;
          }
  
          $data = new stdClass();
  
          $gradeformparams = array('rownum' => $rownum,
                                   'useridlistid' => $useridlistid,
                                   'last' => $last,
                                   'attemptnumber' => $attemptnumber,
                                   'userid' => $userid);
          $mform = new mod_assign_grade_form(null,
                                             array($this, $data, $gradeformparams),
                                             'post',
                                             '',
                                             array('class'=>'gradeform'));
  
          if ($formdata = $mform->get_data()) {
              return $this->save_grade($userid, $formdata);
          } else {
              return false;
          }
      }
code_tokens: protected function process_save_grade ( & $ mform ) { global $ CFG , $ SESSION ; // Include grade form. require_once ( $ CFG -> dirroot . '/mod/assign/gradeform.php' ) ; require_sesskey ( ) ; $ instance = $ this -> get_instance ( ) ; $ rownum = required_param ( 'rownum' , PARAM_INT ) ; $ attemptnumber = optional_param ( 'attemptnumber' , - 1 , PARAM_INT ) ; $ useridlistid = optional_param ( 'useridlistid' , $ this -> get_useridlist_key_id ( ) , PARAM_ALPHANUM ) ; $ userid = optional_param ( 'userid' , 0 , PARAM_INT ) ; if ( ! $ userid ) { if ( empty ( $ SESSION -> mod_assign_useridlist [ $ this -> get_useridlist_key ( $ useridlistid ) ] ) ) { // If the userid list is not stored we must not save, as it is possible that the user in a // given row position may not be the same now as when the grading page was generated. $ url = new moodle_url ( '/mod/assign/view.php' , array ( 'id' => $ this -> get_course_module ( ) -> id ) ) ; throw new moodle_exception ( 'useridlistnotcached' , 'mod_assign' , $ url ) ; } $ useridlist = $ SESSION -> mod_assign_useridlist [ $ this -> get_useridlist_key ( $ useridlistid ) ] ; } else { $ useridlist = array ( $ userid ) ; $ rownum = 0 ; } $ last = false ; $ userid = $ useridlist [ $ rownum ] ; if ( $ rownum == count ( $ useridlist ) - 1 ) { $ last = true ; } $ data = new stdClass ( ) ; $ gradeformparams = array ( 'rownum' => $ rownum , 'useridlistid' => $ useridlistid , 'last' => $ last , 'attemptnumber' => $ attemptnumber , 'userid' => $ userid ) ; $ mform = new mod_assign_grade_form ( null , array ( $ this , $ data , $ gradeformparams ) , 'post' , '' , array ( 'class' => 'gradeform' ) ) ; if ( $ formdata = $ mform -> get_data ( ) ) { return $ this -> save_grade ( $ userid , $ formdata ) ; } else { return false ; } }
docstring: Save grade.
  
  @param  moodleform $mform
  @return bool - was the grade saved
docstring_tokens: Save grade .