original_string: public function update_grading_grades(stdclass $settings, $restrict=null) {
          global $DB;
  
          // Remember the recently used settings for this workshop.
          if (empty($this->settings)) {
              $record = new stdclass();
              $record->workshopid = $this->workshop->id;
              $record->comparison = $settings->comparison;
              $DB->insert_record('workshopeval_best_settings', $record);
          } elseif ($this->settings->comparison != $settings->comparison) {
              $DB->set_field('workshopeval_best_settings', 'comparison', $settings->comparison,
                      array('workshopid' => $this->workshop->id));
          }
  
          // Get the grading strategy instance.
          $grader = $this->workshop->grading_strategy_instance();
  
          // get the information about the assessment dimensions
          $diminfo = $grader->get_dimensions_info();
  
          // fetch a recordset with all assessments to process
          $rs         = $grader->get_assessments_recordset($restrict);
          $batch      = array();    // will contain a set of all assessments of a single submission
          $previous   = null;       // a previous record in the recordset
          foreach ($rs as $current) {
              if (is_null($previous)) {
                  // we are processing the very first record in the recordset
                  $previous = $current;
              }
              if ($current->submissionid == $previous->submissionid) {
                  $batch[] = $current;
              } else {
                  // process all the assessments of a single submission
                  $this->process_assessments($batch, $diminfo, $settings);
                  // start with a new batch to be processed
                  $batch = array($current);
                  $previous = $current;
              }
          }
          // do not forget to process the last batch!
          $this->process_assessments($batch, $diminfo, $settings);
          $rs->close();
      }
code: public function update_grading_grades(stdclass $settings, $restrict=null) {
          global $DB;
  
          // Remember the recently used settings for this workshop.
          if (empty($this->settings)) {
              $record = new stdclass();
              $record->workshopid = $this->workshop->id;
              $record->comparison = $settings->comparison;
              $DB->insert_record('workshopeval_best_settings', $record);
          } elseif ($this->settings->comparison != $settings->comparison) {
              $DB->set_field('workshopeval_best_settings', 'comparison', $settings->comparison,
                      array('workshopid' => $this->workshop->id));
          }
  
          // Get the grading strategy instance.
          $grader = $this->workshop->grading_strategy_instance();
  
          // get the information about the assessment dimensions
          $diminfo = $grader->get_dimensions_info();
  
          // fetch a recordset with all assessments to process
          $rs         = $grader->get_assessments_recordset($restrict);
          $batch      = array();    // will contain a set of all assessments of a single submission
          $previous   = null;       // a previous record in the recordset
          foreach ($rs as $current) {
              if (is_null($previous)) {
                  // we are processing the very first record in the recordset
                  $previous = $current;
              }
              if ($current->submissionid == $previous->submissionid) {
                  $batch[] = $current;
              } else {
                  // process all the assessments of a single submission
                  $this->process_assessments($batch, $diminfo, $settings);
                  // start with a new batch to be processed
                  $batch = array($current);
                  $previous = $current;
              }
          }
          // do not forget to process the last batch!
          $this->process_assessments($batch, $diminfo, $settings);
          $rs->close();
      }
code_tokens: public function update_grading_grades ( stdclass $ settings , $ restrict = null ) { global $ DB ; // Remember the recently used settings for this workshop. if ( empty ( $ this -> settings ) ) { $ record = new stdclass ( ) ; $ record -> workshopid = $ this -> workshop -> id ; $ record -> comparison = $ settings -> comparison ; $ DB -> insert_record ( 'workshopeval_best_settings' , $ record ) ; } elseif ( $ this -> settings -> comparison != $ settings -> comparison ) { $ DB -> set_field ( 'workshopeval_best_settings' , 'comparison' , $ settings -> comparison , array ( 'workshopid' => $ this -> workshop -> id ) ) ; } // Get the grading strategy instance. $ grader = $ this -> workshop -> grading_strategy_instance ( ) ; // get the information about the assessment dimensions $ diminfo = $ grader -> get_dimensions_info ( ) ; // fetch a recordset with all assessments to process $ rs = $ grader -> get_assessments_recordset ( $ restrict ) ; $ batch = array ( ) ; // will contain a set of all assessments of a single submission $ previous = null ; // a previous record in the recordset foreach ( $ rs as $ current ) { if ( is_null ( $ previous ) ) { // we are processing the very first record in the recordset $ previous = $ current ; } if ( $ current -> submissionid == $ previous -> submissionid ) { $ batch [ ] = $ current ; } else { // process all the assessments of a single submission $ this -> process_assessments ( $ batch , $ diminfo , $ settings ) ; // start with a new batch to be processed $ batch = array ( $ current ) ; $ previous = $ current ; } } // do not forget to process the last batch! $ this -> process_assessments ( $ batch , $ diminfo , $ settings ) ; $ rs -> close ( ) ; }
docstring: Calculates the grades for assessment and updates 'gradinggrade' fields in 'workshop_assessments' table
  
  This function relies on the grading strategy subplugin providing get_assessments_recordset() method.
  {@see self::process_assessments()} for the required structure of the recordset.
  
  @param stdClass $settings       The settings for this round of evaluation
  @param null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewers(s)
  
  @return void
docstring_tokens: Calculates the grades for assessment and updates gradinggrade fields in workshop_assessments table