public static function update_plan($plan) {
        global $PAGE;

        $params = self::validate_parameters(self::update_plan_parameters(), array('plan' => $plan));

        $params = $params['plan'];

        $plan = api::read_plan($params['id']);
        self::validate_context($plan->get_context());
        $output = $PAGE->get_renderer('core');

        $params = (object) $params;
        $result = api::update_plan($params);
        $exporter = new plan_exporter($result, ['template' => $plan->get_template()]);
        return $exporter->export($output);
    }