@@ -8,48 +8,48 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class AttendanceLink extends AbstractLink |
10 | 10 | { |
11 | - private $attendance_table = null; |
|
12 | - private $itemprop_table = null; |
|
11 | + private $attendance_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_ATTENDANCE); |
|
21 | - } |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_ATTENDANCE); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function get_type_name() |
|
27 | - { |
|
28 | - return get_lang('Attendance'); |
|
29 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function get_type_name() |
|
27 | + { |
|
28 | + return get_lang('Attendance'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return bool |
|
33 | - */ |
|
34 | - public function is_allowed_to_change_name() |
|
35 | - { |
|
36 | - return false; |
|
37 | - } |
|
31 | + /** |
|
32 | + * @return bool |
|
33 | + */ |
|
34 | + public function is_allowed_to_change_name() |
|
35 | + { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | - * @todo seems to be depracated |
|
43 | - */ |
|
44 | - public function get_not_created_links() |
|
45 | - { |
|
46 | - return false; |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
39 | + /** |
|
40 | + * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | + * @todo seems to be depracated |
|
43 | + */ |
|
44 | + public function get_not_created_links() |
|
45 | + { |
|
46 | + return false; |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
51 | 51 | |
52 | - $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
52 | + $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
53 | 53 | FROM '.$this->get_attendance_table().' att |
54 | 54 | WHERE |
55 | 55 | att.c_id = '.$this->course_id.' AND |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | course_code = "'.Database::escape_string($this->get_course_code()).'" |
61 | 61 | ) |
62 | 62 | AND att.session_id='.api_get_session_id().''; |
63 | - $result = Database::query($sql); |
|
63 | + $result = Database::query($sql); |
|
64 | 64 | |
65 | 65 | $cats = array(); |
66 | 66 | while ($data = Database::fetch_array($result)) { |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - return $cats; |
|
75 | - } |
|
74 | + return $cats; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Generate an array of all attendances available. |
|
79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | - */ |
|
77 | + /** |
|
78 | + * Generate an array of all attendances available. |
|
79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | + */ |
|
81 | 81 | public function get_all_links() |
82 | 82 | { |
83 | 83 | if (empty($this->course_code)) { |
@@ -104,55 +104,55 @@ discard block |
||
104 | 104 | $my_cats = isset($cats) ? $cats : null; |
105 | 105 | |
106 | 106 | return $my_cats; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Has anyone done this exercise yet ? |
|
111 | - */ |
|
112 | - public function has_results() |
|
113 | - { |
|
114 | - $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | - $session_id = api_get_session_id(); |
|
116 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
109 | + /** |
|
110 | + * Has anyone done this exercise yet ? |
|
111 | + */ |
|
112 | + public function has_results() |
|
113 | + { |
|
114 | + $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | + $session_id = api_get_session_id(); |
|
116 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
117 | 117 | WHERE |
118 | 118 | session_id = $session_id AND |
119 | 119 | c_id = '.$this->course_id.' AND |
120 | 120 | attendance_id = '".intval($this->get_ref_id())."'"; |
121 | - $result = Database::query($sql); |
|
122 | - $number = Database::fetch_row($result); |
|
121 | + $result = Database::query($sql); |
|
122 | + $number = Database::fetch_row($result); |
|
123 | 123 | |
124 | - return $number[0] != 0; |
|
125 | - } |
|
124 | + return $number[0] != 0; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @param int $stud_id |
|
129 | - * @return array|null |
|
130 | - */ |
|
131 | - public function calc_score($stud_id = null, $type = null) |
|
132 | - { |
|
133 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | - $session_id = api_get_session_id(); |
|
127 | + /** |
|
128 | + * @param int $stud_id |
|
129 | + * @return array|null |
|
130 | + */ |
|
131 | + public function calc_score($stud_id = null, $type = null) |
|
132 | + { |
|
133 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | + $session_id = api_get_session_id(); |
|
135 | 135 | |
136 | - // get attendance qualify max |
|
137 | - $sql = 'SELECT att.attendance_qualify_max |
|
136 | + // get attendance qualify max |
|
137 | + $sql = 'SELECT att.attendance_qualify_max |
|
138 | 138 | FROM '.$this->get_attendance_table().' att |
139 | 139 | WHERE |
140 | 140 | att.c_id = '.$this->course_id.' AND |
141 | 141 | att.id = '.intval($this->get_ref_id()).' AND |
142 | 142 | att.session_id='.intval($session_id).''; |
143 | - $query = Database::query($sql); |
|
144 | - $attendance = Database::fetch_array($query, 'ASSOC'); |
|
143 | + $query = Database::query($sql); |
|
144 | + $attendance = Database::fetch_array($query, 'ASSOC'); |
|
145 | 145 | |
146 | - // Get results |
|
147 | - $sql = 'SELECT * |
|
146 | + // Get results |
|
147 | + $sql = 'SELECT * |
|
148 | 148 | FROM '.$tbl_attendance_result.' |
149 | 149 | WHERE c_id = '.$this->course_id.' AND attendance_id = '.intval($this->get_ref_id()); |
150 | - if (isset($stud_id)) { |
|
151 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | - } |
|
153 | - $scores = Database::query($sql); |
|
154 | - // for 1 student |
|
155 | - if (isset($stud_id)) { |
|
150 | + if (isset($stud_id)) { |
|
151 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | + } |
|
153 | + $scores = Database::query($sql); |
|
154 | + // for 1 student |
|
155 | + if (isset($stud_id)) { |
|
156 | 156 | if ($data = Database::fetch_array($scores, 'ASSOC')) { |
157 | 157 | return array( |
158 | 158 | $data['score'], |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | //We sent the 0/attendance_qualify_max instead of null for correct calculations |
163 | 163 | return array(0, $attendance['attendance_qualify_max']); |
164 | 164 | } |
165 | - } else { |
|
165 | + } else { |
|
166 | 166 | // all students -> get average |
167 | 167 | $students = array(); // user list, needed to make sure we only |
168 | 168 | // take first attempts into account |
@@ -171,144 +171,144 @@ discard block |
||
171 | 171 | $sumResult = 0; |
172 | 172 | $bestResult = 0; |
173 | 173 | |
174 | - while ($data = Database::fetch_array($scores)) { |
|
175 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | - if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | - $students[$data['user_id']] = $data['score']; |
|
178 | - $rescount++; |
|
179 | - $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | - $sumResult += $data['score']; |
|
181 | - if ($data['score'] > $bestResult) { |
|
182 | - $bestResult = $data['score']; |
|
183 | - } |
|
184 | - $weight = $attendance['attendance_qualify_max']; |
|
185 | - } |
|
186 | - } |
|
187 | - } |
|
174 | + while ($data = Database::fetch_array($scores)) { |
|
175 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | + if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | + $students[$data['user_id']] = $data['score']; |
|
178 | + $rescount++; |
|
179 | + $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | + $sumResult += $data['score']; |
|
181 | + if ($data['score'] > $bestResult) { |
|
182 | + $bestResult = $data['score']; |
|
183 | + } |
|
184 | + $weight = $attendance['attendance_qualify_max']; |
|
185 | + } |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - if ($rescount == 0) { |
|
190 | - return null; |
|
191 | - } else { |
|
192 | - switch ($type) { |
|
193 | - case 'best': |
|
194 | - return array($bestResult, $weight); |
|
195 | - break; |
|
196 | - case 'average': |
|
197 | - return array($sumResult / $rescount, $weight); |
|
198 | - break; |
|
199 | - case 'ranking': |
|
200 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | - break; |
|
202 | - default: |
|
203 | - return array($sum, $rescount); |
|
204 | - break; |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - } |
|
189 | + if ($rescount == 0) { |
|
190 | + return null; |
|
191 | + } else { |
|
192 | + switch ($type) { |
|
193 | + case 'best': |
|
194 | + return array($bestResult, $weight); |
|
195 | + break; |
|
196 | + case 'average': |
|
197 | + return array($sumResult / $rescount, $weight); |
|
198 | + break; |
|
199 | + case 'ranking': |
|
200 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | + break; |
|
202 | + default: |
|
203 | + return array($sum, $rescount); |
|
204 | + break; |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * Lazy load function to get the database table of the student publications |
|
212 | - */ |
|
213 | - private function get_attendance_table() |
|
214 | - { |
|
215 | - $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | - return $this->attendance_table; |
|
217 | - } |
|
210 | + /** |
|
211 | + * Lazy load function to get the database table of the student publications |
|
212 | + */ |
|
213 | + private function get_attendance_table() |
|
214 | + { |
|
215 | + $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | + return $this->attendance_table; |
|
217 | + } |
|
218 | 218 | |
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | 223 | |
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | 228 | |
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function get_name() |
|
238 | - { |
|
239 | - $this->get_attendance_data(); |
|
240 | - $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | - $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | - return $this->attendance_data['attendance_qualify_title']; |
|
244 | - } else { |
|
245 | - return $attendance_title; |
|
246 | - } |
|
247 | - } |
|
234 | + /** |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function get_name() |
|
238 | + { |
|
239 | + $this->get_attendance_data(); |
|
240 | + $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | + $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | + if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | + return $this->attendance_data['attendance_qualify_title']; |
|
244 | + } else { |
|
245 | + return $attendance_title; |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - public function get_description() |
|
253 | - { |
|
254 | - return ''; |
|
255 | - } |
|
249 | + /** |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + public function get_description() |
|
253 | + { |
|
254 | + return ''; |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * Check if this still links to an exercise |
|
259 | - */ |
|
260 | - public function is_valid_link() |
|
261 | - { |
|
262 | - $session_id = api_get_session_id(); |
|
263 | - $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
257 | + /** |
|
258 | + * Check if this still links to an exercise |
|
259 | + */ |
|
260 | + public function is_valid_link() |
|
261 | + { |
|
262 | + $session_id = api_get_session_id(); |
|
263 | + $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
264 | 264 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
265 | - $result = Database::query($sql); |
|
266 | - $number = Database::fetch_row($result); |
|
267 | - return ($number[0] != 0); |
|
268 | - } |
|
265 | + $result = Database::query($sql); |
|
266 | + $number = Database::fetch_row($result); |
|
267 | + return ($number[0] != 0); |
|
268 | + } |
|
269 | 269 | |
270 | - public function get_test_id() |
|
271 | - { |
|
272 | - return 'DEBUG:ID'; |
|
273 | - } |
|
270 | + public function get_test_id() |
|
271 | + { |
|
272 | + return 'DEBUG:ID'; |
|
273 | + } |
|
274 | 274 | |
275 | - public function get_link() |
|
276 | - { |
|
277 | - //it was extracts the attendance id |
|
278 | - $session_id = api_get_session_id(); |
|
279 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
275 | + public function get_link() |
|
276 | + { |
|
277 | + //it was extracts the attendance id |
|
278 | + $session_id = api_get_session_id(); |
|
279 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
281 | - $result = Database::query($sql); |
|
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
283 | - $attendance_id = $row['id']; |
|
284 | - $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
281 | + $result = Database::query($sql); |
|
282 | + $row = Database::fetch_array($result,'ASSOC'); |
|
283 | + $attendance_id = $row['id']; |
|
284 | + $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
285 | 285 | |
286 | - return $url; |
|
287 | - } |
|
286 | + return $url; |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * @return array|bool |
|
291 | - */ |
|
292 | - private function get_attendance_data() |
|
293 | - { |
|
294 | - $tbl_name = $this->get_attendance_table(); |
|
295 | - $session_id = api_get_session_id(); |
|
296 | - if ($tbl_name == '') { |
|
297 | - return false; |
|
298 | - } elseif (!isset($this->attendance_data)) { |
|
299 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
289 | + /** |
|
290 | + * @return array|bool |
|
291 | + */ |
|
292 | + private function get_attendance_data() |
|
293 | + { |
|
294 | + $tbl_name = $this->get_attendance_table(); |
|
295 | + $session_id = api_get_session_id(); |
|
296 | + if ($tbl_name == '') { |
|
297 | + return false; |
|
298 | + } elseif (!isset($this->attendance_data)) { |
|
299 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
300 | 300 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
301 | - $query = Database::query($sql); |
|
302 | - $this->attendance_data = Database::fetch_array($query); |
|
303 | - } |
|
304 | - return $this->attendance_data; |
|
305 | - } |
|
301 | + $query = Database::query($sql); |
|
302 | + $this->attendance_data = Database::fetch_array($query); |
|
303 | + } |
|
304 | + return $this->attendance_data; |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - public function get_icon_name() |
|
311 | - { |
|
312 | - return 'attendance'; |
|
313 | - } |
|
307 | + /** |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + public function get_icon_name() |
|
311 | + { |
|
312 | + return 'attendance'; |
|
313 | + } |
|
314 | 314 | } |
@@ -8,98 +8,98 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class SurveyLink extends AbstractLink |
10 | 10 | { |
11 | - private $survey_table = null; |
|
12 | - |
|
13 | - /** |
|
14 | - * Constructor |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - parent::__construct(); |
|
19 | - $this->set_type(LINK_SURVEY); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public function get_name() |
|
26 | - { |
|
27 | - $this->get_survey_data(); |
|
11 | + private $survey_table = null; |
|
12 | + |
|
13 | + /** |
|
14 | + * Constructor |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + parent::__construct(); |
|
19 | + $this->set_type(LINK_SURVEY); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public function get_name() |
|
26 | + { |
|
27 | + $this->get_survey_data(); |
|
28 | 28 | |
29 | - return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
30 | - } |
|
31 | - |
|
32 | - public function get_description() |
|
33 | - { |
|
34 | - $this->get_survey_data(); |
|
35 | - return $this->survey_data['subtitle']; |
|
36 | - } |
|
37 | - |
|
38 | - public function get_type_name() |
|
39 | - { |
|
40 | - return get_lang('Survey'); |
|
41 | - } |
|
42 | - |
|
43 | - public function is_allowed_to_change_name() |
|
44 | - { |
|
45 | - return false; |
|
46 | - } |
|
47 | - |
|
48 | - public function needs_name_and_description() |
|
49 | - { |
|
50 | - return false; |
|
51 | - } |
|
52 | - |
|
53 | - public function needs_max() |
|
54 | - { |
|
55 | - return false; |
|
56 | - } |
|
57 | - |
|
58 | - public function needs_results() |
|
59 | - { |
|
60 | - return false; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Generates an array of all surveys available. |
|
65 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
66 | - */ |
|
67 | - public function get_all_links() |
|
68 | - { |
|
69 | - if (empty($this->course_code)) { |
|
70 | - die('Error in get_all_links() : course code not set'); |
|
71 | - } |
|
72 | - $tbl_survey = $this->get_survey_table(); |
|
73 | - $session_id = api_get_session_id(); |
|
74 | - $course_id = api_get_course_int_id(); |
|
75 | - $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
29 | + return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
30 | + } |
|
31 | + |
|
32 | + public function get_description() |
|
33 | + { |
|
34 | + $this->get_survey_data(); |
|
35 | + return $this->survey_data['subtitle']; |
|
36 | + } |
|
37 | + |
|
38 | + public function get_type_name() |
|
39 | + { |
|
40 | + return get_lang('Survey'); |
|
41 | + } |
|
42 | + |
|
43 | + public function is_allowed_to_change_name() |
|
44 | + { |
|
45 | + return false; |
|
46 | + } |
|
47 | + |
|
48 | + public function needs_name_and_description() |
|
49 | + { |
|
50 | + return false; |
|
51 | + } |
|
52 | + |
|
53 | + public function needs_max() |
|
54 | + { |
|
55 | + return false; |
|
56 | + } |
|
57 | + |
|
58 | + public function needs_results() |
|
59 | + { |
|
60 | + return false; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Generates an array of all surveys available. |
|
65 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
66 | + */ |
|
67 | + public function get_all_links() |
|
68 | + { |
|
69 | + if (empty($this->course_code)) { |
|
70 | + die('Error in get_all_links() : course code not set'); |
|
71 | + } |
|
72 | + $tbl_survey = $this->get_survey_table(); |
|
73 | + $session_id = api_get_session_id(); |
|
74 | + $course_id = api_get_course_int_id(); |
|
75 | + $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
76 | 76 | WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id).''; |
77 | - $result = Database::query($sql); |
|
78 | - while ($data = Database::fetch_array($result)) { |
|
79 | - $links[] = array( |
|
80 | - $data['survey_id'], |
|
81 | - api_trunc_str( |
|
82 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
83 | - 80 |
|
84 | - ) |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - return isset($links) ? $links : null; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Generates an array of surveys that a teacher hasn't created a link for. |
|
93 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
94 | - */ |
|
95 | - public function get_not_created_links() |
|
96 | - { |
|
97 | - if (empty($this->course_code)) { |
|
98 | - die('Error in get_not_created_links() : course code not set'); |
|
99 | - } |
|
100 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
101 | - |
|
102 | - $sql = 'SELECT survey_id, title, code |
|
77 | + $result = Database::query($sql); |
|
78 | + while ($data = Database::fetch_array($result)) { |
|
79 | + $links[] = array( |
|
80 | + $data['survey_id'], |
|
81 | + api_trunc_str( |
|
82 | + $data['code'] . ': ' . self::html_to_text($data['title']), |
|
83 | + 80 |
|
84 | + ) |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + return isset($links) ? $links : null; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Generates an array of surveys that a teacher hasn't created a link for. |
|
93 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
94 | + */ |
|
95 | + public function get_not_created_links() |
|
96 | + { |
|
97 | + if (empty($this->course_code)) { |
|
98 | + die('Error in get_not_created_links() : course code not set'); |
|
99 | + } |
|
100 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
101 | + |
|
102 | + $sql = 'SELECT survey_id, title, code |
|
103 | 103 | FROM '.$this->get_survey_table().' AS srv |
104 | 104 | WHERE survey_id NOT IN |
105 | 105 | ( |
@@ -110,28 +110,28 @@ discard block |
||
110 | 110 | ) |
111 | 111 | AND srv.session_id = '.api_get_session_id(); |
112 | 112 | |
113 | - $result = Database::query($sql); |
|
114 | - |
|
115 | - $links = array(); |
|
116 | - while ($data = Database::fetch_array($result)) { |
|
117 | - $links[] = array( |
|
118 | - $data['survey_id'], |
|
119 | - api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
120 | - ); |
|
121 | - } |
|
122 | - return $links; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Has anyone done this survey yet? |
|
127 | - */ |
|
128 | - public function has_results($stud_id=null) |
|
129 | - { |
|
130 | - $ref_id = intval($this->get_ref_id()); |
|
131 | - $session_id = api_get_session_id(); |
|
132 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
133 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
134 | - $sql = "SELECT |
|
113 | + $result = Database::query($sql); |
|
114 | + |
|
115 | + $links = array(); |
|
116 | + while ($data = Database::fetch_array($result)) { |
|
117 | + $links[] = array( |
|
118 | + $data['survey_id'], |
|
119 | + api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
120 | + ); |
|
121 | + } |
|
122 | + return $links; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Has anyone done this survey yet? |
|
127 | + */ |
|
128 | + public function has_results($stud_id=null) |
|
129 | + { |
|
130 | + $ref_id = intval($this->get_ref_id()); |
|
131 | + $session_id = api_get_session_id(); |
|
132 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
133 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
134 | + $sql = "SELECT |
|
135 | 135 | COUNT(i.answered) |
136 | 136 | FROM $tbl_survey AS s |
137 | 137 | JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | s.survey_id = $ref_id AND |
142 | 142 | i.session_id = $session_id"; |
143 | 143 | |
144 | - $sql_result = Database::query($sql); |
|
145 | - $data = Database::fetch_array($sql_result); |
|
144 | + $sql_result = Database::query($sql); |
|
145 | + $data = Database::fetch_array($sql_result); |
|
146 | 146 | |
147 | - return ($data[0] != 0); |
|
148 | - } |
|
147 | + return ($data[0] != 0); |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * @param int $stud_id |
|
152 | - * @return array|null |
|
153 | - */ |
|
154 | - public function calc_score($stud_id = null, $type = null) |
|
155 | - { |
|
156 | - // Note: Max score is assumed to be always 1 for surveys, |
|
157 | - // only student's participation is to be taken into account. |
|
158 | - $max_score = 1; |
|
150 | + /** |
|
151 | + * @param int $stud_id |
|
152 | + * @return array|null |
|
153 | + */ |
|
154 | + public function calc_score($stud_id = null, $type = null) |
|
155 | + { |
|
156 | + // Note: Max score is assumed to be always 1 for surveys, |
|
157 | + // only student's participation is to be taken into account. |
|
158 | + $max_score = 1; |
|
159 | 159 | |
160 | - $ref_id = intval($this->get_ref_id()); |
|
161 | - $session_id = api_get_session_id(); |
|
162 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
163 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
160 | + $ref_id = intval($this->get_ref_id()); |
|
161 | + $session_id = api_get_session_id(); |
|
162 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
163 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
164 | 164 | |
165 | - $get_individual_score = !is_null($stud_id); |
|
165 | + $get_individual_score = !is_null($stud_id); |
|
166 | 166 | |
167 | - $sql = "SELECT i.answered |
|
167 | + $sql = "SELECT i.answered |
|
168 | 168 | FROM $tbl_survey AS s |
169 | 169 | JOIN $tbl_survey_invitation AS i |
170 | 170 | ON s.code = i.survey_code |
@@ -175,131 +175,131 @@ discard block |
||
175 | 175 | i.session_id = $session_id |
176 | 176 | "; |
177 | 177 | |
178 | - if ($get_individual_score) { |
|
179 | - $sql .= ' AND i.user = '.intval($stud_id); |
|
180 | - } |
|
181 | - |
|
182 | - $sql_result = Database::query($sql); |
|
183 | - |
|
184 | - if ($get_individual_score) { |
|
185 | - // for 1 student |
|
186 | - if ($data = Database::fetch_array($sql_result)) { |
|
187 | - return array($data['answered'] ? $max_score : 0, $max_score); |
|
188 | - } |
|
189 | - return array(0, $max_score); |
|
190 | - } else { |
|
191 | - // for all the students -> get average |
|
192 | - $rescount = 0; |
|
193 | - $sum = 0; |
|
194 | - $bestResult = 0; |
|
195 | - $weight = 0; |
|
196 | - while ($data = Database::fetch_array($sql_result)) { |
|
197 | - $sum += $data['answered'] ? $max_score : 0; |
|
198 | - $rescount++; |
|
199 | - if ($data['answered'] > $bestResult) { |
|
200 | - $bestResult = $data['answered']; |
|
201 | - $weight = $assignment['qualification']; |
|
202 | - } |
|
203 | - } |
|
204 | - $sum = $sum / $max_score; |
|
205 | - |
|
206 | - if ($rescount == 0) { |
|
207 | - return null; |
|
208 | - } |
|
209 | - |
|
210 | - switch ($type) { |
|
211 | - case 'best': |
|
212 | - return array($bestResult, $rescount); |
|
213 | - break; |
|
214 | - case 'average': |
|
215 | - return array($sum, $rescount); |
|
216 | - break; |
|
217 | - case 'ranking': |
|
218 | - return null; |
|
219 | - break; |
|
220 | - default: |
|
221 | - return array($sum, $rescount); |
|
222 | - break; |
|
223 | - } |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Lazy load function to get the database table of the surveys |
|
229 | - */ |
|
230 | - private function get_survey_table() |
|
231 | - { |
|
232 | - $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
233 | - return $this->survey_table; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Check if this still links to a survey |
|
238 | - */ |
|
239 | - public function is_valid_link() |
|
240 | - { |
|
241 | - $session_id = api_get_session_id(); |
|
242 | - $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
178 | + if ($get_individual_score) { |
|
179 | + $sql .= ' AND i.user = '.intval($stud_id); |
|
180 | + } |
|
181 | + |
|
182 | + $sql_result = Database::query($sql); |
|
183 | + |
|
184 | + if ($get_individual_score) { |
|
185 | + // for 1 student |
|
186 | + if ($data = Database::fetch_array($sql_result)) { |
|
187 | + return array($data['answered'] ? $max_score : 0, $max_score); |
|
188 | + } |
|
189 | + return array(0, $max_score); |
|
190 | + } else { |
|
191 | + // for all the students -> get average |
|
192 | + $rescount = 0; |
|
193 | + $sum = 0; |
|
194 | + $bestResult = 0; |
|
195 | + $weight = 0; |
|
196 | + while ($data = Database::fetch_array($sql_result)) { |
|
197 | + $sum += $data['answered'] ? $max_score : 0; |
|
198 | + $rescount++; |
|
199 | + if ($data['answered'] > $bestResult) { |
|
200 | + $bestResult = $data['answered']; |
|
201 | + $weight = $assignment['qualification']; |
|
202 | + } |
|
203 | + } |
|
204 | + $sum = $sum / $max_score; |
|
205 | + |
|
206 | + if ($rescount == 0) { |
|
207 | + return null; |
|
208 | + } |
|
209 | + |
|
210 | + switch ($type) { |
|
211 | + case 'best': |
|
212 | + return array($bestResult, $rescount); |
|
213 | + break; |
|
214 | + case 'average': |
|
215 | + return array($sum, $rescount); |
|
216 | + break; |
|
217 | + case 'ranking': |
|
218 | + return null; |
|
219 | + break; |
|
220 | + default: |
|
221 | + return array($sum, $rescount); |
|
222 | + break; |
|
223 | + } |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Lazy load function to get the database table of the surveys |
|
229 | + */ |
|
230 | + private function get_survey_table() |
|
231 | + { |
|
232 | + $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
233 | + return $this->survey_table; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Check if this still links to a survey |
|
238 | + */ |
|
239 | + public function is_valid_link() |
|
240 | + { |
|
241 | + $session_id = api_get_session_id(); |
|
242 | + $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
243 | 243 | WHERE |
244 | 244 | c_id = '.$this->course_id.' AND |
245 | 245 | survey_id = '.intval($this->get_ref_id()).' AND |
246 | 246 | session_id='.intval($session_id).''; |
247 | - $result = Database::query($sql); |
|
248 | - $number = Database::fetch_row($result); |
|
249 | - return ($number[0] != 0); |
|
250 | - } |
|
251 | - |
|
252 | - public function get_test_id() |
|
253 | - { |
|
254 | - return 'DEBUG:ID'; |
|
255 | - } |
|
256 | - |
|
257 | - public function get_link() |
|
258 | - { |
|
259 | - if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
260 | - $tbl_name = $this->get_survey_table(); |
|
261 | - $session_id = api_get_session_id(); |
|
262 | - if ($tbl_name != '') { |
|
263 | - $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
247 | + $result = Database::query($sql); |
|
248 | + $number = Database::fetch_row($result); |
|
249 | + return ($number[0] != 0); |
|
250 | + } |
|
251 | + |
|
252 | + public function get_test_id() |
|
253 | + { |
|
254 | + return 'DEBUG:ID'; |
|
255 | + } |
|
256 | + |
|
257 | + public function get_link() |
|
258 | + { |
|
259 | + if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
260 | + $tbl_name = $this->get_survey_table(); |
|
261 | + $session_id = api_get_session_id(); |
|
262 | + if ($tbl_name != '') { |
|
263 | + $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
264 | 264 | WHERE |
265 | 265 | c_id = '.$this->course_id.' AND |
266 | 266 | survey_id = '.intval($this->get_ref_id()).' AND |
267 | 267 | session_id = '.intval($session_id).' '; |
268 | - $result = Database::query($sql); |
|
269 | - $row = Database::fetch_array($result, 'ASSOC'); |
|
270 | - $survey_id = $row['survey_id']; |
|
271 | - return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; |
|
272 | - } |
|
273 | - } |
|
274 | - return null; |
|
275 | - } |
|
276 | - |
|
277 | - private function get_survey_data() |
|
278 | - { |
|
279 | - $tbl_name = $this->get_survey_table(); |
|
280 | - $session_id = api_get_session_id(); |
|
281 | - if ($tbl_name == '') { |
|
282 | - return false; |
|
283 | - } elseif (!isset($this->survey_data)) { |
|
284 | - $sql = 'SELECT * FROM '.$tbl_name.' |
|
268 | + $result = Database::query($sql); |
|
269 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
270 | + $survey_id = $row['survey_id']; |
|
271 | + return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; |
|
272 | + } |
|
273 | + } |
|
274 | + return null; |
|
275 | + } |
|
276 | + |
|
277 | + private function get_survey_data() |
|
278 | + { |
|
279 | + $tbl_name = $this->get_survey_table(); |
|
280 | + $session_id = api_get_session_id(); |
|
281 | + if ($tbl_name == '') { |
|
282 | + return false; |
|
283 | + } elseif (!isset($this->survey_data)) { |
|
284 | + $sql = 'SELECT * FROM '.$tbl_name.' |
|
285 | 285 | WHERE |
286 | 286 | c_id = '.$this->course_id.' AND |
287 | 287 | survey_id = '.intval($this->get_ref_id()).' AND |
288 | 288 | session_id='.intval($session_id).''; |
289 | - $query = Database::query($sql); |
|
290 | - $this->survey_data = Database::fetch_array($query); |
|
291 | - } |
|
292 | - return $this->survey_data; |
|
293 | - } |
|
294 | - |
|
295 | - public function get_icon_name() |
|
296 | - { |
|
297 | - return 'survey'; |
|
298 | - } |
|
299 | - |
|
300 | - private static function html_to_text($string) |
|
301 | - { |
|
302 | - return strip_tags($string); |
|
303 | - //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
304 | - } |
|
289 | + $query = Database::query($sql); |
|
290 | + $this->survey_data = Database::fetch_array($query); |
|
291 | + } |
|
292 | + return $this->survey_data; |
|
293 | + } |
|
294 | + |
|
295 | + public function get_icon_name() |
|
296 | + { |
|
297 | + return 'survey'; |
|
298 | + } |
|
299 | + |
|
300 | + private static function html_to_text($string) |
|
301 | + { |
|
302 | + return strip_tags($string); |
|
303 | + //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
304 | + } |
|
305 | 305 | } |
@@ -251,7 +251,7 @@ |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&' . $courseParams.'">' . |
|
254 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&' . $courseParams.'">' . |
|
255 | 255 | Display::return_icon( |
256 | 256 | 'percentage.png', |
257 | 257 | get_lang('EditAllWeights'), |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class ExerciseShowFunctions |
19 | 19 | { |
20 | - /** |
|
21 | - * Shows the answer to a fill-in-the-blanks question, as HTML |
|
20 | + /** |
|
21 | + * Shows the answer to a fill-in-the-blanks question, as HTML |
|
22 | 22 | * @param int $feedbackType |
23 | - * @param string $answer |
|
24 | - * @param int $id Exercise ID |
|
25 | - * @param int $questionId Question ID |
|
23 | + * @param string $answer |
|
24 | + * @param int $id Exercise ID |
|
25 | + * @param int $questionId Question ID |
|
26 | 26 | * @param int $resultsDisabled |
27 | 27 | * @param string $originalStudentAnswer |
28 | 28 | * |
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function display_fill_in_blanks_answer( |
|
32 | - $feedbackType, |
|
33 | - $answer, |
|
34 | - $id, |
|
35 | - $questionId, |
|
36 | - $resultsDisabled, |
|
37 | - $originalStudentAnswer = '', |
|
38 | - $showTotalScoreAndUserChoices |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function display_fill_in_blanks_answer( |
|
32 | + $feedbackType, |
|
33 | + $answer, |
|
34 | + $id, |
|
35 | + $questionId, |
|
36 | + $resultsDisabled, |
|
37 | + $originalStudentAnswer = '', |
|
38 | + $showTotalScoreAndUserChoices |
|
39 | 39 | ) { |
40 | 40 | $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled, $showTotalScoreAndUserChoices); |
41 | 41 | if (strpos($originalStudentAnswer, 'font color') !== false) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | </tr> |
65 | 65 | <?php |
66 | 66 | } |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Shows the answer to a calculated question, as HTML |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Shows the answer to a free-answer question, as HTML |
|
110 | - * @param string Answer text |
|
111 | - * @param int Exercise ID |
|
112 | - * @param int Question ID |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public static function display_free_answer( |
|
116 | - $feedback_type, |
|
117 | - $answer, |
|
118 | - $exe_id, |
|
119 | - $questionId, |
|
120 | - $questionScore = null, |
|
121 | - $results_disabled = 0 |
|
108 | + /** |
|
109 | + * Shows the answer to a free-answer question, as HTML |
|
110 | + * @param string Answer text |
|
111 | + * @param int Exercise ID |
|
112 | + * @param int Question ID |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public static function display_free_answer( |
|
116 | + $feedback_type, |
|
117 | + $answer, |
|
118 | + $exe_id, |
|
119 | + $questionId, |
|
120 | + $questionScore = null, |
|
121 | + $results_disabled = 0 |
|
122 | 122 | ) { |
123 | 123 | $comments = Event::get_comments($exe_id, $questionId); |
124 | 124 | |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | echo '</tr>'; |
137 | 137 | } |
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | - * @param $feedback_type |
|
143 | - * @param $answer |
|
144 | - * @param $id |
|
145 | - * @param $questionId |
|
146 | - * @param null $nano |
|
147 | - * @param int $results_disabled |
|
142 | + * @param $feedback_type |
|
143 | + * @param $answer |
|
144 | + * @param $id |
|
145 | + * @param $questionId |
|
146 | + * @param null $nano |
|
147 | + * @param int $results_disabled |
|
148 | 148 | */ |
149 | - public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) |
|
149 | + public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) |
|
150 | 150 | { |
151 | 151 | if (isset($fileUrl)) { |
152 | 152 | echo ' |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - /** |
|
188 | - * Displays the answer to a hotspot question |
|
187 | + /** |
|
188 | + * Displays the answer to a hotspot question |
|
189 | 189 | * @param int $feedback_type |
190 | 190 | * @param int $answerId |
191 | 191 | * @param string $answer |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param int $resultsDisabled |
195 | 195 | * @param int $orderColor |
196 | 196 | */ |
197 | - public static function display_hotspot_answer( |
|
197 | + public static function display_hotspot_answer( |
|
198 | 198 | $feedback_type, |
199 | 199 | $answerId, |
200 | 200 | $answer, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - $hotspot_colors = array( |
|
220 | + $hotspot_colors = array( |
|
221 | 221 | "", // $i starts from 1 on next loop (ugly fix) |
222 | 222 | "#4271B5", |
223 | 223 | "#FE8E16", |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | "#F7BDE2" |
235 | 235 | ); |
236 | 236 | |
237 | - ?> |
|
237 | + ?> |
|
238 | 238 | <table class="data_table"> |
239 | 239 | <tr> |
240 | 240 | <td class="text-center" width="5%"> |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | <td class="text-left" width="10%"> |
247 | 247 | <?php |
248 | 248 | if (!$hide_expected_answer) { |
249 | - $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
250 | - echo $my_choice; |
|
249 | + $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
250 | + echo $my_choice; |
|
251 | 251 | } |
252 | - ?> |
|
252 | + ?> |
|
253 | 253 | </td> |
254 | 254 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
255 | 255 | <td class="text-left" width="60%"> |
@@ -257,29 +257,29 @@ discard block |
||
257 | 257 | if ($studentChoice) { |
258 | 258 | echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
259 | 259 | } |
260 | - ?> |
|
260 | + ?> |
|
261 | 261 | </td> |
262 | 262 | <?php } else { ?> |
263 | 263 | <td class="text-left" width="60%"> </td> |
264 | 264 | <?php } ?> |
265 | 265 | </tr> |
266 | 266 | <?php |
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Display the answers to a multiple choice question |
|
271 | - * @param int $feedback_type Feedback type |
|
272 | - * @param integer Answer type |
|
273 | - * @param integer Student choice |
|
274 | - * @param string Textual answer |
|
275 | - * @param string Comment on answer |
|
276 | - * @param string Correct answer comment |
|
277 | - * @param integer Exercise ID |
|
278 | - * @param integer Question ID |
|
279 | - * @param boolean Whether to show the answer comment or not |
|
280 | - * @return void |
|
281 | - */ |
|
282 | - public static function display_unique_or_multiple_answer( |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Display the answers to a multiple choice question |
|
271 | + * @param int $feedback_type Feedback type |
|
272 | + * @param integer Answer type |
|
273 | + * @param integer Student choice |
|
274 | + * @param string Textual answer |
|
275 | + * @param string Comment on answer |
|
276 | + * @param string Correct answer comment |
|
277 | + * @param integer Exercise ID |
|
278 | + * @param integer Question ID |
|
279 | + * @param boolean Whether to show the answer comment or not |
|
280 | + * @return void |
|
281 | + */ |
|
282 | + public static function display_unique_or_multiple_answer( |
|
283 | 283 | $feedback_type, |
284 | 284 | $answerType, |
285 | 285 | $studentChoice, |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | $icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
310 | - $icon .= $studentChoice?'_on':'_off'; |
|
311 | - $icon .= '.gif'; |
|
310 | + $icon .= $studentChoice?'_on':'_off'; |
|
311 | + $icon .= '.gif'; |
|
312 | 312 | |
313 | - $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
314 | - $iconAnswer .= $answerCorrect?'_on':'_off'; |
|
315 | - $iconAnswer .= '.gif'; |
|
313 | + $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
314 | + $iconAnswer .= $answerCorrect?'_on':'_off'; |
|
315 | + $iconAnswer .= '.gif'; |
|
316 | 316 | |
317 | - ?> |
|
317 | + ?> |
|
318 | 318 | <tr> |
319 | 319 | <td width="5%"> |
320 | 320 | <?php echo Display::return_icon($icon); ?> |
@@ -328,39 +328,39 @@ discard block |
||
328 | 328 | </td> |
329 | 329 | <td width="40%"> |
330 | 330 | <?php |
331 | - echo $answer; |
|
332 | - ?> |
|
331 | + echo $answer; |
|
332 | + ?> |
|
333 | 333 | </td> |
334 | 334 | |
335 | 335 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
336 | 336 | <td width="20%"> |
337 | 337 | <?php |
338 | 338 | if ($studentChoice) { |
339 | - if ($answerCorrect) { |
|
339 | + if ($answerCorrect) { |
|
340 | 340 | $color = 'green'; |
341 | - //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
342 | - } else { |
|
341 | + //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
342 | + } else { |
|
343 | 343 | $color = 'black'; |
344 | 344 | //echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>'; |
345 | - } |
|
346 | - if ($hide_expected_answer) { |
|
347 | - $color = ''; |
|
348 | - } |
|
345 | + } |
|
346 | + if ($hide_expected_answer) { |
|
347 | + $color = ''; |
|
348 | + } |
|
349 | 349 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
350 | - } |
|
351 | - ?> |
|
350 | + } |
|
351 | + ?> |
|
352 | 352 | </td> |
353 | 353 | <?php |
354 | - if ($ans==1) { |
|
355 | - $comm = Event::get_comments($id,$questionId); |
|
356 | - } |
|
357 | - ?> |
|
354 | + if ($ans==1) { |
|
355 | + $comm = Event::get_comments($id,$questionId); |
|
356 | + } |
|
357 | + ?> |
|
358 | 358 | <?php } else { ?> |
359 | 359 | <td> </td> |
360 | 360 | <?php } ?> |
361 | 361 | </tr> |
362 | 362 | <?php |
363 | - } |
|
363 | + } |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Display the answers to a multiple choice question |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (isset($new_options[$studentChoice])) { |
414 | 414 | echo get_lang($new_options[$studentChoice]['name']); |
415 | 415 | } else { |
416 | - echo '-'; |
|
416 | + echo '-'; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | ?> |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | <td width="5%"> |
422 | 422 | <?php |
423 | 423 | |
424 | - //Expected choice |
|
424 | + //Expected choice |
|
425 | 425 | if (!$hide_expected_answer) { |
426 | 426 | if (isset($new_options[$answerCorrect])) { |
427 | 427 | echo get_lang($new_options[$answerCorrect]['name']); |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | if ($hide_expected_answer) { |
450 | - $color = ''; |
|
451 | - } |
|
450 | + $color = ''; |
|
451 | + } |
|
452 | 452 | |
453 | 453 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
454 | 454 | } |
@@ -466,19 +466,19 @@ discard block |
||
466 | 466 | <?php |
467 | 467 | } |
468 | 468 | |
469 | - /** |
|
470 | - * Display the answers to a multiple choice question |
|
471 | - * |
|
472 | - * @param integer Answer type |
|
473 | - * @param integer Student choice |
|
474 | - * @param string Textual answer |
|
475 | - * @param string Comment on answer |
|
476 | - * @param string Correct answer comment |
|
477 | - * @param integer Exercise ID |
|
478 | - * @param integer Question ID |
|
479 | - * @param boolean Whether to show the answer comment or not |
|
480 | - * @return void |
|
481 | - */ |
|
469 | + /** |
|
470 | + * Display the answers to a multiple choice question |
|
471 | + * |
|
472 | + * @param integer Answer type |
|
473 | + * @param integer Student choice |
|
474 | + * @param string Textual answer |
|
475 | + * @param string Comment on answer |
|
476 | + * @param string Correct answer comment |
|
477 | + * @param integer Exercise ID |
|
478 | + * @param integer Question ID |
|
479 | + * @param boolean Whether to show the answer comment or not |
|
480 | + * @return void |
|
481 | + */ |
|
482 | 482 | public static function display_multiple_answer_combination_true_false( |
483 | 483 | $feedback_type, |
484 | 484 | $answerType, |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | <tr> |
510 | 510 | <td width="5%"> |
511 | 511 | <?php |
512 | - //Your choice |
|
512 | + //Your choice |
|
513 | 513 | $question = new MultipleAnswerCombinationTrueFalse(); |
514 | 514 | if (isset($question->options[$studentChoice])) { |
515 | 515 | echo $question->options[$studentChoice]; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | </td> |
521 | 521 | <td width="5%"> |
522 | 522 | <?php |
523 | - //Expected choice |
|
523 | + //Expected choice |
|
524 | 524 | if (!$hide_expected_answer) { |
525 | 525 | if (isset($question->options[$answerCorrect])) { |
526 | 526 | echo $question->options[$answerCorrect]; |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | <?php |
546 | 546 | //@todo replace this harcoded value |
547 | 547 | if ($studentChoice) { |
548 | - $color = "black"; |
|
548 | + $color = "black"; |
|
549 | 549 | if ($studentChoice == $answerCorrect) { |
550 | 550 | $color = "green"; |
551 | 551 | } |
552 | - //echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>'; |
|
552 | + //echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>'; |
|
553 | 553 | if ($hide_expected_answer) { |
554 | 554 | $color = ''; |
555 | - } |
|
555 | + } |
|
556 | 556 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
557 | 557 | } |
558 | 558 | ?> |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Set user chat status |
|
43 | - * @param int 0 if disconnected, 1 if connected |
|
44 | - * @param integer $status |
|
42 | + * Set user chat status |
|
43 | + * @param int 0 if disconnected, 1 if connected |
|
44 | + * @param integer $status |
|
45 | 45 | * |
46 | - * @return void |
|
47 | - */ |
|
46 | + * @return void |
|
47 | + */ |
|
48 | 48 | public function setUserStatus($status) |
49 | 49 | { |
50 | 50 | UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status); |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Returns an array of messages inside a chat session with a specific user |
|
152 | - * @param int The ID of the user with whom the current user is chatting |
|
153 | - * @return array Messages list |
|
154 | - */ |
|
151 | + * Returns an array of messages inside a chat session with a specific user |
|
152 | + * @param int The ID of the user with whom the current user is chatting |
|
153 | + * @return array Messages list |
|
154 | + */ |
|
155 | 155 | public function box_session($user_id) |
156 | 156 | { |
157 | 157 | $items = array(); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | - return false; |
|
302 | + return false; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | public function is_chat_blocked_by_exercises() |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | // Coach can't view this page |
21 | 21 | $extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey'); |
22 | 22 | $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( |
23 | - api_get_user_id(), |
|
24 | - api_get_course_info() |
|
23 | + api_get_user_id(), |
|
24 | + api_get_course_info() |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | if ($isDrhOfCourse) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | (api_is_course_coach() && $extend_rights_for_coachs == 'false') |
33 | 33 | ) { |
34 | 34 | api_not_allowed(true); |
35 | - exit; |
|
35 | + exit; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Database table definitions |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | |
50 | 50 | // Breadcrumbs |
51 | 51 | $interbreadcrumb[] = array( |
52 | - 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
53 | - 'name' => get_lang('SurveyList'), |
|
52 | + 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
53 | + 'name' => get_lang('SurveyList'), |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | // Getting the survey information |
57 | 57 | if (!empty($_GET['survey_id'])) { |
58 | - $course_code = api_get_course_id(); |
|
59 | - if ($course_code!=-1) { |
|
60 | - $survey_data = SurveyManager::get_survey($survey_id); |
|
61 | - } else { |
|
62 | - Display :: display_header(get_lang('ToolSurvey')); |
|
63 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
64 | - Display :: display_footer(); |
|
65 | - exit; |
|
66 | - } |
|
58 | + $course_code = api_get_course_id(); |
|
59 | + if ($course_code!=-1) { |
|
60 | + $survey_data = SurveyManager::get_survey($survey_id); |
|
61 | + } else { |
|
62 | + Display :: display_header(get_lang('ToolSurvey')); |
|
63 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
64 | + Display :: display_footer(); |
|
65 | + exit; |
|
66 | + } |
|
67 | 67 | } else { |
68 | 68 | Display :: display_header(get_lang('ToolSurvey')); |
69 | 69 | Display :: display_error_message(get_lang('NotAllowed'), false); |
@@ -76,30 +76,30 @@ discard block |
||
76 | 76 | $is_survey_type_1 = $survey_data['survey_type'] == 1; |
77 | 77 | |
78 | 78 | if (api_strlen(strip_tags($survey_data['title'])) > 40) { |
79 | - $tool_name .= '...'; |
|
79 | + $tool_name .= '...'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) { |
83 | - $_POST['name'] = trim($_POST['name']); |
|
84 | - if ($action == 'addgroup') { |
|
85 | - if (!empty($_POST['group_id'])) { |
|
86 | - Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
83 | + $_POST['name'] = trim($_POST['name']); |
|
84 | + if ($action == 'addgroup') { |
|
85 | + if (!empty($_POST['group_id'])) { |
|
86 | + Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
87 | 87 | WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\''); |
88 | - $sendmsg = 'GroupUpdatedSuccessfully'; |
|
89 | - } elseif(!empty($_POST['name'])) { |
|
90 | - Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') '); |
|
91 | - $sendmsg = 'GroupCreatedSuccessfully'; |
|
92 | - } else { |
|
93 | - $sendmsg = 'GroupNeedName'; |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - if ($action == 'deletegroup') { |
|
98 | - Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
99 | - $sendmsg = 'GroupDeletedSuccessfully'; |
|
100 | - } |
|
101 | - header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
102 | - exit; |
|
88 | + $sendmsg = 'GroupUpdatedSuccessfully'; |
|
89 | + } elseif(!empty($_POST['name'])) { |
|
90 | + Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') '); |
|
91 | + $sendmsg = 'GroupCreatedSuccessfully'; |
|
92 | + } else { |
|
93 | + $sendmsg = 'GroupNeedName'; |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + if ($action == 'deletegroup') { |
|
98 | + Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
99 | + $sendmsg = 'GroupDeletedSuccessfully'; |
|
100 | + } |
|
101 | + header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
102 | + exit; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Displaying the header |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | $message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null; |
114 | 114 | |
115 | 115 | if (isset($action)) { |
116 | - if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
117 | - SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
118 | - Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
119 | - } |
|
120 | - if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
121 | - SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
122 | - } |
|
116 | + if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
117 | + SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
118 | + Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
119 | + } |
|
120 | + if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
121 | + SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>'; |
@@ -137,26 +137,26 @@ discard block |
||
137 | 137 | echo '<div class="actions">'.$survey_actions.'</div>'; |
138 | 138 | |
139 | 139 | if ($survey_data['survey_type'] == 0) { |
140 | - echo '<div class="panel panel-default">'; |
|
140 | + echo '<div class="panel panel-default">'; |
|
141 | 141 | echo '<div class="panel-body">'; |
142 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
143 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
144 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | - echo '</div>'; |
|
142 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
143 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
144 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | + echo '</div>'; |
|
152 | 152 | echo '</div>'; |
153 | 153 | } else { |
154 | - echo '<div class="panel panel-default">'; |
|
154 | + echo '<div class="panel panel-default">'; |
|
155 | 155 | echo '<div class="panel-body">'; |
156 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
157 | - echo Display::return_icon("yesno.png"); |
|
158 | - echo '</a></div>'; |
|
159 | - echo '</div>'; |
|
156 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
157 | + echo Display::return_icon("yesno.png"); |
|
158 | + echo '</a></div>'; |
|
159 | + echo '</div>'; |
|
160 | 160 | echo '</div>'; |
161 | 161 | } |
162 | 162 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | echo ' <th width="50" >'.get_lang('NumberOfOptions').'</th>'; |
170 | 170 | echo ' <th width="100">'.get_lang('Modify').'</th>'; |
171 | 171 | if ($is_survey_type_1) { |
172 | - echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
172 | + echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
173 | 173 | echo '<th width="40">'.get_lang('Group').'</th>'; |
174 | 174 | } |
175 | 175 | echo ' </tr>'; |
@@ -196,97 +196,97 @@ discard block |
||
196 | 196 | $result = Database::query($sql); |
197 | 197 | $question_counter_max = Database::num_rows($result); |
198 | 198 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
199 | - echo '<tr>'; |
|
200 | - echo ' <td>'.$question_counter.'</td>'; |
|
201 | - echo ' <td>'; |
|
202 | - if (api_strlen($row['survey_question']) > 100) { |
|
203 | - echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
204 | - } else { |
|
205 | - echo $row['survey_question']; |
|
206 | - } |
|
207 | - |
|
208 | - if ($row['type'] == 'yesno') { |
|
209 | - $tool_name = get_lang('YesNo'); |
|
210 | - } else if ($row['type'] == 'multiplechoice') { |
|
211 | - $tool_name = get_lang('UniqueSelect'); |
|
212 | - } else { |
|
213 | - $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
214 | - } |
|
215 | - |
|
216 | - echo '</td>'; |
|
217 | - echo ' <td>'.$tool_name.'</td>'; |
|
218 | - echo ' <td>'.$row['number_of_options'].'</td>'; |
|
219 | - echo ' <td>'; |
|
220 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
221 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
222 | - if ($question_counter > 1) { |
|
223 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
224 | - } else { |
|
225 | - Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
226 | - } |
|
227 | - if ($question_counter < $question_counter_max) { |
|
228 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
229 | - } else { |
|
230 | - Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
231 | - } |
|
232 | - echo ' </td>'; |
|
233 | - $question_counter++; |
|
234 | - |
|
235 | - if ($is_survey_type_1) { |
|
236 | - echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
199 | + echo '<tr>'; |
|
200 | + echo ' <td>'.$question_counter.'</td>'; |
|
201 | + echo ' <td>'; |
|
202 | + if (api_strlen($row['survey_question']) > 100) { |
|
203 | + echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
204 | + } else { |
|
205 | + echo $row['survey_question']; |
|
206 | + } |
|
207 | + |
|
208 | + if ($row['type'] == 'yesno') { |
|
209 | + $tool_name = get_lang('YesNo'); |
|
210 | + } else if ($row['type'] == 'multiplechoice') { |
|
211 | + $tool_name = get_lang('UniqueSelect'); |
|
212 | + } else { |
|
213 | + $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
214 | + } |
|
215 | + |
|
216 | + echo '</td>'; |
|
217 | + echo ' <td>'.$tool_name.'</td>'; |
|
218 | + echo ' <td>'.$row['number_of_options'].'</td>'; |
|
219 | + echo ' <td>'; |
|
220 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
221 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
222 | + if ($question_counter > 1) { |
|
223 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
224 | + } else { |
|
225 | + Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
226 | + } |
|
227 | + if ($question_counter < $question_counter_max) { |
|
228 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
229 | + } else { |
|
230 | + Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
231 | + } |
|
232 | + echo ' </td>'; |
|
233 | + $question_counter++; |
|
234 | + |
|
235 | + if ($is_survey_type_1) { |
|
236 | + echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
237 | 237 | echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>'; |
238 | 238 | } |
239 | - echo '</tr>'; |
|
239 | + echo '</tr>'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | echo '</table>'; |
243 | 243 | |
244 | 244 | if ($is_survey_type_1) { |
245 | - echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
246 | - |
|
247 | - if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
248 | - echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
249 | - } |
|
250 | - |
|
251 | - if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
252 | - echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
253 | - } |
|
254 | - echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
255 | - echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
256 | - if ($_GET['action'] == 'editgroup') { |
|
257 | - $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
258 | - $rs = Database::query($sql); |
|
259 | - $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
260 | - echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
261 | - echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
262 | - echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
263 | - echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />'; |
|
264 | - } else { |
|
265 | - echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
266 | - echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
267 | - echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
268 | - } |
|
269 | - echo '</form><br />'; |
|
270 | - |
|
271 | - echo '<table class="data_table">'; |
|
272 | - echo ' <tr class="row_odd">'; |
|
273 | - echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
274 | - echo ' <th>'.get_lang('Description').'</th>'; |
|
275 | - echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
276 | - echo ' </tr>'; |
|
277 | - |
|
278 | - $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
279 | - |
|
280 | - $rs = Database::query($sql); |
|
281 | - while($row = Database::fetch_array($rs,ASSOC)){ |
|
282 | - $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
283 | - '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
284 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
285 | - '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'. |
|
286 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
287 | - '</td></tr>'; |
|
288 | - } |
|
289 | - echo $grouplist.'</table>'; |
|
245 | + echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
246 | + |
|
247 | + if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
248 | + echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
249 | + } |
|
250 | + |
|
251 | + if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
252 | + echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
253 | + } |
|
254 | + echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
255 | + echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
256 | + if ($_GET['action'] == 'editgroup') { |
|
257 | + $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
258 | + $rs = Database::query($sql); |
|
259 | + $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
260 | + echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
261 | + echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
262 | + echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
263 | + echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />'; |
|
264 | + } else { |
|
265 | + echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
266 | + echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
267 | + echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
268 | + } |
|
269 | + echo '</form><br />'; |
|
270 | + |
|
271 | + echo '<table class="data_table">'; |
|
272 | + echo ' <tr class="row_odd">'; |
|
273 | + echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
274 | + echo ' <th>'.get_lang('Description').'</th>'; |
|
275 | + echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
276 | + echo ' </tr>'; |
|
277 | + |
|
278 | + $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
279 | + |
|
280 | + $rs = Database::query($sql); |
|
281 | + while($row = Database::fetch_array($rs,ASSOC)){ |
|
282 | + $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
283 | + '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
284 | + Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
285 | + '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'. |
|
286 | + Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
287 | + '</td></tr>'; |
|
288 | + } |
|
289 | + echo $grouplist.'</table>'; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | Session::erase('answer_count'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // We exit here if there is no valid $_GET parameter |
45 | 45 | if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) { |
46 | 46 | api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false)); |
47 | - exit; |
|
47 | + exit; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Getting the survey information |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | |
54 | 54 | if (empty($survey_data)) { |
55 | 55 | api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false)); |
56 | - exit; |
|
56 | + exit; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $urlname = strip_tags($survey_data['title']); |
60 | 60 | if (api_is_allowed_to_edit()) { |
61 | - // Breadcrumbs |
|
62 | - $interbreadcrumb[] = array( |
|
61 | + // Breadcrumbs |
|
62 | + $interbreadcrumb[] = array( |
|
63 | 63 | 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(), |
64 | 64 | 'name' => get_lang('SurveyList') |
65 | 65 | ); |
@@ -86,57 +86,57 @@ discard block |
||
86 | 86 | $counter_question = 0; |
87 | 87 | // Only a course admin is allowed to preview a survey: you are a course admin |
88 | 88 | if (api_is_course_admin() || |
89 | - (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
90 | - api_is_allowed_to_session_edit(false, true) |
|
89 | + (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
90 | + api_is_allowed_to_session_edit(false, true) |
|
91 | 91 | ) { |
92 | - // Survey information |
|
93 | - echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
94 | - echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
92 | + // Survey information |
|
93 | + echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
94 | + echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
95 | 95 | |
96 | - // Displaying the survey introduction |
|
97 | - if (!isset($_GET['show'])) { |
|
96 | + // Displaying the survey introduction |
|
97 | + if (!isset($_GET['show'])) { |
|
98 | 98 | if (!empty($survey_data['survey_introduction'])) { |
99 | 99 | echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>'; |
100 | 100 | } |
101 | - $limit = 0; |
|
102 | - } |
|
101 | + $limit = 0; |
|
102 | + } |
|
103 | 103 | |
104 | - // Displaying the survey thanks message |
|
105 | - if (isset($_POST['finish_survey'])) { |
|
106 | - Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
104 | + // Displaying the survey thanks message |
|
105 | + if (isset($_POST['finish_survey'])) { |
|
106 | + Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
107 | 107 | echo $survey_data['survey_thanks']; |
108 | - Display :: display_footer(); |
|
109 | - exit; |
|
110 | - } |
|
108 | + Display :: display_footer(); |
|
109 | + exit; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | $questions = array(); |
113 | 113 | |
114 | - if (isset($_GET['show'])) { |
|
115 | - // Getting all the questions for this page and add them to a |
|
116 | - // multidimensional array where the first index is the page. |
|
117 | - // as long as there is no pagebreak fount we keep adding questions to the page |
|
118 | - $questions_displayed = array(); |
|
119 | - $paged_questions = array(); |
|
120 | - $counter = 0; |
|
121 | - $sql = "SELECT * FROM $table_survey_question |
|
114 | + if (isset($_GET['show'])) { |
|
115 | + // Getting all the questions for this page and add them to a |
|
116 | + // multidimensional array where the first index is the page. |
|
117 | + // as long as there is no pagebreak fount we keep adding questions to the page |
|
118 | + $questions_displayed = array(); |
|
119 | + $paged_questions = array(); |
|
120 | + $counter = 0; |
|
121 | + $sql = "SELECT * FROM $table_survey_question |
|
122 | 122 | WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."' |
123 | 123 | ORDER BY sort ASC"; |
124 | - $result = Database::query($sql); |
|
124 | + $result = Database::query($sql); |
|
125 | 125 | $questions_exists = true; |
126 | 126 | if (Database::num_rows($result)) { |
127 | - while ($row = Database::fetch_array($result)) { |
|
128 | - if ($row['type'] == 'pagebreak') { |
|
129 | - $counter++; |
|
130 | - } else { |
|
131 | - $paged_questions[$counter][] = $row['question_id']; |
|
132 | - } |
|
133 | - } |
|
127 | + while ($row = Database::fetch_array($result)) { |
|
128 | + if ($row['type'] == 'pagebreak') { |
|
129 | + $counter++; |
|
130 | + } else { |
|
131 | + $paged_questions[$counter][] = $row['question_id']; |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } else { |
135 | 135 | $questions_exists = false; |
136 | 136 | } |
137 | 137 | |
138 | - if (array_key_exists($_GET['show'], $paged_questions)) { |
|
139 | - $sql = "SELECT |
|
138 | + if (array_key_exists($_GET['show'], $paged_questions)) { |
|
139 | + $sql = "SELECT |
|
140 | 140 | survey_question.question_id, |
141 | 141 | survey_question.survey_id, |
142 | 142 | survey_question.survey_question, |
@@ -158,75 +158,75 @@ discard block |
||
158 | 158 | survey_question.c_id = $course_id |
159 | 159 | ORDER BY survey_question.sort, survey_question_option.sort ASC"; |
160 | 160 | |
161 | - $result = Database::query($sql); |
|
162 | - $question_counter_max = Database::num_rows($result); |
|
163 | - $limit = 0; |
|
164 | - while ($row = Database::fetch_array($result)) { |
|
165 | - // If the type is not a pagebreak we store it in the $questions array |
|
166 | - if ($row['type'] != 'pagebreak') { |
|
167 | - $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
168 | - $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
169 | - $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
170 | - $questions[$row['sort']]['display'] = $row['display']; |
|
171 | - $questions[$row['sort']]['type'] = $row['type']; |
|
172 | - $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
173 | - $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
174 | - } else { |
|
175 | - // If the type is a pagebreak we are finished loading the questions for this page |
|
176 | - break; |
|
177 | - } |
|
178 | - $counter_question++; |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - // Selecting the maximum number of pages |
|
184 | - $sql = "SELECT * FROM $table_survey_question |
|
161 | + $result = Database::query($sql); |
|
162 | + $question_counter_max = Database::num_rows($result); |
|
163 | + $limit = 0; |
|
164 | + while ($row = Database::fetch_array($result)) { |
|
165 | + // If the type is not a pagebreak we store it in the $questions array |
|
166 | + if ($row['type'] != 'pagebreak') { |
|
167 | + $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
168 | + $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
169 | + $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
170 | + $questions[$row['sort']]['display'] = $row['display']; |
|
171 | + $questions[$row['sort']]['type'] = $row['type']; |
|
172 | + $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
173 | + $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
174 | + } else { |
|
175 | + // If the type is a pagebreak we are finished loading the questions for this page |
|
176 | + break; |
|
177 | + } |
|
178 | + $counter_question++; |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + // Selecting the maximum number of pages |
|
184 | + $sql = "SELECT * FROM $table_survey_question |
|
185 | 185 | WHERE |
186 | 186 | c_id = $course_id AND |
187 | 187 | type='".Database::escape_string('pagebreak')."' AND |
188 | 188 | survey_id='".intval($survey_id)."'"; |
189 | - $result = Database::query($sql); |
|
190 | - $numberofpages = Database::num_rows($result) + 1; |
|
191 | - |
|
192 | - // Displaying the form with the questions |
|
193 | - if (isset($_GET['show'])) { |
|
194 | - $show = (int)$_GET['show'] + 1; |
|
195 | - } else { |
|
196 | - $show = 0; |
|
197 | - } |
|
198 | - |
|
199 | - $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
200 | - $form = new FormValidator('question', 'post', $url); |
|
201 | - |
|
202 | - if (is_array($questions) && count($questions) > 0) { |
|
203 | - foreach ($questions as $key => & $question) { |
|
204 | - $ch_type = 'ch_'.$question['type']; |
|
205 | - /** @var survey_question $display */ |
|
206 | - $display = new $ch_type; |
|
207 | - $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
208 | - $form->addHtml($question['survey_question']); |
|
209 | - $display->render($form, $question); |
|
210 | - $form->addHtml('</div></div>'); |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
189 | + $result = Database::query($sql); |
|
190 | + $numberofpages = Database::num_rows($result) + 1; |
|
191 | + |
|
192 | + // Displaying the form with the questions |
|
193 | + if (isset($_GET['show'])) { |
|
194 | + $show = (int)$_GET['show'] + 1; |
|
195 | + } else { |
|
196 | + $show = 0; |
|
197 | + } |
|
198 | + |
|
199 | + $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
200 | + $form = new FormValidator('question', 'post', $url); |
|
201 | + |
|
202 | + if (is_array($questions) && count($questions) > 0) { |
|
203 | + foreach ($questions as $key => & $question) { |
|
204 | + $ch_type = 'ch_'.$question['type']; |
|
205 | + /** @var survey_question $display */ |
|
206 | + $display = new $ch_type; |
|
207 | + $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
208 | + $form->addHtml($question['survey_question']); |
|
209 | + $display->render($form, $question); |
|
210 | + $form->addHtml('</div></div>'); |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
215 | 215 | if ($show == 0) { |
216 | - $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
216 | + $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
217 | 217 | } else { |
218 | - $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
218 | + $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
219 | 219 | } |
220 | - } |
|
221 | - if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
222 | - if ($questions_exists == false) { |
|
223 | - echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
224 | - } |
|
225 | - $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
226 | - } |
|
227 | - $form->display(); |
|
220 | + } |
|
221 | + if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
222 | + if ($questions_exists == false) { |
|
223 | + echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
224 | + } |
|
225 | + $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
226 | + } |
|
227 | + $form->display(); |
|
228 | 228 | } else { |
229 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
229 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | Display :: display_footer(); |
@@ -94,12 +94,12 @@ |
||
94 | 94 | */ |
95 | 95 | protected $assignedLastUser; |
96 | 96 | |
97 | - /** |
|
98 | - * @var Status |
|
99 | - * |
|
100 | - * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status") |
|
101 | - * @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
|
102 | - **/ |
|
97 | + /** |
|
98 | + * @var Status |
|
99 | + * |
|
100 | + * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status") |
|
101 | + * @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
|
102 | + **/ |
|
103 | 103 | protected $status; |
104 | 104 | |
105 | 105 | /** |
@@ -56,7 +56,7 @@ |
||
56 | 56 | */ |
57 | 57 | protected $filename; |
58 | 58 | |
59 | - /** |
|
59 | + /** |
|
60 | 60 | * @var integer |
61 | 61 | * |
62 | 62 | * @ORM\Column(name="size", type="integer", nullable=false, unique=false) |