public static function get_starred_courses($limit, $offset) {
        global $USER, $PAGE;

        $params = self::validate_parameters(self::get_starred_courses_parameters(), [
            'limit' => $limit,
            'offset' => $offset
        ]);

        $limit = $params['limit'];
        $offset = $params['offset'];

        $usercontext = context_user::instance($USER->id);

        self::validate_context($usercontext);
        $PAGE->set_context($usercontext);
        $renderer = $PAGE->get_renderer('core');

        // Get the user favourites service, scoped to a single user (their favourites only).
        $userservice = \core_favourites\service_factory::get_service_for_user_context($usercontext);

        // Get the favourites, by type, for the user.
        $favourites = $userservice->find_favourites_by_type('core_course', 'courses', $offset, $limit);

        // Sort the favourites getting last added first.
        usort($favourites, function($a, $b) {
            if ($a->timemodified == $b->timemodified) return 0;
            return ($a->timemodified > $b->timemodified) ? -1 : 1;
        });

        $formattedcourses = array_map(function($favourite) use ($renderer) {
            $course = get_course($favourite->itemid);
            $context = \context_course::instance($favourite->itemid);

            $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => true]);
            return $exporter->export($renderer);
        }, $favourites);

        return $formattedcourses;
    }