@@ -8,102 +8,102 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class StudentPublicationLink extends AbstractLink |
10 | 10 | { |
11 | - private $studpub_table = null; |
|
12 | - private $itemprop_table = null; |
|
13 | - |
|
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * Returns the URL of a document |
|
26 | - * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | - * see issue #2705 |
|
28 | - * |
|
29 | - */ |
|
30 | - public function get_view_url($stud_id) |
|
31 | - { |
|
32 | - // find a file uploaded by the given student, |
|
33 | - // with the same title as the evaluation name |
|
34 | - |
|
35 | - $eval = $this->get_evaluation(); |
|
36 | - $stud_id = intval($stud_id); |
|
37 | - |
|
38 | - $sql = 'SELECT pub.url |
|
11 | + private $studpub_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | + |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * Returns the URL of a document |
|
26 | + * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | + * see issue #2705 |
|
28 | + * |
|
29 | + */ |
|
30 | + public function get_view_url($stud_id) |
|
31 | + { |
|
32 | + // find a file uploaded by the given student, |
|
33 | + // with the same title as the evaluation name |
|
34 | + |
|
35 | + $eval = $this->get_evaluation(); |
|
36 | + $stud_id = intval($stud_id); |
|
37 | + |
|
38 | + $sql = 'SELECT pub.url |
|
39 | 39 | FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' |
40 | - ." WHERE |
|
40 | + ." WHERE |
|
41 | 41 | prop.c_id = ".$this->course_id." AND |
42 | 42 | pub.c_id = ".$this->course_id." AND |
43 | 43 | prop.tool = 'work'" |
44 | - .' AND prop.insert_user_id = '.$stud_id |
|
45 | - .' AND prop.ref = pub.id' |
|
46 | - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | - |
|
48 | - $result = Database::query($sql); |
|
49 | - if ($fileurl = Database::fetch_row($result)) { |
|
50 | - return null; |
|
51 | - } else { |
|
52 | - return null; |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - public function get_type_name() |
|
57 | - { |
|
58 | - return get_lang('Works'); |
|
59 | - } |
|
60 | - |
|
61 | - public function is_allowed_to_change_name() |
|
62 | - { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | - */ |
|
70 | - public function get_not_created_links() |
|
71 | - { |
|
72 | - return false; |
|
73 | - if (empty($this->course_code)) { |
|
74 | - die('Error in get_not_created_links() : course code not set'); |
|
75 | - } |
|
76 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | - |
|
78 | - $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | - .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | - .') AND pub.session_id='.api_get_session_id().''; |
|
84 | - |
|
85 | - $result = Database::query($sql); |
|
86 | - |
|
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
90 | - } |
|
91 | - return $cats; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generate an array of all exercises available. |
|
96 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | - */ |
|
98 | - public function get_all_links() |
|
99 | - { |
|
100 | - if (empty($this->course_code)) { |
|
101 | - die('Error in get_not_created_links() : course code not set'); |
|
102 | - } |
|
103 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | - |
|
105 | - $session_id = api_get_session_id(); |
|
106 | - /* |
|
44 | + .' AND prop.insert_user_id = '.$stud_id |
|
45 | + .' AND prop.ref = pub.id' |
|
46 | + ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | + |
|
48 | + $result = Database::query($sql); |
|
49 | + if ($fileurl = Database::fetch_row($result)) { |
|
50 | + return null; |
|
51 | + } else { |
|
52 | + return null; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + public function get_type_name() |
|
57 | + { |
|
58 | + return get_lang('Works'); |
|
59 | + } |
|
60 | + |
|
61 | + public function is_allowed_to_change_name() |
|
62 | + { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | + */ |
|
70 | + public function get_not_created_links() |
|
71 | + { |
|
72 | + return false; |
|
73 | + if (empty($this->course_code)) { |
|
74 | + die('Error in get_not_created_links() : course code not set'); |
|
75 | + } |
|
76 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | + |
|
78 | + $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | + .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | + .') AND pub.session_id='.api_get_session_id().''; |
|
84 | + |
|
85 | + $result = Database::query($sql); |
|
86 | + |
|
87 | + $cats=array(); |
|
88 | + while ($data=Database::fetch_array($result)) { |
|
89 | + $cats[] = array ($data['id'], $data['url']); |
|
90 | + } |
|
91 | + return $cats; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generate an array of all exercises available. |
|
96 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | + */ |
|
98 | + public function get_all_links() |
|
99 | + { |
|
100 | + if (empty($this->course_code)) { |
|
101 | + die('Error in get_not_created_links() : course code not set'); |
|
102 | + } |
|
103 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | + |
|
105 | + $session_id = api_get_session_id(); |
|
106 | + /* |
|
107 | 107 | if (empty($session_id)) { |
108 | 108 | $session_condition = api_get_session_condition(0, true); |
109 | 109 | } else { |
@@ -112,68 +112,68 @@ discard block |
||
112 | 112 | $sql = "SELECT id, url, title FROM $tbl_grade_links |
113 | 113 | WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ |
114 | 114 | |
115 | - //Only show works from the session |
|
116 | - //AND has_properties != '' |
|
117 | - $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
115 | + //Only show works from the session |
|
116 | + //AND has_properties != '' |
|
117 | + $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
118 | 118 | WHERE |
119 | 119 | c_id = {$this->course_id} AND |
120 | 120 | active = 1 AND |
121 | 121 | filetype='folder' AND |
122 | 122 | session_id = ".api_get_session_id().""; |
123 | 123 | |
124 | - $result = Database::query($sql); |
|
125 | - while ($data = Database::fetch_array($result)) { |
|
126 | - $work_name = $data['title']; |
|
127 | - if (empty($work_name)) { |
|
128 | - $work_name = basename($data['url']); |
|
129 | - } |
|
130 | - $cats[] = array ($data['id'], $work_name); |
|
131 | - } |
|
132 | - $cats=isset($cats) ? $cats : array(); |
|
133 | - return $cats; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Has anyone done this exercise yet ? |
|
138 | - */ |
|
139 | - public function has_results() |
|
140 | - { |
|
141 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
124 | + $result = Database::query($sql); |
|
125 | + while ($data = Database::fetch_array($result)) { |
|
126 | + $work_name = $data['title']; |
|
127 | + if (empty($work_name)) { |
|
128 | + $work_name = basename($data['url']); |
|
129 | + } |
|
130 | + $cats[] = array ($data['id'], $work_name); |
|
131 | + } |
|
132 | + $cats=isset($cats) ? $cats : array(); |
|
133 | + return $cats; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Has anyone done this exercise yet ? |
|
138 | + */ |
|
139 | + public function has_results() |
|
140 | + { |
|
141 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
143 | 143 | WHERE c_id = {$this->course_id} AND |
144 | 144 | parent_id = '".intval($this->get_ref_id())."' AND |
145 | 145 | session_id =".api_get_session_id().""; |
146 | - $result = Database::query($sql); |
|
147 | - $number = Database::fetch_row($result); |
|
148 | - return ($number[0] != 0); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @param null $stud_id |
|
153 | - * @return array|null |
|
154 | - */ |
|
155 | - public function calc_score($stud_id = null, $type = null) |
|
156 | - { |
|
157 | - $stud_id = intval($stud_id); |
|
158 | - $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | - $sql = 'SELECT * FROM '.$table." |
|
146 | + $result = Database::query($sql); |
|
147 | + $number = Database::fetch_row($result); |
|
148 | + return ($number[0] != 0); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @param null $stud_id |
|
153 | + * @return array|null |
|
154 | + */ |
|
155 | + public function calc_score($stud_id = null, $type = null) |
|
156 | + { |
|
157 | + $stud_id = intval($stud_id); |
|
158 | + $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | + $sql = 'SELECT * FROM '.$table." |
|
160 | 160 | WHERE |
161 | 161 | c_id = {$this->course_id} AND |
162 | 162 | id = '".intval($this->get_ref_id())."' AND |
163 | 163 | session_id = ".api_get_session_id()." |
164 | 164 | " |
165 | - ; |
|
165 | + ; |
|
166 | 166 | |
167 | - $query = Database::query($sql); |
|
168 | - $assignment = Database::fetch_array($query); |
|
167 | + $query = Database::query($sql); |
|
168 | + $assignment = Database::fetch_array($query); |
|
169 | 169 | |
170 | - if (count($assignment) == 0) { |
|
171 | - $parentId = '0'; |
|
172 | - } else { |
|
173 | - $parentId = $assignment['id']; |
|
174 | - } |
|
170 | + if (count($assignment) == 0) { |
|
171 | + $parentId = '0'; |
|
172 | + } else { |
|
173 | + $parentId = $assignment['id']; |
|
174 | + } |
|
175 | 175 | |
176 | - $sql = 'SELECT * FROM '.$table.' |
|
176 | + $sql = 'SELECT * FROM '.$table.' |
|
177 | 177 | WHERE |
178 | 178 | c_id = '.$this->course_id.' AND |
179 | 179 | active = 1 AND |
@@ -181,191 +181,191 @@ discard block |
||
181 | 181 | session_id = '.api_get_session_id() .' AND |
182 | 182 | qualificator_id <> 0 |
183 | 183 | '; |
184 | - if (!empty($stud_id)) { |
|
185 | - $sql .= " AND user_id = $stud_id "; |
|
186 | - } |
|
187 | - |
|
188 | - $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | - |
|
190 | - switch ($order) { |
|
191 | - case 'last': |
|
192 | - // latest attempt |
|
193 | - $sql .= ' ORDER BY sent_date DESC'; |
|
194 | - break; |
|
195 | - case 'first': |
|
196 | - default: |
|
197 | - // first attempt |
|
198 | - $sql .= ' ORDER BY id'; |
|
199 | - break; |
|
200 | - } |
|
201 | - |
|
202 | - $scores = Database::query($sql); |
|
203 | - |
|
204 | - // for 1 student |
|
205 | - if (!empty($stud_id)) { |
|
206 | - if ($data = Database::fetch_array($scores)) { |
|
207 | - return array( |
|
208 | - $data['qualification'], |
|
209 | - $assignment['qualification'] |
|
210 | - ); |
|
211 | - } else { |
|
212 | - return ''; |
|
213 | - } |
|
214 | - } else { |
|
215 | - $students = array(); // user list, needed to make sure we only |
|
216 | - // take first attempts into account |
|
217 | - $rescount = 0; |
|
218 | - $sum = 0; |
|
219 | - $bestResult = 0; |
|
220 | - $weight = 0; |
|
221 | - $sumResult = 0; |
|
222 | - $myResult = 0; |
|
223 | - |
|
224 | - while ($data = Database::fetch_array($scores)) { |
|
225 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | - if ($assignment['qualification'] != 0) { |
|
227 | - $students[$data['user_id']] = $data['qualification']; |
|
228 | - $rescount++; |
|
229 | - $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | - $sumResult += $data['qualification']; |
|
231 | - |
|
232 | - if ($data['qualification'] > $bestResult) { |
|
233 | - $bestResult = $data['qualification']; |
|
234 | - } |
|
235 | - $weight = $assignment['qualification']; |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - if ($rescount == 0) { |
|
241 | - return null; |
|
242 | - } else { |
|
243 | - switch ($type) { |
|
244 | - case 'best': |
|
245 | - return array($bestResult, $weight); |
|
246 | - break; |
|
247 | - case 'average': |
|
248 | - return array($sumResult/$rescount, $weight); |
|
249 | - break; |
|
250 | - case 'ranking': |
|
251 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | - break; |
|
253 | - default: |
|
254 | - return array($sum, $rescount); |
|
255 | - break; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Lazy load function to get the database table of the student publications |
|
263 | - */ |
|
264 | - private function get_studpub_table() |
|
265 | - { |
|
266 | - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Lazy load function to get the database table of the item properties |
|
271 | - */ |
|
272 | - private function get_itemprop_table() |
|
273 | - { |
|
274 | - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | - } |
|
276 | - |
|
277 | - public function needs_name_and_description() |
|
278 | - { |
|
279 | - return false; |
|
280 | - } |
|
281 | - |
|
282 | - public function get_name() |
|
283 | - { |
|
284 | - $this->get_exercise_data(); |
|
285 | - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | - } |
|
287 | - |
|
288 | - public function get_description() |
|
289 | - { |
|
290 | - $this->get_exercise_data(); |
|
291 | - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | - } |
|
293 | - |
|
294 | - public function get_test_id() |
|
295 | - { |
|
296 | - return 'DEBUG:ID'; |
|
297 | - } |
|
298 | - |
|
299 | - public function get_link() |
|
300 | - { |
|
301 | - $session_id = api_get_session_id(); |
|
302 | - $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | - |
|
304 | - return $url; |
|
305 | - } |
|
306 | - |
|
307 | - private function get_exercise_data() |
|
308 | - { |
|
309 | - $tbl_name = $this->get_studpub_table(); |
|
310 | - $course_info = api_get_course_info($this->get_course_code()); |
|
311 | - if ($tbl_name=='') { |
|
312 | - return false; |
|
313 | - } elseif (!isset($this->exercise_data)) { |
|
314 | - $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
184 | + if (!empty($stud_id)) { |
|
185 | + $sql .= " AND user_id = $stud_id "; |
|
186 | + } |
|
187 | + |
|
188 | + $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | + |
|
190 | + switch ($order) { |
|
191 | + case 'last': |
|
192 | + // latest attempt |
|
193 | + $sql .= ' ORDER BY sent_date DESC'; |
|
194 | + break; |
|
195 | + case 'first': |
|
196 | + default: |
|
197 | + // first attempt |
|
198 | + $sql .= ' ORDER BY id'; |
|
199 | + break; |
|
200 | + } |
|
201 | + |
|
202 | + $scores = Database::query($sql); |
|
203 | + |
|
204 | + // for 1 student |
|
205 | + if (!empty($stud_id)) { |
|
206 | + if ($data = Database::fetch_array($scores)) { |
|
207 | + return array( |
|
208 | + $data['qualification'], |
|
209 | + $assignment['qualification'] |
|
210 | + ); |
|
211 | + } else { |
|
212 | + return ''; |
|
213 | + } |
|
214 | + } else { |
|
215 | + $students = array(); // user list, needed to make sure we only |
|
216 | + // take first attempts into account |
|
217 | + $rescount = 0; |
|
218 | + $sum = 0; |
|
219 | + $bestResult = 0; |
|
220 | + $weight = 0; |
|
221 | + $sumResult = 0; |
|
222 | + $myResult = 0; |
|
223 | + |
|
224 | + while ($data = Database::fetch_array($scores)) { |
|
225 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | + if ($assignment['qualification'] != 0) { |
|
227 | + $students[$data['user_id']] = $data['qualification']; |
|
228 | + $rescount++; |
|
229 | + $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | + $sumResult += $data['qualification']; |
|
231 | + |
|
232 | + if ($data['qualification'] > $bestResult) { |
|
233 | + $bestResult = $data['qualification']; |
|
234 | + } |
|
235 | + $weight = $assignment['qualification']; |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + if ($rescount == 0) { |
|
241 | + return null; |
|
242 | + } else { |
|
243 | + switch ($type) { |
|
244 | + case 'best': |
|
245 | + return array($bestResult, $weight); |
|
246 | + break; |
|
247 | + case 'average': |
|
248 | + return array($sumResult/$rescount, $weight); |
|
249 | + break; |
|
250 | + case 'ranking': |
|
251 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | + break; |
|
253 | + default: |
|
254 | + return array($sum, $rescount); |
|
255 | + break; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Lazy load function to get the database table of the student publications |
|
263 | + */ |
|
264 | + private function get_studpub_table() |
|
265 | + { |
|
266 | + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Lazy load function to get the database table of the item properties |
|
271 | + */ |
|
272 | + private function get_itemprop_table() |
|
273 | + { |
|
274 | + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | + } |
|
276 | + |
|
277 | + public function needs_name_and_description() |
|
278 | + { |
|
279 | + return false; |
|
280 | + } |
|
281 | + |
|
282 | + public function get_name() |
|
283 | + { |
|
284 | + $this->get_exercise_data(); |
|
285 | + return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | + } |
|
287 | + |
|
288 | + public function get_description() |
|
289 | + { |
|
290 | + $this->get_exercise_data(); |
|
291 | + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | + } |
|
293 | + |
|
294 | + public function get_test_id() |
|
295 | + { |
|
296 | + return 'DEBUG:ID'; |
|
297 | + } |
|
298 | + |
|
299 | + public function get_link() |
|
300 | + { |
|
301 | + $session_id = api_get_session_id(); |
|
302 | + $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | + |
|
304 | + return $url; |
|
305 | + } |
|
306 | + |
|
307 | + private function get_exercise_data() |
|
308 | + { |
|
309 | + $tbl_name = $this->get_studpub_table(); |
|
310 | + $course_info = api_get_course_info($this->get_course_code()); |
|
311 | + if ($tbl_name=='') { |
|
312 | + return false; |
|
313 | + } elseif (!isset($this->exercise_data)) { |
|
314 | + $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
315 | 315 | WHERE |
316 | 316 | c_id ='".$course_info['real_id']."' AND |
317 | 317 | id = '".intval($this->get_ref_id())."' "; |
318 | - $query = Database::query($sql); |
|
319 | - $this->exercise_data = Database::fetch_array($query); |
|
320 | - } |
|
321 | - return $this->exercise_data; |
|
322 | - } |
|
323 | - |
|
324 | - public function needs_max() |
|
325 | - { |
|
326 | - return false; |
|
327 | - } |
|
328 | - |
|
329 | - public function needs_results() |
|
330 | - { |
|
331 | - return false; |
|
332 | - } |
|
333 | - |
|
334 | - public function is_valid_link() |
|
335 | - { |
|
336 | - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
318 | + $query = Database::query($sql); |
|
319 | + $this->exercise_data = Database::fetch_array($query); |
|
320 | + } |
|
321 | + return $this->exercise_data; |
|
322 | + } |
|
323 | + |
|
324 | + public function needs_max() |
|
325 | + { |
|
326 | + return false; |
|
327 | + } |
|
328 | + |
|
329 | + public function needs_results() |
|
330 | + { |
|
331 | + return false; |
|
332 | + } |
|
333 | + |
|
334 | + public function is_valid_link() |
|
335 | + { |
|
336 | + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
337 | 337 | WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; |
338 | - $result = Database::query($sql); |
|
339 | - $number = Database::fetch_row($result); |
|
340 | - return ($number[0] != 0); |
|
341 | - } |
|
342 | - |
|
343 | - public function get_icon_name() |
|
344 | - { |
|
345 | - return 'studentpublication'; |
|
346 | - } |
|
347 | - |
|
348 | - public function save_linked_data() |
|
349 | - { |
|
350 | - $weight = (float)$this->get_weight(); |
|
351 | - $ref_id = $this->get_ref_id(); |
|
352 | - |
|
353 | - if (!empty($ref_id)) { |
|
354 | - //Cleans works |
|
355 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
338 | + $result = Database::query($sql); |
|
339 | + $number = Database::fetch_row($result); |
|
340 | + return ($number[0] != 0); |
|
341 | + } |
|
342 | + |
|
343 | + public function get_icon_name() |
|
344 | + { |
|
345 | + return 'studentpublication'; |
|
346 | + } |
|
347 | + |
|
348 | + public function save_linked_data() |
|
349 | + { |
|
350 | + $weight = (float)$this->get_weight(); |
|
351 | + $ref_id = $this->get_ref_id(); |
|
352 | + |
|
353 | + if (!empty($ref_id)) { |
|
354 | + //Cleans works |
|
355 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
356 | 356 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
357 | - Database::query($sql); |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - public function delete_linked_data() |
|
362 | - { |
|
363 | - $ref_id = $this->get_ref_id(); |
|
364 | - if (!empty($ref_id)) { |
|
365 | - //Cleans works |
|
366 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
357 | + Database::query($sql); |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + public function delete_linked_data() |
|
362 | + { |
|
363 | + $ref_id = $this->get_ref_id(); |
|
364 | + if (!empty($ref_id)) { |
|
365 | + //Cleans works |
|
366 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
367 | 367 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
368 | - Database::query($sql); |
|
369 | - } |
|
370 | - } |
|
368 | + Database::query($sql); |
|
369 | + } |
|
370 | + } |
|
371 | 371 | } |
@@ -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'), |
@@ -9,70 +9,70 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class WSCMError |
11 | 11 | { |
12 | - /** |
|
13 | - * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
14 | - * |
|
15 | - * @var WSErrorHandler |
|
16 | - */ |
|
17 | - protected static $_handler; |
|
12 | + /** |
|
13 | + * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
14 | + * |
|
15 | + * @var WSErrorHandler |
|
16 | + */ |
|
17 | + protected static $_handler; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Error code |
|
21 | - * |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - public $code; |
|
19 | + /** |
|
20 | + * Error code |
|
21 | + * |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + public $code; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Error message |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $message; |
|
26 | + /** |
|
27 | + * Error message |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $message; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param int Error code |
|
37 | - * @param string Error message |
|
38 | - */ |
|
39 | - public function __construct($code, $message) |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param int Error code |
|
37 | + * @param string Error message |
|
38 | + */ |
|
39 | + public function __construct($code, $message) |
|
40 | 40 | { |
41 | - $this->code = $code; |
|
42 | - $this->message = $message; |
|
43 | - } |
|
41 | + $this->code = $code; |
|
42 | + $this->message = $message; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Sets the error handler |
|
47 | - * |
|
48 | - * @param WSErrorHandler Error handler |
|
49 | - */ |
|
50 | - public static function setErrorHandler($handler) |
|
45 | + /** |
|
46 | + * Sets the error handler |
|
47 | + * |
|
48 | + * @param WSErrorHandler Error handler |
|
49 | + */ |
|
50 | + public static function setErrorHandler($handler) |
|
51 | 51 | { |
52 | - if($handler instanceof WSErrorHandler) { |
|
53 | - self::$_handler = $handler; |
|
54 | - } |
|
55 | - } |
|
52 | + if($handler instanceof WSErrorHandler) { |
|
53 | + self::$_handler = $handler; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Returns the error handler |
|
59 | - * |
|
60 | - * @return WSErrorHandler Error handler |
|
61 | - */ |
|
62 | - public static function getErrorHandler() |
|
57 | + /** |
|
58 | + * Returns the error handler |
|
59 | + * |
|
60 | + * @return WSErrorHandler Error handler |
|
61 | + */ |
|
62 | + public static function getErrorHandler() |
|
63 | 63 | { |
64 | - return self::$_handler; |
|
65 | - } |
|
64 | + return self::$_handler; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Transforms the error into an array |
|
69 | - * |
|
70 | - * @return array Associative array with code and message |
|
71 | - */ |
|
72 | - public function toArray() |
|
67 | + /** |
|
68 | + * Transforms the error into an array |
|
69 | + * |
|
70 | + * @return array Associative array with code and message |
|
71 | + */ |
|
72 | + public function toArray() |
|
73 | 73 | { |
74 | - return array('code' => $this->code, 'message' => $this->message); |
|
75 | - } |
|
74 | + return array('code' => $this->code, 'message' => $this->message); |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | */ |
81 | 81 | interface WSCMErrorHandler |
82 | 82 | { |
83 | - /** |
|
84 | - * Handle method |
|
85 | - * |
|
86 | - * @param WSError Error |
|
87 | - */ |
|
88 | - public function handle($error); |
|
83 | + /** |
|
84 | + * Handle method |
|
85 | + * |
|
86 | + * @param WSError Error |
|
87 | + */ |
|
88 | + public function handle($error); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,58 +93,58 @@ discard block |
||
93 | 93 | */ |
94 | 94 | class WSCM |
95 | 95 | { |
96 | - /** |
|
97 | - * Chamilo configuration |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - protected $_configuration; |
|
96 | + /** |
|
97 | + * Chamilo configuration |
|
98 | + * |
|
99 | + * @var array |
|
100 | + */ |
|
101 | + protected $_configuration; |
|
102 | 102 | |
103 | - /** |
|
104 | - * Constructor |
|
105 | - */ |
|
106 | - public function __construct() |
|
103 | + /** |
|
104 | + * Constructor |
|
105 | + */ |
|
106 | + public function __construct() |
|
107 | 107 | { |
108 | - $this->_configuration = $GLOBALS['_configuration']; |
|
109 | - } |
|
108 | + $this->_configuration = $GLOBALS['_configuration']; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Verifies the API key |
|
113 | - * |
|
114 | - * @param string Secret key |
|
115 | - * @return mixed WSError in case of failure, null in case of success |
|
116 | - */ |
|
117 | - protected function verifyKey($secret_key) |
|
111 | + /** |
|
112 | + * Verifies the API key |
|
113 | + * |
|
114 | + * @param string Secret key |
|
115 | + * @return mixed WSError in case of failure, null in case of success |
|
116 | + */ |
|
117 | + protected function verifyKey($secret_key) |
|
118 | 118 | { |
119 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
120 | - // if we are behind a reverse proxy, assume it will send the |
|
121 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
122 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
123 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
124 | - $ip = trim($ip1); |
|
125 | - } |
|
126 | - $security_key = $ip.$this->_configuration['security_key']; |
|
119 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
120 | + // if we are behind a reverse proxy, assume it will send the |
|
121 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
122 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
123 | + list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
124 | + $ip = trim($ip1); |
|
125 | + } |
|
126 | + $security_key = $ip.$this->_configuration['security_key']; |
|
127 | 127 | |
128 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
129 | - return new WSCMError(1, "API key is invalid"); |
|
130 | - } else { |
|
131 | - return null; |
|
132 | - } |
|
133 | - } |
|
128 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
129 | + return new WSCMError(1, "API key is invalid"); |
|
130 | + } else { |
|
131 | + return null; |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Verifies if the user is valid |
|
137 | - * |
|
138 | - * @param <String> $username of the user in chamilo |
|
139 | - * @param <String> $pass of the same user (in MD5 of SHA) |
|
140 | - * |
|
141 | - * return "valid" if username e password are correct! Else, return a message error |
|
142 | - */ |
|
135 | + /** |
|
136 | + * Verifies if the user is valid |
|
137 | + * |
|
138 | + * @param <String> $username of the user in chamilo |
|
139 | + * @param <String> $pass of the same user (in MD5 of SHA) |
|
140 | + * |
|
141 | + * return "valid" if username e password are correct! Else, return a message error |
|
142 | + */ |
|
143 | 143 | |
144 | - public function verifyUserPass($username, $pass) |
|
144 | + public function verifyUserPass($username, $pass) |
|
145 | 145 | { |
146 | - $login = $username; |
|
147 | - $password = $pass; |
|
146 | + $login = $username; |
|
147 | + $password = $pass; |
|
148 | 148 | |
149 | 149 | //lookup the user in the main database |
150 | 150 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
@@ -182,132 +182,132 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | return get_lang('InvalidId'); |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Gets the real user id based on the user id field name and value. |
|
189 | - * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
190 | - * in the system database |
|
191 | - * |
|
192 | - * @param string User id field name |
|
193 | - * @param string User id value |
|
194 | - * @return mixed System user id if the user was found, WSError otherwise |
|
195 | - */ |
|
196 | - protected function getUserId($user_id_field_name, $user_id_value) |
|
187 | + /** |
|
188 | + * Gets the real user id based on the user id field name and value. |
|
189 | + * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
190 | + * in the system database |
|
191 | + * |
|
192 | + * @param string User id field name |
|
193 | + * @param string User id value |
|
194 | + * @return mixed System user id if the user was found, WSError otherwise |
|
195 | + */ |
|
196 | + protected function getUserId($user_id_field_name, $user_id_value) |
|
197 | 197 | { |
198 | - if($user_id_field_name == "chamilo_user_id") { |
|
199 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
200 | - return intval($user_id_value); |
|
201 | - } else { |
|
202 | - return new WSCMError(100, "User not found"); |
|
203 | - } |
|
204 | - } else { |
|
205 | - $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
206 | - if($user_id == 0) { |
|
207 | - return new WSCMError(100, "User not found"); |
|
208 | - } else { |
|
209 | - return $user_id; |
|
210 | - } |
|
211 | - } |
|
212 | - } |
|
198 | + if($user_id_field_name == "chamilo_user_id") { |
|
199 | + if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
200 | + return intval($user_id_value); |
|
201 | + } else { |
|
202 | + return new WSCMError(100, "User not found"); |
|
203 | + } |
|
204 | + } else { |
|
205 | + $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
206 | + if($user_id == 0) { |
|
207 | + return new WSCMError(100, "User not found"); |
|
208 | + } else { |
|
209 | + return $user_id; |
|
210 | + } |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Gets the real course id based on the course id field name and value. |
|
216 | - * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
217 | - * in the system database |
|
218 | - * |
|
219 | - * @param string Course id field name |
|
220 | - * @param string Course id value |
|
221 | - * @return mixed System course id if the course was found, WSError otherwise |
|
222 | - */ |
|
223 | - protected function getCourseId($course_id_field_name, $course_id_value) |
|
214 | + /** |
|
215 | + * Gets the real course id based on the course id field name and value. |
|
216 | + * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
217 | + * in the system database |
|
218 | + * |
|
219 | + * @param string Course id field name |
|
220 | + * @param string Course id value |
|
221 | + * @return mixed System course id if the course was found, WSError otherwise |
|
222 | + */ |
|
223 | + protected function getCourseId($course_id_field_name, $course_id_value) |
|
224 | 224 | { |
225 | - if($course_id_field_name == "chamilo_course_id") { |
|
226 | - if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
227 | - return intval($course_id_value); |
|
228 | - } else { |
|
229 | - return new WSCMError(200, "Course not found"); |
|
230 | - } |
|
231 | - } else { |
|
232 | - $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
233 | - if (empty($courseId)) { |
|
234 | - return new WSCMError(200, "Course not found"); |
|
235 | - } else { |
|
236 | - return $courseId; |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
225 | + if($course_id_field_name == "chamilo_course_id") { |
|
226 | + if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
227 | + return intval($course_id_value); |
|
228 | + } else { |
|
229 | + return new WSCMError(200, "Course not found"); |
|
230 | + } |
|
231 | + } else { |
|
232 | + $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
233 | + if (empty($courseId)) { |
|
234 | + return new WSCMError(200, "Course not found"); |
|
235 | + } else { |
|
236 | + return $courseId; |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Gets the real session id based on the session id field name and value. |
|
243 | - * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
244 | - * in the system database |
|
245 | - * |
|
246 | - * @param string Session id field name |
|
247 | - * @param string Session id value |
|
248 | - * @return mixed System session id if the session was found, WSError otherwise |
|
249 | - */ |
|
250 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
251 | - { |
|
252 | - if ($session_id_field_name == "chamilo_session_id") { |
|
253 | - $session = SessionManager::fetch((int)$session_id_value); |
|
254 | - if(!empty($session)) { |
|
255 | - return intval($session_id_value); |
|
256 | - } else { |
|
257 | - return new WSCMError(300, "Session not found"); |
|
258 | - } |
|
259 | - } else { |
|
260 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
261 | - $session_id_value, |
|
262 | - $session_id_field_name |
|
263 | - ); |
|
264 | - if($session_id == 0) { |
|
265 | - return new WSCMError(300, "Session not found"); |
|
266 | - } else { |
|
267 | - return $session_id; |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
241 | + /** |
|
242 | + * Gets the real session id based on the session id field name and value. |
|
243 | + * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
244 | + * in the system database |
|
245 | + * |
|
246 | + * @param string Session id field name |
|
247 | + * @param string Session id value |
|
248 | + * @return mixed System session id if the session was found, WSError otherwise |
|
249 | + */ |
|
250 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
251 | + { |
|
252 | + if ($session_id_field_name == "chamilo_session_id") { |
|
253 | + $session = SessionManager::fetch((int)$session_id_value); |
|
254 | + if(!empty($session)) { |
|
255 | + return intval($session_id_value); |
|
256 | + } else { |
|
257 | + return new WSCMError(300, "Session not found"); |
|
258 | + } |
|
259 | + } else { |
|
260 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
261 | + $session_id_value, |
|
262 | + $session_id_field_name |
|
263 | + ); |
|
264 | + if($session_id == 0) { |
|
265 | + return new WSCMError(300, "Session not found"); |
|
266 | + } else { |
|
267 | + return $session_id; |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Handles an error by calling the WSError error handler |
|
274 | - * |
|
275 | - * @param WSError Error |
|
276 | - */ |
|
277 | - protected function handleError($error) |
|
278 | - { |
|
279 | - $handler = WSCMError::getErrorHandler(); |
|
280 | - $handler->handle($error); |
|
281 | - } |
|
272 | + /** |
|
273 | + * Handles an error by calling the WSError error handler |
|
274 | + * |
|
275 | + * @param WSError Error |
|
276 | + */ |
|
277 | + protected function handleError($error) |
|
278 | + { |
|
279 | + $handler = WSCMError::getErrorHandler(); |
|
280 | + $handler->handle($error); |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * Gets a successful result |
|
285 | - * |
|
286 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
287 | - */ |
|
288 | - protected function getSuccessfulResult() |
|
289 | - { |
|
290 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
291 | - } |
|
283 | + /** |
|
284 | + * Gets a successful result |
|
285 | + * |
|
286 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
287 | + */ |
|
288 | + protected function getSuccessfulResult() |
|
289 | + { |
|
290 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
291 | + } |
|
292 | 292 | |
293 | - /** |
|
294 | - * Test function. Returns the string success |
|
295 | - * |
|
296 | - * @return string Success |
|
297 | - */ |
|
298 | - public function test() |
|
299 | - { |
|
300 | - return "success"; |
|
301 | - } |
|
293 | + /** |
|
294 | + * Test function. Returns the string success |
|
295 | + * |
|
296 | + * @return string Success |
|
297 | + */ |
|
298 | + public function test() |
|
299 | + { |
|
300 | + return "success"; |
|
301 | + } |
|
302 | 302 | |
303 | - /** |
|
304 | - * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
305 | - * @param <type> $string |
|
306 | - * @return <type> $string |
|
307 | - */ |
|
308 | - public function nl2br_revert($string) { |
|
309 | - return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
310 | - } |
|
303 | + /** |
|
304 | + * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
305 | + * @param <type> $string |
|
306 | + * @return <type> $string |
|
307 | + */ |
|
308 | + public function nl2br_revert($string) { |
|
309 | + return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
310 | + } |
|
311 | 311 | |
312 | 312 | |
313 | 313 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | 'jpeg' => 'image/jpeg', |
7 | 7 | 'bmp' => 'image/bmp', |
8 | 8 | 'webp' => 'image/webp', |
9 | - 'pdf' => 'application/pdf' |
|
9 | + 'pdf' => 'application/pdf' |
|
10 | 10 | ); |
11 | 11 | |
12 | 12 | ?> |
13 | 13 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | - // You must first create a file "savefile_config.php" in this extensions directory and do whatever |
|
3 | - // checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG |
|
4 | - // files to your server which may cause disk space or possibly security problems |
|
5 | - require('savefile_config.php'); |
|
6 | - if (!isset($_POST['output_svg'])) { |
|
7 | - print "You must supply output_svg"; |
|
8 | - exit; |
|
9 | - } |
|
10 | - $svg = $_POST['output_svg']; |
|
11 | - $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows |
|
2 | + // You must first create a file "savefile_config.php" in this extensions directory and do whatever |
|
3 | + // checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG |
|
4 | + // files to your server which may cause disk space or possibly security problems |
|
5 | + require('savefile_config.php'); |
|
6 | + if (!isset($_POST['output_svg'])) { |
|
7 | + print "You must supply output_svg"; |
|
8 | + exit; |
|
9 | + } |
|
10 | + $svg = $_POST['output_svg']; |
|
11 | + $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows |
|
12 | 12 | |
13 | - $fh = fopen($filename, 'w') or die("Can't open file"); |
|
14 | - fwrite($fh, $svg); |
|
15 | - fclose($fh); |
|
13 | + $fh = fopen($filename, 'w') or die("Can't open file"); |
|
14 | + fwrite($fh, $svg); |
|
15 | + fclose($fh); |
|
16 | 16 | ?> |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | //get all files and folders |
17 | 17 | $scan_files = []; |
18 | 18 | if (is_dir($user_disk_path)) { |
19 | - $scan_files = scandir($user_disk_path); |
|
19 | + $scan_files = scandir($user_disk_path); |
|
20 | 20 | } |
21 | 21 | //get all svg and png files |
22 | 22 | $accepted_extensions = array('.svg', '.png'); |
23 | 23 | |
24 | 24 | if (is_array($scan_files) && count($scan_files) > 0) { |
25 | - foreach ($scan_files as & $file) { |
|
26 | - $slideshow_extension = strrchr($file, '.'); |
|
27 | - $slideshow_extension = strtolower($slideshow_extension); |
|
28 | - if (in_array($slideshow_extension, $accepted_extensions)) { |
|
29 | - $png_svg_files[] =$file; |
|
30 | - } |
|
31 | - } |
|
25 | + foreach ($scan_files as & $file) { |
|
26 | + $slideshow_extension = strrchr($file, '.'); |
|
27 | + $slideshow_extension = strtolower($slideshow_extension); |
|
28 | + if (in_array($slideshow_extension, $accepted_extensions)) { |
|
29 | + $png_svg_files[] =$file; |
|
30 | + } |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | $style = '<style>'; |
34 | 34 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
@@ -47,23 +47,23 @@ discard block |
||
47 | 47 | echo '<h2>'.get_lang('SocialNetwork').': '.get_lang('MyFiles').'</h2>'; |
48 | 48 | |
49 | 49 | if (!empty($png_svg_files)) { |
50 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
51 | - echo '<ul>'; |
|
52 | - foreach($png_svg_files as $filename) { |
|
53 | - $image = $user_disk_path.$filename; |
|
50 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
51 | + echo '<ul>'; |
|
52 | + foreach($png_svg_files as $filename) { |
|
53 | + $image = $user_disk_path.$filename; |
|
54 | 54 | |
55 | - if (strpos($filename, "svg")){ |
|
56 | - $new_sizes['width'] = 60; |
|
57 | - $new_sizes['height'] = 60; |
|
58 | - } else { |
|
59 | - $new_sizes = api_resize_image($image, 60, 60); |
|
60 | - } |
|
55 | + if (strpos($filename, "svg")){ |
|
56 | + $new_sizes['width'] = 60; |
|
57 | + $new_sizes['height'] = 60; |
|
58 | + } else { |
|
59 | + $new_sizes = api_resize_image($image, 60, 60); |
|
60 | + } |
|
61 | 61 | |
62 | - echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
63 | - } |
|
64 | - echo '</ul>'; |
|
62 | + echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
63 | + } |
|
64 | + echo '</ul>'; |
|
65 | 65 | } else { |
66 | - Display::display_warning_message(get_lang('NoSVGImages')); |
|
66 | + Display::display_warning_message(get_lang('NoSVGImages')); |
|
67 | 67 | } |
68 | 68 | ?> |
69 | 69 | </body> |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
35 | 35 | |
36 | 36 | if (count($array_to_search) > 0) { |
37 | - while (list($key) = each($array_to_search)) { |
|
38 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | - } |
|
37 | + while (list($key) = each($array_to_search)) { |
|
38 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //get all svg and png group files |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1 |
71 | 71 | ){ |
72 | 72 | |
73 | - if (!empty($png_svg_files)) { |
|
74 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | - echo '<ul>'; |
|
76 | - foreach($png_svg_files as $filename) { |
|
77 | - $image = $group_disk_path.$filename; |
|
78 | - |
|
79 | - if (strpos($filename, "svg")){ |
|
80 | - $new_sizes['width'] = 60; |
|
81 | - $new_sizes['height'] = 60; |
|
82 | - } else { |
|
83 | - $new_sizes = api_resize_image($image, 60, 60); |
|
84 | - } |
|
73 | + if (!empty($png_svg_files)) { |
|
74 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | + echo '<ul>'; |
|
76 | + foreach($png_svg_files as $filename) { |
|
77 | + $image = $group_disk_path.$filename; |
|
78 | + |
|
79 | + if (strpos($filename, "svg")){ |
|
80 | + $new_sizes['width'] = 60; |
|
81 | + $new_sizes['height'] = 60; |
|
82 | + } else { |
|
83 | + $new_sizes = api_resize_image($image, 60, 60); |
|
84 | + } |
|
85 | 85 | echo '<li style="display:inline; padding:8px;">'; |
86 | 86 | echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">'; |
87 | 87 | echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
88 | - } |
|
89 | - echo '</ul>'; |
|
90 | - } |
|
88 | + } |
|
89 | + echo '</ul>'; |
|
90 | + } |
|
91 | 91 | } else { |
92 | - echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
92 | + echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | </body> |