public static function list_course_module_competencies($cmid) {
        global $DB;

        $sql = 'SELECT coursemodcomp.*
                  FROM {' . self::TABLE . '} coursemodcomp
                  JOIN {' . competency::TABLE . '} comp
                    ON coursemodcomp.competencyid = comp.id
                 WHERE coursemodcomp.cmid = ?
                 ORDER BY coursemodcomp.sortorder ASC';
        $params = array($cmid);

        $results = $DB->get_recordset_sql($sql, $params);
        $instances = array();
        foreach ($results as $result) {
            array_push($instances, new course_module_competency(0, $result));
        }
        $results->close();

        return $instances;
    }