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;
 }
Example #3
0
 /**
  * List plan competencies.
  * @param  int $id The plan ID.
  * @return array
  */
 public static function list_plan_competencies($id)
 {
     global $PAGE;
     $params = self::validate_parameters(self::list_plan_competencies_parameters(), array('id' => $id));
     $id = $params['id'];
     $plan = api::read_plan($id);
     $usercontext = $plan->get_context();
     self::validate_context($usercontext);
     $output = $PAGE->get_renderer('core');
     $result = api::list_plan_competencies($plan);
     if ($plan->get_status() == plan::STATUS_COMPLETE) {
         $ucproperty = 'usercompetencyplan';
     } else {
         $ucproperty = 'usercompetency';
     }
     $contextcache = array();
     $scalecache = array();
     foreach ($result as $key => $r) {
         if (!isset($scalecache[$r->competency->get_competencyframeworkid()])) {
             $scalecache[$r->competency->get_competencyframeworkid()] = $r->competency->get_framework()->get_scale();
         }
         $scale = $scalecache[$r->competency->get_competencyframeworkid()];
         if (!isset($contextcache[$r->competency->get_competencyframeworkid()])) {
             $contextcache[$r->competency->get_competencyframeworkid()] = $r->competency->get_context();
         }
         $context = $contextcache[$r->competency->get_competencyframeworkid()];
         $exporter = new competency_exporter($r->competency, array('context' => $context));
         $r->competency = $exporter->export($output);
         if ($r->usercompetency) {
             $exporter = new user_competency_exporter($r->usercompetency, array('scale' => $scale));
             $r->usercompetency = $exporter->export($output);
             unset($r->usercompetencyplan);
         } else {
             $exporter = new user_competency_plan_exporter($r->usercompetencyplan, array('scale' => $scale));
             $r->usercompetencyplan = $exporter->export($output);
             unset($r->usercompetency);
         }
     }
     return $result;
 }
 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 #5
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;
 }