Exemple #1
0
 /**
  * Returns description of data_for_template_competencies_page() result value.
  *
  * @return \external_description
  */
 public static function data_for_template_competencies_page_returns()
 {
     return new external_single_structure(array('template' => template_exporter::get_read_structure(), 'pagecontextid' => new external_value(PARAM_INT, 'Context ID'), 'canmanagecompetencyframeworks' => new external_value(PARAM_BOOL, 'User can manage competency frameworks'), 'canmanagetemplatecompetencies' => new external_value(PARAM_BOOL, 'User can manage learning plan templates'), 'competencies' => new external_multiple_structure(competency_summary_exporter::get_read_structure()), 'manageurl' => new external_value(PARAM_LOCALURL, 'Url to the manage competencies page.'), 'pluginbaseurl' => new external_value(PARAM_LOCALURL, 'Base URL of the plugin.'), 'statistics' => template_statistics_exporter::get_read_structure()));
 }
 /**
  * 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->template = (new template_exporter($this->template))->export($output);
     $data->pagecontextid = $this->pagecontext->id;
     $data->competencies = array();
     $contextcache = array();
     $frameworkcache = array();
     foreach ($this->competencies as $competency) {
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
             $frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
         }
         $framework = $frameworkcache[$competency->get_competencyframeworkid()];
         $courses = api::list_courses_using_competency($competency->get_id());
         $relatedcompetencies = api::list_related_competencies($competency->get_id());
         $related = array('competency' => $competency, 'linkedcourses' => $courses, 'context' => $context, 'relatedcompetencies' => $relatedcompetencies, 'framework' => $framework);
         $exporter = new competency_summary_exporter(null, $related);
         $record = $exporter->export($output);
         array_push($data->competencies, $record);
     }
     $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
     $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
     $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies;
     $data->manageurl = $this->manageurl->out(true);
     $exporter = new template_statistics_exporter($this->templatestatistics);
     $data->statistics = $exporter->export($output);
     $data->showcompetencylinks = true;
     return $data;
 }