@@ -2,7 +2,7 @@ |
||
2 | 2 | // $Id: x02.php,v 1.1.8.1 2008/06/12 20:34:31 smk Exp $ |
3 | 3 | |
4 | 4 | return array( |
5 | - 'en' => array('A', 'a', 'A', 'a', 'E', 'e', 'E', 'e', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', |
|
5 | + 'en' => array('A', 'a', 'A', 'a', 'E', 'e', 'E', 'e', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', |
|
6 | 6 | 'R', 'r', 'R', 'r', 'U', 'u', 'U', 'u', 'S', 's', 'T', 't', 'Y', 'y', 'H', 'h', |
7 | 7 | 'N', 'd', 'OU', 'ou', 'Z', 'z', 'A', 'a', 'E', 'e', 'O', 'o', 'O', 'o', 'O', 'o', |
8 | 8 | 'O', 'o', 'Y', 'y', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // $Id: x16.php,v 1.1.8.1 2008/06/12 20:34:31 smk Exp $ |
3 | 3 | |
4 | 4 | return array( |
5 | - 'en' => array('kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo', |
|
5 | + 'en' => array('kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo', |
|
6 | 6 | 'ye', 'yee', 'yi', 'ya', 'ju', 'ju', 'jo', 'je', 'jee', 'ji', 'ji', 'ja', 'jju', 'jjo', 'jje', 'jjee', |
7 | 7 | 'jji', 'jja', 'lu', 'lo', 'le', 'lee', 'li', 'la', 'dlu', 'dlo', 'dle', 'dlee', 'dli', 'dla', 'lhu', 'lho', |
8 | 8 | 'lhe', 'lhee', 'lhi', 'lha', 'tlhu', 'tlho', 'tlhe', 'tlhee', 'tlhi', 'tlha', 'tlu', 'tlo', 'tle', 'tlee', 'tli', 'tla', |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // $Id: x6c.php,v 1.1.8.1 2008/06/12 20:34:31 smk Exp $ |
3 | 3 | |
4 | 4 | return array( |
5 | - 'en' => array('Lu ', 'Mu ', 'Li ', 'Tong ', 'Rong ', 'Chang ', 'Pu ', 'Luo ', 'Zhan ', 'Sao ', 'Zhan ', 'Meng ', 'Luo ', 'Qu ', 'Die ', 'Shi ', |
|
5 | + 'en' => array('Lu ', 'Mu ', 'Li ', 'Tong ', 'Rong ', 'Chang ', 'Pu ', 'Luo ', 'Zhan ', 'Sao ', 'Zhan ', 'Meng ', 'Luo ', 'Qu ', 'Die ', 'Shi ', |
|
6 | 6 | 'Di ', 'Min ', 'Jue ', 'Mang ', 'Qi ', 'Pie ', 'Nai ', 'Qi ', 'Dao ', 'Xian ', 'Chuan ', 'Fen ', 'Ri ', 'Nei ', NULL, 'Fu ', |
7 | 7 | 'Shen ', 'Dong ', 'Qing ', 'Qi ', 'Yin ', 'Xi ', 'Hai ', 'Yang ', 'An ', 'Ya ', 'Ke ', 'Qing ', 'Ya ', 'Dong ', 'Dan ', 'Lu ', |
8 | 8 | 'Qing ', 'Yang ', 'Yun ', 'Yun ', 'Shui ', 'San ', 'Zheng ', 'Bing ', 'Yong ', 'Dang ', 'Shitamizu ', 'Le ', 'Ni ', 'Tun ', 'Fan ', 'Gui ', |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // $Id: xb8.php,v 1.1.8.1 2008/06/12 20:34:32 smk Exp $ |
3 | 3 | |
4 | 4 | return array( |
5 | - 'en' => array('reoss', 'reong', 'reoj', 'reoc', 'reok', 'reot', 'reop', 'reoh', 're', 'reg', 'regg', 'regs', 'ren', 'renj', 'renh', 'red', |
|
5 | + 'en' => array('reoss', 'reong', 'reoj', 'reoc', 'reok', 'reot', 'reop', 'reoh', 're', 'reg', 'regg', 'regs', 'ren', 'renj', 'renh', 'red', |
|
6 | 6 | 'rel', 'relg', 'relm', 'relb', 'rels', 'relt', 'relp', 'relh', 'rem', 'reb', 'rebs', 'res', 'ress', 'reng', 'rej', 'rec', |
7 | 7 | 'rek', 'ret', 'rep', 'reh', 'ryeo', 'ryeog', 'ryeogg', 'ryeogs', 'ryeon', 'ryeonj', 'ryeonh', 'ryeod', 'ryeol', 'ryeolg', 'ryeolm', 'ryeolb', |
8 | 8 | 'ryeols', 'ryeolt', 'ryeolp', 'ryeolh', 'ryeom', 'ryeob', 'ryeobs', 'ryeos', 'ryeoss', 'ryeong', 'ryeoj', 'ryeoc', 'ryeok', 'ryeot', 'ryeop', 'ryeoh', |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // $Id: xbd.php,v 1.1.8.1 2008/06/12 20:34:32 smk Exp $ |
3 | 3 | |
4 | 4 | return array( |
5 | - 'en' => array('bols', 'bolt', 'bolp', 'bolh', 'bom', 'bob', 'bobs', 'bos', 'boss', 'bong', 'boj', 'boc', 'bok', 'bot', 'bop', 'boh', |
|
5 | + 'en' => array('bols', 'bolt', 'bolp', 'bolh', 'bom', 'bob', 'bobs', 'bos', 'boss', 'bong', 'boj', 'boc', 'bok', 'bot', 'bop', 'boh', |
|
6 | 6 | 'bwa', 'bwag', 'bwagg', 'bwags', 'bwan', 'bwanj', 'bwanh', 'bwad', 'bwal', 'bwalg', 'bwalm', 'bwalb', 'bwals', 'bwalt', 'bwalp', 'bwalh', |
7 | 7 | 'bwam', 'bwab', 'bwabs', 'bwas', 'bwass', 'bwang', 'bwaj', 'bwac', 'bwak', 'bwat', 'bwap', 'bwah', 'bwae', 'bwaeg', 'bwaegg', 'bwaegs', |
8 | 8 | 'bwaen', 'bwaenj', 'bwaenh', 'bwaed', 'bwael', 'bwaelg', 'bwaelm', 'bwaelb', 'bwaels', 'bwaelt', 'bwaelp', 'bwaelh', 'bwaem', 'bwaeb', 'bwaebs', 'bwaes', |
@@ -18,30 +18,30 @@ discard block |
||
18 | 18 | if (api_is_student() && !api_get_setting('student_page_after_login') == '') { |
19 | 19 | $redirect_url = html_entity_decode(api_get_setting('student_page_after_login')); |
20 | 20 | if ($redirect_url[0] == "/") { |
21 | - $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; |
|
21 | + $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') { |
25 | 25 | $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login')); |
26 | 26 | if ($redirect_url[0] == "/") { |
27 | - $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; |
|
27 | + $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') { |
31 | 31 | $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login')); |
32 | 32 | if ($redirect_url[0] == "/") { |
33 | - $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; |
|
33 | + $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') { |
37 | 37 | $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login')); |
38 | 38 | if ($redirect_url[0] == "/") { |
39 | - $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; |
|
39 | + $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | 43 | if (!empty($redirect_url)) { |
44 | - header('Location: ' . $redirect_url . $param); |
|
44 | + header('Location: '.$redirect_url.$param); |
|
45 | 45 | exit(); |
46 | 46 | } |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (CustomPages::enabled()) { |
50 | 50 | CustomPages::display(CustomPages::INDEX_LOGGED); |
51 | 51 | } |
52 | - header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param); |
|
52 | + header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param); |
|
53 | 53 | exit(); |
54 | 54 | } |
55 | 55 | } |
@@ -6022,7 +6022,7 @@ |
||
6022 | 6022 | ]); |
6023 | 6023 | } |
6024 | 6024 | |
6025 | - /** |
|
6025 | + /** |
|
6026 | 6026 | * Get the count of user courses in session |
6027 | 6027 | * @param int $sessionId The session id |
6028 | 6028 | * @return array |
@@ -1588,8 +1588,10 @@ discard block |
||
1588 | 1588 | if (empty($session_visibility)) { |
1589 | 1589 | $session_visibility = $session->getVisibility(); |
1590 | 1590 | //default status loaded if empty |
1591 | - if (empty($session_visibility)) |
|
1592 | - $session_visibility = SESSION_VISIBLE_READ_ONLY; // by default readonly 1 |
|
1591 | + if (empty($session_visibility)) { |
|
1592 | + $session_visibility = SESSION_VISIBLE_READ_ONLY; |
|
1593 | + } |
|
1594 | + // by default readonly 1 |
|
1593 | 1595 | } else { |
1594 | 1596 | if (!in_array($session_visibility, array(SESSION_VISIBLE_READ_ONLY, SESSION_VISIBLE, SESSION_INVISIBLE))) { |
1595 | 1597 | $session_visibility = SESSION_VISIBLE_READ_ONLY; |
@@ -2792,10 +2794,11 @@ discard block |
||
2792 | 2794 | c_id = $courseId AND |
2793 | 2795 | user_id = $user_id "; |
2794 | 2796 | $result = Database::query($sql); |
2795 | - if (Database::affected_rows($result) > 0) |
|
2796 | - return true; |
|
2797 | - else |
|
2798 | - return false; |
|
2797 | + if (Database::affected_rows($result) > 0) { |
|
2798 | + return true; |
|
2799 | + } else { |
|
2800 | + return false; |
|
2801 | + } |
|
2799 | 2802 | } else { |
2800 | 2803 | // The user is not subscribed to the session, so make sure |
2801 | 2804 | // he isn't subscribed to a course in this session either |
@@ -2806,10 +2809,11 @@ discard block |
||
2806 | 2809 | c_id = $courseId AND |
2807 | 2810 | user_id = $user_id "; |
2808 | 2811 | $result = Database::query($sql); |
2809 | - if (Database::affected_rows($result) > 0) |
|
2810 | - return true; |
|
2811 | - else |
|
2812 | - return false; |
|
2812 | + if (Database::affected_rows($result) > 0) { |
|
2813 | + return true; |
|
2814 | + } else { |
|
2815 | + return false; |
|
2816 | + } |
|
2813 | 2817 | } |
2814 | 2818 | } else { |
2815 | 2819 | // Assign user as a coach to course |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | return $msg; |
144 | 144 | } |
145 | 145 | } else { |
146 | - $rs = Database::query("SELECT 1 FROM $tbl_session WHERE name='" . $name . "'"); |
|
146 | + $rs = Database::query("SELECT 1 FROM $tbl_session WHERE name='".$name."'"); |
|
147 | 147 | if (Database::num_rows($rs)) { |
148 | 148 | $msg = get_lang('SessionNameAlreadyExists'); |
149 | 149 | return $msg; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | public static function session_name_exists($name) |
257 | 257 | { |
258 | 258 | $name = Database::escape_string($name); |
259 | - $sql = "SELECT COUNT(*) as count FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . " |
|
259 | + $sql = "SELECT COUNT(*) as count FROM ".Database::get_main_table(TABLE_MAIN_SESSION)." |
|
260 | 260 | WHERE name = '$name'"; |
261 | 261 | $result = Database::fetch_array(Database::query($sql)); |
262 | 262 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $where .= " AND ( |
288 | 288 | s.session_admin_id = $user_id OR |
289 | 289 | sru.user_id = '$user_id' AND |
290 | - sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' |
|
290 | + sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' |
|
291 | 291 | ) |
292 | 292 | "; |
293 | 293 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $where_condition = str_replace('category_name', 'sc.name', $where_condition); |
306 | 306 | $where_condition = str_replace( |
307 | 307 | array("AND session_active = '1' )", " AND ( session_active = '1' )"), |
308 | - array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " ) |
|
308 | + array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ") |
|
309 | 309 | , $where_condition |
310 | 310 | ); |
311 | 311 | $where_condition = str_replace( |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $access_url_id = api_get_current_access_url_id(); |
352 | 352 | if ($access_url_id != -1) { |
353 | - $where.= " AND ar.access_url_id = $access_url_id "; |
|
353 | + $where .= " AND ar.access_url_id = $access_url_id "; |
|
354 | 354 | |
355 | 355 | $sql = "SELECT count(id) as total_rows FROM ( |
356 | 356 | SELECT DISTINCT |
@@ -400,14 +400,14 @@ discard block |
||
400 | 400 | if (api_is_session_admin() && |
401 | 401 | api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false' |
402 | 402 | ) { |
403 | - $where .=" AND s.session_admin_id = $user_id "; |
|
403 | + $where .= " AND s.session_admin_id = $user_id "; |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | 407 | if (!api_is_platform_admin() && api_is_teacher() && |
408 | 408 | api_get_setting('allow_teachers_to_create_sessions') == 'true' |
409 | 409 | ) { |
410 | - $where .=" AND s.id_coach = $user_id "; |
|
410 | + $where .= " AND s.id_coach = $user_id "; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | $extra_field = new ExtraField('session'); |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | $query = "$select FROM $tbl_session s $inject_joins $where $inject_where"; |
458 | 458 | |
459 | 459 | if (api_is_multiple_url_enabled()) { |
460 | - $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
460 | + $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
461 | 461 | $access_url_id = api_get_current_access_url_id(); |
462 | 462 | if ($access_url_id != -1) { |
463 | - $where.= " AND ar.access_url_id = $access_url_id "; |
|
463 | + $where .= " AND ar.access_url_id = $access_url_id "; |
|
464 | 464 | $query = "$select |
465 | 465 | FROM $tbl_session s $inject_joins |
466 | 466 | INNER JOIN $table_access_url_rel_session ar |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | INNER JOIN $tbl_lp l ON l.id = v.lp_id |
565 | 565 | INNER JOIN $tbl_user u ON u.user_id = v.user_id |
566 | 566 | INNER JOIN $tbl_course c |
567 | - WHERE v.session_id = " . $sessionId; |
|
567 | + WHERE v.session_id = ".$sessionId; |
|
568 | 568 | $result_rows = Database::query($sql); |
569 | 569 | $row = Database::fetch_array($result_rows); |
570 | 570 | $num = $row['total_rows']; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | |
617 | 617 | $limit = null; |
618 | 618 | if (!empty($options['limit'])) { |
619 | - $limit = " LIMIT " . $options['limit']; |
|
619 | + $limit = " LIMIT ".$options['limit']; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | if (!empty($options['where'])) { |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | $order = null; |
627 | 627 | if (!empty($options['order'])) { |
628 | - $order = " ORDER BY " . $options['order']; |
|
628 | + $order = " ORDER BY ".$options['order']; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id |
@@ -684,13 +684,13 @@ discard block |
||
684 | 684 | foreach ($lessons as $lesson) { |
685 | 685 | $data[$lesson['id']] = (!empty($user_lessons[$lesson['id']]['progress'])) ? $user_lessons[$lesson['id']]['progress'] : 0; |
686 | 686 | $progress += $data[$lesson['id']]; |
687 | - $data[$lesson['id']] = $data[$lesson['id']] . '%'; |
|
687 | + $data[$lesson['id']] = $data[$lesson['id']].'%'; |
|
688 | 688 | $count++; |
689 | 689 | } |
690 | 690 | if ($count == 0) { |
691 | 691 | $data['total'] = 0; |
692 | 692 | } else { |
693 | - $data['total'] = round($progress / $count, 2) . '%'; |
|
693 | + $data['total'] = round($progress / $count, 2).'%'; |
|
694 | 694 | } |
695 | 695 | $table[] = $data; |
696 | 696 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | |
732 | 732 | $limit = null; |
733 | 733 | if (!empty($options['limit'])) { |
734 | - $limit = " LIMIT " . $options['limit']; |
|
734 | + $limit = " LIMIT ".$options['limit']; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | if (!empty($options['where'])) { |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | |
741 | 741 | $order = null; |
742 | 742 | if (!empty($options['order'])) { |
743 | - $order = " ORDER BY " . $options['order']; |
|
743 | + $order = " ORDER BY ".$options['order']; |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | |
843 | 843 | $limit = null; |
844 | 844 | if (!empty($options['limit'])) { |
845 | - $limit = " LIMIT " . $options['limit']; |
|
845 | + $limit = " LIMIT ".$options['limit']; |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | if (!empty($options['where'])) { |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | $order = null; |
853 | 853 | if (!empty($options['order'])) { |
854 | - $order = " ORDER BY " . $options['order']; |
|
854 | + $order = " ORDER BY ".$options['order']; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | //TODO, fix create report without session |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | /** |
885 | 885 | * Lessons |
886 | 886 | */ |
887 | - $sql = "SELECT * FROM $tbl_course_lp WHERE c_id = %s "; //AND session_id = %s |
|
887 | + $sql = "SELECT * FROM $tbl_course_lp WHERE c_id = %s "; //AND session_id = %s |
|
888 | 888 | $sql_query = sprintf($sql, $course['real_id']); |
889 | 889 | $result = Database::query($sql_query); |
890 | 890 | $arrLesson = array(array()); |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | if (empty($arrLesson[$row['session_id']]['lessons_total'])) { |
893 | 893 | $arrLesson[$row['session_id']]['lessons_total'] = 1; |
894 | 894 | } else { |
895 | - $arrLesson[$row['session_id']]['lessons_total'] ++; |
|
895 | + $arrLesson[$row['session_id']]['lessons_total']++; |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | $course['real_id'] |
960 | 960 | ); |
961 | 961 | foreach ($user_list as $user_id) { |
962 | - isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id] ++ : $survey_user_list[$user_id] = 1; |
|
962 | + isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : $survey_user_list[$user_id] = 1; |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $assignments_done = Tracking::count_student_assignments($user['user_id'], $course['code'], $user['id_session']); |
1014 | 1014 | $assignments_left = $assignments_total - $assignments_done; |
1015 | 1015 | if (!empty($assignments_total)) { |
1016 | - $assignments_progress = round((( $assignments_done * 100 ) / $assignments_total), 2); |
|
1016 | + $assignments_progress = round((($assignments_done * 100) / $assignments_total), 2); |
|
1017 | 1017 | } else { |
1018 | 1018 | $assignments_progress = 0; |
1019 | 1019 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $wiki_read = $row['count']; |
1044 | 1044 | $wiki_unread = $wiki_total - $wiki_read; |
1045 | 1045 | if (!empty($wiki_total)) { |
1046 | - $wiki_progress = round((( $wiki_read * 100 ) / $wiki_total), 2); |
|
1046 | + $wiki_progress = round((($wiki_read * 100) / $wiki_total), 2); |
|
1047 | 1047 | } else { |
1048 | 1048 | $wiki_progress = 0; |
1049 | 1049 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | $surveys_done = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0); |
1053 | 1053 | $surveys_left = $surveys_total - $surveys_done; |
1054 | 1054 | if (!empty($surveys_total)) { |
1055 | - $surveys_progress = round((( $surveys_done * 100 ) / $surveys_total), 2); |
|
1055 | + $surveys_progress = round((($surveys_done * 100) / $surveys_total), 2); |
|
1056 | 1056 | } else { |
1057 | 1057 | $surveys_progress = 0; |
1058 | 1058 | } |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | ); |
1066 | 1066 | $forums_left = $forums_total - $forums_done; |
1067 | 1067 | if (!empty($forums_total)) { |
1068 | - $forums_progress = round((( $forums_done * 100 ) / $forums_total), 2); |
|
1068 | + $forums_progress = round((($forums_done * 100) / $forums_total), 2); |
|
1069 | 1069 | } else { |
1070 | 1070 | $forums_progress = 0; |
1071 | 1071 | } |
@@ -1073,58 +1073,58 @@ discard block |
||
1073 | 1073 | //Overall Total |
1074 | 1074 | $overall_total = ($course_description_progress + $exercises_progress + $forums_progress + $assignments_progress + $wiki_progress + $surveys_progress) / 6; |
1075 | 1075 | |
1076 | - $link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $user[0] . '&details=true&course=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>'; |
|
1077 | - $linkForum = '<a href="' . api_get_path(WEB_CODE_PATH) . 'forum/index.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>'; |
|
1078 | - $linkWork = '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>'; |
|
1079 | - $linkWiki = '<a href="' . api_get_path(WEB_CODE_PATH) . 'wiki/index.php?cidReq=' . $course['code'] . '&session_id=' . $user['id_session'] . '&action=statistics"> %s </a>'; |
|
1080 | - $linkSurvey = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>'; |
|
1076 | + $link = '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$user[0].'&details=true&course='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>'; |
|
1077 | + $linkForum = '<a href="'.api_get_path(WEB_CODE_PATH).'forum/index.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>'; |
|
1078 | + $linkWork = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>'; |
|
1079 | + $linkWiki = '<a href="'.api_get_path(WEB_CODE_PATH).'wiki/index.php?cidReq='.$course['code'].'&session_id='.$user['id_session'].'&action=statistics"> %s </a>'; |
|
1080 | + $linkSurvey = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>'; |
|
1081 | 1081 | |
1082 | 1082 | $table[] = array( |
1083 | 1083 | 'lastname' => $user[1], |
1084 | 1084 | 'firstname' => $user[2], |
1085 | 1085 | 'username' => $user[3], |
1086 | 1086 | #'profile' => '', |
1087 | - 'total' => round($overall_total, 2) . '%', |
|
1088 | - 'courses' => sprintf($link, $course_description_progress . '%'), |
|
1089 | - 'lessons' => sprintf($link, $lessons_progress . '%'), |
|
1090 | - 'exercises' => sprintf($link, $exercises_progress . '%'), |
|
1091 | - 'forums' => sprintf($link, $forums_progress . '%'), |
|
1092 | - 'homeworks' => sprintf($link, $assignments_progress . '%'), |
|
1093 | - 'wikis' => sprintf($link, $wiki_progress . '%'), |
|
1094 | - 'surveys' => sprintf($link, $surveys_progress . '%'), |
|
1087 | + 'total' => round($overall_total, 2).'%', |
|
1088 | + 'courses' => sprintf($link, $course_description_progress.'%'), |
|
1089 | + 'lessons' => sprintf($link, $lessons_progress.'%'), |
|
1090 | + 'exercises' => sprintf($link, $exercises_progress.'%'), |
|
1091 | + 'forums' => sprintf($link, $forums_progress.'%'), |
|
1092 | + 'homeworks' => sprintf($link, $assignments_progress.'%'), |
|
1093 | + 'wikis' => sprintf($link, $wiki_progress.'%'), |
|
1094 | + 'surveys' => sprintf($link, $surveys_progress.'%'), |
|
1095 | 1095 | //course description |
1096 | - 'course_description_progress' => $course_description_progress . '%', |
|
1096 | + 'course_description_progress' => $course_description_progress.'%', |
|
1097 | 1097 | //lessons |
1098 | 1098 | 'lessons_total' => sprintf($link, $lessons_total), |
1099 | 1099 | 'lessons_done' => sprintf($link, $lessons_done), |
1100 | 1100 | 'lessons_left' => sprintf($link, $lessons_left), |
1101 | - 'lessons_progress' => sprintf($link, $lessons_progress . '%'), |
|
1101 | + 'lessons_progress' => sprintf($link, $lessons_progress.'%'), |
|
1102 | 1102 | //exercises |
1103 | 1103 | 'exercises_total' => sprintf($link, $exercises_total), |
1104 | 1104 | 'exercises_done' => sprintf($link, $exercises_done), |
1105 | 1105 | 'exercises_left' => sprintf($link, $exercises_left), |
1106 | - 'exercises_progress' => sprintf($link, $exercises_progress . '%'), |
|
1106 | + 'exercises_progress' => sprintf($link, $exercises_progress.'%'), |
|
1107 | 1107 | //forums |
1108 | 1108 | 'forums_total' => sprintf($linkForum, $forums_total), |
1109 | 1109 | 'forums_done' => sprintf($linkForum, $forums_done), |
1110 | 1110 | 'forums_left' => sprintf($linkForum, $forums_left), |
1111 | - 'forums_progress' => sprintf($linkForum, $forums_progress . '%'), |
|
1111 | + 'forums_progress' => sprintf($linkForum, $forums_progress.'%'), |
|
1112 | 1112 | //assignments |
1113 | 1113 | 'assignments_total' => sprintf($linkWork, $assignments_total), |
1114 | 1114 | 'assignments_done' => sprintf($linkWork, $assignments_done), |
1115 | 1115 | 'assignments_left' => sprintf($linkWork, $assignments_left), |
1116 | - 'assignments_progress' => sprintf($linkWork, $assignments_progress . '%'), |
|
1116 | + 'assignments_progress' => sprintf($linkWork, $assignments_progress.'%'), |
|
1117 | 1117 | //wiki |
1118 | 1118 | 'wiki_total' => sprintf($linkWiki, $wiki_total), |
1119 | 1119 | 'wiki_revisions' => sprintf($linkWiki, $wiki_revisions), |
1120 | 1120 | 'wiki_read' => sprintf($linkWiki, $wiki_read), |
1121 | 1121 | 'wiki_unread' => sprintf($linkWiki, $wiki_unread), |
1122 | - 'wiki_progress' => sprintf($linkWiki, $wiki_progress . '%'), |
|
1122 | + 'wiki_progress' => sprintf($linkWiki, $wiki_progress.'%'), |
|
1123 | 1123 | //survey |
1124 | 1124 | 'surveys_total' => sprintf($linkSurvey, $surveys_total), |
1125 | 1125 | 'surveys_done' => sprintf($linkSurvey, $surveys_done), |
1126 | 1126 | 'surveys_left' => sprintf($linkSurvey, $surveys_left), |
1127 | - 'surveys_progress' => sprintf($linkSurvey, $surveys_progress . '%'), |
|
1127 | + 'surveys_progress' => sprintf($linkSurvey, $surveys_progress.'%'), |
|
1128 | 1128 | ); |
1129 | 1129 | } |
1130 | 1130 | |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | |
1205 | 1205 | $limit = null; |
1206 | 1206 | if (!empty($options['limit'])) { |
1207 | - $limit = " LIMIT " . $options['limit']; |
|
1207 | + $limit = " LIMIT ".$options['limit']; |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | if (!empty($options['where'])) { |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | $order = null; |
1215 | 1215 | if (!empty($options['order'])) { |
1216 | - $order = " ORDER BY " . $options['order']; |
|
1216 | + $order = " ORDER BY ".$options['order']; |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | //TODO add course name |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | " : " |
1227 | 1227 | u.lastname, |
1228 | 1228 | u.firstname, |
1229 | - ") . " |
|
1229 | + ")." |
|
1230 | 1230 | a.logout_course_date, |
1231 | 1231 | a.counter, |
1232 | 1232 | c.title, |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | if (Database::num_rows($result) > 0) { |
1309 | 1309 | $row = Database::fetch_array($result); |
1310 | 1310 | $count = $row['count'] + 1; |
1311 | - $session_name = $session_name . '_' . $count; |
|
1311 | + $session_name = $session_name.'_'.$count; |
|
1312 | 1312 | $result = self::session_name_exists($session_name); |
1313 | 1313 | if (!$result) { |
1314 | 1314 | return $session_name; |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | return false; |
1390 | 1390 | } else { |
1391 | - $sql = "SELECT id FROM $tbl_session WHERE name='" . Database::escape_string($name) . "'"; |
|
1391 | + $sql = "SELECT id FROM $tbl_session WHERE name='".Database::escape_string($name)."'"; |
|
1392 | 1392 | $rs = Database::query($sql); |
1393 | 1393 | $exists = false; |
1394 | 1394 | while ($row = Database::fetch_array($rs)) { |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | // Delete users from the session |
1755 | 1755 | if ($empty_users === true) { |
1756 | 1756 | $sql = "DELETE FROM $tbl_session_rel_user |
1757 | - WHERE session_id = $id_session AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; |
|
1757 | + WHERE session_id = $id_session AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; |
|
1758 | 1758 | Database::query($sql); |
1759 | 1759 | } |
1760 | 1760 | |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | $enreg_user = Database::escape_string($enreg_user); |
1766 | 1766 | $nbr_users++; |
1767 | 1767 | $sql = "INSERT IGNORE INTO $tbl_session_rel_user (relation_type, session_id, user_id, registered_at) |
1768 | - VALUES (0, $id_session, $enreg_user, '" . api_get_utc_datetime() . "')"; |
|
1768 | + VALUES (0, $id_session, $enreg_user, '".api_get_utc_datetime()."')"; |
|
1769 | 1769 | Database::query($sql); |
1770 | 1770 | } |
1771 | 1771 | |
@@ -1855,9 +1855,9 @@ discard block |
||
1855 | 1855 | is_array($courseInfo) ? $courseId = $courseInfo['real_id'] : $courseId = $courseInfo; |
1856 | 1856 | |
1857 | 1857 | $statusCondition = null; |
1858 | - if (isset($status) && !is_null($status)) { |
|
1858 | + if (isset($status) && !is_null($status)) { |
|
1859 | 1859 | $status = intval($status); |
1860 | - $statusCondition = " AND status = $status"; |
|
1860 | + $statusCondition = " AND status = $status"; |
|
1861 | 1861 | } |
1862 | 1862 | |
1863 | 1863 | foreach ($userList as $userId) { |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | if (empty($count)) { |
1990 | 1990 | // If user is not registered to a session then add it. |
1991 | 1991 | $sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id, registered_at) |
1992 | - VALUES ($session_id, $enreg_user, '" . api_get_utc_datetime() . "')"; |
|
1992 | + VALUES ($session_id, $enreg_user, '".api_get_utc_datetime()."')"; |
|
1993 | 1993 | Database::query($sql); |
1994 | 1994 | |
1995 | 1995 | $sql = "UPDATE $tbl_session SET nbr_users = nbr_users + 1 |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | WHERE |
2033 | 2033 | session_id = $session_id AND |
2034 | 2034 | user_id = $user_id AND |
2035 | - relation_type <> " . SESSION_RELATION_TYPE_RRHH . ""; |
|
2035 | + relation_type <> ".SESSION_RELATION_TYPE_RRHH.""; |
|
2036 | 2036 | $result = Database::query($delete_sql); |
2037 | 2037 | $return = Database::affected_rows($result); |
2038 | 2038 | |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | FROM $tbl_session_rel_user |
2117 | 2117 | WHERE |
2118 | 2118 | session_id = $sessionId AND |
2119 | - relation_type<>" . SESSION_RELATION_TYPE_RRHH; |
|
2119 | + relation_type<>".SESSION_RELATION_TYPE_RRHH; |
|
2120 | 2120 | $result = Database::query($sql); |
2121 | 2121 | $user_list = Database::store_result($result); |
2122 | 2122 | |
@@ -2128,7 +2128,7 @@ discard block |
||
2128 | 2128 | |
2129 | 2129 | $sql = "DELETE FROM $tbl_session_rel_course |
2130 | 2130 | WHERE |
2131 | - c_id = " . $existingCourse['c_id'] . " AND |
|
2131 | + c_id = ".$existingCourse['c_id']." AND |
|
2132 | 2132 | session_id = $sessionId"; |
2133 | 2133 | Database::query($sql); |
2134 | 2134 | |
@@ -2191,7 +2191,7 @@ discard block |
||
2191 | 2191 | $links = $cat->get_links(null, false, $courseInfo['code'], 0); |
2192 | 2192 | |
2193 | 2193 | $cat->set_session_id($sessionId); |
2194 | - $oldCategoryId= $cat->get_id(); |
|
2194 | + $oldCategoryId = $cat->get_id(); |
|
2195 | 2195 | $newId = $cat->add(); |
2196 | 2196 | $newCategoryIdList[$oldCategoryId] = $newId; |
2197 | 2197 | |
@@ -2379,8 +2379,8 @@ discard block |
||
2379 | 2379 | $return_value = false; |
2380 | 2380 | $sql = "SELECT c_id FROM $tbl_session_course |
2381 | 2381 | WHERE |
2382 | - session_id = " . intval($session_id) . " AND |
|
2383 | - c_id = " . intval($courseId) . ""; |
|
2382 | + session_id = ".intval($session_id)." AND |
|
2383 | + c_id = " . intval($courseId).""; |
|
2384 | 2384 | $result = Database::query($sql); |
2385 | 2385 | $num = Database::num_rows($result); |
2386 | 2386 | if ($num > 0) { |
@@ -2403,8 +2403,8 @@ discard block |
||
2403 | 2403 | } |
2404 | 2404 | |
2405 | 2405 | $sql = 'SELECT * |
2406 | - FROM ' . $tbl_session . ' |
|
2407 | - WHERE name = "' . Database::escape_string($session_name) . '"'; |
|
2406 | + FROM ' . $tbl_session.' |
|
2407 | + WHERE name = "' . Database::escape_string($session_name).'"'; |
|
2408 | 2408 | $result = Database::query($sql); |
2409 | 2409 | $num = Database::num_rows($result); |
2410 | 2410 | if ($num > 0) { |
@@ -2444,8 +2444,8 @@ discard block |
||
2444 | 2444 | $month_end = intval($smonth_end); |
2445 | 2445 | $day_end = intval($sday_end); |
2446 | 2446 | |
2447 | - $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start); |
|
2448 | - $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end); |
|
2447 | + $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start); |
|
2448 | + $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end); |
|
2449 | 2449 | |
2450 | 2450 | if (empty($name)) { |
2451 | 2451 | $msg = get_lang('SessionCategoryNameIsRequired'); |
@@ -2517,8 +2517,8 @@ discard block |
||
2517 | 2517 | $month_end = intval($smonth_end); |
2518 | 2518 | $day_end = intval($sday_end); |
2519 | 2519 | $id = intval($id); |
2520 | - $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start); |
|
2521 | - $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end); |
|
2520 | + $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start); |
|
2521 | + $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end); |
|
2522 | 2522 | |
2523 | 2523 | if (empty($name)) { |
2524 | 2524 | $msg = get_lang('SessionCategoryNameIsRequired'); |
@@ -2538,13 +2538,13 @@ discard block |
||
2538 | 2538 | if ($date_end <> null) { |
2539 | 2539 | $sql = "UPDATE $tbl_session_category |
2540 | 2540 | SET |
2541 | - name = '" . Database::escape_string($name) . "', |
|
2541 | + name = '".Database::escape_string($name)."', |
|
2542 | 2542 | date_start = '$date_start' , |
2543 | 2543 | date_end = '$date_end' |
2544 | 2544 | WHERE id= $id"; |
2545 | 2545 | } else { |
2546 | 2546 | $sql = "UPDATE $tbl_session_category SET |
2547 | - name = '" . Database::escape_string($name) . "', |
|
2547 | + name = '".Database::escape_string($name)."', |
|
2548 | 2548 | date_start = '$date_start', |
2549 | 2549 | date_end = NULL |
2550 | 2550 | WHERE id= $id"; |
@@ -2574,10 +2574,10 @@ discard block |
||
2574 | 2574 | |
2575 | 2575 | //Setting session_category_id to 0 |
2576 | 2576 | $sql = "UPDATE $tbl_session SET session_category_id = 0 |
2577 | - WHERE session_category_id IN (" . $id_checked . ")"; |
|
2577 | + WHERE session_category_id IN (".$id_checked.")"; |
|
2578 | 2578 | Database::query($sql); |
2579 | 2579 | |
2580 | - $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (" . $id_checked . ")"; |
|
2580 | + $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")"; |
|
2581 | 2581 | $result = Database::query($sql); |
2582 | 2582 | while ($rows = Database::fetch_array($result)) { |
2583 | 2583 | $session_id = $rows['id']; |
@@ -2589,7 +2589,7 @@ discard block |
||
2589 | 2589 | } |
2590 | 2590 | } |
2591 | 2591 | } |
2592 | - $sql = "DELETE FROM $tbl_session_category WHERE id IN (" . $id_checked . ")"; |
|
2592 | + $sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")"; |
|
2593 | 2593 | Database::query($sql); |
2594 | 2594 | |
2595 | 2595 | // Add event to system log |
@@ -2662,7 +2662,7 @@ discard block |
||
2662 | 2662 | $value = Database::escape_string($options['value']); |
2663 | 2663 | $sql_query .= ' AND '; |
2664 | 2664 | if (in_array($field, $availableFields) && in_array($operator, $availableOperator)) { |
2665 | - $sql_query .= $field . " $operator '" . $value . "'"; |
|
2665 | + $sql_query .= $field." $operator '".$value."'"; |
|
2666 | 2666 | } |
2667 | 2667 | } |
2668 | 2668 | } |
@@ -2729,8 +2729,8 @@ discard block |
||
2729 | 2729 | { |
2730 | 2730 | $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); |
2731 | 2731 | $id = api_get_current_access_url_id(); |
2732 | - $sql = 'SELECT * FROM ' . $tbl_session_category . ' |
|
2733 | - WHERE access_url_id = ' . $id . ' |
|
2732 | + $sql = 'SELECT * FROM '.$tbl_session_category.' |
|
2733 | + WHERE access_url_id = ' . $id.' |
|
2734 | 2734 | ORDER BY name ASC'; |
2735 | 2735 | $result = Database::query($sql); |
2736 | 2736 | if (Database::num_rows($result) > 0) { |
@@ -2909,11 +2909,11 @@ discard block |
||
2909 | 2909 | INNER JOIN $tbl_session_rel_access_url a ON (a.session_id = s.session_id) |
2910 | 2910 | WHERE |
2911 | 2911 | s.user_id = $userId AND |
2912 | - relation_type=" . SESSION_RELATION_TYPE_RRHH . " AND |
|
2913 | - access_url_id = " . api_get_current_access_url_id() . ""; |
|
2912 | + relation_type=".SESSION_RELATION_TYPE_RRHH." AND |
|
2913 | + access_url_id = " . api_get_current_access_url_id().""; |
|
2914 | 2914 | } else { |
2915 | 2915 | $sql = "SELECT session_id FROM $tbl_session_rel_user s |
2916 | - WHERE user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . ""; |
|
2916 | + WHERE user_id = $userId AND relation_type=".SESSION_RELATION_TYPE_RRHH.""; |
|
2917 | 2917 | } |
2918 | 2918 | $result = Database::query($sql); |
2919 | 2919 | |
@@ -2923,7 +2923,7 @@ discard block |
||
2923 | 2923 | WHERE |
2924 | 2924 | session_id = {$row['session_id']} AND |
2925 | 2925 | user_id = $userId AND |
2926 | - relation_type=" . SESSION_RELATION_TYPE_RRHH . " "; |
|
2926 | + relation_type=".SESSION_RELATION_TYPE_RRHH." "; |
|
2927 | 2927 | Database::query($sql); |
2928 | 2928 | } |
2929 | 2929 | } |
@@ -2937,8 +2937,8 @@ discard block |
||
2937 | 2937 | VALUES ( |
2938 | 2938 | $session_id, |
2939 | 2939 | $userId, |
2940 | - '" . SESSION_RELATION_TYPE_RRHH . "', |
|
2941 | - '" . api_get_utc_datetime() . "' |
|
2940 | + '".SESSION_RELATION_TYPE_RRHH."', |
|
2941 | + '" . api_get_utc_datetime()."' |
|
2942 | 2942 | )"; |
2943 | 2943 | |
2944 | 2944 | Database::query($sql); |
@@ -2980,8 +2980,8 @@ discard block |
||
2980 | 2980 | WHERE |
2981 | 2981 | sru.user_id = '$userId' AND |
2982 | 2982 | sru.session_id = '$sessionId' AND |
2983 | - sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' AND |
|
2984 | - access_url_id = " . api_get_current_access_url_id() . " |
|
2983 | + sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND |
|
2984 | + access_url_id = " . api_get_current_access_url_id()." |
|
2985 | 2985 | "; |
2986 | 2986 | } else { |
2987 | 2987 | $sql = "$select FROM $tbl_session s |
@@ -2990,7 +2990,7 @@ discard block |
||
2990 | 2990 | sru.session_id = s.id AND |
2991 | 2991 | sru.user_id = '$userId' AND |
2992 | 2992 | sru.session_id = '$sessionId' AND |
2993 | - sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' |
|
2993 | + sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' |
|
2994 | 2994 | "; |
2995 | 2995 | } |
2996 | 2996 | |
@@ -3088,7 +3088,7 @@ discard block |
||
3088 | 3088 | |
3089 | 3089 | $limitCondition = null; |
3090 | 3090 | if (!empty($start) && !empty($limit)) { |
3091 | - $limitCondition = " LIMIT " . intval($start) . ", " . intval($limit); |
|
3091 | + $limitCondition = " LIMIT ".intval($start).", ".intval($limit); |
|
3092 | 3092 | } |
3093 | 3093 | |
3094 | 3094 | if (empty($orderCondition)) { |
@@ -3166,26 +3166,26 @@ discard block |
||
3166 | 3166 | |
3167 | 3167 | $sessions = array(); |
3168 | 3168 | if (Database::num_rows($result) > 0) { |
3169 | - $sysUploadPath = api_get_path(SYS_UPLOAD_PATH). 'sessions/'; |
|
3170 | - $webUploadPath = api_get_path(WEB_UPLOAD_PATH). 'sessions/'; |
|
3169 | + $sysUploadPath = api_get_path(SYS_UPLOAD_PATH).'sessions/'; |
|
3170 | + $webUploadPath = api_get_path(WEB_UPLOAD_PATH).'sessions/'; |
|
3171 | 3171 | $imgPath = Display::returnIconPath('session_default_small.png'); |
3172 | 3172 | |
3173 | 3173 | $tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD); |
3174 | - $sql = "SELECT id FROM " . $tableExtraFields . " |
|
3174 | + $sql = "SELECT id FROM ".$tableExtraFields." |
|
3175 | 3175 | WHERE extra_field_type = 3 AND variable='image'"; |
3176 | 3176 | $resultField = Database::query($sql); |
3177 | 3177 | $imageFieldId = Database::fetch_assoc($resultField); |
3178 | 3178 | |
3179 | 3179 | while ($row = Database::fetch_array($result)) { |
3180 | 3180 | |
3181 | - $row['image'] = null; |
|
3182 | - $sessionImage = $sysUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png'; |
|
3181 | + $row['image'] = null; |
|
3182 | + $sessionImage = $sysUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png'; |
|
3183 | 3183 | |
3184 | 3184 | if (is_file($sessionImage)) { |
3185 | - $sessionImage = $webUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png'; |
|
3185 | + $sessionImage = $webUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png'; |
|
3186 | 3186 | $row['image'] = $sessionImage; |
3187 | 3187 | } else { |
3188 | - $row['image'] = $imgPath; |
|
3188 | + $row['image'] = $imgPath; |
|
3189 | 3189 | } |
3190 | 3190 | |
3191 | 3191 | $sessions[$row['id']] = $row; |
@@ -3255,7 +3255,7 @@ discard block |
||
3255 | 3255 | return intval($count[0]); |
3256 | 3256 | } |
3257 | 3257 | |
3258 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
3258 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
3259 | 3259 | $courses[$row['real_id']] = $row; |
3260 | 3260 | } |
3261 | 3261 | } |
@@ -3299,7 +3299,7 @@ discard block |
||
3299 | 3299 | } |
3300 | 3300 | |
3301 | 3301 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
3302 | - $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
3302 | + $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
3303 | 3303 | |
3304 | 3304 | if ($getCount) { |
3305 | 3305 | $select = "SELECT COUNT(DISTINCT(c.code)) as count "; |
@@ -3324,7 +3324,7 @@ discard block |
||
3324 | 3324 | "; |
3325 | 3325 | if ($getCount) { |
3326 | 3326 | $result = Database::query($sql); |
3327 | - $row = Database::fetch_array($result,'ASSOC'); |
|
3327 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
3328 | 3328 | return $row['count']; |
3329 | 3329 | } |
3330 | 3330 | |
@@ -3339,7 +3339,7 @@ discard block |
||
3339 | 3339 | $courses = array(); |
3340 | 3340 | |
3341 | 3341 | if ($num_rows > 0) { |
3342 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
3342 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
3343 | 3343 | $courses[$row['id']] = $row; |
3344 | 3344 | } |
3345 | 3345 | } |
@@ -3417,7 +3417,7 @@ discard block |
||
3417 | 3417 | $result = Database::query($sql); |
3418 | 3418 | $num_rows = Database::num_rows($result); |
3419 | 3419 | if ($num_rows > 0) { |
3420 | - $row = Database::fetch_array($result,'ASSOC'); |
|
3420 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
3421 | 3421 | return $row['count']; |
3422 | 3422 | } |
3423 | 3423 | |
@@ -3529,9 +3529,9 @@ discard block |
||
3529 | 3529 | |
3530 | 3530 | if ($access_url_id != -1) { |
3531 | 3531 | $sql = 'SELECT DISTINCT session.* |
3532 | - FROM ' . $session_table . ' session INNER JOIN ' . $tbl_session_rel_access_url . ' session_rel_url |
|
3532 | + FROM ' . $session_table.' session INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url |
|
3533 | 3533 | ON (session.id = session_rel_url.session_id) |
3534 | - WHERE '.$sqlCoach.' access_url_id = ' . $access_url_id; |
|
3534 | + WHERE '.$sqlCoach.' access_url_id = '.$access_url_id; |
|
3535 | 3535 | } |
3536 | 3536 | } |
3537 | 3537 | $sql .= ' ORDER by name'; |
@@ -3565,8 +3565,8 @@ discard block |
||
3565 | 3565 | FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user |
3566 | 3566 | WHERE |
3567 | 3567 | session_rcru.user_id = user.user_id AND |
3568 | - session_rcru.session_id = '" . intval($session_id) . "' AND |
|
3569 | - session_rcru.c_id ='" . intval($courseId) . "' AND |
|
3568 | + session_rcru.session_id = '".intval($session_id)."' AND |
|
3569 | + session_rcru.c_id ='" . intval($courseId)."' AND |
|
3570 | 3570 | user.user_id = " . intval($user_id); |
3571 | 3571 | |
3572 | 3572 | $result = Database::query($sql); |
@@ -3597,8 +3597,8 @@ discard block |
||
3597 | 3597 | $sql = "SELECT session_rcru.status |
3598 | 3598 | FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user |
3599 | 3599 | WHERE session_rcru.user_id = user.user_id AND |
3600 | - session_rcru.session_id = '" . intval($session_id) . "' AND |
|
3601 | - session_rcru.c_id ='" . intval($courseId) . "' AND |
|
3600 | + session_rcru.session_id = '".intval($session_id)."' AND |
|
3601 | + session_rcru.c_id ='" . intval($courseId)."' AND |
|
3602 | 3602 | user.user_id = " . intval($user_id); |
3603 | 3603 | $result = Database::query($sql); |
3604 | 3604 | $status = false; |
@@ -3675,7 +3675,7 @@ discard block |
||
3675 | 3675 | // Get timestamp for now in UTC - see http://php.net/manual/es/function.time.php#117251 |
3676 | 3676 | $now = time() - date('Z'); |
3677 | 3677 | // Timestamp in one month |
3678 | - $inOneMonth = $now + (30*24*3600); |
|
3678 | + $inOneMonth = $now + (30 * 24 * 3600); |
|
3679 | 3679 | $inOneMonth = api_get_local_time($inOneMonth); |
3680 | 3680 | if (api_strtotime($s['access_start_date']) < $now) { |
3681 | 3681 | $s['access_start_date'] = api_get_local_time($now); |
@@ -3697,16 +3697,16 @@ discard block |
||
3697 | 3697 | } |
3698 | 3698 | // Now try to create the session |
3699 | 3699 | $sid = self::create_session( |
3700 | - $s['name'] . ' ' . get_lang('CopyLabelSuffix'), |
|
3700 | + $s['name'].' '.get_lang('CopyLabelSuffix'), |
|
3701 | 3701 | $s['access_start_date'], |
3702 | 3702 | $s['access_end_date'], |
3703 | 3703 | $s['display_start_date'], |
3704 | 3704 | $s['display_end_date'], |
3705 | 3705 | $s['coach_access_start_date'], |
3706 | 3706 | $s['coach_access_end_date'], |
3707 | - (int)$s['id_coach'], |
|
3707 | + (int) $s['id_coach'], |
|
3708 | 3708 | $s['session_category_id'], |
3709 | - (int)$s['visibility'], |
|
3709 | + (int) $s['visibility'], |
|
3710 | 3710 | true |
3711 | 3711 | ); |
3712 | 3712 | |
@@ -3820,7 +3820,7 @@ discard block |
||
3820 | 3820 | $session_table = Database::get_main_table(TABLE_MAIN_SESSION); |
3821 | 3821 | $sql = "SELECT DISTINCT id |
3822 | 3822 | FROM $session_table |
3823 | - WHERE session.id_coach = '" . $user_id . "' AND id = '$session_id'"; |
|
3823 | + WHERE session.id_coach = '".$user_id."' AND id = '$session_id'"; |
|
3824 | 3824 | $result = Database::query($sql); |
3825 | 3825 | if ($result && Database::num_rows($result)) { |
3826 | 3826 | return true; |
@@ -3839,7 +3839,7 @@ discard block |
||
3839 | 3839 | $access_url_rel_session_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
3840 | 3840 | $sql = "SELECT count(id) FROM $session_table s"; |
3841 | 3841 | if (!empty($access_url_id) && $access_url_id == intval($access_url_id)) { |
3842 | - $sql .= ", $access_url_rel_session_table u " . |
|
3842 | + $sql .= ", $access_url_rel_session_table u ". |
|
3843 | 3843 | " WHERE s.id = u.session_id AND u.access_url_id = $access_url_id"; |
3844 | 3844 | } |
3845 | 3845 | $res = Database::query($sql); |
@@ -4090,7 +4090,7 @@ discard block |
||
4090 | 4090 | |
4091 | 4091 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
4092 | 4092 | $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
4093 | - $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
4093 | + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
4094 | 4094 | $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
4095 | 4095 | |
4096 | 4096 | $sessions = array(); |
@@ -4184,10 +4184,10 @@ discard block |
||
4184 | 4184 | $suffix = null; |
4185 | 4185 | while (!$unique_name) { |
4186 | 4186 | if ($i > 1) { |
4187 | - $suffix = ' - ' . $i; |
|
4187 | + $suffix = ' - '.$i; |
|
4188 | 4188 | } |
4189 | - $sql = 'SELECT 1 FROM ' . $tbl_session . ' |
|
4190 | - WHERE name="' . $session_name . $suffix . '"'; |
|
4189 | + $sql = 'SELECT 1 FROM '.$tbl_session.' |
|
4190 | + WHERE name="' . $session_name.$suffix.'"'; |
|
4191 | 4191 | $rs = Database::query($sql); |
4192 | 4192 | |
4193 | 4193 | if (Database::result($rs, 0, 0)) { |
@@ -4205,13 +4205,13 @@ discard block |
||
4205 | 4205 | |
4206 | 4206 | // Creating the session. |
4207 | 4207 | $sql = "INSERT IGNORE INTO $tbl_session SET |
4208 | - name = '" . $session_name . "', |
|
4208 | + name = '".$session_name."', |
|
4209 | 4209 | id_coach = '$coach_id', |
4210 | 4210 | access_start_date = '$date_start', |
4211 | 4211 | access_end_date = '$date_end', |
4212 | 4212 | visibility = '$visibilityAfterExpirationPerSession', |
4213 | 4213 | $sessionCondition |
4214 | - session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters; |
|
4214 | + session_admin_id = ".intval($defaultUserId).$extraParameters.$extraSessionParameters; |
|
4215 | 4215 | Database::query($sql); |
4216 | 4216 | |
4217 | 4217 | $session_id = Database::insert_id(); |
@@ -4251,7 +4251,7 @@ discard block |
||
4251 | 4251 | access_start_date = '$date_start', |
4252 | 4252 | access_end_date = '$date_end', |
4253 | 4253 | visibility = '$visibilityAfterExpirationPerSession', |
4254 | - session_category_id = '$session_category_id' " . $extraParameters . $extraSessionParameters; |
|
4254 | + session_category_id = '$session_category_id' ".$extraParameters.$extraSessionParameters; |
|
4255 | 4255 | |
4256 | 4256 | Database::query($sql); |
4257 | 4257 | |
@@ -4271,7 +4271,7 @@ discard block |
||
4271 | 4271 | |
4272 | 4272 | // Delete session-user relation only for students |
4273 | 4273 | $sql = "DELETE FROM $tbl_session_user |
4274 | - WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; |
|
4274 | + WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH; |
|
4275 | 4275 | Database::query($sql); |
4276 | 4276 | |
4277 | 4277 | $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'"; |
@@ -4359,7 +4359,7 @@ discard block |
||
4359 | 4359 | |
4360 | 4360 | // Delete session-user relation only for students |
4361 | 4361 | $sql = "DELETE FROM $tbl_session_user |
4362 | - WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; |
|
4362 | + WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH; |
|
4363 | 4363 | Database::query($sql); |
4364 | 4364 | |
4365 | 4365 | $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'"; |
@@ -4402,7 +4402,7 @@ discard block |
||
4402 | 4402 | $sql = "INSERT IGNORE INTO $tbl_session_user SET |
4403 | 4403 | user_id = '$user_id', |
4404 | 4404 | session_id = '$session_id', |
4405 | - registered_at = '" . api_get_utc_datetime() . "'"; |
|
4405 | + registered_at = '".api_get_utc_datetime()."'"; |
|
4406 | 4406 | Database::query($sql); |
4407 | 4407 | if ($debug) { |
4408 | 4408 | $logger->addInfo("Sessions - Adding User #$user_id ($user) to session #$session_id"); |
@@ -5040,7 +5040,7 @@ discard block |
||
5040 | 5040 | |
5041 | 5041 | if (!empty($lastConnectionDate)) { |
5042 | 5042 | $lastConnectionDate = Database::escape_string($lastConnectionDate); |
5043 | - $userConditions .= " AND u.last_login <= '$lastConnectionDate' "; |
|
5043 | + $userConditions .= " AND u.last_login <= '$lastConnectionDate' "; |
|
5044 | 5044 | } |
5045 | 5045 | |
5046 | 5046 | if (!empty($keyword)) { |
@@ -5099,7 +5099,7 @@ discard block |
||
5099 | 5099 | $result = Database::query($sql); |
5100 | 5100 | $result = Database::store_result($result); |
5101 | 5101 | |
5102 | - return $result ; |
|
5102 | + return $result; |
|
5103 | 5103 | } |
5104 | 5104 | |
5105 | 5105 | /** |
@@ -5159,7 +5159,7 @@ discard block |
||
5159 | 5159 | $userToString = null; |
5160 | 5160 | foreach ($userList as $userInfo) { |
5161 | 5161 | $newUserList[] = $userInfo['user_id']; |
5162 | - $userToString .= $userInfo['firstname'] . ' ' . $userInfo['lastname'] . '<br />'; |
|
5162 | + $userToString .= $userInfo['firstname'].' '.$userInfo['lastname'].'<br />'; |
|
5163 | 5163 | } |
5164 | 5164 | |
5165 | 5165 | if (!empty($sessionsDestination)) { |
@@ -5172,7 +5172,7 @@ discard block |
||
5172 | 5172 | $messages[] = Display::return_message(sprintf(get_lang('SessionXSkipped'), $sessionDestinationId), 'warning', false); |
5173 | 5173 | continue; |
5174 | 5174 | } |
5175 | - $messages[] = Display::return_message(get_lang('StudentList') . '<br />' . $userToString, 'info', false); |
|
5175 | + $messages[] = Display::return_message(get_lang('StudentList').'<br />'.$userToString, 'info', false); |
|
5176 | 5176 | SessionManager::suscribe_users_to_session( |
5177 | 5177 | $sessionDestinationId, |
5178 | 5178 | $newUserList, |
@@ -5223,7 +5223,7 @@ discard block |
||
5223 | 5223 | } |
5224 | 5224 | } |
5225 | 5225 | } |
5226 | - $sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session='; |
|
5226 | + $sessionUrl = api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='; |
|
5227 | 5227 | |
5228 | 5228 | $htmlResult = null; |
5229 | 5229 | |
@@ -5238,7 +5238,7 @@ discard block |
||
5238 | 5238 | $sessionInfo = self::fetch($sessionId); |
5239 | 5239 | $htmlResult .= '<br />'; |
5240 | 5240 | $htmlResult .= Display::url( |
5241 | - get_lang('Session') . ': ' . $sessionInfo['name'] . ' <br />', $sessionUrl . $sessionId, array('target' => '_blank') |
|
5241 | + get_lang('Session').': '.$sessionInfo['name'].' <br />', $sessionUrl.$sessionId, array('target' => '_blank') |
|
5242 | 5242 | ); |
5243 | 5243 | $teacherList = array(); |
5244 | 5244 | foreach ($coachList as $coachId) { |
@@ -5351,7 +5351,7 @@ discard block |
||
5351 | 5351 | } |
5352 | 5352 | |
5353 | 5353 | $sessionIdList = array_map('intval', $sessionIdList); |
5354 | - $sessionToString = implode("', '", $sessionIdList); |
|
5354 | + $sessionToString = implode("', '", $sessionIdList); |
|
5355 | 5355 | |
5356 | 5356 | $course = Database::get_main_table(TABLE_MAIN_COURSE); |
5357 | 5357 | $sessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
@@ -5363,7 +5363,7 @@ discard block |
||
5363 | 5363 | INNER JOIN $courseUser cu ON (cu.c_id = c.id) |
5364 | 5364 | WHERE src.session_id IN ('$sessionToString') AND cu.status = 1"; |
5365 | 5365 | $result = Database::query($sql); |
5366 | - while($row = Database::fetch_array($result, 'ASSOC')) { |
|
5366 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
5367 | 5367 | $teacherListId[$row['user_id']] = $row['user_id']; |
5368 | 5368 | } |
5369 | 5369 | } else { |
@@ -5438,7 +5438,7 @@ discard block |
||
5438 | 5438 | $toolList = self::getCourseToolToBeManaged(); |
5439 | 5439 | |
5440 | 5440 | foreach ($toolList as $tool) { |
5441 | - $method = 'add' . $tool; |
|
5441 | + $method = 'add'.$tool; |
|
5442 | 5442 | if (method_exists(get_class(), $method)) { |
5443 | 5443 | self::$method($sessionId, $courseId); |
5444 | 5444 | } |
@@ -5457,7 +5457,7 @@ discard block |
||
5457 | 5457 | $toolList = self::getCourseToolToBeManaged(); |
5458 | 5458 | |
5459 | 5459 | foreach ($toolList as $tool) { |
5460 | - $method = 'remove' . $tool; |
|
5460 | + $method = 'remove'.$tool; |
|
5461 | 5461 | if (method_exists(get_class(), $method)) { |
5462 | 5462 | self::$method($sessionId, $courseId); |
5463 | 5463 | } |
@@ -5575,18 +5575,18 @@ discard block |
||
5575 | 5575 | } |
5576 | 5576 | } |
5577 | 5577 | |
5578 | - $message .= '<strong>' . get_lang('User') . '</strong> ' . $userInfo['complete_name'] . ' <br />'; |
|
5578 | + $message .= '<strong>'.get_lang('User').'</strong> '.$userInfo['complete_name'].' <br />'; |
|
5579 | 5579 | |
5580 | 5580 | if (!in_array($userInfo['status'], array(DRH)) && !api_is_platform_admin_by_id($userInfo['user_id'])) { |
5581 | - $message .= get_lang('UserMustHaveTheDrhRole') . '<br />'; |
|
5581 | + $message .= get_lang('UserMustHaveTheDrhRole').'<br />'; |
|
5582 | 5582 | continue; |
5583 | 5583 | } |
5584 | 5584 | |
5585 | 5585 | if (!empty($sessionList)) { |
5586 | - $message .= '<strong>' . get_lang('Sessions') . ':</strong> <br />'; |
|
5587 | - $message .= implode(', ', $sessionList) . '<br /><br />'; |
|
5586 | + $message .= '<strong>'.get_lang('Sessions').':</strong> <br />'; |
|
5587 | + $message .= implode(', ', $sessionList).'<br /><br />'; |
|
5588 | 5588 | } else { |
5589 | - $message .= get_lang('NoSessionProvided') . ' <br /><br />'; |
|
5589 | + $message .= get_lang('NoSessionProvided').' <br /><br />'; |
|
5590 | 5590 | } |
5591 | 5591 | } |
5592 | 5592 | } |
@@ -5766,8 +5766,8 @@ discard block |
||
5766 | 5766 | |
5767 | 5767 | $firstAccess = api_strtotime($courseAccess['login_course_date'], 'UTC'); |
5768 | 5768 | |
5769 | - $endDateInSeconds = $firstAccess + $duration*24*60*60; |
|
5770 | - $leftDays = round(($endDateInSeconds- $currentTime) / 60 / 60 / 24); |
|
5769 | + $endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60; |
|
5770 | + $leftDays = round(($endDateInSeconds - $currentTime) / 60 / 60 / 24); |
|
5771 | 5771 | |
5772 | 5772 | return $leftDays; |
5773 | 5773 | } |
@@ -6049,7 +6049,7 @@ discard block |
||
6049 | 6049 | $sql = "SELECT COUNT(1) as count, u.id, scu.status status_in_session, u.status user_status |
6050 | 6050 | FROM $tableSessionRelCourseRelUser scu |
6051 | 6051 | INNER JOIN $tableUser u ON scu.user_id = u.id |
6052 | - WHERE scu.session_id = " . intval($sessionId) ." |
|
6052 | + WHERE scu.session_id = ".intval($sessionId)." |
|
6053 | 6053 | GROUP BY u.id"; |
6054 | 6054 | |
6055 | 6055 | $result = Database::query($sql); |
@@ -6084,7 +6084,7 @@ discard block |
||
6084 | 6084 | $sfTable = Database::get_main_table(TABLE_EXTRA_FIELD); |
6085 | 6085 | $sfvTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
6086 | 6086 | // Join session field and session field values tables |
6087 | - $joinTable = $sfTable . ' sf INNER JOIN ' . $sfvTable . ' sfv ON sf.id = sfv.field_id'; |
|
6087 | + $joinTable = $sfTable.' sf INNER JOIN '.$sfvTable.' sfv ON sf.id = sfv.field_id'; |
|
6088 | 6088 | $fieldsArray = array(); |
6089 | 6089 | foreach ($extraFields as $field) { |
6090 | 6090 | $fieldsArray[] = Database::escape_string($field); |
@@ -6127,14 +6127,14 @@ discard block |
||
6127 | 6127 | for ($i = 1; $i < count($fieldsArray); $i++) { |
6128 | 6128 | $whereParams .= ', ?'; |
6129 | 6129 | } |
6130 | - $whereFieldVariables = ' variable IN ( ' . $whereParams .' )'; |
|
6131 | - $whereFieldIds = 'field_id IN ( ' . $whereParams . ' )'; |
|
6130 | + $whereFieldVariables = ' variable IN ( '.$whereParams.' )'; |
|
6131 | + $whereFieldIds = 'field_id IN ( '.$whereParams.' )'; |
|
6132 | 6132 | } |
6133 | 6133 | // Get session fields |
6134 | 6134 | $extraField = new ExtraField('session'); |
6135 | 6135 | $questionMarks = substr(str_repeat('?, ', count($fieldsArray)), 0, -2); |
6136 | 6136 | $fieldsList = $extraField->get_all(array( |
6137 | - ' variable IN ( ' . $questionMarks . ' )' => $fieldsArray, |
|
6137 | + ' variable IN ( '.$questionMarks.' )' => $fieldsArray, |
|
6138 | 6138 | )); |
6139 | 6139 | // Index session fields |
6140 | 6140 | foreach ($fieldsList as $field) { |
@@ -6143,7 +6143,7 @@ discard block |
||
6143 | 6143 | // Get session field values |
6144 | 6144 | $extra = new ExtraFieldValue('session'); |
6145 | 6145 | $questionMarksFields = substr(str_repeat('?, ', count($fields)), 0, -2); |
6146 | - $sessionFieldValueList = $extra->get_all(array ('where' => array('field_id IN ( ' . $questionMarksFields . ' )' => array_keys($fields)))); |
|
6146 | + $sessionFieldValueList = $extra->get_all(array('where' => array('field_id IN ( '.$questionMarksFields.' )' => array_keys($fields)))); |
|
6147 | 6147 | // Add session fields values to session list |
6148 | 6148 | foreach ($sessionList as $id => &$session) { |
6149 | 6149 | foreach ($sessionFieldValueList as $sessionFieldValue) { |
@@ -6196,7 +6196,7 @@ discard block |
||
6196 | 6196 | // Check the result |
6197 | 6197 | if ($result < 1) { |
6198 | 6198 | // If not found any result, update error message |
6199 | - $errorResult['errorMessage'] = 'Not found any session category name ' . $categoryName; |
|
6199 | + $errorResult['errorMessage'] = 'Not found any session category name '.$categoryName; |
|
6200 | 6200 | } elseif (count($result) > 1 && !$force) { |
6201 | 6201 | // If found more than one result and force is disabled, update error message |
6202 | 6202 | $errorResult['errorMessage'] = 'Found many session categories'; |
@@ -6255,7 +6255,7 @@ discard block |
||
6255 | 6255 | // Check if session list query had result |
6256 | 6256 | if (!empty($sessionList)) { |
6257 | 6257 | // implode all session id |
6258 | - $sessionIdsString = '(' . implode(', ', array_keys($sessionList)) . ')'; |
|
6258 | + $sessionIdsString = '('.implode(', ', array_keys($sessionList)).')'; |
|
6259 | 6259 | // Get all field variables |
6260 | 6260 | $sessionFieldList = Database::select( |
6261 | 6261 | 'id, variable', |
@@ -6342,7 +6342,7 @@ discard block |
||
6342 | 6342 | return $sessionList; |
6343 | 6343 | } else { |
6344 | 6344 | // Not found result, update error message |
6345 | - $errorResult['errorMessage'] = 'Not found any session for session category id ' . $sessionCategoryId; |
|
6345 | + $errorResult['errorMessage'] = 'Not found any session for session category id '.$sessionCategoryId; |
|
6346 | 6346 | } |
6347 | 6347 | } |
6348 | 6348 | |
@@ -6446,7 +6446,7 @@ discard block |
||
6446 | 6446 | |
6447 | 6447 | $sessionExtraField = new ExtraField('session'); |
6448 | 6448 | $fieldList = $sessionExtraField->get_all(array( |
6449 | - "variable IN ( " . implode(", ", $variablePlaceHolders) . " ) " => $variables, |
|
6449 | + "variable IN ( ".implode(", ", $variablePlaceHolders)." ) " => $variables, |
|
6450 | 6450 | )); |
6451 | 6451 | |
6452 | 6452 | $fields = array(); |
@@ -6460,7 +6460,7 @@ discard block |
||
6460 | 6460 | $extra = new ExtraFieldValue('session'); |
6461 | 6461 | $sessionFieldValueList = $extra->get_all( |
6462 | 6462 | array( |
6463 | - "field_id IN ( " . implode(", ", $variablePlaceHolders) . " )" => array_keys($fields), |
|
6463 | + "field_id IN ( ".implode(", ", $variablePlaceHolders)." )" => array_keys($fields), |
|
6464 | 6464 | ) |
6465 | 6465 | ); |
6466 | 6466 | |
@@ -6531,7 +6531,7 @@ discard block |
||
6531 | 6531 | FROM $sessionTable s |
6532 | 6532 | INNER JOIN $sessionUserTable sru ON s.id = sru.id_session |
6533 | 6533 | WHERE |
6534 | - (sru.id_user IN (" . implode(', ', $userIdList) . ") |
|
6534 | + (sru.id_user IN (".implode(', ', $userIdList).") |
|
6535 | 6535 | AND sru.relation_type = 0 |
6536 | 6536 | )"; |
6537 | 6537 | |
@@ -6547,7 +6547,7 @@ discard block |
||
6547 | 6547 | WHERE |
6548 | 6548 | srau.access_url_id = $accessUrlId |
6549 | 6549 | AND ( |
6550 | - sru.id_user IN (" . implode(', ', $userIdList) . ") |
|
6550 | + sru.id_user IN (".implode(', ', $userIdList).") |
|
6551 | 6551 | AND sru.relation_type = 0 |
6552 | 6552 | )"; |
6553 | 6553 | } |
@@ -6568,7 +6568,7 @@ discard block |
||
6568 | 6568 | */ |
6569 | 6569 | public static function getSessionVisibility($sessionInfo) |
6570 | 6570 | { |
6571 | - switch($sessionInfo['visibility']) { |
|
6571 | + switch ($sessionInfo['visibility']) { |
|
6572 | 6572 | case 1: |
6573 | 6573 | return get_lang('ReadOnly'); |
6574 | 6574 | case 2: |
@@ -6599,7 +6599,7 @@ discard block |
||
6599 | 6599 | |
6600 | 6600 | $result = ''; |
6601 | 6601 | if (!empty($startDateToLocal) && !empty($endDateToLocal)) { |
6602 | - $result = sprintf(get_lang('FromDateXToDateY'), $startDateToLocal, $endDateToLocal); |
|
6602 | + $result = sprintf(get_lang('FromDateXToDateY'), $startDateToLocal, $endDateToLocal); |
|
6603 | 6603 | } else { |
6604 | 6604 | if (!empty($startDateToLocal)) { |
6605 | 6605 | $result = get_lang('From').' '.$startDateToLocal; |
@@ -6742,7 +6742,7 @@ discard block |
||
6742 | 6742 | get_lang('CoachName'), |
6743 | 6743 | null, |
6744 | 6744 | [ |
6745 | - 'url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach', |
|
6745 | + 'url' => api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_general_coach', |
|
6746 | 6746 | 'width' => '100%', |
6747 | 6747 | ] |
6748 | 6748 | ); |
@@ -6753,7 +6753,7 @@ discard block |
||
6753 | 6753 | $form->addHtml('<div id="ajax_list_coachs"></div>'); |
6754 | 6754 | |
6755 | 6755 | $form->addButtonAdvancedSettings('advanced_params'); |
6756 | - $form->addElement('html','<div id="advanced_params_options" style="display:none">'); |
|
6756 | + $form->addElement('html', '<div id="advanced_params_options" style="display:none">'); |
|
6757 | 6757 | |
6758 | 6758 | $form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array( |
6759 | 6759 | 'id' => 'session_category' |
@@ -6891,7 +6891,7 @@ discard block |
||
6891 | 6891 | $extra_field = new ExtraField('session'); |
6892 | 6892 | $extra = $extra_field->addElements($form, $sessionId); |
6893 | 6893 | |
6894 | - $form->addElement('html','</div>'); |
|
6894 | + $form->addElement('html', '</div>'); |
|
6895 | 6895 | |
6896 | 6896 | $js = $extra['jquery_ready_content']; |
6897 | 6897 | |
@@ -6922,16 +6922,16 @@ discard block |
||
6922 | 6922 | if (api_is_session_admin() && |
6923 | 6923 | api_get_setting('allow_session_admins_to_see_all_sessions') == 'false' |
6924 | 6924 | ) { |
6925 | - $where.=" WHERE s.session_admin_id = $user_id "; |
|
6925 | + $where .= " WHERE s.session_admin_id = $user_id "; |
|
6926 | 6926 | } |
6927 | 6927 | |
6928 | 6928 | if (!empty($options['where'])) { |
6929 | 6929 | $options['where'] = str_replace('course_title', 'c.title', $options['where']); |
6930 | - $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']); |
|
6930 | + $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']); |
|
6931 | 6931 | |
6932 | 6932 | $options['where'] = str_replace( |
6933 | 6933 | array("AND session_active = '1' )", " AND ( session_active = '1' )"), |
6934 | - array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " ) |
|
6934 | + array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ") |
|
6935 | 6935 | , $options['where'] |
6936 | 6936 | ); |
6937 | 6937 | |
@@ -6973,10 +6973,10 @@ discard block |
||
6973 | 6973 | $where "; |
6974 | 6974 | |
6975 | 6975 | if (api_is_multiple_url_enabled()) { |
6976 | - $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
6976 | + $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
6977 | 6977 | $access_url_id = api_get_current_access_url_id(); |
6978 | 6978 | if ($access_url_id != -1) { |
6979 | - $where.= " AND ar.access_url_id = $access_url_id "; |
|
6979 | + $where .= " AND ar.access_url_id = $access_url_id "; |
|
6980 | 6980 | |
6981 | 6981 | $query_rows = "SELECT count(*) as total_rows |
6982 | 6982 | FROM $tbl_session s |
@@ -7021,12 +7021,12 @@ discard block |
||
7021 | 7021 | //get_lang('CourseTitle'), |
7022 | 7022 | get_lang('Visibility'), |
7023 | 7023 | ); |
7024 | - $column_model = array ( |
|
7025 | - array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7026 | - array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7027 | - array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), |
|
7028 | - array('name'=>'display_end_date', 'index'=>'display_end_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), |
|
7029 | - array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), |
|
7024 | + $column_model = array( |
|
7025 | + array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7026 | + array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7027 | + array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), |
|
7028 | + array('name'=>'display_end_date', 'index'=>'display_end_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), |
|
7029 | + array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), |
|
7030 | 7030 | ); |
7031 | 7031 | break; |
7032 | 7032 | case 'complete': |
@@ -7039,12 +7039,12 @@ discard block |
||
7039 | 7039 | get_lang('Visibility'), |
7040 | 7040 | get_lang('CourseTitle'), |
7041 | 7041 | ); |
7042 | - $column_model = array ( |
|
7043 | - array('name'=>'name', 'index'=>'s.name', 'width'=>'200', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7044 | - array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), |
|
7045 | - array('name'=>'display_end_date', 'index'=>'display_end_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), |
|
7046 | - array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)), |
|
7047 | - array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select', |
|
7042 | + $column_model = array( |
|
7043 | + array('name'=>'name', 'index'=>'s.name', 'width'=>'200', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), |
|
7044 | + array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), |
|
7045 | + array('name'=>'display_end_date', 'index'=>'display_end_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), |
|
7046 | + array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)), |
|
7047 | + array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select', |
|
7048 | 7048 | // for the bottom bar |
7049 | 7049 | 'searchoptions' => array( |
7050 | 7050 | 'defaultValue' => '1', |
@@ -7052,8 +7052,8 @@ discard block |
||
7052 | 7052 | // for the top bar |
7053 | 7053 | 'editoptions' => array('value' => '" ":'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')), |
7054 | 7054 | ), |
7055 | - array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), |
|
7056 | - array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)), |
|
7055 | + array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), |
|
7056 | + array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true', 'sopt' => $operators)), |
|
7057 | 7057 | ); |
7058 | 7058 | break; |
7059 | 7059 | } |
@@ -7062,14 +7062,14 @@ discard block |
||
7062 | 7062 | $session_field = new ExtraField('session'); |
7063 | 7063 | $rules = $session_field->getRules($columns, $column_model); |
7064 | 7064 | |
7065 | - $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false'); |
|
7065 | + $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80', 'align'=>'left', 'formatter'=>'action_formatter', 'sortable'=>'false', 'search' => 'false'); |
|
7066 | 7066 | $columns[] = get_lang('Actions'); |
7067 | 7067 | |
7068 | 7068 | foreach ($column_model as $col_model) { |
7069 | 7069 | $simple_column_name[] = $col_model['name']; |
7070 | 7070 | } |
7071 | 7071 | |
7072 | - $return_array = array( |
|
7072 | + $return_array = array( |
|
7073 | 7073 | 'columns' => $columns, |
7074 | 7074 | 'column_model' => $column_model, |
7075 | 7075 | 'rules' => $rules, |
@@ -7158,7 +7158,7 @@ discard block |
||
7158 | 7158 | if (api_is_session_admin() && |
7159 | 7159 | api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false' |
7160 | 7160 | ) { |
7161 | - $where.=" AND s.session_admin_id = $user_id "; |
|
7161 | + $where .= " AND s.session_admin_id = $user_id "; |
|
7162 | 7162 | } |
7163 | 7163 | } |
7164 | 7164 | |
@@ -7241,11 +7241,11 @@ discard block |
||
7241 | 7241 | } |
7242 | 7242 | $options['where'] = str_replace('course_title', 'c.title', $options['where']); |
7243 | 7243 | |
7244 | - $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']); |
|
7244 | + $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']); |
|
7245 | 7245 | |
7246 | 7246 | $options['where'] = str_replace( |
7247 | 7247 | array("AND session_active = '1' )", " AND ( session_active = '1' )"), |
7248 | - array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " ) |
|
7248 | + array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ") |
|
7249 | 7249 | , $options['where'] |
7250 | 7250 | ); |
7251 | 7251 | |
@@ -7280,10 +7280,10 @@ discard block |
||
7280 | 7280 | $where; |
7281 | 7281 | |
7282 | 7282 | if (api_is_multiple_url_enabled()) { |
7283 | - $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
7283 | + $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
7284 | 7284 | $access_url_id = api_get_current_access_url_id(); |
7285 | 7285 | if ($access_url_id != -1) { |
7286 | - $where.= " AND ar.access_url_id = $access_url_id "; |
|
7286 | + $where .= " AND ar.access_url_id = $access_url_id "; |
|
7287 | 7287 | $query = "$select |
7288 | 7288 | FROM $tbl_session s |
7289 | 7289 | LEFT JOIN $tbl_session_field_values fv ON (fv.session_id = s.id) |
@@ -7310,7 +7310,7 @@ discard block |
||
7310 | 7310 | $formatted_sessions = array(); |
7311 | 7311 | |
7312 | 7312 | if (Database::num_rows($result)) { |
7313 | - $sessions = Database::store_result($result, 'ASSOC'); |
|
7313 | + $sessions = Database::store_result($result, 'ASSOC'); |
|
7314 | 7314 | foreach ($sessions as $session) { |
7315 | 7315 | $session_id = $session['id']; |
7316 | 7316 | $session['name'] = Display::url($session['name'], "resume_session.php?id_session=".$session['id']); |
@@ -7325,14 +7325,14 @@ discard block |
||
7325 | 7325 | |
7326 | 7326 | switch ($session['visibility']) { |
7327 | 7327 | case SESSION_VISIBLE_READ_ONLY: //1 |
7328 | - $session['visibility'] = get_lang('ReadOnly'); |
|
7328 | + $session['visibility'] = get_lang('ReadOnly'); |
|
7329 | 7329 | break; |
7330 | 7330 | case SESSION_VISIBLE: //2 |
7331 | 7331 | case SESSION_AVAILABLE: //4 |
7332 | - $session['visibility'] = get_lang('Visible'); |
|
7332 | + $session['visibility'] = get_lang('Visible'); |
|
7333 | 7333 | break; |
7334 | 7334 | case SESSION_INVISIBLE: //3 |
7335 | - $session['visibility'] = api_ucfirst(get_lang('Invisible')); |
|
7335 | + $session['visibility'] = api_ucfirst(get_lang('Invisible')); |
|
7336 | 7336 | break; |
7337 | 7337 | } |
7338 | 7338 | |
@@ -7408,7 +7408,7 @@ discard block |
||
7408 | 7408 | if (empty($session)) { |
7409 | 7409 | return false; |
7410 | 7410 | } |
7411 | - return api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $id; |
|
7411 | + return api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$id; |
|
7412 | 7412 | } |
7413 | 7413 | |
7414 | 7414 | /** |
@@ -7426,7 +7426,7 @@ discard block |
||
7426 | 7426 | return false; |
7427 | 7427 | } |
7428 | 7428 | if (empty($courseId)) { |
7429 | - return api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $id; |
|
7429 | + return api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$id; |
|
7430 | 7430 | } else { |
7431 | 7431 | $courseInfo = api_get_course_info_by_id($courseId); |
7432 | 7432 | if ($courseInfo) { |
@@ -7672,7 +7672,7 @@ discard block |
||
7672 | 7672 | // sort $listCat by catSessionName |
7673 | 7673 | usort($listCat, 'self::compareBySessionName'); |
7674 | 7674 | // in each catSession sort sessionList by sessionName |
7675 | - foreach($listCat as $i => $listCatSessionInfo) { |
|
7675 | + foreach ($listCat as $i => $listCatSessionInfo) { |
|
7676 | 7676 | $listSessionList = $listCatSessionInfo['sessionList']; |
7677 | 7677 | usort($listSessionList, 'self::compareCatSessionInfo'); |
7678 | 7678 | $listCat[$i]['sessionList'] = $listSessionList; |
@@ -7687,8 +7687,8 @@ discard block |
||
7687 | 7687 | ); |
7688 | 7688 | |
7689 | 7689 | $userCatId = intval($userCatId); |
7690 | - $listResults[$userCatId]['courseInUserCategoryId'] = $userCatId; |
|
7691 | - $listResults[$userCatId]['courseInUserCategoryTitle'] = $userCatTitle; |
|
7690 | + $listResults[$userCatId]['courseInUserCategoryId'] = $userCatId; |
|
7691 | + $listResults[$userCatId]['courseInUserCategoryTitle'] = $userCatTitle; |
|
7692 | 7692 | $listResults[$userCatId]['courseInUserCatList'][] = $listOneCourse; |
7693 | 7693 | } |
7694 | 7694 | |
@@ -7714,7 +7714,7 @@ discard block |
||
7714 | 7714 | { |
7715 | 7715 | if ($listA['sessionName'] == $listB['sessionName']) { |
7716 | 7716 | return 0; |
7717 | - } else if($listA['sessionName'] > $listB['sessionName']) { |
|
7717 | + } else if ($listA['sessionName'] > $listB['sessionName']) { |
|
7718 | 7718 | return 1; |
7719 | 7719 | } else { |
7720 | 7720 | return -1; |
@@ -7734,7 +7734,7 @@ discard block |
||
7734 | 7734 | return 1; |
7735 | 7735 | } else if ($listA['catSessionName'] == $listB['catSessionName']) { |
7736 | 7736 | return 0; |
7737 | - } else if($listA['catSessionName'] > $listB['catSessionName']) { |
|
7737 | + } else if ($listA['catSessionName'] > $listB['catSessionName']) { |
|
7738 | 7738 | return 1; |
7739 | 7739 | } else { |
7740 | 7740 | return -1; |
@@ -7750,7 +7750,7 @@ discard block |
||
7750 | 7750 | { |
7751 | 7751 | if ($listA['courseInUserCategoryTitle'] == $listB['courseInUserCategoryTitle']) { |
7752 | 7752 | return 0; |
7753 | - } else if($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) { |
|
7753 | + } else if ($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) { |
|
7754 | 7754 | return 1; |
7755 | 7755 | } else { |
7756 | 7756 | return -1; |
@@ -7766,7 +7766,7 @@ discard block |
||
7766 | 7766 | { |
7767 | 7767 | if ($listA['title'] == $listB['title']) { |
7768 | 7768 | return 0; |
7769 | - } else if($listA['title'] > $listB['title']) { |
|
7769 | + } else if ($listA['title'] > $listB['title']) { |
|
7770 | 7770 | return 1; |
7771 | 7771 | } else { |
7772 | 7772 | return -1; |
@@ -7812,8 +7812,8 @@ discard block |
||
7812 | 7812 | |
7813 | 7813 | $marginShift = 20; |
7814 | 7814 | if ($catSessionName != '') { |
7815 | - $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">' . |
|
7816 | - CourseManager::course_item_html($listParamsCatSession, true) . '</div>'; |
|
7815 | + $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">'. |
|
7816 | + CourseManager::course_item_html($listParamsCatSession, true).'</div>'; |
|
7817 | 7817 | $marginShift = 40; |
7818 | 7818 | } |
7819 | 7819 |
@@ -1334,9 +1334,9 @@ discard block |
||
1334 | 1334 | * @param integer $sessionCategoryId |
1335 | 1335 | * @param int $visibility |
1336 | 1336 | * @param string $description |
1337 | - * @param bool $showDescription |
|
1337 | + * @param integer $showDescription |
|
1338 | 1338 | * @param int $duration |
1339 | - * @param array $extraFields |
|
1339 | + * @param boolean|null $extraFields |
|
1340 | 1340 | * @param int $sessionAdminId |
1341 | 1341 | * @param boolean $sendSubscriptionNotification Optional. |
1342 | 1342 | * Whether send a mail notification to users being subscribed |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | * @param array $user_list |
1566 | 1566 | * @param int $session_visibility |
1567 | 1567 | * @param bool $empty_users |
1568 | - * @return bool |
|
1568 | + * @return false|null |
|
1569 | 1569 | */ |
1570 | 1570 | public static function suscribe_users_to_session( |
1571 | 1571 | $id_session, |
@@ -1837,7 +1837,7 @@ discard block |
||
1837 | 1837 | * @param array $courseInfo |
1838 | 1838 | * @param int $status |
1839 | 1839 | * @param bool $updateTotal |
1840 | - * @return bool |
|
1840 | + * @return false|null |
|
1841 | 1841 | */ |
1842 | 1842 | public static function removeUsersFromCourseSession( |
1843 | 1843 | $userList, |
@@ -1903,7 +1903,7 @@ discard block |
||
1903 | 1903 | * @param string $course_code |
1904 | 1904 | * @param int $session_visibility |
1905 | 1905 | * @param bool $removeUsersNotInList |
1906 | - * @return bool |
|
1906 | + * @return false|null |
|
1907 | 1907 | */ |
1908 | 1908 | public static function subscribe_users_to_session_course( |
1909 | 1909 | $user_list, |
@@ -2086,7 +2086,7 @@ discard block |
||
2086 | 2086 | * @param bool $removeExistingCoursesWithUsers Whether to unsubscribe |
2087 | 2087 | * existing courses and users (true, default) or not (false) |
2088 | 2088 | * @param $copyEvaluation from base course to session course |
2089 | - * @return void Nothing, or false on error |
|
2089 | + * @return false|null Nothing, or false on error |
|
2090 | 2090 | * */ |
2091 | 2091 | public static function add_courses_to_session( |
2092 | 2092 | $sessionId, |
@@ -2282,6 +2282,8 @@ discard block |
||
2282 | 2282 | * |
2283 | 2283 | * @param int Session id |
2284 | 2284 | * @param int Course id |
2285 | + * @param integer $session_id |
|
2286 | + * @param integer $course_id |
|
2285 | 2287 | * @return bool True in case of success, false otherwise |
2286 | 2288 | */ |
2287 | 2289 | public static function unsubscribe_course_from_session($session_id, $course_id) |
@@ -2337,7 +2339,7 @@ discard block |
||
2337 | 2339 | * @param string $variable Field's internal variable name |
2338 | 2340 | * @param int $fieldType Field's type |
2339 | 2341 | * @param string $displayText Field's language var name |
2340 | - * @return int new extra field id |
|
2342 | + * @return boolean new extra field id |
|
2341 | 2343 | */ |
2342 | 2344 | public static function create_session_extra_field($variable, $fieldType, $displayText) |
2343 | 2345 | { |
@@ -2356,7 +2358,7 @@ discard block |
||
2356 | 2358 | * @param integer Course ID |
2357 | 2359 | * @param string Field variable name |
2358 | 2360 | * @param string Field value |
2359 | - * @return boolean true if field updated, false otherwise |
|
2361 | + * @return boolean|null true if field updated, false otherwise |
|
2360 | 2362 | */ |
2361 | 2363 | public static function update_session_extra_field_value($sessionId, $variable, $value = '') |
2362 | 2364 | { |
@@ -2561,7 +2563,7 @@ discard block |
||
2561 | 2563 | * @param array id_checked |
2562 | 2564 | * @param bool include delete session |
2563 | 2565 | * @param bool optional, true if the function is called by a webservice, false otherwise. |
2564 | - * @return void Nothing, or false on error |
|
2566 | + * @return boolean Nothing, or false on error |
|
2565 | 2567 | * The parameters is a array to delete sessions |
2566 | 2568 | * */ |
2567 | 2569 | public static function delete_session_category($id_checked, $delete_session = false, $from_ws = false) |
@@ -3056,6 +3058,7 @@ discard block |
||
3056 | 3058 | * @param string $orderCondition |
3057 | 3059 | * @param string $keyword |
3058 | 3060 | * @param string $description |
3061 | + * @param integer $status |
|
3059 | 3062 | * @return array sessions |
3060 | 3063 | */ |
3061 | 3064 | public static function getSessionsFollowedByUser( |
@@ -3268,8 +3271,8 @@ discard block |
||
3268 | 3271 | /** |
3269 | 3272 | * Gets the list of courses by session filtered by access_url |
3270 | 3273 | * |
3271 | - * @param $userId |
|
3272 | - * @param $sessionId |
|
3274 | + * @param integer $userId |
|
3275 | + * @param null|integer $sessionId |
|
3273 | 3276 | * @param null $from |
3274 | 3277 | * @param null $limit |
3275 | 3278 | * @param null $column |
@@ -3394,6 +3397,7 @@ discard block |
||
3394 | 3397 | /** |
3395 | 3398 | * Gets the count of courses by session filtered by access_url |
3396 | 3399 | * @param int session id |
3400 | + * @param integer $session_id |
|
3397 | 3401 | * @return array list of courses |
3398 | 3402 | */ |
3399 | 3403 | public static function getCourseCountBySessionId($session_id, $keyword = null) |
@@ -3645,6 +3649,7 @@ discard block |
||
3645 | 3649 | * Updates a session status |
3646 | 3650 | * @param int session id |
3647 | 3651 | * @param int status |
3652 | + * @param integer $status |
|
3648 | 3653 | */ |
3649 | 3654 | public static function set_session_status($session_id, $status) |
3650 | 3655 | { |
@@ -3853,7 +3858,7 @@ discard block |
||
3853 | 3858 | * Protect a session to be edited. |
3854 | 3859 | * @param int $id |
3855 | 3860 | * @param bool $checkSession |
3856 | - * @return mixed | bool true if pass the check, api_not_allowed otherwise |
|
3861 | + * @return boolean|null | bool true if pass the check, api_not_allowed otherwise |
|
3857 | 3862 | */ |
3858 | 3863 | public static function protectSession($id, $checkSession = true) |
3859 | 3864 | { |
@@ -3961,7 +3966,7 @@ discard block |
||
3961 | 3966 | |
3962 | 3967 | /** |
3963 | 3968 | * @param $id |
3964 | - * @return bool |
|
3969 | + * @return null|boolean |
|
3965 | 3970 | */ |
3966 | 3971 | public static function protect_teacher_session_edit($id) |
3967 | 3972 | { |
@@ -4025,7 +4030,7 @@ discard block |
||
4025 | 4030 | * true: if the session exists it will be updated. |
4026 | 4031 | * false: if session exists a new session will be created adding a counter session1, session2, etc |
4027 | 4032 | * @param int $defaultUserId |
4028 | - * @param mixed $logger |
|
4033 | + * @param Logger $logger |
|
4029 | 4034 | * @param array $extraFields convert a file row to an extra field. Example in CSV file there's a SessionID then it will |
4030 | 4035 | * converted to extra_external_session_id if you set this: array('SessionId' => 'extra_external_session_id') |
4031 | 4036 | * @param string $extraFieldId |
@@ -5267,7 +5272,6 @@ discard block |
||
5267 | 5272 | * @param string $lastConnectionDate |
5268 | 5273 | * @param array $sessionIdList |
5269 | 5274 | * @param array $studentIdList |
5270 | - * @param int $userStatus STUDENT|COURSEMANAGER constants |
|
5271 | 5275 | * |
5272 | 5276 | * @return array|int |
5273 | 5277 | */ |
@@ -5419,7 +5423,7 @@ discard block |
||
5419 | 5423 | /** |
5420 | 5424 | * Get the list of course tools that have to be dealt with in case of |
5421 | 5425 | * registering any course to a session |
5422 | - * @return array The list of tools to be dealt with (literal names) |
|
5426 | + * @return string[] The list of tools to be dealt with (literal names) |
|
5423 | 5427 | */ |
5424 | 5428 | public static function getCourseToolToBeManaged() |
5425 | 5429 | { |
@@ -5433,7 +5437,7 @@ discard block |
||
5433 | 5437 | * Calls the methods bound to each tool when a course is registered into a session |
5434 | 5438 | * @param int $sessionId |
5435 | 5439 | * @param int $courseId |
5436 | - * @return void |
|
5440 | + * @return boolean|null |
|
5437 | 5441 | */ |
5438 | 5442 | public static function installCourse($sessionId, $courseId) |
5439 | 5443 | { |
@@ -6073,6 +6077,7 @@ discard block |
||
6073 | 6077 | * @param int $categoryId The internal ID of the session category |
6074 | 6078 | * @param string $target Value to search for in the session field values |
6075 | 6079 | * @param array $extraFields A list of fields to be scanned and returned |
6080 | + * @param DateTime $publicationDate |
|
6076 | 6081 | * @return mixed |
6077 | 6082 | */ |
6078 | 6083 | public static function getShortSessionListAndExtraByCategory($categoryId, $target, $extraFields = null, $publicationDate = null) |
@@ -7402,7 +7407,7 @@ discard block |
||
7402 | 7407 | /** |
7403 | 7408 | * Get link to the admin page for this session |
7404 | 7409 | * @param int $id Session ID |
7405 | - * @return mixed URL to the admin page to manage the session, or false on error |
|
7410 | + * @return false|string URL to the admin page to manage the session, or false on error |
|
7406 | 7411 | */ |
7407 | 7412 | public static function getAdminPath($id) |
7408 | 7413 | { |
@@ -7419,7 +7424,7 @@ discard block |
||
7419 | 7424 | * If a course is provided, build the link to the course |
7420 | 7425 | * @param int $id Session ID |
7421 | 7426 | * @param int $courseId Course ID (optional) in case the link has to send straight to the course |
7422 | - * @return mixed URL to the page to use the session, or false on error |
|
7427 | + * @return false|string URL to the page to use the session, or false on error |
|
7423 | 7428 | */ |
7424 | 7429 | public static function getPath($id, $courseId = 0) |
7425 | 7430 | { |
@@ -7517,7 +7522,7 @@ discard block |
||
7517 | 7522 | /** |
7518 | 7523 | * Return true if coach is allowed to access this session |
7519 | 7524 | * @param int $sessionId |
7520 | - * @return bool |
|
7525 | + * @return integer |
|
7521 | 7526 | */ |
7522 | 7527 | public static function isSessionDateOkForCoach($sessionId) |
7523 | 7528 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $course_id = intval($course_id); |
74 | 74 | } |
75 | 75 | |
76 | - $session_id = isset($session_id)?intval($session_id):api_get_session_id(); |
|
76 | + $session_id = isset($session_id) ? intval($session_id) : api_get_session_id(); |
|
77 | 77 | $condition_session = api_get_session_condition($session_id); |
78 | 78 | |
79 | 79 | // Get attendance data |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | WHERE c_id = $course_id AND active = 1 $condition_session "; |
83 | 83 | $rs = Database::query($sql); |
84 | 84 | if (Database::num_rows($rs) > 0) { |
85 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
85 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
86 | 86 | $data[$row['id']] = $row; |
87 | 87 | } |
88 | 88 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $from = intval($from); |
109 | 109 | $number_of_items = intval($number_of_items); |
110 | 110 | |
111 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
111 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
112 | 112 | $direction = 'ASC'; |
113 | 113 | } |
114 | 114 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | LIMIT $from,$number_of_items "; |
136 | 136 | |
137 | 137 | $res = Database::query($sql); |
138 | - $attendances = array (); |
|
138 | + $attendances = array(); |
|
139 | 139 | $user_info = api_get_user_info(); |
140 | 140 | $allowDelete = api_get_setting('allow_delete_attendance'); |
141 | 141 | |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
195 | 195 | } |
196 | 196 | if ($allowDelete === 'true') { |
197 | - $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0]. '">' . |
|
198 | - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
197 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'. |
|
198 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; |
|
199 | 199 | } |
200 | 200 | } else { |
201 | 201 | $is_locked_attendance = self::is_locked_attendance($attendance[0]); |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
216 | 216 | } |
217 | 217 | if ($allowDelete === 'true') { |
218 | - $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0].'">' . |
|
219 | - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
218 | + $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'. |
|
219 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]); |
226 | 226 | |
227 | 227 | if ($is_done_all_calendar) { |
228 | - $locked = $attendance[4]; |
|
228 | + $locked = $attendance[4]; |
|
229 | 229 | if ($locked == 0) { |
230 | 230 | if (api_is_platform_admin()) { |
231 | 231 | $message_alert = get_lang('AreYouSureToLockTheAttendance'); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | $actions .= '</center>'; |
247 | 247 | |
248 | - $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3],$actions); |
|
248 | + $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions); |
|
249 | 249 | } else { |
250 | 250 | $attendance[0] = ' '; |
251 | 251 | $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]); |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | public function attendance_add($link_to_gradebook = false) |
286 | 286 | { |
287 | 287 | $_course = api_get_course_info(); |
288 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
288 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
289 | 289 | $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
290 | 290 | $session_id = api_get_session_id(); |
291 | 291 | $user_id = api_get_user_id(); |
292 | 292 | $course_code = $_course['code']; |
293 | 293 | $course_id = $_course['real_id']; |
294 | - $title_gradebook= $this->attendance_qualify_title; |
|
294 | + $title_gradebook = $this->attendance_qualify_title; |
|
295 | 295 | $value_calification = 0; |
296 | 296 | $weight_calification = floatval($this->attendance_weight); |
297 | 297 | |
@@ -434,12 +434,12 @@ discard block |
||
434 | 434 | public function attendance_restore($attendance_id) |
435 | 435 | { |
436 | 436 | $_course = api_get_course_info(); |
437 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
437 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
438 | 438 | $user_id = api_get_user_id(); |
439 | 439 | $course_id = $_course['real_id']; |
440 | 440 | if (is_array($attendance_id)) { |
441 | 441 | foreach ($attendance_id as $id) { |
442 | - $id = intval($id); |
|
442 | + $id = intval($id); |
|
443 | 443 | $sql = "UPDATE $tbl_attendance SET active = 1 |
444 | 444 | WHERE c_id = $course_id AND id = '$id'"; |
445 | 445 | $result = Database::query($sql); |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | ); |
456 | 456 | } |
457 | 457 | } |
458 | - } else { |
|
459 | - $attendance_id = intval($attendance_id); |
|
458 | + } else { |
|
459 | + $attendance_id = intval($attendance_id); |
|
460 | 460 | $sql = "UPDATE $tbl_attendance SET active = 1 |
461 | 461 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
462 | 462 | $result = Database::query($sql); |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | public function attendance_delete($attendance_id) |
485 | 485 | { |
486 | 486 | $_course = api_get_course_info(); |
487 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
487 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
488 | 488 | $user_id = api_get_user_id(); |
489 | 489 | $course_id = $_course['real_id']; |
490 | 490 | |
491 | 491 | if (is_array($attendance_id)) { |
492 | 492 | foreach ($attendance_id as $id) { |
493 | - $id = intval($id); |
|
493 | + $id = intval($id); |
|
494 | 494 | $sql = "UPDATE $tbl_attendance SET active = 2 |
495 | 495 | WHERE c_id = $course_id AND id = '$id'"; |
496 | 496 | $result = Database::query($sql); |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | ); |
507 | 507 | } |
508 | 508 | } |
509 | - } else { |
|
510 | - $attendance_id= intval($attendance_id); |
|
509 | + } else { |
|
510 | + $attendance_id = intval($attendance_id); |
|
511 | 511 | $sql = "UPDATE $tbl_attendance SET active = 2 |
512 | 512 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
513 | 513 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | public function changeVisibility($attendanceId, $status = 1) |
539 | 539 | { |
540 | 540 | $_course = api_get_course_info(); |
541 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
541 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
542 | 542 | $user_id = api_get_user_id(); |
543 | 543 | $course_id = $_course['real_id']; |
544 | 544 | $status = intval($status); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | if (is_array($attendanceId)) { |
552 | 552 | foreach ($attendanceId as $id) { |
553 | - $id = intval($id); |
|
553 | + $id = intval($id); |
|
554 | 554 | $sql = "UPDATE $tbl_attendance SET active = $status |
555 | 555 | WHERE c_id = $course_id AND id = '$id'"; |
556 | 556 | $result = Database::query($sql); |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | api_item_property_update($_course, TOOL_ATTENDANCE, $id, $action, $user_id); |
561 | 561 | } |
562 | 562 | } |
563 | - } else { |
|
564 | - $attendanceId = intval($attendanceId); |
|
563 | + } else { |
|
564 | + $attendanceId = intval($attendanceId); |
|
565 | 565 | $sql = "UPDATE $tbl_attendance SET active = $status |
566 | 566 | WHERE c_id = $course_id AND id = '$attendanceId'"; |
567 | 567 | $result = Database::query($sql); |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
592 | 592 | $course_id = api_get_course_int_id(); |
593 | 593 | $attendance_id = intval($attendance_id); |
594 | - $locked = ($lock)?1:0; |
|
594 | + $locked = ($lock) ? 1 : 0; |
|
595 | 595 | $upd = "UPDATE $tbl_attendance SET locked = $locked |
596 | 596 | WHERE c_id = $course_id AND id = $attendance_id"; |
597 | 597 | $result = Database::query($upd); |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | */ |
721 | 721 | public function attendance_sheet_add($calendar_id, $users_present, $attendance_id) |
722 | 722 | { |
723 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
724 | - $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
723 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
724 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
725 | 725 | |
726 | 726 | $calendar_id = intval($calendar_id); |
727 | 727 | $attendance_id = intval($attendance_id); |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $course_id = api_get_course_int_id(); |
730 | 730 | |
731 | 731 | $user_ids = array_keys($users); |
732 | - $users_absent = array_diff($user_ids,$users_present); |
|
732 | + $users_absent = array_diff($user_ids, $users_present); |
|
733 | 733 | $affected_rows = 0; |
734 | 734 | |
735 | 735 | // get last edit type |
@@ -993,13 +993,13 @@ discard block |
||
993 | 993 | public function get_faults_of_user($user_id, $attendance_id, $groupId = null) |
994 | 994 | { |
995 | 995 | // initializing database table and variables |
996 | - $user_id = intval($user_id); |
|
996 | + $user_id = intval($user_id); |
|
997 | 997 | $attendance_id = intval($attendance_id); |
998 | 998 | $results = array(); |
999 | 999 | $calendar_count = self::get_number_of_attendance_calendar($attendance_id, $groupId, NULL, $user_id); |
1000 | 1000 | // $total_done_attendance = $attendance_data['attendance_qualify_max']; |
1001 | - $total_done_attendance = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id); |
|
1002 | - $attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId); |
|
1001 | + $total_done_attendance = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id); |
|
1002 | + $attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId); |
|
1003 | 1003 | |
1004 | 1004 | //This is the main change of the BT#1381 |
1005 | 1005 | //$total_done_attendance = $calendar_count; |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | $faults = $faults > 0 ? $faults : 0; |
1015 | - $faults_porcent = $calendar_count > 0 ?round(($faults*100)/$calendar_count,0):0; |
|
1015 | + $faults_porcent = $calendar_count > 0 ? round(($faults * 100) / $calendar_count, 0) : 0; |
|
1016 | 1016 | $results['faults'] = $faults; |
1017 | 1017 | $results['total'] = $calendar_count; |
1018 | 1018 | $results['faults_porcent'] = $faults_porcent; |
@@ -1046,13 +1046,13 @@ discard block |
||
1046 | 1046 | //$course_code = $course['code']; |
1047 | 1047 | //$course_info = api_get_course_info($course_code); |
1048 | 1048 | $course_id = $course['real_id']; |
1049 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1049 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1050 | 1050 | |
1051 | 1051 | $attendances_by_course = $this->get_attendances_list($course_id); |
1052 | 1052 | |
1053 | 1053 | foreach ($attendances_by_course as $attendance) { |
1054 | 1054 | // get total faults and total weight |
1055 | - $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1055 | + $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1056 | 1056 | $sql = "SELECT score |
1057 | 1057 | FROM $tbl_attendance_result |
1058 | 1058 | WHERE |
@@ -1065,16 +1065,16 @@ discard block |
||
1065 | 1065 | $row = Database::fetch_array($rs); |
1066 | 1066 | $score = $row['score']; |
1067 | 1067 | } |
1068 | - $faults = $total_done_attendance-$score; |
|
1069 | - $faults = $faults > 0 ? $faults:0; |
|
1068 | + $faults = $total_done_attendance - $score; |
|
1069 | + $faults = $faults > 0 ? $faults : 0; |
|
1070 | 1070 | $total_faults += $faults; |
1071 | 1071 | $total_weight += $total_done_attendance; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1075 | + $porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0; |
|
1076 | 1076 | $results['faults'] = $total_faults; |
1077 | - $results['total'] = $total_weight; |
|
1077 | + $results['total'] = $total_weight; |
|
1078 | 1078 | $results['porcent'] = $porcent; |
1079 | 1079 | |
1080 | 1080 | return $results; |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | { |
1093 | 1093 | // Database tables and variables |
1094 | 1094 | $course_info = api_get_course_info($course_code); |
1095 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1095 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1096 | 1096 | $user_id = intval($user_id); |
1097 | 1097 | $results = array(); |
1098 | 1098 | $total_faults = $total_weight = $porcent = 0; |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | foreach ($attendances_by_course as $attendance) { |
1102 | 1102 | // Get total faults and total weight |
1103 | - $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1103 | + $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1104 | 1104 | $sql = "SELECT score FROM $tbl_attendance_result |
1105 | 1105 | WHERE |
1106 | 1106 | c_id = {$course_info['real_id']} AND |
@@ -1112,15 +1112,15 @@ discard block |
||
1112 | 1112 | $row = Database::fetch_array($rs); |
1113 | 1113 | $score = $row['score']; |
1114 | 1114 | } |
1115 | - $faults = $total_done_attendance-$score; |
|
1116 | - $faults = $faults > 0 ? $faults:0; |
|
1115 | + $faults = $total_done_attendance - $score; |
|
1116 | + $faults = $faults > 0 ? $faults : 0; |
|
1117 | 1117 | $total_faults += $faults; |
1118 | 1118 | $total_weight += $total_done_attendance; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1121 | + $porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0; |
|
1122 | 1122 | $results['faults'] = $total_faults; |
1123 | - $results['total'] = $total_weight; |
|
1123 | + $results['total'] = $total_weight; |
|
1124 | 1124 | $results['porcent'] = $porcent; |
1125 | 1125 | |
1126 | 1126 | return $results; |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | */ |
1135 | 1135 | public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null) |
1136 | 1136 | { |
1137 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1138 | - $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1137 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1138 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1139 | 1139 | |
1140 | 1140 | $attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId); |
1141 | 1141 | $calendar_ids = array(); |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | WHERE |
1158 | 1158 | c_id = $course_id AND |
1159 | 1159 | user_id = '$uid' AND |
1160 | - attendance_calendar_id IN(".implode(',',$calendar_ids).") |
|
1160 | + attendance_calendar_id IN(".implode(',', $calendar_ids).") |
|
1161 | 1161 | "; |
1162 | 1162 | $res = Database::query($sql); |
1163 | 1163 | if (Database::num_rows($res) > 0) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | att.c_id = $course_id AND |
1180 | 1180 | cal.c_id = $course_id AND |
1181 | 1181 | att.user_id = '$user_id' AND |
1182 | - att.attendance_calendar_id IN (".implode(',',$calendar_ids).") |
|
1182 | + att.attendance_calendar_id IN (".implode(',', $calendar_ids).") |
|
1183 | 1183 | ORDER BY date_time"; |
1184 | 1184 | $res = Database::query($sql); |
1185 | 1185 | if (Database::num_rows($res) > 0) { |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | */ |
1256 | 1256 | public function get_user_score($user_id, $attendance_id, $groupId = null) |
1257 | 1257 | { |
1258 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1258 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1259 | 1259 | $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
1260 | 1260 | $tbl_attendance_cal_rel_group = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
1261 | 1261 | $tbl_attendance_cal = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | "; |
1370 | 1370 | } |
1371 | 1371 | |
1372 | - if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) { |
|
1372 | + if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done', 'calendar_id'))) { |
|
1373 | 1373 | $type = 'all'; |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | case 'calendar_id': |
1378 | 1378 | $calendar_id = intval($calendar_id); |
1379 | 1379 | if (!empty($calendar_id)) { |
1380 | - $sql.= " AND c.id = $calendar_id"; |
|
1380 | + $sql .= " AND c.id = $calendar_id"; |
|
1381 | 1381 | } |
1382 | 1382 | break; |
1383 | 1383 | case 'today': |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | $rs = Database::query($sql); |
1399 | 1399 | $data = array(); |
1400 | 1400 | if (Database::num_rows($rs) > 0) { |
1401 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
1401 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
1402 | 1402 | $row['db_date_time'] = $row['date_time']; |
1403 | 1403 | $row['date_time'] = api_get_local_time($row['date_time']); |
1404 | 1404 | $row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT); |
@@ -1762,14 +1762,14 @@ discard block |
||
1762 | 1762 | * @param int The number of years to add |
1763 | 1763 | * @return int The new timestamp |
1764 | 1764 | */ |
1765 | - private function add_month($timestamp, $num=1) |
|
1765 | + private function add_month($timestamp, $num = 1) |
|
1766 | 1766 | { |
1767 | 1767 | $values = api_get_utc_datetime($timestamp); |
1768 | - $values = str_replace(array(':','-',' '), '/', $values); |
|
1769 | - list($y, $m, $d, $h, $n, $s) = split('/',$values); |
|
1770 | - if($m+$num>12) { |
|
1771 | - $y += floor($num/12); |
|
1772 | - $m += $num%12; |
|
1768 | + $values = str_replace(array(':', '-', ' '), '/', $values); |
|
1769 | + list($y, $m, $d, $h, $n, $s) = split('/', $values); |
|
1770 | + if ($m + $num > 12) { |
|
1771 | + $y += floor($num / 12); |
|
1772 | + $m += $num % 12; |
|
1773 | 1773 | } else { |
1774 | 1774 | $m += $num; |
1775 | 1775 | } |
@@ -1827,7 +1827,7 @@ discard block |
||
1827 | 1827 | * @param bool true for removing all calendar inside current attendance, false for removing by calendar id |
1828 | 1828 | * @return int affected rows |
1829 | 1829 | */ |
1830 | - public function attendance_calendar_delete($calendar_id, $attendance_id , $all_delete = false) |
|
1830 | + public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false) |
|
1831 | 1831 | { |
1832 | 1832 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
1833 | 1833 | $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
@@ -1963,7 +1963,7 @@ discard block |
||
1963 | 1963 | } |
1964 | 1964 | |
1965 | 1965 | $sessionId = api_get_session_id(); |
1966 | - $courseCode = api_get_course_id(); |
|
1966 | + $courseCode = api_get_course_id(); |
|
1967 | 1967 | if (!empty($sessionId)) { |
1968 | 1968 | $users = CourseManager:: get_user_list_from_course_code( |
1969 | 1969 | $courseCode, |
@@ -1984,7 +1984,7 @@ discard block |
||
1984 | 1984 | |
1985 | 1985 | $dateTimeStartOriginal = new DateTime($startDate); |
1986 | 1986 | $dateTimeStart = new DateTime($startDate); |
1987 | - $dateTimeEnd= new DateTime($endDate); |
|
1987 | + $dateTimeEnd = new DateTime($endDate); |
|
1988 | 1988 | $interval = $dateTimeStart->diff($dateTimeEnd); |
1989 | 1989 | $days = intval($interval->format('%a')); |
1990 | 1990 | |
@@ -2057,7 +2057,7 @@ discard block |
||
2057 | 2057 | 0, |
2058 | 2058 | $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')' |
2059 | 2059 | ); |
2060 | - $row ++; |
|
2060 | + $row++; |
|
2061 | 2061 | } |
2062 | 2062 | |
2063 | 2063 | $column = 1; |
@@ -2134,7 +2134,7 @@ discard block |
||
2134 | 2134 | $tableToString = $table->toHtml(); |
2135 | 2135 | |
2136 | 2136 | $params = array( |
2137 | - 'filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(), |
|
2137 | + 'filename' => get_lang('Attendance').'_'.api_get_utc_datetime(), |
|
2138 | 2138 | 'pdf_title' => get_lang('Attendance'), |
2139 | 2139 | 'course_code' => api_get_course_id(), |
2140 | 2140 | 'show_real_course_teachers' => true |
@@ -11,50 +11,50 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class Attendance |
13 | 13 | { |
14 | - private $session_id; |
|
15 | - private $course_id; |
|
16 | - private $date_time; |
|
17 | - private $name; |
|
18 | - private $description; |
|
19 | - private $attendance_qualify_title; |
|
20 | - private $attendance_weight; |
|
21 | - private $course_int_id; |
|
22 | - public $category_id; |
|
23 | - |
|
24 | - // constants |
|
25 | - const DONE_ATTENDANCE_LOG_TYPE = 'done_attendance_sheet'; |
|
26 | - const UPDATED_ATTENDANCE_LOG_TYPE = 'updated_attendance_sheet'; |
|
27 | - const LOCKED_ATTENDANCE_LOG_TYPE = 'locked_attendance_sheet'; |
|
28 | - |
|
29 | - /** |
|
30 | - * Constructor |
|
31 | - */ |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - //$this->course_int_id = api_get_course_int_id(); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Get the total number of attendance inside current course and current session |
|
39 | - * @see SortableTable#get_total_number_of_items() |
|
40 | - */ |
|
41 | - public static function get_number_of_attendances($active = -1) |
|
42 | - { |
|
43 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
44 | - $session_id = api_get_session_id(); |
|
45 | - $condition_session = api_get_session_condition($session_id); |
|
46 | - $course_id = api_get_course_int_id(); |
|
47 | - $sql = "SELECT COUNT(att.id) AS total_number_of_items |
|
14 | + private $session_id; |
|
15 | + private $course_id; |
|
16 | + private $date_time; |
|
17 | + private $name; |
|
18 | + private $description; |
|
19 | + private $attendance_qualify_title; |
|
20 | + private $attendance_weight; |
|
21 | + private $course_int_id; |
|
22 | + public $category_id; |
|
23 | + |
|
24 | + // constants |
|
25 | + const DONE_ATTENDANCE_LOG_TYPE = 'done_attendance_sheet'; |
|
26 | + const UPDATED_ATTENDANCE_LOG_TYPE = 'updated_attendance_sheet'; |
|
27 | + const LOCKED_ATTENDANCE_LOG_TYPE = 'locked_attendance_sheet'; |
|
28 | + |
|
29 | + /** |
|
30 | + * Constructor |
|
31 | + */ |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + //$this->course_int_id = api_get_course_int_id(); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Get the total number of attendance inside current course and current session |
|
39 | + * @see SortableTable#get_total_number_of_items() |
|
40 | + */ |
|
41 | + public static function get_number_of_attendances($active = -1) |
|
42 | + { |
|
43 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
44 | + $session_id = api_get_session_id(); |
|
45 | + $condition_session = api_get_session_condition($session_id); |
|
46 | + $course_id = api_get_course_int_id(); |
|
47 | + $sql = "SELECT COUNT(att.id) AS total_number_of_items |
|
48 | 48 | FROM $tbl_attendance att |
49 | 49 | WHERE c_id = $course_id $condition_session "; |
50 | - if ($active == 1 || $active == 0) { |
|
51 | - $sql .= "AND att.active = $active"; |
|
52 | - } |
|
53 | - $res = Database::query($sql); |
|
54 | - $obj = Database::fetch_object($res); |
|
50 | + if ($active == 1 || $active == 0) { |
|
51 | + $sql .= "AND att.active = $active"; |
|
52 | + } |
|
53 | + $res = Database::query($sql); |
|
54 | + $obj = Database::fetch_object($res); |
|
55 | 55 | |
56 | - return $obj->total_number_of_items; |
|
57 | - } |
|
56 | + return $obj->total_number_of_items; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Get attendance list only the id, name and attendance_qualify_max fields |
@@ -90,36 +90,36 @@ discard block |
||
90 | 90 | return $data; |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Get the attendaces to display on the current page (fill the sortable-table) |
|
95 | - * @param int offset of first user to recover |
|
96 | - * @param int Number of users to get |
|
97 | - * @param int Column to sort on |
|
98 | - * @param string Order (ASC,DESC) |
|
99 | - * @see SortableTable#get_table_data($from) |
|
100 | - */ |
|
101 | - public static function get_attendance_data($from, $number_of_items, $column, $direction) |
|
102 | - { |
|
103 | - $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
104 | - $course_id = api_get_course_int_id(); |
|
105 | - $session_id = api_get_session_id(); |
|
106 | - $condition_session = api_get_session_condition($session_id); |
|
107 | - $column = intval($column); |
|
108 | - $from = intval($from); |
|
109 | - $number_of_items = intval($number_of_items); |
|
110 | - |
|
111 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
112 | - $direction = 'ASC'; |
|
113 | - } |
|
114 | - |
|
115 | - $active_plus = ''; |
|
116 | - if ((isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') || |
|
117 | - !api_is_allowed_to_edit(null, true) |
|
118 | - ) { |
|
119 | - $active_plus = ' AND att.active = 1'; |
|
120 | - } |
|
121 | - |
|
122 | - $sql = "SELECT |
|
93 | + /** |
|
94 | + * Get the attendaces to display on the current page (fill the sortable-table) |
|
95 | + * @param int offset of first user to recover |
|
96 | + * @param int Number of users to get |
|
97 | + * @param int Column to sort on |
|
98 | + * @param string Order (ASC,DESC) |
|
99 | + * @see SortableTable#get_table_data($from) |
|
100 | + */ |
|
101 | + public static function get_attendance_data($from, $number_of_items, $column, $direction) |
|
102 | + { |
|
103 | + $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
104 | + $course_id = api_get_course_int_id(); |
|
105 | + $session_id = api_get_session_id(); |
|
106 | + $condition_session = api_get_session_condition($session_id); |
|
107 | + $column = intval($column); |
|
108 | + $from = intval($from); |
|
109 | + $number_of_items = intval($number_of_items); |
|
110 | + |
|
111 | + if (!in_array($direction, array('ASC','DESC'))) { |
|
112 | + $direction = 'ASC'; |
|
113 | + } |
|
114 | + |
|
115 | + $active_plus = ''; |
|
116 | + if ((isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') || |
|
117 | + !api_is_allowed_to_edit(null, true) |
|
118 | + ) { |
|
119 | + $active_plus = ' AND att.active = 1'; |
|
120 | + } |
|
121 | + |
|
122 | + $sql = "SELECT |
|
123 | 123 | att.id AS col0, |
124 | 124 | att.name AS col1, |
125 | 125 | att.description AS col2, |
@@ -134,318 +134,318 @@ discard block |
||
134 | 134 | ORDER BY col$column $direction |
135 | 135 | LIMIT $from,$number_of_items "; |
136 | 136 | |
137 | - $res = Database::query($sql); |
|
138 | - $attendances = array (); |
|
139 | - $user_info = api_get_user_info(); |
|
140 | - $allowDelete = api_get_setting('allow_delete_attendance'); |
|
141 | - |
|
142 | - while ($attendance = Database::fetch_row($res)) { |
|
143 | - |
|
144 | - $student_param = ''; |
|
145 | - if (api_is_drh() && $_GET['student_id']) { |
|
146 | - $student_param = '&student_id='.intval($_GET['student_id']); |
|
147 | - } |
|
148 | - |
|
149 | - $session_star = ''; |
|
150 | - |
|
151 | - if (api_get_session_id() == $attendance[6]) { |
|
152 | - $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); |
|
153 | - } |
|
154 | - if ($attendance[5] == 1) { |
|
155 | - |
|
156 | - $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( |
|
157 | - api_get_user_id(), |
|
158 | - api_get_course_info() |
|
159 | - ); |
|
160 | - |
|
161 | - if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) { |
|
162 | - // Link to edit |
|
163 | - $attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
164 | - } else { |
|
165 | - // Link to view |
|
166 | - $attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list_no_edit&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
167 | - } |
|
168 | - |
|
169 | - } else { |
|
170 | - $attendance[1] = '<a class="muted" href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
171 | - } |
|
172 | - |
|
173 | - if ($attendance[5] == 1) { |
|
174 | - $attendance[3] = '<center>'.$attendance[3].'</center>'; |
|
175 | - } else { |
|
176 | - $attendance[3] = '<center><span class="muted">'.$attendance[3].'</span></center>'; |
|
177 | - } |
|
178 | - |
|
179 | - $attendance[3] = '<center>'.$attendance[3].'</center>'; |
|
180 | - if (api_is_allowed_to_edit(null, true)) { |
|
181 | - $actions = ''; |
|
182 | - $actions .= '<center>'; |
|
183 | - |
|
184 | - if (api_is_platform_admin()) { |
|
185 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'. |
|
186 | - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
187 | - // Visible |
|
188 | - if ($attendance[5] == 1) { |
|
189 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'. |
|
190 | - Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
191 | - } else { |
|
192 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'. |
|
193 | - Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
194 | - $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
|
195 | - } |
|
196 | - if ($allowDelete === 'true') { |
|
197 | - $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0]. '">' . |
|
198 | - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
199 | - } |
|
200 | - } else { |
|
201 | - $is_locked_attendance = self::is_locked_attendance($attendance[0]); |
|
202 | - if ($is_locked_attendance) { |
|
203 | - $actions .= Display::return_icon('edit_na.png', get_lang('Edit')).' '; |
|
204 | - $actions .= Display::return_icon('visible.png', get_lang('Hide')); |
|
205 | - } else { |
|
206 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'. |
|
207 | - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
208 | - |
|
209 | - if ($attendance[5] == 1) { |
|
210 | - $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'. |
|
211 | - Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
212 | - } else { |
|
213 | - $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'. |
|
214 | - Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
215 | - $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
|
216 | - } |
|
217 | - if ($allowDelete === 'true') { |
|
218 | - $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0].'">' . |
|
219 | - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
220 | - } |
|
221 | - } |
|
222 | - } |
|
223 | - |
|
224 | - // display lock/unlock icon |
|
225 | - $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]); |
|
226 | - |
|
227 | - if ($is_done_all_calendar) { |
|
228 | - $locked = $attendance[4]; |
|
229 | - if ($locked == 0) { |
|
230 | - if (api_is_platform_admin()) { |
|
231 | - $message_alert = get_lang('AreYouSureToLockTheAttendance'); |
|
232 | - } else { |
|
233 | - $message_alert = get_lang('UnlockMessageInformation'); |
|
234 | - } |
|
235 | - $actions .= ' <a onclick="javascript:if(!confirm(\''.$message_alert.'\')) return false;" href="index.php?'.api_get_cidreq().'&action=lock_attendance&attendance_id='.$attendance[0].'">'. |
|
137 | + $res = Database::query($sql); |
|
138 | + $attendances = array (); |
|
139 | + $user_info = api_get_user_info(); |
|
140 | + $allowDelete = api_get_setting('allow_delete_attendance'); |
|
141 | + |
|
142 | + while ($attendance = Database::fetch_row($res)) { |
|
143 | + |
|
144 | + $student_param = ''; |
|
145 | + if (api_is_drh() && $_GET['student_id']) { |
|
146 | + $student_param = '&student_id='.intval($_GET['student_id']); |
|
147 | + } |
|
148 | + |
|
149 | + $session_star = ''; |
|
150 | + |
|
151 | + if (api_get_session_id() == $attendance[6]) { |
|
152 | + $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); |
|
153 | + } |
|
154 | + if ($attendance[5] == 1) { |
|
155 | + |
|
156 | + $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( |
|
157 | + api_get_user_id(), |
|
158 | + api_get_course_info() |
|
159 | + ); |
|
160 | + |
|
161 | + if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) { |
|
162 | + // Link to edit |
|
163 | + $attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
164 | + } else { |
|
165 | + // Link to view |
|
166 | + $attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list_no_edit&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
167 | + } |
|
168 | + |
|
169 | + } else { |
|
170 | + $attendance[1] = '<a class="muted" href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$student_param.'">'.$attendance[1].'</a>'.$session_star; |
|
171 | + } |
|
172 | + |
|
173 | + if ($attendance[5] == 1) { |
|
174 | + $attendance[3] = '<center>'.$attendance[3].'</center>'; |
|
175 | + } else { |
|
176 | + $attendance[3] = '<center><span class="muted">'.$attendance[3].'</span></center>'; |
|
177 | + } |
|
178 | + |
|
179 | + $attendance[3] = '<center>'.$attendance[3].'</center>'; |
|
180 | + if (api_is_allowed_to_edit(null, true)) { |
|
181 | + $actions = ''; |
|
182 | + $actions .= '<center>'; |
|
183 | + |
|
184 | + if (api_is_platform_admin()) { |
|
185 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'. |
|
186 | + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
187 | + // Visible |
|
188 | + if ($attendance[5] == 1) { |
|
189 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'. |
|
190 | + Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
191 | + } else { |
|
192 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'. |
|
193 | + Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
194 | + $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
|
195 | + } |
|
196 | + if ($allowDelete === 'true') { |
|
197 | + $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0]. '">' . |
|
198 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
199 | + } |
|
200 | + } else { |
|
201 | + $is_locked_attendance = self::is_locked_attendance($attendance[0]); |
|
202 | + if ($is_locked_attendance) { |
|
203 | + $actions .= Display::return_icon('edit_na.png', get_lang('Edit')).' '; |
|
204 | + $actions .= Display::return_icon('visible.png', get_lang('Hide')); |
|
205 | + } else { |
|
206 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'. |
|
207 | + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
208 | + |
|
209 | + if ($attendance[5] == 1) { |
|
210 | + $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'. |
|
211 | + Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
212 | + } else { |
|
213 | + $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'. |
|
214 | + Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
215 | + $attendance[2] = '<span class="muted">'.$attendance[2].'</span>'; |
|
216 | + } |
|
217 | + if ($allowDelete === 'true') { |
|
218 | + $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0].'">' . |
|
219 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
220 | + } |
|
221 | + } |
|
222 | + } |
|
223 | + |
|
224 | + // display lock/unlock icon |
|
225 | + $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]); |
|
226 | + |
|
227 | + if ($is_done_all_calendar) { |
|
228 | + $locked = $attendance[4]; |
|
229 | + if ($locked == 0) { |
|
230 | + if (api_is_platform_admin()) { |
|
231 | + $message_alert = get_lang('AreYouSureToLockTheAttendance'); |
|
232 | + } else { |
|
233 | + $message_alert = get_lang('UnlockMessageInformation'); |
|
234 | + } |
|
235 | + $actions .= ' <a onclick="javascript:if(!confirm(\''.$message_alert.'\')) return false;" href="index.php?'.api_get_cidreq().'&action=lock_attendance&attendance_id='.$attendance[0].'">'. |
|
236 | 236 | Display::return_icon('unlock.png', get_lang('LockAttendance')).'</a>'; |
237 | - } else { |
|
238 | - if (api_is_platform_admin()) { |
|
239 | - $actions .= ' <a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToUnlockTheAttendance').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=unlock_attendance&attendance_id='.$attendance[0].'">'. |
|
240 | - Display::return_icon('locked.png', get_lang('UnlockAttendance')).'</a>'; |
|
241 | - } else { |
|
242 | - $actions .= ' '.Display::return_icon('locked_na.png', get_lang('LockedAttendance')); |
|
243 | - } |
|
244 | - } |
|
245 | - } |
|
246 | - $actions .= '</center>'; |
|
247 | - |
|
248 | - $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3],$actions); |
|
249 | - } else { |
|
250 | - $attendance[0] = ' '; |
|
251 | - $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]); |
|
252 | - } |
|
253 | - } |
|
254 | - return $attendances; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Get the attendances by id to display on the current page |
|
259 | - * @param int $attendance_id |
|
260 | - * @return array attendance data |
|
261 | - */ |
|
262 | - public function get_attendance_by_id($attendance_id) |
|
263 | - { |
|
264 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
265 | - $attendance_id = intval($attendance_id); |
|
266 | - $course_id = api_get_course_int_id(); |
|
267 | - $attendance_data = array(); |
|
268 | - $sql = "SELECT * FROM $tbl_attendance |
|
237 | + } else { |
|
238 | + if (api_is_platform_admin()) { |
|
239 | + $actions .= ' <a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToUnlockTheAttendance').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=unlock_attendance&attendance_id='.$attendance[0].'">'. |
|
240 | + Display::return_icon('locked.png', get_lang('UnlockAttendance')).'</a>'; |
|
241 | + } else { |
|
242 | + $actions .= ' '.Display::return_icon('locked_na.png', get_lang('LockedAttendance')); |
|
243 | + } |
|
244 | + } |
|
245 | + } |
|
246 | + $actions .= '</center>'; |
|
247 | + |
|
248 | + $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3],$actions); |
|
249 | + } else { |
|
250 | + $attendance[0] = ' '; |
|
251 | + $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]); |
|
252 | + } |
|
253 | + } |
|
254 | + return $attendances; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Get the attendances by id to display on the current page |
|
259 | + * @param int $attendance_id |
|
260 | + * @return array attendance data |
|
261 | + */ |
|
262 | + public function get_attendance_by_id($attendance_id) |
|
263 | + { |
|
264 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
265 | + $attendance_id = intval($attendance_id); |
|
266 | + $course_id = api_get_course_int_id(); |
|
267 | + $attendance_data = array(); |
|
268 | + $sql = "SELECT * FROM $tbl_attendance |
|
269 | 269 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
270 | - $res = Database::query($sql); |
|
271 | - if (Database::num_rows($res) > 0) { |
|
272 | - while ($row = Database::fetch_array($res)) { |
|
273 | - $attendance_data = $row; |
|
274 | - } |
|
275 | - } |
|
276 | - return $attendance_data; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Add attendances sheet inside table. This is the *list of* dates, not |
|
281 | - * a specific date in itself. |
|
282 | - * @param bool true for adding link in gradebook or false otherwise (optional) |
|
283 | - * @return int last attendance id |
|
284 | - */ |
|
285 | - public function attendance_add($link_to_gradebook = false) |
|
286 | - { |
|
287 | - $_course = api_get_course_info(); |
|
288 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
289 | - $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
290 | - $session_id = api_get_session_id(); |
|
291 | - $user_id = api_get_user_id(); |
|
292 | - $course_code = $_course['code']; |
|
293 | - $course_id = $_course['real_id']; |
|
294 | - $title_gradebook= $this->attendance_qualify_title; |
|
295 | - $value_calification = 0; |
|
296 | - $weight_calification = floatval($this->attendance_weight); |
|
297 | - |
|
298 | - $params = [ |
|
299 | - 'c_id' => $course_id, |
|
300 | - 'name' => $this->name, |
|
301 | - 'description' => $this->description, |
|
302 | - 'attendance_qualify_title' => $title_gradebook, |
|
303 | - 'attendance_weight' => $weight_calification, |
|
304 | - 'session_id' => $session_id, |
|
305 | - 'active' => 1, |
|
306 | - 'attendance_qualify_max' => 0, |
|
307 | - 'locked' => 0 |
|
308 | - ]; |
|
309 | - $last_id = Database::insert($tbl_attendance, $params); |
|
310 | - |
|
311 | - if (!empty($last_id)) { |
|
312 | - |
|
313 | - $sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id"; |
|
314 | - Database::query($sql); |
|
315 | - |
|
316 | - api_item_property_update( |
|
317 | - $_course, |
|
318 | - TOOL_ATTENDANCE, |
|
319 | - $last_id, |
|
320 | - "AttendanceAdded", |
|
321 | - $user_id |
|
322 | - ); |
|
323 | - |
|
324 | - } |
|
325 | - // add link to gradebook |
|
326 | - if ($link_to_gradebook && !empty($this->category_id)) { |
|
327 | - $description = ''; |
|
270 | + $res = Database::query($sql); |
|
271 | + if (Database::num_rows($res) > 0) { |
|
272 | + while ($row = Database::fetch_array($res)) { |
|
273 | + $attendance_data = $row; |
|
274 | + } |
|
275 | + } |
|
276 | + return $attendance_data; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Add attendances sheet inside table. This is the *list of* dates, not |
|
281 | + * a specific date in itself. |
|
282 | + * @param bool true for adding link in gradebook or false otherwise (optional) |
|
283 | + * @return int last attendance id |
|
284 | + */ |
|
285 | + public function attendance_add($link_to_gradebook = false) |
|
286 | + { |
|
287 | + $_course = api_get_course_info(); |
|
288 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
289 | + $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
290 | + $session_id = api_get_session_id(); |
|
291 | + $user_id = api_get_user_id(); |
|
292 | + $course_code = $_course['code']; |
|
293 | + $course_id = $_course['real_id']; |
|
294 | + $title_gradebook= $this->attendance_qualify_title; |
|
295 | + $value_calification = 0; |
|
296 | + $weight_calification = floatval($this->attendance_weight); |
|
297 | + |
|
298 | + $params = [ |
|
299 | + 'c_id' => $course_id, |
|
300 | + 'name' => $this->name, |
|
301 | + 'description' => $this->description, |
|
302 | + 'attendance_qualify_title' => $title_gradebook, |
|
303 | + 'attendance_weight' => $weight_calification, |
|
304 | + 'session_id' => $session_id, |
|
305 | + 'active' => 1, |
|
306 | + 'attendance_qualify_max' => 0, |
|
307 | + 'locked' => 0 |
|
308 | + ]; |
|
309 | + $last_id = Database::insert($tbl_attendance, $params); |
|
310 | + |
|
311 | + if (!empty($last_id)) { |
|
312 | + |
|
313 | + $sql = "UPDATE $tbl_attendance SET id = iid WHERE iid = $last_id"; |
|
314 | + Database::query($sql); |
|
315 | + |
|
316 | + api_item_property_update( |
|
317 | + $_course, |
|
318 | + TOOL_ATTENDANCE, |
|
319 | + $last_id, |
|
320 | + "AttendanceAdded", |
|
321 | + $user_id |
|
322 | + ); |
|
323 | + |
|
324 | + } |
|
325 | + // add link to gradebook |
|
326 | + if ($link_to_gradebook && !empty($this->category_id)) { |
|
327 | + $description = ''; |
|
328 | 328 | $link_info = GradebookUtils::is_resource_in_course_gradebook( |
329 | 329 | $course_code, |
330 | 330 | 7, |
331 | 331 | $last_id, |
332 | 332 | $session_id |
333 | 333 | ); |
334 | - $link_id = $link_info['id']; |
|
335 | - if (!$link_info) { |
|
336 | - GradebookUtils::add_resource_to_course_gradebook( |
|
337 | - $this->category_id, |
|
338 | - $course_code, |
|
339 | - 7, |
|
340 | - $last_id, |
|
341 | - $title_gradebook, |
|
342 | - $weight_calification, |
|
343 | - $value_calification, |
|
344 | - $description, |
|
345 | - 1, |
|
346 | - $session_id |
|
347 | - ); |
|
348 | - } else { |
|
349 | - Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.''); |
|
350 | - } |
|
351 | - } |
|
352 | - return $last_id; |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * edit attendances inside table |
|
357 | - * @param int attendance id |
|
358 | - * @param bool true for adding link in gradebook or false otherwise (optional) |
|
359 | - * @return int last id |
|
360 | - */ |
|
361 | - public function attendance_edit($attendance_id, $link_to_gradebook = false) |
|
362 | - { |
|
363 | - $_course = api_get_course_info(); |
|
364 | - $tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE); |
|
365 | - $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
366 | - |
|
367 | - $session_id = api_get_session_id(); |
|
368 | - $user_id = api_get_user_id(); |
|
369 | - $attendance_id = intval($attendance_id); |
|
370 | - $course_code = $_course['code']; |
|
371 | - $course_id = $_course['real_id']; |
|
372 | - $title_gradebook = $this->attendance_qualify_title; |
|
373 | - $value_calification = 0; |
|
374 | - $weight_calification = floatval($this->attendance_weight); |
|
375 | - |
|
376 | - if (!empty($attendance_id)) { |
|
377 | - |
|
378 | - $params = [ |
|
379 | - 'name' => $this->name, |
|
380 | - 'description' => $this->description, |
|
381 | - 'attendance_qualify_title' => $title_gradebook, |
|
382 | - 'attendance_weight' => $weight_calification |
|
383 | - ]; |
|
384 | - Database::update( |
|
385 | - $tbl_attendance, |
|
386 | - $params, |
|
387 | - ['c_id = ? AND id = ?' => [$course_id, $attendance_id]] |
|
388 | - ); |
|
389 | - |
|
390 | - api_item_property_update( |
|
391 | - $_course, |
|
392 | - TOOL_ATTENDANCE, |
|
393 | - $attendance_id, |
|
394 | - "AttendanceUpdated", |
|
395 | - $user_id |
|
396 | - ); |
|
397 | - |
|
398 | - // add link to gradebook |
|
399 | - if ($link_to_gradebook && !empty($this->category_id)) { |
|
400 | - $description = ''; |
|
401 | - $link_info = GradebookUtils::is_resource_in_course_gradebook( |
|
402 | - $course_code, |
|
403 | - 7, |
|
404 | - $attendance_id, |
|
405 | - $session_id |
|
406 | - ); |
|
407 | - if (!$link_info) { |
|
408 | - GradebookUtils::add_resource_to_course_gradebook( |
|
409 | - $this->category_id, |
|
410 | - $course_code, |
|
411 | - 7, |
|
412 | - $attendance_id, |
|
413 | - $title_gradebook, |
|
414 | - $weight_calification, |
|
415 | - $value_calification, |
|
416 | - $description, |
|
417 | - 1, |
|
418 | - $session_id |
|
419 | - ); |
|
420 | - } else { |
|
421 | - Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_info['id'].''); |
|
422 | - } |
|
423 | - } |
|
424 | - return $attendance_id; |
|
425 | - } |
|
426 | - return null; |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Restore attendance |
|
431 | - * @param int|array one or many attendances id |
|
432 | - * @return int affected rows |
|
433 | - */ |
|
434 | - public function attendance_restore($attendance_id) |
|
435 | - { |
|
436 | - $_course = api_get_course_info(); |
|
437 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
438 | - $user_id = api_get_user_id(); |
|
439 | - $course_id = $_course['real_id']; |
|
440 | - if (is_array($attendance_id)) { |
|
441 | - foreach ($attendance_id as $id) { |
|
442 | - $id = intval($id); |
|
443 | - $sql = "UPDATE $tbl_attendance SET active = 1 |
|
334 | + $link_id = $link_info['id']; |
|
335 | + if (!$link_info) { |
|
336 | + GradebookUtils::add_resource_to_course_gradebook( |
|
337 | + $this->category_id, |
|
338 | + $course_code, |
|
339 | + 7, |
|
340 | + $last_id, |
|
341 | + $title_gradebook, |
|
342 | + $weight_calification, |
|
343 | + $value_calification, |
|
344 | + $description, |
|
345 | + 1, |
|
346 | + $session_id |
|
347 | + ); |
|
348 | + } else { |
|
349 | + Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.''); |
|
350 | + } |
|
351 | + } |
|
352 | + return $last_id; |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * edit attendances inside table |
|
357 | + * @param int attendance id |
|
358 | + * @param bool true for adding link in gradebook or false otherwise (optional) |
|
359 | + * @return int last id |
|
360 | + */ |
|
361 | + public function attendance_edit($attendance_id, $link_to_gradebook = false) |
|
362 | + { |
|
363 | + $_course = api_get_course_info(); |
|
364 | + $tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE); |
|
365 | + $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
366 | + |
|
367 | + $session_id = api_get_session_id(); |
|
368 | + $user_id = api_get_user_id(); |
|
369 | + $attendance_id = intval($attendance_id); |
|
370 | + $course_code = $_course['code']; |
|
371 | + $course_id = $_course['real_id']; |
|
372 | + $title_gradebook = $this->attendance_qualify_title; |
|
373 | + $value_calification = 0; |
|
374 | + $weight_calification = floatval($this->attendance_weight); |
|
375 | + |
|
376 | + if (!empty($attendance_id)) { |
|
377 | + |
|
378 | + $params = [ |
|
379 | + 'name' => $this->name, |
|
380 | + 'description' => $this->description, |
|
381 | + 'attendance_qualify_title' => $title_gradebook, |
|
382 | + 'attendance_weight' => $weight_calification |
|
383 | + ]; |
|
384 | + Database::update( |
|
385 | + $tbl_attendance, |
|
386 | + $params, |
|
387 | + ['c_id = ? AND id = ?' => [$course_id, $attendance_id]] |
|
388 | + ); |
|
389 | + |
|
390 | + api_item_property_update( |
|
391 | + $_course, |
|
392 | + TOOL_ATTENDANCE, |
|
393 | + $attendance_id, |
|
394 | + "AttendanceUpdated", |
|
395 | + $user_id |
|
396 | + ); |
|
397 | + |
|
398 | + // add link to gradebook |
|
399 | + if ($link_to_gradebook && !empty($this->category_id)) { |
|
400 | + $description = ''; |
|
401 | + $link_info = GradebookUtils::is_resource_in_course_gradebook( |
|
402 | + $course_code, |
|
403 | + 7, |
|
404 | + $attendance_id, |
|
405 | + $session_id |
|
406 | + ); |
|
407 | + if (!$link_info) { |
|
408 | + GradebookUtils::add_resource_to_course_gradebook( |
|
409 | + $this->category_id, |
|
410 | + $course_code, |
|
411 | + 7, |
|
412 | + $attendance_id, |
|
413 | + $title_gradebook, |
|
414 | + $weight_calification, |
|
415 | + $value_calification, |
|
416 | + $description, |
|
417 | + 1, |
|
418 | + $session_id |
|
419 | + ); |
|
420 | + } else { |
|
421 | + Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_info['id'].''); |
|
422 | + } |
|
423 | + } |
|
424 | + return $attendance_id; |
|
425 | + } |
|
426 | + return null; |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * Restore attendance |
|
431 | + * @param int|array one or many attendances id |
|
432 | + * @return int affected rows |
|
433 | + */ |
|
434 | + public function attendance_restore($attendance_id) |
|
435 | + { |
|
436 | + $_course = api_get_course_info(); |
|
437 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
438 | + $user_id = api_get_user_id(); |
|
439 | + $course_id = $_course['real_id']; |
|
440 | + if (is_array($attendance_id)) { |
|
441 | + foreach ($attendance_id as $id) { |
|
442 | + $id = intval($id); |
|
443 | + $sql = "UPDATE $tbl_attendance SET active = 1 |
|
444 | 444 | WHERE c_id = $course_id AND id = '$id'"; |
445 | - $result = Database::query($sql); |
|
446 | - $affected_rows = Database::affected_rows($result); |
|
447 | - if (!empty($affected_rows)) { |
|
448 | - // update row item property table |
|
445 | + $result = Database::query($sql); |
|
446 | + $affected_rows = Database::affected_rows($result); |
|
447 | + if (!empty($affected_rows)) { |
|
448 | + // update row item property table |
|
449 | 449 | api_item_property_update( |
450 | 450 | $_course, |
451 | 451 | TOOL_ATTENDANCE, |
@@ -453,16 +453,16 @@ discard block |
||
453 | 453 | "restore", |
454 | 454 | $user_id |
455 | 455 | ); |
456 | - } |
|
457 | - } |
|
458 | - } else { |
|
459 | - $attendance_id = intval($attendance_id); |
|
460 | - $sql = "UPDATE $tbl_attendance SET active = 1 |
|
456 | + } |
|
457 | + } |
|
458 | + } else { |
|
459 | + $attendance_id = intval($attendance_id); |
|
460 | + $sql = "UPDATE $tbl_attendance SET active = 1 |
|
461 | 461 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
462 | - $result = Database::query($sql); |
|
463 | - $affected_rows = Database::affected_rows($result); |
|
464 | - if (!empty($affected_rows)) { |
|
465 | - // update row item property table |
|
462 | + $result = Database::query($sql); |
|
463 | + $affected_rows = Database::affected_rows($result); |
|
464 | + if (!empty($affected_rows)) { |
|
465 | + // update row item property table |
|
466 | 466 | api_item_property_update( |
467 | 467 | $_course, |
468 | 468 | TOOL_ATTENDANCE, |
@@ -470,33 +470,33 @@ discard block |
||
470 | 470 | "restore", |
471 | 471 | $user_id |
472 | 472 | ); |
473 | - } |
|
474 | - } |
|
475 | - |
|
476 | - return $affected_rows; |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Delete attendances |
|
481 | - * @param int|array $attendance_id one or many attendances id |
|
482 | - * @return int affected rows |
|
483 | - */ |
|
484 | - public function attendance_delete($attendance_id) |
|
485 | - { |
|
486 | - $_course = api_get_course_info(); |
|
487 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
473 | + } |
|
474 | + } |
|
475 | + |
|
476 | + return $affected_rows; |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Delete attendances |
|
481 | + * @param int|array $attendance_id one or many attendances id |
|
482 | + * @return int affected rows |
|
483 | + */ |
|
484 | + public function attendance_delete($attendance_id) |
|
485 | + { |
|
486 | + $_course = api_get_course_info(); |
|
487 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
488 | 488 | $user_id = api_get_user_id(); |
489 | 489 | $course_id = $_course['real_id']; |
490 | 490 | |
491 | - if (is_array($attendance_id)) { |
|
492 | - foreach ($attendance_id as $id) { |
|
493 | - $id = intval($id); |
|
494 | - $sql = "UPDATE $tbl_attendance SET active = 2 |
|
491 | + if (is_array($attendance_id)) { |
|
492 | + foreach ($attendance_id as $id) { |
|
493 | + $id = intval($id); |
|
494 | + $sql = "UPDATE $tbl_attendance SET active = 2 |
|
495 | 495 | WHERE c_id = $course_id AND id = '$id'"; |
496 | - $result = Database::query($sql); |
|
497 | - $affected_rows = Database::affected_rows($result); |
|
498 | - if (!empty($affected_rows)) { |
|
499 | - // update row item property table |
|
496 | + $result = Database::query($sql); |
|
497 | + $affected_rows = Database::affected_rows($result); |
|
498 | + if (!empty($affected_rows)) { |
|
499 | + // update row item property table |
|
500 | 500 | api_item_property_update( |
501 | 501 | $_course, |
502 | 502 | TOOL_ATTENDANCE, |
@@ -504,142 +504,142 @@ discard block |
||
504 | 504 | "delete", |
505 | 505 | $user_id |
506 | 506 | ); |
507 | - } |
|
508 | - } |
|
509 | - } else { |
|
510 | - $attendance_id= intval($attendance_id); |
|
511 | - $sql = "UPDATE $tbl_attendance SET active = 2 |
|
507 | + } |
|
508 | + } |
|
509 | + } else { |
|
510 | + $attendance_id= intval($attendance_id); |
|
511 | + $sql = "UPDATE $tbl_attendance SET active = 2 |
|
512 | 512 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
513 | 513 | |
514 | - $result = Database::query($sql); |
|
515 | - $affected_rows = Database::affected_rows($result); |
|
516 | - if (!empty($affected_rows)) { |
|
517 | - // update row item property table |
|
518 | - api_item_property_update( |
|
519 | - $_course, |
|
520 | - TOOL_ATTENDANCE, |
|
521 | - $attendance_id, |
|
522 | - "delete", |
|
523 | - $user_id |
|
524 | - ); |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - return $affected_rows; |
|
529 | - } |
|
530 | - |
|
531 | - /** |
|
532 | - * Changes visibility |
|
533 | - * @param int|array $attendanceId one or many attendances id |
|
534 | - * @param int status |
|
514 | + $result = Database::query($sql); |
|
515 | + $affected_rows = Database::affected_rows($result); |
|
516 | + if (!empty($affected_rows)) { |
|
517 | + // update row item property table |
|
518 | + api_item_property_update( |
|
519 | + $_course, |
|
520 | + TOOL_ATTENDANCE, |
|
521 | + $attendance_id, |
|
522 | + "delete", |
|
523 | + $user_id |
|
524 | + ); |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + return $affected_rows; |
|
529 | + } |
|
530 | + |
|
531 | + /** |
|
532 | + * Changes visibility |
|
533 | + * @param int|array $attendanceId one or many attendances id |
|
534 | + * @param int status |
|
535 | 535 | * |
536 | - * @return int affected rows |
|
537 | - */ |
|
538 | - public function changeVisibility($attendanceId, $status = 1) |
|
539 | - { |
|
540 | - $_course = api_get_course_info(); |
|
541 | - $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
542 | - $user_id = api_get_user_id(); |
|
543 | - $course_id = $_course['real_id']; |
|
544 | - $status = intval($status); |
|
545 | - |
|
546 | - $action = 'visible'; |
|
547 | - if ($status == 0) { |
|
548 | - $action = 'invisible'; |
|
549 | - } |
|
550 | - |
|
551 | - if (is_array($attendanceId)) { |
|
552 | - foreach ($attendanceId as $id) { |
|
553 | - $id = intval($id); |
|
554 | - $sql = "UPDATE $tbl_attendance SET active = $status |
|
536 | + * @return int affected rows |
|
537 | + */ |
|
538 | + public function changeVisibility($attendanceId, $status = 1) |
|
539 | + { |
|
540 | + $_course = api_get_course_info(); |
|
541 | + $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
542 | + $user_id = api_get_user_id(); |
|
543 | + $course_id = $_course['real_id']; |
|
544 | + $status = intval($status); |
|
545 | + |
|
546 | + $action = 'visible'; |
|
547 | + if ($status == 0) { |
|
548 | + $action = 'invisible'; |
|
549 | + } |
|
550 | + |
|
551 | + if (is_array($attendanceId)) { |
|
552 | + foreach ($attendanceId as $id) { |
|
553 | + $id = intval($id); |
|
554 | + $sql = "UPDATE $tbl_attendance SET active = $status |
|
555 | 555 | WHERE c_id = $course_id AND id = '$id'"; |
556 | - $result = Database::query($sql); |
|
557 | - $affected_rows = Database::affected_rows($result); |
|
558 | - if (!empty($affected_rows)) { |
|
559 | - // update row item property table |
|
560 | - api_item_property_update($_course, TOOL_ATTENDANCE, $id, $action, $user_id); |
|
561 | - } |
|
562 | - } |
|
563 | - } else { |
|
564 | - $attendanceId = intval($attendanceId); |
|
565 | - $sql = "UPDATE $tbl_attendance SET active = $status |
|
556 | + $result = Database::query($sql); |
|
557 | + $affected_rows = Database::affected_rows($result); |
|
558 | + if (!empty($affected_rows)) { |
|
559 | + // update row item property table |
|
560 | + api_item_property_update($_course, TOOL_ATTENDANCE, $id, $action, $user_id); |
|
561 | + } |
|
562 | + } |
|
563 | + } else { |
|
564 | + $attendanceId = intval($attendanceId); |
|
565 | + $sql = "UPDATE $tbl_attendance SET active = $status |
|
566 | 566 | WHERE c_id = $course_id AND id = '$attendanceId'"; |
567 | - $result = Database::query($sql); |
|
568 | - $affected_rows = Database::affected_rows($result); |
|
569 | - if (!empty($affected_rows)) { |
|
570 | - // update row item property table |
|
571 | - api_item_property_update( |
|
572 | - $_course, |
|
573 | - TOOL_ATTENDANCE, |
|
574 | - $attendanceId, |
|
575 | - $action, |
|
576 | - $user_id |
|
577 | - ); |
|
578 | - } |
|
579 | - } |
|
580 | - |
|
581 | - return $affected_rows; |
|
582 | - } |
|
583 | - |
|
584 | - /** |
|
585 | - * Lock or unlock an attendance |
|
586 | - * @param int attendance id |
|
587 | - * @param bool True to lock or false otherwise |
|
588 | - */ |
|
589 | - public function lock_attendance($attendance_id, $lock = true) |
|
590 | - { |
|
591 | - $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
592 | - $course_id = api_get_course_int_id(); |
|
593 | - $attendance_id = intval($attendance_id); |
|
594 | - $locked = ($lock)?1:0; |
|
595 | - $upd = "UPDATE $tbl_attendance SET locked = $locked |
|
567 | + $result = Database::query($sql); |
|
568 | + $affected_rows = Database::affected_rows($result); |
|
569 | + if (!empty($affected_rows)) { |
|
570 | + // update row item property table |
|
571 | + api_item_property_update( |
|
572 | + $_course, |
|
573 | + TOOL_ATTENDANCE, |
|
574 | + $attendanceId, |
|
575 | + $action, |
|
576 | + $user_id |
|
577 | + ); |
|
578 | + } |
|
579 | + } |
|
580 | + |
|
581 | + return $affected_rows; |
|
582 | + } |
|
583 | + |
|
584 | + /** |
|
585 | + * Lock or unlock an attendance |
|
586 | + * @param int attendance id |
|
587 | + * @param bool True to lock or false otherwise |
|
588 | + */ |
|
589 | + public function lock_attendance($attendance_id, $lock = true) |
|
590 | + { |
|
591 | + $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
592 | + $course_id = api_get_course_int_id(); |
|
593 | + $attendance_id = intval($attendance_id); |
|
594 | + $locked = ($lock)?1:0; |
|
595 | + $upd = "UPDATE $tbl_attendance SET locked = $locked |
|
596 | 596 | WHERE c_id = $course_id AND id = $attendance_id"; |
597 | - $result = Database::query($upd); |
|
598 | - $affected_rows = Database::affected_rows($result); |
|
599 | - if ($affected_rows && $lock) { |
|
600 | - // Save attendance sheet log |
|
601 | - $lastedit_date = api_get_utc_datetime(); |
|
602 | - $lastedit_type = self::LOCKED_ATTENDANCE_LOG_TYPE; |
|
603 | - $lastedit_user_id = api_get_user_id(); |
|
604 | - $this->save_attendance_sheet_log( |
|
605 | - $attendance_id, |
|
606 | - $lastedit_date, |
|
607 | - $lastedit_type, |
|
608 | - $lastedit_user_id |
|
609 | - ); |
|
610 | - } |
|
611 | - return $affected_rows; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Get registered users inside current course |
|
616 | - * @param int $attendance_id attendance id for showing attendance result field (optional) |
|
617 | - * @param int $groupId |
|
618 | - * @return array users data |
|
619 | - */ |
|
620 | - public function get_users_rel_course($attendance_id = 0, $groupId = null) |
|
621 | - { |
|
622 | - $current_session_id = api_get_session_id(); |
|
623 | - $current_course_id = api_get_course_id(); |
|
624 | - $currentCourseIntId = api_get_course_int_id(); |
|
625 | - |
|
626 | - $studentInGroup = array(); |
|
627 | - |
|
628 | - if (!empty($current_session_id)) { |
|
629 | - $a_course_users = CourseManager:: get_user_list_from_course_code( |
|
630 | - $current_course_id, |
|
631 | - $current_session_id, |
|
632 | - '', |
|
633 | - 'lastname' |
|
634 | - ); |
|
635 | - } else { |
|
636 | - $a_course_users = CourseManager:: get_user_list_from_course_code( |
|
637 | - $current_course_id, |
|
638 | - 0, |
|
639 | - '', |
|
640 | - 'lastname' |
|
641 | - ); |
|
642 | - } |
|
597 | + $result = Database::query($upd); |
|
598 | + $affected_rows = Database::affected_rows($result); |
|
599 | + if ($affected_rows && $lock) { |
|
600 | + // Save attendance sheet log |
|
601 | + $lastedit_date = api_get_utc_datetime(); |
|
602 | + $lastedit_type = self::LOCKED_ATTENDANCE_LOG_TYPE; |
|
603 | + $lastedit_user_id = api_get_user_id(); |
|
604 | + $this->save_attendance_sheet_log( |
|
605 | + $attendance_id, |
|
606 | + $lastedit_date, |
|
607 | + $lastedit_type, |
|
608 | + $lastedit_user_id |
|
609 | + ); |
|
610 | + } |
|
611 | + return $affected_rows; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Get registered users inside current course |
|
616 | + * @param int $attendance_id attendance id for showing attendance result field (optional) |
|
617 | + * @param int $groupId |
|
618 | + * @return array users data |
|
619 | + */ |
|
620 | + public function get_users_rel_course($attendance_id = 0, $groupId = null) |
|
621 | + { |
|
622 | + $current_session_id = api_get_session_id(); |
|
623 | + $current_course_id = api_get_course_id(); |
|
624 | + $currentCourseIntId = api_get_course_int_id(); |
|
625 | + |
|
626 | + $studentInGroup = array(); |
|
627 | + |
|
628 | + if (!empty($current_session_id)) { |
|
629 | + $a_course_users = CourseManager:: get_user_list_from_course_code( |
|
630 | + $current_course_id, |
|
631 | + $current_session_id, |
|
632 | + '', |
|
633 | + 'lastname' |
|
634 | + ); |
|
635 | + } else { |
|
636 | + $a_course_users = CourseManager:: get_user_list_from_course_code( |
|
637 | + $current_course_id, |
|
638 | + 0, |
|
639 | + '', |
|
640 | + 'lastname' |
|
641 | + ); |
|
642 | + } |
|
643 | 643 | |
644 | 644 | if (!empty($groupId)) { |
645 | 645 | $students = GroupManager::getStudents($groupId); |
@@ -650,192 +650,192 @@ discard block |
||
650 | 650 | } |
651 | 651 | } |
652 | 652 | |
653 | - // get registered users inside current course |
|
654 | - $a_users = array(); |
|
655 | - foreach ($a_course_users as $key => $user_data) { |
|
656 | - $value = array(); |
|
657 | - $uid = $user_data['user_id']; |
|
658 | - $userInfo = api_get_user_info($uid); |
|
659 | - |
|
660 | - $status = $user_data['status']; |
|
661 | - |
|
662 | - if (!empty($groupId)) { |
|
663 | - if (!isset($studentInGroup[$uid])) { |
|
664 | - continue; |
|
665 | - } |
|
666 | - } |
|
667 | - |
|
668 | - $user_status_in_session = null; |
|
669 | - $user_status_in_course = null; |
|
670 | - |
|
671 | - if (api_get_session_id()) { |
|
672 | - $user_status_in_session = SessionManager::get_user_status_in_course_session( |
|
673 | - $uid, |
|
674 | - $currentCourseIntId, |
|
675 | - $current_session_id |
|
676 | - ); |
|
677 | - } else { |
|
678 | - $user_status_in_course = CourseManager::get_user_in_course_status( |
|
679 | - $uid, |
|
680 | - $current_course_id |
|
681 | - ); |
|
682 | - } |
|
683 | - |
|
684 | - // Not taking into account DRH or COURSEMANAGER |
|
685 | - if ($uid <= 1 || |
|
686 | - $status == DRH || |
|
687 | - $user_status_in_course == COURSEMANAGER || |
|
688 | - $user_status_in_session == 2 |
|
689 | - ) { |
|
690 | - continue; |
|
691 | - } |
|
692 | - |
|
693 | - if (!empty($attendance_id)) { |
|
694 | - $user_faults = $this->get_faults_of_user($uid, $attendance_id, $groupId); |
|
695 | - $value['attendance_result'] = $user_faults['faults'].'/'.$user_faults['total'].' ('.$user_faults['faults_porcent'].'%)'; |
|
696 | - $value['result_color_bar'] = $user_faults['color_bar']; |
|
697 | - } |
|
653 | + // get registered users inside current course |
|
654 | + $a_users = array(); |
|
655 | + foreach ($a_course_users as $key => $user_data) { |
|
656 | + $value = array(); |
|
657 | + $uid = $user_data['user_id']; |
|
658 | + $userInfo = api_get_user_info($uid); |
|
659 | + |
|
660 | + $status = $user_data['status']; |
|
661 | + |
|
662 | + if (!empty($groupId)) { |
|
663 | + if (!isset($studentInGroup[$uid])) { |
|
664 | + continue; |
|
665 | + } |
|
666 | + } |
|
667 | + |
|
668 | + $user_status_in_session = null; |
|
669 | + $user_status_in_course = null; |
|
670 | + |
|
671 | + if (api_get_session_id()) { |
|
672 | + $user_status_in_session = SessionManager::get_user_status_in_course_session( |
|
673 | + $uid, |
|
674 | + $currentCourseIntId, |
|
675 | + $current_session_id |
|
676 | + ); |
|
677 | + } else { |
|
678 | + $user_status_in_course = CourseManager::get_user_in_course_status( |
|
679 | + $uid, |
|
680 | + $current_course_id |
|
681 | + ); |
|
682 | + } |
|
683 | + |
|
684 | + // Not taking into account DRH or COURSEMANAGER |
|
685 | + if ($uid <= 1 || |
|
686 | + $status == DRH || |
|
687 | + $user_status_in_course == COURSEMANAGER || |
|
688 | + $user_status_in_session == 2 |
|
689 | + ) { |
|
690 | + continue; |
|
691 | + } |
|
692 | + |
|
693 | + if (!empty($attendance_id)) { |
|
694 | + $user_faults = $this->get_faults_of_user($uid, $attendance_id, $groupId); |
|
695 | + $value['attendance_result'] = $user_faults['faults'].'/'.$user_faults['total'].' ('.$user_faults['faults_porcent'].'%)'; |
|
696 | + $value['result_color_bar'] = $user_faults['color_bar']; |
|
697 | + } |
|
698 | 698 | |
699 | 699 | $photo = Display::img($userInfo['avatar_small'], $userInfo['complete_name'], [], false); |
700 | 700 | |
701 | - $value['photo'] = $photo; |
|
702 | - $value['firstname'] = $user_data['firstname']; |
|
703 | - $value['lastname'] = $user_data['lastname']; |
|
704 | - $value['username'] = $user_data['username']; |
|
705 | - $value['user_id'] = $uid; |
|
706 | - |
|
707 | - //Sending only 5 items in the array instead of 60 |
|
708 | - $a_users[$key] = $value; |
|
709 | - } |
|
710 | - |
|
711 | - return $a_users; |
|
712 | - } |
|
713 | - |
|
714 | - /** |
|
715 | - * add attendances sheet inside table |
|
716 | - * @param int $calendar_id attendance calendar id |
|
717 | - * @param array $users_present present users during current class |
|
718 | - * @param int $attendance_id |
|
719 | - * @return int affected rows |
|
720 | - */ |
|
721 | - public function attendance_sheet_add($calendar_id, $users_present, $attendance_id) |
|
722 | - { |
|
723 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
724 | - $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
725 | - |
|
726 | - $calendar_id = intval($calendar_id); |
|
727 | - $attendance_id = intval($attendance_id); |
|
728 | - $users = $this->get_users_rel_course(); |
|
729 | - $course_id = api_get_course_int_id(); |
|
730 | - |
|
731 | - $user_ids = array_keys($users); |
|
732 | - $users_absent = array_diff($user_ids,$users_present); |
|
733 | - $affected_rows = 0; |
|
734 | - |
|
735 | - // get last edit type |
|
736 | - $calendar_data = $this->get_attendance_calendar_by_id($calendar_id); |
|
737 | - $lastedit_type = self::DONE_ATTENDANCE_LOG_TYPE; |
|
738 | - if ($calendar_data['done_attendance']) { |
|
739 | - $lastedit_type = self::UPDATED_ATTENDANCE_LOG_TYPE; |
|
740 | - } |
|
741 | - |
|
742 | - // save users present in class |
|
743 | - foreach ($users_present as $user_present) { |
|
744 | - $uid = intval($user_present); |
|
745 | - // check if user already was registered with the $calendar_id |
|
746 | - $sql = "SELECT user_id FROM $tbl_attendance_sheet |
|
701 | + $value['photo'] = $photo; |
|
702 | + $value['firstname'] = $user_data['firstname']; |
|
703 | + $value['lastname'] = $user_data['lastname']; |
|
704 | + $value['username'] = $user_data['username']; |
|
705 | + $value['user_id'] = $uid; |
|
706 | + |
|
707 | + //Sending only 5 items in the array instead of 60 |
|
708 | + $a_users[$key] = $value; |
|
709 | + } |
|
710 | + |
|
711 | + return $a_users; |
|
712 | + } |
|
713 | + |
|
714 | + /** |
|
715 | + * add attendances sheet inside table |
|
716 | + * @param int $calendar_id attendance calendar id |
|
717 | + * @param array $users_present present users during current class |
|
718 | + * @param int $attendance_id |
|
719 | + * @return int affected rows |
|
720 | + */ |
|
721 | + public function attendance_sheet_add($calendar_id, $users_present, $attendance_id) |
|
722 | + { |
|
723 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
724 | + $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
725 | + |
|
726 | + $calendar_id = intval($calendar_id); |
|
727 | + $attendance_id = intval($attendance_id); |
|
728 | + $users = $this->get_users_rel_course(); |
|
729 | + $course_id = api_get_course_int_id(); |
|
730 | + |
|
731 | + $user_ids = array_keys($users); |
|
732 | + $users_absent = array_diff($user_ids,$users_present); |
|
733 | + $affected_rows = 0; |
|
734 | + |
|
735 | + // get last edit type |
|
736 | + $calendar_data = $this->get_attendance_calendar_by_id($calendar_id); |
|
737 | + $lastedit_type = self::DONE_ATTENDANCE_LOG_TYPE; |
|
738 | + if ($calendar_data['done_attendance']) { |
|
739 | + $lastedit_type = self::UPDATED_ATTENDANCE_LOG_TYPE; |
|
740 | + } |
|
741 | + |
|
742 | + // save users present in class |
|
743 | + foreach ($users_present as $user_present) { |
|
744 | + $uid = intval($user_present); |
|
745 | + // check if user already was registered with the $calendar_id |
|
746 | + $sql = "SELECT user_id FROM $tbl_attendance_sheet |
|
747 | 747 | WHERE c_id = $course_id AND user_id='$uid' AND attendance_calendar_id = '$calendar_id'"; |
748 | - $rs = Database::query($sql); |
|
749 | - if (Database::num_rows($rs) == 0) { |
|
750 | - $sql = "INSERT INTO $tbl_attendance_sheet SET |
|
748 | + $rs = Database::query($sql); |
|
749 | + if (Database::num_rows($rs) == 0) { |
|
750 | + $sql = "INSERT INTO $tbl_attendance_sheet SET |
|
751 | 751 | c_id = $course_id, |
752 | 752 | user_id = '$uid', |
753 | 753 | attendance_calendar_id = '$calendar_id', |
754 | 754 | presence = 1"; |
755 | - $result = Database::query($sql); |
|
755 | + $result = Database::query($sql); |
|
756 | 756 | |
757 | - $affected_rows += Database::affected_rows($result); |
|
758 | - } else { |
|
759 | - $sql = "UPDATE $tbl_attendance_sheet SET presence = 1 |
|
757 | + $affected_rows += Database::affected_rows($result); |
|
758 | + } else { |
|
759 | + $sql = "UPDATE $tbl_attendance_sheet SET presence = 1 |
|
760 | 760 | WHERE |
761 | 761 | c_id = $course_id AND |
762 | 762 | user_id ='$uid' AND |
763 | 763 | attendance_calendar_id = '$calendar_id' |
764 | 764 | "; |
765 | - $result = Database::query($sql); |
|
766 | - $affected_rows += Database::affected_rows($result); |
|
767 | - } |
|
768 | - } |
|
769 | - |
|
770 | - // save users absent in class |
|
771 | - foreach ($users_absent as $user_absent) { |
|
772 | - $uid = intval($user_absent); |
|
773 | - // check if user already was registered with the $calendar_id |
|
774 | - $sql = "SELECT user_id FROM $tbl_attendance_sheet |
|
765 | + $result = Database::query($sql); |
|
766 | + $affected_rows += Database::affected_rows($result); |
|
767 | + } |
|
768 | + } |
|
769 | + |
|
770 | + // save users absent in class |
|
771 | + foreach ($users_absent as $user_absent) { |
|
772 | + $uid = intval($user_absent); |
|
773 | + // check if user already was registered with the $calendar_id |
|
774 | + $sql = "SELECT user_id FROM $tbl_attendance_sheet |
|
775 | 775 | WHERE c_id = $course_id AND user_id='$uid' AND attendance_calendar_id = '$calendar_id'"; |
776 | - $rs = Database::query($sql); |
|
777 | - if (Database::num_rows($rs) == 0) { |
|
778 | - $sql = "INSERT INTO $tbl_attendance_sheet SET |
|
776 | + $rs = Database::query($sql); |
|
777 | + if (Database::num_rows($rs) == 0) { |
|
778 | + $sql = "INSERT INTO $tbl_attendance_sheet SET |
|
779 | 779 | c_id = $course_id, |
780 | 780 | user_id ='$uid', |
781 | 781 | attendance_calendar_id = '$calendar_id', |
782 | 782 | presence = 0"; |
783 | - $result = Database::query($sql); |
|
783 | + $result = Database::query($sql); |
|
784 | 784 | |
785 | - Database::insert_id(); |
|
785 | + Database::insert_id(); |
|
786 | 786 | |
787 | - $affected_rows += Database::affected_rows($result); |
|
788 | - } else { |
|
789 | - $sql = "UPDATE $tbl_attendance_sheet SET presence = 0 |
|
787 | + $affected_rows += Database::affected_rows($result); |
|
788 | + } else { |
|
789 | + $sql = "UPDATE $tbl_attendance_sheet SET presence = 0 |
|
790 | 790 | WHERE |
791 | 791 | c_id = $course_id AND |
792 | 792 | user_id ='$uid' AND |
793 | 793 | attendance_calendar_id = '$calendar_id'"; |
794 | - $result = Database::query($sql); |
|
795 | - $affected_rows += Database::affected_rows($result); |
|
796 | - } |
|
797 | - } |
|
794 | + $result = Database::query($sql); |
|
795 | + $affected_rows += Database::affected_rows($result); |
|
796 | + } |
|
797 | + } |
|
798 | 798 | |
799 | - // update done_attendance inside attendance calendar table |
|
800 | - $sql = "UPDATE $tbl_attendance_calendar SET done_attendance = 1 |
|
799 | + // update done_attendance inside attendance calendar table |
|
800 | + $sql = "UPDATE $tbl_attendance_calendar SET done_attendance = 1 |
|
801 | 801 | WHERE c_id = $course_id AND id = '$calendar_id'"; |
802 | - Database::query($sql); |
|
803 | - |
|
804 | - // save users' results |
|
805 | - $this->update_users_results($user_ids, $attendance_id); |
|
806 | - |
|
807 | - if ($affected_rows) { |
|
808 | - //save attendance sheet log |
|
809 | - $lastedit_date = api_get_utc_datetime(); |
|
810 | - $lastedit_user_id = api_get_user_id(); |
|
811 | - $calendar_date_value = $calendar_data['date_time']; |
|
812 | - $this->save_attendance_sheet_log( |
|
813 | - $attendance_id, |
|
814 | - $lastedit_date, |
|
815 | - $lastedit_type, |
|
816 | - $lastedit_user_id, |
|
817 | - $calendar_date_value |
|
818 | - ); |
|
819 | - } |
|
820 | - |
|
821 | - return $affected_rows; |
|
822 | - } |
|
823 | - |
|
824 | - /** |
|
825 | - * update users' attendance results |
|
826 | - * @param array $user_ids registered users inside current course |
|
827 | - * @param int $attendance_id |
|
828 | - * @return void |
|
829 | - */ |
|
830 | - public function update_users_results($user_ids, $attendance_id) |
|
831 | - { |
|
832 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
833 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
834 | - $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
835 | - $course_id = api_get_course_int_id(); |
|
836 | - |
|
837 | - $attendance_id = intval($attendance_id); |
|
838 | - // fill results about presence of students |
|
802 | + Database::query($sql); |
|
803 | + |
|
804 | + // save users' results |
|
805 | + $this->update_users_results($user_ids, $attendance_id); |
|
806 | + |
|
807 | + if ($affected_rows) { |
|
808 | + //save attendance sheet log |
|
809 | + $lastedit_date = api_get_utc_datetime(); |
|
810 | + $lastedit_user_id = api_get_user_id(); |
|
811 | + $calendar_date_value = $calendar_data['date_time']; |
|
812 | + $this->save_attendance_sheet_log( |
|
813 | + $attendance_id, |
|
814 | + $lastedit_date, |
|
815 | + $lastedit_type, |
|
816 | + $lastedit_user_id, |
|
817 | + $calendar_date_value |
|
818 | + ); |
|
819 | + } |
|
820 | + |
|
821 | + return $affected_rows; |
|
822 | + } |
|
823 | + |
|
824 | + /** |
|
825 | + * update users' attendance results |
|
826 | + * @param array $user_ids registered users inside current course |
|
827 | + * @param int $attendance_id |
|
828 | + * @return void |
|
829 | + */ |
|
830 | + public function update_users_results($user_ids, $attendance_id) |
|
831 | + { |
|
832 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
833 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
834 | + $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); |
|
835 | + $course_id = api_get_course_int_id(); |
|
836 | + |
|
837 | + $attendance_id = intval($attendance_id); |
|
838 | + // fill results about presence of students |
|
839 | 839 | $attendance_calendar = $this->get_attendance_calendar( |
840 | 840 | $attendance_id, |
841 | 841 | 'all', |
@@ -843,82 +843,82 @@ discard block |
||
843 | 843 | null, |
844 | 844 | true |
845 | 845 | ); |
846 | - $calendar_ids = array(); |
|
847 | - // get all dates from calendar by current attendance |
|
848 | - foreach ($attendance_calendar as $cal) { |
|
849 | - $calendar_ids[] = $cal['id']; |
|
850 | - } |
|
851 | - |
|
852 | - // get count of presences by users inside current attendance and save like results |
|
853 | - if (count($user_ids) > 0) { |
|
854 | - foreach ($user_ids as $uid) { |
|
855 | - $count_presences = 0; |
|
856 | - if (count($calendar_ids) > 0) { |
|
857 | - $sql = "SELECT count(presence) as count_presences |
|
846 | + $calendar_ids = array(); |
|
847 | + // get all dates from calendar by current attendance |
|
848 | + foreach ($attendance_calendar as $cal) { |
|
849 | + $calendar_ids[] = $cal['id']; |
|
850 | + } |
|
851 | + |
|
852 | + // get count of presences by users inside current attendance and save like results |
|
853 | + if (count($user_ids) > 0) { |
|
854 | + foreach ($user_ids as $uid) { |
|
855 | + $count_presences = 0; |
|
856 | + if (count($calendar_ids) > 0) { |
|
857 | + $sql = "SELECT count(presence) as count_presences |
|
858 | 858 | FROM $tbl_attendance_sheet |
859 | 859 | WHERE |
860 | 860 | c_id = $course_id AND |
861 | 861 | user_id = '$uid' AND |
862 | 862 | attendance_calendar_id IN (".implode(',', $calendar_ids).") AND |
863 | 863 | presence = 1"; |
864 | - $rs_count = Database::query($sql); |
|
865 | - $row_count = Database::fetch_array($rs_count); |
|
866 | - $count_presences = $row_count['count_presences']; |
|
867 | - } |
|
864 | + $rs_count = Database::query($sql); |
|
865 | + $row_count = Database::fetch_array($rs_count); |
|
866 | + $count_presences = $row_count['count_presences']; |
|
867 | + } |
|
868 | 868 | |
869 | - // save results |
|
870 | - $sql = "SELECT id FROM $tbl_attendance_result |
|
869 | + // save results |
|
870 | + $sql = "SELECT id FROM $tbl_attendance_result |
|
871 | 871 | WHERE |
872 | 872 | c_id = $course_id AND |
873 | 873 | user_id = '$uid' AND |
874 | 874 | attendance_id = '$attendance_id' "; |
875 | - $rs_check_result = Database::query($sql); |
|
875 | + $rs_check_result = Database::query($sql); |
|
876 | 876 | |
877 | - if (Database::num_rows($rs_check_result) > 0) { |
|
878 | - // update result |
|
879 | - $sql = "UPDATE $tbl_attendance_result SET |
|
877 | + if (Database::num_rows($rs_check_result) > 0) { |
|
878 | + // update result |
|
879 | + $sql = "UPDATE $tbl_attendance_result SET |
|
880 | 880 | score = '$count_presences' |
881 | 881 | WHERE |
882 | 882 | c_id = $course_id AND |
883 | 883 | user_id='$uid' AND |
884 | 884 | attendance_id='$attendance_id'"; |
885 | - Database::query($sql); |
|
886 | - } else { |
|
887 | - // insert new result |
|
888 | - $sql = "INSERT INTO $tbl_attendance_result SET |
|
885 | + Database::query($sql); |
|
886 | + } else { |
|
887 | + // insert new result |
|
888 | + $sql = "INSERT INTO $tbl_attendance_result SET |
|
889 | 889 | c_id = $course_id , |
890 | 890 | user_id = '$uid', |
891 | 891 | attendance_id = '$attendance_id', |
892 | 892 | score = '$count_presences'"; |
893 | - Database::query($sql); |
|
893 | + Database::query($sql); |
|
894 | 894 | |
895 | - $insertId = Database::insert_id(); |
|
895 | + $insertId = Database::insert_id(); |
|
896 | 896 | if ($insertId) { |
897 | 897 | $sql = "UPDATE $tbl_attendance_result SET id = iid WHERE iid = $insertId"; |
898 | 898 | Database::query($sql); |
899 | 899 | } |
900 | - } |
|
901 | - } |
|
902 | - } |
|
900 | + } |
|
901 | + } |
|
902 | + } |
|
903 | 903 | |
904 | - // update attendance qualify max |
|
905 | - $count_done_calendar = self::get_done_attendance_calendar($attendance_id); |
|
904 | + // update attendance qualify max |
|
905 | + $count_done_calendar = self::get_done_attendance_calendar($attendance_id); |
|
906 | 906 | |
907 | - $sql = "UPDATE $tbl_attendance SET |
|
907 | + $sql = "UPDATE $tbl_attendance SET |
|
908 | 908 | attendance_qualify_max = '$count_done_calendar' |
909 | 909 | WHERE c_id = $course_id AND id = '$attendance_id'"; |
910 | - Database::query($sql); |
|
911 | - } |
|
912 | - |
|
913 | - /** |
|
914 | - * update attendance_sheet_log table, is used as history of an attendance sheet |
|
915 | - * @param int Attendance id |
|
916 | - * @param string Last edit datetime |
|
917 | - * @param string Event type ('locked_attendance', 'done_attendance_sheet' ...) |
|
918 | - * @param int Last edit user id |
|
919 | - * @param string Calendar datetime value (optional, when event type is 'done_attendance_sheet') |
|
920 | - * @return int Affected rows |
|
921 | - */ |
|
910 | + Database::query($sql); |
|
911 | + } |
|
912 | + |
|
913 | + /** |
|
914 | + * update attendance_sheet_log table, is used as history of an attendance sheet |
|
915 | + * @param int Attendance id |
|
916 | + * @param string Last edit datetime |
|
917 | + * @param string Event type ('locked_attendance', 'done_attendance_sheet' ...) |
|
918 | + * @param int Last edit user id |
|
919 | + * @param string Calendar datetime value (optional, when event type is 'done_attendance_sheet') |
|
920 | + * @return int Affected rows |
|
921 | + */ |
|
922 | 922 | public function save_attendance_sheet_log( |
923 | 923 | $attendance_id, |
924 | 924 | $lastedit_date, |
@@ -926,22 +926,22 @@ discard block |
||
926 | 926 | $lastedit_user_id, |
927 | 927 | $calendar_date_value = null |
928 | 928 | ) { |
929 | - $course_id = api_get_course_int_id(); |
|
929 | + $course_id = api_get_course_int_id(); |
|
930 | 930 | |
931 | - // define table |
|
932 | - $tbl_attendance_sheet_log = Database::get_course_table(TABLE_ATTENDANCE_SHEET_LOG); |
|
931 | + // define table |
|
932 | + $tbl_attendance_sheet_log = Database::get_course_table(TABLE_ATTENDANCE_SHEET_LOG); |
|
933 | 933 | |
934 | - // protect data |
|
935 | - $attendance_id = intval($attendance_id); |
|
936 | - $lastedit_user_id = intval($lastedit_user_id); |
|
934 | + // protect data |
|
935 | + $attendance_id = intval($attendance_id); |
|
936 | + $lastedit_user_id = intval($lastedit_user_id); |
|
937 | 937 | |
938 | - if (isset($calendar_date_value)) { |
|
939 | - $calendar_date_value = $calendar_date_value; |
|
940 | - } else { |
|
941 | - $calendar_date_value = ''; |
|
942 | - } |
|
938 | + if (isset($calendar_date_value)) { |
|
939 | + $calendar_date_value = $calendar_date_value; |
|
940 | + } else { |
|
941 | + $calendar_date_value = ''; |
|
942 | + } |
|
943 | 943 | |
944 | - // save data |
|
944 | + // save data |
|
945 | 945 | $params = [ |
946 | 946 | 'c_id' => $course_id, |
947 | 947 | 'attendance_id' => $attendance_id, |
@@ -950,228 +950,228 @@ discard block |
||
950 | 950 | 'lastedit_user_id' => $lastedit_user_id, |
951 | 951 | 'calendar_date_value' => $calendar_date_value, |
952 | 952 | ]; |
953 | - $insertId = Database::insert($tbl_attendance_sheet_log, $params); |
|
953 | + $insertId = Database::insert($tbl_attendance_sheet_log, $params); |
|
954 | 954 | if ($insertId) { |
955 | 955 | $sql = "UPDATE $tbl_attendance_sheet_log SET id = iid WHERE iid = $insertId"; |
956 | 956 | Database::query($sql); |
957 | 957 | } |
958 | 958 | |
959 | - return $insertId; |
|
960 | - } |
|
961 | - |
|
962 | - /** |
|
963 | - * Get number of done attendances inside current sheet |
|
964 | - * @param int attendance id |
|
965 | - * @return int number of done attendances |
|
966 | - */ |
|
967 | - public static function get_done_attendance_calendar($attendance_id) |
|
968 | - { |
|
969 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
970 | - $attendance_id = intval($attendance_id); |
|
971 | - $course_id = api_get_course_int_id(); |
|
972 | - $sql = "SELECT count(done_attendance) as count |
|
959 | + return $insertId; |
|
960 | + } |
|
961 | + |
|
962 | + /** |
|
963 | + * Get number of done attendances inside current sheet |
|
964 | + * @param int attendance id |
|
965 | + * @return int number of done attendances |
|
966 | + */ |
|
967 | + public static function get_done_attendance_calendar($attendance_id) |
|
968 | + { |
|
969 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
970 | + $attendance_id = intval($attendance_id); |
|
971 | + $course_id = api_get_course_int_id(); |
|
972 | + $sql = "SELECT count(done_attendance) as count |
|
973 | 973 | FROM $tbl_attendance_calendar |
974 | 974 | WHERE |
975 | 975 | c_id = $course_id AND |
976 | 976 | attendance_id = '$attendance_id' AND |
977 | 977 | done_attendance = 1 |
978 | 978 | "; |
979 | - $rs = Database::query($sql); |
|
980 | - $row = Database::fetch_array($rs); |
|
981 | - $count = $row['count']; |
|
982 | - return $count; |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * Get results of faults (absents) by user |
|
987 | - * @param int $user_id |
|
988 | - * @param int $attendance_id |
|
989 | - * @param int $groupId |
|
990 | - * @return array results containing number of faults, total done attendance, |
|
991 | - * percent of faults and color depend on result (red, orange) |
|
992 | - */ |
|
993 | - public function get_faults_of_user($user_id, $attendance_id, $groupId = null) |
|
994 | - { |
|
995 | - // initializing database table and variables |
|
996 | - $user_id = intval($user_id); |
|
997 | - $attendance_id = intval($attendance_id); |
|
998 | - $results = array(); |
|
999 | - $calendar_count = self::get_number_of_attendance_calendar($attendance_id, $groupId, NULL, $user_id); |
|
1000 | - // $total_done_attendance = $attendance_data['attendance_qualify_max']; |
|
979 | + $rs = Database::query($sql); |
|
980 | + $row = Database::fetch_array($rs); |
|
981 | + $count = $row['count']; |
|
982 | + return $count; |
|
983 | + } |
|
984 | + |
|
985 | + /** |
|
986 | + * Get results of faults (absents) by user |
|
987 | + * @param int $user_id |
|
988 | + * @param int $attendance_id |
|
989 | + * @param int $groupId |
|
990 | + * @return array results containing number of faults, total done attendance, |
|
991 | + * percent of faults and color depend on result (red, orange) |
|
992 | + */ |
|
993 | + public function get_faults_of_user($user_id, $attendance_id, $groupId = null) |
|
994 | + { |
|
995 | + // initializing database table and variables |
|
996 | + $user_id = intval($user_id); |
|
997 | + $attendance_id = intval($attendance_id); |
|
998 | + $results = array(); |
|
999 | + $calendar_count = self::get_number_of_attendance_calendar($attendance_id, $groupId, NULL, $user_id); |
|
1000 | + // $total_done_attendance = $attendance_data['attendance_qualify_max']; |
|
1001 | 1001 | $total_done_attendance = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id); |
1002 | - $attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId); |
|
1002 | + $attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId); |
|
1003 | 1003 | |
1004 | - //This is the main change of the BT#1381 |
|
1005 | - //$total_done_attendance = $calendar_count; |
|
1004 | + //This is the main change of the BT#1381 |
|
1005 | + //$total_done_attendance = $calendar_count; |
|
1006 | 1006 | |
1007 | - // calculate results |
|
1008 | - $faults = $total_done_attendance - $attendance_user_score; |
|
1007 | + // calculate results |
|
1008 | + $faults = $total_done_attendance - $attendance_user_score; |
|
1009 | 1009 | |
1010 | 1010 | if (empty($calendar_count)) { |
1011 | 1011 | $faults = 0; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | $faults = $faults > 0 ? $faults : 0; |
1015 | - $faults_porcent = $calendar_count > 0 ?round(($faults*100)/$calendar_count,0):0; |
|
1015 | + $faults_porcent = $calendar_count > 0 ?round(($faults*100)/$calendar_count,0):0; |
|
1016 | 1016 | $results['faults'] = $faults; |
1017 | 1017 | $results['total'] = $calendar_count; |
1018 | 1018 | $results['faults_porcent'] = $faults_porcent; |
1019 | - $color_bar = ''; |
|
1019 | + $color_bar = ''; |
|
1020 | 1020 | |
1021 | 1021 | if ($faults_porcent > 25) { |
1022 | 1022 | $color_bar = '#f28989'; |
1023 | - } else if ($faults_porcent > 10) { |
|
1024 | - $color_bar = '#F90'; |
|
1025 | - } |
|
1026 | - $results['color_bar'] = $color_bar; |
|
1027 | - |
|
1028 | - return $results; |
|
1029 | - } |
|
1030 | - |
|
1031 | - /** |
|
1032 | - * Get results of faults average for all courses by user |
|
1033 | - * @param int $user_id |
|
1034 | - * @return array results containing number of faults, total done attendance, |
|
1035 | - * percentage of faults and color depend on result (red, orange) |
|
1036 | - */ |
|
1037 | - public function get_faults_average_inside_courses($user_id) |
|
1038 | - { |
|
1039 | - // get all courses of current user |
|
1040 | - $courses = CourseManager::get_courses_list_by_user_id($user_id, true); |
|
1041 | - |
|
1042 | - $user_id = intval($user_id); |
|
1043 | - $results = array(); |
|
1044 | - $total_faults = $total_weight = $porcent = 0; |
|
1045 | - foreach ($courses as $course) { |
|
1046 | - //$course_code = $course['code']; |
|
1047 | - //$course_info = api_get_course_info($course_code); |
|
1048 | - $course_id = $course['real_id']; |
|
1049 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1050 | - |
|
1051 | - $attendances_by_course = $this->get_attendances_list($course_id); |
|
1052 | - |
|
1053 | - foreach ($attendances_by_course as $attendance) { |
|
1054 | - // get total faults and total weight |
|
1055 | - $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1056 | - $sql = "SELECT score |
|
1023 | + } else if ($faults_porcent > 10) { |
|
1024 | + $color_bar = '#F90'; |
|
1025 | + } |
|
1026 | + $results['color_bar'] = $color_bar; |
|
1027 | + |
|
1028 | + return $results; |
|
1029 | + } |
|
1030 | + |
|
1031 | + /** |
|
1032 | + * Get results of faults average for all courses by user |
|
1033 | + * @param int $user_id |
|
1034 | + * @return array results containing number of faults, total done attendance, |
|
1035 | + * percentage of faults and color depend on result (red, orange) |
|
1036 | + */ |
|
1037 | + public function get_faults_average_inside_courses($user_id) |
|
1038 | + { |
|
1039 | + // get all courses of current user |
|
1040 | + $courses = CourseManager::get_courses_list_by_user_id($user_id, true); |
|
1041 | + |
|
1042 | + $user_id = intval($user_id); |
|
1043 | + $results = array(); |
|
1044 | + $total_faults = $total_weight = $porcent = 0; |
|
1045 | + foreach ($courses as $course) { |
|
1046 | + //$course_code = $course['code']; |
|
1047 | + //$course_info = api_get_course_info($course_code); |
|
1048 | + $course_id = $course['real_id']; |
|
1049 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1050 | + |
|
1051 | + $attendances_by_course = $this->get_attendances_list($course_id); |
|
1052 | + |
|
1053 | + foreach ($attendances_by_course as $attendance) { |
|
1054 | + // get total faults and total weight |
|
1055 | + $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1056 | + $sql = "SELECT score |
|
1057 | 1057 | FROM $tbl_attendance_result |
1058 | 1058 | WHERE |
1059 | 1059 | c_id = $course_id AND |
1060 | 1060 | user_id = $user_id AND |
1061 | 1061 | attendance_id = ".$attendance['id']; |
1062 | - $rs = Database::query($sql); |
|
1063 | - $score = 0; |
|
1064 | - if (Database::num_rows($rs) > 0) { |
|
1065 | - $row = Database::fetch_array($rs); |
|
1066 | - $score = $row['score']; |
|
1067 | - } |
|
1068 | - $faults = $total_done_attendance-$score; |
|
1069 | - $faults = $faults > 0 ? $faults:0; |
|
1070 | - $total_faults += $faults; |
|
1071 | - $total_weight += $total_done_attendance; |
|
1072 | - } |
|
1073 | - } |
|
1074 | - |
|
1075 | - $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1076 | - $results['faults'] = $total_faults; |
|
1077 | - $results['total'] = $total_weight; |
|
1078 | - $results['porcent'] = $porcent; |
|
1079 | - |
|
1080 | - return $results; |
|
1081 | - } |
|
1082 | - |
|
1083 | - /** |
|
1084 | - * Get results of faults average by course |
|
1085 | - * @param int $user_id |
|
1086 | - * @param string $course_code |
|
1087 | - * @param int Session id (optional) |
|
1088 | - * @return array results containing number of faults, |
|
1089 | - * total done attendance, porcent of faults and color depend on result (red, orange) |
|
1090 | - */ |
|
1091 | - public function get_faults_average_by_course($user_id, $course_code, $session_id = null) |
|
1092 | - { |
|
1093 | - // Database tables and variables |
|
1094 | - $course_info = api_get_course_info($course_code); |
|
1095 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1096 | - $user_id = intval($user_id); |
|
1097 | - $results = array(); |
|
1098 | - $total_faults = $total_weight = $porcent = 0; |
|
1099 | - $attendances_by_course = $this->get_attendances_list($course_info['real_id'], $session_id); |
|
1100 | - |
|
1101 | - foreach ($attendances_by_course as $attendance) { |
|
1102 | - // Get total faults and total weight |
|
1103 | - $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1104 | - $sql = "SELECT score FROM $tbl_attendance_result |
|
1105 | - WHERE |
|
1062 | + $rs = Database::query($sql); |
|
1063 | + $score = 0; |
|
1064 | + if (Database::num_rows($rs) > 0) { |
|
1065 | + $row = Database::fetch_array($rs); |
|
1066 | + $score = $row['score']; |
|
1067 | + } |
|
1068 | + $faults = $total_done_attendance-$score; |
|
1069 | + $faults = $faults > 0 ? $faults:0; |
|
1070 | + $total_faults += $faults; |
|
1071 | + $total_weight += $total_done_attendance; |
|
1072 | + } |
|
1073 | + } |
|
1074 | + |
|
1075 | + $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1076 | + $results['faults'] = $total_faults; |
|
1077 | + $results['total'] = $total_weight; |
|
1078 | + $results['porcent'] = $porcent; |
|
1079 | + |
|
1080 | + return $results; |
|
1081 | + } |
|
1082 | + |
|
1083 | + /** |
|
1084 | + * Get results of faults average by course |
|
1085 | + * @param int $user_id |
|
1086 | + * @param string $course_code |
|
1087 | + * @param int Session id (optional) |
|
1088 | + * @return array results containing number of faults, |
|
1089 | + * total done attendance, porcent of faults and color depend on result (red, orange) |
|
1090 | + */ |
|
1091 | + public function get_faults_average_by_course($user_id, $course_code, $session_id = null) |
|
1092 | + { |
|
1093 | + // Database tables and variables |
|
1094 | + $course_info = api_get_course_info($course_code); |
|
1095 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1096 | + $user_id = intval($user_id); |
|
1097 | + $results = array(); |
|
1098 | + $total_faults = $total_weight = $porcent = 0; |
|
1099 | + $attendances_by_course = $this->get_attendances_list($course_info['real_id'], $session_id); |
|
1100 | + |
|
1101 | + foreach ($attendances_by_course as $attendance) { |
|
1102 | + // Get total faults and total weight |
|
1103 | + $total_done_attendance = $attendance['attendance_qualify_max']; |
|
1104 | + $sql = "SELECT score FROM $tbl_attendance_result |
|
1105 | + WHERE |
|
1106 | 1106 | c_id = {$course_info['real_id']} AND |
1107 | 1107 | user_id = $user_id AND |
1108 | 1108 | attendance_id=".$attendance['id']; |
1109 | - $rs = Database::query($sql); |
|
1110 | - $score = 0; |
|
1111 | - if (Database::num_rows($rs) > 0) { |
|
1112 | - $row = Database::fetch_array($rs); |
|
1113 | - $score = $row['score']; |
|
1114 | - } |
|
1115 | - $faults = $total_done_attendance-$score; |
|
1116 | - $faults = $faults > 0 ? $faults:0; |
|
1117 | - $total_faults += $faults; |
|
1118 | - $total_weight += $total_done_attendance; |
|
1119 | - } |
|
1120 | - |
|
1121 | - $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1122 | - $results['faults'] = $total_faults; |
|
1123 | - $results['total'] = $total_weight; |
|
1124 | - $results['porcent'] = $porcent; |
|
1125 | - |
|
1126 | - return $results; |
|
1127 | - } |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * Get registered users' attendance sheet inside current course |
|
1131 | - * @param int $attendance_id |
|
1132 | - * @param int $user_id for showing data for only one user (optional) |
|
1133 | - * @return array users attendance sheet data |
|
1134 | - */ |
|
1135 | - public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null) |
|
1136 | - { |
|
1137 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1138 | - $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1139 | - |
|
1140 | - $attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId); |
|
1141 | - $calendar_ids = array(); |
|
1142 | - // get all dates from calendar by current attendance |
|
1143 | - foreach ($attendance_calendar as $cal) { |
|
1144 | - $calendar_ids[] = $cal['id']; |
|
1145 | - } |
|
1146 | - |
|
1147 | - $course_id = api_get_course_int_id(); |
|
1148 | - |
|
1149 | - $data = array(); |
|
1150 | - if (empty($user_id)) { |
|
1151 | - // get all registered users inside current course |
|
1152 | - $users = $this->get_users_rel_course(); |
|
1153 | - $user_ids = array_keys($users); |
|
1154 | - if (count($calendar_ids) > 0 && count($user_ids) > 0) { |
|
1155 | - foreach ($user_ids as $uid) { |
|
1156 | - $sql = "SELECT * FROM $tbl_attendance_sheet |
|
1109 | + $rs = Database::query($sql); |
|
1110 | + $score = 0; |
|
1111 | + if (Database::num_rows($rs) > 0) { |
|
1112 | + $row = Database::fetch_array($rs); |
|
1113 | + $score = $row['score']; |
|
1114 | + } |
|
1115 | + $faults = $total_done_attendance-$score; |
|
1116 | + $faults = $faults > 0 ? $faults:0; |
|
1117 | + $total_faults += $faults; |
|
1118 | + $total_weight += $total_done_attendance; |
|
1119 | + } |
|
1120 | + |
|
1121 | + $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0; |
|
1122 | + $results['faults'] = $total_faults; |
|
1123 | + $results['total'] = $total_weight; |
|
1124 | + $results['porcent'] = $porcent; |
|
1125 | + |
|
1126 | + return $results; |
|
1127 | + } |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * Get registered users' attendance sheet inside current course |
|
1131 | + * @param int $attendance_id |
|
1132 | + * @param int $user_id for showing data for only one user (optional) |
|
1133 | + * @return array users attendance sheet data |
|
1134 | + */ |
|
1135 | + public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null) |
|
1136 | + { |
|
1137 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1138 | + $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1139 | + |
|
1140 | + $attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId); |
|
1141 | + $calendar_ids = array(); |
|
1142 | + // get all dates from calendar by current attendance |
|
1143 | + foreach ($attendance_calendar as $cal) { |
|
1144 | + $calendar_ids[] = $cal['id']; |
|
1145 | + } |
|
1146 | + |
|
1147 | + $course_id = api_get_course_int_id(); |
|
1148 | + |
|
1149 | + $data = array(); |
|
1150 | + if (empty($user_id)) { |
|
1151 | + // get all registered users inside current course |
|
1152 | + $users = $this->get_users_rel_course(); |
|
1153 | + $user_ids = array_keys($users); |
|
1154 | + if (count($calendar_ids) > 0 && count($user_ids) > 0) { |
|
1155 | + foreach ($user_ids as $uid) { |
|
1156 | + $sql = "SELECT * FROM $tbl_attendance_sheet |
|
1157 | 1157 | WHERE |
1158 | 1158 | c_id = $course_id AND |
1159 | 1159 | user_id = '$uid' AND |
1160 | 1160 | attendance_calendar_id IN(".implode(',',$calendar_ids).") |
1161 | 1161 | "; |
1162 | - $res = Database::query($sql); |
|
1163 | - if (Database::num_rows($res) > 0) { |
|
1164 | - while ($row = Database::fetch_array($res)) { |
|
1165 | - $data[$uid][$row['attendance_calendar_id']]['presence'] = $row['presence']; |
|
1166 | - } |
|
1167 | - } |
|
1168 | - } |
|
1169 | - } |
|
1170 | - } else { |
|
1171 | - // Get attendance for current user |
|
1172 | - $user_id = intval($user_id); |
|
1173 | - if (count($calendar_ids) > 0) { |
|
1174 | - $sql = "SELECT cal.date_time, att.presence |
|
1162 | + $res = Database::query($sql); |
|
1163 | + if (Database::num_rows($res) > 0) { |
|
1164 | + while ($row = Database::fetch_array($res)) { |
|
1165 | + $data[$uid][$row['attendance_calendar_id']]['presence'] = $row['presence']; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + } |
|
1169 | + } |
|
1170 | + } else { |
|
1171 | + // Get attendance for current user |
|
1172 | + $user_id = intval($user_id); |
|
1173 | + if (count($calendar_ids) > 0) { |
|
1174 | + $sql = "SELECT cal.date_time, att.presence |
|
1175 | 1175 | FROM $tbl_attendance_sheet att |
1176 | 1176 | INNER JOIN $tbl_attendance_calendar cal |
1177 | 1177 | ON cal.id = att.attendance_calendar_id |
@@ -1181,87 +1181,87 @@ discard block |
||
1181 | 1181 | att.user_id = '$user_id' AND |
1182 | 1182 | att.attendance_calendar_id IN (".implode(',',$calendar_ids).") |
1183 | 1183 | ORDER BY date_time"; |
1184 | - $res = Database::query($sql); |
|
1185 | - if (Database::num_rows($res) > 0) { |
|
1186 | - while ($row = Database::fetch_array($res)) { |
|
1187 | - $row['date_time'] = api_convert_and_format_date($row['date_time'], null, date_default_timezone_get()); |
|
1188 | - $data[$user_id][] = $row; |
|
1189 | - } |
|
1190 | - } |
|
1191 | - } |
|
1192 | - } |
|
1193 | - return $data; |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * Get next attendance calendar without presences (done attendances) |
|
1198 | - * @param int attendance id |
|
1199 | - * @return int attendance calendar id |
|
1200 | - */ |
|
1201 | - public function get_next_attendance_calendar_id($attendance_id) |
|
1202 | - { |
|
1203 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1204 | - $attendance_id = intval($attendance_id); |
|
1205 | - $course_id = api_get_course_int_id(); |
|
1206 | - |
|
1207 | - $sql = "SELECT id FROM $tbl_attendance_calendar |
|
1184 | + $res = Database::query($sql); |
|
1185 | + if (Database::num_rows($res) > 0) { |
|
1186 | + while ($row = Database::fetch_array($res)) { |
|
1187 | + $row['date_time'] = api_convert_and_format_date($row['date_time'], null, date_default_timezone_get()); |
|
1188 | + $data[$user_id][] = $row; |
|
1189 | + } |
|
1190 | + } |
|
1191 | + } |
|
1192 | + } |
|
1193 | + return $data; |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * Get next attendance calendar without presences (done attendances) |
|
1198 | + * @param int attendance id |
|
1199 | + * @return int attendance calendar id |
|
1200 | + */ |
|
1201 | + public function get_next_attendance_calendar_id($attendance_id) |
|
1202 | + { |
|
1203 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1204 | + $attendance_id = intval($attendance_id); |
|
1205 | + $course_id = api_get_course_int_id(); |
|
1206 | + |
|
1207 | + $sql = "SELECT id FROM $tbl_attendance_calendar |
|
1208 | 1208 | WHERE |
1209 | 1209 | c_id = $course_id AND |
1210 | 1210 | attendance_id = '$attendance_id' AND |
1211 | 1211 | done_attendance = 0 |
1212 | 1212 | ORDER BY date_time |
1213 | 1213 | LIMIT 1"; |
1214 | - $rs = Database::query($sql); |
|
1215 | - $next_calendar_id = 0; |
|
1216 | - if (Database::num_rows($rs) > 0) { |
|
1217 | - $row = Database::fetch_array($rs); |
|
1218 | - $next_calendar_id = $row['id']; |
|
1219 | - } |
|
1220 | - return $next_calendar_id; |
|
1221 | - } |
|
1222 | - |
|
1223 | - /** |
|
1224 | - * Get next attendance calendar datetime without presences (done attendances) |
|
1225 | - * @param int attendance id |
|
1226 | - * @return int UNIX time format datetime |
|
1227 | - */ |
|
1228 | - public function get_next_attendance_calendar_datetime($attendance_id) |
|
1229 | - { |
|
1230 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1231 | - $course_id = api_get_course_int_id(); |
|
1232 | - $attendance_id = intval($attendance_id); |
|
1233 | - $sql = "SELECT id, date_time FROM $tbl_attendance_calendar |
|
1214 | + $rs = Database::query($sql); |
|
1215 | + $next_calendar_id = 0; |
|
1216 | + if (Database::num_rows($rs) > 0) { |
|
1217 | + $row = Database::fetch_array($rs); |
|
1218 | + $next_calendar_id = $row['id']; |
|
1219 | + } |
|
1220 | + return $next_calendar_id; |
|
1221 | + } |
|
1222 | + |
|
1223 | + /** |
|
1224 | + * Get next attendance calendar datetime without presences (done attendances) |
|
1225 | + * @param int attendance id |
|
1226 | + * @return int UNIX time format datetime |
|
1227 | + */ |
|
1228 | + public function get_next_attendance_calendar_datetime($attendance_id) |
|
1229 | + { |
|
1230 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1231 | + $course_id = api_get_course_int_id(); |
|
1232 | + $attendance_id = intval($attendance_id); |
|
1233 | + $sql = "SELECT id, date_time FROM $tbl_attendance_calendar |
|
1234 | 1234 | WHERE |
1235 | 1235 | c_id = $course_id AND |
1236 | 1236 | attendance_id = '$attendance_id' AND |
1237 | 1237 | done_attendance = 0 |
1238 | 1238 | ORDER BY date_time |
1239 | 1239 | LIMIT 1"; |
1240 | - $rs = Database::query($sql); |
|
1241 | - $next_calendar_datetime = 0; |
|
1242 | - if (Database::num_rows($rs) > 0) { |
|
1243 | - $row = Database::fetch_array($rs); |
|
1244 | - $next_calendar_datetime = api_get_local_time($row['date_time']); |
|
1245 | - } |
|
1246 | - |
|
1247 | - return $next_calendar_datetime; |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * Get user' score from current attendance |
|
1252 | - * @param int $user_id |
|
1253 | - * @param int $attendance_id |
|
1254 | - * @return int score |
|
1255 | - */ |
|
1256 | - public function get_user_score($user_id, $attendance_id, $groupId = null) |
|
1257 | - { |
|
1258 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1240 | + $rs = Database::query($sql); |
|
1241 | + $next_calendar_datetime = 0; |
|
1242 | + if (Database::num_rows($rs) > 0) { |
|
1243 | + $row = Database::fetch_array($rs); |
|
1244 | + $next_calendar_datetime = api_get_local_time($row['date_time']); |
|
1245 | + } |
|
1246 | + |
|
1247 | + return $next_calendar_datetime; |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * Get user' score from current attendance |
|
1252 | + * @param int $user_id |
|
1253 | + * @param int $attendance_id |
|
1254 | + * @return int score |
|
1255 | + */ |
|
1256 | + public function get_user_score($user_id, $attendance_id, $groupId = null) |
|
1257 | + { |
|
1258 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
1259 | 1259 | $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
1260 | 1260 | $tbl_attendance_cal_rel_group = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
1261 | 1261 | $tbl_attendance_cal = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
1262 | - $user_id = intval($user_id); |
|
1263 | - $attendance_id = intval($attendance_id); |
|
1264 | - $course_id = api_get_course_int_id(); |
|
1262 | + $user_id = intval($user_id); |
|
1263 | + $attendance_id = intval($attendance_id); |
|
1264 | + $course_id = api_get_course_int_id(); |
|
1265 | 1265 | if (empty($groupId)) { |
1266 | 1266 | $sql = "SELECT score FROM $tbl_attendance_result |
1267 | 1267 | WHERE |
@@ -1285,68 +1285,68 @@ discard block |
||
1285 | 1285 | ) |
1286 | 1286 | "; |
1287 | 1287 | } |
1288 | - $rs = Database::query($sql); |
|
1289 | - $score = 0; |
|
1290 | - if (Database::num_rows($rs) > 0) { |
|
1291 | - $row = Database::fetch_array($rs); |
|
1292 | - $score = $row['score']; |
|
1293 | - } |
|
1294 | - |
|
1295 | - return $score; |
|
1296 | - } |
|
1297 | - |
|
1298 | - /** |
|
1299 | - * Get attendance calendar data by id |
|
1300 | - * @param int attendance calendar id |
|
1301 | - * @return array attendance calendar data |
|
1302 | - */ |
|
1303 | - public function get_attendance_calendar_by_id($calendar_id) |
|
1304 | - { |
|
1305 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1306 | - $calendar_id = intval($calendar_id); |
|
1307 | - $course_id = api_get_course_int_id(); |
|
1308 | - $sql = "SELECT * FROM $tbl_attendance_calendar |
|
1288 | + $rs = Database::query($sql); |
|
1289 | + $score = 0; |
|
1290 | + if (Database::num_rows($rs) > 0) { |
|
1291 | + $row = Database::fetch_array($rs); |
|
1292 | + $score = $row['score']; |
|
1293 | + } |
|
1294 | + |
|
1295 | + return $score; |
|
1296 | + } |
|
1297 | + |
|
1298 | + /** |
|
1299 | + * Get attendance calendar data by id |
|
1300 | + * @param int attendance calendar id |
|
1301 | + * @return array attendance calendar data |
|
1302 | + */ |
|
1303 | + public function get_attendance_calendar_by_id($calendar_id) |
|
1304 | + { |
|
1305 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1306 | + $calendar_id = intval($calendar_id); |
|
1307 | + $course_id = api_get_course_int_id(); |
|
1308 | + $sql = "SELECT * FROM $tbl_attendance_calendar |
|
1309 | 1309 | WHERE c_id = $course_id AND id = '$calendar_id' "; |
1310 | - $rs = Database::query($sql); |
|
1311 | - $data = array(); |
|
1312 | - if (Database::num_rows($rs) > 0) { |
|
1313 | - while ($row = Database::fetch_array($rs)) { |
|
1314 | - $row['date_time'] = api_get_local_time($row['date_time']); |
|
1315 | - $data = $row; |
|
1316 | - } |
|
1317 | - } |
|
1318 | - |
|
1319 | - return $data; |
|
1320 | - } |
|
1321 | - |
|
1322 | - /** |
|
1323 | - * Get all attendance calendar data inside current attendance |
|
1324 | - * @param int $attendance_id |
|
1325 | - * @param string $type |
|
1326 | - * @param int $calendar_id |
|
1327 | - * @param int $groupId |
|
1328 | - * @param bool $showAll = false show group calendar items or not |
|
1329 | - * |
|
1330 | - * @return array attendance calendar data |
|
1331 | - */ |
|
1332 | - public function get_attendance_calendar( |
|
1333 | - $attendance_id, |
|
1334 | - $type = 'all', |
|
1335 | - $calendar_id = null, |
|
1336 | - $groupId = null, |
|
1337 | - $showAll = false |
|
1338 | - ) { |
|
1339 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1310 | + $rs = Database::query($sql); |
|
1311 | + $data = array(); |
|
1312 | + if (Database::num_rows($rs) > 0) { |
|
1313 | + while ($row = Database::fetch_array($rs)) { |
|
1314 | + $row['date_time'] = api_get_local_time($row['date_time']); |
|
1315 | + $data = $row; |
|
1316 | + } |
|
1317 | + } |
|
1318 | + |
|
1319 | + return $data; |
|
1320 | + } |
|
1321 | + |
|
1322 | + /** |
|
1323 | + * Get all attendance calendar data inside current attendance |
|
1324 | + * @param int $attendance_id |
|
1325 | + * @param string $type |
|
1326 | + * @param int $calendar_id |
|
1327 | + * @param int $groupId |
|
1328 | + * @param bool $showAll = false show group calendar items or not |
|
1329 | + * |
|
1330 | + * @return array attendance calendar data |
|
1331 | + */ |
|
1332 | + public function get_attendance_calendar( |
|
1333 | + $attendance_id, |
|
1334 | + $type = 'all', |
|
1335 | + $calendar_id = null, |
|
1336 | + $groupId = null, |
|
1337 | + $showAll = false |
|
1338 | + ) { |
|
1339 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1340 | 1340 | $tbl_acrg = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
1341 | - $attendance_id = intval($attendance_id); |
|
1342 | - $course_id = api_get_course_int_id(); |
|
1343 | - $groupCondition = null; |
|
1341 | + $attendance_id = intval($attendance_id); |
|
1342 | + $course_id = api_get_course_int_id(); |
|
1343 | + $groupCondition = null; |
|
1344 | 1344 | |
1345 | - if ($showAll) { |
|
1346 | - $sql = "SELECT * FROM $tbl_attendance_calendar c |
|
1345 | + if ($showAll) { |
|
1346 | + $sql = "SELECT * FROM $tbl_attendance_calendar c |
|
1347 | 1347 | WHERE c_id = $course_id AND attendance_id = '$attendance_id'"; |
1348 | - } else { |
|
1349 | - $sql = "SELECT * FROM $tbl_attendance_calendar c |
|
1348 | + } else { |
|
1349 | + $sql = "SELECT * FROM $tbl_attendance_calendar c |
|
1350 | 1350 | WHERE |
1351 | 1351 | c_id = $course_id AND |
1352 | 1352 | attendance_id = '$attendance_id' AND |
@@ -1355,11 +1355,11 @@ discard block |
||
1355 | 1355 | WHERE c_id = $course_id AND group_id != 0 AND group_id IS NOT NULL |
1356 | 1356 | ) |
1357 | 1357 | "; |
1358 | - } |
|
1358 | + } |
|
1359 | 1359 | |
1360 | - if (!empty($groupId)) { |
|
1361 | - $groupId = intval($groupId); |
|
1362 | - $sql = "SELECT c.* FROM $tbl_attendance_calendar c |
|
1360 | + if (!empty($groupId)) { |
|
1361 | + $groupId = intval($groupId); |
|
1362 | + $sql = "SELECT c.* FROM $tbl_attendance_calendar c |
|
1363 | 1363 | INNER JOIN $tbl_acrg g |
1364 | 1364 | ON c.c_id = g.c_id AND c.id = g.calendar_id |
1365 | 1365 | WHERE |
@@ -1367,62 +1367,62 @@ discard block |
||
1367 | 1367 | g.group_id = '$groupId' AND |
1368 | 1368 | c.attendance_id = '$attendance_id' |
1369 | 1369 | "; |
1370 | - } |
|
1371 | - |
|
1372 | - if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) { |
|
1373 | - $type = 'all'; |
|
1374 | - } |
|
1375 | - |
|
1376 | - switch ($type) { |
|
1377 | - case 'calendar_id': |
|
1378 | - $calendar_id = intval($calendar_id); |
|
1379 | - if (!empty($calendar_id)) { |
|
1380 | - $sql.= " AND c.id = $calendar_id"; |
|
1381 | - } |
|
1382 | - break; |
|
1383 | - case 'today': |
|
1384 | - //$sql .= ' AND DATE_FORMAT(date_time,"%d-%m-%Y") = DATE_FORMAT("'.api_get_utc_datetime().'", "%d-%m-%Y" )'; |
|
1385 | - break; |
|
1386 | - case 'all_done': |
|
1387 | - $sql .= " AND done_attendance = 1 "; |
|
1388 | - break; |
|
1389 | - case 'all_not_done': |
|
1390 | - $sql .= " AND done_attendance = 0 "; |
|
1391 | - break; |
|
1392 | - case 'all': |
|
1393 | - default: |
|
1394 | - break; |
|
1395 | - } |
|
1396 | - $sql .= " ORDER BY date_time "; |
|
1370 | + } |
|
1397 | 1371 | |
1398 | - $rs = Database::query($sql); |
|
1399 | - $data = array(); |
|
1400 | - if (Database::num_rows($rs) > 0) { |
|
1401 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
1402 | - $row['db_date_time'] = $row['date_time']; |
|
1403 | - $row['date_time'] = api_get_local_time($row['date_time']); |
|
1404 | - $row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT); |
|
1405 | - $row['time'] = api_format_date($row['date_time'], TIME_NO_SEC_FORMAT); |
|
1406 | - $row['groups'] = $this->getGroupListByAttendanceCalendar($row['id'], $course_id); |
|
1407 | - if ($type == 'today') { |
|
1408 | - if (date('d-m-Y', api_strtotime($row['date_time'], 'UTC')) == date('d-m-Y', time())) { |
|
1409 | - $data[] = $row; |
|
1410 | - } |
|
1411 | - } else { |
|
1412 | - $data[] = $row; |
|
1413 | - } |
|
1414 | - } |
|
1415 | - } |
|
1416 | - |
|
1417 | - return $data; |
|
1418 | - } |
|
1419 | - |
|
1420 | - /** |
|
1421 | - * Get number of attendance calendar inside current attendance |
|
1422 | - * @param int $attendance_id |
|
1423 | - * @param int $groupId |
|
1424 | - * @return int number of dates in attendance calendar |
|
1425 | - */ |
|
1372 | + if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) { |
|
1373 | + $type = 'all'; |
|
1374 | + } |
|
1375 | + |
|
1376 | + switch ($type) { |
|
1377 | + case 'calendar_id': |
|
1378 | + $calendar_id = intval($calendar_id); |
|
1379 | + if (!empty($calendar_id)) { |
|
1380 | + $sql.= " AND c.id = $calendar_id"; |
|
1381 | + } |
|
1382 | + break; |
|
1383 | + case 'today': |
|
1384 | + //$sql .= ' AND DATE_FORMAT(date_time,"%d-%m-%Y") = DATE_FORMAT("'.api_get_utc_datetime().'", "%d-%m-%Y" )'; |
|
1385 | + break; |
|
1386 | + case 'all_done': |
|
1387 | + $sql .= " AND done_attendance = 1 "; |
|
1388 | + break; |
|
1389 | + case 'all_not_done': |
|
1390 | + $sql .= " AND done_attendance = 0 "; |
|
1391 | + break; |
|
1392 | + case 'all': |
|
1393 | + default: |
|
1394 | + break; |
|
1395 | + } |
|
1396 | + $sql .= " ORDER BY date_time "; |
|
1397 | + |
|
1398 | + $rs = Database::query($sql); |
|
1399 | + $data = array(); |
|
1400 | + if (Database::num_rows($rs) > 0) { |
|
1401 | + while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
1402 | + $row['db_date_time'] = $row['date_time']; |
|
1403 | + $row['date_time'] = api_get_local_time($row['date_time']); |
|
1404 | + $row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT); |
|
1405 | + $row['time'] = api_format_date($row['date_time'], TIME_NO_SEC_FORMAT); |
|
1406 | + $row['groups'] = $this->getGroupListByAttendanceCalendar($row['id'], $course_id); |
|
1407 | + if ($type == 'today') { |
|
1408 | + if (date('d-m-Y', api_strtotime($row['date_time'], 'UTC')) == date('d-m-Y', time())) { |
|
1409 | + $data[] = $row; |
|
1410 | + } |
|
1411 | + } else { |
|
1412 | + $data[] = $row; |
|
1413 | + } |
|
1414 | + } |
|
1415 | + } |
|
1416 | + |
|
1417 | + return $data; |
|
1418 | + } |
|
1419 | + |
|
1420 | + /** |
|
1421 | + * Get number of attendance calendar inside current attendance |
|
1422 | + * @param int $attendance_id |
|
1423 | + * @param int $groupId |
|
1424 | + * @return int number of dates in attendance calendar |
|
1425 | + */ |
|
1426 | 1426 | public static function get_number_of_attendance_calendar($attendance_id, $groupId = 0, $done_attendance = NULL, $userId = 0) |
1427 | 1427 | { |
1428 | 1428 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
@@ -1508,112 +1508,112 @@ discard block |
||
1508 | 1508 | |
1509 | 1509 | |
1510 | 1510 | /** |
1511 | - * Get count dates inside attendance calendar by attendance id |
|
1512 | - * @param int $attendance_id |
|
1513 | - * @return int count of dates |
|
1514 | - */ |
|
1515 | - public static function get_count_dates_inside_attendance_calendar($attendance_id) |
|
1516 | - { |
|
1517 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1518 | - $attendance_id = intval($attendance_id); |
|
1519 | - $course_id = api_get_course_int_id(); |
|
1520 | - $sql = "SELECT count(id) FROM $tbl_attendance_calendar |
|
1511 | + * Get count dates inside attendance calendar by attendance id |
|
1512 | + * @param int $attendance_id |
|
1513 | + * @return int count of dates |
|
1514 | + */ |
|
1515 | + public static function get_count_dates_inside_attendance_calendar($attendance_id) |
|
1516 | + { |
|
1517 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1518 | + $attendance_id = intval($attendance_id); |
|
1519 | + $course_id = api_get_course_int_id(); |
|
1520 | + $sql = "SELECT count(id) FROM $tbl_attendance_calendar |
|
1521 | 1521 | WHERE |
1522 | 1522 | c_id = $course_id AND |
1523 | 1523 | attendance_id = '$attendance_id'"; |
1524 | - $rs = Database::query($sql); |
|
1525 | - $count = 0; |
|
1526 | - if (Database::num_rows($rs) > 0) { |
|
1527 | - $row = Database::fetch_row($rs); |
|
1528 | - $count = $row[0]; |
|
1529 | - } |
|
1530 | - return $count; |
|
1531 | - } |
|
1532 | - |
|
1533 | - /** |
|
1534 | - * check if all calendar of an attendance is done |
|
1535 | - * @param int $attendance_id |
|
1536 | - * @return bool True if all calendar is done, otherwise false |
|
1537 | - */ |
|
1538 | - public static function is_all_attendance_calendar_done($attendance_id) |
|
1539 | - { |
|
1540 | - $attendance_id = intval($attendance_id); |
|
1541 | - $done_calendar = self::get_done_attendance_calendar($attendance_id); |
|
1542 | - $count_dates_in_calendar = self::get_count_dates_inside_attendance_calendar($attendance_id); |
|
1543 | - $number_of_dates = self::get_number_of_attendance_calendar($attendance_id); |
|
1544 | - |
|
1545 | - $result = false; |
|
1546 | - if ($number_of_dates && (intval($count_dates_in_calendar) == intval($done_calendar))) { |
|
1547 | - $result = true; |
|
1548 | - } |
|
1549 | - return $result; |
|
1550 | - } |
|
1551 | - |
|
1552 | - /** |
|
1553 | - * check if an attendance is locked |
|
1554 | - * @param int $attendance_id |
|
1555 | - * @param bool |
|
1556 | - */ |
|
1557 | - public static function is_locked_attendance($attendance_id) |
|
1558 | - { |
|
1559 | - //use gradebook lock |
|
1560 | - $result = api_resource_is_locked_by_gradebook($attendance_id, LINK_ATTENDANCE); |
|
1561 | - return $result; |
|
1562 | - } |
|
1563 | - |
|
1564 | - /** |
|
1565 | - * Add new datetime inside attendance calendar table |
|
1566 | - * @param int $attendance_id |
|
1567 | - * @param array $groupList |
|
1568 | - * @return int affected rows |
|
1569 | - */ |
|
1570 | - public function attendance_calendar_add($attendance_id, $groupList = array()) |
|
1571 | - { |
|
1572 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1573 | - $affected_rows = 0; |
|
1574 | - $attendance_id = intval($attendance_id); |
|
1575 | - $course_id = api_get_course_int_id(); |
|
1576 | - // check if datetime already exists inside the table |
|
1577 | - /*$sql = "SELECT id FROM $tbl_attendance_calendar |
|
1524 | + $rs = Database::query($sql); |
|
1525 | + $count = 0; |
|
1526 | + if (Database::num_rows($rs) > 0) { |
|
1527 | + $row = Database::fetch_row($rs); |
|
1528 | + $count = $row[0]; |
|
1529 | + } |
|
1530 | + return $count; |
|
1531 | + } |
|
1532 | + |
|
1533 | + /** |
|
1534 | + * check if all calendar of an attendance is done |
|
1535 | + * @param int $attendance_id |
|
1536 | + * @return bool True if all calendar is done, otherwise false |
|
1537 | + */ |
|
1538 | + public static function is_all_attendance_calendar_done($attendance_id) |
|
1539 | + { |
|
1540 | + $attendance_id = intval($attendance_id); |
|
1541 | + $done_calendar = self::get_done_attendance_calendar($attendance_id); |
|
1542 | + $count_dates_in_calendar = self::get_count_dates_inside_attendance_calendar($attendance_id); |
|
1543 | + $number_of_dates = self::get_number_of_attendance_calendar($attendance_id); |
|
1544 | + |
|
1545 | + $result = false; |
|
1546 | + if ($number_of_dates && (intval($count_dates_in_calendar) == intval($done_calendar))) { |
|
1547 | + $result = true; |
|
1548 | + } |
|
1549 | + return $result; |
|
1550 | + } |
|
1551 | + |
|
1552 | + /** |
|
1553 | + * check if an attendance is locked |
|
1554 | + * @param int $attendance_id |
|
1555 | + * @param bool |
|
1556 | + */ |
|
1557 | + public static function is_locked_attendance($attendance_id) |
|
1558 | + { |
|
1559 | + //use gradebook lock |
|
1560 | + $result = api_resource_is_locked_by_gradebook($attendance_id, LINK_ATTENDANCE); |
|
1561 | + return $result; |
|
1562 | + } |
|
1563 | + |
|
1564 | + /** |
|
1565 | + * Add new datetime inside attendance calendar table |
|
1566 | + * @param int $attendance_id |
|
1567 | + * @param array $groupList |
|
1568 | + * @return int affected rows |
|
1569 | + */ |
|
1570 | + public function attendance_calendar_add($attendance_id, $groupList = array()) |
|
1571 | + { |
|
1572 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1573 | + $affected_rows = 0; |
|
1574 | + $attendance_id = intval($attendance_id); |
|
1575 | + $course_id = api_get_course_int_id(); |
|
1576 | + // check if datetime already exists inside the table |
|
1577 | + /*$sql = "SELECT id FROM $tbl_attendance_calendar |
|
1578 | 1578 | WHERE |
1579 | 1579 | c_id = $course_id AND |
1580 | 1580 | date_time='".Database::escape_string($this->date_time)."' AND |
1581 | 1581 | attendance_id = '$attendance_id'"; |
1582 | 1582 | $rs = Database::query($sql); |
1583 | 1583 | if (Database::num_rows($rs) == 0) {*/ |
1584 | - $params = array( |
|
1585 | - 'c_id' => $course_id, |
|
1586 | - 'date_time' => $this->date_time, |
|
1587 | - 'attendance_id' => $attendance_id, |
|
1584 | + $params = array( |
|
1585 | + 'c_id' => $course_id, |
|
1586 | + 'date_time' => $this->date_time, |
|
1587 | + 'attendance_id' => $attendance_id, |
|
1588 | 1588 | 'done_attendance' => 0 |
1589 | - ); |
|
1590 | - $id = Database::insert($tbl_attendance_calendar, $params); |
|
1591 | - |
|
1592 | - if ($id) { |
|
1593 | - $sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id"; |
|
1594 | - Database::query($sql); |
|
1595 | - $affected_rows++; |
|
1596 | - } |
|
1597 | - $this->addAttendanceCalendarToGroup($id, $course_id, $groupList); |
|
1598 | - //} |
|
1599 | - |
|
1600 | - // update locked attendance |
|
1601 | - $is_all_calendar_done = self::is_all_attendance_calendar_done($attendance_id); |
|
1602 | - if (!$is_all_calendar_done) { |
|
1603 | - self::lock_attendance($attendance_id, false); |
|
1604 | - } else { |
|
1605 | - self::lock_attendance($attendance_id); |
|
1606 | - } |
|
1607 | - return $affected_rows; |
|
1608 | - } |
|
1609 | - |
|
1610 | - /** |
|
1611 | - * @param int $calendarId |
|
1612 | - * @param int $courseId |
|
1613 | - * @param array $groupList |
|
1614 | - */ |
|
1615 | - public function addAttendanceCalendarToGroup($calendarId, $courseId, $groupList) |
|
1616 | - { |
|
1589 | + ); |
|
1590 | + $id = Database::insert($tbl_attendance_calendar, $params); |
|
1591 | + |
|
1592 | + if ($id) { |
|
1593 | + $sql = "UPDATE $tbl_attendance_calendar SET id = iid WHERE iid = $id"; |
|
1594 | + Database::query($sql); |
|
1595 | + $affected_rows++; |
|
1596 | + } |
|
1597 | + $this->addAttendanceCalendarToGroup($id, $course_id, $groupList); |
|
1598 | + //} |
|
1599 | + |
|
1600 | + // update locked attendance |
|
1601 | + $is_all_calendar_done = self::is_all_attendance_calendar_done($attendance_id); |
|
1602 | + if (!$is_all_calendar_done) { |
|
1603 | + self::lock_attendance($attendance_id, false); |
|
1604 | + } else { |
|
1605 | + self::lock_attendance($attendance_id); |
|
1606 | + } |
|
1607 | + return $affected_rows; |
|
1608 | + } |
|
1609 | + |
|
1610 | + /** |
|
1611 | + * @param int $calendarId |
|
1612 | + * @param int $courseId |
|
1613 | + * @param array $groupList |
|
1614 | + */ |
|
1615 | + public function addAttendanceCalendarToGroup($calendarId, $courseId, $groupList) |
|
1616 | + { |
|
1617 | 1617 | if (empty($groupList)) { |
1618 | 1618 | return false; |
1619 | 1619 | } |
@@ -1641,506 +1641,506 @@ discard block |
||
1641 | 1641 | Database::insert($table, $params); |
1642 | 1642 | } |
1643 | 1643 | } |
1644 | - } |
|
1645 | - |
|
1646 | - /** |
|
1647 | - * @param int $calendarId |
|
1648 | - * @param int $courseId |
|
1649 | - * @param int $groupId |
|
1650 | - * @return array |
|
1651 | - */ |
|
1652 | - public function getGroupListByAttendanceCalendar($calendarId, $courseId) |
|
1653 | - { |
|
1654 | - $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1655 | - return Database::select( |
|
1656 | - '*', |
|
1657 | - $table, |
|
1658 | - array('where'=> |
|
1659 | - array( |
|
1660 | - 'calendar_id = ? AND c_id = ?' => array($calendarId, $courseId) |
|
1661 | - ) |
|
1662 | - ) |
|
1663 | - ); |
|
1664 | - } |
|
1665 | - |
|
1666 | - /** |
|
1667 | - * @param int $calendarId |
|
1668 | - * @param int $courseId |
|
1669 | - * @param int $groupId |
|
1670 | - * @return array |
|
1671 | - */ |
|
1672 | - public function getAttendanceCalendarGroup($calendarId, $courseId, $groupId) |
|
1673 | - { |
|
1674 | - $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1675 | - return Database::select( |
|
1676 | - '*', |
|
1677 | - $table, |
|
1678 | - array('where'=> |
|
1679 | - array( |
|
1680 | - 'calendar_id = ? AND c_id = ? AND group_id = ?' => array($calendarId, $courseId, $groupId) |
|
1681 | - ) |
|
1682 | - ) |
|
1683 | - ); |
|
1684 | - } |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * @param int $calendarId |
|
1688 | - * @param int $courseId |
|
1689 | - * @param int $groupId |
|
1644 | + } |
|
1645 | + |
|
1646 | + /** |
|
1647 | + * @param int $calendarId |
|
1648 | + * @param int $courseId |
|
1649 | + * @param int $groupId |
|
1650 | + * @return array |
|
1651 | + */ |
|
1652 | + public function getGroupListByAttendanceCalendar($calendarId, $courseId) |
|
1653 | + { |
|
1654 | + $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1655 | + return Database::select( |
|
1656 | + '*', |
|
1657 | + $table, |
|
1658 | + array('where'=> |
|
1659 | + array( |
|
1660 | + 'calendar_id = ? AND c_id = ?' => array($calendarId, $courseId) |
|
1661 | + ) |
|
1662 | + ) |
|
1663 | + ); |
|
1664 | + } |
|
1665 | + |
|
1666 | + /** |
|
1667 | + * @param int $calendarId |
|
1668 | + * @param int $courseId |
|
1669 | + * @param int $groupId |
|
1670 | + * @return array |
|
1671 | + */ |
|
1672 | + public function getAttendanceCalendarGroup($calendarId, $courseId, $groupId) |
|
1673 | + { |
|
1674 | + $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1675 | + return Database::select( |
|
1676 | + '*', |
|
1677 | + $table, |
|
1678 | + array('where'=> |
|
1679 | + array( |
|
1680 | + 'calendar_id = ? AND c_id = ? AND group_id = ?' => array($calendarId, $courseId, $groupId) |
|
1681 | + ) |
|
1682 | + ) |
|
1683 | + ); |
|
1684 | + } |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * @param int $calendarId |
|
1688 | + * @param int $courseId |
|
1689 | + * @param int $groupId |
|
1690 | 1690 | * |
1691 | - * @return array |
|
1692 | - */ |
|
1693 | - public function deleteAttendanceCalendarGroup($calendarId, $courseId) |
|
1694 | - { |
|
1695 | - $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1696 | - Database::delete( |
|
1697 | - $table, |
|
1698 | - array( |
|
1699 | - 'calendar_id = ? AND c_id = ?' => array($calendarId, $courseId) |
|
1700 | - ) |
|
1701 | - ); |
|
1702 | - } |
|
1703 | - |
|
1704 | - /** |
|
1705 | - * save repeated date inside attendance calendar table |
|
1706 | - * @param int $attendance_id |
|
1707 | - * @param int $start_date start date in tms |
|
1708 | - * @param int $end_date end date in tms |
|
1709 | - * @param string $repeat_type daily, weekly, monthlyByDate |
|
1710 | - * @param array $groupList |
|
1711 | - */ |
|
1712 | - public function attendance_repeat_calendar_add( |
|
1713 | - $attendance_id, |
|
1714 | - $start_date, |
|
1715 | - $end_date, |
|
1716 | - $repeat_type, |
|
1717 | - $groupList = array() |
|
1718 | - ) { |
|
1719 | - $attendance_id = intval($attendance_id); |
|
1720 | - // save start date |
|
1721 | - $datetimezone = api_get_utc_datetime($start_date); |
|
1722 | - $this->set_date_time($datetimezone); |
|
1723 | - $this->attendance_calendar_add($attendance_id, $groupList); |
|
1724 | - |
|
1725 | - // 86400 = 24 hours in seconds |
|
1726 | - // 604800 = 1 week in seconds |
|
1727 | - // Saves repeated dates |
|
1728 | - switch ($repeat_type) { |
|
1729 | - case 'daily': |
|
1730 | - $j = 1; |
|
1731 | - for ($i = $start_date + 86400; ($i <= $end_date); $i += 86400) { |
|
1732 | - $datetimezone = api_get_utc_datetime($i); |
|
1733 | - $this->set_date_time($datetimezone); |
|
1734 | - $this->attendance_calendar_add($attendance_id, $groupList); |
|
1735 | - $j++; |
|
1736 | - } |
|
1737 | - break; |
|
1738 | - case 'weekly': |
|
1739 | - $j = 1; |
|
1740 | - for ($i = $start_date + 604800; ($i <= $end_date); $i += 604800) { |
|
1741 | - $datetimezone = api_get_utc_datetime($i); |
|
1742 | - $this->set_date_time($datetimezone); |
|
1743 | - $this->attendance_calendar_add($attendance_id, $groupList); |
|
1744 | - $j++; |
|
1745 | - } |
|
1746 | - break; |
|
1747 | - case 'monthlyByDate': |
|
1748 | - $j = 1; |
|
1749 | - //@todo fix bug with february |
|
1750 | - for ($i = $start_date + 2419200; ($i <= $end_date); $i += 2419200) { |
|
1751 | - $datetimezone = api_get_utc_datetime($i); |
|
1752 | - $this->set_date_time($datetimezone); |
|
1753 | - $this->attendance_calendar_add($attendance_id, $groupList); |
|
1754 | - $j++; |
|
1755 | - } |
|
1756 | - break; |
|
1757 | - } |
|
1758 | - } |
|
1759 | - |
|
1760 | - /** |
|
1761 | - * Adds x months to a UNIX timestamp |
|
1762 | - * @param int The timestamp |
|
1763 | - * @param int The number of years to add |
|
1764 | - * @return int The new timestamp |
|
1765 | - */ |
|
1766 | - private function add_month($timestamp, $num=1) |
|
1767 | - { |
|
1768 | - $values = api_get_utc_datetime($timestamp); |
|
1769 | - $values = str_replace(array(':','-',' '), '/', $values); |
|
1770 | - list($y, $m, $d, $h, $n, $s) = split('/',$values); |
|
1771 | - if($m+$num>12) { |
|
1772 | - $y += floor($num/12); |
|
1773 | - $m += $num%12; |
|
1774 | - } else { |
|
1775 | - $m += $num; |
|
1776 | - } |
|
1777 | - //date_default_timezone_set('UTC'); |
|
1778 | - // return mktime($h, $n, $s, $m, $d, $y); |
|
1779 | - $result = api_strtotime($y.'-'.$m.'-'.$d.' '.$h.':'.$n.':'.$s, 'UTC'); |
|
1780 | - if (!empty($result)) { |
|
1781 | - return $result; |
|
1782 | - } |
|
1783 | - return false; |
|
1784 | - } |
|
1785 | - |
|
1786 | - /** |
|
1787 | - * edit a datetime inside attendance calendar table |
|
1788 | - * @param int attendance calendar id |
|
1789 | - * @param int attendance id |
|
1790 | - * @return int affected rows |
|
1791 | - */ |
|
1792 | - public function attendance_calendar_edit($calendar_id, $attendance_id) |
|
1793 | - { |
|
1794 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1795 | - $affected_rows = 0; |
|
1796 | - $attendance_id = intval($attendance_id); |
|
1797 | - $course_id = api_get_course_int_id(); |
|
1798 | - // check if datetime already exists inside the table |
|
1799 | - $sql = "SELECT id FROM $tbl_attendance_calendar |
|
1691 | + * @return array |
|
1692 | + */ |
|
1693 | + public function deleteAttendanceCalendarGroup($calendarId, $courseId) |
|
1694 | + { |
|
1695 | + $table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP); |
|
1696 | + Database::delete( |
|
1697 | + $table, |
|
1698 | + array( |
|
1699 | + 'calendar_id = ? AND c_id = ?' => array($calendarId, $courseId) |
|
1700 | + ) |
|
1701 | + ); |
|
1702 | + } |
|
1703 | + |
|
1704 | + /** |
|
1705 | + * save repeated date inside attendance calendar table |
|
1706 | + * @param int $attendance_id |
|
1707 | + * @param int $start_date start date in tms |
|
1708 | + * @param int $end_date end date in tms |
|
1709 | + * @param string $repeat_type daily, weekly, monthlyByDate |
|
1710 | + * @param array $groupList |
|
1711 | + */ |
|
1712 | + public function attendance_repeat_calendar_add( |
|
1713 | + $attendance_id, |
|
1714 | + $start_date, |
|
1715 | + $end_date, |
|
1716 | + $repeat_type, |
|
1717 | + $groupList = array() |
|
1718 | + ) { |
|
1719 | + $attendance_id = intval($attendance_id); |
|
1720 | + // save start date |
|
1721 | + $datetimezone = api_get_utc_datetime($start_date); |
|
1722 | + $this->set_date_time($datetimezone); |
|
1723 | + $this->attendance_calendar_add($attendance_id, $groupList); |
|
1724 | + |
|
1725 | + // 86400 = 24 hours in seconds |
|
1726 | + // 604800 = 1 week in seconds |
|
1727 | + // Saves repeated dates |
|
1728 | + switch ($repeat_type) { |
|
1729 | + case 'daily': |
|
1730 | + $j = 1; |
|
1731 | + for ($i = $start_date + 86400; ($i <= $end_date); $i += 86400) { |
|
1732 | + $datetimezone = api_get_utc_datetime($i); |
|
1733 | + $this->set_date_time($datetimezone); |
|
1734 | + $this->attendance_calendar_add($attendance_id, $groupList); |
|
1735 | + $j++; |
|
1736 | + } |
|
1737 | + break; |
|
1738 | + case 'weekly': |
|
1739 | + $j = 1; |
|
1740 | + for ($i = $start_date + 604800; ($i <= $end_date); $i += 604800) { |
|
1741 | + $datetimezone = api_get_utc_datetime($i); |
|
1742 | + $this->set_date_time($datetimezone); |
|
1743 | + $this->attendance_calendar_add($attendance_id, $groupList); |
|
1744 | + $j++; |
|
1745 | + } |
|
1746 | + break; |
|
1747 | + case 'monthlyByDate': |
|
1748 | + $j = 1; |
|
1749 | + //@todo fix bug with february |
|
1750 | + for ($i = $start_date + 2419200; ($i <= $end_date); $i += 2419200) { |
|
1751 | + $datetimezone = api_get_utc_datetime($i); |
|
1752 | + $this->set_date_time($datetimezone); |
|
1753 | + $this->attendance_calendar_add($attendance_id, $groupList); |
|
1754 | + $j++; |
|
1755 | + } |
|
1756 | + break; |
|
1757 | + } |
|
1758 | + } |
|
1759 | + |
|
1760 | + /** |
|
1761 | + * Adds x months to a UNIX timestamp |
|
1762 | + * @param int The timestamp |
|
1763 | + * @param int The number of years to add |
|
1764 | + * @return int The new timestamp |
|
1765 | + */ |
|
1766 | + private function add_month($timestamp, $num=1) |
|
1767 | + { |
|
1768 | + $values = api_get_utc_datetime($timestamp); |
|
1769 | + $values = str_replace(array(':','-',' '), '/', $values); |
|
1770 | + list($y, $m, $d, $h, $n, $s) = split('/',$values); |
|
1771 | + if($m+$num>12) { |
|
1772 | + $y += floor($num/12); |
|
1773 | + $m += $num%12; |
|
1774 | + } else { |
|
1775 | + $m += $num; |
|
1776 | + } |
|
1777 | + //date_default_timezone_set('UTC'); |
|
1778 | + // return mktime($h, $n, $s, $m, $d, $y); |
|
1779 | + $result = api_strtotime($y.'-'.$m.'-'.$d.' '.$h.':'.$n.':'.$s, 'UTC'); |
|
1780 | + if (!empty($result)) { |
|
1781 | + return $result; |
|
1782 | + } |
|
1783 | + return false; |
|
1784 | + } |
|
1785 | + |
|
1786 | + /** |
|
1787 | + * edit a datetime inside attendance calendar table |
|
1788 | + * @param int attendance calendar id |
|
1789 | + * @param int attendance id |
|
1790 | + * @return int affected rows |
|
1791 | + */ |
|
1792 | + public function attendance_calendar_edit($calendar_id, $attendance_id) |
|
1793 | + { |
|
1794 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1795 | + $affected_rows = 0; |
|
1796 | + $attendance_id = intval($attendance_id); |
|
1797 | + $course_id = api_get_course_int_id(); |
|
1798 | + // check if datetime already exists inside the table |
|
1799 | + $sql = "SELECT id FROM $tbl_attendance_calendar |
|
1800 | 1800 | WHERE |
1801 | 1801 | c_id = $course_id AND |
1802 | 1802 | date_time = '".Database::escape_string($this->date_time)."' AND |
1803 | 1803 | attendance_id = '$attendance_id'"; |
1804 | - $rs = Database::query($sql); |
|
1804 | + $rs = Database::query($sql); |
|
1805 | 1805 | |
1806 | - if (Database::num_rows($rs) == 0) { |
|
1807 | - $sql = "UPDATE $tbl_attendance_calendar |
|
1806 | + if (Database::num_rows($rs) == 0) { |
|
1807 | + $sql = "UPDATE $tbl_attendance_calendar |
|
1808 | 1808 | SET date_time='".Database::escape_string($this->date_time)."' |
1809 | 1809 | WHERE c_id = $course_id AND id = '".intval($calendar_id)."'"; |
1810 | - Database::query($sql); |
|
1811 | - } |
|
1812 | - |
|
1813 | - // update locked attendance |
|
1814 | - $is_all_calendar_done = self::is_all_attendance_calendar_done($attendance_id); |
|
1815 | - if (!$is_all_calendar_done) { |
|
1816 | - self::lock_attendance($attendance_id, false); |
|
1817 | - } else { |
|
1818 | - self::lock_attendance($attendance_id); |
|
1819 | - } |
|
1820 | - |
|
1821 | - return $affected_rows; |
|
1822 | - } |
|
1823 | - |
|
1824 | - /** |
|
1825 | - * delete a datetime from attendance calendar table |
|
1826 | - * @param int attendance calendar id |
|
1827 | - * @param int attendance id |
|
1828 | - * @param bool true for removing all calendar inside current attendance, false for removing by calendar id |
|
1829 | - * @return int affected rows |
|
1830 | - */ |
|
1831 | - public function attendance_calendar_delete($calendar_id, $attendance_id , $all_delete = false) |
|
1832 | - { |
|
1833 | - $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1834 | - $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1835 | - |
|
1836 | - $attendance_id = intval($attendance_id); |
|
1837 | - // get all registered users inside current course |
|
1838 | - $users = $this->get_users_rel_course(); |
|
1839 | - $user_ids = array_keys($users); |
|
1840 | - $course_id = api_get_course_int_id(); |
|
1841 | - $affected_rows = 0; |
|
1842 | - if ($all_delete) { |
|
1843 | - $attendance_calendar = $this->get_attendance_calendar($attendance_id); |
|
1844 | - // get all dates from calendar by current attendance |
|
1845 | - if (!empty($attendance_calendar)) { |
|
1846 | - foreach ($attendance_calendar as $cal) { |
|
1847 | - // delete all data from attendance sheet |
|
1848 | - $sql = "DELETE FROM $tbl_attendance_sheet |
|
1810 | + Database::query($sql); |
|
1811 | + } |
|
1812 | + |
|
1813 | + // update locked attendance |
|
1814 | + $is_all_calendar_done = self::is_all_attendance_calendar_done($attendance_id); |
|
1815 | + if (!$is_all_calendar_done) { |
|
1816 | + self::lock_attendance($attendance_id, false); |
|
1817 | + } else { |
|
1818 | + self::lock_attendance($attendance_id); |
|
1819 | + } |
|
1820 | + |
|
1821 | + return $affected_rows; |
|
1822 | + } |
|
1823 | + |
|
1824 | + /** |
|
1825 | + * delete a datetime from attendance calendar table |
|
1826 | + * @param int attendance calendar id |
|
1827 | + * @param int attendance id |
|
1828 | + * @param bool true for removing all calendar inside current attendance, false for removing by calendar id |
|
1829 | + * @return int affected rows |
|
1830 | + */ |
|
1831 | + public function attendance_calendar_delete($calendar_id, $attendance_id , $all_delete = false) |
|
1832 | + { |
|
1833 | + $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1834 | + $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); |
|
1835 | + |
|
1836 | + $attendance_id = intval($attendance_id); |
|
1837 | + // get all registered users inside current course |
|
1838 | + $users = $this->get_users_rel_course(); |
|
1839 | + $user_ids = array_keys($users); |
|
1840 | + $course_id = api_get_course_int_id(); |
|
1841 | + $affected_rows = 0; |
|
1842 | + if ($all_delete) { |
|
1843 | + $attendance_calendar = $this->get_attendance_calendar($attendance_id); |
|
1844 | + // get all dates from calendar by current attendance |
|
1845 | + if (!empty($attendance_calendar)) { |
|
1846 | + foreach ($attendance_calendar as $cal) { |
|
1847 | + // delete all data from attendance sheet |
|
1848 | + $sql = "DELETE FROM $tbl_attendance_sheet |
|
1849 | 1849 | WHERE c_id = $course_id AND attendance_calendar_id = '".intval($cal['id'])."'"; |
1850 | - Database::query($sql); |
|
1851 | - // delete data from attendance calendar |
|
1852 | - $sql = "DELETE FROM $tbl_attendance_calendar |
|
1850 | + Database::query($sql); |
|
1851 | + // delete data from attendance calendar |
|
1852 | + $sql = "DELETE FROM $tbl_attendance_calendar |
|
1853 | 1853 | WHERE c_id = $course_id AND id = '".intval($cal['id'])."'"; |
1854 | - Database::query($sql); |
|
1855 | - |
|
1856 | - $this->deleteAttendanceCalendarGroup($cal['id'], $course_id); |
|
1857 | - $affected_rows++; |
|
1858 | - } |
|
1859 | - } |
|
1860 | - } else { |
|
1861 | - // delete just one row from attendance sheet by the calendar id |
|
1862 | - $sql = "DELETE FROM $tbl_attendance_sheet |
|
1854 | + Database::query($sql); |
|
1855 | + |
|
1856 | + $this->deleteAttendanceCalendarGroup($cal['id'], $course_id); |
|
1857 | + $affected_rows++; |
|
1858 | + } |
|
1859 | + } |
|
1860 | + } else { |
|
1861 | + // delete just one row from attendance sheet by the calendar id |
|
1862 | + $sql = "DELETE FROM $tbl_attendance_sheet |
|
1863 | 1863 | WHERE c_id = $course_id AND attendance_calendar_id = '".intval($calendar_id)."'"; |
1864 | - Database::query($sql); |
|
1865 | - // delete data from attendance calendar |
|
1866 | - $sql = "DELETE FROM $tbl_attendance_calendar |
|
1864 | + Database::query($sql); |
|
1865 | + // delete data from attendance calendar |
|
1866 | + $sql = "DELETE FROM $tbl_attendance_calendar |
|
1867 | 1867 | WHERE c_id = $course_id AND id = '".intval($calendar_id)."'"; |
1868 | - Database::query($sql); |
|
1869 | - |
|
1870 | - $this->deleteAttendanceCalendarGroup($calendar_id, $course_id); |
|
1871 | - $affected_rows++; |
|
1872 | - } |
|
1873 | - |
|
1874 | - // update users' results |
|
1875 | - $this->update_users_results($user_ids, $attendance_id); |
|
1876 | - |
|
1877 | - return $affected_rows; |
|
1878 | - } |
|
1879 | - |
|
1880 | - /** Setters for fields of attendances tables **/ |
|
1881 | - public function set_session_id($session_id) |
|
1882 | - { |
|
1883 | - $this->session_id = $session_id; |
|
1884 | - } |
|
1885 | - |
|
1886 | - public function set_course_id($course_id) |
|
1887 | - { |
|
1888 | - $this->course_id = $course_id; |
|
1889 | - } |
|
1890 | - |
|
1891 | - public function set_date_time($datetime) |
|
1892 | - { |
|
1893 | - $this->date_time = $datetime; |
|
1894 | - } |
|
1895 | - |
|
1896 | - public function set_name($name) |
|
1897 | - { |
|
1898 | - $this->name = $name; |
|
1899 | - } |
|
1900 | - |
|
1901 | - public function set_description($description) |
|
1902 | - { |
|
1903 | - $this->description = $description; |
|
1904 | - } |
|
1905 | - |
|
1906 | - public function set_attendance_qualify_title($attendance_qualify_title) |
|
1907 | - { |
|
1908 | - $this->attendance_qualify_title = $attendance_qualify_title; |
|
1909 | - } |
|
1910 | - |
|
1911 | - public function set_attendance_weight($attendance_weight) |
|
1912 | - { |
|
1913 | - $this->attendance_weight = $attendance_weight; |
|
1914 | - } |
|
1915 | - |
|
1916 | - /** Getters for fields of attendances tables **/ |
|
1917 | - public function get_session_id() |
|
1918 | - { |
|
1919 | - return $this->session_id; |
|
1920 | - } |
|
1921 | - |
|
1922 | - public function get_course_id() |
|
1923 | - { |
|
1924 | - return $this->course_id; |
|
1925 | - } |
|
1926 | - |
|
1927 | - public function get_date_time() |
|
1928 | - { |
|
1929 | - return $this->date_time; |
|
1930 | - } |
|
1931 | - |
|
1932 | - public function get_name() |
|
1933 | - { |
|
1934 | - return $this->name; |
|
1935 | - } |
|
1936 | - |
|
1937 | - public function get_description() |
|
1938 | - { |
|
1939 | - return $this->description; |
|
1940 | - } |
|
1941 | - |
|
1942 | - public function get_attendance_qualify_title() |
|
1943 | - { |
|
1944 | - return $this->attendance_qualify_title; |
|
1945 | - } |
|
1946 | - |
|
1947 | - public function get_attendance_weight() |
|
1948 | - { |
|
1949 | - return $this->attendance_weight; |
|
1950 | - } |
|
1951 | - |
|
1952 | - /** |
|
1953 | - * @param string $startDate in UTC time |
|
1954 | - * @param string $endDate in UTC time |
|
1955 | - * |
|
1956 | - * @return array |
|
1957 | - */ |
|
1958 | - public function getAttendanceLogin($startDate, $endDate) |
|
1959 | - { |
|
1960 | - if (empty($startDate) || $startDate == '0000-00-00' || |
|
1961 | - empty($endDate) || $endDate == '0000-00-00' |
|
1962 | - ) { |
|
1963 | - return false; |
|
1964 | - } |
|
1965 | - |
|
1966 | - $sessionId = api_get_session_id(); |
|
1967 | - $courseCode = api_get_course_id(); |
|
1968 | - if (!empty($sessionId)) { |
|
1969 | - $users = CourseManager:: get_user_list_from_course_code( |
|
1970 | - $courseCode, |
|
1971 | - $sessionId, |
|
1972 | - '', |
|
1973 | - 'lastname', |
|
1974 | - 0 |
|
1975 | - ); |
|
1976 | - } else { |
|
1977 | - $users = CourseManager:: get_user_list_from_course_code( |
|
1978 | - $courseCode, |
|
1979 | - 0, |
|
1980 | - '', |
|
1981 | - 'lastname', |
|
1982 | - STUDENT |
|
1983 | - ); |
|
1984 | - } |
|
1985 | - |
|
1986 | - $dateTimeStartOriginal = new DateTime($startDate); |
|
1987 | - $dateTimeStart = new DateTime($startDate); |
|
1988 | - $dateTimeEnd= new DateTime($endDate); |
|
1989 | - $interval = $dateTimeStart->diff($dateTimeEnd); |
|
1990 | - $days = intval($interval->format('%a')); |
|
1991 | - |
|
1992 | - $dateList = array($dateTimeStart->format('Y-m-d')); |
|
1993 | - $headers = array( |
|
1994 | - get_lang('User'), |
|
1995 | - $dateTimeStart->format('Y-m-d') |
|
1996 | - ); |
|
1997 | - |
|
1998 | - for ($i = 0; $i < $days; $i++) { |
|
1999 | - $dateTimeStart = $dateTimeStart->add(new DateInterval('P1D')); |
|
2000 | - $date = $dateTimeStart->format('Y-m-d'); |
|
2001 | - $dateList[] = $date; |
|
2002 | - $headers[] = $date; |
|
2003 | - } |
|
2004 | - |
|
2005 | - $accessData = CourseManager::getCourseAccessPerCourseAndSession( |
|
2006 | - $courseCode, |
|
2007 | - $sessionId, |
|
2008 | - $dateTimeStartOriginal->format('Y-m-d H:i:s'), |
|
2009 | - $dateTimeEnd->format('Y-m-d H:i:s') |
|
2010 | - ); |
|
2011 | - |
|
2012 | - $results = array(); |
|
2013 | - if (!empty($accessData)) { |
|
2014 | - foreach ($accessData as $data) { |
|
2015 | - $onlyDate = substr($data['login_course_date'], 0, 10); |
|
2016 | - $results[$data['user_id']][$onlyDate] = true; |
|
2017 | - } |
|
2018 | - } |
|
2019 | - |
|
2020 | - return array( |
|
2021 | - 'users' => $users, |
|
2022 | - 'dateList' => $dateList, |
|
2023 | - 'headers' => $headers, |
|
2024 | - 'results' => $results |
|
2025 | - ); |
|
2026 | - } |
|
2027 | - |
|
2028 | - /** |
|
2029 | - * @param string $startDate in UTC time |
|
2030 | - * @param string $endDate in UTC time |
|
2031 | - * |
|
2032 | - * @return string |
|
2033 | - */ |
|
2034 | - public function getAttendanceLoginTable($startDate, $endDate) |
|
2035 | - { |
|
2036 | - $data = $this->getAttendanceLogin($startDate, $endDate); |
|
2037 | - |
|
2038 | - if (!$data) { |
|
2039 | - return null; |
|
2040 | - } |
|
2041 | - |
|
2042 | - $headers = $data['headers']; |
|
2043 | - $dateList = $data['dateList']; |
|
2044 | - $users = $data['users']; |
|
2045 | - $results = $data['results']; |
|
2046 | - |
|
2047 | - $table = new HTML_Table(array('class' => 'data_table')); |
|
2048 | - $row = 0; |
|
2049 | - $column = 0; |
|
2050 | - foreach ($headers as $header) { |
|
2051 | - $table->setHeaderContents($row, $column, $header); |
|
2052 | - $column++; |
|
2053 | - } |
|
2054 | - $row = 1; |
|
2055 | - foreach ($users as $user) { |
|
2056 | - $table->setCellContents( |
|
2057 | - $row, |
|
2058 | - 0, |
|
2059 | - $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')' |
|
2060 | - ); |
|
2061 | - $row ++; |
|
2062 | - } |
|
2063 | - |
|
2064 | - $column = 1; |
|
2065 | - $row = 1; |
|
2066 | - foreach ($users as $user) { |
|
2067 | - foreach ($dateList as $date) { |
|
2068 | - $status = null; |
|
2069 | - if (isset($results[$user['user_id']]) && |
|
2070 | - isset($results[$user['user_id']][$date]) |
|
2071 | - ) { |
|
2072 | - $status = 'X'; |
|
2073 | - } |
|
2074 | - $table->setCellContents($row, $column, $status); |
|
2075 | - $column++; |
|
2076 | - } |
|
2077 | - $row++; |
|
2078 | - $column = 1; |
|
2079 | - } |
|
2080 | - |
|
2081 | - return $table->toHtml(); |
|
2082 | - } |
|
2083 | - |
|
2084 | - /** |
|
2085 | - * @param string $startDate in UTC time |
|
2086 | - * @param string $endDate in UTC time |
|
2087 | - * |
|
2088 | - * @return string |
|
2089 | - */ |
|
2090 | - public function exportAttendanceLogin($startDate, $endDate) |
|
2091 | - { |
|
2092 | - $data = $this->getAttendanceLogin($startDate, $endDate); |
|
2093 | - |
|
2094 | - if (!$data) { |
|
2095 | - return null; |
|
2096 | - } |
|
2097 | - $users = $data['users']; |
|
2098 | - $results = $data['results']; |
|
2099 | - |
|
2100 | - $table = new HTML_Table(array('class' => 'data_table')); |
|
2101 | - |
|
2102 | - $table->setHeaderContents(0, 0, get_lang('User')); |
|
2103 | - $table->setHeaderContents(0, 1, get_lang('Date')); |
|
2104 | - |
|
2105 | - $row = 1; |
|
2106 | - foreach ($users as $user) { |
|
2107 | - $table->setCellContents( |
|
2108 | - $row, |
|
2109 | - 0, |
|
2110 | - $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')' |
|
2111 | - ); |
|
2112 | - $row++; |
|
2113 | - } |
|
2114 | - $table->setColAttributes(0, array('style' => 'width:28%')); |
|
2115 | - |
|
2116 | - $row = 1; |
|
2117 | - foreach ($users as $user) { |
|
2118 | - if (isset($results[$user['user_id']]) && |
|
2119 | - !empty($results[$user['user_id']]) |
|
2120 | - ) { |
|
2121 | - $dates = implode(', ', array_keys($results[$user['user_id']])); |
|
2122 | - $table->setCellContents($row, 1, $dates); |
|
2123 | - } |
|
2124 | - $row++; |
|
2125 | - } |
|
2126 | - |
|
2127 | - //$tableToString = null; |
|
2128 | - |
|
2129 | - //$sessionInfo = api_get_session_info(api_get_session_id()); |
|
2130 | - //if (!empty($sessionInfo)) { |
|
2131 | - /*$tableToString .= '<strong>'.get_lang('PeriodToDisplay').'</strong>: '. |
|
1868 | + Database::query($sql); |
|
1869 | + |
|
1870 | + $this->deleteAttendanceCalendarGroup($calendar_id, $course_id); |
|
1871 | + $affected_rows++; |
|
1872 | + } |
|
1873 | + |
|
1874 | + // update users' results |
|
1875 | + $this->update_users_results($user_ids, $attendance_id); |
|
1876 | + |
|
1877 | + return $affected_rows; |
|
1878 | + } |
|
1879 | + |
|
1880 | + /** Setters for fields of attendances tables **/ |
|
1881 | + public function set_session_id($session_id) |
|
1882 | + { |
|
1883 | + $this->session_id = $session_id; |
|
1884 | + } |
|
1885 | + |
|
1886 | + public function set_course_id($course_id) |
|
1887 | + { |
|
1888 | + $this->course_id = $course_id; |
|
1889 | + } |
|
1890 | + |
|
1891 | + public function set_date_time($datetime) |
|
1892 | + { |
|
1893 | + $this->date_time = $datetime; |
|
1894 | + } |
|
1895 | + |
|
1896 | + public function set_name($name) |
|
1897 | + { |
|
1898 | + $this->name = $name; |
|
1899 | + } |
|
1900 | + |
|
1901 | + public function set_description($description) |
|
1902 | + { |
|
1903 | + $this->description = $description; |
|
1904 | + } |
|
1905 | + |
|
1906 | + public function set_attendance_qualify_title($attendance_qualify_title) |
|
1907 | + { |
|
1908 | + $this->attendance_qualify_title = $attendance_qualify_title; |
|
1909 | + } |
|
1910 | + |
|
1911 | + public function set_attendance_weight($attendance_weight) |
|
1912 | + { |
|
1913 | + $this->attendance_weight = $attendance_weight; |
|
1914 | + } |
|
1915 | + |
|
1916 | + /** Getters for fields of attendances tables **/ |
|
1917 | + public function get_session_id() |
|
1918 | + { |
|
1919 | + return $this->session_id; |
|
1920 | + } |
|
1921 | + |
|
1922 | + public function get_course_id() |
|
1923 | + { |
|
1924 | + return $this->course_id; |
|
1925 | + } |
|
1926 | + |
|
1927 | + public function get_date_time() |
|
1928 | + { |
|
1929 | + return $this->date_time; |
|
1930 | + } |
|
1931 | + |
|
1932 | + public function get_name() |
|
1933 | + { |
|
1934 | + return $this->name; |
|
1935 | + } |
|
1936 | + |
|
1937 | + public function get_description() |
|
1938 | + { |
|
1939 | + return $this->description; |
|
1940 | + } |
|
1941 | + |
|
1942 | + public function get_attendance_qualify_title() |
|
1943 | + { |
|
1944 | + return $this->attendance_qualify_title; |
|
1945 | + } |
|
1946 | + |
|
1947 | + public function get_attendance_weight() |
|
1948 | + { |
|
1949 | + return $this->attendance_weight; |
|
1950 | + } |
|
1951 | + |
|
1952 | + /** |
|
1953 | + * @param string $startDate in UTC time |
|
1954 | + * @param string $endDate in UTC time |
|
1955 | + * |
|
1956 | + * @return array |
|
1957 | + */ |
|
1958 | + public function getAttendanceLogin($startDate, $endDate) |
|
1959 | + { |
|
1960 | + if (empty($startDate) || $startDate == '0000-00-00' || |
|
1961 | + empty($endDate) || $endDate == '0000-00-00' |
|
1962 | + ) { |
|
1963 | + return false; |
|
1964 | + } |
|
1965 | + |
|
1966 | + $sessionId = api_get_session_id(); |
|
1967 | + $courseCode = api_get_course_id(); |
|
1968 | + if (!empty($sessionId)) { |
|
1969 | + $users = CourseManager:: get_user_list_from_course_code( |
|
1970 | + $courseCode, |
|
1971 | + $sessionId, |
|
1972 | + '', |
|
1973 | + 'lastname', |
|
1974 | + 0 |
|
1975 | + ); |
|
1976 | + } else { |
|
1977 | + $users = CourseManager:: get_user_list_from_course_code( |
|
1978 | + $courseCode, |
|
1979 | + 0, |
|
1980 | + '', |
|
1981 | + 'lastname', |
|
1982 | + STUDENT |
|
1983 | + ); |
|
1984 | + } |
|
1985 | + |
|
1986 | + $dateTimeStartOriginal = new DateTime($startDate); |
|
1987 | + $dateTimeStart = new DateTime($startDate); |
|
1988 | + $dateTimeEnd= new DateTime($endDate); |
|
1989 | + $interval = $dateTimeStart->diff($dateTimeEnd); |
|
1990 | + $days = intval($interval->format('%a')); |
|
1991 | + |
|
1992 | + $dateList = array($dateTimeStart->format('Y-m-d')); |
|
1993 | + $headers = array( |
|
1994 | + get_lang('User'), |
|
1995 | + $dateTimeStart->format('Y-m-d') |
|
1996 | + ); |
|
1997 | + |
|
1998 | + for ($i = 0; $i < $days; $i++) { |
|
1999 | + $dateTimeStart = $dateTimeStart->add(new DateInterval('P1D')); |
|
2000 | + $date = $dateTimeStart->format('Y-m-d'); |
|
2001 | + $dateList[] = $date; |
|
2002 | + $headers[] = $date; |
|
2003 | + } |
|
2004 | + |
|
2005 | + $accessData = CourseManager::getCourseAccessPerCourseAndSession( |
|
2006 | + $courseCode, |
|
2007 | + $sessionId, |
|
2008 | + $dateTimeStartOriginal->format('Y-m-d H:i:s'), |
|
2009 | + $dateTimeEnd->format('Y-m-d H:i:s') |
|
2010 | + ); |
|
2011 | + |
|
2012 | + $results = array(); |
|
2013 | + if (!empty($accessData)) { |
|
2014 | + foreach ($accessData as $data) { |
|
2015 | + $onlyDate = substr($data['login_course_date'], 0, 10); |
|
2016 | + $results[$data['user_id']][$onlyDate] = true; |
|
2017 | + } |
|
2018 | + } |
|
2019 | + |
|
2020 | + return array( |
|
2021 | + 'users' => $users, |
|
2022 | + 'dateList' => $dateList, |
|
2023 | + 'headers' => $headers, |
|
2024 | + 'results' => $results |
|
2025 | + ); |
|
2026 | + } |
|
2027 | + |
|
2028 | + /** |
|
2029 | + * @param string $startDate in UTC time |
|
2030 | + * @param string $endDate in UTC time |
|
2031 | + * |
|
2032 | + * @return string |
|
2033 | + */ |
|
2034 | + public function getAttendanceLoginTable($startDate, $endDate) |
|
2035 | + { |
|
2036 | + $data = $this->getAttendanceLogin($startDate, $endDate); |
|
2037 | + |
|
2038 | + if (!$data) { |
|
2039 | + return null; |
|
2040 | + } |
|
2041 | + |
|
2042 | + $headers = $data['headers']; |
|
2043 | + $dateList = $data['dateList']; |
|
2044 | + $users = $data['users']; |
|
2045 | + $results = $data['results']; |
|
2046 | + |
|
2047 | + $table = new HTML_Table(array('class' => 'data_table')); |
|
2048 | + $row = 0; |
|
2049 | + $column = 0; |
|
2050 | + foreach ($headers as $header) { |
|
2051 | + $table->setHeaderContents($row, $column, $header); |
|
2052 | + $column++; |
|
2053 | + } |
|
2054 | + $row = 1; |
|
2055 | + foreach ($users as $user) { |
|
2056 | + $table->setCellContents( |
|
2057 | + $row, |
|
2058 | + 0, |
|
2059 | + $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')' |
|
2060 | + ); |
|
2061 | + $row ++; |
|
2062 | + } |
|
2063 | + |
|
2064 | + $column = 1; |
|
2065 | + $row = 1; |
|
2066 | + foreach ($users as $user) { |
|
2067 | + foreach ($dateList as $date) { |
|
2068 | + $status = null; |
|
2069 | + if (isset($results[$user['user_id']]) && |
|
2070 | + isset($results[$user['user_id']][$date]) |
|
2071 | + ) { |
|
2072 | + $status = 'X'; |
|
2073 | + } |
|
2074 | + $table->setCellContents($row, $column, $status); |
|
2075 | + $column++; |
|
2076 | + } |
|
2077 | + $row++; |
|
2078 | + $column = 1; |
|
2079 | + } |
|
2080 | + |
|
2081 | + return $table->toHtml(); |
|
2082 | + } |
|
2083 | + |
|
2084 | + /** |
|
2085 | + * @param string $startDate in UTC time |
|
2086 | + * @param string $endDate in UTC time |
|
2087 | + * |
|
2088 | + * @return string |
|
2089 | + */ |
|
2090 | + public function exportAttendanceLogin($startDate, $endDate) |
|
2091 | + { |
|
2092 | + $data = $this->getAttendanceLogin($startDate, $endDate); |
|
2093 | + |
|
2094 | + if (!$data) { |
|
2095 | + return null; |
|
2096 | + } |
|
2097 | + $users = $data['users']; |
|
2098 | + $results = $data['results']; |
|
2099 | + |
|
2100 | + $table = new HTML_Table(array('class' => 'data_table')); |
|
2101 | + |
|
2102 | + $table->setHeaderContents(0, 0, get_lang('User')); |
|
2103 | + $table->setHeaderContents(0, 1, get_lang('Date')); |
|
2104 | + |
|
2105 | + $row = 1; |
|
2106 | + foreach ($users as $user) { |
|
2107 | + $table->setCellContents( |
|
2108 | + $row, |
|
2109 | + 0, |
|
2110 | + $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')' |
|
2111 | + ); |
|
2112 | + $row++; |
|
2113 | + } |
|
2114 | + $table->setColAttributes(0, array('style' => 'width:28%')); |
|
2115 | + |
|
2116 | + $row = 1; |
|
2117 | + foreach ($users as $user) { |
|
2118 | + if (isset($results[$user['user_id']]) && |
|
2119 | + !empty($results[$user['user_id']]) |
|
2120 | + ) { |
|
2121 | + $dates = implode(', ', array_keys($results[$user['user_id']])); |
|
2122 | + $table->setCellContents($row, 1, $dates); |
|
2123 | + } |
|
2124 | + $row++; |
|
2125 | + } |
|
2126 | + |
|
2127 | + //$tableToString = null; |
|
2128 | + |
|
2129 | + //$sessionInfo = api_get_session_info(api_get_session_id()); |
|
2130 | + //if (!empty($sessionInfo)) { |
|
2131 | + /*$tableToString .= '<strong>'.get_lang('PeriodToDisplay').'</strong>: '. |
|
2132 | 2132 | sprintf(get_lang('FromDateXToDateY'), $startDate, $endDate);*/ |
2133 | - //} |
|
2134 | - |
|
2135 | - $tableToString = $table->toHtml(); |
|
2136 | - |
|
2137 | - $params = array( |
|
2138 | - 'filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(), |
|
2139 | - 'pdf_title' => get_lang('Attendance'), |
|
2140 | - 'course_code' => api_get_course_id(), |
|
2141 | - 'show_real_course_teachers' => true |
|
2142 | - ); |
|
2143 | - $pdf = new PDF('A4', null, $params); |
|
2144 | - $pdf->html_to_pdf_with_template($tableToString); |
|
2145 | - } |
|
2133 | + //} |
|
2134 | + |
|
2135 | + $tableToString = $table->toHtml(); |
|
2136 | + |
|
2137 | + $params = array( |
|
2138 | + 'filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(), |
|
2139 | + 'pdf_title' => get_lang('Attendance'), |
|
2140 | + 'course_code' => api_get_course_id(), |
|
2141 | + 'show_real_course_teachers' => true |
|
2142 | + ); |
|
2143 | + $pdf = new PDF('A4', null, $params); |
|
2144 | + $pdf->html_to_pdf_with_template($tableToString); |
|
2145 | + } |
|
2146 | 2146 | } |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | if (!defined('MAGPIE_DIR')) { |
29 | - define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP); |
|
29 | + define('MAGPIE_DIR', dirname(__FILE__).DIR_SEP); |
|
30 | 30 | } |
31 | 31 | |
32 | -require_once( MAGPIE_DIR . 'rss_parse.inc' ); |
|
33 | -require_once( MAGPIE_DIR . 'rss_cache.inc' ); |
|
32 | +require_once(MAGPIE_DIR.'rss_parse.inc'); |
|
33 | +require_once(MAGPIE_DIR.'rss_cache.inc'); |
|
34 | 34 | |
35 | 35 | // for including 3rd party libraries |
36 | -define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP); |
|
37 | -require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); |
|
36 | +define('MAGPIE_EXTLIB', MAGPIE_DIR.'extlib'.DIR_SEP); |
|
37 | +require_once(MAGPIE_EXTLIB.'Snoopy.class.inc'); |
|
38 | 38 | define('MAGPIE_CACHE_DIR', api_get_path(SYS_ARCHIVE_PATH)); |
39 | 39 | |
40 | 40 | /* |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | |
88 | 88 | $MAGPIE_ERROR = ""; |
89 | 89 | |
90 | -function fetch_rss ($url) { |
|
90 | +function fetch_rss($url) { |
|
91 | 91 | // initialize constants |
92 | 92 | init(); |
93 | 93 | |
94 | - if ( !isset($url) ) { |
|
94 | + if (!isset($url)) { |
|
95 | 95 | error("fetch_rss called without a url"); |
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // if cache is disabled |
100 | - if ( !MAGPIE_CACHE_ON ) { |
|
100 | + if (!MAGPIE_CACHE_ON) { |
|
101 | 101 | // fetch file, and parse it |
102 | - $resp = _fetch_remote_file( $url ); |
|
103 | - if ( is_success( $resp->status ) ) { |
|
104 | - return _response_to_rss( $resp ); |
|
102 | + $resp = _fetch_remote_file($url); |
|
103 | + if (is_success($resp->status)) { |
|
104 | + return _response_to_rss($resp); |
|
105 | 105 | } |
106 | 106 | else { |
107 | 107 | error("Failed to fetch $url and cache is off"); |
@@ -116,34 +116,34 @@ discard block |
||
116 | 116 | // 3. if cached obj fails freshness check, fetch remote |
117 | 117 | // 4. if remote fails, return stale object, or error |
118 | 118 | |
119 | - $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); |
|
119 | + $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE); |
|
120 | 120 | |
121 | 121 | if (MAGPIE_DEBUG and $cache->ERROR) { |
122 | 122 | debug($cache->ERROR, E_USER_WARNING); |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | - $cache_status = 0; // response of check_cache |
|
126 | + $cache_status = 0; // response of check_cache |
|
127 | 127 | $request_headers = array(); // HTTP headers to send with fetch |
128 | - $rss = 0; // parsed RSS object |
|
129 | - $errormsg = 0; // errors, if any |
|
128 | + $rss = 0; // parsed RSS object |
|
129 | + $errormsg = 0; // errors, if any |
|
130 | 130 | |
131 | 131 | // store parsed XML by desired output encoding |
132 | 132 | // as character munging happens at parse time |
133 | - $cache_key = $url . MAGPIE_OUTPUT_ENCODING; |
|
133 | + $cache_key = $url.MAGPIE_OUTPUT_ENCODING; |
|
134 | 134 | |
135 | 135 | if (!$cache->ERROR) { |
136 | 136 | // return cache HIT, MISS, or STALE |
137 | - $cache_status = $cache->check_cache( $cache_key); |
|
137 | + $cache_status = $cache->check_cache($cache_key); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // if object cached, and cache is fresh, return cached obj |
141 | - if ( $cache_status == 'HIT' ) { |
|
142 | - $rss = $cache->get( $cache_key ); |
|
143 | - if ( isset($rss) and $rss ) { |
|
141 | + if ($cache_status == 'HIT') { |
|
142 | + $rss = $cache->get($cache_key); |
|
143 | + if (isset($rss) and $rss) { |
|
144 | 144 | // should be cache age |
145 | 145 | $rss->from_cache = 1; |
146 | - if ( MAGPIE_DEBUG > 1) { |
|
146 | + if (MAGPIE_DEBUG > 1) { |
|
147 | 147 | debug("MagpieRSS: Cache HIT", E_USER_NOTICE); |
148 | 148 | } |
149 | 149 | return $rss; |
@@ -153,50 +153,50 @@ discard block |
||
153 | 153 | // else attempt a conditional get |
154 | 154 | |
155 | 155 | // setup headers |
156 | - if ( $cache_status == 'STALE' ) { |
|
157 | - $rss = $cache->get( $cache_key ); |
|
158 | - if ( $rss and $rss->etag and $rss->last_modified ) { |
|
156 | + if ($cache_status == 'STALE') { |
|
157 | + $rss = $cache->get($cache_key); |
|
158 | + if ($rss and $rss->etag and $rss->last_modified) { |
|
159 | 159 | $request_headers['If-None-Match'] = $rss->etag; |
160 | 160 | $request_headers['If-Last-Modified'] = $rss->last_modified; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - $resp = _fetch_remote_file( $url, $request_headers ); |
|
164 | + $resp = _fetch_remote_file($url, $request_headers); |
|
165 | 165 | |
166 | 166 | if (isset($resp) and $resp) { |
167 | - if ($resp->status == '304' ) { |
|
167 | + if ($resp->status == '304') { |
|
168 | 168 | // we have the most current copy |
169 | - if ( MAGPIE_DEBUG > 1) { |
|
169 | + if (MAGPIE_DEBUG > 1) { |
|
170 | 170 | debug("Got 304 for $url"); |
171 | 171 | } |
172 | 172 | // reset cache on 304 (at minutillo insistent prodding) |
173 | 173 | $cache->set($cache_key, $rss); |
174 | 174 | return $rss; |
175 | 175 | } |
176 | - elseif ( is_success( $resp->status ) ) { |
|
177 | - $rss = _response_to_rss( $resp ); |
|
178 | - if ( $rss ) { |
|
176 | + elseif (is_success($resp->status)) { |
|
177 | + $rss = _response_to_rss($resp); |
|
178 | + if ($rss) { |
|
179 | 179 | if (MAGPIE_DEBUG > 1) { |
180 | 180 | debug("Fetch successful"); |
181 | 181 | } |
182 | 182 | // add object to cache |
183 | - $cache->set( $cache_key, $rss ); |
|
183 | + $cache->set($cache_key, $rss); |
|
184 | 184 | return $rss; |
185 | 185 | } |
186 | 186 | } |
187 | 187 | else { |
188 | 188 | $errormsg = "Failed to fetch $url "; |
189 | - if ( $resp->status == '-100' ) { |
|
190 | - $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
|
189 | + if ($resp->status == '-100') { |
|
190 | + $errormsg .= "(Request timed out after ".MAGPIE_FETCH_TIME_OUT." seconds)"; |
|
191 | 191 | } |
192 | - elseif ( $resp->error ) { |
|
192 | + elseif ($resp->error) { |
|
193 | 193 | # compensate for Snoopy's annoying habbit to tacking |
194 | 194 | # on '\n' |
195 | 195 | $http_error = substr($resp->error, 0, -2); |
196 | 196 | $errormsg .= "(HTTP Error: $http_error)"; |
197 | 197 | } |
198 | 198 | else { |
199 | - $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
|
199 | + $errormsg .= "(HTTP Response: ".$resp->response_code.')'; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | // attempt to return cached object |
210 | 210 | if ($rss) { |
211 | - if ( MAGPIE_DEBUG ) { |
|
211 | + if (MAGPIE_DEBUG) { |
|
212 | 212 | debug("Returning STALE object for $url"); |
213 | 213 | } |
214 | 214 | return $rss; |
@@ -228,21 +228,21 @@ discard block |
||
228 | 228 | Purpose: set MAGPIE_ERROR, and trigger error |
229 | 229 | \*=======================================================================*/ |
230 | 230 | |
231 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
231 | +function error($errormsg, $lvl = E_USER_WARNING) { |
|
232 | 232 | global $MAGPIE_ERROR; |
233 | 233 | |
234 | 234 | // append PHP's error message if track_errors enabled |
235 | - if ( isset($php_errormsg) ) { |
|
235 | + if (isset($php_errormsg)) { |
|
236 | 236 | $errormsg .= " ($php_errormsg)"; |
237 | 237 | } |
238 | - if ( $errormsg ) { |
|
238 | + if ($errormsg) { |
|
239 | 239 | $errormsg = "MagpieRSS: $errormsg"; |
240 | 240 | $MAGPIE_ERROR = $errormsg; |
241 | - trigger_error( $errormsg, $lvl); |
|
241 | + trigger_error($errormsg, $lvl); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
245 | +function debug($debugmsg, $lvl = E_USER_NOTICE) { |
|
246 | 246 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
247 | 247 | } |
248 | 248 | |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | Function: magpie_error |
251 | 251 | Purpose: accessor for the magpie error variable |
252 | 252 | \*=======================================================================*/ |
253 | -function magpie_error ($errormsg="") { |
|
253 | +function magpie_error($errormsg = "") { |
|
254 | 254 | global $MAGPIE_ERROR; |
255 | 255 | |
256 | - if ( isset($errormsg) and $errormsg ) { |
|
256 | + if (isset($errormsg) and $errormsg) { |
|
257 | 257 | $MAGPIE_ERROR = $errormsg; |
258 | 258 | } |
259 | 259 | |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | headers to send along with the request (optional) |
268 | 268 | Output: an HTTP response object (see Snoopy.class.inc) |
269 | 269 | \*=======================================================================*/ |
270 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
270 | +function _fetch_remote_file($url, $headers = "") { |
|
271 | 271 | // Snoopy is an HTTP client in PHP |
272 | 272 | $client = new Snoopy(); |
273 | 273 | $client->agent = MAGPIE_USER_AGENT; |
274 | 274 | $client->read_timeout = MAGPIE_FETCH_TIME_OUT; |
275 | 275 | $client->use_gzip = MAGPIE_USE_GZIP; |
276 | - if (is_array($headers) ) { |
|
276 | + if (is_array($headers)) { |
|
277 | 277 | $client->rawheaders = $headers; |
278 | 278 | } |
279 | 279 | |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | Input: an HTTP response object (see Snoopy) |
289 | 289 | Output: parsed RSS object (see rss_parse) |
290 | 290 | \*=======================================================================*/ |
291 | -function _response_to_rss ($resp) { |
|
292 | - $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
|
291 | +function _response_to_rss($resp) { |
|
292 | + $rss = new MagpieRSS($resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING); |
|
293 | 293 | |
294 | 294 | // if RSS parsed successfully |
295 | - if ( $rss and !$rss->ERROR) { |
|
295 | + if ($rss and !$rss->ERROR) { |
|
296 | 296 | |
297 | 297 | // find Etag, and Last-Modified |
298 | - foreach($resp->headers as $h) { |
|
298 | + foreach ($resp->headers as $h) { |
|
299 | 299 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
300 | 300 | if (strpos($h, ": ")) { |
301 | 301 | list($field, $val) = explode(": ", $h, 2); |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | $val = ""; |
306 | 306 | } |
307 | 307 | |
308 | - if ( $field == 'ETag' ) { |
|
308 | + if ($field == 'ETag') { |
|
309 | 309 | $rss->etag = $val; |
310 | 310 | } |
311 | 311 | |
312 | - if ( $field == 'Last-Modified' ) { |
|
312 | + if ($field == 'Last-Modified') { |
|
313 | 313 | $rss->last_modified = $val; |
314 | 314 | } |
315 | 315 | } |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | $errormsg = "Failed to parse RSS file."; |
321 | 321 | |
322 | 322 | if ($rss) { |
323 | - $errormsg .= " (" . $rss->ERROR . ")"; |
|
323 | + $errormsg .= " (".$rss->ERROR.")"; |
|
324 | 324 | } |
325 | - error($errormsg,E_USER_NOTICE); |
|
325 | + error($errormsg, E_USER_NOTICE); |
|
326 | 326 | |
327 | 327 | return false; |
328 | 328 | } // end if ($rss and !$rss->error) |
@@ -333,65 +333,65 @@ discard block |
||
333 | 333 | Purpose: setup constants with default values |
334 | 334 | check for user overrides |
335 | 335 | \*=======================================================================*/ |
336 | -function init () { |
|
337 | - if ( defined('MAGPIE_INITALIZED') ) { |
|
336 | +function init() { |
|
337 | + if (defined('MAGPIE_INITALIZED')) { |
|
338 | 338 | return; |
339 | 339 | } |
340 | 340 | else { |
341 | 341 | define('MAGPIE_INITALIZED', true); |
342 | 342 | } |
343 | 343 | |
344 | - if ( !defined('MAGPIE_CACHE_ON') ) { |
|
344 | + if (!defined('MAGPIE_CACHE_ON')) { |
|
345 | 345 | define('MAGPIE_CACHE_ON', true); |
346 | 346 | } |
347 | 347 | |
348 | - if ( !defined('MAGPIE_CACHE_DIR') ) { |
|
348 | + if (!defined('MAGPIE_CACHE_DIR')) { |
|
349 | 349 | define('MAGPIE_CACHE_DIR', './cache'); |
350 | 350 | } |
351 | 351 | |
352 | - if ( !defined('MAGPIE_CACHE_AGE') ) { |
|
353 | - define('MAGPIE_CACHE_AGE', 60*60); // one hour |
|
352 | + if (!defined('MAGPIE_CACHE_AGE')) { |
|
353 | + define('MAGPIE_CACHE_AGE', 60 * 60); // one hour |
|
354 | 354 | } |
355 | 355 | |
356 | - if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { |
|
356 | + if (!defined('MAGPIE_CACHE_FRESH_ONLY')) { |
|
357 | 357 | define('MAGPIE_CACHE_FRESH_ONLY', false); |
358 | 358 | } |
359 | 359 | |
360 | - if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
|
360 | + if (!defined('MAGPIE_OUTPUT_ENCODING')) { |
|
361 | 361 | define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); |
362 | 362 | } |
363 | 363 | |
364 | - if ( !defined('MAGPIE_INPUT_ENCODING') ) { |
|
364 | + if (!defined('MAGPIE_INPUT_ENCODING')) { |
|
365 | 365 | define('MAGPIE_INPUT_ENCODING', null); |
366 | 366 | } |
367 | 367 | |
368 | - if ( !defined('MAGPIE_DETECT_ENCODING') ) { |
|
368 | + if (!defined('MAGPIE_DETECT_ENCODING')) { |
|
369 | 369 | define('MAGPIE_DETECT_ENCODING', true); |
370 | 370 | } |
371 | 371 | |
372 | - if ( !defined('MAGPIE_DEBUG') ) { |
|
372 | + if (!defined('MAGPIE_DEBUG')) { |
|
373 | 373 | define('MAGPIE_DEBUG', 0); |
374 | 374 | } |
375 | 375 | |
376 | - if ( !defined('MAGPIE_USER_AGENT') ) { |
|
377 | - $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net'; |
|
376 | + if (!defined('MAGPIE_USER_AGENT')) { |
|
377 | + $ua = 'MagpieRSS/'.MAGPIE_VERSION.' (+http://magpierss.sf.net'; |
|
378 | 378 | |
379 | - if ( MAGPIE_CACHE_ON ) { |
|
380 | - $ua = $ua . ')'; |
|
379 | + if (MAGPIE_CACHE_ON) { |
|
380 | + $ua = $ua.')'; |
|
381 | 381 | } |
382 | 382 | else { |
383 | - $ua = $ua . '; No cache)'; |
|
383 | + $ua = $ua.'; No cache)'; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | define('MAGPIE_USER_AGENT', $ua); |
387 | 387 | } |
388 | 388 | |
389 | - if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { |
|
389 | + if (!defined('MAGPIE_FETCH_TIME_OUT')) { |
|
390 | 390 | define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout |
391 | 391 | } |
392 | 392 | |
393 | 393 | // use gzip encoding to fetch rss files if supported? |
394 | - if ( !defined('MAGPIE_USE_GZIP') ) { |
|
394 | + if (!defined('MAGPIE_USE_GZIP')) { |
|
395 | 395 | define('MAGPIE_USE_GZIP', true); |
396 | 396 | } |
397 | 397 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | Function: is_info |
415 | 415 | Purpose: return true if Informational status code |
416 | 416 | \*=======================================================================*/ |
417 | -function is_info ($sc) { |
|
417 | +function is_info($sc) { |
|
418 | 418 | return $sc >= 100 && $sc < 200; |
419 | 419 | } |
420 | 420 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | Function: is_success |
423 | 423 | Purpose: return true if Successful status code |
424 | 424 | \*=======================================================================*/ |
425 | -function is_success ($sc) { |
|
425 | +function is_success($sc) { |
|
426 | 426 | return $sc >= 200 && $sc < 300; |
427 | 427 | } |
428 | 428 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | Function: is_redirect |
431 | 431 | Purpose: return true if Redirection status code |
432 | 432 | \*=======================================================================*/ |
433 | -function is_redirect ($sc) { |
|
433 | +function is_redirect($sc) { |
|
434 | 434 | return $sc >= 300 && $sc < 400; |
435 | 435 | } |
436 | 436 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | Function: is_error |
439 | 439 | Purpose: return true if Error status code |
440 | 440 | \*=======================================================================*/ |
441 | -function is_error ($sc) { |
|
441 | +function is_error($sc) { |
|
442 | 442 | return $sc >= 400 && $sc < 600; |
443 | 443 | } |
444 | 444 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | Function: is_client_error |
447 | 447 | Purpose: return true if Error status code, and its a client error |
448 | 448 | \*=======================================================================*/ |
449 | -function is_client_error ($sc) { |
|
449 | +function is_client_error($sc) { |
|
450 | 450 | return $sc >= 400 && $sc < 500; |
451 | 451 | } |
452 | 452 | |
@@ -454,6 +454,6 @@ discard block |
||
454 | 454 | Function: is_client_error |
455 | 455 | Purpose: return true if Error status code, and its a server error |
456 | 456 | \*=======================================================================*/ |
457 | -function is_server_error ($sc) { |
|
457 | +function is_server_error($sc) { |
|
458 | 458 | return $sc >= 500 && $sc < 600; |
459 | 459 | } |
@@ -102,8 +102,7 @@ discard block |
||
102 | 102 | $resp = _fetch_remote_file( $url ); |
103 | 103 | if ( is_success( $resp->status ) ) { |
104 | 104 | return _response_to_rss( $resp ); |
105 | - } |
|
106 | - else { |
|
105 | + } else { |
|
107 | 106 | error("Failed to fetch $url and cache is off"); |
108 | 107 | return false; |
109 | 108 | } |
@@ -172,8 +171,7 @@ discard block |
||
172 | 171 | // reset cache on 304 (at minutillo insistent prodding) |
173 | 172 | $cache->set($cache_key, $rss); |
174 | 173 | return $rss; |
175 | - } |
|
176 | - elseif ( is_success( $resp->status ) ) { |
|
174 | + } elseif ( is_success( $resp->status ) ) { |
|
177 | 175 | $rss = _response_to_rss( $resp ); |
178 | 176 | if ( $rss ) { |
179 | 177 | if (MAGPIE_DEBUG > 1) { |
@@ -183,24 +181,20 @@ discard block |
||
183 | 181 | $cache->set( $cache_key, $rss ); |
184 | 182 | return $rss; |
185 | 183 | } |
186 | - } |
|
187 | - else { |
|
184 | + } else { |
|
188 | 185 | $errormsg = "Failed to fetch $url "; |
189 | 186 | if ( $resp->status == '-100' ) { |
190 | 187 | $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
191 | - } |
|
192 | - elseif ( $resp->error ) { |
|
188 | + } elseif ( $resp->error ) { |
|
193 | 189 | # compensate for Snoopy's annoying habbit to tacking |
194 | 190 | # on '\n' |
195 | 191 | $http_error = substr($resp->error, 0, -2); |
196 | 192 | $errormsg .= "(HTTP Error: $http_error)"; |
197 | - } |
|
198 | - else { |
|
193 | + } else { |
|
199 | 194 | $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
200 | 195 | } |
201 | 196 | } |
202 | - } |
|
203 | - else { |
|
197 | + } else { |
|
204 | 198 | $errormsg = "Unable to retrieve RSS file for unknown reasons."; |
205 | 199 | } |
206 | 200 | |
@@ -299,8 +293,7 @@ discard block |
||
299 | 293 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
300 | 294 | if (strpos($h, ": ")) { |
301 | 295 | list($field, $val) = explode(": ", $h, 2); |
302 | - } |
|
303 | - else { |
|
296 | + } else { |
|
304 | 297 | $field = $h; |
305 | 298 | $val = ""; |
306 | 299 | } |
@@ -336,8 +329,7 @@ discard block |
||
336 | 329 | function init () { |
337 | 330 | if ( defined('MAGPIE_INITALIZED') ) { |
338 | 331 | return; |
339 | - } |
|
340 | - else { |
|
332 | + } else { |
|
341 | 333 | define('MAGPIE_INITALIZED', true); |
342 | 334 | } |
343 | 335 | |
@@ -378,8 +370,7 @@ discard block |
||
378 | 370 | |
379 | 371 | if ( MAGPIE_CACHE_ON ) { |
380 | 372 | $ua = $ua . ')'; |
381 | - } |
|
382 | - else { |
|
373 | + } else { |
|
383 | 374 | $ua = $ua . '; No cache)'; |
384 | 375 | } |
385 | 376 |
@@ -164,7 +164,7 @@ |
||
164 | 164 | $resp = _fetch_remote_file( $url, $request_headers ); |
165 | 165 | |
166 | 166 | if (isset($resp) and $resp) { |
167 | - if ($resp->status == '304' ) { |
|
167 | + if ($resp->status == '304' ) { |
|
168 | 168 | // we have the most current copy |
169 | 169 | if ( MAGPIE_DEBUG > 1) { |
170 | 170 | debug("Got 304 for $url"); |
@@ -228,6 +228,9 @@ discard block |
||
228 | 228 | Purpose: set MAGPIE_ERROR, and trigger error |
229 | 229 | \*=======================================================================*/ |
230 | 230 | |
231 | +/** |
|
232 | + * @param integer $lvl |
|
233 | + */ |
|
231 | 234 | function error ($errormsg, $lvl=E_USER_WARNING) { |
232 | 235 | global $MAGPIE_ERROR; |
233 | 236 | |
@@ -242,6 +245,9 @@ discard block |
||
242 | 245 | } |
243 | 246 | } |
244 | 247 | |
248 | +/** |
|
249 | + * @param integer $lvl |
|
250 | + */ |
|
245 | 251 | function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
246 | 252 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
247 | 253 | } |
@@ -288,6 +294,9 @@ discard block |
||
288 | 294 | Input: an HTTP response object (see Snoopy) |
289 | 295 | Output: parsed RSS object (see rss_parse) |
290 | 296 | \*=======================================================================*/ |
297 | +/** |
|
298 | + * @param Snoopy $resp |
|
299 | + */ |
|
291 | 300 | function _response_to_rss ($resp) { |
292 | 301 | $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
293 | 302 |