/** * Export this data so it can be used as the context for a mustache template. * * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { $data = new stdClass(); $exporter = new competency_framework_exporter($this->framework); $data->framework = $exporter->export($output); $data->canmanage = $this->canmanage; $data->search = $this->search; $data->pagecontextid = $this->pagecontext->id; $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true); $rulesmodules = array(); $rules = competency::get_available_rules(); foreach ($rules as $type => $rulename) { $amd = null; if ($type == 'core_competency\\competency_rule_all') { $amd = 'tool_lp/competency_rule_all'; } else { if ($type == 'core_competency\\competency_rule_points') { $amd = 'tool_lp/competency_rule_points'; } else { // We do not know how to display that rule. continue; } } $rulesmodules[] = ['name' => (string) $rulename, 'type' => $type, 'amd' => $amd]; } $data->rulesmodules = json_encode(array_values($rulesmodules)); return $data; }
/** * Export this data so it can be used as the context for a mustache template. * * @param renderer_base $output Renderer base. * @return stdClass */ public function export_for_template(renderer_base $output) { $data = new stdClass(); $data->competencyframeworks = array(); $data->pagecontextid = $this->pagecontext->id; foreach ($this->competencyframeworks as $framework) { $exporter = new competency_framework_exporter($framework); $data->competencyframeworks[] = $exporter->export($output); } $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true); $data->navigation = array(); foreach ($this->navigation as $button) { $data->navigation[] = $output->render($button); } return $data; }
protected function get_other_values(renderer_base $output) { $result = new stdClass(); $context = $this->related['context']; $courses = $this->related['linkedcourses']; $linkedcourses = array(); foreach ($courses as $course) { $context = context_course::instance($course->id); $exporter = new course_summary_exporter($course, array('context' => $context)); $courseexport = $exporter->export($output); array_push($linkedcourses, $courseexport); } $result->linkedcourses = $linkedcourses; $result->hascourses = count($linkedcourses) > 0; $relatedcompetencies = array(); foreach ($this->related['relatedcompetencies'] as $competency) { $exporter = new competency_exporter($competency, array('context' => $context)); $competencyexport = $exporter->export($output); array_push($relatedcompetencies, $competencyexport); } $result->relatedcompetencies = $relatedcompetencies; $result->hasrelatedcompetencies = count($relatedcompetencies) > 0; $competency = $this->related['competency']; $exporter = new competency_exporter($competency, array('context' => $context)); $result->competency = $exporter->export($output); $exporter = new competency_framework_exporter($this->related['framework']); $result->framework = $exporter->export($output); $scaleconfiguration = $this->related['framework']->get_scaleconfiguration(); $scaleid = $this->related['framework']->get_scaleid(); if ($competency->get_scaleid()) { $scaleconfiguration = $competency->get_scaleconfiguration(); $scaleid = $competency->get_scaleid(); } $result->scaleconfiguration = $scaleconfiguration; $result->scaleid = $scaleid; $level = $competency->get_level(); $taxonomy = $this->related['framework']->get_taxonomy($level); $result->taxonomyterm = (string) competency_framework::get_taxonomies_list()[$taxonomy]; // Competency path. $exporter = new competency_path_exporter(['ancestors' => $competency->get_ancestors(), 'framework' => $this->related['framework'], 'context' => $context]); $result->comppath = $exporter->export($output); return (array) $result; }
/** * Returns description of list_competency_frameworks() result value. * * @return \external_description */ public static function list_competency_frameworks_returns() { return new external_multiple_structure(competency_framework_exporter::get_read_structure()); }
/** * Export the data. * * @param renderer_base $output * @return stdClass */ public function export_for_template(\renderer_base $output) { global $DB; $data = new stdClass(); $missingmappings = $this->processor->get_missing_mappings(); $data->pagecontextid = $this->pagecontext->id; $data->expectedccmigrations = $this->processor->get_expected_course_competency_migrations(); $data->expectedmcmigrations = $this->processor->get_expected_module_competency_migrations(); $data->ccmigrationscount = $this->processor->get_course_competency_migrations(); $data->mcmigrationscount = $this->processor->get_module_competency_migrations(); $data->ccremovalscount = $this->processor->get_course_competency_removals(); $data->mcremovalscount = $this->processor->get_module_competency_removals(); $data->unmappedfrom = array(); $data->unmappedto = array(); $exporter = new competency_framework_exporter($this->frameworkfrom); $data->frameworkfrom = $exporter->export($output); $exporter = new competency_framework_exporter($this->frameworkto); $data->frameworkto = $exporter->export($output); $fromcontext = $this->frameworkfrom->get_context(); $tocontext = $this->frameworkto->get_context(); $compcontext = null; foreach ($this->unmappedfrom as $comp) { $exporter = new competency_exporter($comp, array('context' => $fromcontext)); $data->unmappedfrom[] = $exporter->export($output); } foreach ($this->unmappedto as $comp) { $exporter = new competency_exporter($comp, array('context' => $tocontext)); $data->unmappedto[] = $exporter->export($output); } $data->coursesfound = $this->processor->get_courses_found_count(); $data->cmsfound = $this->processor->get_cms_found_count(); $data->mappingsmissingcount = count($missingmappings); $data->hasunmappedto = count($data->unmappedto) > 0; $data->hasunmappedfrom = count($data->unmappedfrom) > 0; $warnings = $this->processor->get_warnings(); $data->warnings = array(); $data->warningcount = count($warnings); $errors = $this->processor->get_errors(); $data->errors = array(); $data->errorcount = count($errors); foreach ($warnings as $warning) { $cmcontext = !empty($warning['cmid']) ? context_module::instance($warning['cmid']) : null; $coursecontext = context_course::instance($warning['courseid']); $warning['cm'] = $cmcontext ? $cmcontext->get_context_name() : null; $warning['course'] = $coursecontext->get_context_name(); $warning['competency'] = $DB->get_field(competency::TABLE, 'idnumber', array('id' => $warning['competencyid'])); $data->warnings[] = $warning; } foreach ($errors as $error) { $cmcontext = !empty($error['cmid']) ? context_module::instance($error['cmid']) : null; $coursecontext = context_course::instance($error['courseid']); $error['cm'] = $cmcontext ? $cmcontext->get_context_name() : null; $error['course'] = $coursecontext->get_context_name(); $error['competency'] = $DB->get_field(competency::TABLE, 'idnumber', array('id' => $error['competencyid'])); $data->errors[] = $error; } $data->pluginbaseurl = (new moodle_url('/admin/tool/lpmigrate'))->out(false); $data->frameworksurl = url::frameworks($this->pagecontext->id)->out(false); return $data; }
/** * Returns description of data_for_competencies_manage_page() result value. * * @return \external_description */ public static function data_for_competencies_manage_page_returns() { return new external_single_structure(array('framework' => competency_framework_exporter::get_read_structure(), 'canmanage' => new external_value(PARAM_BOOL, 'True if this user has permission to manage competency frameworks'), 'pagecontextid' => new external_value(PARAM_INT, 'Context id for the framework'), 'search' => new external_value(PARAM_RAW, 'Current search string'), 'rulesmodules' => new external_value(PARAM_RAW, 'JSON encoded data for rules'), 'pluginbaseurl' => new external_value(PARAM_RAW, 'Plugin base url'))); }