/** * 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); }
/** * Constructor * * @param string $elementname Element name * @param mixed $elementlabel Label(s) for an element * @param array $options Options to control the element's display * Valid options are: * 'multiple' - boolean multi select * 'exclude' - array or int, list of course ids to never show * 'requiredcapabilities' - array of capabilities. Uses ANY to combine them. */ public function __construct($elementname = null, $elementlabel = null, $options = array()) { if (isset($options['multiple'])) { $this->multiple = $options['multiple']; } if (isset($options['exclude'])) { $this->exclude = $options['exclude']; if (!is_array($this->exclude)) { $this->exclude = array($this->exclude); } } if (isset($options['requiredcapabilities'])) { $this->requiredcapabilities = $options['requiredcapabilities']; } $validattributes = array('ajax' => 'core/form-course-selector', 'data-requiredcapabilities' => implode(',', $this->requiredcapabilities), 'data-exclude' => implode(',', $this->exclude)); if ($this->multiple) { $validattributes['multiple'] = 'multiple'; } parent::__construct($elementname, $elementlabel, array(), $validattributes); }
/** * 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) { $validoptions = array(); if (!empty($options)) { // Only execute it when the element was created and $options has values set by user. // In onQuickFormEvent() we make sure that $options is not empty even if developer left it empty. $showstandard = core_tag_tag::BOTH_STANDARD_AND_NOT; if (isset($options['showstandard'])) { $showstandard = $options['showstandard']; } else { if (isset($options['display'])) { debugging('Option "display" is deprecated, each tag area can be configured to show standard tags or not ' . 'by admin or manager. If it is necessary for the developer to override it, please use "showstandard" option', DEBUG_DEVELOPER); if ($options['display'] === self::NOOFFICIAL) { $showstandard = core_tag_tag::HIDE_STANDARD; } else { if ($options['display'] === self::ONLYOFFICIAL) { $showstandard = core_tag_tag::STANDARD_ONLY; } } } else { if (!empty($options['component']) && !empty($options['itemtype'])) { $showstandard = core_tag_area::get_showstandard($options['component'], $options['itemtype']); } } } $this->tagsoptions = $options; $this->showstandard = $showstandard != core_tag_tag::HIDE_STANDARD; if ($this->showstandard) { $validoptions = $this->load_standard_tags(); } // Option 'tags' allows us to type new tags. $attributes['tags'] = $showstandard != core_tag_tag::STANDARD_ONLY; $attributes['multiple'] = 'multiple'; $attributes['placeholder'] = get_string('entertags', 'tag'); $attributes['showsuggestions'] = $this->showstandard; } parent::__construct($elementName, $elementLabel, $validoptions, $attributes); }
/** * Constructor * * @param string $elementname Element name * @param mixed $elementlabel Label(s) for an element * @param array $options Options to control the element's display * Valid options are: * 'multiple' - boolean multi select * 'exclude' - array or int, list of course ids to never show * 'requiredcapabilities' - array of capabilities. Uses ANY to combine them. * 'limittoenrolled' - boolean Limits to enrolled courses. * 'includefrontpage' - boolean Enables the frontpage to be selected. */ public function __construct($elementname = null, $elementlabel = null, $options = array()) { if (isset($options['multiple'])) { $this->multiple = $options['multiple']; } if (isset($options['exclude'])) { $this->exclude = $options['exclude']; if (!is_array($this->exclude)) { $this->exclude = array($this->exclude); } } if (isset($options['requiredcapabilities'])) { $this->requiredcapabilities = $options['requiredcapabilities']; } if (isset($options['limittoenrolled'])) { $this->limittoenrolled = $options['limittoenrolled']; } $validattributes = array('ajax' => 'core/form-course-selector', 'data-requiredcapabilities' => implode(',', $this->requiredcapabilities), 'data-exclude' => implode(',', $this->exclude), 'data-limittoenrolled' => (int) $this->limittoenrolled); if ($this->multiple) { $validattributes['multiple'] = 'multiple'; } if (isset($options['noselectionstring'])) { $validattributes['noselectionstring'] = $options['noselectionstring']; } if (isset($options['placeholder'])) { $validattributes['placeholder'] = $options['placeholder']; } if (!empty($options['includefrontpage'])) { $validattributes['data-includefrontpage'] = SITEID; } parent::__construct($elementname, $elementlabel, array(), $validattributes); }
/** * Constructor * * @param string $elementname Element name * @param mixed $elementlabel Label(s) for an element * @param array $options List of valid options for the select * @param array $attributes List of HTML attributes for the select */ public function __construct($elementname = null, $elementlabel = null, $options = [], $attributes = []) { unset($options['']); $options = ['' => get_string('noselection', 'form')] + $options; parent::__construct($elementname, $elementlabel, $options, $attributes); }
/** * 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) { if (!isset($options['display'])) { $options['display'] = self::DEFAULTUI; } $this->showingofficial = $options['display'] != MoodleQuickForm_tags::NOOFFICIAL; $validoptions = array(); if ($this->showingofficial) { $validoptions = $this->load_official_tags(); } // 'tags' option allows us to type new tags. if ($options['display'] == MoodleQuickForm_tags::ONLYOFFICIAL) { $attributes['tags'] = false; } else { $attributes['tags'] = true; } $attributes['multiple'] = 'multiple'; $attributes['placeholder'] = get_string('entertags', 'tag'); $attributes['showsuggestions'] = $this->showingofficial; parent::__construct($elementName, $elementLabel, $validoptions, $attributes); }
/** * 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) { $validoptions = array(); if (!empty($options)) { // Only execute it when the element was created and $options has values set by user. // In onQuickFormEvent() we make sure that $options is not empty even if developer left it empty. if (empty($options['display'])) { $options['display'] = self::DEFAULTUI; } $this->tagsoptions = $options; $this->showingofficial = $options['display'] != self::NOOFFICIAL; if ($this->showingofficial) { $validoptions = $this->load_official_tags(); } // Option 'tags' allows us to type new tags. if ($options['display'] == self::ONLYOFFICIAL) { $attributes['tags'] = false; } else { $attributes['tags'] = true; } $attributes['multiple'] = 'multiple'; $attributes['placeholder'] = get_string('entertags', 'tag'); $attributes['showsuggestions'] = $this->showingofficial; } parent::__construct($elementName, $elementLabel, $validoptions, $attributes); }