original_string: public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) {
          global $DB;
  
          if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) {
              return self::ALLOCATION_EXISTS;
          }
  
          $weight = (int)$weight;
          if ($weight < 0) {
              $weight = 0;
          }
          if ($weight > 16) {
              $weight = 16;
          }
  
          $now = time();
          $assessment = new stdclass();
          $assessment->submissionid           = $submission->id;
          $assessment->reviewerid             = $reviewerid;
          $assessment->timecreated            = $now;         // do not set timemodified here
          $assessment->weight                 = $weight;
          $assessment->feedbackauthorformat   = editors_get_preferred_format();
          $assessment->feedbackreviewerformat = editors_get_preferred_format();
  
          return $DB->insert_record('workshop_assessments', $assessment, true, $bulk);
      }
code: public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) {
          global $DB;
  
          if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) {
              return self::ALLOCATION_EXISTS;
          }
  
          $weight = (int)$weight;
          if ($weight < 0) {
              $weight = 0;
          }
          if ($weight > 16) {
              $weight = 16;
          }
  
          $now = time();
          $assessment = new stdclass();
          $assessment->submissionid           = $submission->id;
          $assessment->reviewerid             = $reviewerid;
          $assessment->timecreated            = $now;         // do not set timemodified here
          $assessment->weight                 = $weight;
          $assessment->feedbackauthorformat   = editors_get_preferred_format();
          $assessment->feedbackreviewerformat = editors_get_preferred_format();
  
          return $DB->insert_record('workshop_assessments', $assessment, true, $bulk);
      }
code_tokens: public function add_allocation ( stdclass $ submission , $ reviewerid , $ weight = 1 , $ bulk = false ) { global $ DB ; if ( $ DB -> record_exists ( 'workshop_assessments' , array ( 'submissionid' => $ submission -> id , 'reviewerid' => $ reviewerid ) ) ) { return self :: ALLOCATION_EXISTS ; } $ weight = ( int ) $ weight ; if ( $ weight < 0 ) { $ weight = 0 ; } if ( $ weight > 16 ) { $ weight = 16 ; } $ now = time ( ) ; $ assessment = new stdclass ( ) ; $ assessment -> submissionid = $ submission -> id ; $ assessment -> reviewerid = $ reviewerid ; $ assessment -> timecreated = $ now ; // do not set timemodified here $ assessment -> weight = $ weight ; $ assessment -> feedbackauthorformat = editors_get_preferred_format ( ) ; $ assessment -> feedbackreviewerformat = editors_get_preferred_format ( ) ; return $ DB -> insert_record ( 'workshop_assessments' , $ assessment , true , $ bulk ) ; }
docstring: Allocate a submission to a user for review
  
  @param stdClass $submission Submission object with at least id property
  @param int $reviewerid User ID
  @param int $weight of the new assessment, from 0 to 16
  @param bool $bulk repeated inserts into DB expected
  @return int ID of the new assessment or an error code {@link self::ALLOCATION_EXISTS} if the allocation already exists
docstring_tokens: Allocate a submission to a user for review