protected static function export_recentitems(int $userid, \context $context) {
        global $DB;
        $sql = "SELECT ra.id, c.fullname, ra.timeaccess, m.name, ra.cmid
                  FROM {block_recentlyaccesseditems} ra
                  JOIN {course} c ON c.id = ra.courseid
                  JOIN {course_modules} cm on cm.id = ra.cmid
                  JOIN {modules} m ON m.id = cm.module
                 WHERE ra.userid = :userid";

        $params = ['userid' => $userid];
        $records = $DB->get_records_sql($sql, $params);
        if (!empty($records)) {
            $recentitems = (object) array_map(function($record) use($context) {
                return [
                        'course_name' => format_string($record->fullname, true, ['context' => $context]),
                        'module_name' => format_string($record->name),
                        'timeaccess' => transform::datetime($record->timeaccess)
                ];
            }, $records);
            writer::with_context($context)->export_data([get_string('privacy:recentlyaccesseditemspath',
                    'block_recentlyaccesseditems')], $recentitems);
        }
    }
protected static function export_recentitems(int $userid, \context $context) {
        global $DB;
        $sql = "SELECT ra.id, c.fullname, ra.timeaccess, m.name, ra.cmid
                  FROM {block_recentlyaccesseditems} ra
                  JOIN {course} c ON c.id = ra.courseid
                  JOIN {course_modules} cm on cm.id = ra.cmid
                  JOIN {modules} m ON m.id = cm.module
                 WHERE ra.userid = :userid";

        $params = ['userid' => $userid];
        $records = $DB->get_records_sql($sql, $params);
        if (!empty($records)) {
            $recentitems = (object) array_map(function($record) use($context) {
                return [
                        'course_name' => format_string($record->fullname, true, ['context' => $context]),
                        'module_name' => format_string($record->name),
                        'timeaccess' => transform::datetime($record->timeaccess)
                ];
            }, $records);
            writer::with_context($context)->export_data([get_string('privacy:recentlyaccesseditemspath',
                    'block_recentlyaccesseditems')], $recentitems);
        }
    }
protected static function export_recentitems ( int $ userid , \ context $ context ) { global $ DB ; $ sql = "SELECT ra.id, c.fullname, ra.timeaccess, m.name, ra.cmid
                  FROM {block_recentlyaccesseditems} ra
                  JOIN {course} c ON c.id = ra.courseid
                  JOIN {course_modules} cm on cm.id = ra.cmid
                  JOIN {modules} m ON m.id = cm.module
                 WHERE ra.userid = :userid" ; $ params = [ 'userid' => $ userid ] ; $ records = $ DB -> get_records_sql ( $ sql , $ params ) ; if ( ! empty ( $ records ) ) { $ recentitems = ( object ) array_map ( function ( $ record ) use ( $ context ) { return [ 'course_name' => format_string ( $ record -> fullname , true , [ 'context' => $ context ] ) , 'module_name' => format_string ( $ record -> name ) , 'timeaccess' => transform :: datetime ( $ record -> timeaccess ) ] ; } , $ records ) ; writer :: with_context ( $ context ) -> export_data ( [ get_string ( 'privacy:recentlyaccesseditemspath' , 'block_recentlyaccesseditems' ) ] , $ recentitems ) ; } }
Export information about the most recently accessed items.

@param  int $userid The user ID.
@param  \context $context The user context.
Export information about the most recently accessed items .