|
24 | 24 | */ |
25 | 25 |
|
26 | 26 | require_once("../../config.php"); |
27 | | -require_once($CFG->dirroot.'/mod/questionnaire/questionnaire.class.php'); |
| 27 | +require_once($CFG->dirroot . '/mod/questionnaire/questionnaire.class.php'); |
28 | 28 |
|
29 | 29 | $id = required_param('id', PARAM_INT); // Course module ID. |
30 | 30 | $section = optional_param('section', 1, PARAM_INT); |
|
63 | 63 | if ($sectionid) { |
64 | 64 | // Get the specified section by its id. |
65 | 65 | $feedbacksection = new mod_questionnaire\feedback\section($questionnaire->questions, ['id' => $sectionid]); |
66 | | - |
67 | 66 | } else if (!$DB->count_records('questionnaire_fb_sections', ['surveyid' => $questionnaire->sid])) { |
68 | 67 | // There are no sections currently, so create one. |
69 | 68 | if ($questionnaire->survey->feedbacksections == 1) { |
|
72 | 71 | $sectionlabel = get_string('feedbackdefaultlabel', 'questionnaire'); |
73 | 72 | } |
74 | 73 | $feedbacksection = mod_questionnaire\feedback\section::new_section($questionnaire->sid, $sectionlabel); |
75 | | - |
76 | 74 | } else { |
77 | 75 | // Get the specified section by section number. |
78 | | - $feedbacksection = new mod_questionnaire\feedback\section($questionnaire->questions, |
79 | | - ['surveyid' => $questionnaire->survey->id, 'sectionnum' => $section]); |
| 76 | + $feedbacksection = new mod_questionnaire\feedback\section( |
| 77 | + $questionnaire->questions, |
| 78 | + ['surveyid' => $questionnaire->survey->id, 'sectionnum' => $section] |
| 79 | + ); |
80 | 80 | } |
81 | 81 |
|
82 | 82 | // Get all questions that are valid feedback questions. |
|
102 | 102 | $sectionid = required_param('sectionid', PARAM_INT); |
103 | 103 | $qid = required_param('qid', PARAM_INT); |
104 | 104 | $feedbacksection->remove_question($qid); |
105 | | - |
106 | 105 | } else if ($action == 'deletesection') { |
107 | 106 | $sectionid = required_param('sectionid', PARAM_INT); |
108 | 107 | if ($sectionid == $feedbacksection->id) { |
|
115 | 114 | $customdata->feedbacksection = $feedbacksection; |
116 | 115 | $customdata->validquestions = $validquestions; |
117 | 116 | $customdata->survey = $questionnaire->survey; |
118 | | -$customdata->sectionselect = $DB->get_records_menu('questionnaire_fb_sections', ['surveyid' => $questionnaire->survey->id], |
119 | | - 'section', 'id,sectionlabel'); |
| 117 | +$customdata->sectionselect = $DB->get_records_menu( |
| 118 | + 'questionnaire_fb_sections', |
| 119 | + ['surveyid' => $questionnaire->survey->id], |
| 120 | + 'section', |
| 121 | + 'id,sectionlabel' |
| 122 | +); |
120 | 123 |
|
121 | 124 | $feedbackform = new \mod_questionnaire\feedback_section_form('fbsections.php', $customdata); |
122 | 125 | $sdata = clone($feedbacksection); |
|
125 | 128 | $sdata->id = $cm->id; |
126 | 129 |
|
127 | 130 | $draftideditor = file_get_submitted_draft_itemid('sectionheading'); |
128 | | -$currentinfo = file_prepare_draft_area($draftideditor, $context->id, 'mod_questionnaire', 'sectionheading', |
129 | | - $feedbacksection->id, ['subdirs' => true], $feedbacksection->sectionheading); |
| 131 | +$currentinfo = file_prepare_draft_area( |
| 132 | + $draftideditor, |
| 133 | + $context->id, |
| 134 | + 'mod_questionnaire', |
| 135 | + 'sectionheading', |
| 136 | + $feedbacksection->id, |
| 137 | + ['subdirs' => true], |
| 138 | + $feedbacksection->sectionheading |
| 139 | +); |
130 | 140 | $sdata->sectionheading = ['text' => $currentinfo, 'format' => FORMAT_HTML, 'itemid' => $draftideditor]; |
131 | 141 |
|
132 | 142 | $feedbackform->set_data($sdata); |
|
141 | 151 |
|
142 | 152 | if (isset($settings->gotosection)) { |
143 | 153 | if ($settings->navigatesections != $feedbacksection->id) { |
144 | | - redirect(new moodle_url('/mod/questionnaire/fbsections.php', |
145 | | - ['id' => $cm->id, 'sectionid' => $settings->navigatesections])); |
| 154 | + redirect( |
| 155 | + new moodle_url( |
| 156 | + '/mod/questionnaire/fbsections.php', |
| 157 | + ['id' => $cm->id, 'sectionid' => $settings->navigatesections] |
| 158 | + ) |
| 159 | + ); |
146 | 160 | } |
147 | | - |
148 | 161 | } else if (isset($settings->addnewsection)) { |
149 | 162 | $newsection = mod_questionnaire\feedback\section::new_section($questionnaire->survey->id, $settings->newsectionlabel); |
150 | 163 | redirect(new moodle_url('/mod/questionnaire/fbsections.php', ['id' => $cm->id, 'sectionid' => $newsection->id])); |
151 | | - |
152 | 164 | } else if (isset($fullform->confirmdeletesection)) { |
153 | | - redirect(new moodle_url('/mod/questionnaire/fbsections.php', |
154 | | - ['id' => $cm->id, 'sectionid' => $feedbacksection->id, 'action' => 'confirmdeletesection'])); |
155 | | - |
| 165 | + redirect( |
| 166 | + new moodle_url( |
| 167 | + '/mod/questionnaire/fbsections.php', |
| 168 | + ['id' => $cm->id, 'sectionid' => $feedbacksection->id, 'action' => 'confirmdeletesection'] |
| 169 | + ) |
| 170 | + ); |
156 | 171 | } else if (isset($fullform->confirmremovequestion)) { |
157 | 172 | $qid = key($fullform->confirmremovequestion); |
158 | | - redirect(new moodle_url('/mod/questionnaire/fbsections.php', |
159 | | - ['id' => $cm->id, 'sectionid' => $settings->sectionid, 'action' => 'confirmremovequestion', 'qid' => $qid])); |
160 | | - |
| 173 | + redirect( |
| 174 | + new moodle_url( |
| 175 | + '/mod/questionnaire/fbsections.php', |
| 176 | + ['id' => $cm->id, 'sectionid' => $settings->sectionid, 'action' => 'confirmremovequestion', 'qid' => $qid] |
| 177 | + ) |
| 178 | + ); |
161 | 179 | } else if (isset($settings->addquestion)) { |
162 | 180 | $scorecalculation = []; |
163 | 181 | // Check for added question. |
|
176 | 194 | } |
177 | 195 | // Update the section with question weights. |
178 | 196 | $feedbacksection->set_new_scorecalculation($scorecalculation); |
179 | | - |
180 | 197 | } else if (isset($settings->submitbutton)) { |
181 | 198 | if (isset($fullform->weight)) { |
182 | 199 | $feedbacksection->scorecalculation = $fullform->weight; |
183 | 200 | } else { |
184 | 201 | $feedbacksection->scorecalculation = []; |
185 | 202 | } |
186 | 203 | $feedbacksection->sectionlabel = $settings->sectionlabel; |
187 | | - $feedbacksection->sectionheading = file_save_draft_area_files((int)$settings->sectionheading['itemid'], $context->id, |
188 | | - 'mod_questionnaire', 'sectionheading', $feedbacksection->id, ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], |
189 | | - $settings->sectionheading['text']); |
| 204 | + $feedbacksection->sectionheading = file_save_draft_area_files( |
| 205 | + (int)$settings->sectionheading['itemid'], |
| 206 | + $context->id, |
| 207 | + 'mod_questionnaire', |
| 208 | + 'sectionheading', |
| 209 | + $feedbacksection->id, |
| 210 | + ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], |
| 211 | + $settings->sectionheading['text'] |
| 212 | + ); |
190 | 213 | $feedbacksection->sectionheadingformat = $settings->sectionheading['format']; |
191 | 214 |
|
192 | 215 | // May have changed the section label and weights, so update the data. |
|
230 | 253 |
|
231 | 254 | $fbid = $feedbacksection->load_sectionfeedback($feedback); |
232 | 255 |
|
233 | | - $feedbacktext = file_save_draft_area_files((int)$settings->feedbacktext[$i]['itemid'], |
234 | | - $context->id, 'mod_questionnaire', 'feedback', $fbid, ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], |
235 | | - $settings->feedbacktext[$i]['text']); |
| 256 | + $feedbacktext = file_save_draft_area_files( |
| 257 | + (int)$settings->feedbacktext[$i]['itemid'], |
| 258 | + $context->id, |
| 259 | + 'mod_questionnaire', |
| 260 | + 'feedback', |
| 261 | + $fbid, |
| 262 | + ['subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0], |
| 263 | + $settings->feedbacktext[$i]['text'] |
| 264 | + ); |
236 | 265 | $feedbacksection->sectionfeedback[$fbid]->feedbacktext = $feedbacktext; |
237 | 266 | } |
238 | 267 |
|
|
265 | 294 | $buttonyes = new single_button($urlyes, get_string('yes')); |
266 | 295 | $buttonno = new single_button($urlno, get_string('no')); |
267 | 296 | $questionnaire->page->add_to_page('formarea', $questionnaire->renderer->confirm($msg, $buttonyes, $buttonno)); |
268 | | - |
269 | 297 | } else if ($action == 'confirmdeletesection') { |
270 | 298 | $sectionid = required_param('sectionid', PARAM_INT); |
271 | 299 | $msg = '<div class="warning centerpara"><p>' . |
|
277 | 305 | $buttonyes = new single_button($urlyes, get_string('yes')); |
278 | 306 | $buttonno = new single_button($urlno, get_string('no')); |
279 | 307 | $questionnaire->page->add_to_page('formarea', $questionnaire->renderer->confirm($msg, $buttonyes, $buttonno)); |
280 | | - |
281 | 308 | } else { |
282 | 309 | $questionnaire->page->add_to_page('formarea', $feedbackform->render()); |
283 | 310 | } |
|
0 commit comments