public static function fetch_and_start_tour($tourid, $context, $pageurl) {
        global $PAGE;

        $params = self::validate_parameters(self::fetch_and_start_tour_parameters(), [
                'tourid'    => $tourid,
                'context'   => $context,
                'pageurl'   => $pageurl,
            ]);

        $context = \context_helper::instance_by_id($params['context']);
        self::validate_context($context);

        $tour = tourinstance::instance($params['tourid']);
        if (!$tour->should_show_for_user()) {
            return [];
        }

        $touroutput = new \tool_usertours\output\tour($tour);

        \tool_usertours\event\tour_started::create([
            'contextid' => $context->id,
            'objectid'  => $tourid,
            'other'     => [
                'pageurl' => $pageurl,
            ],
        ])->trigger();

        return [
            'tourconfig' => $touroutput->export_for_template($PAGE->get_renderer('core')),
        ];
    }