/**
  * Constructor
  *
  * @param string $elementName Element name
  * @param mixed $elementLabel Label(s) for an element
  * @param array $options Options to control the element's display
  * @param mixed $attributes Either a typical HTML attribute string or an associative array.
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     global $OUTPUT;
     if ($elementName == null) {
         // This is broken quickforms messing with the constructors.
         return;
     }
     if (!isset($options['courseid'])) {
         throw new coding_exception('Course id is required for the course_competencies form element');
     }
     $courseid = $options['courseid'];
     if (!empty($options['cmid'])) {
         $current = \core_competency\api::list_course_module_competencies_in_course_module($options['cmid']);
         $ids = array();
         foreach ($current as $coursemodulecompetency) {
             array_push($ids, $coursemodulecompetency->get_competencyid());
         }
         $this->setValue($ids);
     }
     $competencies = api::list_course_competencies($courseid);
     $validoptions = array();
     $context = context_course::instance($courseid);
     foreach ($competencies as $competency) {
         // We don't need to show the description as part of the options, so just set this to null.
         $competency['competency']->set_description(null);
         $exporter = new competency_exporter($competency['competency'], array('context' => $context));
         $templatecontext = array('competency' => $exporter->export($OUTPUT));
         $id = $competency['competency']->get_id();
         $validoptions[$id] = $OUTPUT->render_from_template('tool_lp/competency_summary', $templatecontext);
     }
     $attributes['tags'] = false;
     $attributes['multiple'] = 'multiple';
     parent::__construct($elementName, $elementLabel, $validoptions, $attributes);
 }
 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;
 }
示例#3
0
 protected function get_other_values(renderer_base $output)
 {
     $contextcache = array();
     $competencies = array();
     foreach ($this->related['competencies'] as $competency) {
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         $compexporter = new competency_exporter($competency, array('context' => $context));
         $competencies[] = $compexporter->export($output);
     }
     $urlshort = '';
     $url = $this->persistent->get_url();
     if (!empty($url)) {
         $murl = new moodle_url($url);
         $shorturl = preg_replace('@^https?://(www\\.)?@', '', $murl->out(false));
         $urlshort = shorten_text($shorturl, 30, true);
     }
     $files = array();
     $storedfiles = $this->persistent->get_files();
     if (!empty($storedfiles)) {
         foreach ($storedfiles as $storedfile) {
             $fileexporter = new stored_file_exporter($storedfile, array('context' => $this->related['context']));
             $files[] = $fileexporter->export($output);
         }
     }
     $values = array('canmanage' => $this->persistent->can_manage(), 'competencycount' => count($competencies), 'competencies' => $competencies, 'filecount' => count($files), 'files' => $files, 'hasurlorfiles' => !empty($files) || !empty($url), 'urlshort' => $urlshort);
     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;
 }
示例#5
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->relatedcompetencies = array();
     if ($this->relatedcompetencies) {
         foreach ($this->relatedcompetencies as $competency) {
             $exporter = new competency_exporter($competency, array('context' => $this->context));
             $record = $exporter->export($output);
             $data->relatedcompetencies[] = $record;
         }
     }
     // We checked the user permissions in the constructor.
     $data->showdeleterelatedaction = true;
     return $data;
 }
 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     $data = new stdClass();
     $data->userid = $this->userid;
     $data->competencyid = $this->competencyid;
     $data->planid = $this->planid;
     $data->baseurl = $this->baseurl;
     $plancompetencies = \core_competency\api::list_plan_competencies($data->planid);
     $data->competencies = array();
     $contextcache = array();
     foreach ($plancompetencies as $plancompetency) {
         $frameworkid = $plancompetency->competency->get_competencyframeworkid();
         if (!isset($contextcache[$frameworkid])) {
             $contextcache[$frameworkid] = $plancompetency->competency->get_context();
         }
         $context = $contextcache[$frameworkid];
         $exporter = new competency_exporter($plancompetency->competency, array('context' => $context));
         $competency = $exporter->export($output);
         if ($competency->id == $this->competencyid) {
             $competency->selected = true;
         }
         $data->competencies[] = $competency;
     }
     $data->hascompetencies = count($data->competencies);
     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;
 }
 protected function get_other_values(renderer_base $output)
 {
     $proficientcompetencypercentage = 0;
     $proficientcompetencypercentageformatted = '';
     if ($this->data->competencycount > 0) {
         $proficientcompetencypercentage = (double) $this->data->proficientcompetencycount / (double) $this->data->competencycount * 100.0;
         $proficientcompetencypercentageformatted = format_float($proficientcompetencypercentage);
     }
     $competencies = array();
     $contextcache = array();
     foreach ($this->data->leastproficientcompetencies as $competency) {
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         $exporter = new competency_exporter($competency, array('context' => $context));
         $competencies[] = $exporter->export($output);
     }
     return array('proficientcompetencypercentage' => $proficientcompetencypercentage, 'proficientcompetencypercentageformatted' => $proficientcompetencypercentageformatted, 'leastproficient' => $competencies, 'leastproficientcount' => count($competencies), 'canbegradedincourse' => has_capability('moodle/competency:coursecompetencygradable', $this->related['context']), 'canmanagecoursecompetencies' => has_capability('moodle/competency:coursecompetencymanage', $this->related['context']));
 }
 protected function get_other_values(renderer_base $output)
 {
     $linkedcompetencycount = $this->data->competencycount - $this->data->unlinkedcompetencycount;
     if ($linkedcompetencycount < 0) {
         // Should never happen.
         $linkedcompetencycount = 0;
     }
     $linkedcompetencypercentage = 0;
     $linkedcompetencypercentageformatted = '';
     if ($this->data->competencycount > 0) {
         $linkedcompetencypercentage = (double) $linkedcompetencycount / (double) $this->data->competencycount * 100.0;
         $linkedcompetencypercentageformatted = format_float($linkedcompetencypercentage);
     }
     $completedplanpercentage = 0;
     $completedplanpercentageformatted = '';
     if ($this->data->plancount > 0) {
         $completedplanpercentage = (double) $this->data->completedplancount / (double) $this->data->plancount * 100.0;
         $completedplanpercentageformatted = format_float($completedplanpercentage);
     }
     $proficientusercompetencyplanpercentage = 0;
     $proficientusercompetencyplanpercentageformatted = '';
     if ($this->data->usercompetencyplancount > 0) {
         $proficientusercompetencyplanpercentage = (double) $this->data->proficientusercompetencyplancount / (double) $this->data->usercompetencyplancount * 100.0;
         $proficientusercompetencyplanpercentageformatted = format_float($proficientusercompetencyplanpercentage);
     }
     $competencies = array();
     $contextcache = array();
     foreach ($this->data->leastproficientcompetencies as $competency) {
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         $exporter = new competency_exporter($competency, array('context' => $context));
         $competencies[] = $exporter->export($output);
     }
     return array('linkedcompetencycount' => $linkedcompetencycount, 'linkedcompetencypercentage' => $linkedcompetencypercentage, 'linkedcompetencypercentageformatted' => $linkedcompetencypercentageformatted, 'completedplanpercentage' => $completedplanpercentage, 'completedplanpercentageformatted' => $completedplanpercentageformatted, 'proficientusercompetencyplanpercentage' => $proficientusercompetencyplanpercentage, 'proficientusercompetencyplanpercentageformatted' => $proficientusercompetencyplanpercentageformatted, 'leastproficient' => $competencies, 'leastproficientcount' => count($competencies));
 }
示例#10
0
 /**
  * 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)
 {
     global $USER;
     $data = new stdClass();
     $data->courseid = $this->courseid;
     $data->pagecontextid = $this->context->id;
     $data->competencies = array();
     $contextcache = array();
     $gradable = is_enrolled($this->context, $USER, 'moodle/competency:coursecompetencygradable');
     if ($gradable) {
         $usercompetencycourses = api::list_user_competencies_in_course($this->courseid, $USER->id);
         $data->gradableuserid = $USER->id;
     }
     $ruleoutcomelist = course_competency::get_ruleoutcome_list();
     $ruleoutcomeoptions = array();
     foreach ($ruleoutcomelist as $value => $text) {
         $ruleoutcomeoptions[$value] = array('value' => $value, 'text' => (string) $text, 'selected' => false);
     }
     foreach ($this->coursecompetencylist as $coursecompetencyelement) {
         $coursecompetency = $coursecompetencyelement['coursecompetency'];
         $competency = $coursecompetencyelement['competency'];
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         $compexporter = new competency_exporter($competency, array('context' => $context));
         $ccexporter = new course_competency_exporter($coursecompetency, array('context' => $context));
         $ccoutcomeoptions = (array) (object) $ruleoutcomeoptions;
         $ccoutcomeoptions[$coursecompetency->get_ruleoutcome()]['selected'] = true;
         $coursemodules = api::list_course_modules_using_competency($competency->get_id(), $this->courseid);
         $fastmodinfo = get_fast_modinfo($this->courseid);
         $exportedmodules = array();
         foreach ($coursemodules as $cmid) {
             $cminfo = $fastmodinfo->cms[$cmid];
             $cmexporter = new course_module_summary_exporter(null, array('cm' => $cminfo));
             $exportedmodules[] = $cmexporter->export($output);
         }
         // Competency path.
         $pathexporter = new competency_path_exporter(['ancestors' => $competency->get_ancestors(), 'framework' => $competency->get_framework(), 'context' => $context]);
         $onerow = array('competency' => $compexporter->export($output), 'coursecompetency' => $ccexporter->export($output), 'ruleoutcomeoptions' => $ccoutcomeoptions, 'coursemodules' => $exportedmodules, 'comppath' => $pathexporter->export($output));
         if ($gradable) {
             $foundusercompetencycourse = false;
             foreach ($usercompetencycourses as $usercompetencycourse) {
                 if ($usercompetencycourse->get_competencyid() == $competency->get_id()) {
                     $foundusercompetencycourse = $usercompetencycourse;
                 }
             }
             if ($foundusercompetencycourse) {
                 $related = array('scale' => $competency->get_scale());
                 $exporter = new user_competency_course_exporter($foundusercompetencycourse, $related);
                 $onerow['usercompetencycourse'] = $exporter->export($output);
             }
         }
         array_push($data->competencies, $onerow);
     }
     $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
     $data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
     $data->canconfigurecoursecompetencies = $this->canconfigurecoursecompetencies;
     $data->cangradecompetencies = $this->cangradecompetencies;
     $exporter = new course_competency_settings_exporter($this->coursecompetencysettings);
     $data->settings = $exporter->export($output);
     $related = array('context' => $this->context);
     $exporter = new course_competency_statistics_exporter($this->coursecompetencystatistics, $related);
     $data->statistics = $exporter->export($output);
     $data->manageurl = null;
     if ($this->canmanagecompetencyframeworks) {
         $data->manageurl = $this->manageurl->out(true);
     }
     return $data;
 }
示例#11
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)));
 }
 /**
  * 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;
 }
示例#13
0
 /**
  * Returns description of data_for_related_competencies_section_returns() result value.
  *
  * @return external_description
  */
 public static function data_for_related_competencies_section_returns()
 {
     return new external_single_structure(array('relatedcompetencies' => new external_multiple_structure(competency_exporter::get_read_structure()), 'showdeleterelatedaction' => new external_value(PARAM_BOOL, 'Whether to show the delete relation link or not')));
 }
示例#14
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)
 {
     global $CFG, $DB, $PAGE;
     $context = context_course::instance($this->courseid);
     $data = new stdClass();
     $data->userid = $this->userid;
     $data->competencyid = $this->competencyid;
     $data->courseid = $this->courseid;
     $data->baseurl = $this->baseurl;
     $data->groupselector = '';
     if (has_any_capability(array('moodle/competency:usercompetencyview', 'moodle/competency:coursecompetencymanage'), $context)) {
         $course = $DB->get_record('course', array('id' => $this->courseid));
         $currentgroup = groups_get_course_group($course, true);
         if ($currentgroup !== false) {
             $select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup);
             $data->groupselector = $select;
         }
         // Fetch showactive.
         $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
         $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
         $showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
         $users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.*', null, 0, 0, $showonlyactiveenrol);
         $data->users = array();
         foreach ($users as $user) {
             $exporter = new user_summary_exporter($user);
             $user = $exporter->export($output);
             if ($user->id == $this->userid) {
                 $user->selected = true;
             }
             $data->users[] = $user;
         }
         $data->hasusers = true;
     } else {
         $data->users = array();
         $data->hasusers = false;
     }
     $coursecompetencies = \core_competency\api::list_course_competencies($this->courseid);
     $data->competencies = array();
     $contextcache = array();
     foreach ($coursecompetencies as $coursecompetency) {
         $frameworkid = $coursecompetency['competency']->get_competencyframeworkid();
         if (!isset($contextcache[$frameworkid])) {
             $contextcache[$frameworkid] = $coursecompetency['competency']->get_context();
         }
         $context = $contextcache[$frameworkid];
         $coursecompetencycontext = $context;
         $exporter = new competency_exporter($coursecompetency['competency'], array('context' => $coursecompetencycontext));
         $competency = $exporter->export($output);
         if ($competency->id == $this->competencyid) {
             $competency->selected = true;
         }
         $data->competencies[] = $competency;
     }
     $data->hascompetencies = count($data->competencies);
     return $data;
 }
示例#16
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;
 }