mod_form.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.'/course/moodleform_mod.php');
  6. require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');
  7. class mod_gradeimporter_mod_form extends moodleform_mod {
  8. function definition() {
  9. global $CFG, $COURSE, $USER, $DB, $OUTPUT;
  10. $mform =& $this->_form;
  11. $course_modules_id = optional_param('update', 0, PARAM_INT);
  12. $mform->addElement('header', 'general', get_string('general', 'gradeimporter'));
  13. $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size'=>'64'));
  14. $mform->setType('name', PARAM_TEXT);
  15. $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
  16. $this->standard_intro_elements(get_string('description', 'gradeimporter'));
  17. //$ynoptions = array(0 => get_string('visibilityOn', 'gradeimporter'), 1 => get_string('visibilityOff', 'gradeimporter'));
  18. //$mform->addElement('')
  19. $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false,'gradecat' => false, 'idnumber' => false);
  20. $this->standard_coursemodule_elements($features);
  21. //hidden fields
  22. $mform->addElement('hidden', 'action');
  23. $mform->setType('action', PARAM_TEXT);
  24. $mform->addElement('hidden', 'id');
  25. $mform->setType('id', PARAM_TEXT);
  26. $mform->addElement('hidden', 'iassign_id');
  27. $mform->setType('iassign_id', PARAM_TEXT);
  28. $mform->addElement('hidden', 'author_name');
  29. $mform->setType('author_name', PARAM_TEXT);
  30. $mform->addElement('hidden', 'author_modified_name');
  31. $mform->setType('author_modified_name', PARAM_TEXT);
  32. $mform->addElement('hidden', 'timecreated');
  33. $mform->setType('timecreated', PARAM_TEXT);
  34. $mform->addElement('hidden', 'position');
  35. $mform->setType('position', PARAM_TEXT);
  36. $this->add_action_buttons();
  37. }
  38. //$DB->insert_record($table, $dataobject, $returnid, $bulk); insert records on db
  39. /*function data_preprocessing (&$default_values) {
  40. parent::data_preprocessing($default_values);
  41. $mform = & $this->_form;
  42. if (!$mform->isSubmitted() && array_key_exists('name', $default_values)) {
  43. //TODO Remove when updating all the iassign that are tag &lt;ia_uc&gt;
  44. //$ia_uc = explode('&lt;ia_uc&gt;', $default_values['name']);
  45. //$default_values['name'] = $ia_uc[0];
  46. }
  47. }*/
  48. /* function definition_after_data() {
  49. global $DB;
  50. $mform = & $this->_form;
  51. $data = $mform->exportValues();
  52. if ($mform->isSubmitted()) {
  53. $iassign_statements = $data['iassign_statement'];
  54. foreach ($iassign_statements as $key => $value) {
  55. if ($value == 1) {
  56. $updateentry = new stdClass();
  57. $updateentry->id = $key;
  58. $updateentry->timemodified = time();
  59. if (isset($data['grade_enabled']) && $data['grade_enabled'] == 1)
  60. $updateentry->grade = $data['grade'];
  61. if (isset($data['timedue_enabled']) && $data['timedue_enabled'] == 1)
  62. $updateentry->timedue = $data['timedue'];
  63. if (isset($data['timeavailable_enabled']) && $data['timeavailable_enabled'] == 1)
  64. $updateentry->timeavailable = $data['timeavailable'];
  65. if (isset($data['preventlate_enabled']) && $data['preventlate_enabled'] == 1)
  66. $updateentry->preventlate = $data['preventlate'];
  67. if (isset($data['test_enabled']) && $data['test_enabled'] == 1)
  68. $updateentry->test = $data['test'];
  69. if (isset($data['max_experiment_enabled']) && $data['max_experiment_enabled'] == 1)
  70. $updateentry->max_experiment = $data['max_experiment'];
  71. if (!$DB->update_record("iassign_statement", $updateentry))
  72. print_error('error_update', 'iassign');
  73. }
  74. }
  75. }
  76. }*/
  77. }