public static function get_framework_depth($frameworkid) {
        global $DB;
        $totallength = $DB->sql_length('path');
        $trimmedlength = $DB->sql_length("REPLACE(path, '/', '')");
        $sql = "SELECT ($totallength - $trimmedlength - 1) AS depth
                  FROM {" . self::TABLE . "}
                 WHERE competencyframeworkid = :id
              ORDER BY depth DESC";
        $record = $DB->get_record_sql($sql, array('id' => $frameworkid), IGNORE_MULTIPLE);
        if (!$record) {
            $depth = 0;
        } else {
            $depth = $record->depth;
        }
        return $depth;
    }