protected static function export_grading_instances(\context $context, array $subcontext, int $definitionid, int $userid = 0) {
        global $DB;

        $params = ['definitionid' => $definitionid];
        if (!empty($userid)) {
            $params['raterid'] = $userid;
        }
        $instances = $DB->get_recordset('grading_instances', $params);
        $instancedata = [];
        foreach ($instances as $instance) {
            // TODO: Get the status name (instead of the ID).
            $tmpdata = [
                'rawgrade' => $instance->rawgrade,
                'status' => $instance->status,
                'feedback' => $instance->feedback,
                'feedbackformat' => $instance->feedbackformat,
                'timemodified' => transform::datetime($instance->timemodified),
            ];
            $instancedata[] = (object) $tmpdata;
        }
        $instances->close();

        if (!empty($instancedata)) {
            $data = (object) [
                'instances' => $instancedata,
            ];

            writer::with_context($context)->export_related_data($subcontext, 'gradinginstances', $data);
        }
    }
protected static function export_grading_instances(\context $context, array $subcontext, int $definitionid, int $userid = 0) {
        global $DB;

        $params = ['definitionid' => $definitionid];
        if (!empty($userid)) {
            $params['raterid'] = $userid;
        }
        $instances = $DB->get_recordset('grading_instances', $params);
        $instancedata = [];
        foreach ($instances as $instance) {
            // TODO: Get the status name (instead of the ID).
            $tmpdata = [
                'rawgrade' => $instance->rawgrade,
                'status' => $instance->status,
                'feedback' => $instance->feedback,
                'feedbackformat' => $instance->feedbackformat,
                'timemodified' => transform::datetime($instance->timemodified),
            ];
            $instancedata[] = (object) $tmpdata;
        }
        $instances->close();

        if (!empty($instancedata)) {
            $data = (object) [
                'instances' => $instancedata,
            ];

            writer::with_context($context)->export_related_data($subcontext, 'gradinginstances', $data);
        }
    }
protected static function export_grading_instances ( \ context $ context , array $ subcontext , int $ definitionid , int $ userid = 0 ) { global $ DB ; $ params = [ 'definitionid' => $ definitionid ] ; if ( ! empty ( $ userid ) ) { $ params [ 'raterid' ] = $ userid ; } $ instances = $ DB -> get_recordset ( 'grading_instances' , $ params ) ; $ instancedata = [ ] ; foreach ( $ instances as $ instance ) { // TODO: Get the status name (instead of the ID). $ tmpdata = [ 'rawgrade' => $ instance -> rawgrade , 'status' => $ instance -> status , 'feedback' => $ instance -> feedback , 'feedbackformat' => $ instance -> feedbackformat , 'timemodified' => transform :: datetime ( $ instance -> timemodified ) , ] ; $ instancedata [ ] = ( object ) $ tmpdata ; } $ instances -> close ( ) ; if ( ! empty ( $ instancedata ) ) { $ data = ( object ) [ 'instances' => $ instancedata , ] ; writer :: with_context ( $ context ) -> export_related_data ( $ subcontext , 'gradinginstances' , $ data ) ; } }
Exports the data related to grading instances within the specified definition.

@param  \context         $context Context owner of the data.
@param  array            $subcontext Subcontext owner of the data.
@param  int              $definitionid The definition ID whose grading instance information is to be exported.
@param  int              $userid The user whose information is to be exported.
Exports the data related to grading instances within the specified definition .