MDL-51036 tool_lp: There may not always be an action user on evidence

This commit is contained in:
Frederic Massart
2016-04-18 10:58:50 +08:00
parent 6cc8480a69
commit 572721ac1d
2 changed files with 9 additions and 5 deletions
+8 -4
View File
@@ -34,7 +34,7 @@ use renderer_base;
class evidence_exporter extends persistent_exporter {
protected static function define_related() {
return array('actionuser' => 'stdClass',
return array('actionuser' => 'stdClass?',
'scale' => 'grade_scale');
}
@@ -44,9 +44,13 @@ class evidence_exporter extends persistent_exporter {
protected function get_other_values(renderer_base $output) {
$other = array();
$exporter = new user_summary_exporter($this->related['actionuser']);
$actionuser = $exporter->export($output);
$other['actionuser'] = $actionuser;
if (!empty($this->related['actionuser'])) {
$exporter = new user_summary_exporter($this->related['actionuser']);
$actionuser = $exporter->export($output);
$other['actionuser'] = $actionuser;
}
$other['description'] = $this->persistent->get_description();
$other['userdate'] = userdate($this->persistent->get_timecreated());
@@ -141,7 +141,7 @@ class user_competency_summary_exporter extends exporter {
foreach ($this->related['evidence'] as $evidence) {
$related = array('scale' => $scale);
$related['actionuser'] = $usercache[$evidence->get_actionuserid()];
$related['actionuser'] = !empty($evidence->get_actionuserid()) ? $usercache[$evidence->get_actionuserid()] : null;
$exporter = new evidence_exporter($evidence, $related);
$allevidence[] = $exporter->export($output);
}