submission_form.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // This file is part of
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. defined('MOODLE_INTERNAL') || die();
  17. require_once($CFG->dirroot.'/course/moodleform_mod.php');
  18. require_once("$CFG->libdir/formslib.php");
  19. class mod_gradeimporter_submission_form extends moodleform {
  20. public function definition() {
  21. global $CFG, $DB;
  22. $mform = $this->_form;
  23. // Custom data
  24. $submission = $this->_customdata['submission']; // Load fields data
  25. $filemanageroptions = $this->_customdata['filemanageroptions'];
  26. // ----------------------------------------------------------------
  27. // General information
  28. // Header
  29. $mform->addElement('header', 'newsub', get_string('newsubmission', 'gradeimporter'));
  30. // Submission name field
  31. $mform->addElement('text', 'name', get_string('submissionname', 'gradeimporter'));
  32. $mform->setType('name', PARAM_TEXT);
  33. $mform->addRule('name', null, 'required', null, 'client');
  34. $mform->addElement('editor', 'description', get_string('description'));
  35. $mform->setType('description', PARAM_TEXT);
  36. $mform->addElement('filemanager', 'submissionfiles_filemanager', get_string('submissionfiles', 'gradeimporter'),
  37. null, $filemanageroptions);
  38. $mform->addHelpButton('submissionfiles_filemanager', 'submissionfiles', 'gradeimporter');
  39. $selectvalues = array('red', 'green', 'blue');
  40. $select = $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $selectvalues);
  41. $mform->addElement('selectyesno', 'visibility', get_string('visibility', 'gradeimporter'));
  42. $mform->setDefault('visibility', array('value' => 1));
  43. $mform->addHelpButton('visibility', 'visibility', 'gradeimporter');
  44. $mform->addElement('selectyesno', 'gradebook', get_string('gradebook', 'gradeimporter'));
  45. $mform->setDefault('gradebook', array('value' => 0));
  46. $mform->addHelpButton('gradebook', 'gradebook', 'gradeimporter');
  47. // -----------------------------
  48. // Hidden fields
  49. $mform->addElement('hidden', 'id');
  50. $mform->setType('id', PARAM_INT);
  51. $mform->addElement('hidden', 'cmid');
  52. $mform->setType('cmid', PARAM_INT);
  53. // ------------------------------
  54. // Save and cancel buttons
  55. $this->add_action_buttons();
  56. // ------------------------------
  57. // Sets preloaded data to fields
  58. $this->set_data($submission);
  59. }
  60. }