MDL-51963 tool_lp: Pretend that there is a scale ID on competency
The reason why we are doing that is to leave the door open for competency scales later on. Which means that we can write code that will rely on the competency to provide its scale even though the default behaviour will be to use the framework one.
This commit is contained in:
@@ -255,6 +255,33 @@ class competency extends persistent {
|
||||
return new $rule($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scale.
|
||||
*
|
||||
* @return \grade_scale
|
||||
*/
|
||||
public function get_scale() {
|
||||
$scaleid = $this->get_scaleid();
|
||||
if ($scaleid === null) {
|
||||
return $this->get_framework()->get_scale();
|
||||
}
|
||||
$scale = \grade_scale::fetch(array('id' => $scaleid));
|
||||
$scale->load_items();
|
||||
return $scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scale ID.
|
||||
*
|
||||
* Here we pretend that the scale ID can be read from the competency, however it
|
||||
* only serves as a placeholder in case we want to support competency scales later on.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function get_scaleid() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the competency is the parent of passed competencies.
|
||||
*
|
||||
|
||||
@@ -83,10 +83,17 @@ class plan_page implements renderable, templatable {
|
||||
$comp = $pc->competency;
|
||||
$usercomp = $pc->$ucproperty;
|
||||
|
||||
// Get the framework.
|
||||
if (!isset($frameworks[$comp->get_competencyframeworkid()])) {
|
||||
$frameworks[$comp->get_competencyframeworkid()] = $comp->get_framework();
|
||||
}
|
||||
$framework = $frameworks[$comp->get_competencyframeworkid()];
|
||||
|
||||
// Get the scale.
|
||||
$scaleid = $comp->get_scaleid();
|
||||
if ($scaleid === null) {
|
||||
$scaleid = $framework->get_scaleid();
|
||||
}
|
||||
if (!isset($scales[$framework->get_scaleid()])) {
|
||||
$scales[$framework->get_scaleid()] = $framework->get_scale();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user