. /** * This file defines a base class for all assessment forms * * @package mod * @subpackage workshop * @copyright 2009 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); // parent class definition /** * Base class for all assessment forms * * This defines the common fields that all assessment forms need. * Strategies should define their own class that inherits from this one, and * implements the definition_inner() method. * * @uses moodleform */ class workshop_assessment_form extends moodleform { /** * Add the fields that are common for all grading strategies. * * If the strategy does not support all these fields, then you can override * this method and remove the ones you don't want with * $mform->removeElement(). * Strategy subclassess should define their own fields in definition_inner() * * @return void */ public function definition() { global $CFG; $mform = $this->_form; $this->mode = $this->_customdata['mode']; // influences the save buttons $this->strategy = $this->_customdata['strategy']; // instance of the strategy api class $this->workshop = $this->_customdata['workshop']; // instance of the workshop api class $this->options = $this->_customdata['options']; // array with addiotional options // add the strategy-specific fields $this->definition_inner($mform); // add the data common for all subplugins $mform->addElement('hidden', 'strategy', $this->workshop->strategy); $mform->setType('strategy', PARAM_PLUGIN); if (!empty($this->options['editableweight']) and !$mform->isFrozen()) { $mform->addElement('header', 'assessmentsettings', get_string('assessmentweight', 'workshop')); $mform->addElement('select', 'weight', get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list()); $mform->setDefault('weight', 1); } $buttonarray = array(); if ($this->mode == 'preview') { $buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop')); } if ($this->mode == 'assessment') { $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); $buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop')); $buttonarray[] = $mform->createElement('cancel'); } $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); } /** * Add any strategy specific form fields. * * @param stdClass $mform the form being built. */ protected function definition_inner(&$mform) { // By default, do nothing. } }