public static function has_records_for_competencies($competencyids) {
        global $DB;
        list($insql, $params) = $DB->get_in_or_equal($competencyids, SQL_PARAMS_NAMED);
        $sql = "SELECT DISTINCT bc.badgeid
                    FROM {badge_criteria} bc
                    JOIN {badge_criteria_param} bcp ON bc.id = bcp.critid
                    WHERE bc.criteriatype = :criteriatype AND value $insql";
        $params['criteriatype'] = BADGE_CRITERIA_TYPE_COMPETENCY;

        return self::record_exists_sql($sql, $params);
    }