mod_form.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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, $DB;
  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('instanceName', 'gradeimporter'), array('size'=>'64'));
  14. $mform->setType('name', PARAM_TEXT);
  15. $mform->addRule('name', get_string('error_instanceNameField', '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. $this->add_action_buttons();
  22. }
  23. //$DB->insert_record($table, $dataobject, $returnid, $bulk); insert records on db
  24. /*function data_preprocessing (&$default_values) {
  25. parent::data_preprocessing($default_values);
  26. $mform = & $this->_form;
  27. if (!$mform->isSubmitted() && array_key_exists('name', $default_values)) {
  28. //TODO Remove when updating all the iassign that are tag &lt;ia_uc&gt;
  29. //$ia_uc = explode('&lt;ia_uc&gt;', $default_values['name']);
  30. //$default_values['name'] = $ia_uc[0];
  31. }
  32. }*/
  33. /* function definition_after_data() {
  34. global $DB;
  35. $mform = & $this->_form;
  36. $data = $mform->exportValues();
  37. if ($mform->isSubmitted()) {
  38. $iassign_statements = $data['iassign_statement'];
  39. foreach ($iassign_statements as $key => $value) {
  40. if ($value == 1) {
  41. $updateentry = new stdClass();
  42. $updateentry->id = $key;
  43. $updateentry->timemodified = time();
  44. if (isset($data['grade_enabled']) && $data['grade_enabled'] == 1)
  45. $updateentry->grade = $data['grade'];
  46. if (isset($data['timedue_enabled']) && $data['timedue_enabled'] == 1)
  47. $updateentry->timedue = $data['timedue'];
  48. if (isset($data['timeavailable_enabled']) && $data['timeavailable_enabled'] == 1)
  49. $updateentry->timeavailable = $data['timeavailable'];
  50. if (isset($data['preventlate_enabled']) && $data['preventlate_enabled'] == 1)
  51. $updateentry->preventlate = $data['preventlate'];
  52. if (isset($data['test_enabled']) && $data['test_enabled'] == 1)
  53. $updateentry->test = $data['test'];
  54. if (isset($data['max_experiment_enabled']) && $data['max_experiment_enabled'] == 1)
  55. $updateentry->max_experiment = $data['max_experiment'];
  56. if (!$DB->update_record("iassign_statement", $updateentry))
  57. print_error('error_update', 'iassign');
  58. }
  59. }
  60. }
  61. }*/
  62. }