@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | in exercice/exercice.php, look for note-query-exe-results marker*/ |
195 | 195 | $session_id = api_get_session_id(); |
196 | 196 | $courseId = $this->getCourseId(); |
197 | - $exercise = new Exercise($courseId); |
|
197 | + $exercise = new Exercise($courseId); |
|
198 | 198 | $exercise->read($this->get_ref_id()); |
199 | 199 | |
200 | 200 | if (!$this->is_hp) { |
201 | 201 | |
202 | - if ($exercise->exercise_was_added_in_lp == false) { |
|
203 | - $sql = "SELECT * FROM $tblStats |
|
202 | + if ($exercise->exercise_was_added_in_lp == false) { |
|
203 | + $sql = "SELECT * FROM $tblStats |
|
204 | 204 | WHERE |
205 | 205 | exe_exo_id = ".intval($this->get_ref_id())." AND |
206 | 206 | orig_lp_id = 0 AND |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | session_id = $session_id AND |
210 | 210 | c_id = $courseId |
211 | 211 | "; |
212 | - } else { |
|
213 | - $lpId = null; |
|
214 | - if (!empty($exercise->lpList)) { |
|
215 | - // Taking only the first LP |
|
216 | - $lpId = current($exercise->lpList); |
|
217 | - $lpId = $lpId['lp_id']; |
|
218 | - } |
|
219 | - |
|
220 | - $sql = "SELECT * FROM $tblStats |
|
212 | + } else { |
|
213 | + $lpId = null; |
|
214 | + if (!empty($exercise->lpList)) { |
|
215 | + // Taking only the first LP |
|
216 | + $lpId = current($exercise->lpList); |
|
217 | + $lpId = $lpId['lp_id']; |
|
218 | + } |
|
219 | + |
|
220 | + $sql = "SELECT * FROM $tblStats |
|
221 | 221 | WHERE |
222 | 222 | exe_exo_id = ".intval($this->get_ref_id())." AND |
223 | 223 | orig_lp_id = $lpId AND |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | session_id = $session_id AND |
226 | 226 | c_id = $courseId |
227 | 227 | "; |
228 | - } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | if (!empty($stud_id) && $type != 'ranking') { |
231 | 231 | $sql .= " AND exe_user_id = $stud_id "; |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | |
52 | 52 | $result = Database::query($sql); |
53 | 53 | $cats = array(); |
54 | - while ($data=Database::fetch_array($result)) { |
|
55 | - $cats[] = array ($data['id'], $data['title']); |
|
54 | + while ($data = Database::fetch_array($result)) { |
|
55 | + $cats[] = array($data['id'], $data['title']); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | return $cats; |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | $cats = array(); |
117 | 117 | if (isset($result)) { |
118 | 118 | if (Database::num_rows($result) > 0) { |
119 | - while ($data=Database::fetch_array($result)) { |
|
120 | - $cats[] = array ($data['id'], $data['title']); |
|
119 | + while ($data = Database::fetch_array($result)) { |
|
120 | + $cats[] = array($data['id'], $data['title']); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | 125 | if (isset($result2)) { |
126 | 126 | if (Database::num_rows($result2) > 0) { |
127 | - while ($row=Database::fetch_array($result2)) { |
|
127 | + while ($row = Database::fetch_array($result2)) { |
|
128 | 128 | /*$path = $data['path']; |
129 | 129 | $fname = GetQuizName($path,$documentPath); |
130 | 130 | $cats[] = array ($data['id'], $fname);*/ |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | WHERE |
171 | 171 | session_id = $session_id AND |
172 | 172 | c_id = $course_id AND |
173 | - exe_exo_id = ".(int)$this->get_ref_id(); |
|
173 | + exe_exo_id = ".(int) $this->get_ref_id(); |
|
174 | 174 | $result = Database::query($sql); |
175 | - $number=Database::fetch_row($result); |
|
175 | + $number = Database::fetch_row($result); |
|
176 | 176 | return ($number[0] != 0); |
177 | 177 | } |
178 | 178 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } else { |
255 | 255 | // all students -> get average |
256 | 256 | // normal way of getting the info |
257 | - $students = array(); // user list, needed to make sure we only |
|
257 | + $students = array(); // user list, needed to make sure we only |
|
258 | 258 | // take first attempts into account |
259 | 259 | $student_count = 0; |
260 | 260 | $sum = 0; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | /*if (empty($count)) { |
290 | 290 | return null; |
291 | 291 | }*/ |
292 | - return array($sumResult/$count , $weight); |
|
292 | + return array($sumResult / $count, $weight); |
|
293 | 293 | break; |
294 | 294 | case 'ranking': |
295 | 295 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $session_id = api_get_session_id(); |
320 | 320 | |
321 | 321 | $url = api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id().'&type='.$this->get_type(); |
322 | - if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) { |
|
322 | + if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user != 1) { |
|
323 | 323 | $url .= '&doexercise='.$this->get_ref_id(); |
324 | 324 | } |
325 | 325 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | public function is_valid_link() |
365 | 365 | { |
366 | 366 | $sql = 'SELECT count(id) from '.$this->get_exercise_table().' |
367 | - WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' '; |
|
367 | + WHERE c_id = '.$this->course_id.' AND id = '.(int) $this->get_ref_id().' '; |
|
368 | 368 | $result = Database::query($sql); |
369 | 369 | $number = Database::fetch_row($result); |
370 | 370 |
@@ -138,22 +138,22 @@ discard block |
||
138 | 138 | return $this->visible; |
139 | 139 | } |
140 | 140 | |
141 | - public function set_id ($id) |
|
141 | + public function set_id($id) |
|
142 | 142 | { |
143 | 143 | $this->id = $id; |
144 | 144 | } |
145 | 145 | |
146 | - public function set_type ($type) |
|
146 | + public function set_type($type) |
|
147 | 147 | { |
148 | 148 | $this->type = $type; |
149 | 149 | } |
150 | 150 | |
151 | - public function set_ref_id ($ref_id) |
|
151 | + public function set_ref_id($ref_id) |
|
152 | 152 | { |
153 | 153 | $this->ref_id = $ref_id; |
154 | 154 | } |
155 | 155 | |
156 | - public function set_user_id ($user_id) |
|
156 | + public function set_user_id($user_id) |
|
157 | 157 | { |
158 | 158 | $this->user_id = $user_id; |
159 | 159 | } |
@@ -231,29 +231,29 @@ discard block |
||
231 | 231 | $sql = 'SELECT * FROM '.$tbl_grade_links; |
232 | 232 | $paramcount = 0; |
233 | 233 | if (isset ($id)) { |
234 | - $sql.= ' WHERE id = '.intval($id); |
|
235 | - $paramcount ++; |
|
234 | + $sql .= ' WHERE id = '.intval($id); |
|
235 | + $paramcount++; |
|
236 | 236 | } |
237 | 237 | if (isset ($type)) { |
238 | 238 | if ($paramcount != 0) $sql .= ' AND'; |
239 | 239 | else $sql .= ' WHERE'; |
240 | 240 | $sql .= ' type = '.intval($type); |
241 | - $paramcount ++; |
|
241 | + $paramcount++; |
|
242 | 242 | } |
243 | 243 | if (isset ($ref_id)) { |
244 | 244 | if ($paramcount != 0) $sql .= ' AND'; |
245 | 245 | else $sql .= ' WHERE'; |
246 | 246 | $sql .= ' ref_id = '.intval($ref_id); |
247 | - $paramcount ++; |
|
247 | + $paramcount++; |
|
248 | 248 | } |
249 | 249 | if (isset ($user_id)) { |
250 | 250 | if ($paramcount != 0) { |
251 | 251 | $sql .= ' AND'; |
252 | - }else { |
|
252 | + } else { |
|
253 | 253 | $sql .= ' WHERE'; |
254 | 254 | } |
255 | 255 | $sql .= ' user_id = '.intval($user_id); |
256 | - $paramcount ++; |
|
256 | + $paramcount++; |
|
257 | 257 | } |
258 | 258 | if (isset ($course_code)) { |
259 | 259 | if ($paramcount != 0) { |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | $sql .= ' WHERE'; |
263 | 263 | } |
264 | 264 | $sql .= " course_code = '".Database::escape_string($course_code)."'"; |
265 | - $paramcount ++; |
|
265 | + $paramcount++; |
|
266 | 266 | } |
267 | 267 | if (isset ($category_id)) { |
268 | 268 | if ($paramcount != 0) { |
269 | 269 | $sql .= ' AND'; |
270 | - }else { |
|
270 | + } else { |
|
271 | 271 | $sql .= ' WHERE'; |
272 | 272 | } |
273 | 273 | $sql .= ' category_id = '.intval($category_id); |
274 | - $paramcount ++; |
|
274 | + $paramcount++; |
|
275 | 275 | } |
276 | 276 | if (isset ($visible)) { |
277 | 277 | if ($paramcount != 0) { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $session_id = api_get_session_id(); |
312 | 312 | |
313 | 313 | $link->set_session_id($session_id); |
314 | - $links[]=$link; |
|
314 | + $links[] = $link; |
|
315 | 315 | } |
316 | 316 | return $links; |
317 | 317 | } |
@@ -402,12 +402,12 @@ discard block |
||
402 | 402 | $dateobject = AbstractLink::load($idevaluation, null, null, null, null); |
403 | 403 | $current_date_server = api_get_utc_datetime(); |
404 | 404 | $arreval = get_object_vars($dateobject[0]); |
405 | - $description_log = isset($arreval['description']) ? $arreval['description']:''; |
|
405 | + $description_log = isset($arreval['description']) ? $arreval['description'] : ''; |
|
406 | 406 | if (empty($nameLog)) { |
407 | 407 | if (isset($_POST['name_link'])) { |
408 | 408 | $name_log = isset($_POST['name_link']) ? $_POST['name_link'] : $arreval['course_code']; |
409 | - } elseif (isset($_POST['link_' . $idevaluation]) && $_POST['link_' . $idevaluation]) { |
|
410 | - $name_log = $_POST['link_' . $idevaluation]; |
|
409 | + } elseif (isset($_POST['link_'.$idevaluation]) && $_POST['link_'.$idevaluation]) { |
|
410 | + $name_log = $_POST['link_'.$idevaluation]; |
|
411 | 411 | } else { |
412 | 412 | $name_log = $arreval['course_code']; |
413 | 413 | } |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | $targets = array(); |
453 | 453 | $level = 0; |
454 | 454 | |
455 | - $crscats = Category::load(null,null,$this->get_course_code(),0); |
|
455 | + $crscats = Category::load(null, null, $this->get_course_code(), 0); |
|
456 | 456 | foreach ($crscats as $cat) { |
457 | - $targets[] = array($cat->get_id(), $cat->get_name(), $level+1); |
|
458 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
457 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
458 | + $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id()); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | return $targets; |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | */ |
467 | 467 | private function add_target_subcategories($targets, $level, $catid) |
468 | 468 | { |
469 | - $subcats = Category::load(null,null,null,$catid); |
|
469 | + $subcats = Category::load(null, null, null, $catid); |
|
470 | 470 | foreach ($subcats as $cat) { |
471 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
472 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
471 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
472 | + $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id()); |
|
473 | 473 | } |
474 | 474 | return $targets; |
475 | 475 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * To keep consistency, do not call this method but LinkFactory::find_links instead. |
494 | 494 | * @todo can be written more efficiently using a new (but very complex) sql query |
495 | 495 | */ |
496 | - public function find_links ($name_mask,$selectcat) |
|
496 | + public function find_links($name_mask, $selectcat) |
|
497 | 497 | { |
498 | 498 | $rootcat = Category::load($selectcat); |
499 | 499 | $links = $rootcat[0]->get_links((api_is_allowed_to_edit() ? null : api_get_user_id()), true); |
@@ -235,21 +235,27 @@ discard block |
||
235 | 235 | $paramcount ++; |
236 | 236 | } |
237 | 237 | if (isset ($type)) { |
238 | - if ($paramcount != 0) $sql .= ' AND'; |
|
239 | - else $sql .= ' WHERE'; |
|
238 | + if ($paramcount != 0) { |
|
239 | + $sql .= ' AND'; |
|
240 | + } else { |
|
241 | + $sql .= ' WHERE'; |
|
242 | + } |
|
240 | 243 | $sql .= ' type = '.intval($type); |
241 | 244 | $paramcount ++; |
242 | 245 | } |
243 | 246 | if (isset ($ref_id)) { |
244 | - if ($paramcount != 0) $sql .= ' AND'; |
|
245 | - else $sql .= ' WHERE'; |
|
247 | + if ($paramcount != 0) { |
|
248 | + $sql .= ' AND'; |
|
249 | + } else { |
|
250 | + $sql .= ' WHERE'; |
|
251 | + } |
|
246 | 252 | $sql .= ' ref_id = '.intval($ref_id); |
247 | 253 | $paramcount ++; |
248 | 254 | } |
249 | 255 | if (isset ($user_id)) { |
250 | 256 | if ($paramcount != 0) { |
251 | 257 | $sql .= ' AND'; |
252 | - }else { |
|
258 | + } else { |
|
253 | 259 | $sql .= ' WHERE'; |
254 | 260 | } |
255 | 261 | $sql .= ' user_id = '.intval($user_id); |
@@ -267,7 +273,7 @@ discard block |
||
267 | 273 | if (isset ($category_id)) { |
268 | 274 | if ($paramcount != 0) { |
269 | 275 | $sql .= ' AND'; |
270 | - }else { |
|
276 | + } else { |
|
271 | 277 | $sql .= ' WHERE'; |
272 | 278 | } |
273 | 279 | $sql .= ' category_id = '.intval($category_id); |
@@ -8,16 +8,16 @@ |
||
8 | 8 | */ |
9 | 9 | interface GradebookItem |
10 | 10 | { |
11 | - public function get_item_type(); |
|
12 | - public function get_id(); |
|
13 | - public function get_name(); |
|
14 | - public function get_description(); |
|
15 | - public function get_course_code(); |
|
16 | - public function get_weight(); |
|
17 | - public function get_date(); |
|
18 | - public function is_visible(); |
|
19 | - public function get_icon_name(); |
|
20 | - public function getStudentList(); |
|
21 | - public function setStudentList($list); |
|
22 | - public function calc_score($stud_id = null, $type = null); |
|
11 | + public function get_item_type(); |
|
12 | + public function get_id(); |
|
13 | + public function get_name(); |
|
14 | + public function get_description(); |
|
15 | + public function get_course_code(); |
|
16 | + public function get_weight(); |
|
17 | + public function get_date(); |
|
18 | + public function is_visible(); |
|
19 | + public function get_icon_name(); |
|
20 | + public function getStudentList(); |
|
21 | + public function setStudentList($list); |
|
22 | + public function calc_score($stud_id = null, $type = null); |
|
23 | 23 | } |
@@ -1571,7 +1571,6 @@ discard block |
||
1571 | 1571 | * @param string $course_code Course code (optional) |
1572 | 1572 | * @param int $session_id Session ID (optional) |
1573 | 1573 | * @param bool $order |
1574 | - |
|
1575 | 1574 | * @return array Array of subcategories |
1576 | 1575 | */ |
1577 | 1576 | public function get_subcategories($stud_id = null, $course_code = null, $session_id = null, $order = null) |
@@ -1850,7 +1849,6 @@ discard block |
||
1850 | 1849 | * This function, locks a category , only one who can unlock it is |
1851 | 1850 | * the platform administrator. |
1852 | 1851 | * @param int locked 1 or unlocked 0 |
1853 | - |
|
1854 | 1852 | * @return bool |
1855 | 1853 | * */ |
1856 | 1854 | public function lock($locked) |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function set_session_id($session_id = 0) |
201 | 201 | { |
202 | - $this->session_id = (int)$session_id; |
|
202 | + $this->session_id = (int) $session_id; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $skills = $this->get_skills(); |
289 | 289 | $skill_select = array(); |
290 | 290 | if (!empty($skills)) { |
291 | - foreach($skills as $skill) { |
|
291 | + foreach ($skills as $skill) { |
|
292 | 292 | $skill_select[$skill['id']] = $skill['name']; |
293 | 293 | } |
294 | 294 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public static function load_session_categories($id = null, $session_id = null) |
324 | 324 | { |
325 | - if (isset($id) && (int)$id === 0) { |
|
325 | + if (isset($id) && (int) $id === 0) { |
|
326 | 326 | $cats = array(); |
327 | 327 | $cats[] = Category::create_root_category(); |
328 | 328 | return $cats; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if (!empty($session_id)) { |
336 | 336 | $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
337 | 337 | $sql = 'SELECT id, course_code |
338 | - FROM '.$tbl_grade_categories. ' |
|
338 | + FROM '.$tbl_grade_categories.' |
|
339 | 339 | WHERE session_id = '.$session_id; |
340 | 340 | $result_session = Database::query($sql); |
341 | 341 | if (Database::num_rows($result_session) > 0) { |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | ) { |
376 | 376 | //if the category given is explicitly 0 (not null), then create |
377 | 377 | // a root category object (in memory) |
378 | - if (isset($id) && (int)$id === 0) { |
|
378 | + if (isset($id) && (int) $id === 0) { |
|
379 | 379 | $cats = array(); |
380 | 380 | $cats[] = Category::create_root_category(); |
381 | 381 | |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | $sql = 'SELECT * FROM '.$tbl_grade_categories; |
387 | 387 | $paramcount = 0; |
388 | 388 | if (isset($id)) { |
389 | - $sql.= ' WHERE id = '.intval($id); |
|
390 | - $paramcount ++; |
|
389 | + $sql .= ' WHERE id = '.intval($id); |
|
390 | + $paramcount++; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($user_id)) { |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | if (empty($session_id)) { |
424 | 424 | $sql .= ' AND (session_id IS NULL OR session_id = 0) '; |
425 | 425 | } else { |
426 | - $sql .= ' AND session_id = '.(int)$session_id.' '; |
|
426 | + $sql .= ' AND session_id = '.(int) $session_id.' '; |
|
427 | 427 | } |
428 | 428 | //} |
429 | - $paramcount ++; |
|
429 | + $paramcount++; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (isset($parent_id)) { |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $default_weight = $default_weight_setting; |
599 | 599 | } |
600 | 600 | foreach ($components as $component) { |
601 | - $gradebook = new Gradebook(); |
|
601 | + $gradebook = new Gradebook(); |
|
602 | 602 | $params = array(); |
603 | 603 | |
604 | 604 | $params['name'] = $component['acronym']; |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
618 | - $gradebook= new Gradebook(); |
|
618 | + $gradebook = new Gradebook(); |
|
619 | 619 | $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false)); |
620 | 620 | |
621 | 621 | return $id; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | $params['description'] = $component['title']; |
681 | 681 | $params['user_id'] = api_get_user_id(); |
682 | 682 | $params['parent_id'] = $this->id; |
683 | - $params['weight'] = $component['percentage']/100*$default_weight; |
|
683 | + $params['weight'] = $component['percentage'] / 100 * $default_weight; |
|
684 | 684 | $params['session_id'] = api_get_session_id(); |
685 | 685 | $params['course_code'] = $this->get_course_code(); |
686 | 686 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | - $gradebook= new Gradebook(); |
|
693 | + $gradebook = new Gradebook(); |
|
694 | 694 | $gradebook->update_skills_to_gradebook( |
695 | 695 | $this->id, |
696 | 696 | $this->get_skills(false), |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | if (!empty($links)) { |
711 | 711 | foreach ($links as $link_item) { |
712 | 712 | if (isset($link_item)) { |
713 | - $new_item_weight = $new_weight * $link_item->get_weight() / $old_weight; |
|
713 | + $new_item_weight = $new_weight * $link_item->get_weight() / $old_weight; |
|
714 | 714 | $link_item->set_weight($new_item_weight); |
715 | 715 | $link_item->save(); |
716 | 716 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | visible=3'; |
752 | 752 | $res = Database::query($sql); |
753 | 753 | $option = Database::fetch_array($res, 'ASSOC'); |
754 | - if ($option['num']>=1) { |
|
754 | + if ($option['num'] >= 1) { |
|
755 | 755 | return ' <span class="resource-deleted">( '.get_lang('ResourceDeleted').' )</span>'; |
756 | 756 | } else { |
757 | 757 | return false; |
@@ -812,9 +812,9 @@ discard block |
||
812 | 812 | $sql .= ' AND user_id = '.api_get_user_id(); |
813 | 813 | } |
814 | 814 | if (!isset ($parent)) { |
815 | - $sql.= ' AND parent_id is null'; |
|
815 | + $sql .= ' AND parent_id is null'; |
|
816 | 816 | } else { |
817 | - $sql.= ' AND parent_id = '.intval($parent); |
|
817 | + $sql .= ' AND parent_id = '.intval($parent); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | $result = Database::query($sql); |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | } |
913 | 913 | |
914 | 914 | if (isset($score) && !empty($score[1]) && !empty($catweight)) { |
915 | - $ressum += $score[0]/$score[1] * $catweight; |
|
915 | + $ressum += $score[0] / $score[1] * $catweight; |
|
916 | 916 | } |
917 | 917 | } |
918 | 918 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if (isset($score) && !empty($score[1]) && !empty($catweight)) { |
1004 | - $ressum += $score[0]/$score[1] * $catweight; |
|
1004 | + $ressum += $score[0] / $score[1] * $catweight; |
|
1005 | 1005 | |
1006 | 1006 | if ($ressum > $bestResult) { |
1007 | 1007 | $bestResult = $ressum; |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | // session, we don't check his registration to these, but this |
1141 | 1141 | // could be an improvement |
1142 | 1142 | if (!empty($session_id)) { |
1143 | - $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id; |
|
1143 | + $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int) $session_id; |
|
1144 | 1144 | } else { |
1145 | 1145 | $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0"; |
1146 | 1146 | } |
@@ -1164,9 +1164,9 @@ discard block |
||
1164 | 1164 | // could be an improvement |
1165 | 1165 | $sql .= " AND course_code = '".Database::escape_string($course_code)."'"; |
1166 | 1166 | if (!empty($session_id)) { |
1167 | - $sql .= " AND session_id = ".(int)$session_id; |
|
1167 | + $sql .= " AND session_id = ".(int) $session_id; |
|
1168 | 1168 | } else { |
1169 | - $sql .="AND session_id IS NULL OR session_id=0"; |
|
1169 | + $sql .= "AND session_id IS NULL OR session_id=0"; |
|
1170 | 1170 | } |
1171 | 1171 | } else { |
1172 | 1172 | $sql .= ' AND course_code IN |
@@ -1180,10 +1180,10 @@ discard block |
||
1180 | 1180 | )'; |
1181 | 1181 | } |
1182 | 1182 | }elseif (api_is_platform_admin()) { |
1183 | - if (isset($session_id) && $session_id!=0) { |
|
1184 | - $sql.=' AND session_id='.intval($session_id); |
|
1183 | + if (isset($session_id) && $session_id != 0) { |
|
1184 | + $sql .= ' AND session_id='.intval($session_id); |
|
1185 | 1185 | } else { |
1186 | - $sql.=' AND coalesce(session_id,0)=0'; |
|
1186 | + $sql .= ' AND coalesce(session_id,0)=0'; |
|
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | $result = Database::query($sql); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | |
1192 | 1192 | // course independent categories |
1193 | 1193 | if (empty($course_code)) { |
1194 | - $cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats); |
|
1194 | + $cats = Category::get_independent_categories_with_result_for_student(0, $stud_id, $cats); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | return $cats; |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null) |
1207 | 1207 | { |
1208 | 1208 | if ($user_id == null) { |
1209 | - return Category::load(null,null,$course_code,0,null,$session_id); |
|
1209 | + return Category::load(null, null, $course_code, 0, null, $session_id); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE); |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | if (!empty($course_code)) { |
1219 | 1219 | $sql .= " AND course_code = '".Database::escape_string($course_code)."' "; |
1220 | 1220 | if (!empty($session_id)) { |
1221 | - $sql .= " AND session_id = ".(int)$session_id; |
|
1221 | + $sql .= " AND session_id = ".(int) $session_id; |
|
1222 | 1222 | } |
1223 | 1223 | } else { |
1224 | 1224 | $sql .= ' AND course_code in |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | $cats = Category::create_category_objects_from_sql_result($result); |
1235 | 1235 | // course independent categories |
1236 | 1236 | if (isset($course_code)) { |
1237 | - $indcats = Category::load(null,$user_id,$course_code,0,null,$session_id); |
|
1237 | + $indcats = Category::load(null, $user_id, $course_code, 0, null, $session_id); |
|
1238 | 1238 | $cats = array_merge($cats, $indcats); |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1277,20 +1277,20 @@ discard block |
||
1277 | 1277 | $targets[] = $root; |
1278 | 1278 | |
1279 | 1279 | if (isset($this->course_code) && !empty($this->course_code)) { |
1280 | - $crscats = Category::load(null,null,$this->course_code,0); |
|
1280 | + $crscats = Category::load(null, null, $this->course_code, 0); |
|
1281 | 1281 | foreach ($crscats as $cat) { |
1282 | 1282 | if ($this->can_be_moved_to_cat($cat)) { |
1283 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1284 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
1283 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1284 | + $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id()); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | 1287 | } |
1288 | 1288 | |
1289 | - $indcats = Category::load(null,$user,0,0); |
|
1289 | + $indcats = Category::load(null, $user, 0, 0); |
|
1290 | 1290 | foreach ($indcats as $cat) { |
1291 | 1291 | if ($this->can_be_moved_to_cat($cat)) { |
1292 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1293 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
1292 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1293 | + $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id()); |
|
1294 | 1294 | } |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1303,11 +1303,11 @@ discard block |
||
1303 | 1303 | */ |
1304 | 1304 | private function add_target_subcategories($targets, $level, $catid) |
1305 | 1305 | { |
1306 | - $subcats = Category::load(null,null,null,$catid); |
|
1306 | + $subcats = Category::load(null, null, null, $catid); |
|
1307 | 1307 | foreach ($subcats as $cat) { |
1308 | 1308 | if ($this->can_be_moved_to_cat($cat)) { |
1309 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1310 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
1309 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1310 | + $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id()); |
|
1311 | 1311 | } |
1312 | 1312 | } |
1313 | 1313 | |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | * Impossible when origin and target are the same... children won't be processed |
1321 | 1321 | * either. (a category can't be moved to one of its own children) |
1322 | 1322 | */ |
1323 | - private function can_be_moved_to_cat ($cat) |
|
1323 | + private function can_be_moved_to_cat($cat) |
|
1324 | 1324 | { |
1325 | 1325 | return $cat->get_id() != $this->get_id(); |
1326 | 1326 | } |
@@ -1349,7 +1349,7 @@ discard block |
||
1349 | 1349 | { |
1350 | 1350 | $cats = Category::load(null, null, null, $this->id, null); |
1351 | 1351 | $evals = Evaluation::load(null, null, null, $this->id, null); |
1352 | - $links = LinkFactory::load(null,null,null,null,null,$this->id,null); |
|
1352 | + $links = LinkFactory::load(null, null, null, null, null, $this->id, null); |
|
1353 | 1353 | |
1354 | 1354 | foreach ($cats as $cat) { |
1355 | 1355 | $cat->set_course_code($this->get_course_code()); |
@@ -1382,15 +1382,15 @@ discard block |
||
1382 | 1382 | $user = (api_is_platform_admin() ? null : api_get_user_id()); |
1383 | 1383 | $cats = Category::get_root_categories_for_teacher($user); |
1384 | 1384 | foreach ($cats as $cat) { |
1385 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1386 | - $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null); |
|
1385 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1386 | + $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), null); |
|
1387 | 1387 | } |
1388 | 1388 | } else { |
1389 | 1389 | // student |
1390 | 1390 | $cats = Category::get_root_categories_for_student(api_get_user_id()); |
1391 | 1391 | foreach ($cats as $cat) { |
1392 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1393 | - $targets = Category::add_subtree($targets, $level+1, $cat->get_id(), 1); |
|
1392 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1393 | + $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), 1); |
|
1394 | 1394 | } |
1395 | 1395 | } |
1396 | 1396 | |
@@ -1400,14 +1400,14 @@ discard block |
||
1400 | 1400 | /** |
1401 | 1401 | * Internal function used by get_tree() |
1402 | 1402 | */ |
1403 | - private function add_subtree ($targets, $level, $catid, $visible) |
|
1403 | + private function add_subtree($targets, $level, $catid, $visible) |
|
1404 | 1404 | { |
1405 | - $subcats = Category::load(null,null,null,$catid,$visible); |
|
1405 | + $subcats = Category::load(null, null, null, $catid, $visible); |
|
1406 | 1406 | |
1407 | 1407 | if (!empty($subcats)) { |
1408 | 1408 | foreach ($subcats as $cat) { |
1409 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
1410 | - $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),$visible); |
|
1409 | + $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1); |
|
1410 | + $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), $visible); |
|
1411 | 1411 | } |
1412 | 1412 | } |
1413 | 1413 | |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | * Generate an array of courses that a teacher hasn't created a category for. |
1419 | 1419 | * @return array 2-dimensional array - every element contains 2 subelements (code, title) |
1420 | 1420 | */ |
1421 | - public function get_not_created_course_categories ($user_id) |
|
1421 | + public function get_not_created_course_categories($user_id) |
|
1422 | 1422 | { |
1423 | 1423 | $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE); |
1424 | 1424 | $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
@@ -1440,9 +1440,9 @@ discard block |
||
1440 | 1440 | )'; |
1441 | 1441 | $result = Database::query($sql); |
1442 | 1442 | |
1443 | - $cats=array(); |
|
1444 | - while ($data=Database::fetch_array($result)) { |
|
1445 | - $cats[] = array ($data['code'], $data['title']); |
|
1443 | + $cats = array(); |
|
1444 | + while ($data = Database::fetch_array($result)) { |
|
1445 | + $cats[] = array($data['code'], $data['title']); |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | return $cats; |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * Generate an array of all courses that a teacher is admin of. |
1453 | 1453 | * @return array 2-dimensional array - every element contains 2 subelements (code, title) |
1454 | 1454 | */ |
1455 | - public function get_all_courses ($user_id) |
|
1455 | + public function get_all_courses($user_id) |
|
1456 | 1456 | { |
1457 | 1457 | $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE); |
1458 | 1458 | $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | $result = Database::query($sql); |
1467 | 1467 | $cats = array(); |
1468 | 1468 | while ($data = Database::fetch_array($result)) { |
1469 | - $cats[] = array ($data['code'], $data['title']); |
|
1469 | + $cats[] = array($data['code'], $data['title']); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | return $cats; |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | { |
1480 | 1480 | $cats = Category::load(null, null, null, $this->id, null); |
1481 | 1481 | $evals = Evaluation::load(null, null, null, $this->id, null); |
1482 | - $links = LinkFactory::load(null,null,null,null,null,$this->id,null); |
|
1482 | + $links = LinkFactory::load(null, null, null, null, null, $this->id, null); |
|
1483 | 1483 | if (!empty($cats)) { |
1484 | 1484 | foreach ($cats as $cat) { |
1485 | 1485 | $cat->set_visible($this->is_visible()); |
@@ -1834,7 +1834,7 @@ discard block |
||
1834 | 1834 | * @param string $name_mask search string |
1835 | 1835 | * @return array category objects matching the search criterium |
1836 | 1836 | */ |
1837 | - public function find_category($name_mask,$allcat) |
|
1837 | + public function find_category($name_mask, $allcat) |
|
1838 | 1838 | { |
1839 | 1839 | $foundcats = array(); |
1840 | 1840 | foreach ($allcat as $search_cat) { |
@@ -1877,9 +1877,9 @@ discard block |
||
1877 | 1877 | } |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - $link_to_lock= $this->get_links(); |
|
1880 | + $link_to_lock = $this->get_links(); |
|
1881 | 1881 | if (!empty($link_to_lock)) { |
1882 | - foreach ($link_to_lock as $item ) { |
|
1882 | + foreach ($link_to_lock as $item) { |
|
1883 | 1883 | $item->lock($locked); |
1884 | 1884 | } |
1885 | 1885 | } |
@@ -1968,7 +1968,7 @@ discard block |
||
1968 | 1968 | return [ |
1969 | 1969 | 'badge_link' => Display::url( |
1970 | 1970 | get_lang('DownloadBadges'), |
1971 | - api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id", |
|
1971 | + api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id", |
|
1972 | 1972 | array( |
1973 | 1973 | 'target' => '_blank', |
1974 | 1974 | 'class' => 'btn btn-default' |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $fileWasGenerated = $certificate_obj->html_file_is_generated(); |
2003 | 2003 | |
2004 | 2004 | if (!empty($fileWasGenerated)) { |
2005 | - $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id']; |
|
2005 | + $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id']; |
|
2006 | 2006 | |
2007 | 2007 | $certificates = Display::url( |
2008 | 2008 | Display::returnFontAwesomeIcon('download').' '.get_lang('DownloadCertificate'), |
@@ -2025,7 +2025,7 @@ discard block |
||
2025 | 2025 | |
2026 | 2026 | $hideExportLink = api_get_setting('hide_certificate_export_link'); |
2027 | 2027 | $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students'); |
2028 | - if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) { |
|
2028 | + if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) { |
|
2029 | 2029 | $exportToPDF = null; |
2030 | 2030 | } |
2031 | 2031 | |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | if ($skillToolEnabled && $userHasSkills) { |
2039 | 2039 | $html['badge_link'] = Display::url( |
2040 | 2040 | get_lang('DownloadBadges'), |
2041 | - api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id", |
|
2041 | + api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id", |
|
2042 | 2042 | array( |
2043 | 2043 | 'target' => '_blank', |
2044 | 2044 | 'class' => 'btn btn-default' |
@@ -2098,7 +2098,7 @@ discard block |
||
2098 | 2098 | $certificate_obj = new Certificate($value_certificate['id']); |
2099 | 2099 | $certificate_obj->generate(array('hide_print_button' => true)); |
2100 | 2100 | if ($certificate_obj->html_file_is_generated()) { |
2101 | - $certificate_path_list[]= $certificate_obj->html_file; |
|
2101 | + $certificate_path_list[] = $certificate_obj->html_file; |
|
2102 | 2102 | } |
2103 | 2103 | } |
2104 | 2104 | } |
@@ -1179,7 +1179,7 @@ |
||
1179 | 1179 | cu.status = '.COURSEMANAGER.' |
1180 | 1180 | )'; |
1181 | 1181 | } |
1182 | - }elseif (api_is_platform_admin()) { |
|
1182 | + } elseif (api_is_platform_admin()) { |
|
1183 | 1183 | if (isset($session_id) && $session_id!=0) { |
1184 | 1184 | $sql.=' AND session_id='.intval($session_id); |
1185 | 1185 | } else { |
@@ -1545,7 +1545,7 @@ |
||
1545 | 1545 | * Retrieve all categories inside a course independent category |
1546 | 1546 | * that should be visible to a student. |
1547 | 1547 | * @param integer $cat_id parent category |
1548 | - * @param $stud_id student id |
|
1548 | + * @param integer $stud_id student id |
|
1549 | 1549 | * @param $cats optional: if defined, the categories will be added to this array |
1550 | 1550 | */ |
1551 | 1551 | public function get_independent_categories_with_result_for_student($cat_id, $stud_id, $cats = array()) |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } else { |
166 | 166 | // all students -> get average |
167 | - $students = array(); // user list, needed to make sure we only |
|
167 | + $students = array(); // user list, needed to make sure we only |
|
168 | 168 | // take first attempts into account |
169 | 169 | $rescount = 0; |
170 | 170 | $sum = 0; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $this->get_attendance_data(); |
240 | 240 | $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
241 | 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 != '') { |
|
242 | + if (isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | 243 | return $this->attendance_data['attendance_qualify_title']; |
244 | 244 | } else { |
245 | 245 | return $attendance_title; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 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 | 281 | $result = Database::query($sql); |
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
282 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
283 | 283 | $attendance_id = $row['id']; |
284 | 284 | $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&session_id='.$session_id.'&cidReq='.$this->get_course_code(); |
285 | 285 |
@@ -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 | } |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | $eval = $this->get_evaluation(); |
48 | 48 | // course/platform admin can go to the view_results page |
49 | 49 | if (api_is_allowed_to_edit()) { |
50 | - return 'gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
50 | + return 'gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
51 | 51 | } // students can go to the statistics page (if custom display enabled) |
52 | 52 | elseif (ScoreDisplay :: instance()->is_custom()) { |
53 | - return 'gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
53 | + return 'gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
54 | 54 | } else { |
55 | 55 | return null; |
56 | 56 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | $eval = new Evaluation(); |
177 | 177 | $eval->set_category_id(-1); |
178 | 178 | $eval->set_date(api_get_utc_datetime()); // these values will be changed |
179 | - $eval->set_weight(0); // when the link setter |
|
180 | - $eval->set_visible(0); // is called |
|
179 | + $eval->set_weight(0); // when the link setter |
|
180 | + $eval->set_visible(0); // is called |
|
181 | 181 | $eval->set_id(-1); // a 'real' id will be set when eval is added to db |
182 | 182 | $eval->set_user_id($this->get_user_id()); |
183 | 183 | $eval->set_course_code($this->get_course_code()); |
@@ -117,6 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | + /** |
|
121 | + * @param string $name |
|
122 | + */ |
|
120 | 123 | public function set_name($name) |
121 | 124 | { |
122 | 125 | if ($this->is_valid_link()) { |
@@ -124,6 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | } |
126 | 129 | |
130 | + /** |
|
131 | + * @param string $description |
|
132 | + */ |
|
127 | 133 | public function set_description($description) |
128 | 134 | { |
129 | 135 | if ($this->is_valid_link()) { |
@@ -131,6 +137,9 @@ discard block |
||
131 | 137 | } |
132 | 138 | } |
133 | 139 | |
140 | + /** |
|
141 | + * @param integer $max |
|
142 | + */ |
|
134 | 143 | public function set_max($max) |
135 | 144 | { |
136 | 145 | if ($this->is_valid_link()) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $links[] = array( |
76 | 76 | $data['survey_id'], |
77 | 77 | api_trunc_str( |
78 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
78 | + $data['code'].': '.self::html_to_text($data['title']), |
|
79 | 79 | 80 |
80 | 80 | ) |
81 | 81 | ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * Has anyone done this survey yet? |
123 | 123 | */ |
124 | - public function has_results($stud_id=null) |
|
124 | + public function has_results($stud_id = null) |
|
125 | 125 | { |
126 | 126 | $ref_id = intval($this->get_ref_id()); |
127 | 127 | $session_id = api_get_session_id(); |
@@ -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 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $name_mask search string |
59 | 59 | * @return array link objects matching the search criterium |
60 | 60 | */ |
61 | - public function find_links($name_mask,$selectcat) |
|
61 | + public function find_links($name_mask, $selectcat) |
|
62 | 62 | { |
63 | 63 | return AbstractLink::find_links($name_mask, $selectcat); |
64 | 64 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public static function get_all_types() |
99 | 99 | { |
100 | 100 | //LINK_DROPBOX, |
101 | - return array ( |
|
101 | + return array( |
|
102 | 102 | LINK_EXERCISE, |
103 | 103 | //LINK_DROPBOX, |
104 | 104 | LINK_HOTPOTATOES, |
@@ -93,7 +93,7 @@ |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Return an array of all known link types |
96 | - * @return array |
|
96 | + * @return integer[] |
|
97 | 97 | */ |
98 | 98 | public static function get_all_types() |
99 | 99 | { |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | die('Error in get_not_created_links() : course code not set'); |
85 | 85 | } |
86 | 86 | |
87 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
87 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
89 | 89 | $session_id = api_get_session_id(); |
90 | 90 | |
91 | 91 | if ($session_id) { |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | $result = Database::query($sql); |
109 | 109 | |
110 | 110 | while ($data = Database::fetch_array($result)) { |
111 | - if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){ |
|
112 | - $cats[] = array ($data['thread_id'], $data['thread_title_qualify']); |
|
111 | + if (isset($data['thread_title_qualify']) and $data['thread_title_qualify'] != "") { |
|
112 | + $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
|
113 | 113 | } else { |
114 | - $cats[] = array ($data['thread_id'], $data['thread_title']); |
|
114 | + $cats[] = array($data['thread_id'], $data['thread_title']); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | $my_cats = isset($cats) ? $cats : null; |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | if (empty($counter) || $counter <= 2) { |
194 | 194 | return array(0, $assignment['thread_qualify_max']); |
195 | 195 | } |
196 | - return [$score/$counter, $assignment['thread_qualify_max']]; |
|
196 | + return [$score / $counter, $assignment['thread_qualify_max']]; |
|
197 | 197 | } |
198 | 198 | } else { |
199 | 199 | // All students -> get average |
200 | - $students = array(); // user list, needed to make sure we only |
|
200 | + $students = array(); // user list, needed to make sure we only |
|
201 | 201 | // take first attempts into account |
202 | 202 | $counter = 0; |
203 | 203 | $sum = 0; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | return array($bestResult, $weight); |
229 | 229 | break; |
230 | 230 | case 'average': |
231 | - return array($sumResult/$counter, $weight); |
|
231 | + return array($sumResult / $counter, $weight); |
|
232 | 232 | break; |
233 | 233 | case 'ranking': |
234 | 234 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | public function get_name() |
271 | 271 | { |
272 | 272 | $this->get_exercise_data(); |
273 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
273 | + $thread_title = isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | + $thread_title_qualify = isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | + if (isset($thread_title_qualify) && $thread_title_qualify != "") { |
|
276 | 276 | return $this->exercise_data['thread_title_qualify']; |
277 | 277 | } else { |
278 | 278 | return $thread_title; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function get_description() |
286 | 286 | { |
287 | - return '';//$this->exercise_data['description']; |
|
287 | + return ''; //$this->exercise_data['description']; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
311 | 311 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".api_get_session_id().""; |
312 | 312 | $result = Database::query($sql); |
313 | - $row = Database::fetch_array($result,'ASSOC'); |
|
314 | - $forum_id=$row['forum_id']; |
|
313 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
314 | + $forum_id = $row['forum_id']; |
|
315 | 315 | |
316 | 316 | $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?cidReq='.$this->get_course_code().'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
317 | 317 | return $url; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | function save_linked_data() |
344 | 344 | { |
345 | - $weight = (float)$this->get_weight(); |
|
345 | + $weight = (float) $this->get_weight(); |
|
346 | 346 | $ref_id = $this->get_ref_id(); |
347 | 347 | |
348 | 348 | if (!empty($ref_id)) { |
@@ -10,54 +10,54 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class ForumThreadLink extends AbstractLink |
12 | 12 | { |
13 | - private $forum_thread_table = null; |
|
14 | - private $itemprop_table = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_FORUM_THREAD); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function get_type_name() |
|
29 | - { |
|
30 | - return get_lang('ForumThreads'); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function is_allowed_to_change_name() |
|
37 | - { |
|
38 | - return false; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | - */ |
|
45 | - public function get_not_created_links() |
|
46 | - { |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - |
|
51 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | - |
|
53 | - $sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table() |
|
54 | - .' forum_thread WHERE thread_id NOT IN' |
|
55 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
56 | - .' WHERE type = '.LINK_FORUM_THREAD |
|
57 | - ." AND c_id = ".intval($this->course_id) |
|
58 | - .') AND forum_thread.session_id='.api_get_session_id().''; |
|
59 | - |
|
60 | - $result = Database::query($sql); |
|
13 | + private $forum_thread_table = null; |
|
14 | + private $itemprop_table = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_FORUM_THREAD); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function get_type_name() |
|
29 | + { |
|
30 | + return get_lang('ForumThreads'); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function is_allowed_to_change_name() |
|
37 | + { |
|
38 | + return false; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | + */ |
|
45 | + public function get_not_created_links() |
|
46 | + { |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + |
|
51 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | + |
|
53 | + $sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table() |
|
54 | + .' forum_thread WHERE thread_id NOT IN' |
|
55 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
56 | + .' WHERE type = '.LINK_FORUM_THREAD |
|
57 | + ." AND c_id = ".intval($this->course_id) |
|
58 | + .') AND forum_thread.session_id='.api_get_session_id().''; |
|
59 | + |
|
60 | + $result = Database::query($sql); |
|
61 | 61 | |
62 | 62 | $cats = array(); |
63 | 63 | while ($data = Database::fetch_array($result)) { |
@@ -72,29 +72,29 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | return $cats; |
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Generate an array of all exercises available. |
|
79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | - */ |
|
81 | - public function get_all_links() |
|
82 | - { |
|
83 | - if (empty($this->course_code)) { |
|
84 | - die('Error in get_not_created_links() : course code not set'); |
|
85 | - } |
|
86 | - |
|
87 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
89 | - $session_id = api_get_session_id(); |
|
90 | - |
|
91 | - if ($session_id) { |
|
92 | - $session_condition = 'tl.session_id='.api_get_session_id(); |
|
93 | - } else { |
|
94 | - $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
95 | - } |
|
96 | - |
|
97 | - $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Generate an array of all exercises available. |
|
79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | + */ |
|
81 | + public function get_all_links() |
|
82 | + { |
|
83 | + if (empty($this->course_code)) { |
|
84 | + die('Error in get_not_created_links() : course code not set'); |
|
85 | + } |
|
86 | + |
|
87 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
89 | + $session_id = api_get_session_id(); |
|
90 | + |
|
91 | + if ($session_id) { |
|
92 | + $session_condition = 'tl.session_id='.api_get_session_id(); |
|
93 | + } else { |
|
94 | + $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
95 | + } |
|
96 | + |
|
97 | + $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
98 | 98 | FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip |
99 | 99 | ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id ) |
100 | 100 | WHERE |
@@ -105,24 +105,24 @@ discard block |
||
105 | 105 | '.$session_condition.' |
106 | 106 | '; |
107 | 107 | |
108 | - $result = Database::query($sql); |
|
108 | + $result = Database::query($sql); |
|
109 | 109 | |
110 | - while ($data = Database::fetch_array($result)) { |
|
111 | - if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){ |
|
112 | - $cats[] = array ($data['thread_id'], $data['thread_title_qualify']); |
|
113 | - } else { |
|
114 | - $cats[] = array ($data['thread_id'], $data['thread_title']); |
|
115 | - } |
|
116 | - } |
|
117 | - $my_cats = isset($cats) ? $cats : null; |
|
110 | + while ($data = Database::fetch_array($result)) { |
|
111 | + if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){ |
|
112 | + $cats[] = array ($data['thread_id'], $data['thread_title_qualify']); |
|
113 | + } else { |
|
114 | + $cats[] = array ($data['thread_id'], $data['thread_title']); |
|
115 | + } |
|
116 | + } |
|
117 | + $my_cats = isset($cats) ? $cats : null; |
|
118 | 118 | |
119 | - return $my_cats; |
|
120 | - } |
|
119 | + return $my_cats; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | - * Has anyone done this exercise yet ? |
|
124 | - * @return boolean |
|
125 | - */ |
|
123 | + * Has anyone done this exercise yet ? |
|
124 | + * @return boolean |
|
125 | + */ |
|
126 | 126 | public function has_results() |
127 | 127 | { |
128 | 128 | $table = Database :: get_course_table(TABLE_FORUM_POST); |
@@ -134,40 +134,40 @@ discard block |
||
134 | 134 | $number = Database::fetch_row($result); |
135 | 135 | |
136 | 136 | return $number[0] != 0; |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * @param int $stud_id |
|
139 | + /** |
|
140 | + * @param int $stud_id |
|
141 | 141 | * @param string $type |
142 | 142 | * |
143 | - * @return array|null |
|
144 | - */ |
|
145 | - public function calc_score($stud_id = null, $type = null) |
|
146 | - { |
|
143 | + * @return array|null |
|
144 | + */ |
|
145 | + public function calc_score($stud_id = null, $type = null) |
|
146 | + { |
|
147 | 147 | require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
148 | 148 | $threadInfo = get_thread_information($this->get_ref_id()); |
149 | 149 | |
150 | - $thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
150 | + $thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
151 | 151 | |
152 | - $sql = 'SELECT thread_qualify_max |
|
152 | + $sql = 'SELECT thread_qualify_max |
|
153 | 153 | FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)." |
154 | 154 | WHERE c_id = ".$this->course_id." AND thread_id = '".$this->get_ref_id()."'"; |
155 | - $query = Database::query($sql); |
|
156 | - $assignment = Database::fetch_array($query); |
|
155 | + $query = Database::query($sql); |
|
156 | + $assignment = Database::fetch_array($query); |
|
157 | 157 | |
158 | - $sql = "SELECT * FROM $thread_qualify |
|
158 | + $sql = "SELECT * FROM $thread_qualify |
|
159 | 159 | WHERE c_id = ".$this->course_id." AND thread_id = ".$this->get_ref_id(); |
160 | - if (isset($stud_id)) { |
|
161 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
162 | - } |
|
160 | + if (isset($stud_id)) { |
|
161 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
162 | + } |
|
163 | 163 | |
164 | - // order by id, that way the student's first attempt is accessed first |
|
165 | - $sql .= ' ORDER BY qualify_time DESC'; |
|
164 | + // order by id, that way the student's first attempt is accessed first |
|
165 | + $sql .= ' ORDER BY qualify_time DESC'; |
|
166 | 166 | |
167 | - $scores = Database::query($sql); |
|
167 | + $scores = Database::query($sql); |
|
168 | 168 | |
169 | - // for 1 student |
|
170 | - if (isset($stud_id)) { |
|
169 | + // for 1 student |
|
170 | + if (isset($stud_id)) { |
|
171 | 171 | if ($threadInfo['thread_peer_qualify'] == 0) { |
172 | 172 | // Classic way of calculate score |
173 | 173 | if ($data = Database::fetch_array($scores)) { |
@@ -195,175 +195,175 @@ discard block |
||
195 | 195 | } |
196 | 196 | return [$score/$counter, $assignment['thread_qualify_max']]; |
197 | 197 | } |
198 | - } else { |
|
199 | - // All students -> get average |
|
200 | - $students = array(); // user list, needed to make sure we only |
|
201 | - // take first attempts into account |
|
202 | - $counter = 0; |
|
203 | - $sum = 0; |
|
204 | - $bestResult = 0; |
|
205 | - $weight = 0; |
|
206 | - $sumResult = 0; |
|
207 | - |
|
208 | - while ($data = Database::fetch_array($scores)) { |
|
209 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
210 | - if ($assignment['thread_qualify_max'] != 0) { |
|
211 | - $students[$data['user_id']] = $data['qualify']; |
|
212 | - $counter++; |
|
213 | - $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
214 | - $sumResult += $data['qualify']; |
|
215 | - if ($data['qualify'] > $bestResult) { |
|
216 | - $bestResult = $data['qualify']; |
|
217 | - } |
|
218 | - $weight = $assignment['thread_qualify_max']; |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - if ($counter == 0) { |
|
224 | - return null; |
|
225 | - } else { |
|
226 | - switch ($type) { |
|
227 | - case 'best': |
|
228 | - return array($bestResult, $weight); |
|
229 | - break; |
|
230 | - case 'average': |
|
231 | - return array($sumResult/$counter, $weight); |
|
232 | - break; |
|
233 | - case 'ranking': |
|
234 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
235 | - break; |
|
236 | - default: |
|
237 | - return array($sum, $counter); |
|
238 | - break; |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Lazy load function to get the database table of the student publications |
|
246 | - */ |
|
247 | - private function get_forum_thread_table() |
|
248 | - { |
|
249 | - return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
250 | - } |
|
251 | - |
|
252 | - public function needs_name_and_description() |
|
253 | - { |
|
254 | - return false; |
|
255 | - } |
|
256 | - |
|
257 | - public function needs_max() |
|
258 | - { |
|
259 | - return false; |
|
260 | - } |
|
261 | - |
|
262 | - public function needs_results() |
|
263 | - { |
|
264 | - return false; |
|
265 | - } |
|
198 | + } else { |
|
199 | + // All students -> get average |
|
200 | + $students = array(); // user list, needed to make sure we only |
|
201 | + // take first attempts into account |
|
202 | + $counter = 0; |
|
203 | + $sum = 0; |
|
204 | + $bestResult = 0; |
|
205 | + $weight = 0; |
|
206 | + $sumResult = 0; |
|
207 | + |
|
208 | + while ($data = Database::fetch_array($scores)) { |
|
209 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
210 | + if ($assignment['thread_qualify_max'] != 0) { |
|
211 | + $students[$data['user_id']] = $data['qualify']; |
|
212 | + $counter++; |
|
213 | + $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
214 | + $sumResult += $data['qualify']; |
|
215 | + if ($data['qualify'] > $bestResult) { |
|
216 | + $bestResult = $data['qualify']; |
|
217 | + } |
|
218 | + $weight = $assignment['thread_qualify_max']; |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + if ($counter == 0) { |
|
224 | + return null; |
|
225 | + } else { |
|
226 | + switch ($type) { |
|
227 | + case 'best': |
|
228 | + return array($bestResult, $weight); |
|
229 | + break; |
|
230 | + case 'average': |
|
231 | + return array($sumResult/$counter, $weight); |
|
232 | + break; |
|
233 | + case 'ranking': |
|
234 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
235 | + break; |
|
236 | + default: |
|
237 | + return array($sum, $counter); |
|
238 | + break; |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Lazy load function to get the database table of the student publications |
|
246 | + */ |
|
247 | + private function get_forum_thread_table() |
|
248 | + { |
|
249 | + return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
250 | + } |
|
251 | + |
|
252 | + public function needs_name_and_description() |
|
253 | + { |
|
254 | + return false; |
|
255 | + } |
|
256 | + |
|
257 | + public function needs_max() |
|
258 | + { |
|
259 | + return false; |
|
260 | + } |
|
261 | + |
|
262 | + public function needs_results() |
|
263 | + { |
|
264 | + return false; |
|
265 | + } |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * @return string |
269 | 269 | */ |
270 | - public function get_name() |
|
271 | - { |
|
272 | - $this->get_exercise_data(); |
|
273 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
276 | - return $this->exercise_data['thread_title_qualify']; |
|
277 | - } else { |
|
278 | - return $thread_title; |
|
279 | - } |
|
280 | - } |
|
270 | + public function get_name() |
|
271 | + { |
|
272 | + $this->get_exercise_data(); |
|
273 | + $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | + $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | + if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
276 | + return $this->exercise_data['thread_title_qualify']; |
|
277 | + } else { |
|
278 | + return $thread_title; |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - public function get_description() |
|
286 | - { |
|
287 | - return '';//$this->exercise_data['description']; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Check if this still links to an exercise |
|
292 | - */ |
|
293 | - public function is_valid_link() |
|
294 | - { |
|
295 | - $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
285 | + public function get_description() |
|
286 | + { |
|
287 | + return '';//$this->exercise_data['description']; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Check if this still links to an exercise |
|
292 | + */ |
|
293 | + public function is_valid_link() |
|
294 | + { |
|
295 | + $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
296 | 296 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().''; |
297 | - $result = Database::query($sql); |
|
298 | - $number = Database::fetch_row($result); |
|
299 | - return ($number[0] != 0); |
|
300 | - } |
|
301 | - |
|
302 | - public function get_test_id() |
|
303 | - { |
|
304 | - return 'DEBUG:ID'; |
|
305 | - } |
|
306 | - |
|
307 | - public function get_link() |
|
308 | - { |
|
309 | - $sessionId = api_get_session_id(); |
|
310 | - //it was extracts the forum id |
|
311 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
297 | + $result = Database::query($sql); |
|
298 | + $number = Database::fetch_row($result); |
|
299 | + return ($number[0] != 0); |
|
300 | + } |
|
301 | + |
|
302 | + public function get_test_id() |
|
303 | + { |
|
304 | + return 'DEBUG:ID'; |
|
305 | + } |
|
306 | + |
|
307 | + public function get_link() |
|
308 | + { |
|
309 | + $sessionId = api_get_session_id(); |
|
310 | + //it was extracts the forum id |
|
311 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
312 | 312 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId.""; |
313 | - $result = Database::query($sql); |
|
314 | - $row = Database::fetch_array($result,'ASSOC'); |
|
315 | - $forum_id=$row['forum_id']; |
|
316 | - |
|
317 | - $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
318 | - return $url; |
|
319 | - } |
|
320 | - |
|
321 | - private function get_exercise_data() |
|
322 | - { |
|
323 | - $session_id = api_get_session_id(); |
|
324 | - if ($session_id) { |
|
325 | - $session_condition = 'session_id='.api_get_session_id(); |
|
326 | - } else { |
|
327 | - $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
328 | - } |
|
329 | - |
|
330 | - if (!isset($this->exercise_data)) { |
|
331 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
313 | + $result = Database::query($sql); |
|
314 | + $row = Database::fetch_array($result,'ASSOC'); |
|
315 | + $forum_id=$row['forum_id']; |
|
316 | + |
|
317 | + $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
318 | + return $url; |
|
319 | + } |
|
320 | + |
|
321 | + private function get_exercise_data() |
|
322 | + { |
|
323 | + $session_id = api_get_session_id(); |
|
324 | + if ($session_id) { |
|
325 | + $session_condition = 'session_id='.api_get_session_id(); |
|
326 | + } else { |
|
327 | + $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
328 | + } |
|
329 | + |
|
330 | + if (!isset($this->exercise_data)) { |
|
331 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
332 | 332 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND '.$session_condition; |
333 | - $query = Database::query($sql); |
|
334 | - $this->exercise_data = Database::fetch_array($query); |
|
335 | - } |
|
336 | - return $this->exercise_data; |
|
337 | - } |
|
338 | - |
|
339 | - public function get_icon_name() |
|
340 | - { |
|
341 | - return 'forum'; |
|
342 | - } |
|
343 | - |
|
344 | - function save_linked_data() |
|
345 | - { |
|
346 | - $weight = (float)$this->get_weight(); |
|
347 | - $ref_id = $this->get_ref_id(); |
|
348 | - |
|
349 | - if (!empty($ref_id)) { |
|
350 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
333 | + $query = Database::query($sql); |
|
334 | + $this->exercise_data = Database::fetch_array($query); |
|
335 | + } |
|
336 | + return $this->exercise_data; |
|
337 | + } |
|
338 | + |
|
339 | + public function get_icon_name() |
|
340 | + { |
|
341 | + return 'forum'; |
|
342 | + } |
|
343 | + |
|
344 | + function save_linked_data() |
|
345 | + { |
|
346 | + $weight = (float)$this->get_weight(); |
|
347 | + $ref_id = $this->get_ref_id(); |
|
348 | + |
|
349 | + if (!empty($ref_id)) { |
|
350 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
351 | 351 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
352 | - Database::query($sql); |
|
353 | - } |
|
354 | - } |
|
355 | - |
|
356 | - function delete_linked_data() |
|
357 | - { |
|
358 | - $ref_id = $this->get_ref_id(); |
|
359 | - if (!empty($ref_id)) { |
|
360 | - //Cleans forum |
|
361 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
352 | + Database::query($sql); |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + function delete_linked_data() |
|
357 | + { |
|
358 | + $ref_id = $this->get_ref_id(); |
|
359 | + if (!empty($ref_id)) { |
|
360 | + //Cleans forum |
|
361 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
362 | 362 | thread_qualify_max = 0, |
363 | 363 | thread_weight = 0, |
364 | 364 | thread_title_qualify = "" |
365 | 365 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
366 | - Database::query($sql); |
|
367 | - } |
|
368 | - } |
|
366 | + Database::query($sql); |
|
367 | + } |
|
368 | + } |
|
369 | 369 | } |