public static function get_current_versions_ids($audience = null) {
        global $DB;
        $sql = "SELECT v.policyid, v.id
             FROM {tool_policy} d
             LEFT JOIN {tool_policy_versions} v ON v.policyid = d.id
             WHERE d.currentversionid = v.id";
        $params = [];
        if ($audience) {
            $sql .= " AND v.audience IN (?, ?)";
            $params = [$audience, policy_version::AUDIENCE_ALL];
        }
        return $DB->get_records_sql_menu($sql . " ORDER BY d.sortorder", $params);
    }