dirroot.'/course/moodleform_mod.php'); //require_once($CFG->dirroot.'/mod/gradeimporter/lib.php'); class mod_gradeimporter_mod_form extends moodleform_mod { function definition() { global $CFG, $DB, $OUTPUT; $mform =& $this->_form; $course_modules_id = optional_param('update', 0, PARAM_INT); $mform->addElement('text', 'name', get_string('instanceName', 'formStrings'), array('size'=>'64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('error_instanceNameField', 'formStrings'), 'required', null, 'client'); $this->standard_intro_elements(get_string('description', 'formStrings')); $ynoptions = array(0 => get_string('visibilityOn', 'formStrings'), 1 => get_string('visibilityOff', 'formStrings')); $this->standard_coursemodule_elements(); $this->add_action_buttons(); } function data_preprocessing (&$default_values) { parent::data_preprocessing($default_values); $mform = & $this->_form; if (!$mform->isSubmitted() && array_key_exists('name', $default_values)) { //TODO Remove when updating all the iassign that are tag <ia_uc> $ia_uc = explode('<ia_uc>', $default_values['name']); $default_values['name'] = $ia_uc[0]; } } function definition_after_data() { global $DB; $mform = & $this->_form; $data = $mform->exportValues(); if ($mform->isSubmitted() && array_key_exists('iassign_statement', $data)) { $iassign_statements = $data['iassign_statement']; foreach ($iassign_statements as $key => $value) { if ($value == 1) { $updateentry = new stdClass(); $updateentry->id = $key; $updateentry->timemodified = time(); if (isset($data['grade_enabled']) && $data['grade_enabled'] == 1) $updateentry->grade = $data['grade']; if (isset($data['timedue_enabled']) && $data['timedue_enabled'] == 1) $updateentry->timedue = $data['timedue']; if (isset($data['timeavailable_enabled']) && $data['timeavailable_enabled'] == 1) $updateentry->timeavailable = $data['timeavailable']; if (isset($data['preventlate_enabled']) && $data['preventlate_enabled'] == 1) $updateentry->preventlate = $data['preventlate']; if (isset($data['test_enabled']) && $data['test_enabled'] == 1) $updateentry->test = $data['test']; if (isset($data['max_experiment_enabled']) && $data['max_experiment_enabled'] == 1) $updateentry->max_experiment = $data['max_experiment']; if (!$DB->update_record("iassign_statement", $updateentry)) print_error('error_update', 'iassign'); } } } } }