public static function get_policy_version($versionid, $behalfid = null) {
        global $PAGE;

        $result = [];
        $warnings = [];
        $params = external_api::validate_parameters(self::get_policy_version_parameters(), [
            'versionid' => $versionid,
            'behalfid' => $behalfid
        ]);
        $versionid = $params['versionid'];
        $behalfid = $params['behalfid'];

        $context = context_system::instance();
        $PAGE->set_context($context);

        try {
            // Validate if the user has access to the policy version.
            $version = api::get_policy_version($versionid);
            if (!api::can_user_view_policy_version($version, $behalfid)) {
                $warnings[] = [
                    'item' => $versionid,
                    'warningcode' => 'errorusercantviewpolicyversion',
                    'message' => get_string('errorusercantviewpolicyversion', 'tool_policy')
                ];
            } else if (!empty($version)) {
                $version = api::get_policy_version($versionid);
                $policy['name'] = $version->name;
                $policy['versionid'] = $versionid;
                list($policy['content'], $notusedformat) = external_format_text(
                    $version->content,
                    $version->contentformat,
                    SYSCONTEXTID,
                    'tool_policy',
                    'policydocumentcontent',
                    $version->id
                );
                $result['policy'] = $policy;
            }
        } catch (moodle_exception $e) {
            $warnings[] = [
                'item' => $versionid,
                'warningcode' => 'errorpolicyversionnotfound',
                'message' => get_string('errorpolicyversionnotfound', 'tool_policy')
            ];
        }

        return [
            'result' => $result,
            'warnings' => $warnings
        ];
    }