public static function get_records_for_usercompetency($usercompetencyid,
                                                          \context $context,
                                                          $sort = '',
                                                          $order = 'ASC',
                                                          $skip = 0,
                                                          $limit = 0) {
        global $DB;

        $params = array(
            'usercompid' => $usercompetencyid,
            'path' => $context->path . '/%',
            'contextid' => $context->id
        );

        if (!empty($sort)) {
            $sort = ' ORDER BY e.' . $sort . ' ' . $order . ', e.id ASC';
        } else {
            $sort = ' ORDER BY e.id ASC';
        }

        $sql = 'SELECT e.*
                  FROM {' . static::TABLE . '} e
                  JOIN {context} c ON c.id = e.contextid
                 WHERE (c.path LIKE :path OR c.id = :contextid)
                   AND e.usercompetencyid = :usercompid
                 ' . $sort;
        $records = $DB->get_records_sql($sql, $params, $skip, $limit);
        $instances = array();

        foreach ($records as $record) {
            $newrecord = new static(0, $record);
            array_push($instances, $newrecord);
        }
        return $instances;
    }