MDL-21695 - Replace built-in HTML help files with proper strings
[moodle.git] / mod / feedback / mod_form.php
CommitLineData
1adbd2c3 1<?php
c70ad9f7 2/**
3* print the form to add or edit a feedback-instance
4*
c70ad9f7 5* @author Andreas Grabs
6* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7* @package feedback
8*/
9
10require_once ($CFG->dirroot.'/course/moodleform_mod.php');
11
12class mod_feedback_mod_form extends moodleform_mod {
13
14 function definition() {
c18269c7 15 global $CFG, $DB;
c70ad9f7 16
17 $mform =& $this->_form;
18
19 //-------------------------------------------------------------------------------
20 $mform->addElement('header', 'general', get_string('general', 'form'));
3268cf99 21
c70ad9f7 22 $mform->addElement('text', 'name', get_string('name', 'feedback'), array('size'=>'64'));
23 $mform->setType('name', PARAM_TEXT);
24 $mform->addRule('name', null, 'required', null, 'client');
25
50aa3fcc 26 $this->add_intro_editor(true, get_string('description', 'feedback'));
c70ad9f7 27
28 //-------------------------------------------------------------------------------
29 $mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
3268cf99 30
c70ad9f7 31 $enableopengroup = array();
32 $enableopengroup[] =& $mform->createElement('checkbox', 'openenable', get_string('feedbackopen', 'feedback'));
33 $enableopengroup[] =& $mform->createElement('date_time_selector', 'timeopen', '');
34 $mform->addGroup($enableopengroup, 'enableopengroup', get_string('feedbackopen', 'feedback'), ' ', false);
e8790d59 35 $mform->addHelpButton('enableopengroup', 'timeopen', 'feedback');
c70ad9f7 36 $mform->disabledIf('enableopengroup', 'openenable', 'notchecked');
3268cf99 37
c70ad9f7 38 $enableclosegroup = array();
39 $enableclosegroup[] =& $mform->createElement('checkbox', 'closeenable', get_string('feedbackclose', 'feedback'));
40 $enableclosegroup[] =& $mform->createElement('date_time_selector', 'timeclose', '');
41 $mform->addGroup($enableclosegroup, 'enableclosegroup', get_string('feedbackclose', 'feedback'), ' ', false);
e8790d59 42 $mform->addHelpButton('enableclosegroup', 'timeclose', 'feedback');
c70ad9f7 43 $mform->disabledIf('enableclosegroup', 'closeenable', 'notchecked');
3268cf99 44
c70ad9f7 45 //-------------------------------------------------------------------------------
46 $mform->addElement('header', 'feedbackhdr', get_string('feedback_options', 'feedback'));
3268cf99 47
c70ad9f7 48 $options=array();
49 $options[1] = get_string('anonymous', 'feedback');
50 $options[2] = get_string('non_anonymous', 'feedback');
51 $mform->addElement('select', 'anonymous', get_string('anonymous_edit', 'feedback'), $options);
3268cf99 52
7ac32c70 53 $mform->addElement('selectyesno', 'publish_stats', get_string('show_analysepage_after_submit', 'feedback'));
c70ad9f7 54 $mform->addElement('selectyesno', 'email_notification', get_string('email_notification', 'feedback'));
e8790d59 55 $mform->addHelpButton('email_notification', 'emailnotification', 'feedback');
3268cf99 56
c70ad9f7 57 // check if there is existing responses to this feedback
c18269c7 58 if (is_numeric($this->_instance) AND $this->_instance and $feedback = $DB->get_record("feedback", array("id"=>$this->_instance))) {
c70ad9f7 59 $completedFeedbackCount = feedback_get_completeds_group_count($feedback);
60 } else {
61 $completedFeedbackCount = false;
62 }
3268cf99 63
c70ad9f7 64 if($completedFeedbackCount) {
65 $multiple_submit_value = $feedback->multiple_submit ? get_string('yes') : get_string('no');
66 $mform->addElement('text', 'multiple_submit_static', get_string('multiple_submit', 'feedback'), array('size'=>'4','disabled'=>'disabled', 'value'=>$multiple_submit_value));
67 $mform->addElement('hidden', 'multiple_submit', '');
d18e0fe6 68 $mform->setType('', PARAM_INT);
e8790d59 69 $mform->addHelpButton('multiple_submit_static', 'multiplesubmit', 'feedback');
c70ad9f7 70 }else {
71 $mform->addElement('selectyesno', 'multiple_submit', get_string('multiple_submit', 'feedback'));
e8790d59 72 $mform->addHelpButton('multiple_submit', 'multiplesubmit', 'feedback');
c70ad9f7 73 }
efc59167 74 $mform->addElement('selectyesno', 'autonumbering', get_string('autonumbering', 'feedback'));
e8790d59 75 $mform->addHelpButton('autonumbering', 'autonumbering', 'feedback');
3268cf99 76
c70ad9f7 77 //-------------------------------------------------------------------------------
78 $mform->addElement('header', 'aftersubmithdr', get_string('after_submit', 'feedback'));
2f67a9b3 79
9f42276c 80 $mform->addElement('editor', 'page_after_submit', get_string("page_after_submit", "feedback"), null, null);
c70ad9f7 81 $mform->setType('page_after_submit', PARAM_RAW);
1adbd2c3 82
788b72a6 83 $mform->addElement('text', 'site_after_submit', get_string('url_for_continue_button', 'feedback'), array('size'=>'64','maxlength'=>'255'));
84 $mform->setType('site_after_submit', PARAM_TEXT);
e8790d59 85 $mform->addHelpButton('site_after_submit', 'url_for_continue', 'feedback');
c70ad9f7 86 //-------------------------------------------------------------------------------
42f103be 87 $this->standard_coursemodule_elements();
c70ad9f7 88 //-------------------------------------------------------------------------------
89 // buttons
90 $this->add_action_buttons();
91 }
92
93 function data_preprocessing(&$default_values){
94 if (empty($default_values['timeopen'])) {
95 $default_values['openenable'] = 0;
96 } else {
97 $default_values['openenable'] = 1;
98 }
99 if (empty($default_values['timeclose'])) {
100 $default_values['closeenable'] = 0;
101 } else {
102 $default_values['closeenable'] = 1;
103 }
9f42276c
SH
104 if (!isset($default_values['page_after_submitformat'])) {
105 $default_values['page_after_submitformat'] = FORMAT_HTML;
106 }
107 if (!isset($default_values['page_after_submit'])) {
108 $default_values['page_after_submit'] = '';
109 }
110 $default_values['page_after_submit'] = array('text'=>$default_values['page_after_submit'],'format'=>$default_values['page_after_submitformat']);
111 }
c70ad9f7 112
9f42276c
SH
113 function get_data() {
114 $data = parent::get_data();
115 if ($data) {
116 $data->page_after_submitformat = $data->page_after_submit['format'];
117 $data->page_after_submit = $data->page_after_submit['text'];
118 }
119 return $data;
c70ad9f7 120 }
121
32648682 122 function validation($data, $files){
123 $errors = parent::validation($data, $files);
124 return $errors;
c70ad9f7 125 }
126
127}