submission_form.php 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. if (!defined('MOODLE_INTERNAL')) {
  3. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  4. }
  5. require_once($CFG->dirroot.'/lib/formslib.php');
  6. //require_once($CFG->dirroot.'/course/moodleform_mod.php');
  7. //require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');
  8. class mod_gradeimporter_submission_form extends moodleform{
  9. function definition(){
  10. global $CFG, $DB;
  11. $mform =& $this->_form;
  12. $submission = $this->_customdata['submission'];
  13. $cm = $this->_customdata['cm'];
  14. $descriptionoptions = $this->_customdata['descriptionoptions'];
  15. $submissionoptions = $this->_customdata['submissionoptions'];
  16. $context = context_module::instance($cm->id);
  17. $fmtoptions = array('context'=>$context);
  18. //----------------------------------------------------------------------
  19. //form elements start here
  20. $mform->addElement('header', 'general', get_string('general', 'form'));
  21. //submission name
  22. $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size'=>'64'));
  23. $mform->setType('name', PARAM_TEXT);
  24. $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
  25. //description
  26. $mform->addElement('editor', 'description_editor', get_string('submissionDescription', 'gradeimporter'), null, $descriptionoptions);
  27. $mform->setType('description_editor', PARAM_RAW);
  28. $mform->addElement('header', 'filehandling', get_string('filehandling', 'gradeimporter'));
  29. //submission type
  30. $submissionType = array();
  31. $submissionType[0] = get_string('exam', 'gradeimporter');
  32. $submissionType[1] = get_string('activity', 'gradeimporter');
  33. $mform->addElement('select', 'type', get_string('submissionType', 'gradeimporter'), $submissionType, array('onChange' => 'config_type(this.value);'));
  34. //$mform->setDefault('submissionType', 0); // default submissionType = 3
  35. $mform->addHelpButton('type', 'submissionType', 'gradeimporter');
  36. //receive the files
  37. $mform->addElement('filemanager', 'submission_filemanager', get_string('submissionFiles', 'gradeimporter'), null, $descriptionoptions);
  38. $mform->addHelpButton('submission_filemanager', 'submissionFiles', 'gradeimporter');
  39. //csv delimiter
  40. $csv_delimiter = array();
  41. $csv_delimiter[1] = ',';
  42. /*$csv_delimiter[2] = ';';
  43. $csv_delimiter[3] = ':';
  44. $csv_delimiter[4] = '\t';
  45. */
  46. $mform->addElement('select', 'csv_delimiter', get_string('csvdelimiter', 'gradeimporter'), $csv_delimiter, array('onChange' => 'config_type(this.value);'));
  47. $mform->setDefault('csv_delimiter', 1); // default csv_delimiter = 3
  48. $mform->addHelpButton('csv_delimiter', 'csvdelimiter', 'gradeimporter');
  49. //gradebook Y/N Combobox
  50. $ynarray = array();
  51. $ynarray[0] = get_string('no', 'gradeimporter');
  52. $ynarray[1] = get_string('yes', 'gradeimporter');
  53. $mform->addElement('select', 'gradebook', get_string('gradebookYN', 'gradeimporter'), $ynarray);
  54. //$mform->setDefault('gradebook', 0);
  55. $mform->addHelpButton('gradebook', 'gradebookYN', 'gradeimporter');
  56. //visibility Y/N Combobox
  57. $mform->addElement('select', 'visibility', get_string('visibilityYN', 'gradeimporter'), $ynarray);
  58. //$mform->setDefault('visibility', 0);
  59. $mform->addHelpButton('visibility', 'visibilityYN', 'gradeimporter');
  60. //-----------------------------
  61. //hidden fields
  62. $mform->addElement('hidden', 'id');
  63. $mform->setType('id', PARAM_INT);
  64. $mform->addElement('hidden', 'cmid');
  65. $mform->setType('cmid', PARAM_INT);
  66. //------------------------------
  67. //--------------------------------------------------------------
  68. $this->add_action_buttons();
  69. //--------------------------------------------------------------
  70. $this->set_data($submission);
  71. }
  72. }