/** * Add the unit handling options to the form. * @param object $mform the form being built. */ protected function add_unit_options($mform) { $mform->addElement('header', 'unithandling', get_string('unithandling', 'qtype_numerical')); $unitoptions = array(qtype_numerical::UNITNONE => get_string('onlynumerical', 'qtype_numerical'), qtype_numerical::UNITOPTIONAL => get_string('manynumerical', 'qtype_numerical'), qtype_numerical::UNITGRADED => get_string('unitgraded', 'qtype_numerical')); $mform->addElement('select', 'unitrole', get_string('unithandling', 'qtype_numerical'), $unitoptions); $penaltygrp = array(); $penaltygrp[] = $mform->createElement('text', 'unitpenalty', get_string('unitpenalty', 'qtype_numerical'), array('size' => 6)); $mform->setType('unitpenalty', PARAM_FLOAT); $mform->setDefault('unitpenalty', 0.1); $unitgradingtypes = array(qtype_numerical::UNITGRADEDOUTOFMARK => get_string('decfractionofresponsegrade', 'qtype_numerical'), qtype_numerical::UNITGRADEDOUTOFMAX => get_string('decfractionofquestiongrade', 'qtype_numerical')); $penaltygrp[] = $mform->createElement('select', 'unitgradingtypes', '', $unitgradingtypes); $mform->setDefault('unitgradingtypes', 1); $mform->addGroup($penaltygrp, 'penaltygrp', get_string('unitpenalty', 'qtype_numerical'), ' ', false); $mform->addHelpButton('penaltygrp', 'unitpenalty', 'qtype_numerical'); $unitinputoptions = array(qtype_numerical::UNITINPUT => get_string('editableunittext', 'qtype_numerical'), qtype_numerical::UNITRADIO => get_string('unitchoice', 'qtype_numerical'), qtype_numerical::UNITSELECT => get_string('unitselect', 'qtype_numerical')); $mform->addElement('select', 'multichoicedisplay', get_string('studentunitanswer', 'qtype_numerical'), $unitinputoptions); $unitsleftoptions = array(0 => get_string('rightexample', 'qtype_numerical'), 1 => get_string('leftexample', 'qtype_numerical')); $mform->addElement('select', 'unitsleft', get_string('unitposition', 'qtype_numerical'), $unitsleftoptions); $mform->setDefault('unitsleft', 0); $mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITNONE); $mform->disabledIf('penaltygrp', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL); $mform->disabledIf('unitsleft', 'unitrole', 'eq', qtype_numerical::UNITNONE); $mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITNONE); $mform->disabledIf('multichoicedisplay', 'unitrole', 'eq', qtype_numerical::UNITOPTIONAL); }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('checkbox', $this->_name . '_sck', null, get_string('isafter', 'filters')); $objs[] =& $mform->createElement('date_selector', $this->_name . '_sdt', null); $objs[] =& $mform->createElement('static', $this->_name . '_break', null, '<br>'); $objs[] =& $mform->createElement('checkbox', $this->_name . '_eck', null, get_string('isbefore', 'filters')); $objs[] =& $mform->createElement('date_selector', $this->_name . '_edt', null); $objs[] =& $mform->createElement('checkbox', $this->_name . '_never', null, get_string('includenever', 'filters')); $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false); $grp->setHelpButton(array('date', $this->_label, 'filters')); if ($this->_advanced) { $mform->setAdvanced($this->_name . '_grp'); } if ($this->_advanced) { $mform->setAdvanced($this->_name . '_grp'); } $mform->disabledIf($this->_name . '_sdt[day]', $this->_name . '_sck', 'notchecked'); $mform->disabledIf($this->_name . '_sdt[month]', $this->_name . '_sck', 'notchecked'); $mform->disabledIf($this->_name . '_sdt[year]', $this->_name . '_sck', 'notchecked'); $mform->disabledIf($this->_name . '_edt[day]', $this->_name . '_eck', 'notchecked'); $mform->disabledIf($this->_name . '_edt[month]', $this->_name . '_eck', 'notchecked'); $mform->disabledIf($this->_name . '_edt[year]', $this->_name . '_eck', 'notchecked'); $mform->disabledIf($this->_name . '_never', $this->_name . '_eck', 'notchecked'); }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_sck', null, get_string('isafter', 'filters'), null, array('0', '1')); $objs[] =& $mform->createElement('date_selector', $this->_uniqueid . '_sdt', null, array('optional' => false)); $objs[] =& $mform->createElement('static', $this->_uniqueid . '_break', null, '<br/>'); $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_eck', null, get_string('isbefore', 'filters'), null, array('0', '1')); $objs[] =& $mform->createElement('date_selector', $this->_uniqueid . '_edt', null, array('optional' => false)); if ($this->_never_included) { $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_never', null, get_string('includenever', 'filters')); } $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false); $grp->setHelpButton($this->_filterhelp); if ($this->_advanced) { $mform->setAdvanced($this->_uniqueid . '_grp'); } $mform->disabledIf($this->_uniqueid . '_sdt[day]', $this->_uniqueid . '_sck', '0'); $mform->disabledIf($this->_uniqueid . '_sdt[month]', $this->_uniqueid . '_sck', '0'); $mform->disabledIf($this->_uniqueid . '_sdt[year]', $this->_uniqueid . '_sck', '0'); $mform->disabledIf($this->_uniqueid . '_edt[day]', $this->_uniqueid . '_eck', '0'); $mform->disabledIf($this->_uniqueid . '_edt[month]', $this->_uniqueid . '_eck', '0'); $mform->disabledIf($this->_uniqueid . '_edt[year]', $this->_uniqueid . '_eck', '0'); if ($this->_never_included) { $mform->disabledIf($this->_uniqueid . '_never', $this->_uniqueid . '_eck', '0'); } }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('select', $this->_name.'_op', null, $this->getOperators()); $objs[] =& $mform->createElement('text', $this->_name, null); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); if (is_array($this->_fields)) { $objs[] =& $mform->createElement('select', $this->_name . '_fld', null, $this->_fields); } $objs[] =& $mform->createElement('checkbox', $this->_name . '_sck', null, get_string('isafter', 'filters')); $objs[] =& $mform->createElement('date_selector', $this->_name . '_sdt', null); $objs[] =& $mform->createElement('checkbox', $this->_name . '_eck', null, get_string('isbefore', 'filters')); $objs[] =& $mform->createElement('date_selector', $this->_name . '_edt', null); $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false); $grp->setHelpButton(array('date', '', 'filters')); $mform->setDefault($this->_name . '_sck', !empty($this->_value)); $mform->setDefault($this->_name . '_eck', !empty($this->_value2)); $mform->setDefault($this->_name . '_sdt', $this->_value); $mform->setDefault($this->_name . '_edt', $this->_value2); if (is_array($this->_fields)) { $mform->setDefault($this->_name . '_fld', $this->_field); } $mform->disabledIf($this->_name . '_sdt', $this->_name . '_sck'); $mform->disabledIf($this->_name . '_edt', $this->_name . '_eck'); }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->get_operators()); $objs[] =& $mform->createElement('select', $this->_name, null, $this->_options); $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false); $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0); if (!is_null($this->_default)) { $mform->setDefault($this->_name, $this->_default); } if ($this->_advanced) { $mform->setAdvanced($this->_name . '_grp'); } }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs['select'] = $mform->createElement('select', $this->_name . '_op', null, $this->getOperators()); $objs['text'] = $mform->createElement('text', $this->_name, null); $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label)); $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label)); $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false); $mform->setType($this->_name, PARAM_RAW); $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 5); if ($this->_advanced) { $mform->setAdvanced($this->_name . '_grp'); } }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('select', $this->_uniqueid . '_op', null, $this->getOperators()); $objs[] =& $mform->createElement('text', $this->_uniqueid, null); $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false); $mform->setType($this->_uniqueid, PARAM_RAW); $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]); // TBV $mform->disabledIf($this->_uniqueid, $this->_uniqueid . '_op', 'eq', 5); if ($this->_advanced) { $mform->setAdvanced($this->_uniqueid . '_grp'); } }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $objs[] =& $mform->createElement('select', $this->_uniqueid . '_op', null, $this->get_operators()); $objs[] =& $mform->createElement('select', $this->_uniqueid, null, $this->_options); $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false); $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]); // TBV $mform->disabledIf($this->_uniqueid, $this->_uniqueid . '_op', 'eq', 0); if (!is_null($this->_default)) { $mform->setDefault($this->_uniqueid, $this->_default); } if ($this->_advanced) { $mform->setAdvanced($this->_uniqueid . '_grp'); } }
/** * Add question-type specific form fields. * * @param object $mform the form being built. */ public function definition_inner($mform) { // cache this plugins name $plugin = 'qtype_ordering'; // selecttype $name = 'selecttype'; $label = get_string($name, $plugin); $options = array(0 => get_string('selectall', $plugin), 1 => get_string('selectrandom', $plugin), 2 => get_string('selectcontiguous', $plugin)); $mform->addElement('select', $name, $label, $options); $mform->addHelpButton($name, $name, $plugin); $mform->setDefault($name, 0); // selectcount $name = 'selectcount'; $label = get_string($name, $plugin); $options = array(0 => get_string('all')); for ($i = 3; $i <= 20; $i++) { $options[$i] = $i; } $mform->addElement('select', $name, $label, $options); $mform->disabledIf($name, 'selecttype', 'eq', 0); $mform->addHelpButton($name, $name, $plugin); $mform->setDefault($name, 0); // answers (=items) $elements = array(); $name = 'answerheader'; $label = get_string($name, $plugin); $elements[] =& $mform->createElement('header', $name, $label); $name = 'answer'; $label = get_string($name, $plugin); $options = array('rows' => self::NUM_ANS_ROWS, 'cols' => self::NUM_ANS_COLS); $elements[] =& $mform->createElement('textarea', $name, $label, $options); if (empty($this->question->options)) { $start = 0; } else { $start = count($this->question->options->answers); } if ($start < self::NUM_ANS_START) { $start = self::NUM_ANS_START; } $options = array('answerheader' => array('expanded' => true)); $buttontext = get_string('addmoreanswers', $plugin, self::NUM_ANS_ADD); $this->repeat_elements($elements, $start, $options, 'countanswers', 'addanswers', self::NUM_ANS_ADD, $buttontext); // feedback $this->add_ordering_feedback_fields(); }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @return bool */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // Constant values override both default and submitted ones // default values are overriden by submitted. $value = $this->_findValue($caller->_constantValues); if (null === $value) { // If no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case. if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } $requestvalue = $value; if ($value == 0) { $value = time(); } if (!is_array($value)) { $calendartype = \core_calendar\type_factory::get_calendar_instance(); $currentdate = $calendartype->timestamp_to_date_array($value, $this->_options['timezone']); $value = array('day' => $currentdate['mday'], 'month' => $currentdate['mon'], 'year' => $currentdate['year']); // If optional, default to off, unless a date was provided. if ($this->_options['optional']) { $value['enabled'] = $requestvalue != 0; } } else { $value['enabled'] = isset($value['enabled']); } if (null !== $value) { $this->setValue($value); } break; case 'createElement': // Optional is an optional param, if its set we need to add a disabledIf rule. // If its empty or not specified then its not an optional dateselector. if (!empty($arg[2]['optional']) && !empty($arg[0])) { // When using the function addElement, rather than createElement, we still // enter this case, making this check necessary. if ($this->_usedcreateelement) { $caller->disabledIf($arg[0] . '[day]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[month]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[year]', $arg[0] . '[enabled]'); } else { $caller->disabledIf($arg[0], $arg[0] . '[enabled]'); } } return parent::onQuickFormEvent($event, $arg, $caller); break; case 'addElement': $this->_usedcreateelement = false; return parent::onQuickFormEvent($event, $arg, $caller); break; default: return parent::onQuickFormEvent($event, $arg, $caller); } }
/** * hook to add plagiarism specific settings to a module settings page * @param object $mform - Moodle form * @param object $context - current context */ public function get_form_elements_module($mform, $context) { global $DB; $plagiarismsettings = (array) get_config('plagiarism'); if (!empty($plagiarismsettings['crot_use'])) { $cmid = optional_param('update', 0, PARAM_INT); //there doesn't seem to be a way to obtain the current cm a better way - $this->_cm is not available here. if (!empty($cmid)) { $plagiarismvalues = $DB->get_records_menu('plagiarism_crot_config', array('cm' => $cmid), '', 'name,value'); } $plagiarismelements = $this->config_options(); $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); $mform->addElement('header', 'crotdesc', get_string('crot', 'plagiarism_crot')); $mform->addHelpButton('crotdesc', 'crot', 'plagiarism_crot'); $mform->addElement('select', 'crot_use', get_string("usecrot", "plagiarism_crot"), $ynoptions); $mform->addElement('select', 'crot_local', get_string("comparestudents", "plagiarism_crot"), $ynoptions); $mform->disabledIf('crot_local', 'crot_use', 'eq', 0); $mform->setDefault('crot_local', '1'); $mform->addElement('select', 'crot_global', get_string("compareinternet", "plagiarism_crot"), $ynoptions); $mform->disabledIf('crot_global', 'crot_use', 'eq', 0); foreach ($plagiarismelements as $element) { if (isset($plagiarismvalues[$element])) { $mform->setDefault($element, $plagiarismvalues[$element]); } } } //Add elements to form using standard mform like: //$mform->addElement('hidden', $element); //$mform->disabledIf('plagiarism_draft_submit', 'var4', 'eq', 0); }
/** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { $objs = array(); $options = array('optional' => false); if (!empty($this->_timezone)) { $options['timezone'] = $this->_timezone; } if (!empty($this->_startyear)) { $options['startyear'] = $this->_startyear; } if (!empty($this->_stopyear)) { $options['stopyear'] = $this->_stopyear; } $date_elem = $this->_inctime ? 'date_time_selector' : 'date_selector'; $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_sck', null, get_string('isafter', 'filters')); $objs[] =& $mform->createElement($date_elem, $this->_uniqueid . '_sdt', null, $options); $objs[] =& $mform->createElement('static', $this->_uniqueid . '_break', null, '<br/>'); $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_eck', null, get_string('isbefore', 'filters')); $objs[] =& $mform->createElement($date_elem, $this->_uniqueid . '_edt', null, $options); if ($this->_never_included) { $objs[] =& $mform->createElement('advcheckbox', $this->_uniqueid . '_never', null, get_string('includenever', 'filters')); } $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false); $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]); // TBV if ($this->_advanced) { $mform->setAdvanced($this->_uniqueid . '_grp'); } $mform->disabledIf($this->_uniqueid . '_sdt[day]', $this->_uniqueid . '_sck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_sdt[month]', $this->_uniqueid . '_sck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_sdt[year]', $this->_uniqueid . '_sck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_edt[day]', $this->_uniqueid . '_eck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_edt[month]', $this->_uniqueid . '_eck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_edt[year]', $this->_uniqueid . '_eck', 'notchecked'); if ($this->_inctime) { $mform->disabledIf($this->_uniqueid . '_sdt[hour]', $this->_uniqueid . '_sck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_sdt[minute]', $this->_uniqueid . '_sck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_edt[hour]', $this->_uniqueid . '_eck', 'notchecked'); $mform->disabledIf($this->_uniqueid . '_edt[minute]', $this->_uniqueid . '_eck', 'notchecked'); } if ($this->_never_included) { $mform->disabledIf($this->_uniqueid . '_never', $this->_uniqueid . '_eck', '0'); } }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); if (null === $value) { // if no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } $requestvalue = $value; if ($value == 0) { $value = time(); } if (!is_array($value)) { $currentdate = usergetdate($value, $this->_options['timezone']); // Round minutes to the previous multiple of step. $currentdate['minutes'] -= $currentdate['minutes'] % $this->_options['step']; $value = array('minute' => $currentdate['minutes'], 'hour' => $currentdate['hours']); // If optional, default to off, unless a date was provided if ($this->_options['optional']) { $value['off'] = $requestvalue == 0 ? true : false; } } else { $value['off'] = isset($value['off']) ? true : false; } if (null !== $value) { $this->setValue($value); } break; case 'createElement': if (isset($arg[2]['checked']) and 0 == strcmp('checked', $arg[2]['checked'])) { $caller->setDefault($arg[0] . '[timeenable]', true); } if (!empty($arg[2]['optional'])) { $caller->disabledIf($arg[0], $arg[0] . '[timeenable]', 'checked'); } if (!empty($arg[2]['display_12h'])) { $this->display_12h = true; } return parent::onQuickFormEvent($event, $arg, $caller); break; default: return parent::onQuickFormEvent($event, $arg, $caller); } }
/** * adds the list of plagiarism settings to a form * * @param object $mform - Moodle form object */ function turnitin_get_form_elements($mform) { $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); $tiishowoptions = array(PLAGIARISM_TII_SHOW_NEVER => get_string("never"), PLAGIARISM_TII_SHOW_ALWAYS => get_string("always"), PLAGIARISM_TII_SHOW_CLOSED => get_string("showwhenclosed", "plagiarism_turnitin")); $tiidraftoptions = array(PLAGIARISM_TII_DRAFTSUBMIT_IMMEDIATE => get_string("submitondraft", "plagiarism_turnitin"), PLAGIARISM_TII_DRAFTSUBMIT_FINAL => get_string("submitonfinal", "plagiarism_turnitin")); $reportgenoptions = array(0 => get_string('reportgenimmediate', 'plagiarism_turnitin'), 1 => get_string('reportgenimmediateoverwrite', 'plagiarism_turnitin'), 2 => get_string('reportgenduedate', 'plagiarism_turnitin')); $excludetype = array(0 => get_string('no'), 1 => get_string('wordcount', 'plagiarism_turnitin'), 2 => get_string('percentage', 'plagiarism_turnitin')); $mform->addElement('header', 'plagiarismdesc'); $mform->addElement('select', 'use_turnitin', get_string("useturnitin", "plagiarism_turnitin"), $ynoptions); $mform->addElement('select', 'plagiarism_show_student_score', get_string("showstudentsscore", "plagiarism_turnitin"), $tiishowoptions); $mform->addHelpButton('plagiarism_show_student_score', 'showstudentsscore', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_show_student_report', get_string("showstudentsreport", "plagiarism_turnitin"), $tiishowoptions); $mform->addHelpButton('plagiarism_show_student_report', 'showstudentsreport', 'plagiarism_turnitin'); if ($mform->elementExists('var4')) { $mform->addElement('select', 'plagiarism_draft_submit', get_string("draftsubmit", "plagiarism_turnitin"), $tiidraftoptions); } $mform->addElement('select', 'plagiarism_compare_student_papers', get_string("comparestudents", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_compare_student_papers', 'comparestudents', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_compare_internet', get_string("compareinternet", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_compare_internet', 'compareinternet', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_compare_journals', get_string("comparejournals", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_compare_journals', 'comparejournals', 'plagiarism_turnitin'); if (get_config('plagiarism', 'turnitin_institutionnode')) { $mform->addElement('select', 'plagiarism_compare_institution', get_string("compareinstitution", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_compare_institution', 'compareinstitution', 'plagiarism_turnitin'); } $mform->addElement('select', 'plagiarism_report_gen', get_string("reportgen", "plagiarism_turnitin"), $reportgenoptions); $mform->addHelpButton('plagiarism_report_gen', 'reportgen', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_exclude_biblio', get_string("excludebiblio", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_exclude_biblio', 'excludebiblio', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_exclude_quoted', get_string("excludequoted", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_exclude_quoted', 'excludequoted', 'plagiarism_turnitin'); $mform->addElement('select', 'plagiarism_exclude_matches', get_string("excludematches", "plagiarism_turnitin"), $excludetype); $mform->addHelpButton('plagiarism_exclude_matches', 'excludematches', 'plagiarism_turnitin'); $mform->addElement('text', 'plagiarism_exclude_matches_value', ''); $mform->addRule('plagiarism_exclude_matches_value', null, 'numeric', null, 'client'); $mform->disabledIf('plagiarism_exclude_matches_value', 'plagiarism_exclude_matches', 'eq', 0); $mform->addElement('select', 'plagiarism_anonymity', get_string("anonymity", "plagiarism_turnitin"), $ynoptions); $mform->addHelpButton('plagiarism_anonymity', 'anonymity', 'plagiarism_turnitin'); }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); if (null === $value) { // if no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } $requestvalue = $value; if ($value == 0) { $value = time(); } if (!is_array($value)) { $currentdate = usergetdate($value); $value = array('day' => $currentdate['mday'], 'month' => $currentdate['mon'], 'year' => $currentdate['year']); // If optional, default to off, unless a date was provided if ($this->_options['optional']) { $value['enabled'] = $requestvalue != 0; } } else { $value['enabled'] = isset($value['enabled']); } if (null !== $value) { $this->setValue($value); } break; case 'createElement': if ($arg[2]['optional']) { $caller->disabledIf($arg[0], $arg[0] . '[enabled]'); } return parent::onQuickFormEvent($event, $arg, $caller); break; default: return parent::onQuickFormEvent($event, $arg, $caller); } }
/** * Custom moodle profile field plugin definition_after_data function * * @param object $form the custom field form object to embelish * @param string $level the ELIS context level name: user, track, userset ... * @param string $shortname the custom field shortname * @uses $DB */ function moodleprofile_field_edit_form_definition_after_data($form, $level, $shortname) { global $DB; if ($level != 'user') { return; } $moodlefield = $DB->get_record('user_info_field', array('shortname' => $shortname)); if (empty($moodlefield)) { return; } $fieldtypenosync = get_invalid_sync_controls($moodlefield->datatype); if (!empty($fieldtypenosync)) { foreach ($fieldtypenosync as $nosync) { $form->disabledIf('moodle_profile_exclusive', 'manual_field_control', 'eq', $nosync); } } }
/** * Implementation of the function for printing the form elements that control * whether the course reset functionality affects the survey. * * @param object $mform form passed by reference */ function survey_reset_course_form_definition(&$mform) { $mform->addElement('header', 'surveyheader', get_string('modulenameplural', 'survey')); $mform->addElement('checkbox', 'reset_survey_answers', get_string('deleteallanswers','survey')); $mform->addElement('checkbox', 'reset_survey_analysis', get_string('deleteanalysis','survey')); $mform->disabledIf('reset_survey_analysis', 'reset_survey_answers', 'checked'); }
/** * Implementation of the function for printing the form elements that control * whether the course reset functionality affects the glossary. * @param object $mform form passed by reference */ function glossary_reset_course_form_definition(&$mform) { $mform->addElement('header', 'glossaryheader', get_string('modulenameplural', 'glossary')); $mform->addElement('checkbox', 'reset_glossary_all', get_string('resetglossariesall','glossary')); $mform->addElement('select', 'reset_glossary_types', get_string('resetglossaries', 'glossary'), array('main'=>get_string('mainglossary', 'glossary'), 'secondary'=>get_string('secondaryglossary', 'glossary')), array('multiple' => 'multiple')); $mform->setAdvanced('reset_glossary_types'); $mform->disabledIf('reset_glossary_types', 'reset_glossary_all', 'checked'); $mform->addElement('checkbox', 'reset_glossary_notenrolled', get_string('deletenotenrolled', 'glossary')); $mform->disabledIf('reset_glossary_notenrolled', 'reset_glossary_all', 'checked'); $mform->addElement('checkbox', 'reset_glossary_ratings', get_string('deleteallratings')); $mform->disabledIf('reset_glossary_ratings', 'reset_glossary_all', 'checked'); $mform->addElement('checkbox', 'reset_glossary_comments', get_string('deleteallcomments')); $mform->disabledIf('reset_glossary_comments', 'reset_glossary_all', 'checked'); }
/** * add_field_showactivitygrades * * @param object $mform * @param string $plugin * @param array $types * @return void, but will update $mform */ protected function add_field_showactivitygrades($mform, $plugin, $types) { $name = 'showactivitygrades'; $config_name = 'config_' . $name; $elements_name = 'elements_' . $name; $label = get_string($name, $plugin); $elements = array(); // "all" or "specific" activity types $options = array('' => get_string('none'), 'all' => get_string('allgradeableactivities', $plugin), 'specific' => get_string('specificactivitytypes', $plugin)); $elements[] = $mform->createElement('select', $config_name, '', $options); // multi-select list of activity types $params = array('multiple' => 'multiple', 'size' => min(5, count($types))); $elements[] = $mform->createElement('select', $config_name . 'types', '', $types, $params); // add group of elements $mform->addElement('group', $elements_name, $label, $elements, ' ', false); $mform->addHelpButton($elements_name, $name, $plugin); // set elements types $mform->setType($config_name, PARAM_ALPHA); $mform->setType($config_name . 'types', PARAM_ALPHANUM); // set elements defaults $mform->setDefault($config_name, $this->defaultvalue($name)); $mform->setDefault($config_name . 'types', $this->defaultvalue($name . 'types')); // specify conditional access to list of activity types $mform->disabledIf($config_name . 'types[]', $config_name, 'ne', 'specific'); }
/** * Called by HTML_QuickForm whenever form event is made on this element. * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @return mixed */ public function onQuickFormEvent($event, $arg, &$caller) { global $COURSE; switch ($event) { case 'updateValue': $value = $this->_findValue($caller->_constantValues); if (null === $value) { if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } $name = $this->getName(); // Set disable actions. $caller->disabledIf($name . '[modgrade_scale]', $name . '[modgrade_type]', 'neq', 'scale'); $caller->disabledIf($name . '[modgrade_point]', $name . '[modgrade_type]', 'neq', 'point'); // Set element state for existing data. if (!empty($this->_elements)) { if (!empty($value)) { if ($value < 0) { $this->_elements[1]->setValue('scale'); $this->_elements[4]->setValue($value * -1); } else { if ($value > 0) { $this->_elements[1]->setValue('point'); $this->_elements[7]->setValue($value); } } } else { $this->_elements[1]->setValue('none'); $this->_elements[7]->setValue(''); } } // Value Validation. if ($name && $caller->elementExists($name)) { $checkmaxgrade = function ($val) { if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') { if (!isset($val['modgrade_point'])) { return false; } return $this->validate_point($val['modgrade_point']); } return true; }; $checkvalidscale = function ($val) { if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'scale') { if (!isset($val['modgrade_scale'])) { return false; } return $this->validate_scale($val['modgrade_scale']); } return true; }; $maxgradeexceeded = get_string('modgradeerrorbadpoint', 'grades', get_config('core', 'gradepointmax')); $invalidscale = get_string('modgradeerrorbadscale', 'grades'); $caller->addRule($name, $maxgradeexceeded, 'callback', $checkmaxgrade); $caller->addRule($name, $invalidscale, 'callback', $checkvalidscale); } break; } return parent::onQuickFormEvent($event, $arg, $caller); }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @return bool */ public function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // Constant values override both default and submitted ones, // default values are overriden by submitted. $value = $this->_findValue($caller->_constantValues); if (null === $value) { // If no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case. if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } if (!is_array($value)) { list($number, $unit) = $this->value_to_unit($value); $value = array('number' => $number, 'timeunit' => $unit); // If optional, default to off, unless a date was provided. if ($this->_options['optional']) { $value['enabled'] = $number != 0; } } else { $value['enabled'] = isset($value['enabled']); } if (null !== $value) { $this->setValue($value); } break; case 'createElement': if (!empty($arg[2]['optional'])) { $caller->disabledIf($arg[0], $arg[0] . '[enabled]'); } $caller->setType($arg[0] . '[number]', PARAM_INT); return parent::onQuickFormEvent($event, $arg, $caller); break; default: return parent::onQuickFormEvent($event, $arg, $caller); } }
/** * hook to add plagiarism specific settings to a module settings page * @param object $mform - Moodle form * @param object $context - current context */ public function get_form_elements_module($mform, $context, $modulename = '') { global $CFG, $DB; $plagiarismsettings = $this->get_settings(); if (!$plagiarismsettings) { return; } $cmid = optional_param('update', 0, PARAM_INT); if (!empty($cmid)) { $plagiarismvalues = $DB->get_records_menu('plagiarism_vericite_config', array('cm' => $cmid), '', 'name,value'); } $plagiarismelements = $this->config_options(); //add form: $mform->addElement('header', 'plagiarismdesc', get_string('pluginname', 'plagiarism_vericite')); $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); $mform->addElement('checkbox', 'use_vericite', get_string("usevericite", "plagiarism_vericite")); if (isset($plagiarismvalues['use_vericite'])) { $mform->setDefault('use_vericite', $plagiarismvalues['use_vericite']); } else { if (strcmp("mod_forum", $modulename) != 0 && isset($plagiarismsettings['vericite_use_default'])) { $mform->setDefault('use_vericite', $plagiarismsettings['vericite_use_default']); } } $mform->addElement('checkbox', 'plagiarism_show_student_score', get_string("studentscorevericite", "plagiarism_vericite")); $mform->addHelpButton('plagiarism_show_student_score', 'studentscorevericite', 'plagiarism_vericite'); $mform->disabledIf('plagiarism_show_student_score', 'use_vericite'); if (isset($plagiarismvalues['plagiarism_show_student_score'])) { $mform->setDefault('plagiarism_show_student_score', $plagiarismvalues['plagiarism_show_student_score']); } else { if (strcmp("mod_forum", $modulename) != 0 && isset($plagiarismsettings['vericite_student_score_default'])) { $mform->setDefault('plagiarism_show_student_score', $plagiarismsettings['vericite_student_score_default']); } else { if (strcmp("mod_forum", $modulename) == 0 && isset($plagiarismsettings['vericite_student_score_default_forums'])) { $mform->setDefault('plagiarism_show_student_score', $plagiarismsettings['vericite_student_score_default_forums']); } } } $mform->addElement('checkbox', 'plagiarism_show_student_report', get_string("studentreportvericite", "plagiarism_vericite")); $mform->addHelpButton('plagiarism_show_student_report', 'studentreportvericite', 'plagiarism_vericite'); $mform->disabledIf('plagiarism_show_student_report', 'use_vericite'); if (isset($plagiarismvalues['plagiarism_show_student_report'])) { $mform->setDefault('plagiarism_show_student_report', $plagiarismvalues['plagiarism_show_student_report']); } else { if (strcmp("mod_forum", $modulename) != 0 && isset($plagiarismsettings['vericite_student_score_default'])) { $mform->setDefault('plagiarism_show_student_report', $plagiarismsettings['vericite_student_report_default']); } else { if (strcmp("mod_forum", $modulename) == 0 && isset($plagiarismsettings['vericite_student_score_default_forums'])) { $mform->setDefault('plagiarism_show_student_report', $plagiarismsettings['vericite_student_report_default_forums']); } } } }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @return bool */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); if (null === $value) { // if no boxes were checked, then there is no value in the array // yet we don't want to display default value in this case if ($caller->isSubmitted()) { $value = $this->_findValue($caller->_submitValues); } else { $value = $this->_findValue($caller->_defaultValues); } } $requestvalue = $value; if ($value == 0) { $value = $this->_options['defaulttime']; if (!$value) { $value = time(); } } if (!is_array($value)) { $currentdate = usergetdate($value, $this->_options['timezone']); // Round minutes to the previous multiple of step. $currentdate['minutes'] -= $currentdate['minutes'] % $this->_options['step']; $value = array('minute' => $currentdate['minutes'], 'hour' => $currentdate['hours'], 'day' => $currentdate['mday'], 'month' => $currentdate['mon'], 'year' => $currentdate['year']); // If optional, default to off, unless a date was provided if ($this->_options['optional']) { $value['enabled'] = $requestvalue != 0; } } else { $value['enabled'] = isset($value['enabled']); } if (null !== $value) { $this->setValue($value); } break; case 'createElement': if ($arg[2]['optional']) { // When using the function addElement, rather than createElement, we still // enter this case, making this check necessary. if ($this->_usedcreateelement) { $caller->disabledIf($arg[0] . '[day]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[month]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[year]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[hour]', $arg[0] . '[enabled]'); $caller->disabledIf($arg[0] . '[minute]', $arg[0] . '[enabled]'); } else { $caller->disabledIf($arg[0], $arg[0] . '[enabled]'); } } return parent::onQuickFormEvent($event, $arg, $caller); break; case 'addElement': $this->_usedcreateelement = false; return parent::onQuickFormEvent($event, $arg, $caller); break; default: return parent::onQuickFormEvent($event, $arg, $caller); } }
/** * Add form elements for course contact information. * @param object $mform form definition * @param object $courseinfo a record of general information from course info table. * @param object $contactinfo a record of contact information from course instructor table. * @return void */ private function setup_contact($mform, $courseinfo, $contactinfo) { global $CFG, $DB, $USER; //Declare our globals for use global $course; $mform->addElement('html', '<a name="contact"></a>'); // anchor $mform->addElement('header', 'course_contact_header', get_string('course_contact_header', 'local_metadata')); // Email $course_email = $mform->addElement('text', 'course_email', get_string('course_email', 'local_metadata'), ''); if ($contactinfo) { $mform->setDefault('course_email', $contactinfo->email); } else { $mform->setDefault('course_email', $USER->email); } //$mform->addRule('course_email', get_string('err_required', 'local_metadata'), 'required', null, 'client'); $mform->addRule('course_email', get_string('err_email', 'local_metadata'), 'email', null, 'client'); $mform->setType('course_email', PARAM_TEXT); // Phone $course_phone = $mform->addElement('text', 'course_phone', get_string('course_phone', 'local_metadata'), ''); if ($contactinfo) { $mform->setDefault('course_phone', $contactinfo->phonenumber); } $mform->setType('course_phone', PARAM_TEXT); // Office $course_office = $mform->addElement('text', 'course_office', get_string('course_office', 'local_metadata'), ''); if ($contactinfo) { $mform->setDefault('course_office', $contactinfo->officelocation); } //$mform->addRule('course_office', get_string('err_required', 'local_metadata'), 'required', null, 'client'); $mform->setType('course_office', PARAM_TEXT); // Office hours // Set default hours $mform->addElement('advcheckbox', 'default_officeh', get_string('course_officeh', 'local_metadata'), get_string('default_officeh', 'local_metadata'), null, array(0, get_string('default_officeh', 'local_metadata'))); $mform->addHelpButton('default_officeh', 'default_officeh', 'local_metadata'); // Set day $daygroup = array(); foreach (get_days() as $day) { $daygroup[] =& $mform->createElement('advcheckbox', $day, '', $day, null, array(0, $day)); } $mform->addGroup($daygroup, 'daygroup', '', array(' '), false); // Set time $timegroup = array(); $hour = array(); for ($i = 0; $i < 13; $i++) { $hour[] = sprintf("%02d", $i); } $minute = array(); for ($i = 0; $i < 60; $i++) { $minute[] = sprintf("%02d", $i); } $time_format = array('AM', 'PM'); $timegroup[] =& $mform->createElement('static', 'fromhour_label', '', get_string('fromhour_label', 'local_metadata')); $timegroup[] =& $mform->createElement('select', 'fromhour', '', $hour, ''); $timegroup[] =& $mform->createElement('select', 'fromminute', '', $minute, ''); $timegroup[] =& $mform->createElement('select', 'fromformat', '', $time_format, ''); $timegroup[] =& $mform->createElement('static', 'tohour_label', '', get_string('tohour_label', 'local_metadata')); $timegroup[] =& $mform->createElement('select', 'tohour', '', $hour, ''); $timegroup[] =& $mform->createElement('select', 'tominute', '', $minute, ''); $timegroup[] =& $mform->createElement('select', 'toformat', '', $time_format, ''); $mform->addGroup($timegroup, 'timegroup', '', array(' '), false); $mform->disabledIf('daygroup', 'default_officeh', 'checked'); $mform->disabledIf('timegroup', 'default_officeh', 'checked'); if (empty($contactinfo->officehours)) { $mform->setDefault('default_officeh', true); } else { if ($contactinfo->officehours == 'By appointment') { $mform->setDefault('default_officeh', true); } else { $formats = explode(" ", $contactinfo->officehours); $mform->setDefault('toformat', array_pop($formats) == 'AM' ? 0 : 1); $totimes = explode(":", array_pop($formats)); $mform->setDefault('tohour', $totimes[0]); $mform->setDefault('tominute', $totimes[1]); array_pop($formats); $mform->setDefault('fromformat', array_pop($formats) == 'AM' ? 0 : 1); $fromtimes = explode(":", array_pop($formats)); $mform->setDefault('fromhour', $fromtimes[0]); $mform->setDefault('fromminute', $fromtimes[1]); foreach ($formats as $day) { $mform->setDefault($day, true); } } } $mform->addElement('static', 'h_2', ''); // end of header $mform->setType('h_2', PARAM_RAW); $mform->closeHeaderBefore('h_2'); $mform->setExpanded('course_contact_header'); }