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);
    }
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);
    }
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 ) ; }
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
Allocate a submission to a user for review