protected static function extract_grade_grade_from_record(stdClass $record, $ishistory = false) {
        $prefix = $ishistory ? 'ggh_' : 'gg_';
        $ggrecord = static::extract_record($record, $prefix);
        if ($ishistory) {
            // The grade history is not a real grade_grade so we remove the ID.
            $historyid = $ggrecord->id;
            unset($ggrecord->id);
        }
        $gg = new grade_grade($ggrecord, false);

        // There is a grade item in the record.
        if (!empty($record->gi_id)) {
            $gi = new grade_item(static::extract_record($record, 'gi_'), false);
            $gg->grade_item = $gi;  // This is a common hack throughout the grades API.
        }

        // Load the scale, when it still exists.
        if (!empty($gi->scaleid) && !empty($record->sc_id)) {
            $scalerec = static::extract_record($record, 'sc_');
            $gi->scale = new grade_scale($scalerec, false);
            $gi->scale->load_items();
        }

        if ($ishistory) {
            $gg->historyid = $historyid;
        }

        return $gg;
    }
protected static function extract_grade_grade_from_record(stdClass $record, $ishistory = false) {
        $prefix = $ishistory ? 'ggh_' : 'gg_';
        $ggrecord = static::extract_record($record, $prefix);
        if ($ishistory) {
            // The grade history is not a real grade_grade so we remove the ID.
            $historyid = $ggrecord->id;
            unset($ggrecord->id);
        }
        $gg = new grade_grade($ggrecord, false);

        // There is a grade item in the record.
        if (!empty($record->gi_id)) {
            $gi = new grade_item(static::extract_record($record, 'gi_'), false);
            $gg->grade_item = $gi;  // This is a common hack throughout the grades API.
        }

        // Load the scale, when it still exists.
        if (!empty($gi->scaleid) && !empty($record->sc_id)) {
            $scalerec = static::extract_record($record, 'sc_');
            $gi->scale = new grade_scale($scalerec, false);
            $gi->scale->load_items();
        }

        if ($ishistory) {
            $gg->historyid = $historyid;
        }

        return $gg;
    }
protected static function extract_grade_grade_from_record ( stdClass $ record , $ ishistory = false ) { $ prefix = $ ishistory ? 'ggh_' : 'gg_' ; $ ggrecord = static :: extract_record ( $ record , $ prefix ) ; if ( $ ishistory ) { // The grade history is not a real grade_grade so we remove the ID. $ historyid = $ ggrecord -> id ; unset ( $ ggrecord -> id ) ; } $ gg = new grade_grade ( $ ggrecord , false ) ; // There is a grade item in the record. if ( ! empty ( $ record -> gi_id ) ) { $ gi = new grade_item ( static :: extract_record ( $ record , 'gi_' ) , false ) ; $ gg -> grade_item = $ gi ; // This is a common hack throughout the grades API. } // Load the scale, when it still exists. if ( ! empty ( $ gi -> scaleid ) && ! empty ( $ record -> sc_id ) ) { $ scalerec = static :: extract_record ( $ record , 'sc_' ) ; $ gi -> scale = new grade_scale ( $ scalerec , false ) ; $ gi -> scale -> load_items ( ) ; } if ( $ ishistory ) { $ gg -> historyid = $ historyid ; } return $ gg ; }
Extract grade_grade from a record.

@param stdClass $record The record.
@param bool $ishistory Whether we're extracting a historical grade.
@return grade_grade
Extract grade_grade from a record .