Skip to content

Commit

Permalink
MDL-51036 report_competency: Invalid reference to scale when null
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent a4383fe commit 1315408
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion report/competency/classes/output/report.php
Expand Up @@ -115,6 +115,7 @@ public function export_for_template(renderer_base $output) {
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp/'))->out(false);
$data->usercompetencies = array();
$scalecache = array();
$frameworkcache = array();
foreach ($this->users as $user) {
$usercompetencies = api::list_user_competencies_in_course($this->courseid, $user->id);
$onerow = new stdClass();
Expand All @@ -131,7 +132,20 @@ public function export_for_template(renderer_base $output) {
break;
}
}
if (!isset($scalecache[$competency->get_scaleid()])) {

// Fetch the scale.
$scaleid = $competency->get_scaleid();
if ($scaleid === null) {
if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
$frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
}
$framework = $frameworkcache[$competency->get_competencyframeworkid()];
$scaleid = $framework->get_scaleid();
if (!isset($scalecache[$scaleid])) {
$scalecache[$competency->get_scaleid()] = $framework->get_scale();
}

} else if (!isset($scalecache[$scaleid])) {
$scalecache[$competency->get_scaleid()] = $competency->get_scale();
}
$scale = $scalecache[$competency->get_scaleid()];
Expand Down

0 comments on commit 1315408

Please sign in to comment.