protected function other_preference_fields(MoodleQuickForm $mform) { $mform->addGroup(array($mform->createElement('advcheckbox', 'qtext', '', get_string('questiontext', 'quiz_responses')), $mform->createElement('advcheckbox', 'resp', '', get_string('response', 'quiz_responses')), $mform->createElement('advcheckbox', 'right', '', get_string('rightanswer', 'quiz_responses'))), 'coloptions', get_string('showthe', 'quiz_responses'), array(' '), false); $mform->disabledIf('qtext', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('resp', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('right', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); }
protected function standard_attempt_fields(MoodleQuickForm $mform) { $mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'), quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'), quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'), quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz'))); $stategroup = array($mform->createElement('advcheckbox', 'stateinprogress', '', get_string('stateinprogress', 'quiz')), $mform->createElement('advcheckbox', 'stateoverdue', '', get_string('stateoverdue', 'quiz')), $mform->createElement('advcheckbox', 'statefinished', '', get_string('statefinished', 'quiz')), $mform->createElement('advcheckbox', 'stateabandoned', '', get_string('stateabandoned', 'quiz'))); $mform->addGroup($stategroup, 'stateoptions', get_string('reportattemptsthatare', 'quiz'), array(' '), false); $mform->setDefault('stateinprogress', 1); $mform->setDefault('stateoverdue', 1); $mform->setDefault('statefinished', 1); $mform->setDefault('stateabandoned', 1); $mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) { $gm = html_writer::tag('span', quiz_get_grading_option_name($this->_customdata['quiz']->grademethod), array('class' => 'highlight')); $mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'), get_string('optonlygradedattempts', 'quiz_overview', $gm)); $mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('onlygraded', 'statefinished', 'notchecked'); } }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { $menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz')); $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu); $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz')); $mform->closeHeaderBefore('answersinstruct'); $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_shortanswer', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 54)); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD; } else { $repeatsatstart = $countanswers; } $repeatedoptions = array(); $mform->setType('answer', PARAM_RAW); $repeatedoptions['fraction']['default'] = 0; $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_shortanswer')); }
/** * @param MoodleQuickForm $mform */ function add_submit_buttons($mform) { $buttons = array(); $buttons[] =& $mform->createElement('submit', 'submitbutton', get_string('filter', 'local_mr')); $buttons[] =& $mform->createElement('submit', 'resetbutton', get_string('reset', 'local_mr')); $mform->addGroup($buttons, 'buttons', '', array(' '), false); $mform->registerNoSubmitButton('reset'); }
/** * Create the form element used to define the weight of the cell * * @param MoodleQuickForm $form * @param int $row row number * @param int $col column number * @return object */ public function create_cell_element($form, $row, $col, $multiple) { $cell_name = $this->cell_name($row, $col, $multiple); if ($multiple) { return $form->createElement('checkbox', $cell_name, 'label'); } else { return $form->createElement('radio', $cell_name, '', '', $col); } }
function _createElements() { $this->_elements = array(); for ($i = 1; $i <= 31; $i++) { $days[$i] = $i; } for ($i = 1; $i <= 12; $i++) { $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B"); } for ($i = $this->_options['startyear']; $i <= $this->_options['stopyear']; $i++) { $years[$i] = $i; } $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true); $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true); // If optional we add a checkbox which the user can use to turn if on if ($this->_options['optional']) { $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true); } foreach ($this->_elements as $element) { if (method_exists($element, 'setHiddenLabel')) { $element->setHiddenLabel(true); } } }
function definition() { $mform =& $this->_form; $qcreate = $this->_customdata['qcreate']; if ($qcreate->graderatio != 100) { //-------------------------------------------------------------------------------- $mform->addElement('header', 'exportselection', get_string('exportselection', 'qcreate')); $menu = make_grades_menu($qcreate->grade); unset($menu[0]); $menu += array(0 => get_string('allquestions', 'qcreate')); $mform->addElement('select', 'betterthangrade', get_string('betterthangrade', 'qcreate'), $menu); $mform->setDefault('betterthangrade', 0); } $mform->addElement('header', 'exportnaming', get_string('exportnaming', 'qcreate')); $cbarray3 = array(); $cbarray3[] =& MoodleQuickForm::createElement('checkbox', 'naming[other]', '', get_string('specifictext', 'qcreate')); $cbarray3[] =& MoodleQuickForm::createElement('text', 'naming[othertext]'); $mform->addGroup($cbarray3, 'naming3', '', array(' '), false); $mform->disabledIf('naming3', 'naming[other]'); $cbarray1 = array(); $cbarray1[] =& MoodleQuickForm::createElement('checkbox', 'naming[firstname]', '', get_string('firstname')); $cbarray1[] =& MoodleQuickForm::createElement('checkbox', 'naming[lastname]', '', get_string('lastname')); $cbarray1[] =& MoodleQuickForm::createElement('checkbox', 'naming[username]', '', get_string('username', 'qcreate')); $mform->addGroup($cbarray1, 'naming1', '', array(' '), false); $cbarray2 = array(); $cbarray2[] =& MoodleQuickForm::createElement('checkbox', 'naming[activityname]', '', get_string('activityname', 'qcreate')); $cbarray2[] =& MoodleQuickForm::createElement('checkbox', 'naming[timecreated]', '', get_string('timecreated', 'qcreate')); $mform->addGroup($cbarray2, 'naming2', '', array(' '), false); parent::definition(); }
function definition() { global $CFG, $USER; $mform =& $this->_form; $course = $this->_customdata['course']; $cm = $this->_customdata['cm']; $modcontext = $this->_customdata['modcontext']; $mform->addElement('header', 'general', get_string('export', 'quiz')); $mform->setHelpButton('general', array('export', get_string('export', 'quiz'), 'attforblock')); $groupmode = groups_get_activity_groupmode($cm); $groups = groups_get_activity_allowed_groups($cm, $USER->id); if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { $grouplist[0] = get_string('allparticipants'); } if ($groups) { foreach ($groups as $group) { $grouplist[$group->id] = $group->name; } } $mform->addElement('select', 'group', get_string('group'), $grouplist); $ident = array(); $ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); $ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username')); $mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('<br />'), true); $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes')); $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock')); $mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked'); $mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attforblock'), 'ooo' => get_string('downloadooo', 'attforblock'), 'text' => get_string('downloadtext', 'attforblock'))); // buttons $submit_string = get_string('ok'); $this->add_action_buttons(false, $submit_string); $mform->addElement('hidden', 'id', $cm->id); // $mform->addElement('hidden', 'action', 'add'); }
function _createElements() { global $COURSE; $this->_elements = array(); if (!is_array($this->getAttributes()) || !array_key_exists('size', $this->getAttributes())) { $this->updateAttributes(array('size' => 48)); } $this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', $this->getAttributes()); $this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') . ' ...'); $button =& $this->_elements[1]; if ($this->_options['courseid'] !== null) { $courseid = $this->_options['courseid']; } else { $courseid = $COURSE->id; } // first find out the text field id - this is a bit hacky, is there a better way? $choose = 'id_' . str_replace(array('[', ']'), array('_', ''), $this->getElementName(0)); $url = "/files/index.php?id={$courseid}&choose=" . $choose; if ($this->_options['options'] == 'none') { $options = 'menubar=0,location=0,scrollbars,resizable,width=' . $this->_options['width'] . ',height=' . $this->_options['height']; } else { $options = $this->_options['options']; } $fullscreen = 0; $buttonattributes = array('title' => get_string("chooseafile", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});"); $button->updateAttributes($buttonattributes); }
function definition() { global $CFG, $CHOICE_SHOWRESULTS, $CHOICE_PUBLISH, $CHOICE_DISPLAY, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('choicename', 'choice'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $this->add_intro_editor(true, get_string('chatintro', 'chat')); //------------------------------------------------------------------------------- $repeatarray = array(); $repeatarray[] =& MoodleQuickForm::createElement('header', '', get_string('option', 'choice') . ' {no}'); $repeatarray[] =& MoodleQuickForm::createElement('text', 'option', get_string('option', 'choice')); $repeatarray[] =& MoodleQuickForm::createElement('text', 'limit', get_string('limit', 'choice')); $repeatarray[] =& MoodleQuickForm::createElement('hidden', 'optionid', 0); $menuoptions = array(); $menuoptions[0] = get_string('disable'); $menuoptions[1] = get_string('enable'); $mform->addElement('header', 'timerestricthdr', get_string('limit', 'choice')); $mform->addElement('select', 'limitanswers', get_string('limitanswers', 'choice'), $menuoptions); $mform->addHelpButton('limitanswers', 'limitanswers', 'choice'); if ($this->_instance) { $repeatno = $DB->count_records('choice_options', array('choiceid' => $this->_instance)); $repeatno += 2; } else { $repeatno = 5; } $repeateloptions = array(); $repeateloptions['limit']['default'] = 0; $repeateloptions['limit']['disabledif'] = array('limitanswers', 'eq', 0); $mform->setType('limit', PARAM_INT); $repeateloptions['option']['helpbutton'] = array('choiceoptions', 'choice'); $mform->setType('option', PARAM_CLEAN); $mform->setType('optionid', PARAM_INT); $this->repeat_elements($repeatarray, $repeatno, $repeateloptions, 'option_repeats', 'option_add_fields', 3); //------------------------------------------------------------------------------- $mform->addElement('header', 'timerestricthdr', get_string('timerestrict', 'choice')); $mform->addElement('checkbox', 'timerestrict', get_string('timerestrict', 'choice')); $mform->addElement('date_time_selector', 'timeopen', get_string("choiceopen", "choice")); $mform->disabledIf('timeopen', 'timerestrict'); $mform->addElement('date_time_selector', 'timeclose', get_string("choiceclose", "choice")); $mform->disabledIf('timeclose', 'timerestrict'); //------------------------------------------------------------------------------- $mform->addElement('header', 'miscellaneoussettingshdr', get_string('miscellaneoussettings', 'form')); $mform->addElement('select', 'display', get_string("displaymode", "choice"), $CHOICE_DISPLAY); $mform->addElement('select', 'showresults', get_string("publish", "choice"), $CHOICE_SHOWRESULTS); $mform->addElement('select', 'publish', get_string("privacy", "choice"), $CHOICE_PUBLISH); $mform->disabledIf('publish', 'showresults', 'eq', 0); $mform->addElement('selectyesno', 'allowupdate', get_string("allowupdate", "choice")); $mform->addElement('selectyesno', 'showunanswered', get_string("showunanswered", "choice")); //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- $this->add_action_buttons(); }
function definition() { global $CFG; $mform =& $this->_form; $course = $this->_customdata['course']; $cm = $this->_customdata['cm']; $modcontext = $this->_customdata['modcontext']; $ids = $this->_customdata['ids']; $mform->addElement('header', 'general', get_string('changeduration', 'attforblock')); $mform->addElement('static', 'count', get_string('countofselected', 'attforblock'), count(explode('_', $ids))); for ($i = 0; $i <= 23; $i++) { $hours[$i] = sprintf("%02d", $i); } for ($i = 0; $i < 60; $i += 5) { $minutes[$i] = sprintf("%02d", $i); } $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours); $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true); $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attforblock'), array(' '), true); $mform->addElement('hidden', 'ids', $ids); $mform->addElement('hidden', 'id', $cm->id); $mform->addElement('hidden', 'action', att_sessions_page_params::ACTION_CHANGE_DURATION); $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0))); //------------------------------------------------------------------------------- // buttons $submit_string = get_string('update', 'attforblock'); $this->add_action_buttons(true, $submit_string); // $mform->addElement('hidden', 'id', $cm->id); // $mform->addElement('hidden', 'sessionid', $sessionid); // $mform->addElement('hidden', 'action', 'changeduration'); }
function _createElements() { global $CFG, $COURSE; $this->_elements = array(); $this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', array('size' => '48')); $this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') . ' ...'); $button =& $this->_elements[1]; if ($this->_options['courseid'] !== null) { $courseid = $this->_options['courseid']; } else { $courseid = $COURSE->id; } // first find out the text field id - this is a bit hacky, is there a better way? $choose = 'id_' . str_replace(array('[', ']'), array('_', ''), $this->getElementName(0)); $url = "/files/index.php?id={$courseid}&choose=" . $choose; if ($this->_options['options'] == 'none') { $options = 'menubar=0,location=0,scrollbars,resizable,width=' . $this->_options['width'] . ',height=' . $this->_options['height']; } else { $options = $this->_options['options']; } $fullscreen = 0; $buttonattributes = array('title' => get_string("chooseafile", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});"); $button->updateAttributes($buttonattributes); /// With repository active, show the button to browse it if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) { $this->_elements[2] =& MoodleQuickForm::createElement('button', 'imsrepo', get_string('browserepository', 'resource')); $imsbutton =& $this->_elements[2]; $url = "/mod/resource/type/ims/finder.php?directory=&choose=" . $choose; $buttonattributes = array('title' => get_string("browserepository", "resource"), 'onclick' => "return openpopup('{$url}', '" . $button->getName() . "', '{$options}', {$fullscreen});"); $imsbutton->updateAttributes($buttonattributes); } }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name'); $addfieldsname = 'updatecategory'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory'); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1); $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 1; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}')); if ($mform->elementExists('multiplier[0]')) { $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); } //hidden elements $mform->addElement('hidden', 'synchronize', ''); if (isset($this->question->options) && isset($this->question->options->synchronize)) { $mform->setDefault("synchronize", $this->question->options->synchronize); } else { $mform->setDefault("synchronize", 0); } $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); }
function definition() { global $COURSE; $mform =& $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; $contexts = $this->_customdata['contexts']; //-------------------------------------------------------------------------------- $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz')); $fileformatnames = get_import_export_formats('import'); $radioarray = array(); foreach ($fileformatnames as $shortname => $fileformatname) { $radioelement =& MoodleQuickForm::createElement('radio', 'format', '', $fileformatname, $shortname); $radioelement->setHelpButton(array("{$shortname}", $fileformatname, "qformat_{$shortname}")); $radioarray[] = $radioelement; } $mform->addGroup($radioarray, 'format', '', array('<br />'), false); $mform->addRule('format', null, 'required', null, 'client'); //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), compact('contexts')); $mform->setDefault('category', $defaultcategory); $mform->setHelpButton('category', array('importcategory', get_string('importcategory', 'quiz'), 'quiz')); $categorygroup = array(); $categorygroup[] =& $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question')); $categorygroup[] =& $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question')); $mform->addGroup($categorygroup, 'categorygroup', '', '', false); $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked'); $mform->setDefault('catfromfile', 1); $mform->setDefault('contextfromfile', 1); $matchgrades = array(); $matchgrades['error'] = get_string('matchgradeserror', 'quiz'); $matchgrades['nearest'] = get_string('matchgradesnearest', 'quiz'); $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'quiz'), $matchgrades); $mform->setHelpButton('matchgrades', array('matchgrades', get_string('matchgrades', 'quiz'), 'quiz')); $mform->setDefault('matchgrades', 'error'); $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'quiz')); $mform->setDefault('stoponerror', 1); $mform->setHelpButton('stoponerror', array('stoponerror', get_string('stoponerror', 'quiz'), 'quiz')); //-------------------------------------------------------------------------------- $mform->addElement('header', 'importfileupload', get_string('importfileupload', 'quiz')); $mform->addElement('file', 'newfile', get_string('upload')); //-------------------------------------------------------------------------------- $mform->addElement('submit', 'submitbutton', get_string('uploadthisfile')); //-------------------------------------------------------------------------------- if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { $mform->addElement('header', 'importfilearea', get_string('importfilearea', 'quiz')); $mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile', 'quiz')); //-------------------------------------------------------------------------------- $mform->addElement('submit', 'submitbutton', get_string('importfromthisfile', 'quiz')); } //-------------------------------------------------------------------------------- $mform->addElement('static', 'dummy', ''); $mform->closeHeaderBefore('dummy'); // set a template for the format select elements $renderer =& $mform->defaultRenderer(); $template = "{help} {element}\n"; $renderer->setGroupElementTemplate($template, 'format'); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { //------------------------------------------------------------------------------------------ $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated = array(); $repeatedoptions = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz')); $mform->setType('answer', PARAM_RAW); $repeated[] =& $mform->createElement('text', 'tolerance', get_string('acceptederror', 'quiz')); $mform->setType('tolerance', PARAM_NUMBER); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeatedoptions['fraction']['default'] = 0; $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); $mform->setType('feedback', PARAM_RAW); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = QUESTION_NUMANS_START > $countanswers + 1 ? QUESTION_NUMANS_START : $countanswers + 1; } else { $repeatsatstart = $countanswers; } $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 2, get_string('addmoreanswerblanks', 'qtype_numerical')); //------------------------------------------------------------------------------------------ $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 2; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_numerical')); $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); }
function definition() { global $COURSE; $mform =& $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; $contexts = $this->_customdata['contexts']; //-------------------------------------------------------------------------------- $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz')); $fileformatnames = get_import_export_formats('import'); $radioarray = array(); foreach ($fileformatnames as $id => $fileformatname) { $radioarray[] =& MoodleQuickForm::createElement('radio', 'format', '', $fileformatname, $id); } $mform->addGroup($radioarray, 'format', '', array('<br />'), false); $mform->addRule('format', null, 'required', null, 'client'); $mform->setHelpButton('format', array('import', get_string('importquestions', 'quiz'), 'quiz')); //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), compact('contexts')); $mform->setDefault('category', $defaultcategory); $mform->setHelpButton('category', array('importcategory', get_string('importcategory', 'quiz'), 'quiz')); $categorygroup = array(); $categorygroup[] =& $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question')); $categorygroup[] =& $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question')); $mform->addGroup($categorygroup, 'categorygroup', '', '', false); $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked'); $mform->setDefault('catfromfile', 1); $mform->setDefault('contextfromfile', 1); $matchgrades = array(); $matchgrades['error'] = get_string('matchgradeserror', 'quiz'); $matchgrades['nearest'] = get_string('matchgradesnearest', 'quiz'); $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'quiz'), $matchgrades); $mform->setHelpButton('matchgrades', array('matchgrades', get_string('matchgrades', 'quiz'), 'quiz')); $mform->setDefault('matchgrades', 'error'); $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'quiz')); $mform->setDefault('stoponerror', 1); $mform->setHelpButton('stoponerror', array('stoponerror', get_string('stoponerror', 'quiz'), 'quiz')); //-------------------------------------------------------------------------------- $mform->addElement('header', 'importfileupload', get_string('importfileupload', 'quiz')); $this->set_upload_manager(new upload_manager('newfile', true, false, $COURSE, false, 0, false, true, false)); $mform->addElement('file', 'newfile', get_string('upload')); //-------------------------------------------------------------------------------- $this->add_action_buttons(true, get_string('uploadthisfile')); //-------------------------------------------------------------------------------- if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { $mform->addElement('header', 'importfilearea', get_string('importfilearea', 'quiz')); $mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile', 'quiz')); //-------------------------------------------------------------------------------- $this->add_action_buttons(true, get_string('importfromthisfile', 'quiz')); } //-------------------------------------------------------------------------------- }
function definition() { global $CFG; $mform =& $this->_form; $mform->addElement('header', 'notice', get_string('chooseexportformat', 'data')); $choices = csv_import_reader::get_delimiter_list(); $key = array_search(';', $choices); if (!$key === FALSE) { // array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon): unset($choices[$key]); } $typesarray = array(); $typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv'); $typesarray[] =& MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices); $typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls'); $typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods'); $mform->addGroup($typesarray, 'exportar', '', array(''), false); $mform->addRule('exportar', null, 'required'); $mform->setDefault('exporttype', 'csv'); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else { if (get_string('listsep') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } } $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data')); foreach ($this->_datafields as $field) { if ($field->text_export_supported()) { $mform->addElement('advcheckbox', 'field_' . $field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group' => 1)); $mform->setDefault('field_' . $field->field->id, 1); } else { $a = new object(); $a->fieldtype = $field->name(); $mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a)); } } $this->add_checkbox_controller(1, null, null, 1); require_once $CFG->libdir . '/portfoliolib.php'; if (has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->_cm->id))) { if ($portfoliooptions = portfolio_instance_select(portfolio_instances(), call_user_func(array('data_portfolio_caller', 'supported_formats')), 'data_portfolio_caller', '', true, true)) { $mform->addElement('header', 'notice', get_string('portfolionotfile', 'data') . ':'); $portfoliooptions[0] = get_string('none'); ksort($portfoliooptions); $mform->addElement('select', 'portfolio', get_string('portfolio', 'portfolio'), $portfoliooptions); } } $this->add_action_buttons(true, get_string('exportdatabaserecords', 'data')); }
/** * Creates the group's elements. */ function _createElements() { global $CFG, $OUTPUT; $this->_elements = array(); // Official tags. $showingofficial = $this->_options['display'] != MoodleQuickForm_tags::NOOFFICIAL; if ($showingofficial) { $this->_load_official_tags(); // If the user can manage official tags, give them a link to manage them. $label = $this->elementDescription !== null ? $this->elementDescription : get_string('otags', 'tag'); if (has_capability('moodle/tag:manage', context_system::instance())) { $url = $CFG->wwwroot . '/tag/manage.php'; $label .= ' ' . $OUTPUT->action_link($url, "( " . ($this->editElementLabel !== null ? $this->editElementLabel : get_string('manageofficialtags', 'tag')) . " )", new popup_action('click', $url, 'managetags'), array('title' => get_string('newwindow'), "style" => "float: right;")) . ''; } // Get the list of official tags. $noofficial = false; if (empty($this->_officialtags)) { $officialtags = array('' => get_string('none')); $noofficial = true; } else { $officialtags = array_combine($this->_officialtags, $this->_officialtags); } // Create the element. $size = min(5, count($officialtags)); // E_STRICT creating elements without forms is nasty because it internally uses $this $officialtagsselect = @MoodleQuickForm::createElement('select', $this->selectElementLabel, $label, $officialtags, array('size' => $size, "width" => "100%")); $officialtagsselect->setMultiple(true); if ($noofficial) { $officialtagsselect->updateAttributes(array('disabled' => 'disabled')); } $this->_elements[] = $officialtagsselect; } // Other tags. // if ($this->_options['display'] != MoodleQuickForm_tags::ONLYOFFICIAL) { // if ($showingofficial) { // $label = get_string('othertags', 'tag'); // } else { // $label = get_string('entertags', 'tag'); // } // // E_STRICT creating elements without forms is nasty because it internally uses $this // $othertags = @MoodleQuickForm::createElement('textarea', 'othertags', $label, array('cols' => '40', 'rows' => '5')); // $this->_elements[] = $othertags; // } // Paradoxically, the only way to get labels output is to ask for 'hidden' // labels, and then override the .accesshide class in the CSS! foreach ($this->_elements as $element) { if (method_exists($element, 'setHiddenLabel')) { $element->setHiddenLabel(true); } } }
/** * this function returns the mform elements taht will be added to a report form * */ public function entry_form(&$mform) { $fieldname = "{$this->reportfield_id}_field"; $optionlist = $this->get_option_list($this->reportfield_id); $radioarray = array(); foreach ($optionlist as $key => $value) { $radioarray[] =& MoodleQuickForm::createElement('radio', $fieldname, '', $value, $key); } $mform->addGroup($radioarray, $fieldname, $this->label, '', '', array('class' => 'form_input'), false); if (!empty($this->req)) { $mform->addRule($fieldname, null, 'required', null, 'client'); } $mform->setType($fieldname, PARAM_RAW); }
/** * Adds controls specific to this filter in the form. * * @param moodleform $mform a MoodleQuickForm object in which element will be added */ public function setupForm(MoodleQuickForm &$mform) { $objs = array(); $objs[] = $mform->createElement('checkbox', $this->_name, null, ''); $grp = $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false); if ($this->_advanced) { $mform->setAdvanced($this->_name . '_grp'); } //Check if disable if options are set. if yes then set rules if (!empty($this->disableelements) && is_array($this->disableelements)) { foreach ($this->disableelements as $disableelement) { $mform->disabledIf($disableelement, $this->_name, 'checked'); } } }
/** * Get the settings for onlinetext submission plugin * * @param MoodleQuickForm $mform The form to add elements to * @return void */ public function get_settings(MoodleQuickForm $mform) { global $CFG, $COURSE; $defaultwordlimit = $this->get_config('wordlimit') == 0 ? '' : $this->get_config('wordlimit'); $defaultwordlimitenabled = $this->get_config('wordlimitenabled'); $options = array('size' => '6', 'maxlength' => '6'); $name = get_string('wordlimit', 'assignsubmission_onlinetext'); // Create a text box that can be enabled/disabled for onlinetext word limit. $wordlimitgrp = array(); $wordlimitgrp[] = $mform->createElement('text', 'assignsubmission_onlinetext_wordlimit', '', $options); $wordlimitgrp[] = $mform->createElement('checkbox', 'assignsubmission_onlinetext_wordlimit_enabled', '', get_string('enable')); $mform->addGroup($wordlimitgrp, 'assignsubmission_onlinetext_wordlimit_group', $name, ' ', false); $mform->addHelpButton('assignsubmission_onlinetext_wordlimit_group', 'wordlimit', 'assignsubmission_onlinetext'); $mform->disabledIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_wordlimit_enabled', 'notchecked'); // Add numeric rule to text field. $wordlimitgrprules = array(); $wordlimitgrprules['assignsubmission_onlinetext_wordlimit'][] = array(null, 'numeric', null, 'client'); $mform->addGroupRule('assignsubmission_onlinetext_wordlimit_group', $wordlimitgrprules); // Rest of group setup. $mform->setDefault('assignsubmission_onlinetext_wordlimit', $defaultwordlimit); $mform->setDefault('assignsubmission_onlinetext_wordlimit_enabled', $defaultwordlimitenabled); $mform->setType('assignsubmission_onlinetext_wordlimit', PARAM_INT); $mform->disabledIf('assignsubmission_onlinetext_wordlimit_group', 'assignsubmission_onlinetext_enabled', 'notchecked'); }
function definition() { global $CFG, $USER, $COURSE; $mform =& $this->_form; /// Print the required moodle fields first $mform->addElement('header', 'matches', get_string('messagematches', 'block_email_list')); // And or Or. $radiobuttons = array(); $radiobuttons[] =& MoodleQuickForm::createElement('radio', 'connector', get_string('matchanyquery', 'block_email_list'), get_string('matchanyquery', 'block_email_list'), 'OR'); $radiobuttons[] =& MoodleQuickForm::createElement('radio', 'connector', get_string('matchaallquery', 'block_email_list'), get_string('matchallquery', 'block_email_list'), 'AND'); $mform->addGroup($radiobuttons, 'messagematches', '', ' ', false); $mform->setDefault('connector', 'AND'); // Words $mform->addElement('header', 'words', get_string('search', 'search')); $mform->addElement('text', 'to', get_string('to', 'block_email_list'), 'maxlength="254" size="60"'); $mform->setType('to', PARAM_TEXT); $mform->addElement('text', 'from', get_string('from', 'block_email_list'), 'maxlength="254" size="60"'); $mform->setType('from', PARAM_TEXT); $mform->addElement('text', 'subject', get_string('subject', 'block_email_list'), 'maxlength="254" size="60"'); $mform->setType('subject', PARAM_TEXT); $mform->addElement('text', 'body', get_string('body', 'block_email_list'), 'maxlength="254" size="60"'); $mform->setType('body', PARAM_TEXT); // Folders $mform->addElement('header', 'folder', get_string('messagefolders', 'block_email_list')); // Get my root folders $folders = email_get_root_folders($USER->id, false); if (!empty($folders)) { $choose = array(); // Get courses foreach ($folders as $folder) { $choose[] =& MoodleQuickForm::createElement('checkbox', $folder->id, $folder->name, $folder->name); // Now, get all subfolders it $subfolders = email_get_subfolders($folder->id); // If subfolders if ($subfolders) { foreach ($subfolders as $subfolder) { $choose[] =& MoodleQuickForm::createElement('checkbox', $subfolder->id, $subfolder->name, $subfolder->name); } } } $mform->addGroup($choose, 'folders', get_string('folders', 'block_email_list'), ' <br /> '); $mform->setDefault('folders[' . $folders[0]->id . ']', true); $mform->addRule('folders', get_string('nosearchfolders', 'block_email_list'), 'required', null, 'server'); } $mform->addElement('hidden', 'courseid', $COURSE->id); // buttons $this->add_action_buttons(true, get_string('search', 'search')); }
function search_definition(&$mform) { //search text box $mform->addElement('text', 'search', get_string('searchfor', 'taoresource'), array('size' => '35')); //checkboxes to choose search scope $searchin = array(); $searchin[] =& MoodleQuickForm::createElement('checkbox', 'title', '', get_string('title', 'taoresource')); $searchin[] =& MoodleQuickForm::createElement('checkbox', 'keywords', '', get_string('keywords', 'taoresource')); $searchin[] =& MoodleQuickForm::createElement('checkbox', 'description', '', get_string('description', 'taoresource')); $mform->addGroup($searchin, 'searchin', get_string('searchin', 'taoresource'), array(' '), false); //set defaults $mform->setDefault('title', 1); $mform->setDefault('keywords', 1); $mform->setDefault('description', 1); return false; }
public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'stage', PORTFOLIO_STAGE_CONFIG); $mform->addElement('hidden', 'id', $this->_customdata['id']); $mform->addElement('hidden', 'instance', $this->_customdata['instance']->get('id')); $mform->setType('instance', PARAM_INT); $mform->setType('stage', PARAM_INT); $mform->setType('id', PARAM_INT); if (array_key_exists('formats', $this->_customdata) && is_array($this->_customdata['formats'])) { if (count($this->_customdata['formats']) > 1) { $options = array(); foreach ($this->_customdata['formats'] as $key) { $options[$key] = get_string('format_' . $key, 'portfolio'); } $mform->addElement('select', 'format', get_string('availableformats', 'portfolio'), $options); } else { $f = array_shift($this->_customdata['formats']); $mform->addElement('hidden', 'format', $f); $mform->setType('format', PARAM_RAW); } } // only display the option to wait or not if it's applicable if (array_key_exists('expectedtime', $this->_customdata) && $this->_customdata['expectedtime'] != PORTFOLIO_TIME_LOW && $this->_customdata['expectedtime'] != PORTFOLIO_TIME_FORCEQUEUE) { $radioarray = array(); $radioarray[] =& MoodleQuickForm::createElement('radio', 'wait', '', get_string('wait', 'portfolio'), 1); $radioarray[] =& MoodleQuickForm::createElement('radio', 'wait', '', get_string('dontwait', 'portfolio'), 0); $mform->addGroup($radioarray, 'radioar', get_string('wanttowait_' . $this->_customdata['expectedtime'], 'portfolio'), array(' '), false); $mform->setDefault('wait', 0); } else { if ($this->_customdata['expectedtime'] == PORTFOLIO_TIME_LOW) { $mform->addElement('hidden', 'wait', 1); } else { $mform->addElement('hidden', 'wait', 0); } $mform->setType('wait', PARAM_INT); } if (array_key_exists('plugin', $this->_customdata) && is_object($this->_customdata['plugin'])) { $this->_customdata['plugin']->export_config_form($mform, $this->_customdata['userid']); } if (array_key_exists('caller', $this->_customdata) && is_object($this->_customdata['caller'])) { $this->_customdata['caller']->export_config_form($mform, $this->_customdata['instance'], $this->_customdata['userid']); } $this->add_action_buttons(true, get_string('next')); }
/** * @param moodleform $combinedform * @param MoodleQuickForm $mform * @param $repeatenabled */ public function add_form_fragment(moodleform $combinedform, MoodleQuickForm $mform, $repeatenabled) { $mform->addElement('advcheckbox', $this->form_field_name('shuffleanswers'), get_string('shuffle', 'qtype_gapselect')); $answerel = array($mform->createElement('text', $this->form_field_name('answer'), get_string('choicex', 'qtype_gapselect'), array('size' => 57, 'class' => 'tweakcss'))); if ($this->questionrec !== null) { $countanswers = count($this->questionrec->options->answers); } else { $countanswers = 0; } if ($repeatenabled) { $defaultstartnumbers = QUESTION_NUMANS_START * 2; $repeatsatstart = max($defaultstartnumbers, $countanswers + QUESTION_NUMANS_ADD); } else { $repeatsatstart = $countanswers; } $combinedform->repeat_elements($answerel, $repeatsatstart, array(), $this->form_field_name('noofchoices'), $this->form_field_name('morechoices'), QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_gapselect'), true); $mform->setType($this->form_field_name('answer'), PARAM_RAW_TRIMMED); }
function definition() { $mform =& $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; $contexts = $this->_customdata['contexts']; $defaultfilename = $this->_customdata['defaultfilename']; //-------------------------------------------------------------------------------- $mform->addElement('header', 'fileformat', get_string('fileformat', 'quiz')); $fileformatnames = get_import_export_formats('export'); $radioarray = array(); foreach ($fileformatnames as $shortname => $fileformatname) { $radioelement =& MoodleQuickForm::createElement('radio', 'format', '', $fileformatname, $shortname); $radioelement->setHelpButton(array("{$shortname}", $fileformatname, "qformat_{$shortname}")); $radioarray[] = $radioelement; } $mform->addGroup($radioarray, 'format', '', array('<br />'), false); $mform->addRule('format', null, 'required', null, 'client'); //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), compact('contexts')); $mform->setDefault('category', $defaultcategory); $mform->setHelpButton('category', array('exportcategory', get_string('exportcategory', 'question'), 'quiz')); $categorygroup = array(); $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question')); $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question')); $mform->addGroup($categorygroup, 'categorygroup', '', '', false); $mform->disabledIf('categorygroup', 'cattofile', 'notchecked'); $mform->setDefault('cattofile', 1); $mform->setDefault('contexttofile', 1); // $fileformatnames = get_import_export_formats('export'); // $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames); // $mform->setDefault('format', 'gift'); // $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz')); $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size' => 40)); $mform->setDefault('exportfilename', $defaultfilename); $mform->setType('exportfilename', PARAM_FILE); // set a template for the format select elements $renderer =& $mform->defaultRenderer(); $template = "{help} {element}\n"; $renderer->setGroupElementTemplate($template, 'format'); //-------------------------------------------------------------------------------- $this->add_action_buttons(false, get_string('exportquestions', 'quiz')); //-------------------------------------------------------------------------------- }
function definition() { global $CFG; $mform =& $this->_form; $mform->addElement('header', 'notice', get_string('chooseexportformat', 'data')); $choices = csv_import_reader::get_delimiter_list(); $key = array_search(';', $choices); if (!$key === FALSE) { // array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon): unset($choices[$key]); } $typesarray = array(); $typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv'); $typesarray[] =& MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices); //temporarily commenting out Excel export option. See MDL-19864 //$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls'); $typesarray[] =& MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods'); $mform->addGroup($typesarray, 'exportar', '', array(''), false); $mform->addRule('exportar', null, 'required'); $mform->setDefault('exporttype', 'csv'); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else { if (get_string('listsep', 'langconfig') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } } $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data')); foreach ($this->_datafields as $field) { if ($field->text_export_supported()) { $mform->addElement('advcheckbox', 'field_' . $field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group' => 1)); $mform->setDefault('field_' . $field->field->id, 1); } else { $a = new stdClass(); $a->fieldtype = $field->name(); $mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a)); } } $this->add_checkbox_controller(1, null, null, 1); $this->add_action_buttons(true, get_string('exportentries', 'data')); }
function definition() { global $CFG; $mform =& $this->_form; $cm = $this->_customdata; $mform->addElement('header', 'general', get_string('import')); $group = array(); $group[0] =& MoodleQuickForm::createElement('text', 'reference', get_string('fileordir', 'book'), array('size' => '48')); $group[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') . ' ...'); $options = 'menubar=0,location=0,scrollbars,resizable,width=600,height=400'; $url = '/mod/book/coursefiles.php?choose=id_reference&id=' . $cm->course; $buttonattributes = array('title' => get_string('chooseafile', 'resource'), 'onclick' => "return openpopup('{$url}', '" . $group[1]->getName() . "', '{$options}', 0);"); $group[1]->updateAttributes($buttonattributes); $mform->addGroup($group, 'choosesomething', get_string('fileordir', 'book'), array(''), false); $mform->addElement('checkbox', 'subchapter', get_string('subchapter', 'book')); $mform->addElement('static', 'importfileinfo', get_string('help'), get_string('importinfo', 'book')); $mform->addElement('hidden', 'id', $cm->id); $mform->setType('id', PARAM_INT); $this->add_action_buttons(true, get_string('import', 'book')); }
function definition() { global $COURSE; $mform =& $this->_form; if (isset($this->_customdata)) { // hardcoding plugin names here is hacky $features = $this->_customdata; } else { $features = array(); } // course id needs to be passed for auth purposes $mform->addElement('hidden', 'id', optional_param('id')); $mform->setType('id', PARAM_INT); $mform->addElement('header', 'general', get_string('importfile', 'grades')); // file upload $mform->addElement('file', 'userfile', get_string('file')); $mform->setType('userfile', PARAM_FILE); $mform->addRule('userfile', null, 'required'); $textlib = textlib_get_instance(); $encodings = $textlib->get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); if (!empty($features['includeseparator'])) { $radio = array(); $radio[] =& MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab'); $radio[] =& MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma'); $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false); $mform->setDefault('separator', 'comma'); } if (!empty($features['verbosescales'])) { $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options); } $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options); // TODO: localize $mform->setType('previewrows', PARAM_INT); $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE)); $mform->setType('groupid', PARAM_INT); $this->add_action_buttons(false, get_string('uploadgrades', 'grades')); }
function definition() { global $CFG, $DB; $mform =& $this->_form; $course = $this->_customdata['course']; $cm = $this->_customdata['cm']; // $coursecontext = $this->_customdata['coursecontext']; $modcontext = $this->_customdata['modcontext']; $sessionid = $this->_customdata['sessionid']; if (!($att = $DB->get_record('attendance_sessions', array('id' => $sessionid)))) { error('No such session in this course'); } $mform->addElement('header', 'general', get_string('changesession', 'attforblock')); $mform->addHelpButton('general', 'changesession', 'attforblock'); $mform->addElement('static', 'olddate', get_string('olddate', 'attforblock'), userdate($att->sessdate, get_string('str_ftimedmyhm', 'attforblock'))); $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attforblock')); for ($i = 0; $i <= 23; $i++) { $hours[$i] = sprintf("%02d", $i); } for ($i = 0; $i < 60; $i += 5) { $minutes[$i] = sprintf("%02d", $i); } $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours); $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true); $mform->addGroup($durselect, 'durtime', get_string('duration', 'attforblock'), array(' '), true); $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"'); $mform->setType('sdescription', PARAM_TEXT); $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client'); $dhours = floor($att->duration / HOURSECS); $dmins = floor(($att->duration - $dhours * HOURSECS) / MINSECS); $mform->setDefaults(array('sessiondate' => $att->sessdate, 'durtime' => array('hours' => $dhours, 'minutes' => $dmins), 'sdescription' => $att->description)); //------------------------------------------------------------------------------- // buttons $submit_string = get_string('update', 'attforblock'); $this->add_action_buttons(true, $submit_string); $mform->addElement('hidden', 'id', $cm->id); $mform->addElement('hidden', 'sessionid', $sessionid); $mform->addElement('hidden', 'action', 'update'); }