Completed
Push — 1.11.x ( 60645e...aacf46 )
by José
76:05 queued 37:57
created
main/inc/lib/internationalization_database/transliteration/xb8.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
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',
Please login to merge, or discard this patch.
main/inc/lib/internationalization_database/transliteration/xbd.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
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',
Please login to merge, or discard this patch.
main/inc/lib/login_redirection.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/inc/lib/sessionmanager.lib.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6022,7 +6022,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1588,8 +1588,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Doc Comments   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
      * @param string    $description
1337 1337
      * @param int       $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     {
@@ -2561,7 +2563,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
@@ -5273,7 +5278,6 @@  discard block
 block discarded – undo
5273 5278
      * @param string $lastConnectionDate
5274 5279
      * @param array $sessionIdList
5275 5280
      * @param array $studentIdList
5276
-     * @param int $userStatus STUDENT|COURSEMANAGER constants
5277 5281
      *
5278 5282
      * @return array|int
5279 5283
      */
@@ -5425,7 +5429,7 @@  discard block
 block discarded – undo
5425 5429
     /**
5426 5430
      * Get the list of course tools that have to be dealt with in case of
5427 5431
      * registering any course to a session
5428
-     * @return array The list of tools to be dealt with (literal names)
5432
+     * @return string[] The list of tools to be dealt with (literal names)
5429 5433
      */
5430 5434
     public static function getCourseToolToBeManaged()
5431 5435
     {
@@ -5439,7 +5443,7 @@  discard block
 block discarded – undo
5439 5443
      * Calls the methods bound to each tool when a course is registered into a session
5440 5444
      * @param int $sessionId
5441 5445
      * @param int $courseId
5442
-     * @return void
5446
+     * @return boolean|null
5443 5447
      */
5444 5448
     public static function installCourse($sessionId, $courseId)
5445 5449
     {
@@ -6079,6 +6083,7 @@  discard block
 block discarded – undo
6079 6083
      * @param int $categoryId The internal ID of the session category
6080 6084
      * @param string $target Value to search for in the session field values
6081 6085
      * @param array $extraFields A list of fields to be scanned and returned
6086
+     * @param DateTime $publicationDate
6082 6087
      * @return mixed
6083 6088
      */
6084 6089
     public static function getShortSessionListAndExtraByCategory($categoryId, $target, $extraFields = null, $publicationDate = null)
@@ -6591,6 +6596,8 @@  discard block
 block discarded – undo
6591 6596
      * Converts "start date" and "end date" to "From start date to end date" string
6592 6597
      * @param string $startDate
6593 6598
      * @param string $endDate
6599
+     * @param boolean $showTime
6600
+     * @param boolean $dateHuman
6594 6601
      *
6595 6602
      * @return string
6596 6603
      */
@@ -7407,7 +7414,7 @@  discard block
 block discarded – undo
7407 7414
     /**
7408 7415
      * Get link to the admin page for this session
7409 7416
      * @param   int $id Session ID
7410
-     * @return mixed    URL to the admin page to manage the session, or false on error
7417
+     * @return false|string    URL to the admin page to manage the session, or false on error
7411 7418
      */
7412 7419
     public static function getAdminPath($id)
7413 7420
     {
@@ -7424,7 +7431,7 @@  discard block
 block discarded – undo
7424 7431
      * If a course is provided, build the link to the course
7425 7432
      * @param   int $id Session ID
7426 7433
      * @param   int $courseId Course ID (optional) in case the link has to send straight to the course
7427
-     * @return mixed    URL to the page to use the session, or false on error
7434
+     * @return false|string    URL to the page to use the session, or false on error
7428 7435
      */
7429 7436
     public static function getPath($id, $courseId = 0)
7430 7437
     {
@@ -7522,7 +7529,7 @@  discard block
 block discarded – undo
7522 7529
     /**
7523 7530
      * Return true if coach is allowed to access this session
7524 7531
      * @param int $sessionId
7525
-     * @return bool
7532
+     * @return integer
7526 7533
      */
7527 7534
     public static function isSessionDateOkForCoach($sessionId)
7528 7535
     {
Please login to merge, or discard this patch.
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)) {
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
         // Delete users from the session
1757 1757
         if ($empty_users === true) {
1758 1758
             $sql = "DELETE FROM $tbl_session_rel_user
1759
-                    WHERE session_id = $id_session AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . "";
1759
+                    WHERE session_id = $id_session AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
1760 1760
             Database::query($sql);
1761 1761
         }
1762 1762
 
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
             $enreg_user = Database::escape_string($enreg_user);
1768 1768
             $nbr_users++;
1769 1769
             $sql = "INSERT IGNORE INTO $tbl_session_rel_user (relation_type, session_id, user_id, registered_at)
1770
-                    VALUES (0, $id_session, $enreg_user, '" . api_get_utc_datetime() . "')";
1770
+                    VALUES (0, $id_session, $enreg_user, '".api_get_utc_datetime()."')";
1771 1771
             Database::query($sql);
1772 1772
         }
1773 1773
 
@@ -1857,9 +1857,9 @@  discard block
 block discarded – undo
1857 1857
         is_array($courseInfo) ? $courseId = $courseInfo['real_id'] : $courseId = $courseInfo;
1858 1858
 
1859 1859
         $statusCondition = null;
1860
-        if (isset($status) && !is_null($status))  {
1860
+        if (isset($status) && !is_null($status)) {
1861 1861
             $status = intval($status);
1862
-            $statusCondition  = " AND status = $status";
1862
+            $statusCondition = " AND status = $status";
1863 1863
         }
1864 1864
 
1865 1865
         foreach ($userList as $userId) {
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
             if (empty($count)) {
1992 1992
                 // If user is not registered to a session then add it.
1993 1993
                 $sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id, registered_at)
1994
-                        VALUES ($session_id, $enreg_user, '" . api_get_utc_datetime() . "')";
1994
+                        VALUES ($session_id, $enreg_user, '".api_get_utc_datetime()."')";
1995 1995
                 Database::query($sql);
1996 1996
 
1997 1997
                 $sql = "UPDATE $tbl_session SET nbr_users = nbr_users + 1
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
 		               WHERE
2035 2035
                             session_id = $session_id AND
2036 2036
 		                    user_id = $user_id AND
2037
-		                    relation_type <> " . SESSION_RELATION_TYPE_RRHH . "";
2037
+		                    relation_type <> ".SESSION_RELATION_TYPE_RRHH."";
2038 2038
         $result = Database::query($delete_sql);
2039 2039
         $return = Database::affected_rows($result);
2040 2040
 
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
                 FROM $tbl_session_rel_user
2119 2119
                 WHERE
2120 2120
                     session_id = $sessionId AND
2121
-                    relation_type<>" . SESSION_RELATION_TYPE_RRHH;
2121
+                    relation_type<>".SESSION_RELATION_TYPE_RRHH;
2122 2122
         $result = Database::query($sql);
2123 2123
         $user_list = Database::store_result($result);
2124 2124
 
@@ -2130,7 +2130,7 @@  discard block
 block discarded – undo
2130 2130
 
2131 2131
                     $sql = "DELETE FROM $tbl_session_rel_course
2132 2132
                             WHERE
2133
-                                c_id = " . $existingCourse['c_id'] . " AND
2133
+                                c_id = ".$existingCourse['c_id']." AND
2134 2134
                                 session_id = $sessionId";
2135 2135
                     Database::query($sql);
2136 2136
 
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
                             $links = $cat->get_links(null, false, $courseInfo['code'], 0);
2194 2194
 
2195 2195
                             $cat->set_session_id($sessionId);
2196
-                            $oldCategoryId= $cat->get_id();
2196
+                            $oldCategoryId = $cat->get_id();
2197 2197
                             $newId = $cat->add();
2198 2198
                             $newCategoryIdList[$oldCategoryId] = $newId;
2199 2199
 
@@ -2381,8 +2381,8 @@  discard block
 block discarded – undo
2381 2381
         $return_value = false;
2382 2382
         $sql = "SELECT c_id FROM $tbl_session_course
2383 2383
                 WHERE
2384
-                  session_id = " . intval($session_id) . " AND
2385
-                  c_id = " . intval($courseId) . "";
2384
+                  session_id = ".intval($session_id)." AND
2385
+                  c_id = " . intval($courseId)."";
2386 2386
         $result = Database::query($sql);
2387 2387
         $num = Database::num_rows($result);
2388 2388
         if ($num > 0) {
@@ -2405,8 +2405,8 @@  discard block
 block discarded – undo
2405 2405
         }
2406 2406
 
2407 2407
         $sql = 'SELECT *
2408
-		        FROM ' . $tbl_session . '
2409
-		        WHERE name = "' . Database::escape_string($session_name) . '"';
2408
+		        FROM ' . $tbl_session.'
2409
+		        WHERE name = "' . Database::escape_string($session_name).'"';
2410 2410
         $result = Database::query($sql);
2411 2411
         $num = Database::num_rows($result);
2412 2412
         if ($num > 0) {
@@ -2446,8 +2446,8 @@  discard block
 block discarded – undo
2446 2446
         $month_end = intval($smonth_end);
2447 2447
         $day_end = intval($sday_end);
2448 2448
 
2449
-        $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
2450
-        $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
2449
+        $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
2450
+        $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
2451 2451
 
2452 2452
         if (empty($name)) {
2453 2453
             $msg = get_lang('SessionCategoryNameIsRequired');
@@ -2519,8 +2519,8 @@  discard block
 block discarded – undo
2519 2519
         $month_end = intval($smonth_end);
2520 2520
         $day_end = intval($sday_end);
2521 2521
         $id = intval($id);
2522
-        $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
2523
-        $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
2522
+        $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
2523
+        $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
2524 2524
 
2525 2525
         if (empty($name)) {
2526 2526
             $msg = get_lang('SessionCategoryNameIsRequired');
@@ -2540,13 +2540,13 @@  discard block
 block discarded – undo
2540 2540
         if ($date_end <> null) {
2541 2541
             $sql = "UPDATE $tbl_session_category
2542 2542
                     SET
2543
-                        name = '" . Database::escape_string($name) . "',
2543
+                        name = '".Database::escape_string($name)."',
2544 2544
                         date_start = '$date_start' ,
2545 2545
                         date_end = '$date_end'
2546 2546
                     WHERE id= $id";
2547 2547
         } else {
2548 2548
             $sql = "UPDATE $tbl_session_category SET
2549
-                        name = '" . Database::escape_string($name) . "',
2549
+                        name = '".Database::escape_string($name)."',
2550 2550
                         date_start = '$date_start',
2551 2551
                         date_end = NULL
2552 2552
                     WHERE id= $id";
@@ -2576,10 +2576,10 @@  discard block
 block discarded – undo
2576 2576
 
2577 2577
         //Setting session_category_id to 0
2578 2578
         $sql = "UPDATE $tbl_session SET session_category_id = 0
2579
-                WHERE session_category_id IN (" . $id_checked . ")";
2579
+                WHERE session_category_id IN (".$id_checked.")";
2580 2580
         Database::query($sql);
2581 2581
 
2582
-        $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (" . $id_checked . ")";
2582
+        $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
2583 2583
         $result = Database::query($sql);
2584 2584
         while ($rows = Database::fetch_array($result)) {
2585 2585
             $session_id = $rows['id'];
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
                 }
2592 2592
             }
2593 2593
         }
2594
-        $sql = "DELETE FROM $tbl_session_category WHERE id IN (" . $id_checked . ")";
2594
+        $sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")";
2595 2595
         Database::query($sql);
2596 2596
 
2597 2597
         // Add event to system log
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
                 $value = Database::escape_string($options['value']);
2665 2665
                 $sql_query .= ' AND ';
2666 2666
                 if (in_array($field, $availableFields) && in_array($operator, $availableOperator)) {
2667
-                    $sql_query .= $field . " $operator '" . $value . "'";
2667
+                    $sql_query .= $field." $operator '".$value."'";
2668 2668
                 }
2669 2669
             }
2670 2670
         }
@@ -2731,8 +2731,8 @@  discard block
 block discarded – undo
2731 2731
     {
2732 2732
         $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
2733 2733
         $id = api_get_current_access_url_id();
2734
-        $sql = 'SELECT * FROM ' . $tbl_session_category . '
2735
-                WHERE access_url_id = ' . $id . '
2734
+        $sql = 'SELECT * FROM '.$tbl_session_category.'
2735
+                WHERE access_url_id = ' . $id.'
2736 2736
                 ORDER BY name ASC';
2737 2737
         $result = Database::query($sql);
2738 2738
         if (Database::num_rows($result) > 0) {
@@ -2911,11 +2911,11 @@  discard block
 block discarded – undo
2911 2911
                         INNER JOIN $tbl_session_rel_access_url a ON (a.session_id = s.session_id)
2912 2912
                         WHERE
2913 2913
                             s.user_id = $userId AND
2914
-                            relation_type=" . SESSION_RELATION_TYPE_RRHH . " AND
2915
-                            access_url_id = " . api_get_current_access_url_id() . "";
2914
+                            relation_type=".SESSION_RELATION_TYPE_RRHH." AND
2915
+                            access_url_id = " . api_get_current_access_url_id()."";
2916 2916
             } else {
2917 2917
                 $sql = "SELECT session_id FROM $tbl_session_rel_user s
2918
-                        WHERE user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH . "";
2918
+                        WHERE user_id = $userId AND relation_type=".SESSION_RELATION_TYPE_RRHH."";
2919 2919
             }
2920 2920
             $result = Database::query($sql);
2921 2921
 
@@ -2925,7 +2925,7 @@  discard block
 block discarded – undo
2925 2925
                             WHERE
2926 2926
                                 session_id = {$row['session_id']} AND
2927 2927
                                 user_id = $userId AND
2928
-                                relation_type=" . SESSION_RELATION_TYPE_RRHH . " ";
2928
+                                relation_type=".SESSION_RELATION_TYPE_RRHH." ";
2929 2929
                     Database::query($sql);
2930 2930
                 }
2931 2931
             }
@@ -2939,8 +2939,8 @@  discard block
 block discarded – undo
2939 2939
                         VALUES (
2940 2940
                             $session_id,
2941 2941
                             $userId,
2942
-                            '" . SESSION_RELATION_TYPE_RRHH . "',
2943
-                            '" . api_get_utc_datetime() . "'
2942
+                            '".SESSION_RELATION_TYPE_RRHH."',
2943
+                            '" . api_get_utc_datetime()."'
2944 2944
                         )";
2945 2945
 
2946 2946
                 Database::query($sql);
@@ -2982,8 +2982,8 @@  discard block
 block discarded – undo
2982 2982
                     WHERE
2983 2983
                         sru.user_id = '$userId' AND
2984 2984
                         sru.session_id = '$sessionId' AND
2985
-                        sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' AND
2986
-                        access_url_id = " . api_get_current_access_url_id() . "
2985
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND
2986
+                        access_url_id = " . api_get_current_access_url_id()."
2987 2987
                         ";
2988 2988
         } else {
2989 2989
             $sql = "$select FROM $tbl_session s
@@ -2992,7 +2992,7 @@  discard block
 block discarded – undo
2992 2992
                         sru.session_id = s.id AND
2993 2993
                         sru.user_id = '$userId' AND
2994 2994
                         sru.session_id = '$sessionId' AND
2995
-                        sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "'
2995
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."'
2996 2996
                     ";
2997 2997
         }
2998 2998
 
@@ -3090,7 +3090,7 @@  discard block
 block discarded – undo
3090 3090
 
3091 3091
         $limitCondition = null;
3092 3092
         if (!empty($start) && !empty($limit)) {
3093
-            $limitCondition = " LIMIT " . intval($start) . ", " . intval($limit);
3093
+            $limitCondition = " LIMIT ".intval($start).", ".intval($limit);
3094 3094
         }
3095 3095
 
3096 3096
         if (empty($orderCondition)) {
@@ -3168,26 +3168,26 @@  discard block
 block discarded – undo
3168 3168
 
3169 3169
         $sessions = array();
3170 3170
         if (Database::num_rows($result) > 0) {
3171
-            $sysUploadPath = api_get_path(SYS_UPLOAD_PATH). 'sessions/';
3172
-            $webUploadPath = api_get_path(WEB_UPLOAD_PATH). 'sessions/';
3171
+            $sysUploadPath = api_get_path(SYS_UPLOAD_PATH).'sessions/';
3172
+            $webUploadPath = api_get_path(WEB_UPLOAD_PATH).'sessions/';
3173 3173
             $imgPath = Display::return_icon('session_default_small.png', null, null, null, null, true);
3174 3174
 
3175 3175
             $tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD);
3176
-            $sql = "SELECT id FROM " . $tableExtraFields . "
3176
+            $sql = "SELECT id FROM ".$tableExtraFields."
3177 3177
                     WHERE extra_field_type = 3 AND variable='image'";
3178 3178
             $resultField = Database::query($sql);
3179 3179
             $imageFieldId = Database::fetch_assoc($resultField);
3180 3180
 
3181 3181
             while ($row = Database::fetch_array($result)) {
3182 3182
 
3183
-                $row['image'] =  null;
3184
-                $sessionImage = $sysUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png';
3183
+                $row['image'] = null;
3184
+                $sessionImage = $sysUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png';
3185 3185
 
3186 3186
                 if (is_file($sessionImage)) {
3187
-                    $sessionImage = $webUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png';
3187
+                    $sessionImage = $webUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png';
3188 3188
                     $row['image'] = $sessionImage;
3189 3189
                 } else {
3190
-                    $row['image'] =  $imgPath;
3190
+                    $row['image'] = $imgPath;
3191 3191
                 }
3192 3192
 
3193 3193
                 $sessions[$row['id']] = $row;
@@ -3257,7 +3257,7 @@  discard block
 block discarded – undo
3257 3257
                 return intval($count[0]);
3258 3258
             }
3259 3259
 
3260
-            while ($row = Database::fetch_array($result,'ASSOC'))	{
3260
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
3261 3261
                 $courses[$row['real_id']] = $row;
3262 3262
             }
3263 3263
         }
@@ -3301,7 +3301,7 @@  discard block
 block discarded – undo
3301 3301
         }
3302 3302
 
3303 3303
         $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
3304
-        $tbl_session_rel_course	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
3304
+        $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
3305 3305
 
3306 3306
         if ($getCount) {
3307 3307
             $select = "SELECT COUNT(DISTINCT(c.code)) as count ";
@@ -3326,7 +3326,7 @@  discard block
 block discarded – undo
3326 3326
 		        ";
3327 3327
         if ($getCount) {
3328 3328
             $result = Database::query($sql);
3329
-            $row = Database::fetch_array($result,'ASSOC');
3329
+            $row = Database::fetch_array($result, 'ASSOC');
3330 3330
             return $row['count'];
3331 3331
         }
3332 3332
 
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
         $courses = array();
3342 3342
 
3343 3343
         if ($num_rows > 0) {
3344
-            while ($row = Database::fetch_array($result,'ASSOC'))	{
3344
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
3345 3345
                 $courses[$row['id']] = $row;
3346 3346
             }
3347 3347
         }
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
         $result = Database::query($sql);
3420 3420
         $num_rows = Database::num_rows($result);
3421 3421
         if ($num_rows > 0) {
3422
-            $row = Database::fetch_array($result,'ASSOC');
3422
+            $row = Database::fetch_array($result, 'ASSOC');
3423 3423
             return $row['count'];
3424 3424
         }
3425 3425
 
@@ -3531,9 +3531,9 @@  discard block
 block discarded – undo
3531 3531
 
3532 3532
             if ($access_url_id != -1) {
3533 3533
                 $sql = 'SELECT DISTINCT session.*
3534
-                    FROM ' . $session_table . ' session INNER JOIN ' . $tbl_session_rel_access_url . ' session_rel_url
3534
+                    FROM ' . $session_table.' session INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
3535 3535
                     ON (session.id = session_rel_url.session_id)
3536
-                    WHERE '.$sqlCoach.' access_url_id = ' . $access_url_id;
3536
+                    WHERE '.$sqlCoach.' access_url_id = '.$access_url_id;
3537 3537
             }
3538 3538
         }
3539 3539
         $sql .= ' ORDER by name';
@@ -3567,8 +3567,8 @@  discard block
 block discarded – undo
3567 3567
                 FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
3568 3568
                 WHERE
3569 3569
                     session_rcru.user_id = user.user_id AND
3570
-                    session_rcru.session_id = '" . intval($session_id) . "' AND
3571
-                    session_rcru.c_id ='" . intval($courseId) . "' AND
3570
+                    session_rcru.session_id = '".intval($session_id)."' AND
3571
+                    session_rcru.c_id ='" . intval($courseId)."' AND
3572 3572
                     user.user_id = " . intval($user_id);
3573 3573
 
3574 3574
         $result = Database::query($sql);
@@ -3599,8 +3599,8 @@  discard block
 block discarded – undo
3599 3599
         $sql = "SELECT session_rcru.status
3600 3600
                 FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
3601 3601
                 WHERE session_rcru.user_id = user.user_id AND
3602
-                    session_rcru.session_id = '" . intval($session_id) . "' AND
3603
-                    session_rcru.c_id ='" . intval($courseId) . "' AND
3602
+                    session_rcru.session_id = '".intval($session_id)."' AND
3603
+                    session_rcru.c_id ='" . intval($courseId)."' AND
3604 3604
                     user.user_id = " . intval($user_id);
3605 3605
         $result = Database::query($sql);
3606 3606
         $status = false;
@@ -3677,7 +3677,7 @@  discard block
 block discarded – undo
3677 3677
         // Get timestamp for now in UTC - see http://php.net/manual/es/function.time.php#117251
3678 3678
         $now = time() - date('Z');
3679 3679
         // Timestamp in one month
3680
-        $inOneMonth = $now + (30*24*3600);
3680
+        $inOneMonth = $now + (30 * 24 * 3600);
3681 3681
         $inOneMonth = api_get_local_time($inOneMonth);
3682 3682
         if (api_strtotime($s['access_start_date']) < $now) {
3683 3683
             $s['access_start_date'] = api_get_local_time($now);
@@ -3699,16 +3699,16 @@  discard block
 block discarded – undo
3699 3699
         }
3700 3700
         // Now try to create the session
3701 3701
         $sid = self::create_session(
3702
-            $s['name'] . ' ' . get_lang('CopyLabelSuffix'),
3702
+            $s['name'].' '.get_lang('CopyLabelSuffix'),
3703 3703
             $s['access_start_date'],
3704 3704
             $s['access_end_date'],
3705 3705
             $s['display_start_date'],
3706 3706
             $s['display_end_date'],
3707 3707
             $s['coach_access_start_date'],
3708 3708
             $s['coach_access_end_date'],
3709
-            (int)$s['id_coach'],
3709
+            (int) $s['id_coach'],
3710 3710
             $s['session_category_id'],
3711
-            (int)$s['visibility'],
3711
+            (int) $s['visibility'],
3712 3712
             true
3713 3713
         );
3714 3714
 
@@ -3822,7 +3822,7 @@  discard block
 block discarded – undo
3822 3822
         $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
3823 3823
         $sql = "SELECT DISTINCT id
3824 3824
 	         	FROM $session_table
3825
-	         	WHERE session.id_coach =  '" . $user_id . "' AND id = '$session_id'";
3825
+	         	WHERE session.id_coach =  '".$user_id."' AND id = '$session_id'";
3826 3826
         $result = Database::query($sql);
3827 3827
         if ($result && Database::num_rows($result)) {
3828 3828
             return true;
@@ -3841,7 +3841,7 @@  discard block
 block discarded – undo
3841 3841
         $access_url_rel_session_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3842 3842
         $sql = "SELECT count(id) FROM $session_table s";
3843 3843
         if (!empty($access_url_id) && $access_url_id == intval($access_url_id)) {
3844
-            $sql .= ", $access_url_rel_session_table u " .
3844
+            $sql .= ", $access_url_rel_session_table u ".
3845 3845
                 " WHERE s.id = u.session_id AND u.access_url_id = $access_url_id";
3846 3846
         }
3847 3847
         $res = Database::query($sql);
@@ -4093,7 +4093,7 @@  discard block
 block discarded – undo
4093 4093
 
4094 4094
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
4095 4095
         $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
4096
-        $tbl_session_course  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
4096
+        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
4097 4097
         $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
4098 4098
 
4099 4099
         $sessions = array();
@@ -4187,10 +4187,10 @@  discard block
 block discarded – undo
4187 4187
                     $suffix = null;
4188 4188
                     while (!$unique_name) {
4189 4189
                         if ($i > 1) {
4190
-                            $suffix = ' - ' . $i;
4190
+                            $suffix = ' - '.$i;
4191 4191
                         }
4192
-                        $sql = 'SELECT 1 FROM ' . $tbl_session . '
4193
-                                WHERE name="' . $session_name . $suffix . '"';
4192
+                        $sql = 'SELECT 1 FROM '.$tbl_session.'
4193
+                                WHERE name="' . $session_name.$suffix.'"';
4194 4194
                         $rs = Database::query($sql);
4195 4195
 
4196 4196
                         if (Database::result($rs, 0, 0)) {
@@ -4208,13 +4208,13 @@  discard block
 block discarded – undo
4208 4208
 
4209 4209
                     // Creating the session.
4210 4210
                     $sql = "INSERT IGNORE INTO $tbl_session SET
4211
-                            name = '" . $session_name . "',
4211
+                            name = '".$session_name."',
4212 4212
                             id_coach = '$coach_id',
4213 4213
                             access_start_date = '$date_start',
4214 4214
                             access_end_date = '$date_end',
4215 4215
                             visibility = '$visibilityAfterExpirationPerSession',
4216 4216
                             $sessionCondition
4217
-                            session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters;
4217
+                            session_admin_id = ".intval($defaultUserId).$extraParameters.$extraSessionParameters;
4218 4218
                     Database::query($sql);
4219 4219
 
4220 4220
                     $session_id = Database::insert_id();
@@ -4254,7 +4254,7 @@  discard block
 block discarded – undo
4254 4254
                                 access_start_date = '$date_start',
4255 4255
                                 access_end_date = '$date_end',
4256 4256
                                 visibility = '$visibilityAfterExpirationPerSession',
4257
-                                session_category_id = '$session_category_id' " . $extraParameters . $extraSessionParameters;
4257
+                                session_category_id = '$session_category_id' ".$extraParameters.$extraSessionParameters;
4258 4258
 
4259 4259
                         Database::query($sql);
4260 4260
 
@@ -4274,7 +4274,7 @@  discard block
 block discarded – undo
4274 4274
 
4275 4275
                             // Delete session-user relation only for students
4276 4276
                             $sql = "DELETE FROM $tbl_session_user
4277
-                                    WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH;
4277
+                                    WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH;
4278 4278
                             Database::query($sql);
4279 4279
 
4280 4280
                             $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'";
@@ -4362,7 +4362,7 @@  discard block
 block discarded – undo
4362 4362
 
4363 4363
                             // Delete session-user relation only for students
4364 4364
                             $sql = "DELETE FROM $tbl_session_user
4365
-                                    WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH;
4365
+                                    WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH;
4366 4366
                             Database::query($sql);
4367 4367
 
4368 4368
                             $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'";
@@ -4405,7 +4405,7 @@  discard block
 block discarded – undo
4405 4405
                             $sql = "INSERT IGNORE INTO $tbl_session_user SET
4406 4406
                                     user_id = '$user_id',
4407 4407
                                     session_id = '$session_id',
4408
-                                    registered_at = '" . api_get_utc_datetime() . "'";
4408
+                                    registered_at = '".api_get_utc_datetime()."'";
4409 4409
                             Database::query($sql);
4410 4410
                             if ($debug) {
4411 4411
                                 $logger->addInfo("Sessions - Adding User #$user_id ($user) to session #$session_id");
@@ -5049,7 +5049,7 @@  discard block
 block discarded – undo
5049 5049
 
5050 5050
         if (!empty($lastConnectionDate)) {
5051 5051
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
5052
-            $userConditions .=  " AND u.last_login <= '$lastConnectionDate' ";
5052
+            $userConditions .= " AND u.last_login <= '$lastConnectionDate' ";
5053 5053
         }
5054 5054
 
5055 5055
         if (!empty($keyword)) {
@@ -5108,7 +5108,7 @@  discard block
 block discarded – undo
5108 5108
         $result = Database::query($sql);
5109 5109
         $result = Database::store_result($result);
5110 5110
 
5111
-        return $result ;
5111
+        return $result;
5112 5112
     }
5113 5113
 
5114 5114
     /**
@@ -5168,7 +5168,7 @@  discard block
 block discarded – undo
5168 5168
                     $userToString = null;
5169 5169
                     foreach ($userList as $userInfo) {
5170 5170
                         $newUserList[] = $userInfo['user_id'];
5171
-                        $userToString .= $userInfo['firstname'] . ' ' . $userInfo['lastname'] . '<br />';
5171
+                        $userToString .= $userInfo['firstname'].' '.$userInfo['lastname'].'<br />';
5172 5172
                     }
5173 5173
 
5174 5174
                     if (!empty($sessionsDestination)) {
@@ -5181,7 +5181,7 @@  discard block
 block discarded – undo
5181 5181
                                 $messages[] = Display::return_message(sprintf(get_lang('SessionXSkipped'), $sessionDestinationId), 'warning', false);
5182 5182
                                 continue;
5183 5183
                             }
5184
-                            $messages[] = Display::return_message(get_lang('StudentList') . '<br />' . $userToString, 'info', false);
5184
+                            $messages[] = Display::return_message(get_lang('StudentList').'<br />'.$userToString, 'info', false);
5185 5185
                             SessionManager::suscribe_users_to_session(
5186 5186
                                 $sessionDestinationId,
5187 5187
                                 $newUserList,
@@ -5232,7 +5232,7 @@  discard block
 block discarded – undo
5232 5232
                 }
5233 5233
             }
5234 5234
         }
5235
-        $sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=';
5235
+        $sessionUrl = api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session=';
5236 5236
 
5237 5237
         $htmlResult = null;
5238 5238
 
@@ -5247,7 +5247,7 @@  discard block
 block discarded – undo
5247 5247
                     $sessionInfo = self::fetch($sessionId);
5248 5248
                     $htmlResult .= '<br />';
5249 5249
                     $htmlResult .= Display::url(
5250
-                        get_lang('Session') . ': ' . $sessionInfo['name'] . ' <br />', $sessionUrl . $sessionId, array('target' => '_blank')
5250
+                        get_lang('Session').': '.$sessionInfo['name'].' <br />', $sessionUrl.$sessionId, array('target' => '_blank')
5251 5251
                     );
5252 5252
                     $teacherList = array();
5253 5253
                     foreach ($coachList as $coachId) {
@@ -5360,7 +5360,7 @@  discard block
 block discarded – undo
5360 5360
                 }
5361 5361
 
5362 5362
                 $sessionIdList = array_map('intval', $sessionIdList);
5363
-                $sessionToString = implode("', '",  $sessionIdList);
5363
+                $sessionToString = implode("', '", $sessionIdList);
5364 5364
 
5365 5365
                 $course = Database::get_main_table(TABLE_MAIN_COURSE);
5366 5366
                 $sessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -5372,7 +5372,7 @@  discard block
 block discarded – undo
5372 5372
                         INNER JOIN $courseUser cu ON (cu.c_id = c.id)
5373 5373
 		                WHERE src.session_id IN ('$sessionToString') AND cu.status = 1";
5374 5374
                 $result = Database::query($sql);
5375
-                while($row = Database::fetch_array($result, 'ASSOC')) {
5375
+                while ($row = Database::fetch_array($result, 'ASSOC')) {
5376 5376
                     $teacherListId[$row['user_id']] = $row['user_id'];
5377 5377
                 }
5378 5378
             } else {
@@ -5447,7 +5447,7 @@  discard block
 block discarded – undo
5447 5447
         $toolList = self::getCourseToolToBeManaged();
5448 5448
 
5449 5449
         foreach ($toolList as $tool) {
5450
-            $method = 'add' . $tool;
5450
+            $method = 'add'.$tool;
5451 5451
             if (method_exists(get_class(), $method)) {
5452 5452
                 self::$method($sessionId, $courseId);
5453 5453
             }
@@ -5466,7 +5466,7 @@  discard block
 block discarded – undo
5466 5466
         $toolList = self::getCourseToolToBeManaged();
5467 5467
 
5468 5468
         foreach ($toolList as $tool) {
5469
-            $method = 'remove' . $tool;
5469
+            $method = 'remove'.$tool;
5470 5470
             if (method_exists(get_class(), $method)) {
5471 5471
                 self::$method($sessionId, $courseId);
5472 5472
             }
@@ -5584,18 +5584,18 @@  discard block
 block discarded – undo
5584 5584
                         }
5585 5585
                     }
5586 5586
 
5587
-                    $message .= '<strong>' . get_lang('User') . '</strong> ' . $userInfo['complete_name'] . ' <br />';
5587
+                    $message .= '<strong>'.get_lang('User').'</strong> '.$userInfo['complete_name'].' <br />';
5588 5588
 
5589 5589
                     if (!in_array($userInfo['status'], array(DRH)) && !api_is_platform_admin_by_id($userInfo['user_id'])) {
5590
-                        $message .= get_lang('UserMustHaveTheDrhRole') . '<br />';
5590
+                        $message .= get_lang('UserMustHaveTheDrhRole').'<br />';
5591 5591
                         continue;
5592 5592
                     }
5593 5593
 
5594 5594
                     if (!empty($sessionList)) {
5595
-                        $message .= '<strong>' . get_lang('Sessions') . ':</strong> <br />';
5596
-                        $message .= implode(', ', $sessionList) . '<br /><br />';
5595
+                        $message .= '<strong>'.get_lang('Sessions').':</strong> <br />';
5596
+                        $message .= implode(', ', $sessionList).'<br /><br />';
5597 5597
                     } else {
5598
-                        $message .= get_lang('NoSessionProvided') . ' <br /><br />';
5598
+                        $message .= get_lang('NoSessionProvided').' <br /><br />';
5599 5599
                     }
5600 5600
                 }
5601 5601
             }
@@ -5775,8 +5775,8 @@  discard block
 block discarded – undo
5775 5775
 
5776 5776
         $firstAccess = api_strtotime($courseAccess['login_course_date'], 'UTC');
5777 5777
 
5778
-        $endDateInSeconds = $firstAccess + $duration*24*60*60;
5779
-        $leftDays = round(($endDateInSeconds- $currentTime) / 60 / 60 / 24);
5778
+        $endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60;
5779
+        $leftDays = round(($endDateInSeconds - $currentTime) / 60 / 60 / 24);
5780 5780
 
5781 5781
         return $leftDays;
5782 5782
     }
@@ -6058,7 +6058,7 @@  discard block
 block discarded – undo
6058 6058
         $sql = "SELECT COUNT(1) as count, u.id, scu.status status_in_session, u.status user_status
6059 6059
                 FROM $tableSessionRelCourseRelUser scu
6060 6060
                 INNER JOIN $tableUser u ON scu.user_id = u.id
6061
-                WHERE scu.session_id = " . intval($sessionId) ."
6061
+                WHERE scu.session_id = ".intval($sessionId)."
6062 6062
                 GROUP BY u.id";
6063 6063
 
6064 6064
         $result = Database::query($sql);
@@ -6093,7 +6093,7 @@  discard block
 block discarded – undo
6093 6093
             $sfTable = Database::get_main_table(TABLE_EXTRA_FIELD);
6094 6094
             $sfvTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6095 6095
             // Join session field and session field values tables
6096
-            $joinTable = $sfTable . ' sf INNER JOIN ' . $sfvTable . ' sfv ON sf.id = sfv.field_id';
6096
+            $joinTable = $sfTable.' sf INNER JOIN '.$sfvTable.' sfv ON sf.id = sfv.field_id';
6097 6097
             $fieldsArray = array();
6098 6098
             foreach ($extraFields as $field) {
6099 6099
                 $fieldsArray[] = Database::escape_string($field);
@@ -6136,14 +6136,14 @@  discard block
 block discarded – undo
6136 6136
                 for ($i = 1; $i < count($fieldsArray); $i++) {
6137 6137
                     $whereParams .= ', ?';
6138 6138
                 }
6139
-                $whereFieldVariables = ' variable IN ( ' . $whereParams .' )';
6140
-                $whereFieldIds = 'field_id IN ( ' . $whereParams .  ' )';
6139
+                $whereFieldVariables = ' variable IN ( '.$whereParams.' )';
6140
+                $whereFieldIds = 'field_id IN ( '.$whereParams.' )';
6141 6141
             }
6142 6142
             // Get session fields
6143 6143
             $extraField = new ExtraField('session');
6144 6144
             $questionMarks = substr(str_repeat('?, ', count($fieldsArray)), 0, -2);
6145 6145
             $fieldsList = $extraField->get_all(array(
6146
-                ' variable IN ( ' . $questionMarks . ' )' => $fieldsArray,
6146
+                ' variable IN ( '.$questionMarks.' )' => $fieldsArray,
6147 6147
             ));
6148 6148
             // Index session fields
6149 6149
             foreach ($fieldsList as $field) {
@@ -6152,7 +6152,7 @@  discard block
 block discarded – undo
6152 6152
             // Get session field values
6153 6153
             $extra = new ExtraFieldValue('session');
6154 6154
             $questionMarksFields = substr(str_repeat('?, ', count($fields)), 0, -2);
6155
-            $sessionFieldValueList = $extra->get_all(array ('where' => array('field_id IN ( ' . $questionMarksFields . ' )' => array_keys($fields))));
6155
+            $sessionFieldValueList = $extra->get_all(array('where' => array('field_id IN ( '.$questionMarksFields.' )' => array_keys($fields))));
6156 6156
             // Add session fields values to session list
6157 6157
             foreach ($sessionList as $id => &$session) {
6158 6158
                 foreach ($sessionFieldValueList as $sessionFieldValue) {
@@ -6205,7 +6205,7 @@  discard block
 block discarded – undo
6205 6205
             // Check the result
6206 6206
             if ($result < 1) {
6207 6207
                 // If not found any result, update error message
6208
-                $errorResult['errorMessage'] = 'Not found any session category name ' . $categoryName;
6208
+                $errorResult['errorMessage'] = 'Not found any session category name '.$categoryName;
6209 6209
             } elseif (count($result) > 1 && !$force) {
6210 6210
                 // If found more than one result and force is disabled, update error message
6211 6211
                 $errorResult['errorMessage'] = 'Found many session categories';
@@ -6264,7 +6264,7 @@  discard block
 block discarded – undo
6264 6264
             // Check if session list query had result
6265 6265
             if (!empty($sessionList)) {
6266 6266
                 // implode all session id
6267
-                $sessionIdsString = '(' . implode(', ', array_keys($sessionList)) . ')';
6267
+                $sessionIdsString = '('.implode(', ', array_keys($sessionList)).')';
6268 6268
                 // Get all field variables
6269 6269
                 $sessionFieldList = Database::select(
6270 6270
                     'id, variable',
@@ -6351,7 +6351,7 @@  discard block
 block discarded – undo
6351 6351
                 return $sessionList;
6352 6352
             } else {
6353 6353
                 // Not found result, update error message
6354
-                $errorResult['errorMessage'] = 'Not found any session for session category id ' . $sessionCategoryId;
6354
+                $errorResult['errorMessage'] = 'Not found any session for session category id '.$sessionCategoryId;
6355 6355
             }
6356 6356
         }
6357 6357
 
@@ -6455,7 +6455,7 @@  discard block
 block discarded – undo
6455 6455
 
6456 6456
         $sessionExtraField = new ExtraField('session');
6457 6457
         $fieldList = $sessionExtraField->get_all(array(
6458
-            "variable IN ( " . implode(", ", $variablePlaceHolders) . " ) " => $variables,
6458
+            "variable IN ( ".implode(", ", $variablePlaceHolders)." ) " => $variables,
6459 6459
         ));
6460 6460
 
6461 6461
         $fields = array();
@@ -6469,7 +6469,7 @@  discard block
 block discarded – undo
6469 6469
         $extra = new ExtraFieldValue('session');
6470 6470
         $sessionFieldValueList = $extra->get_all(
6471 6471
             array(
6472
-                "field_id IN ( " . implode(", ", $variablePlaceHolders) . " )" => array_keys($fields),
6472
+                "field_id IN ( ".implode(", ", $variablePlaceHolders)." )" => array_keys($fields),
6473 6473
             )
6474 6474
         );
6475 6475
 
@@ -6540,7 +6540,7 @@  discard block
 block discarded – undo
6540 6540
                 FROM $sessionTable s
6541 6541
                 INNER JOIN $sessionUserTable sru ON s.id = sru.id_session
6542 6542
                 WHERE
6543
-                    (sru.id_user IN (" . implode(', ', $userIdList) . ")
6543
+                    (sru.id_user IN (".implode(', ', $userIdList).")
6544 6544
                     AND sru.relation_type = 0
6545 6545
                 )";
6546 6546
 
@@ -6556,7 +6556,7 @@  discard block
 block discarded – undo
6556 6556
                         WHERE
6557 6557
                             srau.access_url_id = $accessUrlId
6558 6558
                             AND (
6559
-                                sru.id_user IN (" . implode(', ', $userIdList) . ")
6559
+                                sru.id_user IN (".implode(', ', $userIdList).")
6560 6560
                                 AND sru.relation_type = 0
6561 6561
                             )";
6562 6562
             }
@@ -6577,7 +6577,7 @@  discard block
 block discarded – undo
6577 6577
      */
6578 6578
     public static function getSessionVisibility($sessionInfo)
6579 6579
     {
6580
-        switch($sessionInfo['visibility']) {
6580
+        switch ($sessionInfo['visibility']) {
6581 6581
             case 1:
6582 6582
                 return get_lang('ReadOnly');
6583 6583
             case 2:
@@ -6607,7 +6607,7 @@  discard block
 block discarded – undo
6607 6607
         }
6608 6608
         $result = '';
6609 6609
         if (!empty($startDateToLocal) && !empty($endDateToLocal)) {
6610
-            $result =  sprintf(get_lang('FromDateXToDateY'), $startDateToLocal, $endDateToLocal);
6610
+            $result = sprintf(get_lang('FromDateXToDateY'), $startDateToLocal, $endDateToLocal);
6611 6611
         } else {
6612 6612
             if (!empty($startDateToLocal)) {
6613 6613
                 $result = get_lang('From').' '.$startDateToLocal;
@@ -6752,7 +6752,7 @@  discard block
 block discarded – undo
6752 6752
                     get_lang('CoachName'),
6753 6753
                     null,
6754 6754
                     [
6755
-                        'url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach',
6755
+                        'url' => api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_general_coach',
6756 6756
                         'width' => '100%',
6757 6757
                     ]
6758 6758
                 );
@@ -6763,7 +6763,7 @@  discard block
 block discarded – undo
6763 6763
         $form->addHtml('<div id="ajax_list_coachs"></div>');
6764 6764
 
6765 6765
         $form->addButtonAdvancedSettings('advanced_params');
6766
-        $form->addElement('html','<div id="advanced_params_options" style="display:none">');
6766
+        $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
6767 6767
 
6768 6768
         $form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array(
6769 6769
             'id' => 'session_category'
@@ -6930,16 +6930,16 @@  discard block
 block discarded – undo
6930 6930
         if (api_is_session_admin() &&
6931 6931
             api_get_setting('allow_session_admins_to_see_all_sessions') == 'false'
6932 6932
         ) {
6933
-            $where.=" WHERE s.session_admin_id = $user_id ";
6933
+            $where .= " WHERE s.session_admin_id = $user_id ";
6934 6934
         }
6935 6935
 
6936 6936
         if (!empty($options['where'])) {
6937 6937
             $options['where'] = str_replace('course_title', 'c.title', $options['where']);
6938
-            $options['where'] = str_replace("( session_active = '0' )", '1=1',  $options['where']);
6938
+            $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
6939 6939
 
6940 6940
             $options['where'] = str_replace(
6941 6941
                 array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
6942
-                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " )
6942
+                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
6943 6943
                 , $options['where']
6944 6944
             );
6945 6945
 
@@ -6981,10 +6981,10 @@  discard block
 block discarded – undo
6981 6981
                        $where ";
6982 6982
 
6983 6983
         if (api_is_multiple_url_enabled()) {
6984
-            $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
6984
+            $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
6985 6985
             $access_url_id = api_get_current_access_url_id();
6986 6986
             if ($access_url_id != -1) {
6987
-                $where.= " AND ar.access_url_id = $access_url_id ";
6987
+                $where .= " AND ar.access_url_id = $access_url_id ";
6988 6988
 
6989 6989
                 $query_rows = "SELECT count(*) as total_rows
6990 6990
                                FROM $tbl_session s
@@ -7029,12 +7029,12 @@  discard block
 block discarded – undo
7029 7029
                     //get_lang('CourseTitle'),
7030 7030
                     get_lang('Visibility'),
7031 7031
                 );
7032
-                $column_model = array (
7033
-                    array('name'=>'name', 'index'=>'s.name', 'width'=>'160',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7034
-                    array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7035
-                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50',   'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7036
-                    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)),
7037
-                    array('name'=>'visibility', 'index'=>'visibility',      'width'=>'40',   'align'=>'left', 'search' => 'false'),
7032
+                $column_model = array(
7033
+                    array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7034
+                    array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7035
+                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7036
+                    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)),
7037
+                    array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
7038 7038
                 );
7039 7039
                 break;
7040 7040
             case 'complete':
@@ -7047,12 +7047,12 @@  discard block
 block discarded – undo
7047 7047
                     get_lang('Visibility'),
7048 7048
                     get_lang('CourseTitle'),
7049 7049
                 );
7050
-                $column_model = array (
7051
-                    array('name'=>'name', 'index'=>'s.name', 'width'=>'200',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7052
-                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70',   'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7053
-                    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)),
7054
-                    array('name'=>'coach_name', 'index'=>'coach_name',     'width'=>'70',   'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
7055
-                    array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25',   'align'=>'left', 'search' => 'true', 'stype'=>'select',
7050
+                $column_model = array(
7051
+                    array('name'=>'name', 'index'=>'s.name', 'width'=>'200', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7052
+                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7053
+                    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)),
7054
+                    array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
7055
+                    array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
7056 7056
                         // for the bottom bar
7057 7057
                         'searchoptions' => array(
7058 7058
                             'defaultValue'  => '1',
@@ -7060,8 +7060,8 @@  discard block
 block discarded – undo
7060 7060
                         // for the top bar
7061 7061
                         'editoptions' => array('value' => '" ":'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')),
7062 7062
                     ),
7063
-                    array('name'=>'visibility',     'index'=>'visibility',      'width'=>'40',   'align'=>'left', 'search' => 'false'),
7064
-                    array('name'=>'course_title',    'index'=>'course_title',   'width'=>'50',   'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
7063
+                    array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
7064
+                    array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true', 'sopt' => $operators)),
7065 7065
                 );
7066 7066
                 break;
7067 7067
         }
@@ -7070,14 +7070,14 @@  discard block
 block discarded – undo
7070 7070
         $session_field = new ExtraField('session');
7071 7071
         $rules = $session_field->getRules($columns, $column_model);
7072 7072
 
7073
-        $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80',  'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false');
7073
+        $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80', 'align'=>'left', 'formatter'=>'action_formatter', 'sortable'=>'false', 'search' => 'false');
7074 7074
         $columns[] = get_lang('Actions');
7075 7075
 
7076 7076
         foreach ($column_model as $col_model) {
7077 7077
             $simple_column_name[] = $col_model['name'];
7078 7078
         }
7079 7079
 
7080
-        $return_array =  array(
7080
+        $return_array = array(
7081 7081
             'columns' => $columns,
7082 7082
             'column_model' => $column_model,
7083 7083
             'rules' => $rules,
@@ -7166,7 +7166,7 @@  discard block
 block discarded – undo
7166 7166
             if (api_is_session_admin() &&
7167 7167
                 api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
7168 7168
             ) {
7169
-                $where.=" AND s.session_admin_id = $user_id ";
7169
+                $where .= " AND s.session_admin_id = $user_id ";
7170 7170
             }
7171 7171
         }
7172 7172
 
@@ -7249,11 +7249,11 @@  discard block
 block discarded – undo
7249 7249
             }
7250 7250
             $options['where'] = str_replace('course_title', 'c.title', $options['where']);
7251 7251
 
7252
-            $options['where'] = str_replace("( session_active = '0' )", '1=1',  $options['where']);
7252
+            $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
7253 7253
 
7254 7254
             $options['where'] = str_replace(
7255 7255
                 array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
7256
-                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " )
7256
+                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
7257 7257
                 , $options['where']
7258 7258
             );
7259 7259
 
@@ -7288,10 +7288,10 @@  discard block
 block discarded – undo
7288 7288
             $where;
7289 7289
 
7290 7290
         if (api_is_multiple_url_enabled()) {
7291
-            $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7291
+            $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7292 7292
             $access_url_id = api_get_current_access_url_id();
7293 7293
             if ($access_url_id != -1) {
7294
-                $where.= " AND ar.access_url_id = $access_url_id ";
7294
+                $where .= " AND ar.access_url_id = $access_url_id ";
7295 7295
                 $query = "$select
7296 7296
                     FROM $tbl_session s
7297 7297
                     LEFT JOIN $tbl_session_field_values fv ON (fv.session_id = s.id)
@@ -7318,7 +7318,7 @@  discard block
 block discarded – undo
7318 7318
         $formatted_sessions = array();
7319 7319
 
7320 7320
         if (Database::num_rows($result)) {
7321
-            $sessions   = Database::store_result($result, 'ASSOC');
7321
+            $sessions = Database::store_result($result, 'ASSOC');
7322 7322
             foreach ($sessions as $session) {
7323 7323
                 $session_id = $session['id'];
7324 7324
                 $session['name'] = Display::url($session['name'], "resume_session.php?id_session=".$session['id']);
@@ -7333,14 +7333,14 @@  discard block
 block discarded – undo
7333 7333
 
7334 7334
                 switch ($session['visibility']) {
7335 7335
                     case SESSION_VISIBLE_READ_ONLY: //1
7336
-                        $session['visibility'] =  get_lang('ReadOnly');
7336
+                        $session['visibility'] = get_lang('ReadOnly');
7337 7337
                         break;
7338 7338
                     case SESSION_VISIBLE:           //2
7339 7339
                     case SESSION_AVAILABLE:         //4
7340
-                        $session['visibility'] =  get_lang('Visible');
7340
+                        $session['visibility'] = get_lang('Visible');
7341 7341
                         break;
7342 7342
                     case SESSION_INVISIBLE:         //3
7343
-                        $session['visibility'] =  api_ucfirst(get_lang('Invisible'));
7343
+                        $session['visibility'] = api_ucfirst(get_lang('Invisible'));
7344 7344
                         break;
7345 7345
                 }
7346 7346
 
@@ -7416,7 +7416,7 @@  discard block
 block discarded – undo
7416 7416
         if (empty($session)) {
7417 7417
             return false;
7418 7418
         }
7419
-        return api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $id;
7419
+        return api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$id;
7420 7420
     }
7421 7421
 
7422 7422
     /**
@@ -7434,7 +7434,7 @@  discard block
 block discarded – undo
7434 7434
             return false;
7435 7435
         }
7436 7436
         if (empty($courseId)) {
7437
-            return api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $id;
7437
+            return api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$id;
7438 7438
         } else {
7439 7439
             $courseInfo = api_get_course_info_by_id($courseId);
7440 7440
             if ($courseInfo) {
@@ -7680,7 +7680,7 @@  discard block
 block discarded – undo
7680 7680
             // sort $listCat by catSessionName
7681 7681
             usort($listCat, 'self::compareBySessionName');
7682 7682
             // in each catSession sort sessionList by sessionName
7683
-            foreach($listCat as $i => $listCatSessionInfo) {
7683
+            foreach ($listCat as $i => $listCatSessionInfo) {
7684 7684
                 $listSessionList = $listCatSessionInfo['sessionList'];
7685 7685
                 usort($listSessionList, 'self::compareCatSessionInfo');
7686 7686
                 $listCat[$i]['sessionList'] = $listSessionList;
@@ -7695,8 +7695,8 @@  discard block
 block discarded – undo
7695 7695
             );
7696 7696
 
7697 7697
             $userCatId = intval($userCatId);
7698
-            $listResults[$userCatId]['courseInUserCategoryId'] =  $userCatId;
7699
-            $listResults[$userCatId]['courseInUserCategoryTitle'] =  $userCatTitle;
7698
+            $listResults[$userCatId]['courseInUserCategoryId'] = $userCatId;
7699
+            $listResults[$userCatId]['courseInUserCategoryTitle'] = $userCatTitle;
7700 7700
             $listResults[$userCatId]['courseInUserCatList'][] = $listOneCourse;
7701 7701
         }
7702 7702
 
@@ -7722,7 +7722,7 @@  discard block
 block discarded – undo
7722 7722
     {
7723 7723
         if ($listA['sessionName'] == $listB['sessionName']) {
7724 7724
             return 0;
7725
-        } else if($listA['sessionName'] > $listB['sessionName']) {
7725
+        } else if ($listA['sessionName'] > $listB['sessionName']) {
7726 7726
             return 1;
7727 7727
         } else {
7728 7728
             return -1;
@@ -7742,7 +7742,7 @@  discard block
 block discarded – undo
7742 7742
             return 1;
7743 7743
         } else if ($listA['catSessionName'] == $listB['catSessionName']) {
7744 7744
             return 0;
7745
-        } else if($listA['catSessionName'] > $listB['catSessionName']) {
7745
+        } else if ($listA['catSessionName'] > $listB['catSessionName']) {
7746 7746
             return 1;
7747 7747
         } else {
7748 7748
             return -1;
@@ -7758,7 +7758,7 @@  discard block
 block discarded – undo
7758 7758
     {
7759 7759
         if ($listA['courseInUserCategoryTitle'] == $listB['courseInUserCategoryTitle']) {
7760 7760
             return 0;
7761
-        } else if($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) {
7761
+        } else if ($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) {
7762 7762
             return 1;
7763 7763
         } else {
7764 7764
             return -1;
@@ -7774,7 +7774,7 @@  discard block
 block discarded – undo
7774 7774
     {
7775 7775
         if ($listA['title'] == $listB['title']) {
7776 7776
             return 0;
7777
-        } else if($listA['title'] > $listB['title']) {
7777
+        } else if ($listA['title'] > $listB['title']) {
7778 7778
             return 1;
7779 7779
         } else {
7780 7780
             return -1;
@@ -7820,8 +7820,8 @@  discard block
 block discarded – undo
7820 7820
 
7821 7821
                 $marginShift = 20;
7822 7822
                 if ($catSessionName != '') {
7823
-                    $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">' .
7824
-                        CourseManager::course_item_html($listParamsCatSession, true) . '</div>';
7823
+                    $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">'.
7824
+                        CourseManager::course_item_html($listParamsCatSession, true).'</div>';
7825 7825
                     $marginShift = 40;
7826 7826
                 }
7827 7827
 
Please login to merge, or discard this patch.
main/inc/lib/conditional_login.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
                     if (isset($condition['conditional_function']) && $condition['conditional_function']($user) == false) {
24 24
                         $_SESSION['conditional_login']['uid'] = $user['user_id'];
25 25
                         $_SESSION['conditional_login']['can_login'] = false;
26
-                        header("Location:". $condition['url']);
26
+                        header("Location:".$condition['url']);
27 27
                         exit();
28 28
                     }
29 29
                 }
Please login to merge, or discard this patch.
main/inc/lib/image.lib.php 4 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             if ($height >= $max_size_for_picture) {
48 48
                 // scale width
49 49
                 $new_width = round($width * ($max_size_for_picture / $height));
50
-                 $this->image_wrapper->resize($new_width, $max_size_for_picture, 0);
50
+                    $this->image_wrapper->resize($new_width, $max_size_for_picture, 0);
51 51
             }
52 52
         }
53 53
     }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function __construct($path)
151 151
     {
152
-          parent::__construct($path);
152
+            parent::__construct($path);
153 153
     }
154 154
 
155 155
     public function set_image_wrapper()
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
         }
185 185
     }
186 186
 
187
-	public function get_image_size()
187
+    public function get_image_size()
188 188
     {
189
-		$imagesize = array('width'=>0,'height'=>0);
190
-	    if ($this->image_validated) {
189
+        $imagesize = array('width'=>0,'height'=>0);
190
+        if ($this->image_validated) {
191 191
             $imagesize = $this->image->getImageGeometry();
192
-	    }
193
-	    return $imagesize;
194
-	}
192
+        }
193
+        return $imagesize;
194
+    }
195 195
 
196
-	//@todo implement border logic case for Imagick
197
-	public function resize($thumbw, $thumbh, $border, $specific_size = false)
196
+    //@todo implement border logic case for Imagick
197
+    public function resize($thumbw, $thumbh, $border, $specific_size = false)
198 198
     {
199
-	    if (!$this->image_validated) return false;
199
+        if (!$this->image_validated) return false;
200 200
 
201 201
         if ($specific_size) {
202 202
             $width = $thumbw;
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
             $width  = (int)($this->width * $scale);
207 207
             $height = (int)($this->height * $scale);
208 208
         }
209
-		$result = $this->image->resizeImage($width, $height, $this->filter, 1);
210
-		$this->width  = $thumbw;
211
-		$this->height = $thumbh;
212
-	}
209
+        $result = $this->image->resizeImage($width, $height, $this->filter, 1);
210
+        $this->width  = $thumbw;
211
+        $this->height = $thumbh;
212
+    }
213 213
     
214 214
     /**
215 215
      * @author José Loguercio <[email protected]>
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
225 225
         if (!$this->image_validated) return false;
226 226
         $this->image->cropimage($width, $height, $x, $y);
227
-		$this->width  = $width;
228
-		$this->height = $height;
227
+        $this->width  = $width;
228
+        $this->height = $height;
229 229
     }
230 230
 
231 231
     public function send_image($file = '', $compress = -1, $convert_file_to = null)
@@ -235,35 +235,35 @@  discard block
 block discarded – undo
235 235
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
236 236
             $type = $convert_file_to;
237 237
         }
238
-		switch ($type) {
239
-		    case 'jpeg':
240
-			case 'jpg':
241
-				if (!$file) header("Content-type: image/jpeg");
242
-				break;
243
-			case 'png':
244
-				if (!$file) header("Content-type: image/png");
245
-				break;
246
-			case 'gif':
247
-				if (!$file) header("Content-type: image/gif");
248
-				break;
249
-		}
250
-		$result = false;
251
-		try {
252
-		    $result = $this->image->writeImage($file);
253
-		} catch(ImagickException $e) {
238
+        switch ($type) {
239
+            case 'jpeg':
240
+            case 'jpg':
241
+                if (!$file) header("Content-type: image/jpeg");
242
+                break;
243
+            case 'png':
244
+                if (!$file) header("Content-type: image/png");
245
+                break;
246
+            case 'gif':
247
+                if (!$file) header("Content-type: image/gif");
248
+                break;
249
+        }
250
+        $result = false;
251
+        try {
252
+            $result = $this->image->writeImage($file);
253
+        } catch(ImagickException $e) {
254 254
             if ($this->debug) error_log($e->getMessage());
255 255
         }
256 256
 
257
-		if (!$file) {
258
-		    echo $this->image;
259
-		    $this->image->clear();
257
+        if (!$file) {
258
+            echo $this->image;
259
+            $this->image->clear();
260 260
             $this->image->destroy();
261
-		} else {
262
-		    $this->image->clear();
261
+        } else {
262
+            $this->image->clear();
263 263
             $this->image->destroy();
264
-		    return $result;
265
-		}
266
-	}
264
+            return $result;
265
+        }
266
+    }
267 267
 
268 268
 }
269 269
 
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
         $this->fill_image_info();
286 286
 
287 287
         switch ($this->type) {
288
-        	case 0:
289
-        		$handler = false;
290
-        		break;
291
-		    case 1 :
288
+            case 0:
289
+                $handler = false;
290
+                break;
291
+            case 1 :
292 292
                 $handler = @imagecreatefromgif($this->path);
293 293
                 $this->type = 'gif';
294 294
                 break;
295
-		    case 2 :
295
+            case 2 :
296 296
                 $handler = @imagecreatefromjpeg($this->path);
297 297
                 $this->type = 'jpg';
298 298
                 break;
299
-		    case 3 :
300
-		        $handler = @imagecreatefrompng($this->path);
301
-		        $this->type = 'png';
302
-		        break;
299
+            case 3 :
300
+                $handler = @imagecreatefrompng($this->path);
301
+                $this->type = 'png';
302
+                break;
303 303
         }
304 304
         if ($handler) {
305 305
             $this->image_validated = true;
@@ -313,29 +313,29 @@  discard block
 block discarded – undo
313 313
     {
314 314
         $return_array = array('width'=>0,'height'=>0);
315 315
         if ($this->image_validated) {
316
-	        $return_array = array('width'=>$this->width,'height'=>$this->height);
316
+            $return_array = array('width'=>$this->width,'height'=>$this->height);
317 317
         }
318 318
         return $return_array;
319
-	}
319
+    }
320 320
 
321 321
     public function fill_image_info()
322 322
     {
323
-    	if (file_exists($this->path)) {
324
-	        $image_info     = getimagesize($this->path);
325
-			$this->width    = $image_info[0];
326
-			$this->height   = $image_info[1];
327
-			$this->type     = $image_info[2];
328
-    	} else {
329
-    		$this->width    = 0;
330
-    		$this->height   = 0;
331
-    		$this->type     = 0;
332
-    	}
323
+        if (file_exists($this->path)) {
324
+            $image_info     = getimagesize($this->path);
325
+            $this->width    = $image_info[0];
326
+            $this->height   = $image_info[1];
327
+            $this->type     = $image_info[2];
328
+        } else {
329
+            $this->width    = 0;
330
+            $this->height   = 0;
331
+            $this->type     = 0;
332
+        }
333 333
     }
334 334
 
335 335
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
336 336
     {
337 337
         if (!$this->image_validated) return false;
338
-		if ($border == 1) {
338
+        if ($border == 1) {
339 339
             if ($specific_size) {
340 340
                 $width = $thumbw;
341 341
                 $height = $thumbh;
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
                 $width = (int)($this->width * $scale);
345 345
                 $height = (int)($this->height * $scale);
346 346
             }
347
-			$deltaw = (int)(($thumbw - $width) / 2);
348
-			$deltah = (int)(($thumbh - $height) / 2);
349
-			$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350
-            		@imagealphablending($dst_img, false);
351
-		        @imagesavealpha($dst_img, true);
352
-			if (!empty($this->color)) {
353
-				@imagefill($dst_img, 0, 0, $this->color);
354
-			}
355
-			$this->width = $thumbw;
356
-			$this->height = $thumbh;
357
-		} elseif ($border == 0) {
347
+            $deltaw = (int)(($thumbw - $width) / 2);
348
+            $deltah = (int)(($thumbh - $height) / 2);
349
+            $dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350
+                    @imagealphablending($dst_img, false);
351
+                @imagesavealpha($dst_img, true);
352
+            if (!empty($this->color)) {
353
+                @imagefill($dst_img, 0, 0, $this->color);
354
+            }
355
+            $this->width = $thumbw;
356
+            $this->height = $thumbh;
357
+        } elseif ($border == 0) {
358 358
             if ($specific_size) {
359 359
                 $width = $thumbw;
360 360
                 $height = $thumbh;
@@ -363,19 +363,19 @@  discard block
 block discarded – undo
363 363
                 $width  = (int)($this->width * $scale);
364 364
                 $height = (int)($this->height * $scale);
365 365
             }
366
-			$deltaw = 0;
367
-			$deltah = 0;
368
-			$dst_img = @ImageCreateTrueColor($width, $height);
369
-            		@imagealphablending($dst_img, false);
370
-		        @imagesavealpha($dst_img, true);
371
-			$this->width = $width;
372
-			$this->height = $height;
373
-		}
374
-		$src_img = $this->bg;
375
-		@ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img));
376
-		$this->bg = $dst_img;
377
-		@imagedestroy($src_img);
378
-	}
366
+            $deltaw = 0;
367
+            $deltah = 0;
368
+            $dst_img = @ImageCreateTrueColor($width, $height);
369
+                    @imagealphablending($dst_img, false);
370
+                @imagesavealpha($dst_img, true);
371
+            $this->width = $width;
372
+            $this->height = $height;
373
+        }
374
+        $src_img = $this->bg;
375
+        @ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img));
376
+        $this->bg = $dst_img;
377
+        @imagedestroy($src_img);
378
+    }
379 379
     
380 380
     /**
381 381
      * @author José Loguercio <[email protected]>
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
390 390
         if (!$this->image_validated) return false;
391 391
         $this->width = $width;
392
-		$this->height = $height;
392
+        $this->height = $height;
393 393
         $src = null;
394 394
         $dest = @imagecreatetruecolor($width, $height);
395 395
         $type = $this->type;
@@ -400,56 +400,56 @@  discard block
 block discarded – undo
400 400
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
401 401
                 @imagejpeg($dest, $this->path);
402 402
                 break;
403
-		    case 'png' :
403
+            case 'png' :
404 404
                 $src = @imagecreatefrompng($this->path);
405 405
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
406 406
                 @imagepng($dest, $this->path);
407 407
                 break;
408
-		    case 'gif' :
409
-		        $src = @imagecreatefromgif($this->path);
408
+            case 'gif' :
409
+                $src = @imagecreatefromgif($this->path);
410 410
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
411 411
                 @imagegif($dest, $this->path);
412
-		        break;
412
+                break;
413 413
             default: return 0;
414 414
         }
415 415
         @imagedestroy($dest);
416 416
         @imagedestroy($src);
417 417
     }
418 418
 
419
-	public function send_image($file = '', $compress = -1, $convert_file_to = null)
419
+    public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 420
     {
421
-	    if (!$this->image_validated) return false;
421
+        if (!$this->image_validated) return false;
422 422
         $compress = (int)$compress;
423 423
         $type = $this->type;
424 424
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
425 425
             $type = $convert_file_to;
426 426
         }
427
-		switch ($type) {
428
-		    case 'jpeg':
429
-			case 'jpg':
430
-				if (!$file) header("Content-type: image/jpeg");
431
-				if ($compress == -1) $compress = 100;
432
-				return imagejpeg($this->bg, $file, $compress);
433
-				break;
434
-			case 'png':
435
-				if (!$file) header("Content-type: image/png");
436
-				if ($compress != -1) {
437
-					@imagetruecolortopalette($this->bg, true, $compress);
438
-				}
439
-				return imagepng($this->bg, $file, $compress);
440
-				break;
441
-			case 'gif':
442
-				if (!$file) header("Content-type: image/gif");
443
-				if ($compress != -1) {
444
-					@imagetruecolortopalette($this->bg, true, $compress);
445
-				}
446
-				return imagegif($this->bg, $file, $compress);
447
-				break;
448
-			default: return 0;
449
-		}
450
-		// TODO: Occupied memory is not released, because the following fragment of code is actually dead.
451
-		@imagedestroy($this->bg);
452
-	}
427
+        switch ($type) {
428
+            case 'jpeg':
429
+            case 'jpg':
430
+                if (!$file) header("Content-type: image/jpeg");
431
+                if ($compress == -1) $compress = 100;
432
+                return imagejpeg($this->bg, $file, $compress);
433
+                break;
434
+            case 'png':
435
+                if (!$file) header("Content-type: image/png");
436
+                if ($compress != -1) {
437
+                    @imagetruecolortopalette($this->bg, true, $compress);
438
+                }
439
+                return imagepng($this->bg, $file, $compress);
440
+                break;
441
+            case 'gif':
442
+                if (!$file) header("Content-type: image/gif");
443
+                if ($compress != -1) {
444
+                    @imagetruecolortopalette($this->bg, true, $compress);
445
+                }
446
+                return imagegif($this->bg, $file, $compress);
447
+                break;
448
+            default: return 0;
449
+        }
450
+        // TODO: Occupied memory is not released, because the following fragment of code is actually dead.
451
+        @imagedestroy($this->bg);
452
+    }
453 453
 
454 454
     /**
455 455
      * Convert image to black & white
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             return false;
116 116
         }
117 117
         $this->path = preg_match(VALID_WEB_PATH, $path) ? (api_is_internal_path($path) ? api_get_path(TO_SYS, $path) : $path) : $path;
118
-        $this->set_image_wrapper();  //Creates image obj
118
+        $this->set_image_wrapper(); //Creates image obj
119 119
     }
120 120
 
121 121
     abstract function set_image_wrapper();
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         if ($this->debug) error_log('Image::set_image_wrapper loaded');
158 158
         try {
159 159
             if (file_exists($this->path)) {
160
-                $this->image     = new Imagick($this->path);
160
+                $this->image = new Imagick($this->path);
161 161
 
162 162
                 if ($this->image) {
163 163
                     $this->fill_image_info(); //Fills height, width and type
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             } else {
166 166
                 if ($this->debug) error_log('Image::image does not exist');
167 167
             }
168
-        } catch(ImagickException $e) {
168
+        } catch (ImagickException $e) {
169 169
             if ($this->debug) error_log($e->getMessage());
170 170
         }
171 171
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 	public function get_image_size()
188 188
     {
189
-		$imagesize = array('width'=>0,'height'=>0);
189
+		$imagesize = array('width'=>0, 'height'=>0);
190 190
 	    if ($this->image_validated) {
191 191
             $imagesize = $this->image->getImageGeometry();
192 192
 	    }
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
             $height = $thumbh;
204 204
         } else {
205 205
             $scale  = ($this->width > 0 && $this->height > 0) ? min($thumbw / $this->width, $thumbh / $this->height) : 0;
206
-            $width  = (int)($this->width * $scale);
207
-            $height = (int)($this->height * $scale);
206
+            $width  = (int) ($this->width * $scale);
207
+            $height = (int) ($this->height * $scale);
208 208
         }
209 209
 		$result = $this->image->resizeImage($width, $height, $this->filter, 1);
210 210
 		$this->width  = $thumbw;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$result = false;
251 251
 		try {
252 252
 		    $result = $this->image->writeImage($file);
253
-		} catch(ImagickException $e) {
253
+		} catch (ImagickException $e) {
254 254
             if ($this->debug) error_log($e->getMessage());
255 255
         }
256 256
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 
312 312
     public function get_image_size()
313 313
     {
314
-        $return_array = array('width'=>0,'height'=>0);
314
+        $return_array = array('width'=>0, 'height'=>0);
315 315
         if ($this->image_validated) {
316
-	        $return_array = array('width'=>$this->width,'height'=>$this->height);
316
+	        $return_array = array('width'=>$this->width, 'height'=>$this->height);
317 317
         }
318 318
         return $return_array;
319 319
 	}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     public function fill_image_info()
322 322
     {
323 323
     	if (file_exists($this->path)) {
324
-	        $image_info     = getimagesize($this->path);
324
+	        $image_info = getimagesize($this->path);
325 325
 			$this->width    = $image_info[0];
326 326
 			$this->height   = $image_info[1];
327 327
 			$this->type     = $image_info[2];
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
                 $height = $thumbh;
342 342
             } else {
343 343
                 $scale = min($thumbw / $this->width, $thumbh / $this->height);
344
-                $width = (int)($this->width * $scale);
345
-                $height = (int)($this->height * $scale);
344
+                $width = (int) ($this->width * $scale);
345
+                $height = (int) ($this->height * $scale);
346 346
             }
347
-			$deltaw = (int)(($thumbw - $width) / 2);
348
-			$deltah = (int)(($thumbh - $height) / 2);
347
+			$deltaw = (int) (($thumbw - $width) / 2);
348
+			$deltah = (int) (($thumbh - $height) / 2);
349 349
 			$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350 350
             		@imagealphablending($dst_img, false);
351 351
 		        @imagesavealpha($dst_img, true);
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
                 $height = $thumbh;
361 361
             } else {
362 362
                 $scale = ($this->width > 0 && $this->height > 0) ? min($thumbw / $this->width, $thumbh / $this->height) : 0;
363
-                $width  = (int)($this->width * $scale);
364
-                $height = (int)($this->height * $scale);
363
+                $width  = (int) ($this->width * $scale);
364
+                $height = (int) ($this->height * $scale);
365 365
             }
366 366
 			$deltaw = 0;
367 367
 			$deltah = 0;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 420
     {
421 421
 	    if (!$this->image_validated) return false;
422
-        $compress = (int)$compress;
422
+        $compress = (int) $compress;
423 423
         $type = $this->type;
424 424
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
425 425
             $type = $convert_file_to;
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
          * so that we can use black (0,0,0) as transparent, which is what
464 464
          * the image is filled with when created.
465 465
          */
466
-        $transparent = imagecolorallocate($dest_img, 0,0,0);
466
+        $transparent = imagecolorallocate($dest_img, 0, 0, 0);
467 467
         imagealphablending($dest_img, false);
468 468
         imagesavealpha($dest_img, true);
469 469
         imagecolortransparent($dest_img, $transparent);
470
-        imagecopy($dest_img, $this->bg, 0,0, 0, 0,imagesx($this->bg), imagesx($this->bg));
470
+        imagecopy($dest_img, $this->bg, 0, 0, 0, 0, imagesx($this->bg), imagesx($this->bg));
471 471
         imagefilter($dest_img, IMG_FILTER_GRAYSCALE);
472 472
         $this->bg = $dest_img;
473 473
 
Please login to merge, or discard this patch.
Braces   +57 added lines, -19 removed lines patch added patch discarded remove patch
@@ -154,7 +154,9 @@  discard block
 block discarded – undo
154 154
 
155 155
     public function set_image_wrapper()
156 156
     {
157
-        if ($this->debug) error_log('Image::set_image_wrapper loaded');
157
+        if ($this->debug) {
158
+            error_log('Image::set_image_wrapper loaded');
159
+        }
158 160
         try {
159 161
             if (file_exists($this->path)) {
160 162
                 $this->image     = new Imagick($this->path);
@@ -163,10 +165,14 @@  discard block
 block discarded – undo
163 165
                     $this->fill_image_info(); //Fills height, width and type
164 166
                 }
165 167
             } else {
166
-                if ($this->debug) error_log('Image::image does not exist');
168
+                if ($this->debug) {
169
+                    error_log('Image::image does not exist');
170
+                }
167 171
             }
168 172
         } catch(ImagickException $e) {
169
-            if ($this->debug) error_log($e->getMessage());
173
+            if ($this->debug) {
174
+                error_log($e->getMessage());
175
+            }
170 176
         }
171 177
     }
172 178
 
@@ -180,7 +186,9 @@  discard block
 block discarded – undo
180 186
 
181 187
         if (in_array($this->type, $this->allowed_extensions)) {
182 188
             $this->image_validated = true;
183
-            if ($this->debug) error_log('image_validated true');
189
+            if ($this->debug) {
190
+                error_log('image_validated true');
191
+            }
184 192
         }
185 193
     }
186 194
 
@@ -196,7 +204,9 @@  discard block
 block discarded – undo
196 204
 	//@todo implement border logic case for Imagick
197 205
 	public function resize($thumbw, $thumbh, $border, $specific_size = false)
198 206
     {
199
-	    if (!$this->image_validated) return false;
207
+	    if (!$this->image_validated) {
208
+	        return false;
209
+	    }
200 210
 
201 211
         if ($specific_size) {
202 212
             $width = $thumbw;
@@ -222,7 +232,9 @@  discard block
 block discarded – undo
222 232
      */
223 233
     
224 234
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
225
-        if (!$this->image_validated) return false;
235
+        if (!$this->image_validated) {
236
+            return false;
237
+        }
226 238
         $this->image->cropimage($width, $height, $x, $y);
227 239
 		$this->width  = $width;
228 240
 		$this->height = $height;
@@ -230,7 +242,9 @@  discard block
 block discarded – undo
230 242
 
231 243
     public function send_image($file = '', $compress = -1, $convert_file_to = null)
232 244
     {
233
-        if (!$this->image_validated) return false;
245
+        if (!$this->image_validated) {
246
+            return false;
247
+        }
234 248
         $type = $this->type;
235 249
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
236 250
             $type = $convert_file_to;
@@ -238,20 +252,28 @@  discard block
 block discarded – undo
238 252
 		switch ($type) {
239 253
 		    case 'jpeg':
240 254
 			case 'jpg':
241
-				if (!$file) header("Content-type: image/jpeg");
255
+				if (!$file) {
256
+				    header("Content-type: image/jpeg");
257
+				}
242 258
 				break;
243 259
 			case 'png':
244
-				if (!$file) header("Content-type: image/png");
260
+				if (!$file) {
261
+				    header("Content-type: image/png");
262
+				}
245 263
 				break;
246 264
 			case 'gif':
247
-				if (!$file) header("Content-type: image/gif");
265
+				if (!$file) {
266
+				    header("Content-type: image/gif");
267
+				}
248 268
 				break;
249 269
 		}
250 270
 		$result = false;
251 271
 		try {
252 272
 		    $result = $this->image->writeImage($file);
253 273
 		} catch(ImagickException $e) {
254
-            if ($this->debug) error_log($e->getMessage());
274
+            if ($this->debug) {
275
+                error_log($e->getMessage());
276
+            }
255 277
         }
256 278
 
257 279
 		if (!$file) {
@@ -334,7 +356,9 @@  discard block
 block discarded – undo
334 356
 
335 357
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
336 358
     {
337
-        if (!$this->image_validated) return false;
359
+        if (!$this->image_validated) {
360
+            return false;
361
+        }
338 362
 		if ($border == 1) {
339 363
             if ($specific_size) {
340 364
                 $width = $thumbw;
@@ -387,7 +411,9 @@  discard block
 block discarded – undo
387 411
      * @param int $src_height the source height of the original image
388 412
      */
389 413
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
390
-        if (!$this->image_validated) return false;
414
+        if (!$this->image_validated) {
415
+            return false;
416
+        }
391 417
         $this->width = $width;
392 418
 		$this->height = $height;
393 419
         $src = null;
@@ -418,7 +444,9 @@  discard block
 block discarded – undo
418 444
 
419 445
 	public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 446
     {
421
-	    if (!$this->image_validated) return false;
447
+	    if (!$this->image_validated) {
448
+	        return false;
449
+	    }
422 450
         $compress = (int)$compress;
423 451
         $type = $this->type;
424 452
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
@@ -427,19 +455,27 @@  discard block
 block discarded – undo
427 455
 		switch ($type) {
428 456
 		    case 'jpeg':
429 457
 			case 'jpg':
430
-				if (!$file) header("Content-type: image/jpeg");
431
-				if ($compress == -1) $compress = 100;
458
+				if (!$file) {
459
+				    header("Content-type: image/jpeg");
460
+				}
461
+				if ($compress == -1) {
462
+				    $compress = 100;
463
+				}
432 464
 				return imagejpeg($this->bg, $file, $compress);
433 465
 				break;
434 466
 			case 'png':
435
-				if (!$file) header("Content-type: image/png");
467
+				if (!$file) {
468
+				    header("Content-type: image/png");
469
+				}
436 470
 				if ($compress != -1) {
437 471
 					@imagetruecolortopalette($this->bg, true, $compress);
438 472
 				}
439 473
 				return imagepng($this->bg, $file, $compress);
440 474
 				break;
441 475
 			case 'gif':
442
-				if (!$file) header("Content-type: image/gif");
476
+				if (!$file) {
477
+				    header("Content-type: image/gif");
478
+				}
443 479
 				if ($compress != -1) {
444 480
 					@imagetruecolortopalette($this->bg, true, $compress);
445 481
 				}
@@ -456,7 +492,9 @@  discard block
 block discarded – undo
456 492
      */
457 493
     function convert2bw()
458 494
     {
459
-        if (!$this->image_validated) return false;
495
+        if (!$this->image_validated) {
496
+            return false;
497
+        }
460 498
 
461 499
         $dest_img = imagecreatetruecolor(imagesx($this->bg), imagesy($this->bg));
462 500
         /* copy ignore the transparent color
Please login to merge, or discard this patch.
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -63,6 +63,9 @@  discard block
 block discarded – undo
63 63
         return $image;
64 64
     }
65 65
 
66
+    /**
67
+     * @param string $convert_file_to
68
+     */
66 69
     public function send_image(
67 70
         $file = '',
68 71
         $compress = -1,
@@ -144,6 +147,9 @@  discard block
 block discarded – undo
144 147
     public $image;
145 148
     public $filter = Imagick::FILTER_LANCZOS;
146 149
 
150
+    /**
151
+     * @param string $path
152
+     */
147 153
     public function __construct($path)
148 154
     {
149 155
           parent::__construct($path);
@@ -191,6 +197,10 @@  discard block
 block discarded – undo
191 197
 	}
192 198
 
193 199
 	//@todo implement border logic case for Imagick
200
+
201
+	/**
202
+	 * @param integer $border
203
+	 */
194 204
 	public function resize($thumbw, $thumbh, $border, $specific_size = false)
195 205
     {
196 206
 	    if (!$this->image_validated) return false;
@@ -272,6 +282,9 @@  discard block
 block discarded – undo
272 282
 {
273 283
     public $bg;
274 284
 
285
+    /**
286
+     * @param string $path
287
+     */
275 288
     function __construct($path) {
276 289
         parent::__construct($path);
277 290
     }
@@ -329,6 +342,9 @@  discard block
 block discarded – undo
329 342
     	}
330 343
     }
331 344
 
345
+    /**
346
+     * @param integer $border
347
+     */
332 348
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
333 349
     {
334 350
         if (!$this->image_validated) return false;
Please login to merge, or discard this patch.
main/inc/lib/timeline.lib.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     );
26 26
     public $is_course_model = true;
27 27
 
28
-	public function __construct()
28
+    public function __construct()
29 29
     {
30 30
         $this->table =  Database::get_course_table(TABLE_TIMELINE);
31
-	}
31
+    }
32 32
 
33 33
     /**
34 34
      * Get the count of elements
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Displays the title + grid
54 54
      */
55
-	public function listing()
55
+    public function listing()
56 56
     {
57
-		// action links
58
-		$html = '<div class="actions">';
57
+        // action links
58
+        $html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
-		$html .= '</div>';
60
+        $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
+        $html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
64
-	}
64
+    }
65 65
 
66 66
     public function get_status_list()
67 67
     {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70'));
91 91
         //$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
92
-	    $status_list = $this->get_status_list();
92
+        $status_list = $this->get_status_list();
93 93
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
94 94
         if ($action == 'edit') {
95 95
             //$form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         // Setting the rules
175 175
         $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
176
-		return $form;
176
+        return $form;
177 177
 
178 178
     }
179 179
 
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
     public function save_item($params)
185 185
     {
186 186
         $params['c_id'] = api_get_course_int_id();
187
-	    $id = parent::save($params);
188
-	    if (!empty($id)) {
189
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
-   		}
191
-   		return $id;
187
+        $id = parent::save($params);
188
+        if (!empty($id)) {
189
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
+            }
191
+            return $id;
192 192
     }
193 193
 
194 194
     /**
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
         $params['c_id'] = api_get_course_int_id();
200 200
         $params['parent_id'] = '0';
201 201
         $params['type'] = 'default';
202
-	    $id = parent::save($params);
203
-	    if (!empty($id)) {
204
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
-   		}
206
-   		return $id;
202
+        $id = parent::save($params);
203
+        if (!empty($id)) {
204
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
+            }
206
+            return $id;
207 207
     }
208 208
 
209 209
     public function delete($id) {
210
-	    parent::delete($id);
211
-	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
210
+        parent::delete($id);
211
+        //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
212 212
     }
213 213
 
214 214
     public function get_url($id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $item['asset'] = array( 'media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250
-         );
250
+            );
251 251
 
252 252
         //Cleaning items
253 253
         unset($item['id']);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct()
29 29
     {
30
-        $this->table =  Database::get_course_table(TABLE_TIMELINE);
30
+        $this->table = Database::get_course_table(TABLE_TIMELINE);
31 31
 	}
32 32
 
33 33
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function get_all($where_conditions = array())
48 48
     {
49
-        return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'headline ASC'));
49
+        return Database::select('*', $this->table, array('where'=>$where_conditions, 'order' =>'headline ASC'));
50 50
     }
51 51
 
52 52
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		// action links
58 58
 		$html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
60
+		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
61 61
 		$html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         }
245 245
         unset($item['end_date']);
246 246
         // Assets
247
-        $item['asset'] = array( 'media'     => $item['media'],
247
+        $item['asset'] = array('media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250 250
          );
Please login to merge, or discard this patch.
main/inc/lib/urlmanager.lib.php 3 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 class UrlManager
12 12
 {
13 13
     /**
14
-    * Creates a new url access
15
-    *
16
-    * @author Julio Montoya <[email protected]>,
17
-    *
18
-    * @param	string	$url The URL of the site
19
-    * @param	string  $description The description of the site
20
-    * @param	int		$active is active or not
21
-    * @return boolean if success
22
-    */
14
+     * Creates a new url access
15
+     *
16
+     * @author Julio Montoya <[email protected]>,
17
+     *
18
+     * @param	string	$url The URL of the site
19
+     * @param	string  $description The description of the site
20
+     * @param	int		$active is active or not
21
+     * @return boolean if success
22
+     */
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Updates an URL access
40
-    * @author Julio Montoya <[email protected]>,
41
-    *
42
-    * @param	int 	$url_id The url id
43
-    * @param	string 	$url
44
-    * @param	string  $description The description of the site
45
-    * @param	int		$active is active or not
46
-    * @return 	boolean if success
47
-    */
39
+     * Updates an URL access
40
+     * @author Julio Montoya <[email protected]>,
41
+     *
42
+     * @param	int 	$url_id The url id
43
+     * @param	string 	$url
44
+     * @param	string  $description The description of the site
45
+     * @param	int		$active is active or not
46
+     * @return 	boolean if success
47
+     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
50 50
         $url_id = intval($url_id);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     /**
66
-    * Deletes an url
67
-    * @author Julio Montoya
68
-    * @param int $id url id
66
+     * Deletes an url
67
+     * @author Julio Montoya
68
+     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
71
-    * */
70
+     * @return boolean true if success
71
+     * */
72 72
     public static function delete($id)
73 73
     {
74 74
         $id = intval($id);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     /**
203
-    * Gets the inner join of access_url and the course table
204
-    *
205
-    * @author Julio Montoya
206
-    * @param int  access url id
207
-    * @return array   Database::store_result of the result
208
-    **/
203
+     * Gets the inner join of access_url and the course table
204
+     *
205
+     * @author Julio Montoya
206
+     * @param int  access url id
207
+     * @return array   Database::store_result of the result
208
+     **/
209 209
     public static function get_url_rel_course_data($access_url_id = null)
210 210
     {
211 211
         $where = '';
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
     }
363 363
 
364 364
     /**
365
-    * Checks the relationship between an URL and a User (return the num_rows)
366
-    * @author Julio Montoya
367
-    * @param int user id
368
-    * @param int url id
369
-    * @return boolean true if success
370
-    * */
365
+     * Checks the relationship between an URL and a User (return the num_rows)
366
+     * @author Julio Montoya
367
+     * @param int user id
368
+     * @param int url id
369
+     * @return boolean true if success
370
+     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
         $num = Database::num_rows($result);
378 378
 
379 379
         return $num;
380
-	}
380
+    }
381 381
 
382 382
     /**
383
-    * Checks the relationship between an URL and a Course (return the num_rows)
384
-    * @author Julio Montoya
385
-    * @param int $courseId
386
-    * @param int $urlId
387
-    * @return boolean true if success
388
-    * */
383
+     * Checks the relationship between an URL and a Course (return the num_rows)
384
+     * @author Julio Montoya
385
+     * @param int $courseId
386
+     * @param int $urlId
387
+     * @return boolean true if success
388
+     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
     /**
423
-    * Checks the relationship between an URL and a Session (return the num_rows)
424
-    * @author Julio Montoya
425
-    * @param int user id
426
-    * @param int url id
427
-    * @return boolean true if success
428
-    * */
423
+     * Checks the relationship between an URL and a Session (return the num_rows)
424
+     * @author Julio Montoya
425
+     * @param int user id
426
+     * @param int url id
427
+     * @return boolean true if success
428
+     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431 431
         $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
     }
738 738
 
739 739
     /**
740
-    * Deletes an url and user relationship
741
-    * @author Julio Montoya
742
-    * @param int user id
743
-    * @param int url id
740
+     * Deletes an url and user relationship
741
+     * @author Julio Montoya
742
+     * @param int user id
743
+     * @param int url id
744 744
      *
745
-    * @return boolean true if success
746
-    * */
745
+     * @return boolean true if success
746
+     * */
747 747
     public static function delete_url_rel_user($user_id, $url_id)
748 748
     {
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
     }
759 759
 
760 760
     /**
761
-    * Deletes an url and course relationship
762
-    * @author Julio Montoya
763
-    * @param  int  $courseId
764
-    * @param  int  $urlId
761
+     * Deletes an url and course relationship
762
+     * @author Julio Montoya
763
+     * @param  int  $courseId
764
+     * @param  int  $urlId
765 765
      *
766
-    * @return boolean true if success
767
-    * */
766
+     * @return boolean true if success
767
+     * */
768 768
     public static function delete_url_rel_course($courseId, $urlId)
769 769
     {
770 770
         $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
     }
815 815
 
816 816
     /**
817
-    * Deletes an url and session relationship
818
-    * @author Julio Montoya
819
-    * @param  char  course code
820
-    * @param  int url id
817
+     * Deletes an url and session relationship
818
+     * @author Julio Montoya
819
+     * @param  char  course code
820
+     * @param  int url id
821 821
      *
822
-    * @return boolean true if success
823
-    * */
822
+     * @return boolean true if success
823
+     * */
824 824
     public static function delete_url_rel_session($session_id, $url_id)
825 825
     {
826 826
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
Please login to merge, or discard this patch.
Doc Comments   +16 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     * @param	string	$url The URL of the site
19 19
     * @param	string  $description The description of the site
20 20
     * @param	int		$active is active or not
21
-    * @return boolean if success
21
+    * @return Doctrine\DBAL\Driver\Statement|null if success
22 22
     */
23 23
     public static function add($url, $description, $active)
24 24
     {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     * @param	string 	$url
44 44
     * @param	string  $description The description of the site
45 45
     * @param	int		$active is active or not
46
-    * @return 	boolean if success
46
+    * @return 	Doctrine\DBAL\Driver\Statement|null if success
47 47
     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     * @author Julio Montoya
387 387
     * @param int user id
388 388
     * @param int url id
389
-    * @return boolean true if success
389
+    * @return integer true if success
390 390
     * */
391 391
     public static function relation_url_user_exist($user_id, $url_id)
392 392
     {
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     * @author Julio Montoya
405 405
     * @param int $courseId
406 406
     * @param int $urlId
407
-    * @return boolean true if success
407
+    * @return integer true if success
408 408
     * */
409 409
     public static function relation_url_course_exist($courseId, $urlId)
410 410
     {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      * @author Julio Montoya
426 426
      * @param int $userGroupId
427 427
      * @param int $urlId
428
-     * @return boolean true if success
428
+     * @return integer true if success
429 429
      * */
430 430
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
431 431
     {
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     * @author Julio Montoya
446 446
     * @param int user id
447 447
     * @param int url id
448
-    * @return boolean true if success
448
+    * @return integer true if success
449 449
     * */
450 450
     public static function relation_url_session_exist($session_id, $url_id)
451 451
     {
@@ -568,6 +568,8 @@  discard block
 block discarded – undo
568 568
      * @author Julio Montoya
569 569
      * @param  array of course ids
570 570
      * @param  array of url_ids
571
+     * @param integer[] $courseCategoryList
572
+     * @param integer[] $urlList
571 573
      * @return array
572 574
      **/
573 575
     public static function addCourseCategoryListToUrl($courseCategoryList, $urlList)
@@ -598,7 +600,7 @@  discard block
 block discarded – undo
598 600
      * @author Julio Montoya
599 601
      * @param int $categoryCourseId
600 602
      * @param int $urlId
601
-     * @return boolean true if success
603
+     * @return integer true if success
602 604
      * */
603 605
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
604 606
     {
@@ -615,7 +617,7 @@  discard block
 block discarded – undo
615 617
     /**
616 618
      * @param int $userGroupId
617 619
      * @param int $urlId
618
-     * @return int
620
+     * @return string
619 621
      */
620 622
     public static function addUserGroupToUrl($userGroupId, $urlId)
621 623
     {
@@ -716,7 +718,7 @@  discard block
 block discarded – undo
716 718
      * @param int $courseId
717 719
      * @param int $url_id
718 720
      *
719
-     * @return resource
721
+     * @return boolean
720 722
      */
721 723
     public static function add_course_to_url($courseId, $url_id = 1)
722 724
     {
@@ -807,7 +809,7 @@  discard block
 block discarded – undo
807 809
     * @param  int  $courseId
808 810
     * @param  int  $urlId
809 811
      *
810
-    * @return boolean true if success
812
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
811 813
     * */
812 814
     public static function delete_url_rel_course($courseId, $urlId)
813 815
     {
@@ -825,7 +827,7 @@  discard block
 block discarded – undo
825 827
      * @param  int $userGroupId
826 828
      * @param  int $urlId
827 829
      *
828
-     * @return boolean true if success
830
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
829 831
      * */
830 832
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
831 833
     {
@@ -844,7 +846,7 @@  discard block
 block discarded – undo
844 846
      * @param  int $userGroupId
845 847
      * @param  int $urlId
846 848
      *
847
-     * @return boolean true if success
849
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
848 850
      * */
849 851
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
850 852
     {
@@ -862,8 +864,9 @@  discard block
 block discarded – undo
862 864
     * @author Julio Montoya
863 865
     * @param  char  course code
864 866
     * @param  int url id
867
+    * @param integer $url_id
865 868
      *
866
-    * @return boolean true if success
869
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
867 870
     * */
868 871
     public static function delete_url_rel_session($session_id, $url_id)
869 872
     {
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
26
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
26
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
27 27
         $sql = "INSERT INTO $table
28 28
                 SET url 	= '".Database::escape_string($url)."',
29 29
                 description = '".Database::escape_string($description)."',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id;
93 93
         Database::query($sql);
94 94
 
95
-        $sql= "DELETE FROM $table WHERE id = ".$id;
95
+        $sql = "DELETE FROM $table WHERE id = ".$id;
96 96
         Database::query($sql);
97 97
 
98 98
         return true;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function url_exist($url)
107 107
     {
108
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
108
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
109 109
         $sql = "SELECT id FROM $table
110 110
                 WHERE url = '".Database::escape_string($url)."' ";
111 111
         $res = Database::query($sql);
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
      * */
140 140
     public static function url_count()
141 141
     {
142
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
142
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
143 143
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
144 144
         $res = Database::query($sql);
145
-        $url = Database::fetch_array($res,'ASSOC');
145
+        $url = Database::fetch_array($res, 'ASSOC');
146 146
         $result = $url['count_result'];
147 147
 
148 148
         return $result;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 FROM $table
161 161
                 ORDER BY id";
162 162
         $res = Database::query($sql);
163
-        $urls = array ();
163
+        $urls = array();
164 164
         while ($url = Database::fetch_array($res)) {
165 165
             $urls[] = $url;
166 166
         }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      **/
278 278
     public static function get_url_rel_session_data($access_url_id = null)
279 279
     {
280
-        $where ='';
280
+        $where = '';
281 281
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
282 282
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
283 283
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
314 314
 
315 315
         if (!empty($access_url_id)) {
316
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
316
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
317 317
         }
318 318
 
319 319
         $sql = "SELECT id, name, access_url_id
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
     public static function relation_url_user_exist($user_id, $url_id)
392 392
     {
393 393
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
394
-        $sql= "SELECT user_id FROM $table
394
+        $sql = "SELECT user_id FROM $table
395 395
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
396 396
         $result = Database::query($sql);
397 397
         $num = Database::num_rows($result);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     public static function relation_url_course_exist($courseId, $urlId)
410 410
     {
411 411
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
412
-        $sql= "SELECT c_id FROM $table_url_rel_course
412
+        $sql = "SELECT c_id FROM $table_url_rel_course
413 413
                WHERE
414 414
                     access_url_id = ".intval($urlId)." AND
415 415
                     c_id = '".intval($courseId)."'";
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
431 431
     {
432 432
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
433
-        $sql= "SELECT usergroup_id FROM $table
433
+        $sql = "SELECT usergroup_id FROM $table
434 434
                WHERE 
435 435
                     access_url_id = ".intval($urlId)." AND
436 436
                     usergroup_id = ".intval($userGroupId);
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
     * */
450 450
     public static function relation_url_session_exist($session_id, $url_id)
451 451
     {
452
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
452
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
453 453
         $session_id = intval($session_id);
454
-        $url_id		= intval($url_id);
454
+        $url_id = intval($url_id);
455 455
         $sql = "SELECT session_id FROM $table_url_rel_session
456 456
                 WHERE
457 457
                     access_url_id = ".intval($url_id)." AND
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         if (is_array($user_list) && is_array($url_list)) {
478 478
             foreach ($url_list as $url_id) {
479 479
                 foreach ($user_list as $user_id) {
480
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
480
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
481 481
                     if ($count == 0) {
482 482
                         $sql = "INSERT INTO $table_url_rel_user
483 483
                                 SET 
@@ -505,19 +505,19 @@  discard block
 block discarded – undo
505 505
      * @param  array of url_ids
506 506
      * @return array
507 507
      **/
508
-    public static function add_courses_to_urls($course_list,$url_list)
508
+    public static function add_courses_to_urls($course_list, $url_list)
509 509
     {
510 510
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
511 511
         $result_array = array();
512 512
 
513
-        if (is_array($course_list) && is_array($url_list)){
513
+        if (is_array($course_list) && is_array($url_list)) {
514 514
             foreach ($url_list as $url_id) {
515 515
                 foreach ($course_list as $course_code) {
516 516
                     $courseInfo = api_get_course_info($course_code);
517 517
                     $courseId = $courseInfo['real_id'];
518 518
 
519 519
                     $count = self::relation_url_course_exist($courseId, $url_id);
520
-                    if ($count==0) {
520
+                    if ($count == 0) {
521 521
                         $sql = "INSERT INTO $table_url_rel_course
522 522
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
523 523
                         $result = Database::query($sql);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
604 604
     {
605 605
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
606
-        $sql= "SELECT course_category_id FROM $table
606
+        $sql = "SELECT course_category_id FROM $table
607 607
                WHERE access_url_id = ".intval($urlId)." AND
608 608
                      course_category_id = ".intval($categoryCourseId);
609 609
         $result = Database::query($sql);
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
774 774
         $result = true;
775 775
         if (!empty($user_id) && !empty($url_id)) {
776
-            $sql= "DELETE FROM $table_url_rel_user
776
+            $sql = "DELETE FROM $table_url_rel_user
777 777
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
778 778
             $result = Database::query($sql);
779 779
         }
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
794 794
         $result = true;
795 795
         if (!empty($userId)) {
796
-            $sql= "DELETE FROM $table_url_rel_user
796
+            $sql = "DELETE FROM $table_url_rel_user
797 797
                    WHERE user_id = ".intval($userId);
798 798
             Database::query($sql);
799 799
         }
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
     * */
812 812
     public static function delete_url_rel_course($courseId, $urlId)
813 813
     {
814
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
815
-        $sql= "DELETE FROM $table_url_rel_course
814
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
815
+        $sql = "DELETE FROM $table_url_rel_course
816 816
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
817 817
         $result = Database::query($sql);
818 818
 
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
831 831
     {
832 832
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
833
-        $sql= "DELETE FROM $table
833
+        $sql = "DELETE FROM $table
834 834
                WHERE usergroup_id = '".intval($userGroupId)."' AND
835 835
                      access_url_id=".intval($urlId)."  ";
836 836
         $result = Database::query($sql);
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
850 850
     {
851 851
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
852
-        $sql= "DELETE FROM $table
852
+        $sql = "DELETE FROM $table
853 853
                WHERE course_category_id = '".intval($userGroupId)."' AND
854 854
                      access_url_id=".intval($urlId)."  ";
855 855
         $result = Database::query($sql);
@@ -868,9 +868,9 @@  discard block
 block discarded – undo
868 868
     public static function delete_url_rel_session($session_id, $url_id)
869 869
     {
870 870
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
871
-        $sql= "DELETE FROM $table_url_rel_session
871
+        $sql = "DELETE FROM $table_url_rel_session
872 872
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
873
-        $result = Database::query($sql,'ASSOC');
873
+        $result = Database::query($sql, 'ASSOC');
874 874
 
875 875
         return $result;
876 876
     }
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
      * */
884 884
     public static function update_urls_rel_user($user_list, $access_url_id)
885 885
     {
886
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
886
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
887 887
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
888 888
         $result = Database::query($sql);
889 889
         $existing_users = array();
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
         $result = Database::query($sql);
938 938
 
939 939
         $existing_courses = array();
940
-        while ($row = Database::fetch_array($result)){
940
+        while ($row = Database::fetch_array($result)) {
941 941
             $existing_courses[] = $row['c_id'];
942 942
         }
943 943
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
         $result = Database::query($sql);
971 971
         $existingItems = array();
972 972
 
973
-        while ($row = Database::fetch_array($result)){
973
+        while ($row = Database::fetch_array($result)) {
974 974
             $existingItems[] = $row['usergroup_id'];
975 975
         }
976 976
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
         $result = Database::query($sql);
1004 1004
         $existingItems = array();
1005 1005
 
1006
-        while ($row = Database::fetch_array($result)){
1006
+        while ($row = Database::fetch_array($result)) {
1007 1007
             $existingItems[] = $row['course_category_id'];
1008 1008
         }
1009 1009
 
@@ -1044,13 +1044,13 @@  discard block
 block discarded – undo
1044 1044
      * */
1045 1045
     public static function update_urls_rel_session($session_list, $access_url_id)
1046 1046
     {
1047
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1047
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1048 1048
 
1049 1049
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1050 1050
         $result = Database::query($sql);
1051 1051
         $existing_sessions = array();
1052 1052
 
1053
-        while ($row = Database::fetch_array($result)){
1053
+        while ($row = Database::fetch_array($result)) {
1054 1054
             $existing_sessions[] = $row['session_id'];
1055 1055
         }
1056 1056
 
@@ -1080,13 +1080,13 @@  discard block
 block discarded – undo
1080 1080
      */
1081 1081
     public static function get_access_url_from_user($user_id)
1082 1082
     {
1083
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1084
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1083
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1084
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1085 1085
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1086 1086
                 ON (url_rel_user.access_url_id = u.id)
1087 1087
                 WHERE user_id = ".intval($user_id);
1088 1088
         $result = Database::query($sql);
1089
-        $url_list = Database::store_result($result,'ASSOC');
1089
+        $url_list = Database::store_result($result, 'ASSOC');
1090 1090
 
1091 1091
         return $url_list;
1092 1092
     }
@@ -1097,14 +1097,14 @@  discard block
 block discarded – undo
1097 1097
      */
1098 1098
     public static function get_access_url_from_course($courseId)
1099 1099
     {
1100
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1101
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1100
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1101
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1102 1102
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1103 1103
                 ON (c.access_url_id = u.id)
1104 1104
                 WHERE c_id = ".intval($courseId);
1105 1105
 
1106 1106
         $result = Database::query($sql);
1107
-        $url_list = Database::store_result($result,'ASSOC');
1107
+        $url_list = Database::store_result($result, 'ASSOC');
1108 1108
         return $url_list;
1109 1109
     }
1110 1110
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     public static function get_access_url_from_session($session_id)
1116 1116
     {
1117 1117
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1118
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1118
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1119 1119
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1120 1120
                 ON (url_rel_session.access_url_id = u.id)
1121 1121
                 WHERE session_id = ".intval($session_id);
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
      */
1132 1132
     public static function get_url_id($url)
1133 1133
     {
1134
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1134
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1135 1135
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1136 1136
         $result = Database::query($sql);
1137 1137
         $access_url_id = Database::result($result, 0, 0);
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 4 patches
Braces   +74 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2259,7 +2259,9 @@  discard block
 block discarded – undo
2259 2259
             $debug = false;
2260 2260
         }
2261 2261
 
2262
-        if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
2262
+        if ($debug) {
2263
+            echo '<h1>Tracking::get_avg_student_score</h1>';
2264
+        }
2263 2265
         $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
2264 2266
         $tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
2265 2267
 
@@ -2336,7 +2338,9 @@  discard block
 block discarded – undo
2336 2338
                             $condition_user1 AND
2337 2339
                             session_id = $session_id
2338 2340
                         GROUP BY lp_id, user_id";
2339
-                if ($debug) echo $sql;
2341
+                if ($debug) {
2342
+                    echo $sql;
2343
+                }
2340 2344
 
2341 2345
                 $rs_last_lp_view_id = Database::query($sql);
2342 2346
 
@@ -2352,7 +2356,9 @@  discard block
 block discarded – undo
2352 2356
                         $lp_view_id = $row_lp_view['id'];
2353 2357
                         $lp_id      = $row_lp_view['lp_id'];
2354 2358
                         $user_id    = $row_lp_view['user_id'];
2355
-                        if ($debug) echo '<h2>LP id '.$lp_id.'</h2>';
2359
+                        if ($debug) {
2360
+                            echo '<h2>LP id '.$lp_id.'</h2>';
2361
+                        }
2356 2362
 
2357 2363
                         if ($get_only_latest_attempt_results) {
2358 2364
                             //Getting lp_items done by the user
@@ -2409,7 +2415,9 @@  discard block
 block discarded – undo
2409 2415
                                          lp_i.c_id  = $course_id AND
2410 2416
                                          (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
2411 2417
                                       WHERE lp_view_id = $lp_view_id ";
2412
-                            if ($debug) echo $sql.'<br />';
2418
+                            if ($debug) {
2419
+                                echo $sql.'<br />';
2420
+                            }
2413 2421
                             $res_max_score = Database::query($sql);
2414 2422
 
2415 2423
                             while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
@@ -2428,7 +2436,9 @@  discard block
 block discarded – undo
2428 2436
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2429 2437
                             $score = $row_max_score['score'];
2430 2438
 
2431
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2439
+                            if ($debug) {
2440
+                                echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2441
+                            }
2432 2442
 
2433 2443
                             if ($row_max_score['item_type'] == 'sco') {
2434 2444
                                 /* Check if it is sco (easier to get max_score)
@@ -2448,7 +2458,9 @@  discard block
 block discarded – undo
2448 2458
                                 if (!empty($max_score)) {
2449 2459
                                     $lp_partial_total += $score/$max_score;
2450 2460
                                 }
2451
-                                if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2461
+                                if ($debug) {
2462
+                                    echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2463
+                                }
2452 2464
                             } else {
2453 2465
                                 // Case of a TOOL_QUIZ element
2454 2466
                                 $item_id = $row_max_score['iid'];
@@ -2470,12 +2482,16 @@  discard block
 block discarded – undo
2470 2482
                                         ORDER BY exe_date DESC
2471 2483
                                         LIMIT 1";
2472 2484
 
2473
-                                if ($debug) echo $sql .'<br />';
2485
+                                if ($debug) {
2486
+                                    echo $sql .'<br />';
2487
+                                }
2474 2488
                                 $result_last_attempt = Database::query($sql);
2475 2489
                                 $num = Database :: num_rows($result_last_attempt);
2476 2490
                                 if ($num > 0 ) {
2477 2491
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2478
-                                    if ($debug) echo $id_last_attempt.'<br />';
2492
+                                    if ($debug) {
2493
+                                        echo $id_last_attempt.'<br />';
2494
+                                    }
2479 2495
 
2480 2496
                                     // Within the last attempt number tracking, get the sum of
2481 2497
                                     // the max_scores of all questions that it was
@@ -2494,7 +2510,9 @@  discard block
 block discarded – undo
2494 2510
                                                     q.c_id = $course_id
2495 2511
                                             )
2496 2512
                                             AS t";
2497
-                                    if ($debug) echo '$sql: '.$sql.' <br />';
2513
+                                    if ($debug) {
2514
+                                        echo '$sql: '.$sql.' <br />';
2515
+                                    }
2498 2516
                                     $res_max_score_bis = Database::query($sql);
2499 2517
                                     $row_max_score_bis = Database::fetch_array($res_max_score_bis);
2500 2518
 
@@ -2504,7 +2522,9 @@  discard block
 block discarded – undo
2504 2522
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2505 2523
                                         $lp_partial_total += $score/$max_score;
2506 2524
                                     }
2507
-                                    if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2525
+                                    if ($debug) {
2526
+                                        echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2527
+                                    }
2508 2528
                                 }
2509 2529
                             }
2510 2530
 
@@ -2517,17 +2537,25 @@  discard block
 block discarded – undo
2517 2537
                                         $count_items++;
2518 2538
                                     }
2519 2539
                                 }
2520
-                                if ($debug) echo '$count_items: '.$count_items;
2540
+                                if ($debug) {
2541
+                                    echo '$count_items: '.$count_items;
2542
+                                }
2521 2543
                             }
2522 2544
                         } //end for
2523 2545
 
2524 2546
                         $score_of_scorm_calculate += $count_items ? (($lp_partial_total / $count_items) * 100) : 0;
2525 2547
 
2526
-                        if ($debug) echo '<h3>$count_items '.$count_items.'</h3>';
2527
-                        if ($debug) echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2548
+                        if ($debug) {
2549
+                            echo '<h3>$count_items '.$count_items.'</h3>';
2550
+                        }
2551
+                        if ($debug) {
2552
+                            echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2553
+                        }
2528 2554
 
2529 2555
                         $global_result += $score_of_scorm_calculate;
2530
-                        if ($debug) echo '<h3>$global_result '.$global_result.'</h3>';
2556
+                        if ($debug) {
2557
+                            echo '<h3>$global_result '.$global_result.'</h3>';
2558
+                        }
2531 2559
                     } // end while
2532 2560
                 }
2533 2561
 
@@ -2540,7 +2568,9 @@  discard block
 block discarded – undo
2540 2568
                                 c_id = $course_id AND
2541 2569
                                 (item_type = 'quiz' OR item_type = 'sco') AND
2542 2570
                                 lp_id = ".$lp_id;
2543
-                    if ($debug) echo $sql;
2571
+                    if ($debug) {
2572
+                        echo $sql;
2573
+                    }
2544 2574
                     $result_have_quiz = Database::query($sql);
2545 2575
 
2546 2576
                     if (Database::num_rows($result_have_quiz) > 0 ) {
@@ -2551,19 +2581,29 @@  discard block
 block discarded – undo
2551 2581
                     }
2552 2582
                 }
2553 2583
 
2554
-                if ($debug) echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2555
-                if ($debug) echo '<h3>Final return</h3>';
2584
+                if ($debug) {
2585
+                    echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2586
+                }
2587
+                if ($debug) {
2588
+                    echo '<h3>Final return</h3>';
2589
+                }
2556 2590
 
2557 2591
                 if ($lp_with_quiz != 0) {
2558 2592
                     if (!$return_array) {
2559 2593
                         $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2560
-                        if ($debug) var_dump($score_of_scorm_calculate);
2594
+                        if ($debug) {
2595
+                            var_dump($score_of_scorm_calculate);
2596
+                        }
2561 2597
                         if (empty($lp_ids)) {
2562
-                            if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2598
+                            if ($debug) {
2599
+                                echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2600
+                            }
2563 2601
                         }
2564 2602
                         return $score_of_scorm_calculate;
2565 2603
                     } else {
2566
-                        if ($debug) var_dump($global_result, $lp_with_quiz);
2604
+                        if ($debug) {
2605
+                            var_dump($global_result, $lp_with_quiz);
2606
+                        }
2567 2607
                         return array($global_result, $lp_with_quiz);
2568 2608
                     }
2569 2609
                 } else {
@@ -3050,11 +3090,13 @@  discard block
 block discarded – undo
3050 3090
 
3051 3091
         if (!empty ($id_session)) {
3052 3092
             $sql .= ' WHERE session_course.session_id=' . $id_session;
3053
-            if (api_is_multiple_url_enabled())
3054
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3055
-        }  else {
3056
-            if (api_is_multiple_url_enabled())
3057
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3093
+            if (api_is_multiple_url_enabled()) {
3094
+                        $sql .=  ' AND access_url_id = '.$access_url_id;
3095
+            }
3096
+        } else {
3097
+            if (api_is_multiple_url_enabled()) {
3098
+                        $sql .=  ' WHERE access_url_id = '.$access_url_id;
3099
+            }
3058 3100
         }
3059 3101
 
3060 3102
         $result = Database::query($sql);
@@ -3162,8 +3204,7 @@  discard block
 block discarded – undo
3162 3204
                 if ($session['access_start_date'] == '0000-00-00 00:00:00' || empty($session['access_start_date'])
3163 3205
                 ) {
3164 3206
                     $session['status'] = get_lang('SessionActive');
3165
-                }
3166
-                else {
3207
+                } else {
3167 3208
                     $time_start = api_strtotime($session['access_start_date'], 'UTC');
3168 3209
                     $time_end = api_strtotime($session['access_end_date'], 'UTC');
3169 3210
                     if ($time_start < time() && time() < $time_end) {
@@ -6599,8 +6640,9 @@  discard block
 block discarded – undo
6599 6640
     		if (is_array($hpresults)) {
6600 6641
     			for($i = 0; $i < sizeof($hpresults); $i++) {
6601 6642
     				$title = GetQuizName($hpresults[$i][0],'');
6602
-    				if ($title == '')
6603
-    				$title = basename($hpresults[$i][0]);
6643
+    				if ($title == '') {
6644
+    				    				$title = basename($hpresults[$i][0]);
6645
+    				}
6604 6646
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6605 6647
     				?>
6606 6648
                     <tr>
@@ -6972,8 +7014,9 @@  discard block
 block discarded – undo
6972 7014
     			for($i = 0; $i < sizeof($hpresults); $i++) {
6973 7015
     				$title = GetQuizName($hpresults[$i][0],'');
6974 7016
 
6975
-    				if ($title == '')
6976
-    				$title = basename($hpresults[$i][0]);
7017
+    				if ($title == '') {
7018
+    				    				$title = basename($hpresults[$i][0]);
7019
+    				}
6977 7020
 
6978 7021
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6979 7022
 
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1333,6 +1333,8 @@  discard block
 block discarded – undo
1333 1333
      * @param   string type of time filter: 'last_week' or 'custom'
1334 1334
      * @param   string  start date date('Y-m-d H:i:s')
1335 1335
      * @param   string  end date date('Y-m-d H:i:s')
1336
+     * @param string $start_date
1337
+     * @param string $end_date
1336 1338
      * @return timestamp $nb_seconds
1337 1339
      */
1338 1340
     public static function get_time_spent_on_the_platform(
@@ -1435,7 +1437,7 @@  discard block
 block discarded – undo
1435 1437
      * Get first connection date for a student
1436 1438
      * @param    int $student_id
1437 1439
      *
1438
-     * @return    string|bool Date format long without day or false if there are no connections
1440
+     * @return    string|false Date format long without day or false if there are no connections
1439 1441
      */
1440 1442
     public static function get_first_connection_date($student_id)
1441 1443
     {
@@ -1465,7 +1467,7 @@  discard block
 block discarded – undo
1465 1467
      * @param int $student_id
1466 1468
      * @param bool $warning_message Show a warning message (optional)
1467 1469
      * @param bool $return_timestamp True for returning results in timestamp (optional)
1468
-     * @return string|int|bool Date format long without day, false if there are no connections or
1470
+     * @return string Date format long without day, false if there are no connections or
1469 1471
      * timestamp if parameter $return_timestamp is true
1470 1472
      */
1471 1473
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
@@ -2762,6 +2764,9 @@  discard block
 block discarded – undo
2762 2764
      * @param     array         Limit average to listed lp ids
2763 2765
      * @param     int            Session id (optional), if param $session_id is
2764 2766
      * null(default) it'll return results including sessions, 0 = session is not filtered
2767
+     * @param integer $student_id
2768
+     * @param string $course_code
2769
+     * @param integer $session_id
2765 2770
      * @return     int         Total time
2766 2771
      */
2767 2772
     public static function get_time_spent_in_lp($student_id, $course_code, $lp_ids = array(), $session_id = null)
@@ -2831,6 +2836,8 @@  discard block
 block discarded – undo
2831 2836
      * @param     int|array    Student id(s)
2832 2837
      * @param     string         Course code
2833 2838
      * @param     int         Learning path id
2839
+     * @param integer $student_id
2840
+     * @param string $course_code
2834 2841
      * @return     int         Total time
2835 2842
      */
2836 2843
     public static function get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id = 0)
@@ -5504,7 +5511,7 @@  discard block
 block discarded – undo
5504 5511
 
5505 5512
     /**
5506 5513
     * @param FormValidator $form
5507
-    * @return mixed
5514
+    * @return FormValidator
5508 5515
     */
5509 5516
     public static function setUserSearchForm($form)
5510 5517
     {
@@ -6985,7 +6992,7 @@  discard block
 block discarded – undo
6985 6992
      * @param int $user_id
6986 6993
      * @param int $course_id
6987 6994
      * @param int $session_id
6988
-     * @return array
6995
+     * @return string[]
6989 6996
      */
6990 6997
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6991 6998
     {
@@ -7031,9 +7038,9 @@  discard block
 block discarded – undo
7031 7038
     /**
7032 7039
      * Displays the exercise results for a specific user in a specific course.
7033 7040
      * @param   string $view
7034
-     * @param   int $user_id    User ID
7041
+     * @param   int $userId    User ID
7035 7042
      * @param   string  $courseCode Course code
7036
-     * @return array
7043
+     * @return string[]
7037 7044
      * @todo remove globals
7038 7045
      */
7039 7046
     public function display_exercise_tracking_info($view, $userId, $courseCode)
Please login to merge, or discard this patch.
Indentation   +861 added lines, -861 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                     $extend_link = '';
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
314
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
             case 'last_30_days':
1366 1366
                 $new_date = date('Y-m-d H:i:s', strtotime('-30 day'));
1367 1367
                 $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
1368
-               break;
1368
+                break;
1369 1369
             case 'custom':
1370 1370
                 if (!empty($start_date) && !empty($end_date)) {
1371 1371
                     $start_date = Database::escape_string($start_date);
@@ -1375,10 +1375,10 @@  discard block
 block discarded – undo
1375 1375
                 break;
1376 1376
         }
1377 1377
 
1378
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1378
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1379 1379
     	        FROM '.$tbl_track_login.'
1380 1380
                 WHERE '.$userCondition.$condition_time;
1381
-    	$rs = Database::query($sql);
1381
+        $rs = Database::query($sql);
1382 1382
         $row = Database::fetch_array($rs, 'ASSOC');
1383 1383
         $diff = $row['diff'];
1384 1384
 
@@ -1400,18 +1400,18 @@  discard block
 block discarded – undo
1400 1400
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1401 1401
     {
1402 1402
         $courseId = intval($courseId);
1403
-    	$session_id  = intval($session_id);
1404
-
1405
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1406
-    	if (is_array($user_id)) {
1407
-    	    $user_id = array_map('intval', $user_id);
1408
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1409
-    	} else {
1410
-    		$user_id = intval($user_id);
1411
-    		$condition_user = " AND user_id = $user_id ";
1412
-    	}
1413
-
1414
-    	$sql = "SELECT
1403
+        $session_id  = intval($session_id);
1404
+
1405
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1406
+        if (is_array($user_id)) {
1407
+            $user_id = array_map('intval', $user_id);
1408
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1409
+        } else {
1410
+            $user_id = intval($user_id);
1411
+            $condition_user = " AND user_id = $user_id ";
1412
+        }
1413
+
1414
+        $sql = "SELECT
1415 1415
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1416 1416
                 FROM $tbl_track_course
1417 1417
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1426,9 +1426,9 @@  discard block
 block discarded – undo
1426 1426
 
1427 1427
         $sql .= $condition_user;
1428 1428
         $rs = Database::query($sql);
1429
-    	$row = Database::fetch_array($rs);
1429
+        $row = Database::fetch_array($rs);
1430 1430
 
1431
-    	return $row['nb_seconds'];
1431
+        return $row['nb_seconds'];
1432 1432
     }
1433 1433
 
1434 1434
     /**
@@ -1439,25 +1439,25 @@  discard block
 block discarded – undo
1439 1439
      */
1440 1440
     public static function get_first_connection_date($student_id)
1441 1441
     {
1442
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1443
-    	$sql = 'SELECT login_date
1442
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1443
+        $sql = 'SELECT login_date
1444 1444
     	        FROM ' . $tbl_track_login . '
1445 1445
                 WHERE login_user_id = ' . intval($student_id) . '
1446 1446
                 ORDER BY login_date ASC
1447 1447
                 LIMIT 0,1';
1448 1448
 
1449
-    	$rs = Database::query($sql);
1450
-    	if (Database::num_rows($rs)>0) {
1451
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1449
+        $rs = Database::query($sql);
1450
+        if (Database::num_rows($rs)>0) {
1451
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1452 1452
                 return api_convert_and_format_date(
1453 1453
                     $first_login_date,
1454 1454
                     DATE_FORMAT_SHORT,
1455 1455
                     date_default_timezone_get()
1456 1456
                 );
1457
-    		}
1458
-    	}
1457
+            }
1458
+        }
1459 1459
 
1460
-    	return false;
1460
+        return false;
1461 1461
     }
1462 1462
 
1463 1463
     /**
@@ -1470,38 +1470,38 @@  discard block
 block discarded – undo
1470 1470
      */
1471 1471
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1472 1472
     {
1473
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1474
-    	$sql = 'SELECT login_date
1473
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1474
+        $sql = 'SELECT login_date
1475 1475
     	        FROM ' . $table . '
1476 1476
                 WHERE login_user_id = ' . intval($student_id) . '
1477 1477
                 ORDER BY login_date
1478 1478
                 DESC LIMIT 0,1';
1479 1479
 
1480
-    	$rs = Database::query($sql);
1481
-    	if (Database::num_rows($rs) > 0) {
1482
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1483
-    			$last_login_date = api_get_local_time($last_login_date);
1484
-    			if ($return_timestamp) {
1485
-    				return api_strtotime($last_login_date,'UTC');
1486
-    			} else {
1487
-    				if (!$warning_message) {
1488
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1489
-    				} else {
1490
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1491
-    					$currentTimestamp = time();
1492
-
1493
-    					//If the last connection is > than 7 days, the text is red
1494
-    					//345600 = 7 days in seconds
1495
-    					if ($currentTimestamp - $timestamp > 604800) {
1496
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1497
-    					} else {
1498
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1499
-    					}
1500
-    				}
1501
-    			}
1502
-    		}
1503
-    	}
1504
-    	return false;
1480
+        $rs = Database::query($sql);
1481
+        if (Database::num_rows($rs) > 0) {
1482
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1483
+                $last_login_date = api_get_local_time($last_login_date);
1484
+                if ($return_timestamp) {
1485
+                    return api_strtotime($last_login_date,'UTC');
1486
+                } else {
1487
+                    if (!$warning_message) {
1488
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1489
+                    } else {
1490
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1491
+                        $currentTimestamp = time();
1492
+
1493
+                        //If the last connection is > than 7 days, the text is red
1494
+                        //345600 = 7 days in seconds
1495
+                        if ($currentTimestamp - $timestamp > 604800) {
1496
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1497
+                        } else {
1498
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1499
+                        }
1500
+                    }
1501
+                }
1502
+            }
1503
+        }
1504
+        return false;
1505 1505
     }
1506 1506
 
1507 1507
     /**
@@ -1555,30 +1555,30 @@  discard block
 block discarded – undo
1555 1555
         $session_id = 0,
1556 1556
         $convert_date = true
1557 1557
     ) {
1558
-    	$student_id  = intval($student_id);
1558
+        $student_id  = intval($student_id);
1559 1559
         $courseId = intval($courseId);
1560
-    	$session_id  = intval($session_id);
1560
+        $session_id  = intval($session_id);
1561 1561
 
1562
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1563
-    	$sql = 'SELECT login_course_date
1562
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1563
+        $sql = 'SELECT login_course_date
1564 1564
     	        FROM '.$tbl_track_login.'
1565 1565
                 WHERE
1566 1566
                     user_id = '.$student_id.' AND
1567 1567
                     c_id = '.$courseId.' AND
1568 1568
                     session_id = '.$session_id.'
1569 1569
                 ORDER BY login_course_date ASC LIMIT 0,1';
1570
-    	$rs = Database::query($sql);
1571
-    	if (Database::num_rows($rs) > 0) {
1572
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1573
-    			if ($convert_date) {
1574
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1575
-    			} else {
1576
-    				return $first_login_date;
1577
-    			}
1578
-    		}
1579
-    	}
1580
-
1581
-    	return false;
1570
+        $rs = Database::query($sql);
1571
+        if (Database::num_rows($rs) > 0) {
1572
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1573
+                if ($convert_date) {
1574
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1575
+                } else {
1576
+                    return $first_login_date;
1577
+                }
1578
+            }
1579
+        }
1580
+
1581
+        return false;
1582 1582
     }
1583 1583
 
1584 1584
     /**
@@ -1594,13 +1594,13 @@  discard block
 block discarded – undo
1594 1594
         $session_id = 0,
1595 1595
         $convert_date = true
1596 1596
     ) {
1597
-    	// protect data
1598
-    	$student_id  = intval($student_id);
1597
+        // protect data
1598
+        $student_id  = intval($student_id);
1599 1599
         $courseId = $courseInfo['real_id'];
1600
-    	$session_id  = intval($session_id);
1600
+        $session_id  = intval($session_id);
1601 1601
 
1602
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1603
-    	$sql = 'SELECT access_date
1602
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1603
+        $sql = 'SELECT access_date
1604 1604
                 FROM '.$tbl_track_e_access.'
1605 1605
                 WHERE   access_user_id = '.$student_id.' AND
1606 1606
                         c_id = "'.$courseId.'" AND
@@ -1608,39 +1608,39 @@  discard block
 block discarded – undo
1608 1608
                 ORDER BY access_date DESC
1609 1609
                 LIMIT 0,1';
1610 1610
 
1611
-    	$rs = Database::query($sql);
1612
-    	if (Database::num_rows($rs) > 0) {
1613
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1611
+        $rs = Database::query($sql);
1612
+        if (Database::num_rows($rs) > 0) {
1613
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1614 1614
                 if (empty($last_login_date)) {
1615 1615
                     return false;
1616 1616
                 }
1617 1617
                 //see #5736
1618 1618
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1619
-    			$now = time();
1620
-    			//If the last connection is > than 7 days, the text is red
1621
-    			//345600 = 7 days in seconds
1622
-    			if ($now - $last_login_date_timestamp > 604800) {
1623
-    				if ($convert_date) {
1619
+                $now = time();
1620
+                //If the last connection is > than 7 days, the text is red
1621
+                //345600 = 7 days in seconds
1622
+                if ($now - $last_login_date_timestamp > 604800) {
1623
+                    if ($convert_date) {
1624 1624
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1625 1625
                         $icon = api_is_allowed_to_edit() ?
1626 1626
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1627 1627
                               '.Display::return_icon('messagebox_warning.gif').'
1628 1628
                              </a>'
1629 1629
                             : null;
1630
-    					return $icon. Display::label($last_login_date, 'warning');
1631
-    				} else {
1632
-    					return $last_login_date;
1633
-    				}
1634
-    			} else {
1635
-    				if ($convert_date) {
1636
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1637
-    				} else {
1638
-    					return $last_login_date;
1639
-    				}
1640
-    			}
1641
-    		}
1642
-    	}
1643
-    	return false;
1630
+                        return $icon. Display::label($last_login_date, 'warning');
1631
+                    } else {
1632
+                        return $last_login_date;
1633
+                    }
1634
+                } else {
1635
+                    if ($convert_date) {
1636
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1637
+                    } else {
1638
+                        return $last_login_date;
1639
+                    }
1640
+                }
1641
+            }
1642
+        }
1643
+        return false;
1644 1644
     }
1645 1645
 
1646 1646
     /**
@@ -1653,36 +1653,36 @@  discard block
 block discarded – undo
1653 1653
      */
1654 1654
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1655 1655
     {
1656
-    	if ($start < 0) {
1657
-    		$start = 0;
1658
-    	}
1659
-    	if (!isset($stop) or ($stop < 0)) {
1660
-    		$stop = api_get_utc_datetime();
1661
-    	}
1656
+        if ($start < 0) {
1657
+            $start = 0;
1658
+        }
1659
+        if (!isset($stop) or ($stop < 0)) {
1660
+            $stop = api_get_utc_datetime();
1661
+        }
1662 1662
 
1663 1663
         $start = Database::escape_string($start);
1664 1664
         $stop = Database::escape_string($stop);
1665 1665
 
1666
-    	$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1666
+        $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1667 1667
 
1668 1668
         $courseId = intval($courseId);
1669
-    	$session_id  = intval($session_id);
1670
-    	$count = 0;
1669
+        $session_id  = intval($session_id);
1670
+        $count = 0;
1671 1671
 
1672
-    	$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1673
-    	$sql = "SELECT count(*) as count_connections
1672
+        $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1673
+        $sql = "SELECT count(*) as count_connections
1674 1674
                 FROM $tbl_track_e_course_access
1675 1675
                 WHERE
1676 1676
                     c_id = $courseId AND
1677 1677
                     session_id = $session_id
1678 1678
                     $month_filter";
1679
-    	$rs = Database::query($sql);
1680
-    	if (Database::num_rows($rs)>0) {
1681
-    		$row = Database::fetch_object($rs);
1682
-    		$count = $row->count_connections;
1683
-    	}
1679
+        $rs = Database::query($sql);
1680
+        if (Database::num_rows($rs)>0) {
1681
+            $row = Database::fetch_object($rs);
1682
+            $count = $row->count_connections;
1683
+        }
1684 1684
 
1685
-    	return $count;
1685
+        return $count;
1686 1686
     }
1687 1687
 
1688 1688
     /**
@@ -1693,25 +1693,25 @@  discard block
 block discarded – undo
1693 1693
      */
1694 1694
     public static function count_course_per_student($user_id, $include_sessions = true)
1695 1695
     {
1696
-    	$user_id = intval($user_id);
1697
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1698
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1696
+        $user_id = intval($user_id);
1697
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1698
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1699 1699
 
1700
-    	$sql = 'SELECT DISTINCT c_id
1700
+        $sql = 'SELECT DISTINCT c_id
1701 1701
                 FROM ' . $tbl_course_rel_user . '
1702 1702
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1703
-    	$rs = Database::query($sql);
1704
-    	$nb_courses = Database::num_rows($rs);
1703
+        $rs = Database::query($sql);
1704
+        $nb_courses = Database::num_rows($rs);
1705 1705
 
1706
-    	if ($include_sessions) {
1707
-    		$sql = 'SELECT DISTINCT c_id
1706
+        if ($include_sessions) {
1707
+            $sql = 'SELECT DISTINCT c_id
1708 1708
                     FROM ' . $tbl_session_course_rel_user . '
1709 1709
                     WHERE user_id = ' . $user_id;
1710
-    		$rs = Database::query($sql);
1711
-    		$nb_courses += Database::num_rows($rs);
1712
-    	}
1710
+            $rs = Database::query($sql);
1711
+            $nb_courses += Database::num_rows($rs);
1712
+        }
1713 1713
 
1714
-    	return $nb_courses;
1714
+        return $nb_courses;
1715 1715
     }
1716 1716
 
1717 1717
     /**
@@ -1742,25 +1742,25 @@  discard block
 block discarded – undo
1742 1742
         $into_lp = 0
1743 1743
     ) {
1744 1744
         $course_code = Database::escape_string($course_code);
1745
-    	$course_info = api_get_course_info($course_code);
1746
-    	if (!empty($course_info)) {
1747
-    		// table definition
1748
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1749
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1750
-
1751
-    		// Compose a filter based on optional exercise given
1752
-    		$condition_quiz = "";
1753
-    		if (!empty($exercise_id)) {
1754
-    			$exercise_id = intval($exercise_id);
1755
-    			$condition_quiz =" AND id = $exercise_id ";
1756
-    		}
1757
-
1758
-    		// Compose a filter based on optional session id given
1759
-    		$condition_session = "";
1760
-    		if (isset($session_id)) {
1761
-    			$session_id = intval($session_id);
1762
-    			$condition_session = " AND session_id = $session_id ";
1763
-    		}
1745
+        $course_info = api_get_course_info($course_code);
1746
+        if (!empty($course_info)) {
1747
+            // table definition
1748
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1749
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1750
+
1751
+            // Compose a filter based on optional exercise given
1752
+            $condition_quiz = "";
1753
+            if (!empty($exercise_id)) {
1754
+                $exercise_id = intval($exercise_id);
1755
+                $condition_quiz =" AND id = $exercise_id ";
1756
+            }
1757
+
1758
+            // Compose a filter based on optional session id given
1759
+            $condition_session = "";
1760
+            if (isset($session_id)) {
1761
+                $session_id = intval($session_id);
1762
+                $condition_session = " AND session_id = $session_id ";
1763
+            }
1764 1764
             if ($active_filter == 1) {
1765 1765
                 $condition_active = 'AND active <> -1';
1766 1766
             } elseif ($active_filter == 0) {
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
                 $select_lp_id = ', orig_lp_id as lp_id ';
1777 1777
             }
1778 1778
 
1779
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1779
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1780 1780
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1781 1781
             $count_quiz = 0;
1782 1782
             $countQuizResult = Database::query($sql);
@@ -1784,21 +1784,21 @@  discard block
 block discarded – undo
1784 1784
                 $count_quiz = Database::fetch_row($countQuizResult);
1785 1785
             }
1786 1786
 
1787
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1788
-    			if (is_array($student_id)) {
1787
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1788
+                if (is_array($student_id)) {
1789 1789
                     $student_id = array_map('intval', $student_id);
1790
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1791
-    			} else {
1790
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1791
+                } else {
1792 1792
                     $student_id = intval($student_id);
1793
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1794
-    			}
1793
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1794
+                }
1795 1795
 
1796
-    			if (empty($exercise_id)) {
1797
-    				$sql = "SELECT id FROM $tbl_course_quiz
1796
+                if (empty($exercise_id)) {
1797
+                    $sql = "SELECT id FROM $tbl_course_quiz
1798 1798
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1799 1799
                     $result = Database::query($sql);
1800 1800
                     $exercise_list = array();
1801
-    				$exercise_id = null;
1801
+                    $exercise_id = null;
1802 1802
                     if (!empty($result) && Database::num_rows($result)) {
1803 1803
                         while ($row = Database::fetch_array($result)) {
1804 1804
                             $exercise_list[] = $row['id'];
@@ -1807,11 +1807,11 @@  discard block
 block discarded – undo
1807 1807
                     if (!empty($exercise_list)) {
1808 1808
                         $exercise_id = implode("','",$exercise_list);
1809 1809
                     }
1810
-    			}
1810
+                }
1811 1811
 
1812
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1812
+                $count_quiz = Database::fetch_row(Database::query($sql));
1813 1813
 
1814
-    			$sql = "SELECT
1814
+                $sql = "SELECT
1815 1815
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1816 1816
     			        COUNT(*) as num_attempts
1817 1817
     			        $select_lp_id
@@ -1825,20 +1825,20 @@  discard block
 block discarded – undo
1825 1825
                             $condition_into_lp
1826 1826
                         ORDER BY exe_date DESC";
1827 1827
 
1828
-    			$res = Database::query($sql);
1829
-    			$row = Database::fetch_array($res);
1830
-    			$quiz_avg_score = null;
1828
+                $res = Database::query($sql);
1829
+                $row = Database::fetch_array($res);
1830
+                $quiz_avg_score = null;
1831 1831
 
1832
-    			if (!empty($row['avg_score'])) {
1833
-    				$quiz_avg_score = round($row['avg_score'],2);
1834
-    			}
1832
+                if (!empty($row['avg_score'])) {
1833
+                    $quiz_avg_score = round($row['avg_score'],2);
1834
+                }
1835 1835
 
1836
-    			if(!empty($row['num_attempts'])) {
1837
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1838
-    			}
1839
-    			if (is_array($student_id)) {
1840
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1841
-    			}
1836
+                if(!empty($row['num_attempts'])) {
1837
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1838
+                }
1839
+                if (is_array($student_id)) {
1840
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1841
+                }
1842 1842
                 if ($into_lp == 0) {
1843 1843
                     return $quiz_avg_score;
1844 1844
                 } else {
@@ -1861,9 +1861,9 @@  discard block
 block discarded – undo
1861 1861
                         return array($quiz_avg_score, null);
1862 1862
                     }
1863 1863
                 }
1864
-    		}
1865
-    	}
1866
-    	return null;
1864
+            }
1865
+        }
1866
+        return null;
1867 1867
     }
1868 1868
 
1869 1869
     /**
@@ -1896,15 +1896,15 @@  discard block
 block discarded – undo
1896 1896
         $find_all_lp = 0
1897 1897
     ) {
1898 1898
         $courseId = intval($courseId);
1899
-    	$student_id  = intval($student_id);
1900
-    	$exercise_id = intval($exercise_id);
1901
-    	$session_id  = intval($session_id);
1899
+        $student_id  = intval($student_id);
1900
+        $exercise_id = intval($exercise_id);
1901
+        $session_id  = intval($session_id);
1902 1902
 
1903
-    	$lp_id = intval($lp_id);
1903
+        $lp_id = intval($lp_id);
1904 1904
         $lp_item_id = intval($lp_item_id);
1905
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1905
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1906 1906
 
1907
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1907
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1908 1908
                 WHERE  ex.c_id = $courseId
1909 1909
                 AND ex.exe_exo_id = $exercise_id
1910 1910
                 AND status = ''
@@ -1919,11 +1919,11 @@  discard block
 block discarded – undo
1919 1919
                 AND orig_lp_item_id = $lp_item_id";
1920 1920
         }
1921 1921
 
1922
-    	$rs = Database::query($sql);
1923
-    	$row = Database::fetch_row($rs);
1924
-    	$count_attempts = $row[0];
1922
+        $rs = Database::query($sql);
1923
+        $row = Database::fetch_row($rs);
1924
+        $count_attempts = $row[0];
1925 1925
 
1926
-    	return $count_attempts;
1926
+        return $count_attempts;
1927 1927
     }
1928 1928
 
1929 1929
     /**
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
      * @param int    $user_id
1934 1934
      * @param int    $courseId
1935 1935
      * @param int    $session_id
1936
-    */
1936
+     */
1937 1937
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1938 1938
     {
1939 1939
         $courseId = intval($courseId);
@@ -3597,8 +3597,8 @@  discard block
 block discarded – undo
3597 3597
 
3598 3598
         $condition_session = '';
3599 3599
         if (isset($session_id)) {
3600
-             $session_id = intval($session_id);
3601
-             $condition_session = ' AND f.session_id = '. $session_id;
3600
+                $session_id = intval($session_id);
3601
+                $condition_session = ' AND f.session_id = '. $session_id;
3602 3602
         }
3603 3603
 
3604 3604
         $groupId = intval($groupId);
@@ -5503,9 +5503,9 @@  discard block
 block discarded – undo
5503 5503
     }
5504 5504
 
5505 5505
     /**
5506
-    * @param FormValidator $form
5507
-    * @return mixed
5508
-    */
5506
+     * @param FormValidator $form
5507
+     * @return mixed
5508
+     */
5509 5509
     public static function setUserSearchForm($form)
5510 5510
     {
5511 5511
         global $_configuration;
@@ -5785,26 +5785,26 @@  discard block
 block discarded – undo
5785 5785
         $session_id = api_get_session_id();
5786 5786
         $course_id = api_get_course_int_id();
5787 5787
 
5788
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5789
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5788
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5789
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5790 5790
 
5791
-    	$sql = "SELECT count(tool) AS total_number_of_items
5791
+        $sql = "SELECT count(tool) AS total_number_of_items
5792 5792
     	        FROM $table_item_property track_resource, $table_user user
5793 5793
     	        WHERE
5794 5794
                     track_resource.c_id = $course_id AND
5795 5795
                     track_resource.insert_user_id = user.user_id AND
5796 5796
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5797 5797
 
5798
-    	if (isset($_GET['keyword'])) {
5799
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5800
-    		$sql .= " AND (
5798
+        if (isset($_GET['keyword'])) {
5799
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5800
+            $sql .= " AND (
5801 5801
     		            user.username LIKE '%".$keyword."%' OR
5802 5802
     		            lastedit_type LIKE '%".$keyword."%' OR
5803 5803
     		            tool LIKE '%".$keyword."%'
5804 5804
                     )";
5805
-    	}
5805
+        }
5806 5806
 
5807
-    	$sql .= " AND tool IN (
5807
+        $sql .= " AND tool IN (
5808 5808
     	            'document',
5809 5809
     	            'learnpath',
5810 5810
     	            'quiz',
@@ -5816,10 +5816,10 @@  discard block
 block discarded – undo
5816 5816
     	            'thematic_advance',
5817 5817
     	            'thematic_plan'
5818 5818
                 )";
5819
-    	$res = Database::query($sql);
5820
-    	$obj = Database::fetch_object($res);
5819
+        $res = Database::query($sql);
5820
+        $obj = Database::fetch_object($res);
5821 5821
 
5822
-    	return $obj->total_number_of_items;
5822
+        return $obj->total_number_of_items;
5823 5823
     }
5824 5824
 
5825 5825
     /**
@@ -5834,12 +5834,12 @@  discard block
 block discarded – undo
5834 5834
         $session_id = api_get_session_id();
5835 5835
         $course_id = api_get_course_int_id();
5836 5836
 
5837
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5838
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5839
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5840
-    	$session_id = intval($session_id);
5837
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5838
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5839
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5840
+        $session_id = intval($session_id);
5841 5841
 
5842
-    	$sql = "SELECT
5842
+        $sql = "SELECT
5843 5843
                     tool as col0,
5844 5844
                     lastedit_type as col1,
5845 5845
                     ref as ref,
@@ -5853,16 +5853,16 @@  discard block
 block discarded – undo
5853 5853
                   track_resource.insert_user_id = user.user_id AND
5854 5854
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5855 5855
 
5856
-    	if (isset($_GET['keyword'])) {
5857
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5858
-    		$sql .= " AND (
5856
+        if (isset($_GET['keyword'])) {
5857
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5858
+            $sql .= " AND (
5859 5859
     		            user.username LIKE '%".$keyword."%' OR
5860 5860
     		            lastedit_type LIKE '%".$keyword."%' OR
5861 5861
     		            tool LIKE '%".$keyword."%'
5862 5862
                      ) ";
5863
-    	}
5863
+        }
5864 5864
 
5865
-    	$sql .= " AND tool IN (
5865
+        $sql .= " AND tool IN (
5866 5866
     	            'document',
5867 5867
     	            'learnpath',
5868 5868
     	            'quiz',
@@ -5875,41 +5875,41 @@  discard block
 block discarded – undo
5875 5875
     	            'thematic_plan'
5876 5876
                 )";
5877 5877
 
5878
-    	if ($column == 0) {
5879
-    		$column = '0';
5880
-    	}
5881
-    	if ($column != '' && $direction != '') {
5882
-    		if ($column != 2 && $column != 4) {
5883
-    			$sql .= " ORDER BY col$column $direction";
5884
-    		}
5885
-    	} else {
5886
-    		$sql .= " ORDER BY col5 DESC ";
5887
-    	}
5878
+        if ($column == 0) {
5879
+            $column = '0';
5880
+        }
5881
+        if ($column != '' && $direction != '') {
5882
+            if ($column != 2 && $column != 4) {
5883
+                $sql .= " ORDER BY col$column $direction";
5884
+            }
5885
+        } else {
5886
+            $sql .= " ORDER BY col5 DESC ";
5887
+        }
5888 5888
 
5889 5889
         $from = intval($from);
5890 5890
         $number_of_items = intval($number_of_items);
5891 5891
 
5892
-    	$sql .= " LIMIT $from, $number_of_items ";
5893
-
5894
-    	$res = Database::query($sql);
5895
-    	$resources = array();
5896
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5897
-    	while ($row = Database::fetch_array($res)) {
5898
-    		$ref = $row['ref'];
5899
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5900
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5901
-
5902
-    		$id = $table_name['id_tool'];
5903
-    		$recorset = false;
5892
+        $sql .= " LIMIT $from, $number_of_items ";
5904 5893
 
5905
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5906
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5907
-    			$sql = "SELECT thematic_id FROM $table_tool
5894
+        $res = Database::query($sql);
5895
+        $resources = array();
5896
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5897
+        while ($row = Database::fetch_array($res)) {
5898
+            $ref = $row['ref'];
5899
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5900
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5901
+
5902
+            $id = $table_name['id_tool'];
5903
+            $recorset = false;
5904
+
5905
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5906
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5907
+                $sql = "SELECT thematic_id FROM $table_tool
5908 5908
     			        WHERE c_id = $course_id AND id = $ref";
5909
-    			$rs_thematic  = Database::query($sql);
5910
-    			if (Database::num_rows($rs_thematic)) {
5911
-    				$row_thematic = Database::fetch_array($rs_thematic);
5912
-    				$thematic_id = $row_thematic['thematic_id'];
5909
+                $rs_thematic  = Database::query($sql);
5910
+                if (Database::num_rows($rs_thematic)) {
5911
+                    $row_thematic = Database::fetch_array($rs_thematic);
5912
+                    $thematic_id = $row_thematic['thematic_id'];
5913 5913
 
5914 5914
                     $sql = "SELECT session.id, session.name, user.username
5915 5915
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5918,9 +5918,9 @@  discard block
 block discarded – undo
5918 5918
                               t.session_id = session.id AND
5919 5919
                               session.id_coach = user.user_id AND
5920 5920
                               t.id = $thematic_id";
5921
-    				$recorset = Database::query($sql);
5922
-    			}
5923
-    		} else {
5921
+                    $recorset = Database::query($sql);
5922
+                }
5923
+            } else {
5924 5924
                 $sql = "SELECT session.id, session.name, user.username
5925 5925
                           FROM $table_tool tool, $table_session session, $table_user user
5926 5926
     			          WHERE
@@ -5928,127 +5928,127 @@  discard block
 block discarded – undo
5928 5928
     			              tool.session_id = session.id AND
5929 5929
     			              session.id_coach = user.user_id AND
5930 5930
     			              tool.$id = $ref";
5931
-    			$recorset = Database::query($sql);
5932
-    		}
5933
-
5934
-    		if (!empty($recorset)) {
5935
-    			$obj = Database::fetch_object($recorset);
5936
-
5937
-    			$name_session = '';
5938
-    			$coach_name = '';
5939
-    			if (!empty($obj)) {
5940
-    				$name_session = $obj->name;
5941
-    				$coach_name   = $obj->username;
5942
-    			}
5943
-
5944
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5945
-    			$row[0] = '';
5946
-    			if ($row['col6'] != 2) {
5947
-    				if (in_array($row['col0'], $thematic_tools)) {
5948
-
5949
-    					$exp_thematic_tool = explode('_', $row['col0']);
5950
-    					$thematic_tool_title = '';
5951
-    					if (is_array($exp_thematic_tool)) {
5952
-    						foreach ($exp_thematic_tool as $exp) {
5953
-    							$thematic_tool_title .= api_ucfirst($exp);
5954
-    						}
5955
-    					} else {
5956
-    						$thematic_tool_title = api_ucfirst($row['col0']);
5957
-    					}
5958
-
5959
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5960
-    				} else {
5961
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5962
-    				}
5963
-    			} else {
5964
-    				$row[0] = api_ucfirst($row['col0']);
5965
-    			}
5966
-    			$row[1] = get_lang($row[1]);
5967
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5968
-    			$row[5] = '';
5969
-    			//@todo Improve this code please
5970
-    			switch ($table_name['table_name']) {
5971
-    				case 'document' :
5972
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5931
+                $recorset = Database::query($sql);
5932
+            }
5933
+
5934
+            if (!empty($recorset)) {
5935
+                $obj = Database::fetch_object($recorset);
5936
+
5937
+                $name_session = '';
5938
+                $coach_name = '';
5939
+                if (!empty($obj)) {
5940
+                    $name_session = $obj->name;
5941
+                    $coach_name   = $obj->username;
5942
+                }
5943
+
5944
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5945
+                $row[0] = '';
5946
+                if ($row['col6'] != 2) {
5947
+                    if (in_array($row['col0'], $thematic_tools)) {
5948
+
5949
+                        $exp_thematic_tool = explode('_', $row['col0']);
5950
+                        $thematic_tool_title = '';
5951
+                        if (is_array($exp_thematic_tool)) {
5952
+                            foreach ($exp_thematic_tool as $exp) {
5953
+                                $thematic_tool_title .= api_ucfirst($exp);
5954
+                            }
5955
+                        } else {
5956
+                            $thematic_tool_title = api_ucfirst($row['col0']);
5957
+                        }
5958
+
5959
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5960
+                    } else {
5961
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5962
+                    }
5963
+                } else {
5964
+                    $row[0] = api_ucfirst($row['col0']);
5965
+                }
5966
+                $row[1] = get_lang($row[1]);
5967
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5968
+                $row[5] = '';
5969
+                //@todo Improve this code please
5970
+                switch ($table_name['table_name']) {
5971
+                    case 'document' :
5972
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
5973 5973
                                 WHERE c_id = $course_id AND id = $ref";
5974
-    					$rs_document = Database::query($sql);
5975
-    					$obj_document = Database::fetch_object($rs_document);
5976
-    					$row[5] = $obj_document->title;
5974
+                        $rs_document = Database::query($sql);
5975
+                        $obj_document = Database::fetch_object($rs_document);
5976
+                        $row[5] = $obj_document->title;
5977 5977
 
5978
-    					break;
5979
-    				case 'announcement':
5978
+                        break;
5979
+                    case 'announcement':
5980 5980
                         $sql = "SELECT title FROM $table_tool
5981 5981
                                 WHERE c_id = $course_id AND id = $ref";
5982
-    					$rs_document = Database::query($sql);
5983
-    					$obj_document = Database::fetch_object($rs_document);
5982
+                        $rs_document = Database::query($sql);
5983
+                        $obj_document = Database::fetch_object($rs_document);
5984 5984
                         if ($obj_document) {
5985 5985
                             $row[5] = $obj_document->title;
5986 5986
                         }
5987
-    					break;
5988
-    				case 'glossary':
5987
+                        break;
5988
+                    case 'glossary':
5989 5989
                         $sql = "SELECT name FROM $table_tool
5990 5990
     					        WHERE c_id = $course_id AND glossary_id = $ref";
5991
-    					$rs_document = Database::query($sql);
5992
-    					$obj_document = Database::fetch_object($rs_document);
5991
+                        $rs_document = Database::query($sql);
5992
+                        $obj_document = Database::fetch_object($rs_document);
5993 5993
                         if ($obj_document) {
5994 5994
                             $row[5] = $obj_document->name;
5995 5995
                         }
5996
-    					break;
5997
-    				case 'lp':
5996
+                        break;
5997
+                    case 'lp':
5998 5998
                         $sql = "SELECT name
5999 5999
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6000
-    					$rs_document = Database::query($sql);
6001
-    					$obj_document = Database::fetch_object($rs_document);
6002
-    					$row[5] = $obj_document->name;
6003
-    					break;
6004
-    				case 'quiz':
6000
+                        $rs_document = Database::query($sql);
6001
+                        $obj_document = Database::fetch_object($rs_document);
6002
+                        $row[5] = $obj_document->name;
6003
+                        break;
6004
+                    case 'quiz':
6005 6005
                         $sql = "SELECT title FROM $table_tool
6006 6006
                                 WHERE c_id = $course_id AND id = $ref";
6007
-    					$rs_document = Database::query($sql);
6008
-    					$obj_document = Database::fetch_object($rs_document);
6007
+                        $rs_document = Database::query($sql);
6008
+                        $obj_document = Database::fetch_object($rs_document);
6009 6009
                         if ($obj_document) {
6010 6010
                             $row[5] = $obj_document->title;
6011 6011
                         }
6012
-    					break;
6013
-    				case 'course_description':
6012
+                        break;
6013
+                    case 'course_description':
6014 6014
                         $sql = "SELECT title FROM $table_tool
6015 6015
                                 WHERE c_id = $course_id AND id = $ref";
6016
-    					$rs_document = Database::query($sql);
6017
-    					$obj_document = Database::fetch_object($rs_document);
6016
+                        $rs_document = Database::query($sql);
6017
+                        $obj_document = Database::fetch_object($rs_document);
6018 6018
                         if ($obj_document) {
6019 6019
                             $row[5] = $obj_document->title;
6020 6020
                         }
6021
-    					break;
6022
-    				case 'thematic':
6023
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6024
-    					if (Database::num_rows($rs) > 0) {
6025
-    						$obj = Database::fetch_object($rs);
6026
-    						$row[5] = $obj->title;
6027
-    					}
6028
-    					break;
6029
-    				case 'thematic_advance':
6030
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6031
-    					if (Database::num_rows($rs) > 0) {
6032
-    						$obj = Database::fetch_object($rs);
6033
-    						$row[5] = $obj->content;
6034
-    					}
6035
-    					break;
6036
-    				case 'thematic_plan':
6037
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6038
-    					if (Database::num_rows($rs) > 0) {
6039
-    						$obj = Database::fetch_object($rs);
6040
-    						$row[5] = $obj->title;
6041
-    					}
6042
-    					break;
6043
-    				default:
6044
-    					break;
6045
-    			}
6046
-
6047
-    			$row2 = $name_session;
6048
-    			if (!empty($coach_name)) {
6049
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6050
-    			}
6051
-    			$row[2] = $row2;
6021
+                        break;
6022
+                    case 'thematic':
6023
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6024
+                        if (Database::num_rows($rs) > 0) {
6025
+                            $obj = Database::fetch_object($rs);
6026
+                            $row[5] = $obj->title;
6027
+                        }
6028
+                        break;
6029
+                    case 'thematic_advance':
6030
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6031
+                        if (Database::num_rows($rs) > 0) {
6032
+                            $obj = Database::fetch_object($rs);
6033
+                            $row[5] = $obj->content;
6034
+                        }
6035
+                        break;
6036
+                    case 'thematic_plan':
6037
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6038
+                        if (Database::num_rows($rs) > 0) {
6039
+                            $obj = Database::fetch_object($rs);
6040
+                            $row[5] = $obj->title;
6041
+                        }
6042
+                        break;
6043
+                    default:
6044
+                        break;
6045
+                }
6046
+
6047
+                $row2 = $name_session;
6048
+                if (!empty($coach_name)) {
6049
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6050
+                }
6051
+                $row[2] = $row2;
6052 6052
                 if (!empty($row['col3'])) {
6053 6053
                     $userInfo = api_get_user_info($row['user_id']);
6054 6054
 
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
                     $row[4] = $ip;
6066 6066
                 }
6067 6067
 
6068
-    			$resources[] = $row;
6069
-    		}
6070
-    	}
6068
+                $resources[] = $row;
6069
+            }
6070
+        }
6071 6071
 
6072
-    	return $resources;
6072
+        return $resources;
6073 6073
     }
6074 6074
 
6075 6075
     /**
@@ -6079,63 +6079,63 @@  discard block
 block discarded – undo
6079 6079
      */
6080 6080
     public static function get_tool_name_table($tool)
6081 6081
     {
6082
-    	switch ($tool) {
6083
-    		case 'document':
6084
-    			$table_name = TABLE_DOCUMENT;
6085
-    			$link_tool = 'document/document.php';
6086
-    			$id_tool = 'id';
6087
-    			break;
6088
-    		case 'learnpath':
6089
-    			$table_name = TABLE_LP_MAIN;
6090
-    			$link_tool = 'lp/lp_controller.php';
6091
-    			$id_tool = 'id';
6092
-    			break;
6093
-    		case 'quiz':
6094
-    			$table_name = TABLE_QUIZ_TEST;
6095
-    			$link_tool = 'exercise/exercise.php';
6096
-    			$id_tool = 'id';
6097
-    			break;
6098
-    		case 'glossary':
6099
-    			$table_name = TABLE_GLOSSARY;
6100
-    			$link_tool = 'glossary/index.php';
6101
-    			$id_tool = 'glossary_id';
6102
-    			break;
6103
-    		case 'link':
6104
-    			$table_name = TABLE_LINK;
6105
-    			$link_tool = 'link/link.php';
6106
-    			$id_tool = 'id';
6107
-    			break;
6108
-    		case 'course_description':
6109
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6110
-    			$link_tool = 'course_description/';
6111
-    			$id_tool = 'id';
6112
-    			break;
6113
-    		case 'announcement':
6114
-    			$table_name = TABLE_ANNOUNCEMENT;
6115
-    			$link_tool = 'announcements/announcements.php';
6116
-    			$id_tool = 'id';
6117
-    			break;
6118
-    		case 'thematic':
6119
-    			$table_name = TABLE_THEMATIC;
6120
-    			$link_tool = 'course_progress/index.php';
6121
-    			$id_tool = 'id';
6122
-    			break;
6123
-    		case 'thematic_advance':
6124
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6125
-    			$link_tool = 'course_progress/index.php';
6126
-    			$id_tool = 'id';
6127
-    			break;
6128
-    		case 'thematic_plan':
6129
-    			$table_name = TABLE_THEMATIC_PLAN;
6130
-    			$link_tool = 'course_progress/index.php';
6131
-    			$id_tool = 'id';
6132
-    			break;
6133
-    		default:
6134
-    			$table_name = $tool;
6135
-    		break;
6136
-    	}
6137
-
6138
-    	return array(
6082
+        switch ($tool) {
6083
+            case 'document':
6084
+                $table_name = TABLE_DOCUMENT;
6085
+                $link_tool = 'document/document.php';
6086
+                $id_tool = 'id';
6087
+                break;
6088
+            case 'learnpath':
6089
+                $table_name = TABLE_LP_MAIN;
6090
+                $link_tool = 'lp/lp_controller.php';
6091
+                $id_tool = 'id';
6092
+                break;
6093
+            case 'quiz':
6094
+                $table_name = TABLE_QUIZ_TEST;
6095
+                $link_tool = 'exercise/exercise.php';
6096
+                $id_tool = 'id';
6097
+                break;
6098
+            case 'glossary':
6099
+                $table_name = TABLE_GLOSSARY;
6100
+                $link_tool = 'glossary/index.php';
6101
+                $id_tool = 'glossary_id';
6102
+                break;
6103
+            case 'link':
6104
+                $table_name = TABLE_LINK;
6105
+                $link_tool = 'link/link.php';
6106
+                $id_tool = 'id';
6107
+                break;
6108
+            case 'course_description':
6109
+                $table_name = TABLE_COURSE_DESCRIPTION;
6110
+                $link_tool = 'course_description/';
6111
+                $id_tool = 'id';
6112
+                break;
6113
+            case 'announcement':
6114
+                $table_name = TABLE_ANNOUNCEMENT;
6115
+                $link_tool = 'announcements/announcements.php';
6116
+                $id_tool = 'id';
6117
+                break;
6118
+            case 'thematic':
6119
+                $table_name = TABLE_THEMATIC;
6120
+                $link_tool = 'course_progress/index.php';
6121
+                $id_tool = 'id';
6122
+                break;
6123
+            case 'thematic_advance':
6124
+                $table_name = TABLE_THEMATIC_ADVANCE;
6125
+                $link_tool = 'course_progress/index.php';
6126
+                $id_tool = 'id';
6127
+                break;
6128
+            case 'thematic_plan':
6129
+                $table_name = TABLE_THEMATIC_PLAN;
6130
+                $link_tool = 'course_progress/index.php';
6131
+                $id_tool = 'id';
6132
+                break;
6133
+            default:
6134
+                $table_name = $tool;
6135
+            break;
6136
+        }
6137
+
6138
+        return array(
6139 6139
             'table_name' => $table_name,
6140 6140
             'link_tool' => $link_tool,
6141 6141
             'id_tool' => $id_tool
@@ -6144,45 +6144,45 @@  discard block
 block discarded – undo
6144 6144
 
6145 6145
     public static function display_additional_profile_fields()
6146 6146
     {
6147
-    	// getting all the extra profile fields that are defined by the platform administrator
6148
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6149
-
6150
-    	// creating the form
6151
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6152
-
6153
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6154
-    	// the information the users have entered or selected.
6155
-    	$return .= '<select name="additional_profile_field">';
6156
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6157
-    	$extra_fields_to_show = 0;
6158
-    	foreach ($extra_fields as $key=>$field) {
6159
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6160
-    		if ($field[6]==1 && $field[8] == 1) {
6161
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6162
-    				$selected = 'selected="selected"';
6163
-    			} else {
6164
-    				$selected = '';
6165
-    			}
6166
-    			$extra_fields_to_show++;
6167
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6168
-    		}
6169
-    	}
6170
-    	$return .= '</select>';
6171
-
6172
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6173
-    	foreach ($_GET as $key=>$value){
6174
-    		if ($key <> 'additional_profile_field')    {
6175
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6176
-    		}
6177
-    	}
6178
-    	// the submit button
6179
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6180
-    	$return .= '</form>';
6181
-    	if ($extra_fields_to_show > 0) {
6182
-    		return $return;
6183
-    	} else {
6184
-    		return '';
6185
-    	}
6147
+        // getting all the extra profile fields that are defined by the platform administrator
6148
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6149
+
6150
+        // creating the form
6151
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6152
+
6153
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6154
+        // the information the users have entered or selected.
6155
+        $return .= '<select name="additional_profile_field">';
6156
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6157
+        $extra_fields_to_show = 0;
6158
+        foreach ($extra_fields as $key=>$field) {
6159
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6160
+            if ($field[6]==1 && $field[8] == 1) {
6161
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6162
+                    $selected = 'selected="selected"';
6163
+                } else {
6164
+                    $selected = '';
6165
+                }
6166
+                $extra_fields_to_show++;
6167
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6168
+            }
6169
+        }
6170
+        $return .= '</select>';
6171
+
6172
+        // the form elements for the $_GET parameters (because the form is passed through GET
6173
+        foreach ($_GET as $key=>$value){
6174
+            if ($key <> 'additional_profile_field')    {
6175
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6176
+            }
6177
+        }
6178
+        // the submit button
6179
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6180
+        $return .= '</form>';
6181
+        if ($extra_fields_to_show > 0) {
6182
+            return $return;
6183
+        } else {
6184
+            return '';
6185
+        }
6186 6186
     }
6187 6187
 
6188 6188
     /**
@@ -6201,31 +6201,31 @@  discard block
 block discarded – undo
6201 6201
      */
6202 6202
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6203 6203
     {
6204
-    	// Database table definition
6205
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6206
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6204
+        // Database table definition
6205
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6206
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6207 6207
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6208
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6209
-
6210
-    	if (!empty($users)) {
6211
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6212
-    			foreach($users as $user_id) {
6213
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6214
-    				$tag_list = array();
6215
-    				foreach($user_result as $item) {
6216
-    					$tag_list[] = $item['tag'];
6217
-    				}
6218
-    				$return[$user_id][] = implode(', ',$tag_list);
6219
-    			}
6220
-    		} else {
6221
-    			$new_user_array = array();
6222
-    			foreach ($users as $user_id) {
6223
-    				$new_user_array[]= "'".$user_id."'";
6224
-    			}
6225
-    			$users = implode(',',$new_user_array);
6208
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6209
+
6210
+        if (!empty($users)) {
6211
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6212
+                foreach($users as $user_id) {
6213
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6214
+                    $tag_list = array();
6215
+                    foreach($user_result as $item) {
6216
+                        $tag_list[] = $item['tag'];
6217
+                    }
6218
+                    $return[$user_id][] = implode(', ',$tag_list);
6219
+                }
6220
+            } else {
6221
+                $new_user_array = array();
6222
+                foreach ($users as $user_id) {
6223
+                    $new_user_array[]= "'".$user_id."'";
6224
+                }
6225
+                $users = implode(',',$new_user_array);
6226 6226
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6227
-    			// Selecting only the necessary information NOT ALL the user list
6228
-    			$sql = "SELECT user.user_id, v.value
6227
+                // Selecting only the necessary information NOT ALL the user list
6228
+                $sql = "SELECT user.user_id, v.value
6229 6229
     			        FROM $table_user user
6230 6230
     			        INNER JOIN $table_user_field_values v
6231 6231
                         ON (user.user_id = v.item_id)
@@ -6236,27 +6236,27 @@  discard block
 block discarded – undo
6236 6236
                             v.field_id=".intval($field_id)." AND
6237 6237
                             user.user_id IN ($users)";
6238 6238
 
6239
-    			$result = Database::query($sql);
6240
-    			while($row = Database::fetch_array($result)) {
6241
-    				// get option value for field type double select by id
6242
-    				if (!empty($row['value'])) {
6243
-    					if ($result_extra_field['field_type'] ==
6239
+                $result = Database::query($sql);
6240
+                while($row = Database::fetch_array($result)) {
6241
+                    // get option value for field type double select by id
6242
+                    if (!empty($row['value'])) {
6243
+                        if ($result_extra_field['field_type'] ==
6244 6244
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6245 6245
                         ) {
6246
-    						$id_double_select = explode(';', $row['value']);
6247
-    						if (is_array($id_double_select)) {
6248
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6249
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6250
-    							$row['value'] = ($value1.';'.$value2);
6251
-    						}
6252
-    					}
6253
-    				}
6254
-    				// get other value from extra field
6255
-    				$return[$row['user_id']][] = $row['value'];
6256
-    			}
6257
-    		}
6258
-    	}
6259
-    	return $return;
6246
+                            $id_double_select = explode(';', $row['value']);
6247
+                            if (is_array($id_double_select)) {
6248
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6249
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6250
+                                $row['value'] = ($value1.';'.$value2);
6251
+                            }
6252
+                        }
6253
+                    }
6254
+                    // get other value from extra field
6255
+                    $return[$row['user_id']][] = $row['value'];
6256
+                }
6257
+            }
6258
+        }
6259
+        return $return;
6260 6260
     }
6261 6261
 
6262 6262
     /**
@@ -6265,18 +6265,18 @@  discard block
 block discarded – undo
6265 6265
      */
6266 6266
     public function count_student_in_course()
6267 6267
     {
6268
-    	global $nbStudents;
6269
-    	return $nbStudents;
6268
+        global $nbStudents;
6269
+        return $nbStudents;
6270 6270
     }
6271 6271
 
6272 6272
     public function sort_users($a, $b)
6273 6273
     {
6274
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6274
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6275 6275
     }
6276 6276
 
6277 6277
     public function sort_users_desc($a, $b)
6278 6278
     {
6279
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6279
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6280 6280
     }
6281 6281
 
6282 6282
     /**
@@ -6285,8 +6285,8 @@  discard block
 block discarded – undo
6285 6285
      */
6286 6286
     public static function get_number_of_users()
6287 6287
     {
6288
-    	global $user_ids;
6289
-    	return count($user_ids);
6288
+        global $user_ids;
6289
+        return count($user_ids);
6290 6290
     }
6291 6291
 
6292 6292
     /**
@@ -6302,37 +6302,37 @@  discard block
 block discarded – undo
6302 6302
     {
6303 6303
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6304 6304
 
6305
-    	$course_code = Database::escape_string($course_code);
6306
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6307
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6305
+        $course_code = Database::escape_string($course_code);
6306
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6307
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6308 6308
 
6309
-    	$access_url_id = api_get_current_access_url_id();
6309
+        $access_url_id = api_get_current_access_url_id();
6310 6310
 
6311
-    	// get all users data from a course for sortable with limit
6312
-    	if (is_array($user_ids)) {
6313
-    		$user_ids = array_map('intval', $user_ids);
6314
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6315
-    	} else {
6316
-    		$user_ids = intval($user_ids);
6317
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6318
-    	}
6311
+        // get all users data from a course for sortable with limit
6312
+        if (is_array($user_ids)) {
6313
+            $user_ids = array_map('intval', $user_ids);
6314
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6315
+        } else {
6316
+            $user_ids = intval($user_ids);
6317
+            $condition_user = " WHERE user.user_id = $user_ids ";
6318
+        }
6319 6319
 
6320
-    	if (!empty($_GET['user_keyword'])) {
6321
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6322
-    		$condition_user .=  " AND (
6320
+        if (!empty($_GET['user_keyword'])) {
6321
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6322
+            $condition_user .=  " AND (
6323 6323
                 user.firstname LIKE '%".$keyword."%' OR
6324 6324
                 user.lastname LIKE '%".$keyword."%'  OR
6325 6325
                 user.username LIKE '%".$keyword."%'  OR
6326 6326
                 user.email LIKE '%".$keyword."%'
6327 6327
              ) ";
6328
-    	}
6328
+        }
6329 6329
 
6330 6330
         $url_table = null;
6331 6331
         $url_condition = null;
6332
-    	if (api_is_multiple_url_enabled()) {
6333
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6334
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6335
-    	}
6332
+        if (api_is_multiple_url_enabled()) {
6333
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6334
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6335
+        }
6336 6336
 
6337 6337
         $invitedUsersCondition = '';
6338 6338
 
@@ -6340,7 +6340,7 @@  discard block
 block discarded – undo
6340 6340
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6341 6341
         }
6342 6342
 
6343
-    	$sql = "SELECT  user.user_id as user_id,
6343
+        $sql = "SELECT  user.user_id as user_id,
6344 6344
                     user.official_code  as col0,
6345 6345
                     user.lastname       as col1,
6346 6346
                     user.firstname      as col2,
@@ -6348,17 +6348,17 @@  discard block
 block discarded – undo
6348 6348
                 FROM $tbl_user as user $url_table
6349 6349
     	        $condition_user $url_condition $invitedUsersCondition";
6350 6350
 
6351
-    	if (!in_array($direction, array('ASC','DESC'))) {
6352
-    		$direction = 'ASC';
6353
-    	}
6351
+        if (!in_array($direction, array('ASC','DESC'))) {
6352
+            $direction = 'ASC';
6353
+        }
6354 6354
 
6355
-    	$column = intval($column);
6355
+        $column = intval($column);
6356 6356
 
6357
-    	$from = intval($from);
6358
-    	$number_of_items = intval($number_of_items);
6357
+        $from = intval($from);
6358
+        $number_of_items = intval($number_of_items);
6359 6359
 
6360
-    	$sql .= " ORDER BY col$column $direction ";
6361
-    	$sql .= " LIMIT $from,$number_of_items";
6360
+        $sql .= " ORDER BY col$column $direction ";
6361
+        $sql .= " LIMIT $from,$number_of_items";
6362 6362
 
6363 6363
         $res = Database::query($sql);
6364 6364
         $users = array();
@@ -6392,7 +6392,7 @@  discard block
 block discarded – undo
6392 6392
             }
6393 6393
         }
6394 6394
 
6395
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6395
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6396 6396
             $courseInfo = api_get_course_info($course_code);
6397 6397
             $courseId = $courseInfo['real_id'];
6398 6398
 
@@ -6423,10 +6423,10 @@  discard block
 block discarded – undo
6423 6423
                 $session_id
6424 6424
             );
6425 6425
 
6426
-    		if (empty($avg_student_progress)) {
6426
+            if (empty($avg_student_progress)) {
6427 6427
                 $avg_student_progress = 0;
6428
-    		}
6429
-    		$user['average_progress'] = $avg_student_progress.'%';
6428
+            }
6429
+            $user['average_progress'] = $avg_student_progress.'%';
6430 6430
 
6431 6431
             $total_user_exercise = Tracking::get_exercise_student_progress(
6432 6432
                 $total_exercises,
@@ -6446,11 +6446,11 @@  discard block
 block discarded – undo
6446 6446
 
6447 6447
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6448 6448
 
6449
-    		if (is_numeric($avg_student_score)) {
6450
-    			$user['student_score']  = $avg_student_score.'%';
6451
-    		} else {
6452
-    			$user['student_score']  = $avg_student_score;
6453
-    		}
6449
+            if (is_numeric($avg_student_score)) {
6450
+                $user['student_score']  = $avg_student_score.'%';
6451
+            } else {
6452
+                $user['student_score']  = $avg_student_score;
6453
+            }
6454 6454
 
6455 6455
             $user['count_assignments'] = Tracking::count_student_assignments(
6456 6456
                 $user['user_id'],
@@ -6473,29 +6473,29 @@  discard block
 block discarded – undo
6473 6473
                 $session_id
6474 6474
             );
6475 6475
 
6476
-    		// we need to display an additional profile field
6477
-    		$user['additional'] = '';
6476
+            // we need to display an additional profile field
6477
+            $user['additional'] = '';
6478 6478
 
6479
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6480
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6479
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6480
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6481 6481
                     is_array($additional_user_profile_info[$user['user_id']])
6482 6482
                 ) {
6483
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6484
-    			}
6485
-    		}
6483
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6484
+                }
6485
+            }
6486 6486
 
6487 6487
             if (empty($session_id)) {
6488 6488
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6489 6489
             }
6490 6490
 
6491
-    		$user['link'] = '<center>
6491
+            $user['link'] = '<center>
6492 6492
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6493 6493
     		                 '.Display::return_icon('2rightarrow.png').'
6494 6494
     		                 </a>
6495 6495
                          </center>';
6496 6496
 
6497
-    		// store columns in array $users
6498
-    		$is_western_name_order = api_is_western_name_order();
6497
+            // store columns in array $users
6498
+            $is_western_name_order = api_is_western_name_order();
6499 6499
             $user_row = array();
6500 6500
             $user_row[]= $user['official_code']; //0
6501 6501
             if ($is_western_name_order) {
@@ -6531,21 +6531,21 @@  discard block
 block discarded – undo
6531 6531
 
6532 6532
             $users[] = $user_row;
6533 6533
 
6534
-    		if ($export_csv) {
6535
-    		    if (empty($session_id)) {
6534
+            if ($export_csv) {
6535
+                if (empty($session_id)) {
6536 6536
                     $user_row = array_map('strip_tags', $user_row);
6537
-    			    unset($user_row[14]);
6538
-    			    unset($user_row[15]);
6537
+                    unset($user_row[14]);
6538
+                    unset($user_row[15]);
6539 6539
                 } else {
6540 6540
                     $user_row = array_map('strip_tags', $user_row);
6541 6541
                     unset($user_row[13]);
6542 6542
                     unset($user_row[14]);
6543 6543
                 }
6544 6544
 
6545
-    			$csv_content[] = $user_row;
6546
-    		}
6547
-    	}
6548
-    	return $users;
6545
+                $csv_content[] = $user_row;
6546
+            }
6547
+        }
6548
+        return $users;
6549 6549
     }
6550 6550
 }
6551 6551
 
@@ -6563,18 +6563,18 @@  discard block
 block discarded – undo
6563 6563
      */
6564 6564
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6565 6565
     {
6566
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6567
-
6568
-    	// protected data
6569
-    	$user_id = intval($user_id);
6570
-    	$session_id = intval($session_id);
6571
-    	$course_id = Database::escape_string($course_id);
6572
-
6573
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6574
-    	$tempView = $view;
6575
-    	if(substr($view,0,1) == '1') {
6576
-    		$new_view = substr_replace($view,'0',0,1);
6577
-    		echo "
6566
+        $MonthsLong = $GLOBALS['MonthsLong'];
6567
+
6568
+        // protected data
6569
+        $user_id = intval($user_id);
6570
+        $session_id = intval($session_id);
6571
+        $course_id = Database::escape_string($course_id);
6572
+
6573
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6574
+        $tempView = $view;
6575
+        if(substr($view,0,1) == '1') {
6576
+            $new_view = substr_replace($view,'0',0,1);
6577
+            echo "
6578 6578
                 <tr>
6579 6579
                     <td valign='top'>
6580 6580
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6582,9 +6582,9 @@  discard block
 block discarded – undo
6582 6582
                     </td>
6583 6583
                 </tr>
6584 6584
                 ";
6585
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6585
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6586 6586
 
6587
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6587
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6588 6588
                         FROM $track_access_table
6589 6589
                         WHERE access_user_id = $user_id
6590 6590
                         AND c_id = $course_id
@@ -6592,11 +6592,11 @@  discard block
 block discarded – undo
6592 6592
                         GROUP BY YEAR(access_date),MONTH(access_date)
6593 6593
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6594 6594
 
6595
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6596
-    		$results = getManyResults3Col($sql);
6595
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6596
+            $results = getManyResults3Col($sql);
6597 6597
 
6598
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6599
-    		echo "<tr>
6598
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6599
+            echo "<tr>
6600 6600
                     <td class='secLine'>
6601 6601
                     ".get_lang('LoginsTitleMonthColumn')."
6602 6602
                     </td>
@@ -6604,36 +6604,36 @@  discard block
 block discarded – undo
6604 6604
                     ".get_lang('LoginsTitleCountColumn')."
6605 6605
                     </td>
6606 6606
                 </tr>";
6607
-    		$total = 0;
6608
-    		if (is_array($results)) {
6609
-    			for($j = 0 ; $j < count($results) ; $j++) {
6610
-    				echo "<tr>";
6611
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6612
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6613
-    				echo"</tr>";
6614
-    				$total = $total + $results[$j][1];
6615
-    			}
6616
-    			echo "<tr>";
6617
-    			echo "<td>".get_lang('Total')."</td>";
6618
-    			echo "<td align='right' class='content'>".$total."</td>";
6619
-    			echo"</tr>";
6620
-    		} else {
6621
-    			echo "<tr>";
6622
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6623
-    			echo"</tr>";
6624
-    		}
6625
-    		echo "</table>";
6626
-    		echo "</td></tr>";
6627
-    	} else {
6628
-    		$new_view = substr_replace($view,'1',0,1);
6629
-    		echo "
6607
+            $total = 0;
6608
+            if (is_array($results)) {
6609
+                for($j = 0 ; $j < count($results) ; $j++) {
6610
+                    echo "<tr>";
6611
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6612
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6613
+                    echo"</tr>";
6614
+                    $total = $total + $results[$j][1];
6615
+                }
6616
+                echo "<tr>";
6617
+                echo "<td>".get_lang('Total')."</td>";
6618
+                echo "<td align='right' class='content'>".$total."</td>";
6619
+                echo"</tr>";
6620
+            } else {
6621
+                echo "<tr>";
6622
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6623
+                echo"</tr>";
6624
+            }
6625
+            echo "</table>";
6626
+            echo "</td></tr>";
6627
+        } else {
6628
+            $new_view = substr_replace($view,'1',0,1);
6629
+            echo "
6630 6630
                 <tr>
6631 6631
                     <td valign='top'>
6632 6632
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6633 6633
                     </td>
6634 6634
                 </tr>
6635 6635
             ";
6636
-    	}
6636
+        }
6637 6637
     }
6638 6638
 
6639 6639
     /**
@@ -6646,38 +6646,38 @@  discard block
 block discarded – undo
6646 6646
      */
6647 6647
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6648 6648
     {
6649
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6649
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6650 6650
         $courseId = api_get_course_int_id($courseCode);
6651
-    	if(substr($view,1,1) == '1') {
6652
-    		$new_view = substr_replace($view,'0',1,1);
6653
-    		echo "<tr>
6651
+        if(substr($view,1,1) == '1') {
6652
+            $new_view = substr_replace($view,'0',1,1);
6653
+            echo "<tr>
6654 6654
                     <td valign='top'>
6655 6655
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6656 6656
                     </td>
6657 6657
                 </tr>";
6658
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6658
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6659 6659
 
6660
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6660
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6661 6661
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6662 6662
                     WHERE te.c_id = $courseId
6663 6663
                         AND te.exe_user_id = ".intval($user_id)."
6664 6664
                         AND te.exe_exo_id = ce.id
6665 6665
                     ORDER BY ce.title ASC, te.exe_date ASC";
6666 6666
 
6667
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6667
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6668 6668
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6669 6669
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6670 6670
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6671 6671
 
6672
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6672
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6673 6673
 
6674
-    		$NoTestRes = 0;
6675
-    		$NoHPTestRes = 0;
6674
+            $NoTestRes = 0;
6675
+            $NoHPTestRes = 0;
6676 6676
 
6677
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6678
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6679
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6680
-    		echo "
6677
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6678
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6679
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6680
+            echo "
6681 6681
                 <tr bgcolor='#E6E6E6'>
6682 6682
                     <td>
6683 6683
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6690,28 +6690,28 @@  discard block
 block discarded – undo
6690 6690
                     </td>
6691 6691
                 </tr>";
6692 6692
 
6693
-    		if (is_array($results)) {
6694
-    			for($i = 0; $i < sizeof($results); $i++) {
6695
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6696
-    				echo "<tr>\n";
6697
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6698
-    				echo "<td class='content'>".$display_date."</td>\n";
6699
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6700
-    				echo "</tr>\n";
6701
-    			}
6702
-    		} else {
6703
-    			// istvan begin
6704
-    			$NoTestRes = 1;
6705
-    		}
6706
-
6707
-    		// The Result of Tests
6708
-    		if (is_array($hpresults)) {
6709
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6710
-    				$title = GetQuizName($hpresults[$i][0],'');
6711
-    				if ($title == '')
6712
-    				$title = basename($hpresults[$i][0]);
6713
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6714
-    				?>
6693
+            if (is_array($results)) {
6694
+                for($i = 0; $i < sizeof($results); $i++) {
6695
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6696
+                    echo "<tr>\n";
6697
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6698
+                    echo "<td class='content'>".$display_date."</td>\n";
6699
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6700
+                    echo "</tr>\n";
6701
+                }
6702
+            } else {
6703
+                // istvan begin
6704
+                $NoTestRes = 1;
6705
+            }
6706
+
6707
+            // The Result of Tests
6708
+            if (is_array($hpresults)) {
6709
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6710
+                    $title = GetQuizName($hpresults[$i][0],'');
6711
+                    if ($title == '')
6712
+                    $title = basename($hpresults[$i][0]);
6713
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6714
+                    ?>
6715 6715
                     <tr>
6716 6716
                         <td class="content"><?php echo $title; ?></td>
6717 6717
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6721,26 +6721,26 @@  discard block
 block discarded – undo
6721 6721
 
6722 6722
                     <?php
6723 6723
                 }
6724
-    		} else {
6725
-    			$NoHPTestRes = 1;
6726
-    		}
6727
-
6728
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6729
-    			echo "<tr>\n";
6730
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6731
-    			echo "</tr>\n";
6732
-    		}
6733
-    		echo "</table>";
6734
-    		echo "</td>\n</tr>\n";
6735
-    	} else {
6736
-    		$new_view = substr_replace($view,'1',1,1);
6737
-    		echo "
6724
+            } else {
6725
+                $NoHPTestRes = 1;
6726
+            }
6727
+
6728
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6729
+                echo "<tr>\n";
6730
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6731
+                echo "</tr>\n";
6732
+            }
6733
+            echo "</table>";
6734
+            echo "</td>\n</tr>\n";
6735
+        } else {
6736
+            $new_view = substr_replace($view,'1',1,1);
6737
+            echo "
6738 6738
                 <tr>
6739 6739
                     <td valign='top'>
6740 6740
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6741 6741
                     </td>
6742 6742
                 </tr>";
6743
-    	}
6743
+        }
6744 6744
     }
6745 6745
 
6746 6746
     /**
@@ -6749,27 +6749,27 @@  discard block
 block discarded – undo
6749 6749
      */
6750 6750
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6751 6751
     {
6752
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6752
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6753 6753
         $_course = api_get_course_info_by_id($course_id);
6754 6754
 
6755
-    	if (substr($view,2,1) == '1') {
6756
-    		$new_view = substr_replace($view,'0',2,1);
6757
-    		echo "<tr>
6755
+        if (substr($view,2,1) == '1') {
6756
+            $new_view = substr_replace($view,'0',2,1);
6757
+            echo "<tr>
6758 6758
                     <td valign='top'>
6759 6759
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6760 6760
                     </td>
6761 6761
                 </tr>";
6762
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6763
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6762
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6763
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6764 6764
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6765 6765
                     WHERE u.upload_work_id = w.id
6766 6766
                         AND u.upload_user_id = '".intval($user_id)."'
6767 6767
                         AND u.c_id = '".intval($course_id)."'
6768 6768
                     ORDER BY u.upload_date DESC";
6769
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6770
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6771
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6772
-    		echo "<tr>
6769
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6770
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6771
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6772
+            echo "<tr>
6773 6773
                     <td class='secLine' width='40%'>
6774 6774
                     ".get_lang('WorkTitle')."
6775 6775
                     </td>
@@ -6780,35 +6780,35 @@  discard block
 block discarded – undo
6780 6780
                     ".get_lang('Date')."
6781 6781
                     </td>
6782 6782
                 </tr>";
6783
-    		if (is_array($results)) {
6784
-    			for($j = 0 ; $j < count($results) ; $j++) {
6785
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6786
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6787
-    				echo "<tr>";
6788
-    				echo "<td class='content'>"
6789
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6790
-    				."</td>";
6791
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6792
-    				echo "<td class='content'>".$beautifulDate."</td>";
6793
-    				echo"</tr>";
6794
-    			}
6795
-    		} else {
6796
-    			echo "<tr>";
6797
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6798
-    			echo"</tr>";
6799
-    		}
6800
-    		echo "</table>";
6801
-    		echo "</td></tr>";
6802
-    	} else {
6803
-    		$new_view = substr_replace($view,'1',2,1);
6804
-    		echo "
6783
+            if (is_array($results)) {
6784
+                for($j = 0 ; $j < count($results) ; $j++) {
6785
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6786
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6787
+                    echo "<tr>";
6788
+                    echo "<td class='content'>"
6789
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6790
+                    ."</td>";
6791
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6792
+                    echo "<td class='content'>".$beautifulDate."</td>";
6793
+                    echo"</tr>";
6794
+                }
6795
+            } else {
6796
+                echo "<tr>";
6797
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6798
+                echo"</tr>";
6799
+            }
6800
+            echo "</table>";
6801
+            echo "</td></tr>";
6802
+        } else {
6803
+            $new_view = substr_replace($view,'1',2,1);
6804
+            echo "
6805 6805
                 <tr>
6806 6806
                     <td valign='top'>
6807 6807
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6808 6808
                     </td>
6809 6809
                 </tr>
6810 6810
             ";
6811
-    	}
6811
+        }
6812 6812
     }
6813 6813
 
6814 6814
     /**
@@ -6817,55 +6817,55 @@  discard block
 block discarded – undo
6817 6817
      */
6818 6818
     public function display_links_tracking_info($view, $user_id, $courseCode)
6819 6819
     {
6820
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6820
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6821 6821
         $courseId = api_get_course_int_id($courseCode);
6822
-    	if (substr($view,3,1) == '1') {
6823
-    		$new_view = substr_replace($view,'0',3,1);
6824
-    		echo "
6822
+        if (substr($view,3,1) == '1') {
6823
+            $new_view = substr_replace($view,'0',3,1);
6824
+            echo "
6825 6825
                 <tr>
6826 6826
                         <td valign='top'>
6827 6827
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
6828 6828
                         </td>
6829 6829
                 </tr>
6830 6830
             ";
6831
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6832
-    		$sql = "SELECT cl.title, cl.url
6831
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6832
+            $sql = "SELECT cl.title, cl.url
6833 6833
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6834 6834
                     WHERE sl.links_link_id = cl.id
6835 6835
                         AND sl.c_id = $courseId
6836 6836
                         AND sl.links_user_id = ".intval($user_id)."
6837 6837
                     GROUP BY cl.title, cl.url";
6838
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6839
-    		$results = StatsUtils::getManyResults2Col($sql);
6840
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6841
-    		echo "<tr>
6838
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6839
+            $results = StatsUtils::getManyResults2Col($sql);
6840
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6841
+            echo "<tr>
6842 6842
                     <td class='secLine'>
6843 6843
                     ".get_lang('LinksTitleLinkColumn')."
6844 6844
                     </td>
6845 6845
                 </tr>";
6846
-    		if (is_array($results)) {
6847
-    			for($j = 0 ; $j < count($results) ; $j++) {
6848
-    				echo "<tr>";
6849
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6850
-    				echo"</tr>";
6851
-    			}
6852
-    		} else {
6853
-    			echo "<tr>";
6854
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6855
-    			echo"</tr>";
6856
-    		}
6857
-    		echo "</table>";
6858
-    		echo "</td></tr>";
6859
-    	} else {
6860
-    		$new_view = substr_replace($view,'1',3,1);
6861
-    		echo "
6846
+            if (is_array($results)) {
6847
+                for($j = 0 ; $j < count($results) ; $j++) {
6848
+                    echo "<tr>";
6849
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6850
+                    echo"</tr>";
6851
+                }
6852
+            } else {
6853
+                echo "<tr>";
6854
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6855
+                echo"</tr>";
6856
+            }
6857
+            echo "</table>";
6858
+            echo "</td></tr>";
6859
+        } else {
6860
+            $new_view = substr_replace($view,'1',3,1);
6861
+            echo "
6862 6862
                 <tr>
6863 6863
                     <td valign='top'>
6864 6864
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
6865 6865
                     </td>
6866 6866
                 </tr>
6867 6867
             ";
6868
-    	}
6868
+        }
6869 6869
     }
6870 6870
 
6871 6871
     /**
@@ -6878,61 +6878,61 @@  discard block
 block discarded – undo
6878 6878
      */
6879 6879
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6880 6880
     {
6881
-    	// protect data
6881
+        // protect data
6882 6882
         $user_id = intval($user_id);
6883 6883
         $courseId = api_get_course_int_id($course_code);
6884
-    	$session_id = intval($session_id);
6884
+        $session_id = intval($session_id);
6885 6885
 
6886
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6887
-    	if(substr($view,4,1) == '1') {
6888
-    		$new_view = substr_replace($view,'0',4,1);
6889
-    		echo "
6886
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6887
+        if(substr($view,4,1) == '1') {
6888
+            $new_view = substr_replace($view,'0',4,1);
6889
+            echo "
6890 6890
                 <tr>
6891 6891
                     <td valign='top'>
6892 6892
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
6893 6893
                     </td>
6894 6894
                 </tr>
6895 6895
             ";
6896
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6896
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6897 6897
 
6898
-    		$sql = "SELECT down_doc_path
6898
+            $sql = "SELECT down_doc_path
6899 6899
                     FROM $downloads_table
6900 6900
                     WHERE c_id = $courseId
6901 6901
                         AND down_user_id = $user_id
6902 6902
                         AND down_session_id = $session_id
6903 6903
                     GROUP BY down_doc_path";
6904 6904
 
6905
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6906
-    		$results = StatsUtils::getManyResults1Col($sql);
6907
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6908
-    		echo "<tr>
6905
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6906
+            $results = StatsUtils::getManyResults1Col($sql);
6907
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6908
+            echo "<tr>
6909 6909
                     <td class='secLine'>
6910 6910
                     ".get_lang('DocumentsTitleDocumentColumn')."
6911 6911
                     </td>
6912 6912
                 </tr>";
6913
-    		if (is_array($results)) {
6914
-    			for($j = 0 ; $j < count($results) ; $j++) {
6915
-    				echo "<tr>";
6916
-    				echo "<td class='content'>".$results[$j]."</td>";
6917
-    				echo"</tr>";
6918
-    			}
6919
-    		} else {
6920
-    			echo "<tr>";
6921
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6922
-    			echo"</tr>";
6923
-    		}
6924
-    		echo "</table>";
6925
-    		echo "</td></tr>";
6926
-    	} else {
6927
-    		$new_view = substr_replace($view,'1',4,1);
6928
-    		echo "
6913
+            if (is_array($results)) {
6914
+                for($j = 0 ; $j < count($results) ; $j++) {
6915
+                    echo "<tr>";
6916
+                    echo "<td class='content'>".$results[$j]."</td>";
6917
+                    echo"</tr>";
6918
+                }
6919
+            } else {
6920
+                echo "<tr>";
6921
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6922
+                echo"</tr>";
6923
+            }
6924
+            echo "</table>";
6925
+            echo "</td></tr>";
6926
+        } else {
6927
+            $new_view = substr_replace($view,'1',4,1);
6928
+            echo "
6929 6929
                 <tr>
6930 6930
                     <td valign='top'>
6931 6931
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
6932 6932
                     </td>
6933 6933
                 </tr>
6934 6934
             ";
6935
-    	}
6935
+        }
6936 6936
     }
6937 6937
 
6938 6938
     /**
@@ -6989,43 +6989,43 @@  discard block
 block discarded – undo
6989 6989
      */
6990 6990
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6991 6991
     {
6992
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6993
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6994
-
6995
-    	// protected data
6996
-    	$user_id    = intval($user_id);
6997
-    	$session_id = intval($session_id);
6998
-    	$course_id  = intval($course_id);
6999
-
7000
-    	$tempView = $view;
7001
-    	if (substr($view,0,1) == '1') {
7002
-    		$new_view = substr_replace($view,'0',0,1);
7003
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7004
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6992
+        $MonthsLong = $GLOBALS['MonthsLong'];
6993
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6994
+
6995
+        // protected data
6996
+        $user_id    = intval($user_id);
6997
+        $session_id = intval($session_id);
6998
+        $course_id  = intval($course_id);
6999
+
7000
+        $tempView = $view;
7001
+        if (substr($view,0,1) == '1') {
7002
+            $new_view = substr_replace($view,'0',0,1);
7003
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7004
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7005 7005
                     FROM $track_access_table
7006 7006
                     WHERE access_user_id = $user_id
7007 7007
                     AND c_id = $course_id
7008 7008
                     AND access_session_id = $session_id
7009 7009
                     GROUP BY YEAR(access_date),MONTH(access_date)
7010 7010
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7011
-    		//$results = getManyResults2Col($sql);
7012
-    		$results = getManyResults3Col($sql);
7013
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7014
-    		$line='';
7015
-    		$total = 0;
7016
-    		if (is_array($results)) {
7017
-    			for($j = 0 ; $j < count($results) ; $j++) {
7018
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7019
-    				$total = $total + $results[$j][1];
7020
-    			}
7021
-    			$line .= get_lang('Total').";".$total."\n";
7022
-    		} else {
7023
-    			$line= get_lang('NoResult')."</center></td>";
7024
-    		}
7025
-    	} else {
7026
-    		$new_view = substr_replace($view,'1',0,1);
7027
-    	}
7028
-    	return array($title_line, $line);
7011
+            //$results = getManyResults2Col($sql);
7012
+            $results = getManyResults3Col($sql);
7013
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7014
+            $line='';
7015
+            $total = 0;
7016
+            if (is_array($results)) {
7017
+                for($j = 0 ; $j < count($results) ; $j++) {
7018
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7019
+                    $total = $total + $results[$j][1];
7020
+                }
7021
+                $line .= get_lang('Total').";".$total."\n";
7022
+            } else {
7023
+                $line= get_lang('NoResult')."</center></td>";
7024
+            }
7025
+        } else {
7026
+            $new_view = substr_replace($view,'1',0,1);
7027
+        }
7028
+        return array($title_line, $line);
7029 7029
     }
7030 7030
 
7031 7031
     /**
@@ -7038,67 +7038,67 @@  discard block
 block discarded – undo
7038 7038
      */
7039 7039
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7040 7040
     {
7041
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7041
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7042 7042
         $courseId = api_get_course_int_id($courseCode);
7043 7043
         $userId = intval($userId);
7044
-    	if (substr($view,1,1) == '1') {
7045
-    		$new_view = substr_replace($view,'0',1,1);
7046
-    		$title[1] = get_lang('ExercicesDetails');
7047
-    		$line = '';
7048
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7044
+        if (substr($view,1,1) == '1') {
7045
+            $new_view = substr_replace($view,'0',1,1);
7046
+            $title[1] = get_lang('ExercicesDetails');
7047
+            $line = '';
7048
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7049 7049
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7050 7050
                     WHERE te.c_id = $courseId
7051 7051
                         AND te.exe_user_id = $userId
7052 7052
                         AND te.exe_exo_id = ce.id
7053 7053
                     ORDER BY ce.title ASC, te.exe_date ASC";
7054 7054
 
7055
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7055
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7056 7056
                         FROM $TABLETRACK_HOTPOTATOES AS te
7057 7057
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7058 7058
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7059 7059
 
7060
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7060
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7061 7061
 
7062
-    		$NoTestRes = 0;
7063
-    		$NoHPTestRes = 0;
7062
+            $NoTestRes = 0;
7063
+            $NoHPTestRes = 0;
7064 7064
 
7065
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7066
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7065
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7066
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7067 7067
 
7068
-    		if (is_array($results)) {
7069
-    			for($i = 0; $i < sizeof($results); $i++)
7070
-    			{
7071
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7072
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7073
-    			}
7074
-    		} else {
7068
+            if (is_array($results)) {
7069
+                for($i = 0; $i < sizeof($results); $i++)
7070
+                {
7071
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7072
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7073
+                }
7074
+            } else {
7075 7075
                 // istvan begin
7076
-    			$NoTestRes = 1;
7077
-    		}
7078
-
7079
-    		// The Result of Tests
7080
-    		if (is_array($hpresults)) {
7081
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7082
-    				$title = GetQuizName($hpresults[$i][0],'');
7083
-
7084
-    				if ($title == '')
7085
-    				$title = basename($hpresults[$i][0]);
7086
-
7087
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7088
-
7089
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7090
-    			}
7091
-    		} else {
7092
-    			$NoHPTestRes = 1;
7093
-    		}
7094
-
7095
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7096
-    			$line=get_lang('NoResult');
7097
-    		}
7098
-    	} else {
7099
-    		$new_view = substr_replace($view,'1',1,1);
7100
-    	}
7101
-    	return array($title_line, $line);
7076
+                $NoTestRes = 1;
7077
+            }
7078
+
7079
+            // The Result of Tests
7080
+            if (is_array($hpresults)) {
7081
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7082
+                    $title = GetQuizName($hpresults[$i][0],'');
7083
+
7084
+                    if ($title == '')
7085
+                    $title = basename($hpresults[$i][0]);
7086
+
7087
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7088
+
7089
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7090
+                }
7091
+            } else {
7092
+                $NoHPTestRes = 1;
7093
+            }
7094
+
7095
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7096
+                $line=get_lang('NoResult');
7097
+            }
7098
+        } else {
7099
+            $new_view = substr_replace($view,'1',1,1);
7100
+        }
7101
+        return array($title_line, $line);
7102 7102
     }
7103 7103
 
7104 7104
     /**
@@ -7107,37 +7107,37 @@  discard block
 block discarded – undo
7107 7107
      */
7108 7108
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7109 7109
     {
7110
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7110
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7111 7111
         $_course = api_get_course_info();
7112 7112
         $user_id = intval($user_id);
7113 7113
         $course_id = intval($course_id);
7114 7114
 
7115
-    	if (substr($view,2,1) == '1') {
7116
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7115
+        if (substr($view,2,1) == '1') {
7116
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7117 7117
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7118 7118
                     WHERE
7119 7119
                         u.upload_work_id = w.id AND
7120 7120
                         u.upload_user_id = '$user_id' AND
7121 7121
                         u.c_id = '$course_id'
7122 7122
                     ORDER BY u.upload_date DESC";
7123
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7124
-
7125
-    		$title[1]=get_lang('WorksDetails');
7126
-    		$line='';
7127
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7128
-
7129
-    		if (is_array($results)) {
7130
-    			for($j = 0 ; $j < count($results) ; $j++) {
7131
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7132
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7133
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7134
-    			}
7135
-
7136
-    		} else {
7137
-    			$line= get_lang('NoResult');
7138
-    		}
7139
-    	}
7140
-    	return array($title_line, $line);
7123
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7124
+
7125
+            $title[1]=get_lang('WorksDetails');
7126
+            $line='';
7127
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7128
+
7129
+            if (is_array($results)) {
7130
+                for($j = 0 ; $j < count($results) ; $j++) {
7131
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7132
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7133
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7134
+                }
7135
+
7136
+            } else {
7137
+                $line= get_lang('NoResult');
7138
+            }
7139
+        }
7140
+        return array($title_line, $line);
7141 7141
     }
7142 7142
 
7143 7143
     /**
@@ -7146,32 +7146,32 @@  discard block
 block discarded – undo
7146 7146
      */
7147 7147
     public function display_links_tracking_info($view, $userId, $courseCode)
7148 7148
     {
7149
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7149
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7150 7150
         $courseId = api_get_course_int_id($courseCode);
7151 7151
         $userId = intval($userId);
7152 7152
         $line = null;
7153
-    	if (substr($view,3,1) == '1') {
7154
-    		$new_view = substr_replace($view,'0',3,1);
7155
-    		$title[1]=get_lang('LinksDetails');
7156
-    		$sql = "SELECT cl.title, cl.url
7153
+        if (substr($view,3,1) == '1') {
7154
+            $new_view = substr_replace($view,'0',3,1);
7155
+            $title[1]=get_lang('LinksDetails');
7156
+            $sql = "SELECT cl.title, cl.url
7157 7157
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7158 7158
                         WHERE sl.links_link_id = cl.id
7159 7159
                             AND sl.c_id = $courseId
7160 7160
                             AND sl.links_user_id = $userId
7161 7161
                         GROUP BY cl.title, cl.url";
7162
-    		$results = StatsUtils::getManyResults2Col($sql);
7163
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7164
-    		if (is_array($results)) {
7165
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7166
-    				$line .= $results[$j][0]."\n";
7167
-    			}
7168
-    		} else {
7169
-    			$line=get_lang('NoResult');
7170
-    		}
7171
-    	} else {
7172
-    		$new_view = substr_replace($view,'1',3,1);
7173
-    	}
7174
-    	return array($title_line, $line);
7162
+            $results = StatsUtils::getManyResults2Col($sql);
7163
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7164
+            if (is_array($results)) {
7165
+                for ($j = 0 ; $j < count($results) ; $j++) {
7166
+                    $line .= $results[$j][0]."\n";
7167
+                }
7168
+            } else {
7169
+                $line=get_lang('NoResult');
7170
+            }
7171
+        } else {
7172
+            $new_view = substr_replace($view,'1',3,1);
7173
+        }
7174
+        return array($title_line, $line);
7175 7175
     }
7176 7176
 
7177 7177
     /**
@@ -7184,38 +7184,38 @@  discard block
 block discarded – undo
7184 7184
      */
7185 7185
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7186 7186
     {
7187
-    	// protect data
7188
-    	$user_id     = intval($user_id);
7187
+        // protect data
7188
+        $user_id     = intval($user_id);
7189 7189
         $courseId = api_get_course_int_id($courseCode);
7190
-    	$session_id = intval($session_id);
7190
+        $session_id = intval($session_id);
7191 7191
 
7192
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7192
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7193 7193
 
7194
-    	if (substr($view,4,1) == '1') {
7195
-    		$new_view = substr_replace($view,'0',4,1);
7196
-    		$title[1]= get_lang('DocumentsDetails');
7194
+        if (substr($view,4,1) == '1') {
7195
+            $new_view = substr_replace($view,'0',4,1);
7196
+            $title[1]= get_lang('DocumentsDetails');
7197 7197
 
7198
-    		$sql = "SELECT down_doc_path
7198
+            $sql = "SELECT down_doc_path
7199 7199
                         FROM $downloads_table
7200 7200
                         WHERE c_id = $courseId
7201 7201
                             AND down_user_id = $user_id
7202 7202
                             AND down_session_id = $session_id
7203 7203
                         GROUP BY down_doc_path";
7204 7204
 
7205
-    		$results = StatsUtils::getManyResults1Col($sql);
7206
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7205
+            $results = StatsUtils::getManyResults1Col($sql);
7206
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7207 7207
             $line = null;
7208
-    		if (is_array($results)) {
7209
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7210
-    				$line .= $results[$j]."\n";
7211
-    			}
7212
-    		} else {
7213
-    			$line = get_lang('NoResult');
7214
-    		}
7215
-    	} else {
7216
-    		$new_view = substr_replace($view,'1',4,1);
7217
-    	}
7218
-    	return array($title_line, $line);
7208
+            if (is_array($results)) {
7209
+                for ($j = 0 ; $j < count($results) ; $j++) {
7210
+                    $line .= $results[$j]."\n";
7211
+                }
7212
+            } else {
7213
+                $line = get_lang('NoResult');
7214
+            }
7215
+        } else {
7216
+            $new_view = substr_replace($view,'1',4,1);
7217
+        }
7218
+        return array($title_line, $line);
7219 7219
     }
7220 7220
 
7221 7221
     /**
Please login to merge, or discard this patch.
Spacing   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $extendedAttempt = null,
115 115
         $extendedAll = null,
116 116
         $type = 'classic',
117
-        $allowExtend =  true
117
+        $allowExtend = true
118 118
     ) {
119 119
         if (empty($courseInfo) || empty($lp_id)) {
120 120
             return null;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
         $extend_all = 0;
139 139
 
140 140
         if ($origin == 'tracking') {
141
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
141
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
142 142
         } else {
143
-            $url_suffix = '&lp_id=' . $lp_id;
143
+            $url_suffix = '&lp_id='.$lp_id;
144 144
         }
145 145
 
146 146
         if (!empty($extendedAll)) {
147 147
             $extend_all_link = Display::url(
148 148
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
149
-                api_get_self() . '?action=stats' . $url_suffix
149
+                api_get_self().'?action=stats'.$url_suffix
150 150
             );
151 151
 
152 152
             $extend_all = 1;
153 153
         } else {
154 154
             $extend_all_link = Display::url(
155 155
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
156
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
156
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
157 157
             );
158 158
         }
159 159
 
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 
166 166
         $actionColumn = null;
167 167
         if ($type == 'classic') {
168
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
168
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
169 169
         }
170 170
         $output .= '<div class="table-responsive">';
171 171
         $output .= '<table class="table tracking">
172 172
             <thead>
173 173
             <tr class="table-header">
174
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
174
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
175 175
                 <th colspan="4">
176
-                    ' . get_lang('ScormLessonTitle') .'
176
+                    ' . get_lang('ScormLessonTitle').'
177 177
                 </th>
178 178
                 <th colspan="2">
179
-                    ' . get_lang('ScormStatus') . '
179
+                    ' . get_lang('ScormStatus').'
180 180
                 </th>
181 181
                 <th colspan="2">
182
-                    ' . get_lang('ScormScore') . '
182
+                    ' . get_lang('ScormScore').'
183 183
                 </th>
184 184
                 <th colspan="2">
185
-                    ' . get_lang('ScormTime') . '
185
+                    ' . get_lang('ScormTime').'
186 186
                 </th>
187 187
                 '.$actionColumn.'
188 188
                 </tr>
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 // Prepare statement to go through each attempt.
246 246
                 $viewCondition = null;
247 247
                 if (!empty($view)) {
248
-                    $viewCondition =  " AND v.view_count = $view  ";
248
+                    $viewCondition = " AND v.view_count = $view  ";
249 249
                 }
250 250
 
251 251
                 $sql = "SELECT
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                                 FROM $TBL_QUIZ
294 294
                                 WHERE
295 295
                                     c_id = $course_id AND
296
-                                    id ='" . $my_path . "'";
296
+                                    id ='".$my_path."'";
297 297
                         $res_result_disabled = Database::query($sql);
298 298
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
299 299
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317 317
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
318
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                     $action = null;
335 335
                     if ($type == 'classic') {
336
-                        $action =  '<td></td>';
336
+                        $action = '<td></td>';
337 337
                     }
338 338
 
339 339
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
                                 $extend_this_attempt = 1;
378 378
                                 $extend_attempt_link = Display::url(
379 379
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
380
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
380
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
381 381
                                 );
382 382
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
383 383
                                 // The extend button for this attempt has not been clicked.
384 384
                                 $extend_attempt_link = Display::url(
385 385
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
386
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
386
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
387 387
                                 );
388 388
                             }
389 389
                         }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                         }
417 417
 
418 418
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
419
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
419
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
420 420
 
421 421
                         if ($row['item_type'] != 'dir') {
422 422
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
                                 $action = '<td></td>';
445 445
                             }
446 446
 
447
-                            $output .= '<tr class="' . $oddclass . '">
447
+                            $output .= '<tr class="'.$oddclass.'">
448 448
                                     <td></td>
449
-                                    <td>' . $extend_attempt_link . '</td>
450
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
451
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
452
-                                    <td colspan="2">' . $view_score . '</td>
453
-                                    <td colspan="2">' . $time . '</td>
449
+                                    <td>' . $extend_attempt_link.'</td>
450
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
451
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
452
+                                    <td colspan="2">' . $view_score.'</td>
453
+                                    <td colspan="2">' . $time.'</td>
454 454
                                     '.$action.'
455 455
                                 </tr>';
456 456
                             $attemptCount++;
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
464 464
                                         $temp[] = '/';
465 465
                                     } else {
466
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
466
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
467 467
                                     }
468 468
                                 } else {
469
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
469
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
470 470
                                 }
471 471
                                 $temp[] = $time;
472 472
                                 $csv_content[] = $temp;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
                                         <td></td>
504 504
                                         <td></td>
505 505
                                         <td></td>
506
-                                        <td>'.$interaction['order_id'] . '</td>
507
-                                        <td>'.$interaction['id'] . '</td>
506
+                                        <td>'.$interaction['order_id'].'</td>
507
+                                        <td>'.$interaction['id'].'</td>
508 508
                                         <td colspan="2">' . $interaction['type'].'</td>
509
-                                        <td>'.$student_response . '</td>
510
-                                        <td>'.$interaction['result'] . '</td>
511
-                                        <td>'.$interaction['latency'] . '</td>
512
-                                        <td>'.$interaction['time'] . '</td>
509
+                                        <td>'.$student_response.'</td>
510
+                                        <td>'.$interaction['result'].'</td>
511
+                                        <td>'.$interaction['latency'].'</td>
512
+                                        <td>'.$interaction['time'].'</td>
513 513
                                         '.$action.'
514 514
                                     </tr>';
515 515
                                 $counter++;
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
                                         <td></td>
527 527
                                         <td></td>
528 528
                                         <td></td>
529
-                                        <td>' . $interaction['order_id'] . '</td>
530
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
531
-                                        <td colspan="2">' . $interaction['status'] .'</td>
532
-                                        <td>' . $interaction['score_raw'] . '</td>
533
-                                        <td>' . $interaction['score_max'] . '</td>
534
-                                        <td>' . $interaction['score_min'] . '</td>
529
+                                        <td>' . $interaction['order_id'].'</td>
530
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
531
+                                        <td colspan="2">' . $interaction['status'].'</td>
532
+                                        <td>' . $interaction['score_raw'].'</td>
533
+                                        <td>' . $interaction['score_max'].'</td>
534
+                                        <td>' . $interaction['score_min'].'</td>
535 535
                                         '.$action.'
536 536
                                      </tr>';
537 537
                                 $counter++;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                         $my_path = Database::escape_string($my_path);
555 555
                         $sql = "SELECT results_disabled
556 556
                                 FROM $TBL_QUIZ
557
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
557
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
558 558
                         $res_result_disabled = Database::query($sql);
559 559
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
560 560
 
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
                             $extend_this_attempt = 1;
579 579
                             $extend_attempt_link = Display::url(
580 580
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
581
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
581
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
582 582
                             );
583 583
                         } else {
584 584
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
585 585
                             // The extend button for this attempt has not been clicked.
586 586
                             $extend_attempt_link = Display::url(
587 587
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
588
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
588
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
589 589
                             );
590 590
                         }
591 591
                     }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                     if ($inter_num > 1) {
601 601
                         $extend_link = Display::url(
602 602
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
603
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
603
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
604 604
                         );
605 605
                     }
606 606
 
@@ -616,15 +616,15 @@  discard block
 block discarded – undo
616 616
 
617 617
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
618 618
 
619
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
619
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
620 620
                              WHERE
621
-                                exe_exo_id="' . $row['path'] . '" AND
622
-                                exe_user_id="' . $user_id . '" AND
623
-                                orig_lp_id = "' . $lp_id . '" AND
624
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
625
-                                c_id = ' . $course_id . ' AND
621
+                                exe_exo_id="' . $row['path'].'" AND
622
+                                exe_user_id="' . $user_id.'" AND
623
+                                orig_lp_id = "' . $lp_id.'" AND
624
+                                orig_lp_item_id = "' . $row['myid'].'" AND
625
+                                c_id = ' . $course_id.' AND
626 626
                                 status <> "incomplete" AND
627
-                                session_id = ' . $session_id . '
627
+                                session_id = ' . $session_id.'
628 628
                              ORDER BY exe_date DESC
629 629
                              LIMIT 1';
630 630
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
                                         FROM $TBL_LP_ITEM_VIEW
656 656
                                         WHERE
657 657
                                             c_id = $course_id AND
658
-                                            lp_item_id = '" . (int) $my_id . "' AND
659
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
658
+                                            lp_item_id = '".(int) $my_id."' AND
659
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
660 660
                                         ORDER BY view_count DESC limit 1";
661 661
                                 $res_score = Database::query($sql);
662 662
                                 $row_score = Database::fetch_array($res_score);
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
                                         FROM $TBL_LP_ITEM_VIEW
666 666
                                         WHERE
667 667
                                             c_id = $course_id AND
668
-                                            lp_item_id = '" . (int) $my_id . "' AND
669
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
668
+                                            lp_item_id = '".(int) $my_id."' AND
669
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
670 670
                                 $res_time = Database::query($sql);
671 671
                                 $row_time = Database::fetch_array($res_time);
672 672
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
                     } else {
726 726
                         $correct_test_link = '-';
727 727
                         if ($row['item_type'] == 'quiz') {
728
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
729
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
728
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
729
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
730 730
                                      WHERE
731
-                                        exe_exo_id="' . $row['path'] . '" AND
732
-                                        exe_user_id="' . $user_id . '" AND
733
-                                        orig_lp_id = "' . $lp_id . '" AND
734
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
735
-                                        c_id = ' . $course_id . ' AND
731
+                                        exe_exo_id="' . $row['path'].'" AND
732
+                                        exe_user_id="' . $user_id.'" AND
733
+                                        orig_lp_id = "' . $lp_id.'" AND
734
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
735
+                                        c_id = ' . $course_id.' AND
736 736
                                         status <> "incomplete" AND
737
-                                        session_id = ' . $session_id . '
737
+                                        session_id = ' . $session_id.'
738 738
                                      ORDER BY exe_date DESC ';
739 739
 
740 740
                             $resultLastAttempt = Database::query($sql);
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
                                 ) {
747 747
                                     $correct_test_link = Display::url(
748 748
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
749
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
749
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
750 750
                                     );
751 751
                                 } else {
752 752
                                     $correct_test_link = Display::url(
753 753
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
754
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
754
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
755 755
                                     );
756 756
                                 }
757 757
                             }
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 
762 762
                         $action = null;
763 763
                         if ($type == 'classic') {
764
-                            $action =  '<td>' . $correct_test_link . '</td>';
764
+                            $action = '<td>'.$correct_test_link.'</td>';
765 765
                         }
766 766
 
767 767
                         if ($lp_id == $my_lp_id && false) {
768 768
 
769
-                            $output .= '<tr class =' . $oddclass . '>
770
-                                    <td>' . $extend_link . '</td>
771
-                                    <td colspan="4">' . $title . '</td>
769
+                            $output .= '<tr class ='.$oddclass.'>
770
+                                    <td>' . $extend_link.'</td>
771
+                                    <td colspan="4">' . $title.'</td>
772 772
                                     <td colspan="2">&nbsp;</td>
773 773
                                     <td colspan="2">&nbsp;</td>
774 774
                                     <td colspan="2">&nbsp;</td>
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
794 794
                                 }
795 795
                             } else {
796
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
796
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
797 797
                             }
798 798
 
799 799
                             $output .= '
800 800
                                 <td>'.$extend_link.'</td>
801
-                                <td colspan="4">' . $title . '</td>
802
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
801
+                                <td colspan="4">' . $title.'</td>
802
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
803 803
                                 <td colspan="2">'.$scoreItem.'</td>
804 804
                                 <td colspan="2">'.$time.'</td>
805 805
                                 '.$action.'
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
817 817
                                     $temp[] = '/';
818 818
                                 } else {
819
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
819
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
820 820
                                 }
821 821
                             } else {
822
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
822
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
823 823
                             }
824 824
                             $temp[] = $time;
825 825
                             $csv_content[] = $temp;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 
831 831
                     $action = null;
832 832
                     if ($type == 'classic') {
833
-                        $action =  '<td></td>';
833
+                        $action = '<td></td>';
834 834
                     }
835 835
 
836 836
                     if ($extend_this_attempt || $extend_all) {
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
                                     <td></td>
868 868
                                     <td></td>
869 869
                                     <td></td>
870
-                                    <td>' . $interaction['order_id'] . '</td>
871
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
872
-                                    <td colspan="2">' . $interaction['status'] . '</td>
870
+                                    <td>' . $interaction['order_id'].'</td>
871
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
872
+                                    <td colspan="2">' . $interaction['status'].'</td>
873 873
                                     <td>' . $interaction['score_raw'].'</td>
874
-                                    <td>' . $interaction['score_max'] .'</td>
874
+                                    <td>' . $interaction['score_max'].'</td>
875 875
                                     <td>' . $interaction['score_min'].'</td>
876 876
                                     '.$action.'
877 877
                                </tr>';
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
                     }
881 881
 
882 882
                     // Attempts listing by exercise.
883
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
883
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
884 884
                         // Get attempts of a exercise.
885 885
                         if (!empty($lp_id) &&
886 886
                             !empty($lp_item_id) &&
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
                             $row_path = Database::fetch_array($res_path);
896 896
 
897 897
                             if (Database::num_rows($res_path) > 0) {
898
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
898
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
899 899
                                         WHERE
900
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
900
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
901 901
                                             status <> "incomplete" AND
902
-                                            exe_user_id="' . $user_id . '" AND
903
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
904
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
905
-                                            c_id = ' . $course_id . '  AND
906
-                                            session_id = ' . $session_id . '
902
+                                            exe_user_id="' . $user_id.'" AND
903
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
904
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
905
+                                            c_id = ' . $course_id.'  AND
906
+                                            session_id = ' . $session_id.'
907 907
                                         ORDER BY exe_date';
908 908
                                 $res_attempts = Database::query($sql);
909 909
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
                                         if ($mktime_start_date && $mktime_exe_date) {
922 922
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
923 923
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
924
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
924
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
925 925
                                         } else {
926 926
                                             $time_attemp = ' - ';
927 927
                                         }
@@ -947,33 +947,33 @@  discard block
 block discarded – undo
947 947
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
948 948
                                         }
949 949
 
950
-                                        $output .= '<tr class="' . $oddclass . '" >
950
+                                        $output .= '<tr class="'.$oddclass.'" >
951 951
                                         <td></td>
952
-                                        <td>' . $extend_attempt_link . '</td>
953
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
954
-                                        <td colspan="2">' . $my_lesson_status . '</td>
955
-                                        <td colspan="2">'.$view_score . '</td>
956
-                                        <td colspan="2">'.$time_attemp . '</td>';
952
+                                        <td>' . $extend_attempt_link.'</td>
953
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
954
+                                        <td colspan="2">' . $my_lesson_status.'</td>
955
+                                        <td colspan="2">'.$view_score.'</td>
956
+                                        <td colspan="2">'.$time_attemp.'</td>';
957 957
                                         if ($action == 'classic') {
958 958
                                             if ($origin != 'tracking') {
959 959
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
960 960
                                                     $output .= '<td>
961
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
961
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
962 962
                                                             </td>';
963 963
                                                 } else {
964 964
                                                     $output .= '<td>
965
-                                                            <a href="../exercise/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
966
-                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
965
+                                                            <a href="../exercise/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
966
+                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
967 967
                                                             </a></td>';
968 968
                                                 }
969 969
                                             } else {
970 970
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
971 971
                                                     $output .= '<td>
972
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
972
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
973 973
                                                 } else {
974 974
                                                     $output .= '<td>
975
-                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
976
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
975
+                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
976
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
977 977
                                                 }
978 978
                                             }
979 979
                                         }
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
         }
1033 1033
 
1034 1034
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1035
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1035
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1036 1036
 
1037 1037
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1038 1038
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1039 1039
         } else {
1040 1040
             if (is_numeric($total_score)) {
1041
-                $final_score = $total_score . '%';
1041
+                $final_score = $total_score.'%';
1042 1042
             } else {
1043 1043
                 $final_score = $total_score;
1044 1044
             }
@@ -1054,19 +1054,19 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
         $action = null;
1056 1056
         if ($type == 'classic') {
1057
-            $action =  '<td></td>';
1057
+            $action = '<td></td>';
1058 1058
         }
1059 1059
 
1060 1060
         $output .= '<tr class="'.$oddclass.'">
1061 1061
                 <td></td>
1062 1062
                 <td colspan="4">
1063
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1063
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1064 1064
                 </td>
1065 1065
                 <td colspan="2">'.$progress.'%</td>
1066 1066
                 <td colspan="2">
1067 1067
                     ' . $final_score.'
1068 1068
                 </td>
1069
-                <td colspan="2">' . $total_time . '</div>
1069
+                <td colspan="2">' . $total_time.'</div>
1070 1070
                 '.$action.'
1071 1071
            </tr>';
1072 1072
 
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411 1411
     	if (is_array($user_id)) {
1412 1412
     	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1413
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1414 1414
     	} else {
1415 1415
     		$user_id = intval($user_id);
1416 1416
     		$condition_user = " AND user_id = $user_id ";
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
     {
1447 1447
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448 1448
     	$sql = 'SELECT login_date
1449
-    	        FROM ' . $tbl_track_login . '
1450
-                WHERE login_user_id = ' . intval($student_id) . '
1449
+    	        FROM ' . $tbl_track_login.'
1450
+                WHERE login_user_id = ' . intval($student_id).'
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454 1454
     	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1455
+    	if (Database::num_rows($rs) > 0) {
1456 1456
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
     {
1478 1478
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479 1479
     	$sql = 'SELECT login_date
1480
-    	        FROM ' . $table . '
1481
-                WHERE login_user_id = ' . intval($student_id) . '
1480
+    	        FROM ' . $table.'
1481
+                WHERE login_user_id = ' . intval($student_id).'
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
@@ -1487,18 +1487,18 @@  discard block
 block discarded – undo
1487 1487
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1488 1488
     			$last_login_date = api_get_local_time($last_login_date);
1489 1489
     			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1490
+    				return api_strtotime($last_login_date, 'UTC');
1491 1491
     			} else {
1492 1492
     				if (!$warning_message) {
1493 1493
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494 1494
     				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1495
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1496 1496
     					$currentTimestamp = time();
1497 1497
 
1498 1498
     					//If the last connection is > than 7 days, the text is red
1499 1499
     					//345600 = 7 days in seconds
1500 1500
     					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1501
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1502 1502
     					} else {
1503 1503
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504 1504
     					}
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
         $sql = "$select
1534 1534
                 FROM $tbl_track_login
1535 1535
                 WHERE
1536
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1536
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1537 1537
                     login_date < '$date'
1538 1538
                 ";
1539 1539
         $rs = Database::query($sql);
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1635
+    					return $icon.Display::label($last_login_date, 'warning');
1636 1636
     				} else {
1637 1637
     					return $last_login_date;
1638 1638
     				}
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
                     session_id = $session_id
1683 1683
                     $month_filter";
1684 1684
     	$rs = Database::query($sql);
1685
-    	if (Database::num_rows($rs)>0) {
1685
+    	if (Database::num_rows($rs) > 0) {
1686 1686
     		$row = Database::fetch_object($rs);
1687 1687
     		$count = $row->count_connections;
1688 1688
     	}
@@ -1703,14 +1703,14 @@  discard block
 block discarded – undo
1703 1703
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1704 1704
 
1705 1705
     	$sql = 'SELECT DISTINCT c_id
1706
-                FROM ' . $tbl_course_rel_user . '
1706
+                FROM ' . $tbl_course_rel_user.'
1707 1707
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1708 1708
     	$rs = Database::query($sql);
1709 1709
     	$nb_courses = Database::num_rows($rs);
1710 1710
 
1711 1711
     	if ($include_sessions) {
1712 1712
     		$sql = 'SELECT DISTINCT c_id
1713
-                    FROM ' . $tbl_session_course_rel_user . '
1713
+                    FROM ' . $tbl_session_course_rel_user.'
1714 1714
                     WHERE user_id = ' . $user_id;
1715 1715
     		$rs = Database::query($sql);
1716 1716
     		$nb_courses += Database::num_rows($rs);
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
     		$condition_quiz = "";
1758 1758
     		if (!empty($exercise_id)) {
1759 1759
     			$exercise_id = intval($exercise_id);
1760
-    			$condition_quiz =" AND id = $exercise_id ";
1760
+    			$condition_quiz = " AND id = $exercise_id ";
1761 1761
     		}
1762 1762
 
1763 1763
     		// Compose a filter based on optional session id given
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
                         }
1811 1811
                     }
1812 1812
                     if (!empty($exercise_list)) {
1813
-                        $exercise_id = implode("','",$exercise_list);
1813
+                        $exercise_id = implode("','", $exercise_list);
1814 1814
                     }
1815 1815
     			}
1816 1816
 
@@ -1835,10 +1835,10 @@  discard block
 block discarded – undo
1835 1835
     			$quiz_avg_score = null;
1836 1836
 
1837 1837
     			if (!empty($row['avg_score'])) {
1838
-    				$quiz_avg_score = round($row['avg_score'],2);
1838
+    				$quiz_avg_score = round($row['avg_score'], 2);
1839 1839
     			}
1840 1840
 
1841
-    			if(!empty($row['num_attempts'])) {
1841
+    			if (!empty($row['num_attempts'])) {
1842 1842
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1843 1843
     			}
1844 1844
     			if (is_array($student_id)) {
@@ -1968,7 +1968,7 @@  discard block
 block discarded – undo
1968 1968
             $row = Database::fetch_row($rs);
1969 1969
             $count = $row[0];
1970 1970
         }
1971
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1971
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
1972 1972
         return $count;
1973 1973
     }
1974 1974
 
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
                 );
1994 1994
 
1995 1995
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
1996
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
1996
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
1997 1997
                 }
1998 1998
             }
1999 1999
             $result = $result / count($exercise_list);
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
         $query = sprintf($sql, intval($courseId), $sessionId);
2031 2031
         $rs = Database::query($query);
2032 2032
         $teachers = array();
2033
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2033
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2034 2034
             $teachers[] = $teacher;
2035 2035
         }
2036 2036
         $data = array();
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
             $data[] = array(
2155 2155
                 'course' => $course['title'],
2156 2156
                 'session' => $teacher['name'],
2157
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2157
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2158 2158
                 'documents' => $totalDocuments,
2159 2159
                 'links' => $totalLinks,
2160 2160
                 'forums' => $totalForums,
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
             for ($i = 0; $i < count($lpIdList); $i++) {
2218 2218
                 $placeHolders[] = '?';
2219 2219
             }
2220
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2220
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2221 2221
         }
2222 2222
 
2223 2223
         if ($onlySeriousGame) {
@@ -2237,14 +2237,14 @@  discard block
 block discarded – undo
2237 2237
 
2238 2238
         $conditions = [
2239 2239
             " c_id = {$courseInfo['real_id']} ",
2240
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2240
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2241 2241
         ];
2242 2242
 
2243 2243
         $groupBy = 'GROUP BY lp_id';
2244 2244
 
2245 2245
         if (is_array($studentId)) {
2246 2246
             $studentId = array_map('intval', $studentId);
2247
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2247
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2248 2248
 
2249 2249
 
2250 2250
         } else {
@@ -2379,7 +2379,7 @@  discard block
 block discarded – undo
2379 2379
             // Compose a filter based on optional learning paths list given
2380 2380
             $condition_lp = "";
2381 2381
             if (count($lp_ids) > 0) {
2382
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2382
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2383 2383
             }
2384 2384
 
2385 2385
             // Compose a filter based on optional session id
@@ -2419,9 +2419,9 @@  discard block
 block discarded – undo
2419 2419
             // prepare filter on users
2420 2420
             if (is_array($student_id)) {
2421 2421
                 array_walk($student_id, 'intval');
2422
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2422
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2423 2423
             } else {
2424
-                $condition_user1 =" AND user_id = $student_id ";
2424
+                $condition_user1 = " AND user_id = $student_id ";
2425 2425
             }
2426 2426
 
2427 2427
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
                                     ORDER BY lp_item_id";
2465 2465
                             $res_lp_item = Database::query($sql);
2466 2466
 
2467
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2467
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2468 2468
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2469 2469
 
2470 2470
                                 // Getting the most recent attempt
@@ -2487,8 +2487,8 @@  discard block
 block discarded – undo
2487 2487
                                         ORDER BY view_count DESC
2488 2488
                                         LIMIT 1";
2489 2489
                                 $res_lp_item_result = Database::query($sql);
2490
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2491
-                                    $list[]= $row_max_score;
2490
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2491
+                                    $list[] = $row_max_score;
2492 2492
                                 }
2493 2493
                             }
2494 2494
                         } else {
@@ -2512,8 +2512,8 @@  discard block
 block discarded – undo
2512 2512
                             if ($debug) echo $sql.'<br />';
2513 2513
                             $res_max_score = Database::query($sql);
2514 2514
 
2515
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2516
-                                $list[]= $row_max_score;
2515
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2516
+                                $list[] = $row_max_score;
2517 2517
                             }
2518 2518
                         }
2519 2519
 
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2529 2529
                             $score = $row_max_score['score'];
2530 2530
 
2531
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2531
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2532 2532
 
2533 2533
                             if ($row_max_score['item_type'] == 'sco') {
2534 2534
                                 /* Check if it is sco (easier to get max_score)
@@ -2546,7 +2546,7 @@  discard block
 block discarded – undo
2546 2546
                                 }
2547 2547
                                 // Avoid division by zero errors
2548 2548
                                 if (!empty($max_score)) {
2549
-                                    $lp_partial_total += $score/$max_score;
2549
+                                    $lp_partial_total += $score / $max_score;
2550 2550
                                 }
2551 2551
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2552 2552
                             } else {
@@ -2570,10 +2570,10 @@  discard block
 block discarded – undo
2570 2570
                                         ORDER BY exe_date DESC
2571 2571
                                         LIMIT 1";
2572 2572
 
2573
-                                if ($debug) echo $sql .'<br />';
2573
+                                if ($debug) echo $sql.'<br />';
2574 2574
                                 $result_last_attempt = Database::query($sql);
2575 2575
                                 $num = Database :: num_rows($result_last_attempt);
2576
-                                if ($num > 0 ) {
2576
+                                if ($num > 0) {
2577 2577
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2578 2578
                                     if ($debug) echo $id_last_attempt.'<br />';
2579 2579
 
@@ -2602,13 +2602,13 @@  discard block
 block discarded – undo
2602 2602
                                         $max_score = $row_max_score_bis['maxscore'];
2603 2603
                                     }
2604 2604
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2605
-                                        $lp_partial_total += $score/$max_score;
2605
+                                        $lp_partial_total += $score / $max_score;
2606 2606
                                     }
2607 2607
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2608 2608
                                 }
2609 2609
                             }
2610 2610
 
2611
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2611
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2612 2612
                                 // Normal way
2613 2613
                                 if ($use_max_score[$lp_id]) {
2614 2614
                                     $count_items++;
@@ -2643,8 +2643,8 @@  discard block
 block discarded – undo
2643 2643
                     if ($debug) echo $sql;
2644 2644
                     $result_have_quiz = Database::query($sql);
2645 2645
 
2646
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2647
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2646
+                    if (Database::num_rows($result_have_quiz) > 0) {
2647
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2648 2648
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2649 2649
                             $lp_with_quiz++;
2650 2650
                         }
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 
2657 2657
                 if ($lp_with_quiz != 0) {
2658 2658
                     if (!$return_array) {
2659
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2659
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2660 2660
                         if ($debug) var_dump($score_of_scorm_calculate);
2661 2661
                         if (empty($lp_ids)) {
2662 2662
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2730,9 +2730,9 @@  discard block
 block discarded – undo
2730 2730
 
2731 2731
         if (is_array($student_id)) {
2732 2732
             array_walk($student_id, 'intval');
2733
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2733
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2734 2734
         } else {
2735
-            $conditions[] =" lp_view.user_id = $student_id ";
2735
+            $conditions[] = " lp_view.user_id = $student_id ";
2736 2736
         }
2737 2737
 
2738 2738
         $conditionsToString = implode('AND ', $conditions);
@@ -2756,7 +2756,7 @@  discard block
 block discarded – undo
2756 2756
             return 0;
2757 2757
         }
2758 2758
 
2759
-        return ($row['sum_score'] / $row['sum_max_score'])*100;
2759
+        return ($row['sum_score'] / $row['sum_max_score']) * 100;
2760 2760
 
2761 2761
     }
2762 2762
 
@@ -2786,7 +2786,7 @@  discard block
 block discarded – undo
2786 2786
             // Compose a filter based on optional learning paths list given
2787 2787
             $condition_lp = "";
2788 2788
             if (count($lp_ids) > 0) {
2789
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2789
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2790 2790
             }
2791 2791
 
2792 2792
             // Compose a filter based on optional session id
@@ -2848,7 +2848,7 @@  discard block
 block discarded – undo
2848 2848
 
2849 2849
         if (!empty($course)) {
2850 2850
 
2851
-            $course_id	 = $course['real_id'];
2851
+            $course_id = $course['real_id'];
2852 2852
 
2853 2853
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2854 2854
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2862,8 +2862,8 @@  discard block
 block discarded – undo
2862 2862
             // calculates last connection time
2863 2863
             if ($count_row_lp > 0) {
2864 2864
                 $sql = 'SELECT MAX(start_time)
2865
-                        FROM ' . $t_lpiv . ' AS item_view
2866
-                        INNER JOIN ' . $t_lpv . ' AS view
2865
+                        FROM ' . $t_lpiv.' AS item_view
2866
+                        INNER JOIN ' . $t_lpv.' AS view
2867 2867
                             ON item_view.lp_view_id = view.id
2868 2868
                         WHERE
2869 2869
                             item_view.c_id 		= '.$course_id.' AND
@@ -2899,15 +2899,15 @@  discard block
 block discarded – undo
2899 2899
 
2900 2900
         // At first, courses where $coach_id is coach of the course //
2901 2901
         $sql = 'SELECT session_id, c_id
2902
-                FROM ' . $tbl_session_course_user . '
2902
+                FROM ' . $tbl_session_course_user.'
2903 2903
                 WHERE user_id=' . $coach_id.' AND status=2';
2904 2904
 
2905 2905
         if (api_is_multiple_url_enabled()) {
2906
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2906
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2907 2907
             $access_url_id = api_get_current_access_url_id();
2908 2908
             if ($access_url_id != -1) {
2909 2909
                 $sql = 'SELECT scu.session_id, scu.c_id
2910
-                    FROM ' . $tbl_session_course_user . ' scu
2910
+                    FROM ' . $tbl_session_course_user.' scu
2911 2911
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2912 2912
                     ON (scu.session_id=sru.session_id)
2913 2913
                     WHERE
@@ -2941,28 +2941,28 @@  discard block
 block discarded – undo
2941 2941
 
2942 2942
         // Then, courses where $coach_id is coach of the session    //
2943 2943
         $sql = 'SELECT session_course_user.user_id
2944
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2944
+                FROM ' . $tbl_session_course_user.' as session_course_user
2945 2945
                 INNER JOIN     '.$tbl_session_user.' sru
2946 2946
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2947
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2947
+                INNER JOIN ' . $tbl_session_course.' as session_course
2948 2948
                 ON session_course.c_id = session_course_user.c_id
2949 2949
                 AND session_course_user.session_id = session_course.session_id
2950
-                INNER JOIN ' . $tbl_session . ' as session
2950
+                INNER JOIN ' . $tbl_session.' as session
2951 2951
                 ON session.id = session_course.session_id
2952 2952
                 AND session.id_coach = ' . $coach_id;
2953 2953
         if (api_is_multiple_url_enabled()) {
2954
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2954
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2955 2955
             $access_url_id = api_get_current_access_url_id();
2956
-            if ($access_url_id != -1){
2956
+            if ($access_url_id != -1) {
2957 2957
                 $sql = 'SELECT session_course_user.user_id
2958
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2958
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2959 2959
                         INNER JOIN     '.$tbl_session_user.' sru
2960 2960
                             ON session_course_user.user_id = sru.user_id AND
2961 2961
                                session_course_user.session_id = sru.session_id
2962
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2962
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2963 2963
                             ON session_course.c_id = session_course_user.c_id AND
2964 2964
                             session_course_user.session_id = session_course.session_id
2965
-                        INNER JOIN ' . $tbl_session . ' as session
2965
+                        INNER JOIN ' . $tbl_session.' as session
2966 2966
                             ON session.id = session_course.session_id AND
2967 2967
                             session.id_coach = ' . $coach_id.'
2968 2968
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -2992,8 +2992,8 @@  discard block
 block discarded – undo
2992 2992
 
2993 2993
         $students = [];
2994 2994
         // At first, courses where $coach_id is coach of the course //
2995
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
2996
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
2995
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
2996
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
2997 2997
         $result = Database::query($sql);
2998 2998
 
2999 2999
         while ($a_courses = Database::fetch_array($result)) {
@@ -3003,7 +3003,7 @@  discard block
 block discarded – undo
3003 3003
                     FROM $tbl_session_course_user AS srcru
3004 3004
                     WHERE
3005 3005
                         c_id = '$courseId' AND
3006
-                        session_id = '" . $id_session . "'";
3006
+                        session_id = '".$id_session."'";
3007 3007
             $rs = Database::query($sql);
3008 3008
             while ($row = Database::fetch_array($rs)) {
3009 3009
                 $students[$row['user_id']] = $row['user_id'];
@@ -3011,15 +3011,15 @@  discard block
 block discarded – undo
3011 3011
         }
3012 3012
 
3013 3013
         // Then, courses where $coach_id is coach of the session
3014
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3015
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3014
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3015
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3016 3016
         $result = Database::query($sql);
3017 3017
 
3018 3018
         //He is the session_coach so we select all the users in the session
3019 3019
         if (Database::num_rows($result) > 0) {
3020 3020
             $sql = 'SELECT DISTINCT srcru.user_id
3021
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3022
-                    WHERE session_id="' . $id_session . '"';
3021
+                    FROM ' . $tbl_session_course_user.' AS srcru
3022
+                    WHERE session_id="' . $id_session.'"';
3023 3023
             $result = Database::query($sql);
3024 3024
             while ($row = Database::fetch_array($result)) {
3025 3025
                 $students[$row['user_id']] = $row['user_id'];
@@ -3046,8 +3046,8 @@  discard block
 block discarded – undo
3046 3046
 
3047 3047
         // At first, courses where $coach_id is coach of the course //
3048 3048
 
3049
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3050
-                WHERE user_id=' . $coach_id .' AND status=2';
3049
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3050
+                WHERE user_id=' . $coach_id.' AND status=2';
3051 3051
         $result = Database::query($sql);
3052 3052
         if (Database::num_rows($result) > 0) {
3053 3053
             return true;
@@ -3055,12 +3055,12 @@  discard block
 block discarded – undo
3055 3055
 
3056 3056
         // Then, courses where $coach_id is coach of the session
3057 3057
         $sql = 'SELECT session_course_user.user_id
3058
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3059
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3058
+                FROM ' . $tbl_session_course_user.' as session_course_user
3059
+                INNER JOIN ' . $tbl_session_course.' as session_course
3060 3060
                     ON session_course.c_id = session_course_user.c_id
3061
-                INNER JOIN ' . $tbl_session . ' as session
3061
+                INNER JOIN ' . $tbl_session.' as session
3062 3062
                     ON session.id = session_course.session_id
3063
-                    AND session.id_coach = ' . $coach_id . '
3063
+                    AND session.id_coach = ' . $coach_id.'
3064 3064
                 WHERE user_id = ' . $student_id;
3065 3065
         $result = Database::query($sql);
3066 3066
         if (Database::num_rows($result) > 0) {
@@ -3092,16 +3092,16 @@  discard block
 block discarded – undo
3092 3092
         // At first, courses where $coach_id is coach of the course.
3093 3093
 
3094 3094
         $sql = 'SELECT DISTINCT c.code
3095
-                FROM ' . $tbl_session_course_user . ' sc
3095
+                FROM ' . $tbl_session_course_user.' sc
3096 3096
                 INNER JOIN '.$tbl_course.' c
3097 3097
                 ON (c.id = sc.c_id)
3098 3098
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3099 3099
 
3100 3100
         if (api_is_multiple_url_enabled()) {
3101 3101
             $access_url_id = api_get_current_access_url_id();
3102
-            if ($access_url_id != -1){
3102
+            if ($access_url_id != -1) {
3103 3103
                 $sql = 'SELECT DISTINCT c.code
3104
-                        FROM ' . $tbl_session_course_user . ' scu
3104
+                        FROM ' . $tbl_session_course_user.' scu
3105 3105
                         INNER JOIN '.$tbl_course.' c
3106 3106
                         ON (c.code = scu.c_id)
3107 3107
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3114,7 +3114,7 @@  discard block
 block discarded – undo
3114 3114
         }
3115 3115
 
3116 3116
         if (!empty($id_session)) {
3117
-            $sql .= ' AND session_id=' . $id_session;
3117
+            $sql .= ' AND session_id='.$id_session;
3118 3118
         }
3119 3119
 
3120 3120
         $courseList = array();
@@ -3126,25 +3126,25 @@  discard block
 block discarded – undo
3126 3126
         // Then, courses where $coach_id is coach of the session
3127 3127
 
3128 3128
         $sql = 'SELECT DISTINCT course.code
3129
-                FROM ' . $tbl_session_course . ' as session_course
3130
-                INNER JOIN ' . $tbl_session . ' as session
3129
+                FROM ' . $tbl_session_course.' as session_course
3130
+                INNER JOIN ' . $tbl_session.' as session
3131 3131
                     ON session.id = session_course.session_id
3132
-                    AND session.id_coach = ' . $coach_id . '
3133
-                INNER JOIN ' . $tbl_course . ' as course
3132
+                    AND session.id_coach = ' . $coach_id.'
3133
+                INNER JOIN ' . $tbl_course.' as course
3134 3134
                     ON course.id = session_course.c_id';
3135 3135
 
3136 3136
         if (api_is_multiple_url_enabled()) {
3137 3137
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3138 3138
             $access_url_id = api_get_current_access_url_id();
3139
-            if ($access_url_id != -1){
3139
+            if ($access_url_id != -1) {
3140 3140
                 $sql = 'SELECT DISTINCT c.code
3141
-                    FROM ' . $tbl_session_course . ' as session_course
3141
+                    FROM ' . $tbl_session_course.' as session_course
3142 3142
                     INNER JOIN '.$tbl_course.' c
3143 3143
                     ON (c.id = session_course.c_id)
3144
-                    INNER JOIN ' . $tbl_session . ' as session
3144
+                    INNER JOIN ' . $tbl_session.' as session
3145 3145
                     ON session.id = session_course.session_id
3146
-                        AND session.id_coach = ' . $coach_id . '
3147
-                    INNER JOIN ' . $tbl_course . ' as course
3146
+                        AND session.id_coach = ' . $coach_id.'
3147
+                    INNER JOIN ' . $tbl_course.' as course
3148 3148
                         ON course.id = session_course.c_id
3149 3149
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3150 3150
                     ON (course_rel_url.c_id = c.id)';
@@ -3152,12 +3152,12 @@  discard block
 block discarded – undo
3152 3152
         }
3153 3153
 
3154 3154
         if (!empty ($id_session)) {
3155
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3155
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3156 3156
             if (api_is_multiple_url_enabled())
3157
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3158
-        }  else {
3157
+            $sql .= ' AND access_url_id = '.$access_url_id;
3158
+        } else {
3159 3159
             if (api_is_multiple_url_enabled())
3160
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3160
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3161 3161
         }
3162 3162
 
3163 3163
         $result = Database::query($sql);
@@ -3213,7 +3213,7 @@  discard block
 block discarded – undo
3213 3213
             }
3214 3214
         }
3215 3215
 
3216
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3216
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3217 3217
         $access_url_id = api_get_current_access_url_id();
3218 3218
 
3219 3219
         $sql = "
@@ -3333,7 +3333,7 @@  discard block
 block discarded – undo
3333 3333
             // table definition
3334 3334
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3335 3335
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3336
-            $course_id	 = $a_course['real_id'];
3336
+            $course_id = $a_course['real_id'];
3337 3337
             if (is_array($student_id)) {
3338 3338
                 $studentList = array_map('intval', $student_id);
3339 3339
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
         $a_course = CourseManager::get_course_information($course_code);
3385 3385
         if (!empty($a_course)) {
3386 3386
             $course_id = $a_course['real_id'];
3387
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3387
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3388 3388
         }
3389 3389
 
3390 3390
         // table definition
@@ -3393,14 +3393,14 @@  discard block
 block discarded – undo
3393 3393
 
3394 3394
         if (is_array($student_id)) {
3395 3395
             $studentList = array_map('intval', $student_id);
3396
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3396
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3397 3397
         } else {
3398 3398
             $student_id = intval($student_id);
3399
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3399
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3400 3400
         }
3401 3401
         if (isset($session_id)) {
3402 3402
             $session_id = intval($session_id);
3403
-            $conditions[]= " pub.session_id = $session_id ";
3403
+            $conditions[] = " pub.session_id = $session_id ";
3404 3404
         }
3405 3405
         $conditionToString = implode('AND', $conditions);
3406 3406
 
@@ -3433,8 +3433,8 @@  discard block
 block discarded – undo
3433 3433
         $courseCondition = null;
3434 3434
         $conditions = array();
3435 3435
         if (!empty($courseInfo)) {
3436
-            $course_id	    = $courseInfo['real_id'];
3437
-            $conditions[]= " post.c_id  = $course_id AND forum.c_id = $course_id ";
3436
+            $course_id = $courseInfo['real_id'];
3437
+            $conditions[] = " post.c_id  = $course_id AND forum.c_id = $course_id ";
3438 3438
         }
3439 3439
 
3440 3440
         // Table definition.
@@ -3443,15 +3443,15 @@  discard block
 block discarded – undo
3443 3443
 
3444 3444
         if (is_array($student_id)) {
3445 3445
             $studentList = array_map('intval', $student_id);
3446
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3446
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3447 3447
         } else {
3448 3448
             $student_id = intval($student_id);
3449
-            $conditions[]= " post.poster_id = '$student_id' ";
3449
+            $conditions[] = " post.poster_id = '$student_id' ";
3450 3450
         }
3451 3451
 
3452 3452
         if (isset($session_id)) {
3453 3453
             $session_id = intval($session_id);
3454
-            $conditions[]= " forum.session_id = $session_id";
3454
+            $conditions[] = " forum.session_id = $session_id";
3455 3455
         }
3456 3456
 
3457 3457
         $conditionsToString = implode('AND ', $conditions);
@@ -3486,7 +3486,7 @@  discard block
 block discarded – undo
3486 3486
             $condition_session = '';
3487 3487
             if (isset($session_id)) {
3488 3488
                 $session_id = intval($session_id);
3489
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3489
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3490 3490
             }
3491 3491
 
3492 3492
             $course_id = $courseInfo['real_id'];
@@ -3542,7 +3542,7 @@  discard block
 block discarded – undo
3542 3542
         $condition_session = '';
3543 3543
         if (isset($session_id)) {
3544 3544
             $session_id = intval($session_id);
3545
-            $condition_session = ' AND f.session_id = '. $session_id;
3545
+            $condition_session = ' AND f.session_id = '.$session_id;
3546 3546
         }
3547 3547
 
3548 3548
         $groupId = intval($groupId);
@@ -3603,7 +3603,7 @@  discard block
 block discarded – undo
3603 3603
         $condition_session = '';
3604 3604
         if (isset($session_id)) {
3605 3605
              $session_id = intval($session_id);
3606
-             $condition_session = ' AND f.session_id = '. $session_id;
3606
+             $condition_session = ' AND f.session_id = '.$session_id;
3607 3607
         }
3608 3608
 
3609 3609
         $groupId = intval($groupId);
@@ -3682,7 +3682,7 @@  discard block
 block discarded – undo
3682 3682
     {
3683 3683
         $student_id = intval($student_id);
3684 3684
         $courseId = intval($courseId);
3685
-        $session_id    = intval($session_id);
3685
+        $session_id = intval($session_id);
3686 3686
         $date_time  = '';
3687 3687
 
3688 3688
         // table definition
@@ -3751,7 +3751,7 @@  discard block
 block discarded – undo
3751 3751
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3752 3752
 
3753 3753
         $sql = 'SELECT 1
3754
-                FROM ' . $table . '
3754
+                FROM ' . $table.'
3755 3755
                 WHERE down_user_id = '.$student_id.'
3756 3756
                 AND c_id  = "'.$courseId.'"
3757 3757
                 AND down_session_id = '.$session_id.' ';
@@ -3829,30 +3829,30 @@  discard block
 block discarded – undo
3829 3829
                 '.$inner.'
3830 3830
                 WHERE c.id = '.$courseId.'
3831 3831
                 GROUP BY stats_login.user_id
3832
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3832
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3833 3833
 
3834 3834
         if ($since == 'never') {
3835 3835
             if (empty($session_id)) {
3836 3836
                 $sql = 'SELECT course_user.user_id
3837
-                        FROM ' . $table_course_rel_user . ' course_user
3838
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3837
+                        FROM ' . $table_course_rel_user.' course_user
3838
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3839 3839
                         ON course_user.user_id = stats_login.user_id AND
3840
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3841
-                        INNER JOIN ' . $tableCourse . ' c
3840
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3841
+                        INNER JOIN ' . $tableCourse.' c
3842 3842
                         ON (c.id = course_user.c_id)
3843 3843
                         WHERE
3844
-                            course_user.c_id = ' . $courseId . ' AND
3844
+                            course_user.c_id = ' . $courseId.' AND
3845 3845
                             stats_login.login_course_date IS NULL
3846 3846
                         GROUP BY course_user.user_id';
3847 3847
             } else {
3848 3848
                 $sql = 'SELECT session_course_user.user_id
3849 3849
                         FROM '.$tbl_session_course_user.' session_course_user
3850
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3850
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3851 3851
                         ON session_course_user.user_id = stats_login.user_id
3852
-                        INNER JOIN ' . $tableCourse . ' c
3852
+                        INNER JOIN ' . $tableCourse.' c
3853 3853
                         ON (c.id = session_course_user.c_id)
3854 3854
                         WHERE
3855
-                            session_course_user.c_id = ' . $courseId . ' AND
3855
+                            session_course_user.c_id = ' . $courseId.' AND
3856 3856
                             stats_login.login_course_date IS NULL
3857 3857
                         GROUP BY session_course_user.user_id';
3858 3858
 
@@ -3861,7 +3861,7 @@  discard block
 block discarded – undo
3861 3861
 
3862 3862
         $rs = Database::query($sql);
3863 3863
         $inactive_users = array();
3864
-        while($user = Database::fetch_array($rs)) {
3864
+        while ($user = Database::fetch_array($rs)) {
3865 3865
             $inactive_users[] = $user['user_id'];
3866 3866
         }
3867 3867
 
@@ -3883,10 +3883,10 @@  discard block
 block discarded – undo
3883 3883
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3884 3884
 
3885 3885
         $sql = 'SELECT '.$student_id.'
3886
-                FROM ' . $table . '
3886
+                FROM ' . $table.'
3887 3887
                 WHERE
3888
-                    access_user_id=' . $student_id . ' AND
3889
-                    c_id="' . $courseId . '" AND
3888
+                    access_user_id=' . $student_id.' AND
3889
+                    c_id="' . $courseId.'" AND
3890 3890
                     access_session_id = "'.$session_id.'" ';
3891 3891
 
3892 3892
         $rs = Database::query($sql);
@@ -3904,13 +3904,13 @@  discard block
 block discarded – undo
3904 3904
     {
3905 3905
         $hr_dept_id = intval($hr_dept_id);
3906 3906
         $a_students = array();
3907
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3907
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3908 3908
 
3909 3909
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3910 3910
                 WHERE hr_dept_id='.$hr_dept_id;
3911 3911
         $rs = Database::query($sql);
3912 3912
 
3913
-        while($user = Database :: fetch_array($rs)) {
3913
+        while ($user = Database :: fetch_array($rs)) {
3914 3914
             $a_students[$user['user_id']] = $user['user_id'];
3915 3915
         }
3916 3916
 
@@ -3935,7 +3935,7 @@  discard block
 block discarded – undo
3935 3935
         $condition_session     = '';
3936 3936
         if (isset($session_id)) {
3937 3937
             $session_id = intval($session_id);
3938
-            $condition_session = ' AND access_session_id = '. $session_id;
3938
+            $condition_session = ' AND access_session_id = '.$session_id;
3939 3939
         }
3940 3940
         $sql = "SELECT
3941 3941
                     access_tool,
@@ -4047,7 +4047,7 @@  discard block
 block discarded – undo
4047 4047
             if (!empty($date_from) && !empty($date_to)) {
4048 4048
                 $fieldStartDate = $fields['start_date'];
4049 4049
                 if (!isset($fields['end_date'])) {
4050
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4050
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4051 4051
                 } else {
4052 4052
                     $fieldEndDate = $fields['end_date'];
4053 4053
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4063,12 +4063,12 @@  discard block
 block discarded – undo
4063 4063
                 $where
4064 4064
                 GROUP BY %s";
4065 4065
             $sql = sprintf($sql,
4066
-                $fields['user'],    //user field
4067
-                $tableName,         //FROM
4068
-                $fields['course'],  //course condition
4069
-                $course['real_id'],    //course condition
4070
-                $fields['user'],    //user condition
4071
-                $userId,            //user condition
4066
+                $fields['user'], //user field
4067
+                $tableName, //FROM
4068
+                $fields['course'], //course condition
4069
+                $course['real_id'], //course condition
4070
+                $fields['user'], //user condition
4071
+                $userId, //user condition
4072 4072
                 $fields['user']     //GROUP BY
4073 4073
                 );
4074 4074
             $rs = Database::query($sql);
@@ -4076,7 +4076,7 @@  discard block
 block discarded – undo
4076 4076
             //iterate query
4077 4077
             if (Database::num_rows($rs) > 0) {
4078 4078
                 while ($row = Database::fetch_array($rs)) {
4079
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4079
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4080 4080
                 }
4081 4081
             }
4082 4082
         }
@@ -4099,11 +4099,11 @@  discard block
 block discarded – undo
4099 4099
         $courseId = api_get_course_int_id($course_code);
4100 4100
         $data = array();
4101 4101
 
4102
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4102
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4103 4103
         $condition_session = '';
4104 4104
         if (isset($session_id)) {
4105 4105
             $session_id = intval($session_id);
4106
-            $condition_session = ' AND down_session_id = '. $session_id;
4106
+            $condition_session = ' AND down_session_id = '.$session_id;
4107 4107
         }
4108 4108
         $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4109 4109
                 FROM $TABLETRACK_DOWNLOADS
@@ -4288,7 +4288,7 @@  discard block
 block discarded – undo
4288 4288
 
4289 4289
             $final_course_data = array();
4290 4290
 
4291
-            foreach($my_course_data as $course_id => $value) {
4291
+            foreach ($my_course_data as $course_id => $value) {
4292 4292
                 $final_course_data[$course_id] = $course_list[$course_id];
4293 4293
             }
4294 4294
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4311,7 +4311,7 @@  discard block
 block discarded – undo
4311 4311
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4312 4312
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4313 4313
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4314
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4314
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4315 4315
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4316 4316
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4317 4317
                         </tr>';
@@ -4400,7 +4400,7 @@  discard block
 block discarded – undo
4400 4400
             $all_exercise_start_time = array();
4401 4401
 
4402 4402
             foreach ($course_in_session as $my_session_id => $session_data) {
4403
-                $course_list  = $session_data['course_list'];
4403
+                $course_list = $session_data['course_list'];
4404 4404
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4405 4405
                 $exercise_graph_name_list = array();
4406 4406
                 //$user_results = array();
@@ -4445,20 +4445,20 @@  discard block
 block discarded – undo
4445 4445
 
4446 4446
                             $score = 0;
4447 4447
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4448
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4448
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4449 4449
                             }
4450 4450
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4451 4451
                             $all_exercise_start_time[] = $time;
4452 4452
                             $my_results[] = $score;
4453
-                            if (count($exercise_list)<=10) {
4453
+                            if (count($exercise_list) <= 10) {
4454 4454
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4455
-                                $exercise_graph_name_list[]= $title;
4455
+                                $exercise_graph_name_list[] = $title;
4456 4456
                                 $all_exercise_graph_name_list[] = $title;
4457 4457
                             } else {
4458 4458
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4459 4459
                                 $title = cut($exercise_data['title'], 30);
4460
-                                $exercise_graph_name_list[]= $title;
4461
-                                $all_exercise_graph_name_list[]= $title;
4460
+                                $exercise_graph_name_list[] = $title;
4461
+                                $all_exercise_graph_name_list[] = $title;
4462 4462
                             }
4463 4463
                         }
4464 4464
                     }
@@ -4491,7 +4491,7 @@  discard block
 block discarded – undo
4491 4491
             }
4492 4492
 
4493 4493
             $html .= Display::page_subheader(
4494
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4494
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4495 4495
             );
4496 4496
 
4497 4497
             $html .= '<div class="table-responsive">';
@@ -4545,7 +4545,7 @@  discard block
 block discarded – undo
4545 4545
                                 $courseInfo['real_id'],
4546 4546
                                 $my_session_id
4547 4547
                             );
4548
-                            if ($attempts > 1)  {
4548
+                            if ($attempts > 1) {
4549 4549
                                 $answered_exercises++;
4550 4550
                             }
4551 4551
                         }
@@ -4558,7 +4558,7 @@  discard block
 block discarded – undo
4558 4558
                     $all_average += $average;
4559 4559
                 }
4560 4560
 
4561
-                $all_average = $all_average /  count($course_list);
4561
+                $all_average = $all_average / count($course_list);
4562 4562
 
4563 4563
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4564 4564
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4584,16 +4584,16 @@  discard block
 block discarded – undo
4584 4584
             }
4585 4585
             $html .= '</tbody>';
4586 4586
             $html .= '</table></div><br />';
4587
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4587
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4588 4588
 
4589 4589
             // Checking selected session.
4590 4590
 
4591 4591
             if (isset($_GET['session_id'])) {
4592 4592
                 $session_id_from_get = intval($_GET['session_id']);
4593
-                $session_data 	= $course_in_session[$session_id_from_get];
4594
-                $course_list 	= $session_data['course_list'];
4593
+                $session_data = $course_in_session[$session_id_from_get];
4594
+                $course_list = $session_data['course_list'];
4595 4595
 
4596
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4596
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4597 4597
 
4598 4598
                 $html .= '<div class="table-responsive">';
4599 4599
                 $html .= '<table class="table table-hover table-striped">';
@@ -4602,15 +4602,15 @@  discard block
 block discarded – undo
4602 4602
                     <thead>
4603 4603
                     <tr>
4604 4604
                       <th width="300px">'.get_lang('Course').'</th>
4605
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4606
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4607
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4608
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4609
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4610
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4611
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4612
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4613
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4605
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4606
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4607
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4608
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4609
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4610
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4611
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4612
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4613
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4614 4614
                     </tr>
4615 4615
                     </thead>
4616 4616
                     <tbody>
@@ -4629,14 +4629,14 @@  discard block
 block discarded – undo
4629 4629
                         $count_exercises = count($exercises);
4630 4630
                     }
4631 4631
                     $answered_exercises = 0;
4632
-                    foreach($exercises as $exercise_item) {
4632
+                    foreach ($exercises as $exercise_item) {
4633 4633
                         $attempts = Event::count_exercise_attempts_by_user(
4634 4634
                             api_get_user_id(),
4635 4635
                             $exercise_item['id'],
4636 4636
                             $courseId,
4637 4637
                             $session_id_from_get
4638 4638
                         );
4639
-                        if ($attempts > 1)  {
4639
+                        if ($attempts > 1) {
4640 4640
                             $answered_exercises++;
4641 4641
                         }
4642 4642
                     }
@@ -4645,7 +4645,7 @@  discard block
 block discarded – undo
4645 4645
 
4646 4646
                     // Average
4647 4647
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4648
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4648
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4649 4649
 
4650 4650
                     $stats_array[$course_code] = array(
4651 4651
                         'exercises' => $count_exercises,
@@ -4722,7 +4722,7 @@  discard block
 block discarded – undo
4722 4722
 
4723 4723
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4724 4724
                         $details = '<a href="#">';
4725
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4725
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4726 4726
                     } else {
4727 4727
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4728 4728
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4822,7 +4822,7 @@  discard block
 block discarded – undo
4822 4822
                     );
4823 4823
 
4824 4824
                     $html .= '<tr class="row_even">';
4825
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4825
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4826 4826
 
4827 4827
                     if ($visible_return['value'] == true) {
4828 4828
                         $exercices['title'] = Display::url(
@@ -4849,7 +4849,7 @@  discard block
 block discarded – undo
4849 4849
                         );
4850 4850
 
4851 4851
                         $latest_attempt_url = '';
4852
-                        $best_score = $position = $percentage_score_result  = '-';
4852
+                        $best_score = $position = $percentage_score_result = '-';
4853 4853
                         $graph = $normal_graph = null;
4854 4854
 
4855 4855
                         // Getting best results
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
                                 $weighting      = $exercise_stat['exe_weighting'];
4882 4882
                                 $exe_id         = $exercise_stat['exe_id'];
4883 4883
 
4884
-                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4884
+                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4885 4885
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4886 4886
                                 $my_score = 0;
4887 4887
                                 if (!empty($weighting) && intval($weighting) != 0) {
4888
-                                    $my_score = $score/$weighting;
4888
+                                    $my_score = $score / $weighting;
4889 4889
                                 }
4890 4890
                                 //@todo this function slows the page
4891 4891
                                 if (is_int($user_list)) {
@@ -4899,14 +4899,14 @@  discard block
 block discarded – undo
4899 4899
                         }
4900 4900
                         $html .= Display::div(
4901 4901
                             $normal_graph,
4902
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4902
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4903 4903
                         );
4904 4904
 
4905 4905
                         if (empty($graph)) {
4906 4906
                             $graph = '-';
4907 4907
                         } else {
4908 4908
                             $graph = Display::url(
4909
-                                '<img src="' . $graph . '" >',
4909
+                                '<img src="'.$graph.'" >',
4910 4910
                                 $normal_graph,
4911 4911
                                 array(
4912 4912
                                     'id' => $exercices['id'],
@@ -4940,7 +4940,7 @@  discard block
 block discarded – undo
4940 4940
 
4941 4941
             // LP table results
4942 4942
             $html .= '<div class="table-responsive">';
4943
-            $html .='<table class="table table-striped table-hover">';
4943
+            $html .= '<table class="table table-striped table-hover">';
4944 4944
             $html .= '<thead><tr>';
4945 4945
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
4946 4946
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -4976,7 +4976,7 @@  discard block
 block discarded – undo
4976 4976
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
4977 4977
 
4978 4978
                     $html .= '<tr class="row_even">';
4979
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
4979
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
4980 4980
 
4981 4981
                     if ($learnpath['lp_visibility'] == 0) {
4982 4982
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -4995,7 +4995,7 @@  discard block
 block discarded – undo
4995 4995
                     if (!empty($last_connection_in_lp)) {
4996 4996
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
4997 4997
                     }
4998
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
4998
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
4999 4999
                     $html .= "</tr>";
5000 5000
                 }
5001 5001
             } else {
@@ -5005,7 +5005,7 @@  discard block
 block discarded – undo
5005 5005
                         </td>
5006 5006
                       </tr>';
5007 5007
             }
5008
-            $html .='</tbody></table></div>';
5008
+            $html .= '</tbody></table></div>';
5009 5009
 
5010 5010
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5011 5011
         }
@@ -5034,7 +5034,7 @@  discard block
 block discarded – undo
5034 5034
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5035 5035
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5036 5036
         $myData->setAxisUnit(0, '%');
5037
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5037
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5038 5038
         // Cache definition
5039 5039
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5040 5040
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5042,9 +5042,9 @@  discard block
 block discarded – undo
5042 5042
 
5043 5043
         if ($myCache->isInCache($chartHash)) {
5044 5044
             //if we already created the img
5045
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5045
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5046 5046
             $myCache->saveFromCache($chartHash, $imgPath);
5047
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5047
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5048 5048
         } else {
5049 5049
             /* Define width, height and angle */
5050 5050
             $mainWidth = 860;
@@ -5073,7 +5073,7 @@  discard block
 block discarded – undo
5073 5073
             /* Set the default font */
5074 5074
             $myPicture->setFontProperties(
5075 5075
                 array(
5076
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5076
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5077 5077
                     'FontSize' => 10)
5078 5078
             );
5079 5079
             /* Write the chart title */
@@ -5090,7 +5090,7 @@  discard block
 block discarded – undo
5090 5090
             /* Set the default font */
5091 5091
             $myPicture->setFontProperties(
5092 5092
                 array(
5093
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5093
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5094 5094
                     'FontSize' => 6
5095 5095
                 )
5096 5096
             );
@@ -5132,7 +5132,7 @@  discard block
 block discarded – undo
5132 5132
             /* Draw the line chart */
5133 5133
             $myPicture->setFontProperties(
5134 5134
                 array(
5135
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5135
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5136 5136
                     'FontSize' => 10
5137 5137
                 )
5138 5138
             );
@@ -5165,12 +5165,12 @@  discard block
 block discarded – undo
5165 5165
             );
5166 5166
 
5167 5167
             $myCache->writeToCache($chartHash, $myPicture);
5168
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5168
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5169 5169
             $myCache->saveFromCache($chartHash, $imgPath);
5170
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5170
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5171 5171
         }
5172 5172
 
5173
-        $html = '<img src="' . $imgPath . '">';
5173
+        $html = '<img src="'.$imgPath.'">';
5174 5174
 
5175 5175
         return $html;
5176 5176
     }
@@ -5191,12 +5191,12 @@  discard block
 block discarded – undo
5191 5191
 
5192 5192
         foreach ($attempts as $attempt) {
5193 5193
             if (api_get_user_id() == $attempt['exe_user_id']) {
5194
-                if ($attempt['exe_weighting'] != 0 ) {
5195
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5194
+                if ($attempt['exe_weighting'] != 0) {
5195
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5196 5196
                 }
5197 5197
             } else {
5198
-                if ($attempt['exe_weighting'] != 0 ) {
5199
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5198
+                if ($attempt['exe_weighting'] != 0) {
5199
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5200 5200
                 }
5201 5201
             }
5202 5202
         }
@@ -5205,27 +5205,27 @@  discard block
 block discarded – undo
5205 5205
         rsort($my_exercise_result_array);
5206 5206
         $my_exercise_result = 0;
5207 5207
         if (isset($my_exercise_result_array[0])) {
5208
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5208
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5209 5209
         }
5210 5210
 
5211 5211
         $max     = 100;
5212
-        $pieces  = 5 ;
5212
+        $pieces  = 5;
5213 5213
         $part    = round($max / $pieces);
5214 5214
         $x_axis = array();
5215 5215
         $final_array = array();
5216 5216
         $my_final_array = array();
5217 5217
 
5218
-        for ($i=1; $i <=$pieces; $i++) {
5218
+        for ($i = 1; $i <= $pieces; $i++) {
5219 5219
             $sum = 1;
5220 5220
             if ($i == 1) {
5221 5221
                 $sum = 0;
5222 5222
             }
5223
-            $min = ($i-1)*$part + $sum;
5224
-            $max = ($i)*$part;
5225
-            $x_axis[]= $min." - ".$max;
5223
+            $min = ($i - 1) * $part + $sum;
5224
+            $max = ($i) * $part;
5225
+            $x_axis[] = $min." - ".$max;
5226 5226
             $count = 0;
5227
-            foreach($exercise_result as $result) {
5228
-                $percentage = $result*100;
5227
+            foreach ($exercise_result as $result) {
5228
+                $percentage = $result * 100;
5229 5229
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5230 5230
                 if ($percentage >= $min && $percentage <= $max) {
5231 5231
                     //echo ' is > ';
@@ -5233,7 +5233,7 @@  discard block
 block discarded – undo
5233 5233
                 }
5234 5234
             }
5235 5235
             //echo '<br />';
5236
-            $final_array[]= $count;
5236
+            $final_array[] = $count;
5237 5237
 
5238 5238
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5239 5239
                 $my_final_array[] = 1;
@@ -5243,9 +5243,9 @@  discard block
 block discarded – undo
5243 5243
         }
5244 5244
 
5245 5245
         //Fix to remove the data of the user with my data
5246
-        for($i = 0; $i<=count($my_final_array); $i++) {
5246
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5247 5247
             if (!empty($my_final_array[$i])) {
5248
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5248
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5249 5249
                 $final_array[$i] = 0;
5250 5250
             }
5251 5251
         }
@@ -5255,16 +5255,16 @@  discard block
 block discarded – undo
5255 5255
         $dataSet->addPoints($final_array, 'Serie1');
5256 5256
         $dataSet->addPoints($my_final_array, 'Serie2');
5257 5257
         $dataSet->normalize(100, "%");
5258
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5258
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5259 5259
 
5260 5260
         // Cache definition
5261 5261
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5262 5262
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5263 5263
         $chartHash = $myCache->getHash($dataSet);
5264 5264
         if ($myCache->isInCache($chartHash)) {
5265
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5265
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5266 5266
             $myCache->saveFromCache($chartHash, $imgPath);
5267
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5267
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5268 5268
         } else {
5269 5269
             /* Create the pChart object */
5270 5270
             $widthSize = 80;
@@ -5280,7 +5280,7 @@  discard block
 block discarded – undo
5280 5280
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5281 5281
 
5282 5282
             /* Set the default font */
5283
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5283
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5284 5284
 
5285 5285
             /* Do not write the chart title */
5286 5286
 
@@ -5344,9 +5344,9 @@  discard block
 block discarded – undo
5344 5344
 
5345 5345
             /* Save and write in cache */
5346 5346
             $myCache->writeToCache($chartHash, $myPicture);
5347
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5347
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5348 5348
             $myCache->saveFromCache($chartHash, $imgPath);
5349
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5349
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5350 5350
         }
5351 5351
 
5352 5352
         return $imgPath;
@@ -5366,12 +5366,12 @@  discard block
 block discarded – undo
5366 5366
         }
5367 5367
         foreach ($attempts as $attempt) {
5368 5368
             if (api_get_user_id() == $attempt['exe_user_id']) {
5369
-                if ($attempt['exe_weighting'] != 0 ) {
5370
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5369
+                if ($attempt['exe_weighting'] != 0) {
5370
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5371 5371
                 }
5372 5372
             } else {
5373
-                if ($attempt['exe_weighting'] != 0 ) {
5374
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5373
+                if ($attempt['exe_weighting'] != 0) {
5374
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5375 5375
                 }
5376 5376
             }
5377 5377
         }
@@ -5380,32 +5380,32 @@  discard block
 block discarded – undo
5380 5380
         rsort($my_exercise_result_array);
5381 5381
         $my_exercise_result = 0;
5382 5382
         if (isset($my_exercise_result_array[0])) {
5383
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5383
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5384 5384
         }
5385 5385
 
5386 5386
         $max = 100;
5387
-        $pieces = 5 ;
5387
+        $pieces = 5;
5388 5388
         $part = round($max / $pieces);
5389 5389
         $x_axis = array();
5390 5390
         $final_array = array();
5391 5391
         $my_final_array = array();
5392 5392
 
5393
-        for ($i=1; $i <=$pieces; $i++) {
5393
+        for ($i = 1; $i <= $pieces; $i++) {
5394 5394
             $sum = 1;
5395 5395
             if ($i == 1) {
5396 5396
                 $sum = 0;
5397 5397
             }
5398
-            $min = ($i-1)*$part + $sum;
5399
-            $max = ($i)*$part;
5400
-            $x_axis[]= $min." - ".$max;
5398
+            $min = ($i - 1) * $part + $sum;
5399
+            $max = ($i) * $part;
5400
+            $x_axis[] = $min." - ".$max;
5401 5401
             $count = 0;
5402
-            foreach($exercise_result as $result) {
5403
-                $percentage = $result*100;
5402
+            foreach ($exercise_result as $result) {
5403
+                $percentage = $result * 100;
5404 5404
                 if ($percentage >= $min && $percentage <= $max) {
5405 5405
                     $count++;
5406 5406
                 }
5407 5407
             }
5408
-            $final_array[]= $count;
5408
+            $final_array[] = $count;
5409 5409
 
5410 5410
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5411 5411
                 $my_final_array[] = 1;
@@ -5416,9 +5416,9 @@  discard block
 block discarded – undo
5416 5416
 
5417 5417
         //Fix to remove the data of the user with my data
5418 5418
 
5419
-        for($i = 0; $i<=count($my_final_array); $i++) {
5419
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5420 5420
             if (!empty($my_final_array[$i])) {
5421
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5421
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5422 5422
                 $final_array[$i] = 0;
5423 5423
             }
5424 5424
         }
@@ -5436,7 +5436,7 @@  discard block
 block discarded – undo
5436 5436
         $dataSet->setXAxisName(get_lang('Score'));
5437 5437
         $dataSet->normalize(100, "%");
5438 5438
 
5439
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5439
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5440 5440
 
5441 5441
         // Cache definition
5442 5442
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5444,9 +5444,9 @@  discard block
 block discarded – undo
5444 5444
         $chartHash = $myCache->getHash($dataSet);
5445 5445
 
5446 5446
         if ($myCache->isInCache($chartHash)) {
5447
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5447
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5448 5448
             $myCache->saveFromCache($chartHash, $imgPath);
5449
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5449
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5450 5450
         } else {
5451 5451
             /* Create the pChart object */
5452 5452
             $widthSize = 480;
@@ -5462,7 +5462,7 @@  discard block
 block discarded – undo
5462 5462
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5463 5463
 
5464 5464
             /* Set the default font */
5465
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5465
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5466 5466
 
5467 5467
             /* Write the chart title */
5468 5468
             $myPicture->drawText(
@@ -5521,9 +5521,9 @@  discard block
 block discarded – undo
5521 5521
 
5522 5522
             /* Write and save into cache */
5523 5523
             $myCache->writeToCache($chartHash, $myPicture);
5524
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5524
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5525 5525
             $myCache->saveFromCache($chartHash, $imgPath);
5526
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5526
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5527 5527
         }
5528 5528
 
5529 5529
         return $imgPath;
@@ -5650,7 +5650,7 @@  discard block
 block discarded – undo
5650 5650
                         $whereSessionParams .= $sessionIdx.',';
5651 5651
                     }
5652 5652
                 }
5653
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5653
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5654 5654
             }
5655 5655
 
5656 5656
             if (!empty($exerciseId)) {
@@ -5711,7 +5711,7 @@  discard block
 block discarded – undo
5711 5711
                     qq.position = rq.question_order AND
5712 5712
                     ta.question_id = rq.question_id
5713 5713
                 WHERE
5714
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5714
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5715 5715
                     AND q.c_id = $courseIdx
5716 5716
                     $where $order $limit";
5717 5717
             $sql_query = vsprintf($sql, $whereParams);
@@ -5759,7 +5759,7 @@  discard block
 block discarded – undo
5759 5759
             // Now fill users data
5760 5760
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5761 5761
                          FROM $tuser
5762
-                         WHERE user_id IN (".implode(',',$userIds).")";
5762
+                         WHERE user_id IN (".implode(',', $userIds).")";
5763 5763
             $resUsers = Database::query($sqlUsers);
5764 5764
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5765 5765
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5863,7 +5863,7 @@  discard block
 block discarded – undo
5863 5863
                 <table class="table" id="skillList">
5864 5864
                     <thead>
5865 5865
                         <tr>
5866
-                            <th>' . get_lang('AchievedSkills') . '</th>
5866
+                            <th>' . get_lang('AchievedSkills').'</th>
5867 5867
                         </tr>
5868 5868
                     </thead>
5869 5869
                     <tbody>
@@ -5882,10 +5882,10 @@  discard block
 block discarded – undo
5882 5882
 
5883 5883
                 $html .= '
5884 5884
                                             <li class="thumbnail">
5885
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5886
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5885
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5886
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5887 5887
                                                     <div class="caption">
5888
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5888
+                                                        <p class="text-center">' . $skill->getName().'</p>
5889 5889
                                                     </div>
5890 5890
                                                 </a>
5891 5891
                                             </li>
@@ -5935,7 +5935,7 @@  discard block
 block discarded – undo
5935 5935
     	        WHERE
5936 5936
                     track_resource.c_id = $course_id AND
5937 5937
                     track_resource.insert_user_id = user.user_id AND
5938
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5938
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5939 5939
 
5940 5940
     	if (isset($_GET['keyword'])) {
5941 5941
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -5993,7 +5993,7 @@  discard block
 block discarded – undo
5993 5993
                 WHERE
5994 5994
                   track_resource.c_id = $course_id AND
5995 5995
                   track_resource.insert_user_id = user.user_id AND
5996
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5996
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5997 5997
 
5998 5998
     	if (isset($_GET['keyword'])) {
5999 5999
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6287,7 +6287,7 @@  discard block
 block discarded – undo
6287 6287
     public static function display_additional_profile_fields()
6288 6288
     {
6289 6289
     	// getting all the extra profile fields that are defined by the platform administrator
6290
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6290
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6291 6291
 
6292 6292
     	// creating the form
6293 6293
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6299,8 +6299,8 @@  discard block
 block discarded – undo
6299 6299
     	$extra_fields_to_show = 0;
6300 6300
     	foreach ($extra_fields as $key=>$field) {
6301 6301
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6302
-    		if ($field[6]==1 && $field[8] == 1) {
6303
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6302
+    		if ($field[6] == 1 && $field[8] == 1) {
6303
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6304 6304
     				$selected = 'selected="selected"';
6305 6305
     			} else {
6306 6306
     				$selected = '';
@@ -6312,8 +6312,8 @@  discard block
 block discarded – undo
6312 6312
     	$return .= '</select>';
6313 6313
 
6314 6314
     	// the form elements for the $_GET parameters (because the form is passed through GET
6315
-    	foreach ($_GET as $key=>$value){
6316
-    		if ($key <> 'additional_profile_field')    {
6315
+    	foreach ($_GET as $key=>$value) {
6316
+    		if ($key <> 'additional_profile_field') {
6317 6317
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6318 6318
     		}
6319 6319
     	}
@@ -6350,21 +6350,21 @@  discard block
 block discarded – undo
6350 6350
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6351 6351
 
6352 6352
     	if (!empty($users)) {
6353
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6354
-    			foreach($users as $user_id) {
6353
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6354
+    			foreach ($users as $user_id) {
6355 6355
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6356 6356
     				$tag_list = array();
6357
-    				foreach($user_result as $item) {
6357
+    				foreach ($user_result as $item) {
6358 6358
     					$tag_list[] = $item['tag'];
6359 6359
     				}
6360
-    				$return[$user_id][] = implode(', ',$tag_list);
6360
+    				$return[$user_id][] = implode(', ', $tag_list);
6361 6361
     			}
6362 6362
     		} else {
6363 6363
     			$new_user_array = array();
6364 6364
     			foreach ($users as $user_id) {
6365
-    				$new_user_array[]= "'".$user_id."'";
6365
+    				$new_user_array[] = "'".$user_id."'";
6366 6366
     			}
6367
-    			$users = implode(',',$new_user_array);
6367
+    			$users = implode(',', $new_user_array);
6368 6368
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6369 6369
     			// Selecting only the necessary information NOT ALL the user list
6370 6370
     			$sql = "SELECT user.user_id, v.value
@@ -6379,7 +6379,7 @@  discard block
 block discarded – undo
6379 6379
                             user.user_id IN ($users)";
6380 6380
 
6381 6381
     			$result = Database::query($sql);
6382
-    			while($row = Database::fetch_array($result)) {
6382
+    			while ($row = Database::fetch_array($result)) {
6383 6383
     				// get option value for field type double select by id
6384 6384
     				if (!empty($row['value'])) {
6385 6385
     					if ($result_extra_field['field_type'] ==
@@ -6418,7 +6418,7 @@  discard block
 block discarded – undo
6418 6418
 
6419 6419
     public function sort_users_desc($a, $b)
6420 6420
     {
6421
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6421
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6422 6422
     }
6423 6423
 
6424 6424
     /**
@@ -6453,7 +6453,7 @@  discard block
 block discarded – undo
6453 6453
     	// get all users data from a course for sortable with limit
6454 6454
     	if (is_array($user_ids)) {
6455 6455
     		$user_ids = array_map('intval', $user_ids);
6456
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6456
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6457 6457
     	} else {
6458 6458
     		$user_ids = intval($user_ids);
6459 6459
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6461,7 +6461,7 @@  discard block
 block discarded – undo
6461 6461
 
6462 6462
     	if (!empty($_GET['user_keyword'])) {
6463 6463
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6464
-    		$condition_user .=  " AND (
6464
+    		$condition_user .= " AND (
6465 6465
                 user.firstname LIKE '%".$keyword."%' OR
6466 6466
                 user.lastname LIKE '%".$keyword."%'  OR
6467 6467
                 user.username LIKE '%".$keyword."%'  OR
@@ -6479,7 +6479,7 @@  discard block
 block discarded – undo
6479 6479
         $invitedUsersCondition = '';
6480 6480
 
6481 6481
         if (!$includeInvitedUsers) {
6482
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6482
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6483 6483
         }
6484 6484
 
6485 6485
     	$sql = "SELECT  user.user_id as user_id,
@@ -6490,7 +6490,7 @@  discard block
 block discarded – undo
6490 6490
                 FROM $tbl_user as user $url_table
6491 6491
     	        $condition_user $url_condition $invitedUsersCondition";
6492 6492
 
6493
-    	if (!in_array($direction, array('ASC','DESC'))) {
6493
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6494 6494
     		$direction = 'ASC';
6495 6495
     	}
6496 6496
 
@@ -6627,7 +6627,7 @@  discard block
 block discarded – undo
6627 6627
     		}
6628 6628
 
6629 6629
             if (empty($session_id)) {
6630
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6630
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6631 6631
             }
6632 6632
 
6633 6633
     		$user['link'] = '<center>
@@ -6639,37 +6639,37 @@  discard block
 block discarded – undo
6639 6639
     		// store columns in array $users
6640 6640
     		$is_western_name_order = api_is_western_name_order();
6641 6641
             $user_row = array();
6642
-            $user_row[]= $user['official_code']; //0
6642
+            $user_row[] = $user['official_code']; //0
6643 6643
             if ($is_western_name_order) {
6644
-                $user_row[]= $user['firstname'];
6645
-                $user_row[]= $user['lastname'];
6644
+                $user_row[] = $user['firstname'];
6645
+                $user_row[] = $user['lastname'];
6646 6646
             } else {
6647
-                $user_row[]= $user['lastname'];
6648
-                $user_row[]= $user['firstname'];
6647
+                $user_row[] = $user['lastname'];
6648
+                $user_row[] = $user['firstname'];
6649 6649
             }
6650
-            $user_row[]= $user['username'];
6651
-            $user_row[]= $user['time'];
6652
-            $user_row[]= $user['average_progress'];
6653
-            $user_row[]= $user['exercise_progress'];
6654
-            $user_row[]= $user['exercise_average_best_attempt'];
6655
-            $user_row[]= $user['student_score'];
6656
-            $user_row[]= $user['count_assignments'];
6657
-            $user_row[]= $user['count_messages'];
6650
+            $user_row[] = $user['username'];
6651
+            $user_row[] = $user['time'];
6652
+            $user_row[] = $user['average_progress'];
6653
+            $user_row[] = $user['exercise_progress'];
6654
+            $user_row[] = $user['exercise_average_best_attempt'];
6655
+            $user_row[] = $user['student_score'];
6656
+            $user_row[] = $user['count_assignments'];
6657
+            $user_row[] = $user['count_messages'];
6658 6658
 
6659 6659
             $userGroupManager = new UserGroup();
6660 6660
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6661 6661
 
6662 6662
             if (empty($session_id)) {
6663
-                $user_row[]= $user['survey'];
6663
+                $user_row[] = $user['survey'];
6664 6664
             }
6665 6665
 
6666
-            $user_row[]= $user['first_connection'];
6667
-            $user_row[]= $user['last_connection'];
6666
+            $user_row[] = $user['first_connection'];
6667
+            $user_row[] = $user['last_connection'];
6668 6668
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6669
-                $user_row[]= $user['additional'];
6669
+                $user_row[] = $user['additional'];
6670 6670
             }
6671 6671
 
6672
-            $user_row[]= $user['link'];
6672
+            $user_row[] = $user['link'];
6673 6673
 
6674 6674
             $users[] = $user_row;
6675 6675
 
@@ -6714,8 +6714,8 @@  discard block
 block discarded – undo
6714 6714
 
6715 6715
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6716 6716
     	$tempView = $view;
6717
-    	if(substr($view,0,1) == '1') {
6718
-    		$new_view = substr_replace($view,'0',0,1);
6717
+    	if (substr($view, 0, 1) == '1') {
6718
+    		$new_view = substr_replace($view, '0', 0, 1);
6719 6719
     		echo "
6720 6720
                 <tr>
6721 6721
                     <td valign='top'>
@@ -6748,9 +6748,9 @@  discard block
 block discarded – undo
6748 6748
                 </tr>";
6749 6749
     		$total = 0;
6750 6750
     		if (is_array($results)) {
6751
-    			for($j = 0 ; $j < count($results) ; $j++) {
6751
+    			for ($j = 0; $j < count($results); $j++) {
6752 6752
     				echo "<tr>";
6753
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6753
+    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0]) - 1].' '.date('Y', $results[$j][0])."</a></td>";
6754 6754
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6755 6755
     				echo"</tr>";
6756 6756
     				$total = $total + $results[$j][1];
@@ -6767,7 +6767,7 @@  discard block
 block discarded – undo
6767 6767
     		echo "</table>";
6768 6768
     		echo "</td></tr>";
6769 6769
     	} else {
6770
-    		$new_view = substr_replace($view,'1',0,1);
6770
+    		$new_view = substr_replace($view, '1', 0, 1);
6771 6771
     		echo "
6772 6772
                 <tr>
6773 6773
                     <td valign='top'>
@@ -6790,8 +6790,8 @@  discard block
 block discarded – undo
6790 6790
     {
6791 6791
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6792 6792
         $courseId = api_get_course_int_id($courseCode);
6793
-    	if(substr($view,1,1) == '1') {
6794
-    		$new_view = substr_replace($view,'0',1,1);
6793
+    	if (substr($view, 1, 1) == '1') {
6794
+    		$new_view = substr_replace($view, '0', 1, 1);
6795 6795
     		echo "<tr>
6796 6796
                     <td valign='top'>
6797 6797
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
@@ -6833,7 +6833,7 @@  discard block
 block discarded – undo
6833 6833
                 </tr>";
6834 6834
 
6835 6835
     		if (is_array($results)) {
6836
-    			for($i = 0; $i < sizeof($results); $i++) {
6836
+    			for ($i = 0; $i < sizeof($results); $i++) {
6837 6837
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6838 6838
     				echo "<tr>\n";
6839 6839
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6848,8 +6848,8 @@  discard block
 block discarded – undo
6848 6848
 
6849 6849
     		// The Result of Tests
6850 6850
     		if (is_array($hpresults)) {
6851
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6852
-    				$title = GetQuizName($hpresults[$i][0],'');
6851
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6852
+    				$title = GetQuizName($hpresults[$i][0], '');
6853 6853
     				if ($title == '')
6854 6854
     				$title = basename($hpresults[$i][0]);
6855 6855
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6875,7 +6875,7 @@  discard block
 block discarded – undo
6875 6875
     		echo "</table>";
6876 6876
     		echo "</td>\n</tr>\n";
6877 6877
     	} else {
6878
-    		$new_view = substr_replace($view,'1',1,1);
6878
+    		$new_view = substr_replace($view, '1', 1, 1);
6879 6879
     		echo "
6880 6880
                 <tr>
6881 6881
                     <td valign='top'>
@@ -6894,8 +6894,8 @@  discard block
 block discarded – undo
6894 6894
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6895 6895
         $_course = api_get_course_info_by_id($course_id);
6896 6896
 
6897
-    	if (substr($view,2,1) == '1') {
6898
-    		$new_view = substr_replace($view,'0',2,1);
6897
+    	if (substr($view, 2, 1) == '1') {
6898
+    		$new_view = substr_replace($view, '0', 2, 1);
6899 6899
     		echo "<tr>
6900 6900
                     <td valign='top'>
6901 6901
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
@@ -6909,7 +6909,7 @@  discard block
 block discarded – undo
6909 6909
                         AND u.c_id = '".intval($course_id)."'
6910 6910
                     ORDER BY u.upload_date DESC";
6911 6911
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6912
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6912
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6913 6913
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6914 6914
     		echo "<tr>
6915 6915
                     <td class='secLine' width='40%'>
@@ -6923,7 +6923,7 @@  discard block
 block discarded – undo
6923 6923
                     </td>
6924 6924
                 </tr>";
6925 6925
     		if (is_array($results)) {
6926
-    			for($j = 0 ; $j < count($results) ; $j++) {
6926
+    			for ($j = 0; $j < count($results); $j++) {
6927 6927
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6928 6928
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6929 6929
     				echo "<tr>";
@@ -6942,7 +6942,7 @@  discard block
 block discarded – undo
6942 6942
     		echo "</table>";
6943 6943
     		echo "</td></tr>";
6944 6944
     	} else {
6945
-    		$new_view = substr_replace($view,'1',2,1);
6945
+    		$new_view = substr_replace($view, '1', 2, 1);
6946 6946
     		echo "
6947 6947
                 <tr>
6948 6948
                     <td valign='top'>
@@ -6961,8 +6961,8 @@  discard block
 block discarded – undo
6961 6961
     {
6962 6962
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6963 6963
         $courseId = api_get_course_int_id($courseCode);
6964
-    	if (substr($view,3,1) == '1') {
6965
-    		$new_view = substr_replace($view,'0',3,1);
6964
+    	if (substr($view, 3, 1) == '1') {
6965
+    		$new_view = substr_replace($view, '0', 3, 1);
6966 6966
     		echo "
6967 6967
                 <tr>
6968 6968
                         <td valign='top'>
@@ -6986,7 +6986,7 @@  discard block
 block discarded – undo
6986 6986
                     </td>
6987 6987
                 </tr>";
6988 6988
     		if (is_array($results)) {
6989
-    			for($j = 0 ; $j < count($results) ; $j++) {
6989
+    			for ($j = 0; $j < count($results); $j++) {
6990 6990
     				echo "<tr>";
6991 6991
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6992 6992
     				echo"</tr>";
@@ -6999,7 +6999,7 @@  discard block
 block discarded – undo
6999 6999
     		echo "</table>";
7000 7000
     		echo "</td></tr>";
7001 7001
     	} else {
7002
-    		$new_view = substr_replace($view,'1',3,1);
7002
+    		$new_view = substr_replace($view, '1', 3, 1);
7003 7003
     		echo "
7004 7004
                 <tr>
7005 7005
                     <td valign='top'>
@@ -7026,8 +7026,8 @@  discard block
 block discarded – undo
7026 7026
     	$session_id = intval($session_id);
7027 7027
 
7028 7028
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7029
-    	if(substr($view,4,1) == '1') {
7030
-    		$new_view = substr_replace($view,'0',4,1);
7029
+    	if (substr($view, 4, 1) == '1') {
7030
+    		$new_view = substr_replace($view, '0', 4, 1);
7031 7031
     		echo "
7032 7032
                 <tr>
7033 7033
                     <td valign='top'>
@@ -7053,7 +7053,7 @@  discard block
 block discarded – undo
7053 7053
                     </td>
7054 7054
                 </tr>";
7055 7055
     		if (is_array($results)) {
7056
-    			for($j = 0 ; $j < count($results) ; $j++) {
7056
+    			for ($j = 0; $j < count($results); $j++) {
7057 7057
     				echo "<tr>";
7058 7058
     				echo "<td class='content'>".$results[$j]."</td>";
7059 7059
     				echo"</tr>";
@@ -7066,7 +7066,7 @@  discard block
 block discarded – undo
7066 7066
     		echo "</table>";
7067 7067
     		echo "</td></tr>";
7068 7068
     	} else {
7069
-    		$new_view = substr_replace($view,'1',4,1);
7069
+    		$new_view = substr_replace($view, '1', 4, 1);
7070 7070
     		echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
@@ -7100,11 +7100,11 @@  discard block
 block discarded – undo
7100 7100
                    ORDER BY login_date DESC LIMIT 1";
7101 7101
         $ip = '';
7102 7102
         $res_ip = Database::query($sql_ip);
7103
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7103
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7104 7104
             $row_ip = Database::fetch_row($res_ip);
7105 7105
             if ($return_as_link) {
7106 7106
                 $ip = Display::url(
7107
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7107
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7108 7108
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7109 7109
                 );
7110 7110
             } else {
@@ -7140,9 +7140,9 @@  discard block
 block discarded – undo
7140 7140
     	$course_id  = intval($course_id);
7141 7141
 
7142 7142
     	$tempView = $view;
7143
-    	if (substr($view,0,1) == '1') {
7144
-    		$new_view = substr_replace($view,'0',0,1);
7145
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7143
+    	if (substr($view, 0, 1) == '1') {
7144
+    		$new_view = substr_replace($view, '0', 0, 1);
7145
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7146 7146
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7147 7147
                     FROM $track_access_table
7148 7148
                     WHERE access_user_id = $user_id
@@ -7152,20 +7152,20 @@  discard block
 block discarded – undo
7152 7152
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7153 7153
     		//$results = getManyResults2Col($sql);
7154 7154
     		$results = getManyResults3Col($sql);
7155
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7156
-    		$line='';
7155
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7156
+    		$line = '';
7157 7157
     		$total = 0;
7158 7158
     		if (is_array($results)) {
7159
-    			for($j = 0 ; $j < count($results) ; $j++) {
7159
+    			for ($j = 0; $j < count($results); $j++) {
7160 7160
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7161 7161
     				$total = $total + $results[$j][1];
7162 7162
     			}
7163 7163
     			$line .= get_lang('Total').";".$total."\n";
7164 7164
     		} else {
7165
-    			$line= get_lang('NoResult')."</center></td>";
7165
+    			$line = get_lang('NoResult')."</center></td>";
7166 7166
     		}
7167 7167
     	} else {
7168
-    		$new_view = substr_replace($view,'1',0,1);
7168
+    		$new_view = substr_replace($view, '1', 0, 1);
7169 7169
     	}
7170 7170
     	return array($title_line, $line);
7171 7171
     }
@@ -7183,8 +7183,8 @@  discard block
 block discarded – undo
7183 7183
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7184 7184
         $courseId = api_get_course_int_id($courseCode);
7185 7185
         $userId = intval($userId);
7186
-    	if (substr($view,1,1) == '1') {
7187
-    		$new_view = substr_replace($view,'0',1,1);
7186
+    	if (substr($view, 1, 1) == '1') {
7187
+    		$new_view = substr_replace($view, '0', 1, 1);
7188 7188
     		$title[1] = get_lang('ExercicesDetails');
7189 7189
     		$line = '';
7190 7190
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7208,7 +7208,7 @@  discard block
 block discarded – undo
7208 7208
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7209 7209
 
7210 7210
     		if (is_array($results)) {
7211
-    			for($i = 0; $i < sizeof($results); $i++)
7211
+    			for ($i = 0; $i < sizeof($results); $i++)
7212 7212
     			{
7213 7213
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7214 7214
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7220,8 +7220,8 @@  discard block
 block discarded – undo
7220 7220
 
7221 7221
     		// The Result of Tests
7222 7222
     		if (is_array($hpresults)) {
7223
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7224
-    				$title = GetQuizName($hpresults[$i][0],'');
7223
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7224
+    				$title = GetQuizName($hpresults[$i][0], '');
7225 7225
 
7226 7226
     				if ($title == '')
7227 7227
     				$title = basename($hpresults[$i][0]);
@@ -7235,10 +7235,10 @@  discard block
 block discarded – undo
7235 7235
     		}
7236 7236
 
7237 7237
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7238
-    			$line=get_lang('NoResult');
7238
+    			$line = get_lang('NoResult');
7239 7239
     		}
7240 7240
     	} else {
7241
-    		$new_view = substr_replace($view,'1',1,1);
7241
+    		$new_view = substr_replace($view, '1', 1, 1);
7242 7242
     	}
7243 7243
     	return array($title_line, $line);
7244 7244
     }
@@ -7254,7 +7254,7 @@  discard block
 block discarded – undo
7254 7254
         $user_id = intval($user_id);
7255 7255
         $course_id = intval($course_id);
7256 7256
 
7257
-    	if (substr($view,2,1) == '1') {
7257
+    	if (substr($view, 2, 1) == '1') {
7258 7258
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7259 7259
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7260 7260
                     WHERE
@@ -7262,21 +7262,21 @@  discard block
 block discarded – undo
7262 7262
                         u.upload_user_id = '$user_id' AND
7263 7263
                         u.c_id = '$course_id'
7264 7264
                     ORDER BY u.upload_date DESC";
7265
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7265
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7266 7266
 
7267
-    		$title[1]=get_lang('WorksDetails');
7268
-    		$line='';
7269
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7267
+    		$title[1] = get_lang('WorksDetails');
7268
+    		$line = '';
7269
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7270 7270
 
7271 7271
     		if (is_array($results)) {
7272
-    			for($j = 0 ; $j < count($results) ; $j++) {
7272
+    			for ($j = 0; $j < count($results); $j++) {
7273 7273
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7274 7274
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7275 7275
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7276 7276
     			}
7277 7277
 
7278 7278
     		} else {
7279
-    			$line= get_lang('NoResult');
7279
+    			$line = get_lang('NoResult');
7280 7280
     		}
7281 7281
     	}
7282 7282
     	return array($title_line, $line);
@@ -7292,9 +7292,9 @@  discard block
 block discarded – undo
7292 7292
         $courseId = api_get_course_int_id($courseCode);
7293 7293
         $userId = intval($userId);
7294 7294
         $line = null;
7295
-    	if (substr($view,3,1) == '1') {
7296
-    		$new_view = substr_replace($view,'0',3,1);
7297
-    		$title[1]=get_lang('LinksDetails');
7295
+    	if (substr($view, 3, 1) == '1') {
7296
+    		$new_view = substr_replace($view, '0', 3, 1);
7297
+    		$title[1] = get_lang('LinksDetails');
7298 7298
     		$sql = "SELECT cl.title, cl.url
7299 7299
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7300 7300
                         WHERE sl.links_link_id = cl.id
@@ -7302,16 +7302,16 @@  discard block
 block discarded – undo
7302 7302
                             AND sl.links_user_id = $userId
7303 7303
                         GROUP BY cl.title, cl.url";
7304 7304
     		$results = StatsUtils::getManyResults2Col($sql);
7305
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7305
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7306 7306
     		if (is_array($results)) {
7307
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7307
+    			for ($j = 0; $j < count($results); $j++) {
7308 7308
     				$line .= $results[$j][0]."\n";
7309 7309
     			}
7310 7310
     		} else {
7311
-    			$line=get_lang('NoResult');
7311
+    			$line = get_lang('NoResult');
7312 7312
     		}
7313 7313
     	} else {
7314
-    		$new_view = substr_replace($view,'1',3,1);
7314
+    		$new_view = substr_replace($view, '1', 3, 1);
7315 7315
     	}
7316 7316
     	return array($title_line, $line);
7317 7317
     }
@@ -7333,9 +7333,9 @@  discard block
 block discarded – undo
7333 7333
 
7334 7334
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7335 7335
 
7336
-    	if (substr($view,4,1) == '1') {
7337
-    		$new_view = substr_replace($view,'0',4,1);
7338
-    		$title[1]= get_lang('DocumentsDetails');
7336
+    	if (substr($view, 4, 1) == '1') {
7337
+    		$new_view = substr_replace($view, '0', 4, 1);
7338
+    		$title[1] = get_lang('DocumentsDetails');
7339 7339
 
7340 7340
     		$sql = "SELECT down_doc_path
7341 7341
                         FROM $downloads_table
@@ -7348,14 +7348,14 @@  discard block
 block discarded – undo
7348 7348
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7349 7349
             $line = null;
7350 7350
     		if (is_array($results)) {
7351
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7351
+    			for ($j = 0; $j < count($results); $j++) {
7352 7352
     				$line .= $results[$j]."\n";
7353 7353
     			}
7354 7354
     		} else {
7355 7355
     			$line = get_lang('NoResult');
7356 7356
     		}
7357 7357
     	} else {
7358
-    		$new_view = substr_replace($view,'1',4,1);
7358
+    		$new_view = substr_replace($view, '1', 4, 1);
7359 7359
     	}
7360 7360
     	return array($title_line, $line);
7361 7361
     }
Please login to merge, or discard this patch.