submission_form.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. //description format
  28. //kill on the install.xml
  29. $mform->addElement('header', 'filehandling', get_string('filehandling', 'gradeimporter'));
  30. //submission type
  31. $submissiontype = array();
  32. $submissiontype[0] = get_string('exam', 'gradeimporter');
  33. $submissiontype[1] = get_string('activity', 'gradeimporter');
  34. $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $submissiontype, array('onChange' => 'config_type(this.value);'));
  35. //$mform->setDefault('submissiontype', 0); // default submissiontype = 3
  36. $mform->addHelpButton('submissiontype', 'subtype_help', 'gradeimporter');
  37. //receive the files
  38. $mform->addElement('filemanager', 'submission_filemanager', get_string('submissionFiles', 'gradeimporter'), null, $descriptionoptions);
  39. $mform->addHelpButton('submission_filemanager', 'submissionfiles', 'gradeimporter');
  40. //csv delimiter
  41. $csv_delimiter = array();
  42. $csv_delimiter[1] = ',';
  43. /*$csv_delimiter[2] = ';';
  44. $csv_delimiter[3] = ':';
  45. $csv_delimiter[4] = '\t';
  46. */
  47. $mform->addElement('select', 'csv_delimiter', get_string('csvdelimiter', 'gradeimporter'), $csv_delimiter, array('onChange' => 'config_type(this.value);'));
  48. $mform->setDefault('csv_delimiter', 1); // default csv_delimiter = 3
  49. $mform->addHelpButton('csv_delimiter', 'csvdelimiter_help', 'gradeimporter');
  50. //gradebook Y/N Combobox
  51. $ynarray = array();
  52. $ynarray[0] = get_string('no', 'gradeimporter');
  53. $ynarray[1] = get_string('yes', 'gradeimporter');
  54. $mform->addElement('select', 'gradebook', get_string('gradebookYN', 'gradeimporter'), $ynarray);
  55. //$mform->setDefault('gradebook', 0);
  56. $mform->addHelpButton('gradebook', 'gradebook_help', 'gradeimporter');
  57. //visibility Y/N Combobox
  58. $mform->addElement('select', 'visibility', get_string('visibilityYN', 'gradeimporter'), $ynarray);
  59. //$mform->setDefault('visibility', 0);
  60. $mform->addHelpButton('visibility', 'visibility_help', 'gradeimporter');
  61. //-----------------------------
  62. //hidden fields
  63. $mform->addElement('hidden', 'id');
  64. $mform->setType('id', PARAM_INT);
  65. $mform->addElement('hidden', 'cmid');
  66. $mform->setType('cmid', PARAM_INT);
  67. //------------------------------
  68. //--------------------------------------------------------------
  69. $this->add_action_buttons();
  70. //--------------------------------------------------------------
  71. $this->set_data($submission);
  72. }
  73. }