protected static function export_user_data_lti_types(approved_contextlist $contextlist) {
        global $DB;

        // Filter out any contexts that are not related to courses.
        $courseids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
            if ($context->contextlevel == CONTEXT_COURSE) {
                $carry[] = $context->instanceid;
            }
            return $carry;
        }, []);

        if (empty($courseids)) {
            return;
        }

        $user = $contextlist->get_user();

        list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
        $params = array_merge($inparams, ['userid' => $user->id]);
        $ltitypes = $DB->get_recordset_select('lti_types', "course $insql AND createdby = :userid", $params, 'timecreated ASC');
        self::recordset_loop_and_export($ltitypes, 'course', [], function($carry, $record) {
            $context = \context_course::instance($record->course);
            $options = ['context' => $context];
            $carry[] = [
                'name' => format_string($record->name, true, $options),
                'createdby' => transform::user($record->createdby),
                'timecreated' => transform::datetime($record->timecreated),
                'timemodified' => transform::datetime($record->timemodified)
            ];
            return $carry;
        }, function($courseid, $data) {
            $context = \context_course::instance($courseid);
            $finaldata = (object) ['lti_types' => $data];
            writer::with_context($context)->export_data([], $finaldata);
        });
    }
protected static function export_user_data_lti_types(approved_contextlist $contextlist) {
        global $DB;

        // Filter out any contexts that are not related to courses.
        $courseids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
            if ($context->contextlevel == CONTEXT_COURSE) {
                $carry[] = $context->instanceid;
            }
            return $carry;
        }, []);

        if (empty($courseids)) {
            return;
        }

        $user = $contextlist->get_user();

        list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
        $params = array_merge($inparams, ['userid' => $user->id]);
        $ltitypes = $DB->get_recordset_select('lti_types', "course $insql AND createdby = :userid", $params, 'timecreated ASC');
        self::recordset_loop_and_export($ltitypes, 'course', [], function($carry, $record) {
            $context = \context_course::instance($record->course);
            $options = ['context' => $context];
            $carry[] = [
                'name' => format_string($record->name, true, $options),
                'createdby' => transform::user($record->createdby),
                'timecreated' => transform::datetime($record->timecreated),
                'timemodified' => transform::datetime($record->timemodified)
            ];
            return $carry;
        }, function($courseid, $data) {
            $context = \context_course::instance($courseid);
            $finaldata = (object) ['lti_types' => $data];
            writer::with_context($context)->export_data([], $finaldata);
        });
    }
protected static function export_user_data_lti_types ( approved_contextlist $ contextlist ) { global $ DB ; // Filter out any contexts that are not related to courses. $ courseids = array_reduce ( $ contextlist -> get_contexts ( ) , function ( $ carry , $ context ) { if ( $ context -> contextlevel == CONTEXT_COURSE ) { $ carry [ ] = $ context -> instanceid ; } return $ carry ; } , [ ] ) ; if ( empty ( $ courseids ) ) { return ; } $ user = $ contextlist -> get_user ( ) ; list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ courseids , SQL_PARAMS_NAMED ) ; $ params = array_merge ( $ inparams , [ 'userid' => $ user -> id ] ) ; $ ltitypes = $ DB -> get_recordset_select ( 'lti_types' , "course $insql AND createdby = :userid" , $ params , 'timecreated ASC' ) ; self :: recordset_loop_and_export ( $ ltitypes , 'course' , [ ] , function ( $ carry , $ record ) { $ context = \ context_course :: instance ( $ record -> course ) ; $ options = [ 'context' => $ context ] ; $ carry [ ] = [ 'name' => format_string ( $ record -> name , true , $ options ) , 'createdby' => transform :: user ( $ record -> createdby ) , 'timecreated' => transform :: datetime ( $ record -> timecreated ) , 'timemodified' => transform :: datetime ( $ record -> timemodified ) ] ; return $ carry ; } , function ( $ courseid , $ data ) { $ context = \ context_course :: instance ( $ courseid ) ; $ finaldata = ( object ) [ 'lti_types' => $ data ] ; writer :: with_context ( $ context ) -> export_data ( [ ] , $ finaldata ) ; } ) ; }
Export personal data for the given approved_contextlist related to LTI types.

@param approved_contextlist $contextlist a list of contexts approved for export.
Export personal data for the given approved_contextlist related to LTI types .