/** * definition_inner adds all specific fields to the form. * * @param MoodleQuickForm $mform (the form being built). */ protected function definition_inner($mform) { $mform->addElement('header', 'previewareaheader', get_string('previewareaheader', 'qtype_' . $this->qtype())); $mform->setExpanded('previewareaheader'); $mform->addElement('static', 'previewarea', '', get_string('previewareamessage', 'qtype_' . $this->qtype())); $mform->registerNoSubmitButton('refresh'); $mform->addElement('submit', 'refresh', get_string('refresh', 'qtype_' . $this->qtype())); $mform->addElement('filepicker', 'bgimage', get_string('bgimage', 'qtype_' . $this->qtype()), null, self::file_picker_options()); $mform->closeHeaderBefore('dropzoneheader'); // Add the draggable image fields & drop zones to the form. list($itemrepeatsatstart, $imagerepeats) = $this->get_drag_item_repeats(); $this->definition_draggable_items($mform, $itemrepeatsatstart); $this->definition_drop_zones($mform, $imagerepeats); $this->add_combined_feedback_fields(true); $this->add_interactive_settings(true, true); }
/** * Add elements in grading plugin form. * * @param mixed $grade stdClass|null * @param MoodleQuickForm $mform * @param stdClass $data * @param int $userid - The userid we are grading * @return void */ protected function add_plugin_grade_elements($grade, MoodleQuickForm $mform, stdClass $data, $userid) { foreach ($this->feedbackplugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $mform->addElement('header', 'header_' . $plugin->get_type(), $plugin->get_name()); $mform->setExpanded('header_' . $plugin->get_type()); if (!$plugin->get_form_elements_for_user($grade, $mform, $data, $userid)) { $mform->removeElement('header_' . $plugin->get_type()); } } } }
/** * Add the form elements defining one PRT. * @param string $prtname the name of the PRT. * @param MoodleQuickForm $mform the form being assembled. * @param int $count the number of times this PRT appears in the text of the question. */ protected function definition_prt($prtname, MoodleQuickForm $mform, $count) { $mform->addElement('header', $prtname . 'header', stack_string('prtheading', $prtname)); if ($count == 0) { $mform->addElement('static', $prtname . 'prtwarning', '', stack_string('prtwillberemoved', $prtname)); $mform->addElement('advcheckbox', $prtname . 'prtdeleteconfirm', '', stack_string('prtremovedconfirm')); $mform->setDefault($prtname . 'prtdeleteconfirm', 0); $mform->setExpanded($prtname . 'header'); } $mform->addElement('text', $prtname . 'value', stack_string('questionvalue'), array('size' => 3)); $mform->setType($prtname . 'value', PARAM_FLOAT); $mform->setDefault($prtname . 'value', 1); $mform->addElement('selectyesno', $prtname . 'autosimplify', stack_string('autosimplify')); $mform->setDefault($prtname . 'autosimplify', true); $mform->addHelpButton($prtname . 'autosimplify', 'autosimplifyprt', 'qtype_stack'); $mform->addElement('textarea', $prtname . 'feedbackvariables', stack_string('feedbackvariables'), array('rows' => 3, 'cols' => 80)); $mform->addHelpButton($prtname . 'feedbackvariables', 'feedbackvariables', 'qtype_stack'); $inputnames = implode(', ', $this->get_inputs_used_by_prt($prtname)); $mform->addElement('static', $prtname . 'inputsnote', '', stack_string('prtwillbecomeactivewhen', html_writer::tag('b', $inputnames))); // Create the section of the form for each node - general bits. $graph = $this->get_prt_graph($prtname); $mform->addElement('static', $prtname . 'graph', '', stack_abstract_graph_svg_renderer::render($graph, $prtname . 'graphsvg')); $nextnodechoices = array('-1' => stack_string('stop')); foreach ($graph->get_nodes() as $node) { $nextnodechoices[$node->name - 1] = stack_string('nodex', $node->name); } $deletable = count($graph->get_nodes()) > 1; foreach ($graph->get_nodes() as $node) { $this->definition_prt_node($prtname, $node->name, $nextnodechoices, $deletable, $mform); } $mform->addElement('submit', $prtname . 'nodeadd', stack_string('addanothernode')); $mform->registerNoSubmitButton($prtname . 'nodeadd'); }