Beispiel #1
0
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(\renderer_base $output)
 {
     $frameworks = array();
     $scales = array();
     $planexporter = new plan_exporter($this->plan, array('template' => $this->plan->get_template()));
     $data = new stdClass();
     $data->plan = $planexporter->export($output);
     $data->competencies = array();
     $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
     $data->contextid = $this->plan->get_context()->id;
     if ($data->plan->iscompleted) {
         $ucproperty = 'usercompetencyplan';
         $ucexporter = 'core_competency\\external\\user_competency_plan_exporter';
     } else {
         $ucproperty = 'usercompetency';
         $ucexporter = 'core_competency\\external\\user_competency_exporter';
     }
     $pclist = api::list_plan_competencies($this->plan);
     $proficientcount = 0;
     foreach ($pclist as $pc) {
         $comp = $pc->competency;
         $usercomp = $pc->{$ucproperty};
         // Get the framework.
         if (!isset($frameworks[$comp->get_competencyframeworkid()])) {
             $frameworks[$comp->get_competencyframeworkid()] = $comp->get_framework();
         }
         $framework = $frameworks[$comp->get_competencyframeworkid()];
         // Get the scale.
         $scaleid = $comp->get_scaleid();
         if ($scaleid === null) {
             $scaleid = $framework->get_scaleid();
         }
         if (!isset($scales[$framework->get_scaleid()])) {
             $scales[$framework->get_scaleid()] = $framework->get_scale();
         }
         $scale = $scales[$framework->get_scaleid()];
         // Prepare the data.
         $record = new stdClass();
         $exporter = new competency_exporter($comp, array('context' => $framework->get_context()));
         $record->competency = $exporter->export($output);
         // Competency path.
         $exporter = new competency_path_exporter(['ancestors' => $comp->get_ancestors(), 'framework' => $framework, 'context' => $framework->get_context()]);
         $record->comppath = $exporter->export($output);
         $exporter = new $ucexporter($usercomp, array('scale' => $scale));
         $record->{$ucproperty} = $exporter->export($output);
         $data->competencies[] = $record;
         if ($usercomp->get_proficiency()) {
             $proficientcount++;
         }
     }
     $data->competencycount = count($data->competencies);
     $data->proficientcompetencycount = $proficientcount;
     if ($data->competencycount) {
         $data->proficientcompetencypercentage = (double) $proficientcount / (double) $data->competencycount * 100.0;
     } else {
         $data->proficientcompetencypercentage = 0.0;
     }
     $data->proficientcompetencypercentageformatted = format_float($data->proficientcompetencypercentage);
     return $data;
 }
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $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('plans' => $planstoreview, 'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false));
     return $data;
 }
 protected function get_other_values(renderer_base $output)
 {
     // Arrays are copy on assign.
     $related = $this->related;
     // Remove plan from related as it is not wanted by the user_competency_summary_exporter.
     unset($related['plan']);
     // We do not need user_competency_course in user_competency_summary_exporter.
     $related['usercompetencycourse'] = null;
     $exporter = new user_competency_summary_exporter(null, $related);
     $result = new stdClass();
     $result->usercompetencysummary = $exporter->export($output);
     $exporter = new plan_exporter($this->related['plan'], array('template' => $this->related['plan']->get_template()));
     $result->plan = $exporter->export($output);
     return (array) $result;
 }
Beispiel #4
0
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $data->userid = $this->userid;
     $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
     $data->canreaduserevidence = user_evidence::can_read_user($this->userid);
     $data->canmanageuserplans = plan::can_manage_user($this->userid);
     // Attach standard objects as mustache can not parse \core_competency\plan objects.
     $data->plans = array();
     if ($this->plans) {
         foreach ($this->plans as $plan) {
             $exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
             $record = $exporter->export($output);
             $data->plans[] = $record;
         }
     }
     $data->navigation = array();
     foreach ($this->navigation as $button) {
         $data->navigation[] = $output->render($button);
     }
     return $data;
 }
Beispiel #5
0
 /**
  * Returns description of external function result value.
  *
  * @return \external_function_parameters
  */
 public static function list_user_plans_returns()
 {
     return new external_multiple_structure(plan_exporter::get_read_structure());
 }
Beispiel #6
0
 /**
  * Returns description of data_for_plans_page() result value.
  *
  * @return \external_description
  */
 public static function data_for_plans_page_returns()
 {
     return new external_single_structure(array('userid' => new external_value(PARAM_INT, 'The learning plan user id'), 'plans' => new external_multiple_structure(plan_exporter::get_read_structure()), 'pluginbaseurl' => new external_value(PARAM_LOCALURL, 'Url to the tool_lp plugin folder on this Moodle site'), 'navigation' => new external_multiple_structure(new external_value(PARAM_RAW, 'HTML for a navigation item that should be on this page')), 'canreaduserevidence' => new external_value(PARAM_BOOL, 'Can the current user view the user\'s evidence'), 'canmanageuserplans' => new external_value(PARAM_BOOL, 'Can the current user manage the user\'s plans')));
 }
Beispiel #7
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;
 }