protected function get_other_values(renderer_base $output)
 {
     $competencyexporter = new competency_exporter($this->related['competency'], array('context' => $this->related['context']));
     $usercompetencyexporter = new user_competency_exporter($this->related['usercompetency'], array('scale' => $this->related['scale']));
     $values = array('competency' => $competencyexporter->export($output), 'usercompetency' => $usercompetencyexporter->export($output));
     return $values;
 }
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $compstoreview = array();
     foreach ($this->compstoreview['competencies'] as $compdata) {
         $ucexporter = new user_competency_exporter($compdata->usercompetency, array('scale' => $compdata->competency->get_scale()));
         $compexporter = new competency_exporter($compdata->competency, array('context' => $compdata->competency->get_context()));
         $userexporter = new user_summary_exporter($compdata->user);
         $compstoreview[] = array('usercompetency' => $ucexporter->export($output), 'competency' => $compexporter->export($output), 'user' => $userexporter->export($output));
     }
     $data = array('competencies' => $compstoreview, 'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false));
     return $data;
 }
示例#3
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)));
 }
 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;
 }
示例#5
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')));
 }
示例#6
0
 public function export_for_template(renderer_base $output)
 {
     $plans = array();
     foreach ($this->plans as $plan) {
         if (count($plans) >= 3) {
             break;
         }
         if ($plan->get_status() == plan::STATUS_ACTIVE) {
             $plans[] = $plan;
         }
     }
     $activeplans = array();
     foreach ($plans as $plan) {
         $planexporter = new plan_exporter($plan, array('template' => $plan->get_template()));
         $activeplans[] = $planexporter->export($output);
     }
     $compstoreview = array();
     foreach ($this->compstoreview['competencies'] as $compdata) {
         $ucexporter = new user_competency_exporter($compdata->usercompetency, array('scale' => $compdata->competency->get_scale()));
         $compexporter = new competency_exporter($compdata->competency, array('context' => $compdata->competency->get_context()));
         $userexporter = new user_summary_exporter($compdata->user);
         $compstoreview[] = array('usercompetency' => $ucexporter->export($output), 'competency' => $compexporter->export($output), 'user' => $userexporter->export($output));
     }
     $planstoreview = array();
     foreach ($this->planstoreview['plans'] as $plandata) {
         $planexporter = new plan_exporter($plandata->plan, array('template' => $plandata->template));
         $userexporter = new user_summary_exporter($plandata->owner);
         $planstoreview[] = array('plan' => $planexporter->export($output), 'user' => $userexporter->export($output));
     }
     $data = array('hasplans' => !empty($this->plans), 'hasactiveplans' => !empty($activeplans), 'hasmoreplans' => count($this->plans) > count($activeplans), 'activeplans' => $activeplans, 'compstoreview' => $compstoreview, 'hascompstoreview' => $this->compstoreview['count'] > 0, 'hasmorecompstoreview' => $this->compstoreview['count'] > 3, 'planstoreview' => $planstoreview, 'hasplanstoreview' => $this->planstoreview['count'] > 0, 'hasmoreplanstoreview' => $this->planstoreview['count'] > 3, 'plansurl' => url::plans($this->user->id)->out(false), 'pluginbaseurl' => (new \moodle_url('/blocks/lp'))->out(false), 'userid' => $this->user->id);
     return $data;
 }