public static function get_agreement_optional($versionid) {
        global $DB;

        $optcache = \cache::make('tool_policy', 'policy_optional');

        $hit = $optcache->get($versionid);

        if ($hit === false) {
            $flags = $DB->get_records_menu('tool_policy_versions', null, '', 'id, optional');
            $optcache->set_many($flags);
            $hit = $flags[$versionid];
        }

        return $hit;
    }