protected function get_other_values(renderer_base $output)
 {
     global $DB;
     $result = new stdClass();
     $result->showrelatedcompetencies = true;
     $competency = $this->related['competency'];
     $exporter = new competency_summary_exporter(null, array('competency' => $competency, 'context' => $competency->get_context(), 'framework' => $competency->get_framework(), 'linkedcourses' => array(), 'relatedcompetencies' => $this->related['relatedcompetencies']));
     $result->competency = $exporter->export($output);
     $result->cangrade = user_competency::can_grade_user($this->related['user']->id);
     if ($this->related['user']) {
         $exporter = new user_summary_exporter($this->related['user']);
         $result->user = $exporter->export($output);
     }
     $related = array('scale' => $competency->get_scale());
     if ($this->related['usercompetency']) {
         $exporter = new user_competency_exporter($this->related['usercompetency'], $related);
         $result->usercompetency = $exporter->export($output);
     }
     if ($this->related['usercompetencyplan']) {
         $exporter = new user_competency_plan_exporter($this->related['usercompetencyplan'], $related);
         $result->usercompetencyplan = $exporter->export($output);
     }
     if ($this->related['usercompetencycourse']) {
         $exporter = new user_competency_course_exporter($this->related['usercompetencycourse'], $related);
         $result->usercompetencycourse = $exporter->export($output);
     }
     $allevidence = array();
     $usercache = array();
     $scale = $competency->get_scale();
     $result->evidence = array();
     if (count($this->related['evidence'])) {
         foreach ($this->related['evidence'] as $evidence) {
             $actionuserid = $evidence->get_actionuserid();
             if (!empty($actionuserid)) {
                 $usercache[$evidence->get_actionuserid()] = true;
             }
         }
         $users = array();
         if (!empty($usercache)) {
             list($sql, $params) = $DB->get_in_or_equal(array_keys($usercache));
             $users = $DB->get_records_select('user', 'id ' . $sql, $params);
         }
         foreach ($users as $user) {
             $usercache[$user->id] = $user;
         }
         foreach ($this->related['evidence'] as $evidence) {
             $actionuserid = $evidence->get_actionuserid();
             $related = array('scale' => $scale, 'usercompetency' => $this->related['usercompetency'] ? $this->related['usercompetency'] : null, 'usercompetencyplan' => $this->related['usercompetencyplan'] ? $this->related['usercompetencyplan'] : null);
             $related['actionuser'] = !empty($actionuserid) ? $usercache[$actionuserid] : null;
             $exporter = new evidence_exporter($evidence, $related);
             $allevidence[] = $exporter->export($output);
         }
         $result->evidence = $allevidence;
     }
     $usercompetency = !empty($this->related['usercompetency']) ? $this->related['usercompetency'] : null;
     if (!empty($usercompetency) && $usercompetency->can_read_comments()) {
         $commentareaexporter = new comment_area_exporter($usercompetency->get_comment_object());
         $result->commentarea = $commentareaexporter->export($output);
     }
     return (array) $result;
 }
Example #2
0
 /**
  * External function return structure.
  *
  * @return \external_description
  */
 public static function list_plan_competencies_returns()
 {
     $uc = user_competency_exporter::get_read_structure();
     $ucp = user_competency_plan_exporter::get_read_structure();
     $uc->required = VALUE_OPTIONAL;
     $ucp->required = VALUE_OPTIONAL;
     return new external_multiple_structure(new external_single_structure(array('competency' => competency_exporter::get_read_structure(), 'usercompetency' => $uc, 'usercompetencyplan' => $ucp)));
 }
Example #3
0
 /**
  * Returns description of data_for_plan_page() result value.
  *
  * @return \external_description
  */
 public static function data_for_plan_page_returns()
 {
     $uc = user_competency_exporter::get_read_structure();
     $ucp = user_competency_plan_exporter::get_read_structure();
     $uc->required = VALUE_OPTIONAL;
     $ucp->required = VALUE_OPTIONAL;
     return new external_single_structure(array('plan' => plan_exporter::get_read_structure(), 'contextid' => new external_value(PARAM_INT, 'Context ID.'), 'pluginbaseurl' => new external_value(PARAM_URL, 'Plugin base URL.'), 'competencies' => new external_multiple_structure(new external_single_structure(array('competency' => competency_exporter::get_read_structure(), 'comppath' => competency_path_exporter::get_read_structure(), 'usercompetency' => $uc, 'usercompetencyplan' => $ucp))), 'competencycount' => new external_value(PARAM_INT, 'Count of competencies'), 'proficientcompetencycount' => new external_value(PARAM_INT, 'Count of proficientcompetencies'), 'proficientcompetencypercentage' => new external_value(PARAM_FLOAT, 'Percentage of competencies proficient'), 'proficientcompetencypercentageformatted' => new external_value(PARAM_RAW, 'Displayable percentage')));
 }