public function get_scale_from_competency(competency $competency) {
        $scaleid = $competency->get('scaleid');
        if ($scaleid !== null && !isset($this->scales[$scaleid])) {
            $this->scales[$scaleid] = $competency->get_scale();

        } else if ($scaleid === null) {
            $framework = $this->get_framework_from_competency($competency);
            $scaleid = $framework->get('scaleid');
            if (!isset($this->scales[$scaleid])) {
                $this->scales[$scaleid] = $framework->get_scale();
            }
        }

        return $this->scales[$scaleid];
    }