. defined('MOODLE_INTERNAL') || die(); require_once("$CFG->dirroot/course/moodleform_mod.php"); require_once("$CFG->libdir/formslib.php"); require_once("submission_functions.php"); class mod_gradeimporter_submission_form extends moodleform { public function definition() { global $CFG, $DB; $mform = $this->_form; // Custom data $submission = $this->_customdata['submission']; // Load fields data $filemanageroptions = $this->_customdata['filemanageroptions']; $gradeimporterid = $this->_customdata['gradeimporterid']; $cmid = $this->_customdata['cmid']; // ---------------------------------------------------------------- // General information // Header $mform->addElement('header', 'newsub', get_string('newsubmission', 'gradeimporter')); // Submission name field $mform->addElement('text', 'name', get_string('submissionname', 'gradeimporter'), array('maxlength' => '256')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); // Description $mform->addElement('editor', 'intro', get_string('submissionintro', 'gradeimporter')); $mform->setType('intro', PARAM_RAW); $mform->addElement('filemanager', 'submissionfiles_filemanager', get_string('submissionfiles', 'gradeimporter'), null, $filemanageroptions); $mform->addHelpButton('submissionfiles_filemanager', 'submissionfiles', 'gradeimporter'); // Add button to open new subtypeform $subtypeformurl = new moodle_url("/mod/gradeimporter/forms/submissiontype/submissiontype.php", array('cmid' => $cmid, 'id' => $gradeimporterid) ); $newsubtypebutton = "
"; $mform->addElement('html', $newsubtypebutton); // To edit $subtypes = get_types_array($gradeimporterid); if ($subtypes) { $selectvalues = array(); foreach ($subtypes as $id => $type) { $selectvalues[$id] = $type->name; } } else { $selectvalues = array(-1 => 'create new type first'); } $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $selectvalues); $mform->addElement('selectyesno', 'visibility', get_string('visibility', 'gradeimporter')); $mform->setDefault('visibility', array('value' => 1)); $mform->addHelpButton('visibility', 'visibility', 'gradeimporter'); $mform->addElement('selectyesno', 'gradebook', get_string('gradebook', 'gradeimporter')); $mform->setDefault('gradebook', array('value' => 0)); $mform->addHelpButton('gradebook', 'gradebook', 'gradeimporter'); $mform->addElement('text', 'maxgrade', get_string('maxgrade', 'gradeimporter'), array('type' => 'number', 'value' => 100)); $mform->setType('maxgrade', PARAM_INT); $mform->hideIf('maxgrade', 'gradebook', 'eq', 0); // ----------------------------- // Hidden fields $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'cmid'); $mform->setType('cmid', PARAM_INT); // ------------------------------ // Save and cancel buttons $this->add_action_buttons(); // ------------------------------ // Sets preloaded data to fields $this->set_data($submission); } }