Completed
Push — 1.11.x ( 69878b...1da93a )
by José
64:32 queued 39:16
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   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2896,10 +2896,11 @@
 block discarded – undo
2896 2896
                                 c_id = $courseId AND
2897 2897
                                 user_id = $user_id ";
2898 2898
                     $result = Database::query($sql);
2899
-                    if (Database::affected_rows($result) > 0)
2900
-                        return true;
2901
-                    else
2902
-                        return false;
2899
+                    if (Database::affected_rows($result) > 0) {
2900
+                                            return true;
2901
+                    } else {
2902
+                                            return false;
2903
+                    }
2903 2904
                 } else {
2904 2905
                     // The user is not subscribed to the session, so make sure
2905 2906
                     // he isn't subscribed to a course in this session either
Please login to merge, or discard this patch.
Doc Comments   +19 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
      * @param	array	$id_checked an array to delete sessions
1533 1533
      * @param   boolean  $from_ws optional, true if the function is called
1534 1534
      * by a webservice, false otherwise.
1535
-     * @return	void	Nothing, or false on error
1535
+     * @return	boolean	Nothing, or false on error
1536 1536
      * */
1537 1537
     public static function delete($id_checked, $from_ws = false)
1538 1538
     {
@@ -1669,7 +1669,7 @@  discard block
 block discarded – undo
1669 1669
      * @param array $user_list
1670 1670
      * @param int $session_visibility
1671 1671
      * @param bool $empty_users
1672
-     * @return bool
1672
+     * @return false|null
1673 1673
      */
1674 1674
     public static function subscribe_users_to_session(
1675 1675
         $id_session,
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
      * @param array $courseInfo
1943 1943
      * @param int $status
1944 1944
      * @param bool $updateTotal
1945
-     * @return bool
1945
+     * @return false|null
1946 1946
      */
1947 1947
     public static function removeUsersFromCourseSession(
1948 1948
         $userList,
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
      * @param string $course_code
2009 2009
      * @param int $session_visibility
2010 2010
      * @param bool $removeUsersNotInList
2011
-     * @return bool
2011
+     * @return false|null
2012 2012
      */
2013 2013
     public static function subscribe_users_to_session_course(
2014 2014
         $user_list,
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
      * @param	bool	$removeExistingCoursesWithUsers Whether to unsubscribe
2193 2193
      * existing courses and users (true, default) or not (false)
2194 2194
      * @param $copyEvaluation from base course to session course
2195
-     * @return	void	Nothing, or false on error
2195
+     * @return	false|null	Nothing, or false on error
2196 2196
      * */
2197 2197
     public static function add_courses_to_session(
2198 2198
         $sessionId,
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
      * @param	string	$variable Field's internal variable name
2442 2442
      * @param	int		$fieldType Field's type
2443 2443
      * @param	string	$displayText Field's language var name
2444
-     * @return int     new extra field id
2444
+     * @return boolean     new extra field id
2445 2445
      */
2446 2446
     public static function create_session_extra_field($variable, $fieldType, $displayText)
2447 2447
     {
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
      * @param	array	id_checked
2671 2671
      * @param	bool	include delete session
2672 2672
      * @param	bool	optional, true if the function is called by a webservice, false otherwise.
2673
-     * @return	void	Nothing, or false on error
2673
+     * @return	boolean	Nothing, or false on error
2674 2674
      * The parameters is a array to delete sessions
2675 2675
      * */
2676 2676
     public static function delete_session_category($id_checked, $delete_session = false, $from_ws = false)
@@ -3436,8 +3436,8 @@  discard block
 block discarded – undo
3436 3436
     /**
3437 3437
      * Gets the list of courses by session filtered by access_url
3438 3438
      *
3439
-     * @param $userId
3440
-     * @param $sessionId
3439
+     * @param integer $userId
3440
+     * @param null|integer $sessionId
3441 3441
      * @param null $from
3442 3442
      * @param null $limit
3443 3443
      * @param null $column
@@ -3562,6 +3562,7 @@  discard block
 block discarded – undo
3562 3562
     /**
3563 3563
      * Gets the count of courses by session filtered by access_url
3564 3564
      * @param int session id
3565
+     * @param integer $session_id
3565 3566
      * @return array list of courses
3566 3567
      */
3567 3568
     public static function getCourseCountBySessionId($session_id, $keyword = null)
@@ -3820,6 +3821,7 @@  discard block
 block discarded – undo
3820 3821
      * Updates a session status
3821 3822
      * @param	int 	session id
3822 3823
      * @param	int 	status
3824
+     * @param integer $status
3823 3825
      */
3824 3826
     public static function set_session_status($session_id, $status)
3825 3827
     {
@@ -4028,7 +4030,7 @@  discard block
 block discarded – undo
4028 4030
      * Protect a session to be edited.
4029 4031
      * @param int $id
4030 4032
      * @param bool $checkSession
4031
-     * @return mixed | bool true if pass the check, api_not_allowed otherwise
4033
+     * @return boolean|null | bool true if pass the check, api_not_allowed otherwise
4032 4034
      */
4033 4035
     public static function protectSession($id, $checkSession = true)
4034 4036
     {
@@ -4136,7 +4138,7 @@  discard block
 block discarded – undo
4136 4138
 
4137 4139
     /**
4138 4140
      * @param $id
4139
-     * @return bool
4141
+     * @return null|boolean
4140 4142
      */
4141 4143
     public static function protect_teacher_session_edit($id)
4142 4144
     {
@@ -4201,7 +4203,7 @@  discard block
 block discarded – undo
4201 4203
      *  true: if the session exists it will be updated.
4202 4204
      *  false: if session exists a new session will be created adding a counter session1, session2, etc
4203 4205
      * @param int $defaultUserId
4204
-     * @param mixed $logger
4206
+     * @param Logger $logger
4205 4207
      * @param array $extraFields convert a file row to an extra field. Example in CSV file there's a SessionID then it will
4206 4208
      * converted to extra_external_session_id if you set this: array('SessionId' => 'extra_external_session_id')
4207 4209
      * @param string $extraFieldId
@@ -5504,7 +5506,6 @@  discard block
 block discarded – undo
5504 5506
      * @param string $lastConnectionDate
5505 5507
      * @param array $sessionIdList
5506 5508
      * @param array $studentIdList
5507
-     * @param int $userStatus STUDENT|COURSEMANAGER constants
5508 5509
      *
5509 5510
      * @return array|int
5510 5511
      */
@@ -5656,7 +5657,7 @@  discard block
 block discarded – undo
5656 5657
     /**
5657 5658
      * Get the list of course tools that have to be dealt with in case of
5658 5659
      * registering any course to a session
5659
-     * @return array The list of tools to be dealt with (literal names)
5660
+     * @return string[] The list of tools to be dealt with (literal names)
5660 5661
      */
5661 5662
     public static function getCourseToolToBeManaged()
5662 5663
     {
@@ -5670,7 +5671,7 @@  discard block
 block discarded – undo
5670 5671
      * Calls the methods bound to each tool when a course is registered into a session
5671 5672
      * @param int $sessionId
5672 5673
      * @param int $courseId
5673
-     * @return void
5674
+     * @return boolean|null
5674 5675
      */
5675 5676
     public static function installCourse($sessionId, $courseId)
5676 5677
     {
@@ -6320,6 +6321,7 @@  discard block
 block discarded – undo
6320 6321
      * @param int $categoryId The internal ID of the session category
6321 6322
      * @param string $target Value to search for in the session field values
6322 6323
      * @param array $extraFields A list of fields to be scanned and returned
6324
+     * @param DateTime $publicationDate
6323 6325
      * @return mixed
6324 6326
      */
6325 6327
     public static function getShortSessionListAndExtraByCategory(
@@ -7656,7 +7658,7 @@  discard block
 block discarded – undo
7656 7658
     /**
7657 7659
      * Get link to the admin page for this session
7658 7660
      * @param   int $id Session ID
7659
-     * @return mixed    URL to the admin page to manage the session, or false on error
7661
+     * @return false|string    URL to the admin page to manage the session, or false on error
7660 7662
      */
7661 7663
     public static function getAdminPath($id)
7662 7664
     {
@@ -7673,7 +7675,7 @@  discard block
 block discarded – undo
7673 7675
      * If a course is provided, build the link to the course
7674 7676
      * @param   int $id Session ID
7675 7677
      * @param   int $courseId Course ID (optional) in case the link has to send straight to the course
7676
-     * @return mixed    URL to the page to use the session, or false on error
7678
+     * @return false|string    URL to the page to use the session, or false on error
7677 7679
      */
7678 7680
     public static function getPath($id, $courseId = 0)
7679 7681
     {
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     return $msg;
178 178
                 }
179 179
             } else {
180
-                $rs = Database::query("SELECT 1 FROM $tbl_session WHERE name='" . $name . "'");
180
+                $rs = Database::query("SELECT 1 FROM $tbl_session WHERE name='".$name."'");
181 181
                 if (Database::num_rows($rs)) {
182 182
                     $msg = get_lang('SessionNameAlreadyExists');
183 183
                     return $msg;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     public static function session_name_exists($name)
291 291
     {
292 292
         $name = Database::escape_string($name);
293
-        $sql = "SELECT COUNT(*) as count FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . "
293
+        $sql = "SELECT COUNT(*) as count FROM ".Database::get_main_table(TABLE_MAIN_SESSION)."
294 294
                 WHERE name = '$name'";
295 295
         $result = Database::fetch_array(Database::query($sql));
296 296
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
             $where .= " AND (
322 322
                             s.session_admin_id = $user_id  OR
323 323
                             sru.user_id = '$user_id' AND
324
-                            sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "'
324
+                            sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."'
325 325
                             )
326 326
                       ";
327 327
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             $where_condition = str_replace('category_name', 'sc.name', $where_condition);
340 340
             $where_condition = str_replace(
341 341
                 array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
342
-                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " )
342
+                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
343 343
                 , $where_condition
344 344
             );
345 345
             $where_condition = str_replace(
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 
385 385
             $access_url_id = api_get_current_access_url_id();
386 386
             if ($access_url_id != -1) {
387
-                $where.= " AND ar.access_url_id = $access_url_id ";
387
+                $where .= " AND ar.access_url_id = $access_url_id ";
388 388
 
389 389
                 $sql = "SELECT count(id) as total_rows FROM (
390 390
                 SELECT DISTINCT
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
             if (api_is_session_admin() &&
435 435
                 api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
436 436
             ) {
437
-                $where .=" AND s.session_admin_id = $user_id ";
437
+                $where .= " AND s.session_admin_id = $user_id ";
438 438
             }
439 439
         }
440 440
 
441 441
         if (!api_is_platform_admin() && api_is_teacher() &&
442 442
             api_get_setting('allow_teachers_to_create_sessions') == 'true'
443 443
         ) {
444
-            $where .=" AND s.id_coach = $user_id ";
444
+            $where .= " AND s.id_coach = $user_id ";
445 445
         }
446 446
 
447 447
         $extra_field = new ExtraFieldModel('session');
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
         $query = "$select FROM $tbl_session s $inject_joins $where $inject_where";
493 493
 
494 494
         if (api_is_multiple_url_enabled()) {
495
-            $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
495
+            $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
496 496
             $access_url_id = api_get_current_access_url_id();
497 497
             if ($access_url_id != -1) {
498
-                $where.= " AND ar.access_url_id = $access_url_id ";
498
+                $where .= " AND ar.access_url_id = $access_url_id ";
499 499
                 $query = "$select
500 500
                         FROM $tbl_session s $inject_joins
501 501
                         INNER JOIN $table_access_url_rel_session ar
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
                 INNER JOIN $tbl_lp l ON l.id = v.lp_id
600 600
                 INNER JOIN $tbl_user u ON u.user_id = v.user_id
601 601
                 INNER JOIN $tbl_course c
602
-                WHERE v.session_id = " . $sessionId;
602
+                WHERE v.session_id = ".$sessionId;
603 603
         $result_rows = Database::query($sql);
604 604
         $row = Database::fetch_array($result_rows);
605 605
         $num = $row['total_rows'];
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 
652 652
         $limit = null;
653 653
         if (!empty($options['limit'])) {
654
-            $limit = " LIMIT " . $options['limit'];
654
+            $limit = " LIMIT ".$options['limit'];
655 655
         }
656 656
 
657 657
         if (!empty($options['where'])) {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
         $order = null;
662 662
         if (!empty($options['order'])) {
663
-            $order = " ORDER BY " . $options['order'];
663
+            $order = " ORDER BY ".$options['order'];
664 664
         }
665 665
 
666 666
         $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
             foreach ($lessons as $lesson) {
720 720
                 $data[$lesson['id']] = (!empty($user_lessons[$lesson['id']]['progress'])) ? $user_lessons[$lesson['id']]['progress'] : 0;
721 721
                 $progress += $data[$lesson['id']];
722
-                $data[$lesson['id']] = $data[$lesson['id']] . '%';
722
+                $data[$lesson['id']] = $data[$lesson['id']].'%';
723 723
                 $count++;
724 724
             }
725 725
             if ($count == 0) {
726 726
                 $data['total'] = 0;
727 727
             } else {
728
-                $data['total'] = round($progress / $count, 2) . '%';
728
+                $data['total'] = round($progress / $count, 2).'%';
729 729
             }
730 730
             $table[] = $data;
731 731
         }
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 
767 767
         $limit = null;
768 768
         if (!empty($options['limit'])) {
769
-            $limit = " LIMIT " . $options['limit'];
769
+            $limit = " LIMIT ".$options['limit'];
770 770
         }
771 771
 
772 772
         if (!empty($options['where'])) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
         $order = null;
777 777
         if (!empty($options['order'])) {
778
-            $order = " ORDER BY " . $options['order'];
778
+            $order = " ORDER BY ".$options['order'];
779 779
         }
780 780
 
781 781
         $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.c_id
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 
878 878
         $limit = null;
879 879
         if (!empty($options['limit'])) {
880
-            $limit = " LIMIT " . $options['limit'];
880
+            $limit = " LIMIT ".$options['limit'];
881 881
         }
882 882
 
883 883
         if (!empty($options['where'])) {
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 
887 887
         $order = null;
888 888
         if (!empty($options['order'])) {
889
-            $order = " ORDER BY " . $options['order'];
889
+            $order = " ORDER BY ".$options['order'];
890 890
         }
891 891
 
892 892
         //TODO, fix create report without session
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
         /**
920 920
          *  Lessons
921 921
          */
922
-        $sql = "SELECT * FROM $tbl_course_lp WHERE c_id = %s ";  //AND session_id = %s
922
+        $sql = "SELECT * FROM $tbl_course_lp WHERE c_id = %s "; //AND session_id = %s
923 923
         $sql_query = sprintf($sql, $course['real_id']);
924 924
         $result = Database::query($sql_query);
925 925
         $arrLesson = array(array());
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
             if (empty($arrLesson[$row['session_id']]['lessons_total'])) {
928 928
                 $arrLesson[$row['session_id']]['lessons_total'] = 1;
929 929
             } else {
930
-                $arrLesson[$row['session_id']]['lessons_total'] ++;
930
+                $arrLesson[$row['session_id']]['lessons_total']++;
931 931
             }
932 932
         }
933 933
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                 $course['real_id']
1004 1004
             );
1005 1005
             foreach ($user_list as $user_id) {
1006
-                isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id] ++ : $survey_user_list[$user_id] = 1;
1006
+                isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : $survey_user_list[$user_id] = 1;
1007 1007
             }
1008 1008
         }
1009 1009
 
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
             $assignments_done = Tracking::count_student_assignments($user['user_id'], $course['code'], $user['id_session']);
1058 1058
             $assignments_left = $assignments_total - $assignments_done;
1059 1059
             if (!empty($assignments_total)) {
1060
-                $assignments_progress = round((( $assignments_done * 100 ) / $assignments_total), 2);
1060
+                $assignments_progress = round((($assignments_done * 100) / $assignments_total), 2);
1061 1061
             } else {
1062 1062
                 $assignments_progress = 0;
1063 1063
             }
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
             $wiki_read = $row['count'];
1088 1088
             $wiki_unread = $wiki_total - $wiki_read;
1089 1089
             if (!empty($wiki_total)) {
1090
-                $wiki_progress = round((( $wiki_read * 100 ) / $wiki_total), 2);
1090
+                $wiki_progress = round((($wiki_read * 100) / $wiki_total), 2);
1091 1091
             } else {
1092 1092
                 $wiki_progress = 0;
1093 1093
             }
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
             $surveys_done = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0);
1097 1097
             $surveys_left = $surveys_total - $surveys_done;
1098 1098
             if (!empty($surveys_total)) {
1099
-                $surveys_progress = round((( $surveys_done * 100 ) / $surveys_total), 2);
1099
+                $surveys_progress = round((($surveys_done * 100) / $surveys_total), 2);
1100 1100
             } else {
1101 1101
                 $surveys_progress = 0;
1102 1102
             }
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
             );
1110 1110
             $forums_left = $forums_total - $forums_done;
1111 1111
             if (!empty($forums_total)) {
1112
-                $forums_progress = round((( $forums_done * 100 ) / $forums_total), 2);
1112
+                $forums_progress = round((($forums_done * 100) / $forums_total), 2);
1113 1113
             } else {
1114 1114
                 $forums_progress = 0;
1115 1115
             }
@@ -1117,58 +1117,58 @@  discard block
 block discarded – undo
1117 1117
             //Overall Total
1118 1118
             $overall_total = ($course_description_progress + $exercises_progress + $forums_progress + $assignments_progress + $wiki_progress + $surveys_progress) / 6;
1119 1119
 
1120
-            $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>';
1121
-            $linkForum = '<a href="' . api_get_path(WEB_CODE_PATH) . 'forum/index.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
1122
-            $linkWork = '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
1123
-            $linkWiki = '<a href="' . api_get_path(WEB_CODE_PATH) . 'wiki/index.php?cidReq=' . $course['code'] . '&session_id=' . $user['id_session'] . '&action=statistics"> %s </a>';
1124
-            $linkSurvey = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
1120
+            $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>';
1121
+            $linkForum = '<a href="'.api_get_path(WEB_CODE_PATH).'forum/index.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>';
1122
+            $linkWork = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>';
1123
+            $linkWiki = '<a href="'.api_get_path(WEB_CODE_PATH).'wiki/index.php?cidReq='.$course['code'].'&session_id='.$user['id_session'].'&action=statistics"> %s </a>';
1124
+            $linkSurvey = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?cidReq='.$course['code'].'&id_session='.$user['id_session'].'"> %s </a>';
1125 1125
 
1126 1126
             $table[] = array(
1127 1127
                 'lastname' => $user[1],
1128 1128
                 'firstname' => $user[2],
1129 1129
                 'username' => $user[3],
1130 1130
                 #'profile'   => '',
1131
-                'total' => round($overall_total, 2) . '%',
1132
-                'courses' => sprintf($link, $course_description_progress . '%'),
1133
-                'lessons' => sprintf($link, $lessons_progress . '%'),
1134
-                'exercises' => sprintf($link, $exercises_progress . '%'),
1135
-                'forums' => sprintf($link, $forums_progress . '%'),
1136
-                'homeworks' => sprintf($link, $assignments_progress . '%'),
1137
-                'wikis' => sprintf($link, $wiki_progress . '%'),
1138
-                'surveys' => sprintf($link, $surveys_progress . '%'),
1131
+                'total' => round($overall_total, 2).'%',
1132
+                'courses' => sprintf($link, $course_description_progress.'%'),
1133
+                'lessons' => sprintf($link, $lessons_progress.'%'),
1134
+                'exercises' => sprintf($link, $exercises_progress.'%'),
1135
+                'forums' => sprintf($link, $forums_progress.'%'),
1136
+                'homeworks' => sprintf($link, $assignments_progress.'%'),
1137
+                'wikis' => sprintf($link, $wiki_progress.'%'),
1138
+                'surveys' => sprintf($link, $surveys_progress.'%'),
1139 1139
                 //course description
1140
-                'course_description_progress' => $course_description_progress . '%',
1140
+                'course_description_progress' => $course_description_progress.'%',
1141 1141
                 //lessons
1142 1142
                 'lessons_total' => sprintf($link, $lessons_total),
1143 1143
                 'lessons_done' => sprintf($link, $lessons_done),
1144 1144
                 'lessons_left' => sprintf($link, $lessons_left),
1145
-                'lessons_progress' => sprintf($link, $lessons_progress . '%'),
1145
+                'lessons_progress' => sprintf($link, $lessons_progress.'%'),
1146 1146
                 //exercises
1147 1147
                 'exercises_total' => sprintf($link, $exercises_total),
1148 1148
                 'exercises_done' => sprintf($link, $exercises_done),
1149 1149
                 'exercises_left' => sprintf($link, $exercises_left),
1150
-                'exercises_progress' => sprintf($link, $exercises_progress . '%'),
1150
+                'exercises_progress' => sprintf($link, $exercises_progress.'%'),
1151 1151
                 //forums
1152 1152
                 'forums_total' => sprintf($linkForum, $forums_total),
1153 1153
                 'forums_done' => sprintf($linkForum, $forums_done),
1154 1154
                 'forums_left' => sprintf($linkForum, $forums_left),
1155
-                'forums_progress' => sprintf($linkForum, $forums_progress . '%'),
1155
+                'forums_progress' => sprintf($linkForum, $forums_progress.'%'),
1156 1156
                 //assignments
1157 1157
                 'assignments_total' => sprintf($linkWork, $assignments_total),
1158 1158
                 'assignments_done' => sprintf($linkWork, $assignments_done),
1159 1159
                 'assignments_left' => sprintf($linkWork, $assignments_left),
1160
-                'assignments_progress' => sprintf($linkWork, $assignments_progress . '%'),
1160
+                'assignments_progress' => sprintf($linkWork, $assignments_progress.'%'),
1161 1161
                 //wiki
1162 1162
                 'wiki_total' => sprintf($linkWiki, $wiki_total),
1163 1163
                 'wiki_revisions' => sprintf($linkWiki, $wiki_revisions),
1164 1164
                 'wiki_read' => sprintf($linkWiki, $wiki_read),
1165 1165
                 'wiki_unread' => sprintf($linkWiki, $wiki_unread),
1166
-                'wiki_progress' => sprintf($linkWiki, $wiki_progress . '%'),
1166
+                'wiki_progress' => sprintf($linkWiki, $wiki_progress.'%'),
1167 1167
                 //survey
1168 1168
                 'surveys_total' => sprintf($linkSurvey, $surveys_total),
1169 1169
                 'surveys_done' => sprintf($linkSurvey, $surveys_done),
1170 1170
                 'surveys_left' => sprintf($linkSurvey, $surveys_left),
1171
-                'surveys_progress' => sprintf($linkSurvey, $surveys_progress . '%'),
1171
+                'surveys_progress' => sprintf($linkSurvey, $surveys_progress.'%'),
1172 1172
             );
1173 1173
         }
1174 1174
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
         $limit = null;
1252 1252
         if (!empty($options['limit'])) {
1253
-            $limit = " LIMIT " . $options['limit'];
1253
+            $limit = " LIMIT ".$options['limit'];
1254 1254
         }
1255 1255
 
1256 1256
         if (!empty($options['where'])) {
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 
1260 1260
         $order = null;
1261 1261
         if (!empty($options['order'])) {
1262
-            $order = " ORDER BY " . $options['order'];
1262
+            $order = " ORDER BY ".$options['order'];
1263 1263
         }
1264 1264
 
1265 1265
         //TODO add course name
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
                     " : "
1273 1273
                     u.lastname,
1274 1274
                     u.firstname,
1275
-                ") . "
1275
+                ")."
1276 1276
                 a.logout_course_date,
1277 1277
                 a.counter,
1278 1278
                 c.title,
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
             if (Database::num_rows($result) > 0) {
1355 1355
                 $row = Database::fetch_array($result);
1356 1356
                 $count = $row['count'] + 1;
1357
-                $session_name = $session_name . '_' . $count;
1357
+                $session_name = $session_name.'_'.$count;
1358 1358
                 $result = self::session_name_exists($session_name);
1359 1359
                 if (!$result) {
1360 1360
                     return $session_name;
@@ -1861,7 +1861,7 @@  discard block
 block discarded – undo
1861 1861
         // Delete users from the session
1862 1862
         if ($empty_users === true) {
1863 1863
             $sql = "DELETE FROM $tbl_session_rel_user
1864
-                    WHERE session_id = $id_session AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . "";
1864
+                    WHERE session_id = $id_session AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
1865 1865
             Database::query($sql);
1866 1866
         }
1867 1867
 
@@ -1872,7 +1872,7 @@  discard block
 block discarded – undo
1872 1872
             $enreg_user = Database::escape_string($enreg_user);
1873 1873
             $nbr_users++;
1874 1874
             $sql = "INSERT IGNORE INTO $tbl_session_rel_user (relation_type, session_id, user_id, registered_at)
1875
-                    VALUES (0, $id_session, $enreg_user, '" . api_get_utc_datetime() . "')";
1875
+                    VALUES (0, $id_session, $enreg_user, '".api_get_utc_datetime()."')";
1876 1876
             Database::query($sql);
1877 1877
         }
1878 1878
 
@@ -1962,9 +1962,9 @@  discard block
 block discarded – undo
1962 1962
         is_array($courseInfo) ? $courseId = $courseInfo['real_id'] : $courseId = $courseInfo;
1963 1963
 
1964 1964
         $statusCondition = null;
1965
-        if (isset($status) && !is_null($status))  {
1965
+        if (isset($status) && !is_null($status)) {
1966 1966
             $status = intval($status);
1967
-            $statusCondition  = " AND status = $status";
1967
+            $statusCondition = " AND status = $status";
1968 1968
         }
1969 1969
 
1970 1970
         foreach ($userList as $userId) {
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
             if (empty($count)) {
2097 2097
                 // If user is not registered to a session then add it.
2098 2098
                 $sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id, registered_at)
2099
-                        VALUES ($session_id, $enreg_user, '" . api_get_utc_datetime() . "')";
2099
+                        VALUES ($session_id, $enreg_user, '".api_get_utc_datetime()."')";
2100 2100
                 Database::query($sql);
2101 2101
 
2102 2102
                 $sql = "UPDATE $tbl_session SET nbr_users = nbr_users + 1
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
                 WHERE
2140 2140
                     session_id = $session_id AND
2141 2141
                     user_id = $user_id AND
2142
-                    relation_type <> " . SESSION_RELATION_TYPE_RRHH . "";
2142
+                    relation_type <> ".SESSION_RELATION_TYPE_RRHH."";
2143 2143
         $result = Database::query($sql);
2144 2144
         $return = Database::affected_rows($result);
2145 2145
 
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
                 FROM $tbl_session_rel_user
2225 2225
                 WHERE
2226 2226
                     session_id = $sessionId AND
2227
-                    relation_type<>" . SESSION_RELATION_TYPE_RRHH;
2227
+                    relation_type<>".SESSION_RELATION_TYPE_RRHH;
2228 2228
         $result = Database::query($sql);
2229 2229
         $user_list = Database::store_result($result);
2230 2230
 
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
 
2236 2236
                     $sql = "DELETE FROM $tbl_session_rel_course
2237 2237
                             WHERE
2238
-                                c_id = " . $existingCourse['c_id'] . " AND
2238
+                                c_id = ".$existingCourse['c_id']." AND
2239 2239
                                 session_id = $sessionId";
2240 2240
                     Database::query($sql);
2241 2241
 
@@ -2298,7 +2298,7 @@  discard block
 block discarded – undo
2298 2298
                             $links = $cat->get_links(null, false, $courseInfo['code'], 0);
2299 2299
 
2300 2300
                             $cat->set_session_id($sessionId);
2301
-                            $oldCategoryId= $cat->get_id();
2301
+                            $oldCategoryId = $cat->get_id();
2302 2302
                             $newId = $cat->add();
2303 2303
                             $newCategoryIdList[$oldCategoryId] = $newId;
2304 2304
                             $parentId = $cat->get_parent_id();
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
         $return_value = false;
2486 2486
         $sql = "SELECT c_id FROM $tbl_session_course
2487 2487
                 WHERE
2488
-                  session_id = " . intval($session_id) . " AND
2488
+                  session_id = ".intval($session_id)." AND
2489 2489
                   c_id = " . intval($courseId);
2490 2490
         $result = Database::query($sql);
2491 2491
         $num = Database::num_rows($result);
@@ -2509,8 +2509,8 @@  discard block
 block discarded – undo
2509 2509
         }
2510 2510
 
2511 2511
         $sql = 'SELECT *
2512
-		        FROM ' . $tbl_session . '
2513
-		        WHERE name = "' . Database::escape_string($session_name) . '"';
2512
+		        FROM ' . $tbl_session.'
2513
+		        WHERE name = "' . Database::escape_string($session_name).'"';
2514 2514
         $result = Database::query($sql);
2515 2515
         $num = Database::num_rows($result);
2516 2516
         if ($num > 0) {
@@ -2550,8 +2550,8 @@  discard block
 block discarded – undo
2550 2550
         $month_end = intval($smonth_end);
2551 2551
         $day_end = intval($sday_end);
2552 2552
 
2553
-        $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
2554
-        $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
2553
+        $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
2554
+        $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
2555 2555
 
2556 2556
         if (empty($name)) {
2557 2557
             $msg = get_lang('SessionCategoryNameIsRequired');
@@ -2628,8 +2628,8 @@  discard block
 block discarded – undo
2628 2628
         $month_end = intval($smonth_end);
2629 2629
         $day_end = intval($sday_end);
2630 2630
         $id = intval($id);
2631
-        $date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
2632
-        $date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
2631
+        $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
2632
+        $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
2633 2633
 
2634 2634
         if (empty($name)) {
2635 2635
             $msg = get_lang('SessionCategoryNameIsRequired');
@@ -2649,13 +2649,13 @@  discard block
 block discarded – undo
2649 2649
         if ($date_end <> null) {
2650 2650
             $sql = "UPDATE $tbl_session_category
2651 2651
                     SET
2652
-                        name = '" . Database::escape_string($name) . "',
2652
+                        name = '".Database::escape_string($name)."',
2653 2653
                         date_start = '$date_start' ,
2654 2654
                         date_end = '$date_end'
2655 2655
                     WHERE id= $id";
2656 2656
         } else {
2657 2657
             $sql = "UPDATE $tbl_session_category SET
2658
-                        name = '" . Database::escape_string($name) . "',
2658
+                        name = '".Database::escape_string($name)."',
2659 2659
                         date_start = '$date_start',
2660 2660
                         date_end = NULL
2661 2661
                     WHERE id= $id";
@@ -2685,10 +2685,10 @@  discard block
 block discarded – undo
2685 2685
 
2686 2686
         //Setting session_category_id to 0
2687 2687
         $sql = "UPDATE $tbl_session SET session_category_id = 0
2688
-                WHERE session_category_id IN (" . $id_checked . ")";
2688
+                WHERE session_category_id IN (".$id_checked.")";
2689 2689
         Database::query($sql);
2690 2690
 
2691
-        $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (" . $id_checked . ")";
2691
+        $sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
2692 2692
         $result = Database::query($sql);
2693 2693
         while ($rows = Database::fetch_array($result)) {
2694 2694
             $session_id = $rows['id'];
@@ -2700,7 +2700,7 @@  discard block
 block discarded – undo
2700 2700
                 }
2701 2701
             }
2702 2702
         }
2703
-        $sql = "DELETE FROM $tbl_session_category WHERE id IN (" . $id_checked . ")";
2703
+        $sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")";
2704 2704
         Database::query($sql);
2705 2705
 
2706 2706
         // Add event to system log
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
                 $value = Database::escape_string($options['value']);
2774 2774
                 $sql_query .= ' AND ';
2775 2775
                 if (in_array($field, $availableFields) && in_array($operator, $availableOperator)) {
2776
-                    $sql_query .= $field . " $operator '" . $value . "'";
2776
+                    $sql_query .= $field." $operator '".$value."'";
2777 2777
                 }
2778 2778
             }
2779 2779
         }
@@ -2840,8 +2840,8 @@  discard block
 block discarded – undo
2840 2840
     {
2841 2841
         $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
2842 2842
         $id = api_get_current_access_url_id();
2843
-        $sql = 'SELECT * FROM ' . $tbl_session_category . '
2844
-                WHERE access_url_id = ' . $id . '
2843
+        $sql = 'SELECT * FROM '.$tbl_session_category.'
2844
+                WHERE access_url_id = ' . $id.'
2845 2845
                 ORDER BY name ASC';
2846 2846
         $result = Database::query($sql);
2847 2847
         if (Database::num_rows($result) > 0) {
@@ -2994,7 +2994,7 @@  discard block
 block discarded – undo
2994 2994
         $sql = "DELETE FROM $tbl_session_rel_user
2995 2995
                 WHERE
2996 2996
                     session_id = $sessionId AND                            
2997
-                    relation_type =" . SESSION_RELATION_TYPE_RRHH;
2997
+                    relation_type =".SESSION_RELATION_TYPE_RRHH;
2998 2998
         Database::query($sql);
2999 2999
 
3000 3000
         return true;
@@ -3048,12 +3048,12 @@  discard block
 block discarded – undo
3048 3048
                         ON (a.session_id = s.session_id)
3049 3049
                         WHERE
3050 3050
                             s.user_id = $userId AND
3051
-                            relation_type = " . SESSION_RELATION_TYPE_RRHH . " AND
3051
+                            relation_type = ".SESSION_RELATION_TYPE_RRHH." AND
3052 3052
                             access_url_id = " . api_get_current_access_url_id();
3053 3053
             } else {
3054 3054
                 $sql = "SELECT s.session_id 
3055 3055
                         FROM $tbl_session_rel_user s
3056
-                        WHERE user_id = $userId AND relation_type=" . SESSION_RELATION_TYPE_RRHH;
3056
+                        WHERE user_id = $userId AND relation_type=".SESSION_RELATION_TYPE_RRHH;
3057 3057
             }
3058 3058
             $result = Database::query($sql);
3059 3059
 
@@ -3063,7 +3063,7 @@  discard block
 block discarded – undo
3063 3063
                             WHERE
3064 3064
                                 session_id = {$row['session_id']} AND
3065 3065
                                 user_id = $userId AND
3066
-                                relation_type =" . SESSION_RELATION_TYPE_RRHH;
3066
+                                relation_type =".SESSION_RELATION_TYPE_RRHH;
3067 3067
                     Database::query($sql);
3068 3068
                 }
3069 3069
             }
@@ -3077,8 +3077,8 @@  discard block
 block discarded – undo
3077 3077
                         VALUES (
3078 3078
                             $session_id,
3079 3079
                             $userId,
3080
-                            '" . SESSION_RELATION_TYPE_RRHH . "',
3081
-                            '" . api_get_utc_datetime() . "'
3080
+                            '".SESSION_RELATION_TYPE_RRHH."',
3081
+                            '" . api_get_utc_datetime()."'
3082 3082
                         )";
3083 3083
                 Database::query($sql);
3084 3084
                 $affected_rows++;
@@ -3119,8 +3119,8 @@  discard block
 block discarded – undo
3119 3119
                     WHERE
3120 3120
                         sru.user_id = '$userId' AND
3121 3121
                         sru.session_id = '$sessionId' AND
3122
-                        sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "' AND
3123
-                        access_url_id = " . api_get_current_access_url_id() . "
3122
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND
3123
+                        access_url_id = " . api_get_current_access_url_id()."
3124 3124
                         ";
3125 3125
         } else {
3126 3126
             $sql = "$select FROM $tbl_session s
@@ -3129,7 +3129,7 @@  discard block
 block discarded – undo
3129 3129
                         sru.session_id = s.id AND
3130 3130
                         sru.user_id = '$userId' AND
3131 3131
                         sru.session_id = '$sessionId' AND
3132
-                        sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "'
3132
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."'
3133 3133
                     ";
3134 3134
         }
3135 3135
 
@@ -3229,7 +3229,7 @@  discard block
 block discarded – undo
3229 3229
 
3230 3230
         $limitCondition = null;
3231 3231
         if (!empty($start) && !empty($limit)) {
3232
-            $limitCondition = " LIMIT " . intval($start) . ", " . intval($limit);
3232
+            $limitCondition = " LIMIT ".intval($start).", ".intval($limit);
3233 3233
         }
3234 3234
 
3235 3235
         if (empty($orderCondition)) {
@@ -3306,26 +3306,26 @@  discard block
 block discarded – undo
3306 3306
 
3307 3307
         $sessions = array();
3308 3308
         if (Database::num_rows($result) > 0) {
3309
-            $sysUploadPath = api_get_path(SYS_UPLOAD_PATH). 'sessions/';
3310
-            $webUploadPath = api_get_path(WEB_UPLOAD_PATH). 'sessions/';
3309
+            $sysUploadPath = api_get_path(SYS_UPLOAD_PATH).'sessions/';
3310
+            $webUploadPath = api_get_path(WEB_UPLOAD_PATH).'sessions/';
3311 3311
             $imgPath = Display::return_icon('session_default_small.png', null, null, null, null, true);
3312 3312
 
3313 3313
             $tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD);
3314
-            $sql = "SELECT id FROM " . $tableExtraFields . "
3314
+            $sql = "SELECT id FROM ".$tableExtraFields."
3315 3315
                     WHERE extra_field_type = 3 AND variable='image'";
3316 3316
             $resultField = Database::query($sql);
3317 3317
             $imageFieldId = Database::fetch_assoc($resultField);
3318 3318
 
3319 3319
             while ($row = Database::fetch_array($result)) {
3320 3320
 
3321
-                $row['image'] =  null;
3322
-                $sessionImage = $sysUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png';
3321
+                $row['image'] = null;
3322
+                $sessionImage = $sysUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png';
3323 3323
 
3324 3324
                 if (is_file($sessionImage)) {
3325
-                    $sessionImage = $webUploadPath . $imageFieldId['id'] . '_' . $row['id'] . '.png';
3325
+                    $sessionImage = $webUploadPath.$imageFieldId['id'].'_'.$row['id'].'.png';
3326 3326
                     $row['image'] = $sessionImage;
3327 3327
                 } else {
3328
-                    $row['image'] =  $imgPath;
3328
+                    $row['image'] = $imgPath;
3329 3329
                 }
3330 3330
 
3331 3331
                 if ($row['display_start_date'] == '0000-00-00 00:00:00' || $row['display_start_date'] == '0000-00-00') {
@@ -3425,7 +3425,7 @@  discard block
 block discarded – undo
3425 3425
                 return intval($count['count']);
3426 3426
             }
3427 3427
 
3428
-            while ($row = Database::fetch_array($result,'ASSOC'))	{
3428
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
3429 3429
                 $courses[$row['real_id']] = $row;
3430 3430
             }
3431 3431
         }
@@ -3469,7 +3469,7 @@  discard block
 block discarded – undo
3469 3469
         }
3470 3470
 
3471 3471
         $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
3472
-        $tbl_session_rel_course	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
3472
+        $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
3473 3473
 
3474 3474
         if ($getCount) {
3475 3475
             $select = "SELECT COUNT(DISTINCT(c.code)) as count ";
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
 		        ";
3495 3495
         if ($getCount) {
3496 3496
             $result = Database::query($sql);
3497
-            $row = Database::fetch_array($result,'ASSOC');
3497
+            $row = Database::fetch_array($result, 'ASSOC');
3498 3498
             return $row['count'];
3499 3499
         }
3500 3500
 
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
         $courses = array();
3510 3510
 
3511 3511
         if ($num_rows > 0) {
3512
-            while ($row = Database::fetch_array($result,'ASSOC'))	{
3512
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
3513 3513
                 $courses[$row['id']] = $row;
3514 3514
             }
3515 3515
         }
@@ -3587,7 +3587,7 @@  discard block
 block discarded – undo
3587 3587
         $result = Database::query($sql);
3588 3588
         $num_rows = Database::num_rows($result);
3589 3589
         if ($num_rows > 0) {
3590
-            $row = Database::fetch_array($result,'ASSOC');
3590
+            $row = Database::fetch_array($result, 'ASSOC');
3591 3591
             return $row['count'];
3592 3592
         }
3593 3593
 
@@ -3706,9 +3706,9 @@  discard block
 block discarded – undo
3706 3706
 
3707 3707
             if ($access_url_id != -1) {
3708 3708
                 $sql = 'SELECT DISTINCT session.*
3709
-                    FROM ' . $session_table . ' session INNER JOIN ' . $tbl_session_rel_access_url . ' session_rel_url
3709
+                    FROM ' . $session_table.' session INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
3710 3710
                     ON (session.id = session_rel_url.session_id)
3711
-                    WHERE '.$sqlCoach.' access_url_id = ' . $access_url_id;
3711
+                    WHERE '.$sqlCoach.' access_url_id = '.$access_url_id;
3712 3712
             }
3713 3713
         }
3714 3714
         $sql .= ' ORDER by name';
@@ -3742,8 +3742,8 @@  discard block
 block discarded – undo
3742 3742
                 FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
3743 3743
                 WHERE
3744 3744
                     session_rcru.user_id = user.user_id AND
3745
-                    session_rcru.session_id = '" . intval($session_id) . "' AND
3746
-                    session_rcru.c_id ='" . intval($courseId) . "' AND
3745
+                    session_rcru.session_id = '".intval($session_id)."' AND
3746
+                    session_rcru.c_id ='" . intval($courseId)."' AND
3747 3747
                     user.user_id = " . intval($user_id);
3748 3748
 
3749 3749
         $result = Database::query($sql);
@@ -3774,8 +3774,8 @@  discard block
 block discarded – undo
3774 3774
         $sql = "SELECT session_rcru.status
3775 3775
                 FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
3776 3776
                 WHERE session_rcru.user_id = user.user_id AND
3777
-                    session_rcru.session_id = '" . intval($session_id) . "' AND
3778
-                    session_rcru.c_id ='" . intval($courseId) . "' AND
3777
+                    session_rcru.session_id = '".intval($session_id)."' AND
3778
+                    session_rcru.c_id ='" . intval($courseId)."' AND
3779 3779
                     user.user_id = " . intval($user_id);
3780 3780
         $result = Database::query($sql);
3781 3781
         $status = false;
@@ -3852,7 +3852,7 @@  discard block
 block discarded – undo
3852 3852
         // Get timestamp for now in UTC - see http://php.net/manual/es/function.time.php#117251
3853 3853
         $now = time() - date('Z');
3854 3854
         // Timestamp in one month
3855
-        $inOneMonth = $now + (30*24*3600);
3855
+        $inOneMonth = $now + (30 * 24 * 3600);
3856 3856
         $inOneMonth = api_get_local_time($inOneMonth);
3857 3857
         if (api_strtotime($s['access_start_date']) < $now) {
3858 3858
             $s['access_start_date'] = api_get_local_time($now);
@@ -3874,16 +3874,16 @@  discard block
 block discarded – undo
3874 3874
         }
3875 3875
         // Now try to create the session
3876 3876
         $sid = self::create_session(
3877
-            $s['name'] . ' ' . get_lang('CopyLabelSuffix'),
3877
+            $s['name'].' '.get_lang('CopyLabelSuffix'),
3878 3878
             $s['access_start_date'],
3879 3879
             $s['access_end_date'],
3880 3880
             $s['display_start_date'],
3881 3881
             $s['display_end_date'],
3882 3882
             $s['coach_access_start_date'],
3883 3883
             $s['coach_access_end_date'],
3884
-            (int)$s['id_coach'],
3884
+            (int) $s['id_coach'],
3885 3885
             $s['session_category_id'],
3886
-            (int)$s['visibility'],
3886
+            (int) $s['visibility'],
3887 3887
             true
3888 3888
         );
3889 3889
 
@@ -3997,7 +3997,7 @@  discard block
 block discarded – undo
3997 3997
         $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
3998 3998
         $sql = "SELECT DISTINCT id
3999 3999
 	         	FROM $session_table
4000
-	         	WHERE session.id_coach =  '" . $user_id . "' AND id = '$session_id'";
4000
+	         	WHERE session.id_coach =  '".$user_id."' AND id = '$session_id'";
4001 4001
         $result = Database::query($sql);
4002 4002
         if ($result && Database::num_rows($result)) {
4003 4003
             return true;
@@ -4016,7 +4016,7 @@  discard block
 block discarded – undo
4016 4016
         $access_url_rel_session_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
4017 4017
         $sql = "SELECT count(id) FROM $session_table s";
4018 4018
         if (!empty($access_url_id) && $access_url_id == intval($access_url_id)) {
4019
-            $sql .= ", $access_url_rel_session_table u " .
4019
+            $sql .= ", $access_url_rel_session_table u ".
4020 4020
                 " WHERE s.id = u.session_id AND u.access_url_id = $access_url_id";
4021 4021
         }
4022 4022
         $res = Database::query($sql);
@@ -4255,7 +4255,7 @@  discard block
 block discarded – undo
4255 4255
 
4256 4256
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
4257 4257
         $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
4258
-        $tbl_session_course  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
4258
+        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
4259 4259
         $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
4260 4260
 
4261 4261
         $sessions = array();
@@ -4391,10 +4391,10 @@  discard block
 block discarded – undo
4391 4391
                     $suffix = null;
4392 4392
                     while (!$unique_name) {
4393 4393
                         if ($i > 1) {
4394
-                            $suffix = ' - ' . $i;
4394
+                            $suffix = ' - '.$i;
4395 4395
                         }
4396
-                        $sql = 'SELECT 1 FROM ' . $tbl_session . '
4397
-                                WHERE name="' . Database::escape_string($session_name). $suffix . '"';
4396
+                        $sql = 'SELECT 1 FROM '.$tbl_session.'
4397
+                                WHERE name="' . Database::escape_string($session_name).$suffix.'"';
4398 4398
                         $rs = Database::query($sql);
4399 4399
 
4400 4400
                         if (Database::result($rs, 0, 0)) {
@@ -4407,14 +4407,14 @@  discard block
 block discarded – undo
4407 4407
 
4408 4408
                     // Creating the session.
4409 4409
                     $sql = "INSERT IGNORE INTO $tbl_session SET
4410
-                            name = '" . Database::escape_string($session_name). "',
4410
+                            name = '".Database::escape_string($session_name)."',
4411 4411
                             id_coach = '$coach_id',
4412 4412
                             access_start_date = '$dateStart',
4413 4413
                             access_end_date = '$dateEnd',
4414 4414
                             display_start_date = '$dateStart',
4415 4415
                             display_end_date = '$dateEnd',
4416 4416
                             visibility = '$visibilityAfterExpirationPerSession',                            
4417
-                            session_admin_id = " . $defaultUserId . " 
4417
+                            session_admin_id = ".$defaultUserId." 
4418 4418
                             $sessionCondition $extraParameters $extraSessionParameters";
4419 4419
                     Database::query($sql);
4420 4420
 
@@ -4480,7 +4480,7 @@  discard block
 block discarded – undo
4480 4480
 
4481 4481
                             // Delete session-user relation only for students
4482 4482
                             $sql = "DELETE FROM $tbl_session_user
4483
-                                    WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH;
4483
+                                    WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH;
4484 4484
                             Database::query($sql);
4485 4485
 
4486 4486
                             $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'";
@@ -4571,7 +4571,7 @@  discard block
 block discarded – undo
4571 4571
 
4572 4572
                             // Delete session-user relation only for students
4573 4573
                             $sql = "DELETE FROM $tbl_session_user
4574
-                                    WHERE session_id = '$session_id' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH;
4574
+                                    WHERE session_id = '$session_id' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH;
4575 4575
                             Database::query($sql);
4576 4576
 
4577 4577
                             $sql = "DELETE FROM $tbl_session_course WHERE session_id = '$session_id'";
@@ -4614,7 +4614,7 @@  discard block
 block discarded – undo
4614 4614
                             $sql = "INSERT IGNORE INTO $tbl_session_user SET
4615 4615
                                     user_id = '$user_id',
4616 4616
                                     session_id = '$session_id',
4617
-                                    registered_at = '" . api_get_utc_datetime() . "'";
4617
+                                    registered_at = '".api_get_utc_datetime()."'";
4618 4618
                             Database::query($sql);
4619 4619
                             if ($debug) {
4620 4620
                                 $logger->addInfo("Sessions - Adding User #$user_id ($user) to session #$session_id");
@@ -5265,7 +5265,7 @@  discard block
 block discarded – undo
5265 5265
 
5266 5266
         if (!empty($lastConnectionDate)) {
5267 5267
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
5268
-            $userConditions .=  " AND u.last_login <= '$lastConnectionDate' ";
5268
+            $userConditions .= " AND u.last_login <= '$lastConnectionDate' ";
5269 5269
         }
5270 5270
 
5271 5271
         if (!empty($keyword)) {
@@ -5335,7 +5335,7 @@  discard block
 block discarded – undo
5335 5335
         $result = Database::query($sql);
5336 5336
         $result = Database::store_result($result);
5337 5337
 
5338
-        return $result ;
5338
+        return $result;
5339 5339
     }
5340 5340
 
5341 5341
     /**
@@ -5395,7 +5395,7 @@  discard block
 block discarded – undo
5395 5395
                     $userToString = null;
5396 5396
                     foreach ($userList as $userInfo) {
5397 5397
                         $newUserList[] = $userInfo['user_id'];
5398
-                        $userToString .= $userInfo['firstname'] . ' ' . $userInfo['lastname'] . '<br />';
5398
+                        $userToString .= $userInfo['firstname'].' '.$userInfo['lastname'].'<br />';
5399 5399
                     }
5400 5400
 
5401 5401
                     if (!empty($sessionsDestination)) {
@@ -5408,7 +5408,7 @@  discard block
 block discarded – undo
5408 5408
                                 $messages[] = Display::return_message(sprintf(get_lang('SessionXSkipped'), $sessionDestinationId), 'warning', false);
5409 5409
                                 continue;
5410 5410
                             }
5411
-                            $messages[] = Display::return_message(get_lang('StudentList') . '<br />' . $userToString, 'info', false);
5411
+                            $messages[] = Display::return_message(get_lang('StudentList').'<br />'.$userToString, 'info', false);
5412 5412
                             SessionManager::subscribe_users_to_session(
5413 5413
                                 $sessionDestinationId,
5414 5414
                                 $newUserList,
@@ -5463,7 +5463,7 @@  discard block
 block discarded – undo
5463 5463
                 }
5464 5464
             }
5465 5465
         }
5466
-        $sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=';
5466
+        $sessionUrl = api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session=';
5467 5467
 
5468 5468
         $htmlResult = null;
5469 5469
 
@@ -5478,7 +5478,7 @@  discard block
 block discarded – undo
5478 5478
                     $sessionInfo = self::fetch($sessionId);
5479 5479
                     $htmlResult .= '<br />';
5480 5480
                     $htmlResult .= Display::url(
5481
-                        get_lang('Session') . ': ' . $sessionInfo['name'] . ' <br />', $sessionUrl . $sessionId, array('target' => '_blank')
5481
+                        get_lang('Session').': '.$sessionInfo['name'].' <br />', $sessionUrl.$sessionId, array('target' => '_blank')
5482 5482
                     );
5483 5483
                     $teacherList = array();
5484 5484
                     foreach ($coachList as $coachId) {
@@ -5591,7 +5591,7 @@  discard block
 block discarded – undo
5591 5591
                 }
5592 5592
 
5593 5593
                 $sessionIdList = array_map('intval', $sessionIdList);
5594
-                $sessionToString = implode("', '",  $sessionIdList);
5594
+                $sessionToString = implode("', '", $sessionIdList);
5595 5595
 
5596 5596
                 $course = Database::get_main_table(TABLE_MAIN_COURSE);
5597 5597
                 $sessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -5603,7 +5603,7 @@  discard block
 block discarded – undo
5603 5603
                         INNER JOIN $courseUser cu ON (cu.c_id = c.id)
5604 5604
 		                WHERE src.session_id IN ('$sessionToString') AND cu.status = 1";
5605 5605
                 $result = Database::query($sql);
5606
-                while($row = Database::fetch_array($result, 'ASSOC')) {
5606
+                while ($row = Database::fetch_array($result, 'ASSOC')) {
5607 5607
                     $teacherListId[$row['user_id']] = $row['user_id'];
5608 5608
                 }
5609 5609
             } else {
@@ -5678,7 +5678,7 @@  discard block
 block discarded – undo
5678 5678
         $toolList = self::getCourseToolToBeManaged();
5679 5679
 
5680 5680
         foreach ($toolList as $tool) {
5681
-            $method = 'add' . $tool;
5681
+            $method = 'add'.$tool;
5682 5682
             if (method_exists(get_class(), $method)) {
5683 5683
                 self::$method($sessionId, $courseId);
5684 5684
             }
@@ -5697,7 +5697,7 @@  discard block
 block discarded – undo
5697 5697
         $toolList = self::getCourseToolToBeManaged();
5698 5698
 
5699 5699
         foreach ($toolList as $tool) {
5700
-            $method = 'remove' . $tool;
5700
+            $method = 'remove'.$tool;
5701 5701
             if (method_exists(get_class(), $method)) {
5702 5702
                 self::$method($sessionId, $courseId);
5703 5703
             }
@@ -5815,18 +5815,18 @@  discard block
 block discarded – undo
5815 5815
                         }
5816 5816
                     }
5817 5817
 
5818
-                    $message .= '<strong>' . get_lang('User') . '</strong> ' . $userInfo['complete_name'] . ' <br />';
5818
+                    $message .= '<strong>'.get_lang('User').'</strong> '.$userInfo['complete_name'].' <br />';
5819 5819
 
5820 5820
                     if (!in_array($userInfo['status'], array(DRH)) && !api_is_platform_admin_by_id($userInfo['user_id'])) {
5821
-                        $message .= get_lang('UserMustHaveTheDrhRole') . '<br />';
5821
+                        $message .= get_lang('UserMustHaveTheDrhRole').'<br />';
5822 5822
                         continue;
5823 5823
                     }
5824 5824
 
5825 5825
                     if (!empty($sessionList)) {
5826
-                        $message .= '<strong>' . get_lang('Sessions') . ':</strong> <br />';
5827
-                        $message .= implode(', ', $sessionList) . '<br /><br />';
5826
+                        $message .= '<strong>'.get_lang('Sessions').':</strong> <br />';
5827
+                        $message .= implode(', ', $sessionList).'<br /><br />';
5828 5828
                     } else {
5829
-                        $message .= get_lang('NoSessionProvided') . ' <br /><br />';
5829
+                        $message .= get_lang('NoSessionProvided').' <br /><br />';
5830 5830
                     }
5831 5831
                 }
5832 5832
             }
@@ -6006,8 +6006,8 @@  discard block
 block discarded – undo
6006 6006
 
6007 6007
         $firstAccess = api_strtotime($courseAccess['login_course_date'], 'UTC');
6008 6008
 
6009
-        $endDateInSeconds = $firstAccess + $duration*24*60*60;
6010
-        $leftDays = round(($endDateInSeconds- $currentTime) / 60 / 60 / 24);
6009
+        $endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60;
6010
+        $leftDays = round(($endDateInSeconds - $currentTime) / 60 / 60 / 24);
6011 6011
 
6012 6012
         return $leftDays;
6013 6013
     }
@@ -6299,7 +6299,7 @@  discard block
 block discarded – undo
6299 6299
                 FROM $table scu
6300 6300
                 INNER JOIN $tableUser u 
6301 6301
                 ON scu.user_id = u.id
6302
-                WHERE scu.session_id = " . intval($sessionId) ."
6302
+                WHERE scu.session_id = ".intval($sessionId)."
6303 6303
                 GROUP BY u.id";
6304 6304
 
6305 6305
         $result = Database::query($sql);
@@ -6337,7 +6337,7 @@  discard block
 block discarded – undo
6337 6337
             $sfTable = Database::get_main_table(TABLE_EXTRA_FIELD);
6338 6338
             $sfvTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6339 6339
             // Join session field and session field values tables
6340
-            $joinTable = $sfTable . ' sf INNER JOIN ' . $sfvTable . ' sfv ON sf.id = sfv.field_id';
6340
+            $joinTable = $sfTable.' sf INNER JOIN '.$sfvTable.' sfv ON sf.id = sfv.field_id';
6341 6341
             $fieldsArray = array();
6342 6342
             foreach ($extraFields as $field) {
6343 6343
                 $fieldsArray[] = Database::escape_string($field);
@@ -6380,14 +6380,14 @@  discard block
 block discarded – undo
6380 6380
                 for ($i = 1; $i < count($fieldsArray); $i++) {
6381 6381
                     $whereParams .= ', ?';
6382 6382
                 }
6383
-                $whereFieldVariables = ' variable IN ( ' . $whereParams .' )';
6384
-                $whereFieldIds = 'field_id IN ( ' . $whereParams .  ' )';
6383
+                $whereFieldVariables = ' variable IN ( '.$whereParams.' )';
6384
+                $whereFieldIds = 'field_id IN ( '.$whereParams.' )';
6385 6385
             }
6386 6386
             // Get session fields
6387 6387
             $extraField = new ExtraFieldModel('session');
6388 6388
             $questionMarks = substr(str_repeat('?, ', count($fieldsArray)), 0, -2);
6389 6389
             $fieldsList = $extraField->get_all(array(
6390
-                ' variable IN ( ' . $questionMarks . ' )' => $fieldsArray,
6390
+                ' variable IN ( '.$questionMarks.' )' => $fieldsArray,
6391 6391
             ));
6392 6392
             // Index session fields
6393 6393
             foreach ($fieldsList as $field) {
@@ -6396,7 +6396,7 @@  discard block
 block discarded – undo
6396 6396
             // Get session field values
6397 6397
             $extra = new ExtraFieldValue('session');
6398 6398
             $questionMarksFields = substr(str_repeat('?, ', count($fields)), 0, -2);
6399
-            $sessionFieldValueList = $extra->get_all(array ('where' => array('field_id IN ( ' . $questionMarksFields . ' )' => array_keys($fields))));
6399
+            $sessionFieldValueList = $extra->get_all(array('where' => array('field_id IN ( '.$questionMarksFields.' )' => array_keys($fields))));
6400 6400
             // Add session fields values to session list
6401 6401
             foreach ($sessionList as $id => &$session) {
6402 6402
                 foreach ($sessionFieldValueList as $sessionFieldValue) {
@@ -6449,7 +6449,7 @@  discard block
 block discarded – undo
6449 6449
             // Check the result
6450 6450
             if ($result < 1) {
6451 6451
                 // If not found any result, update error message
6452
-                $errorResult['errorMessage'] = 'Not found any session category name ' . $categoryName;
6452
+                $errorResult['errorMessage'] = 'Not found any session category name '.$categoryName;
6453 6453
             } elseif (count($result) > 1 && !$force) {
6454 6454
                 // If found more than one result and force is disabled, update error message
6455 6455
                 $errorResult['errorMessage'] = 'Found many session categories';
@@ -6508,7 +6508,7 @@  discard block
 block discarded – undo
6508 6508
             // Check if session list query had result
6509 6509
             if (!empty($sessionList)) {
6510 6510
                 // implode all session id
6511
-                $sessionIdsString = '(' . implode(', ', array_keys($sessionList)) . ')';
6511
+                $sessionIdsString = '('.implode(', ', array_keys($sessionList)).')';
6512 6512
                 // Get all field variables
6513 6513
                 $sessionFieldList = Database::select(
6514 6514
                     'id, variable',
@@ -6595,7 +6595,7 @@  discard block
 block discarded – undo
6595 6595
                 return $sessionList;
6596 6596
             } else {
6597 6597
                 // Not found result, update error message
6598
-                $errorResult['errorMessage'] = 'Not found any session for session category id ' . $sessionCategoryId;
6598
+                $errorResult['errorMessage'] = 'Not found any session for session category id '.$sessionCategoryId;
6599 6599
             }
6600 6600
         }
6601 6601
 
@@ -6699,7 +6699,7 @@  discard block
 block discarded – undo
6699 6699
 
6700 6700
         $sessionExtraField = new ExtraFieldModel('session');
6701 6701
         $fieldList = $sessionExtraField->get_all(array(
6702
-            "variable IN ( " . implode(", ", $variablePlaceHolders) . " ) " => $variables,
6702
+            "variable IN ( ".implode(", ", $variablePlaceHolders)." ) " => $variables,
6703 6703
         ));
6704 6704
 
6705 6705
         $fields = array();
@@ -6713,7 +6713,7 @@  discard block
 block discarded – undo
6713 6713
         $extra = new ExtraFieldValue('session');
6714 6714
         $sessionFieldValueList = $extra->get_all(
6715 6715
             array(
6716
-                "field_id IN ( " . implode(", ", $variablePlaceHolders) . " )" => array_keys($fields),
6716
+                "field_id IN ( ".implode(", ", $variablePlaceHolders)." )" => array_keys($fields),
6717 6717
             )
6718 6718
         );
6719 6719
 
@@ -6785,7 +6785,7 @@  discard block
 block discarded – undo
6785 6785
                 INNER JOIN $sessionUserTable sru 
6786 6786
                 ON s.id = sru.id_session
6787 6787
                 WHERE
6788
-                    (sru.id_user IN (" . implode(', ', $userIdList) . ")
6788
+                    (sru.id_user IN (".implode(', ', $userIdList).")
6789 6789
                     AND sru.relation_type = 0
6790 6790
                 )";
6791 6791
 
@@ -6801,7 +6801,7 @@  discard block
 block discarded – undo
6801 6801
                         WHERE
6802 6802
                             srau.access_url_id = $accessUrlId
6803 6803
                             AND (
6804
-                                sru.id_user IN (" . implode(', ', $userIdList) . ")
6804
+                                sru.id_user IN (".implode(', ', $userIdList).")
6805 6805
                                 AND sru.relation_type = 0
6806 6806
                             )";
6807 6807
             }
@@ -7014,7 +7014,7 @@  discard block
 block discarded – undo
7014 7014
                     get_lang('CoachName'),
7015 7015
                     null,
7016 7016
                     [
7017
-                        'url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach',
7017
+                        'url' => api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_general_coach',
7018 7018
                         'width' => '100%',
7019 7019
                     ]
7020 7020
                 );
@@ -7025,7 +7025,7 @@  discard block
 block discarded – undo
7025 7025
         $form->addHtml('<div id="ajax_list_coachs"></div>');
7026 7026
 
7027 7027
         $form->addButtonAdvancedSettings('advanced_params');
7028
-        $form->addElement('html','<div id="advanced_params_options" style="display:none">');
7028
+        $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
7029 7029
 
7030 7030
         $form->addSelect(
7031 7031
             'session_category',
@@ -7197,16 +7197,16 @@  discard block
 block discarded – undo
7197 7197
         if (api_is_session_admin() &&
7198 7198
             api_get_setting('allow_session_admins_to_see_all_sessions') == 'false'
7199 7199
         ) {
7200
-            $where.=" WHERE s.session_admin_id = $user_id ";
7200
+            $where .= " WHERE s.session_admin_id = $user_id ";
7201 7201
         }
7202 7202
 
7203 7203
         if (!empty($options['where'])) {
7204 7204
             $options['where'] = str_replace('course_title', 'c.title', $options['where']);
7205
-            $options['where'] = str_replace("( session_active = '0' )", '1=1',  $options['where']);
7205
+            $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
7206 7206
 
7207 7207
             $options['where'] = str_replace(
7208 7208
                 array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
7209
-                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " )
7209
+                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
7210 7210
                 , $options['where']
7211 7211
             );
7212 7212
 
@@ -7248,10 +7248,10 @@  discard block
 block discarded – undo
7248 7248
                        $where ";
7249 7249
 
7250 7250
         if (api_is_multiple_url_enabled()) {
7251
-            $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7251
+            $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7252 7252
             $access_url_id = api_get_current_access_url_id();
7253 7253
             if ($access_url_id != -1) {
7254
-                $where.= " AND ar.access_url_id = $access_url_id ";
7254
+                $where .= " AND ar.access_url_id = $access_url_id ";
7255 7255
 
7256 7256
                 $query_rows = "SELECT count(*) as total_rows
7257 7257
                                FROM $tbl_session s
@@ -7296,12 +7296,12 @@  discard block
 block discarded – undo
7296 7296
                     //get_lang('CourseTitle'),
7297 7297
                     get_lang('Visibility'),
7298 7298
                 );
7299
-                $column_model = array (
7300
-                    array('name'=>'name', 'index'=>'s.name', 'width'=>'160',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7301
-                    array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7302
-                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50',   'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7303
-                    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)),
7304
-                    array('name'=>'visibility', 'index'=>'visibility',      'width'=>'40',   'align'=>'left', 'search' => 'false'),
7299
+                $column_model = array(
7300
+                    array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7301
+                    array('name'=>'category_name', 'index'=>'category_name', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7302
+                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7303
+                    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)),
7304
+                    array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
7305 7305
                 );
7306 7306
                 break;
7307 7307
             case 'complete':
@@ -7314,12 +7314,12 @@  discard block
 block discarded – undo
7314 7314
                     get_lang('Visibility'),
7315 7315
                     get_lang('CourseTitle'),
7316 7316
                 );
7317
-                $column_model = array (
7318
-                    array('name'=>'name', 'index'=>'s.name', 'width'=>'200',  'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7319
-                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70',   'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7320
-                    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)),
7321
-                    array('name'=>'coach_name', 'index'=>'coach_name',     'width'=>'70',   'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
7322
-                    array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25',   'align'=>'left', 'search' => 'true', 'stype'=>'select',
7317
+                $column_model = array(
7318
+                    array('name'=>'name', 'index'=>'s.name', 'width'=>'200', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)),
7319
+                    array('name'=>'display_start_date', 'index'=>'display_start_date', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)),
7320
+                    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)),
7321
+                    array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
7322
+                    array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
7323 7323
                         // for the bottom bar
7324 7324
                         'searchoptions' => array(
7325 7325
                             'defaultValue'  => '1',
@@ -7327,8 +7327,8 @@  discard block
 block discarded – undo
7327 7327
                         // for the top bar
7328 7328
                         'editoptions' => array('value' => '" ":'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')),
7329 7329
                     ),
7330
-                    array('name'=>'visibility',     'index'=>'visibility',      'width'=>'40',   'align'=>'left', 'search' => 'false'),
7331
-                    array('name'=>'course_title',    'index'=>'course_title',   'width'=>'50',   'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
7330
+                    array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
7331
+                    array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true', 'sopt' => $operators)),
7332 7332
                 );
7333 7333
                 break;
7334 7334
         }
@@ -7337,14 +7337,14 @@  discard block
 block discarded – undo
7337 7337
         $session_field = new ExtraFieldModel('session');
7338 7338
         $rules = $session_field->getRules($columns, $column_model);
7339 7339
 
7340
-        $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80',  'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false');
7340
+        $column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80', 'align'=>'left', 'formatter'=>'action_formatter', 'sortable'=>'false', 'search' => 'false');
7341 7341
         $columns[] = get_lang('Actions');
7342 7342
 
7343 7343
         foreach ($column_model as $col_model) {
7344 7344
             $simple_column_name[] = $col_model['name'];
7345 7345
         }
7346 7346
 
7347
-        $return_array =  array(
7347
+        $return_array = array(
7348 7348
             'columns' => $columns,
7349 7349
             'column_model' => $column_model,
7350 7350
             'rules' => $rules,
@@ -7433,7 +7433,7 @@  discard block
 block discarded – undo
7433 7433
             if (api_is_session_admin() &&
7434 7434
                 api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
7435 7435
             ) {
7436
-                $where.=" AND s.session_admin_id = $user_id ";
7436
+                $where .= " AND s.session_admin_id = $user_id ";
7437 7437
             }
7438 7438
         }
7439 7439
 
@@ -7515,11 +7515,11 @@  discard block
 block discarded – undo
7515 7515
             }
7516 7516
             $options['where'] = str_replace('course_title', 'c.title', $options['where']);
7517 7517
 
7518
-            $options['where'] = str_replace("( session_active = '0' )", '1=1',  $options['where']);
7518
+            $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
7519 7519
 
7520 7520
             $options['where'] = str_replace(
7521 7521
                 array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
7522
-                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 " )
7522
+                array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
7523 7523
                 , $options['where']
7524 7524
             );
7525 7525
 
@@ -7554,10 +7554,10 @@  discard block
 block discarded – undo
7554 7554
             $where;
7555 7555
 
7556 7556
         if (api_is_multiple_url_enabled()) {
7557
-            $table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7557
+            $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
7558 7558
             $access_url_id = api_get_current_access_url_id();
7559 7559
             if ($access_url_id != -1) {
7560
-                $where.= " AND ar.access_url_id = $access_url_id ";
7560
+                $where .= " AND ar.access_url_id = $access_url_id ";
7561 7561
                 $query = "$select
7562 7562
                     FROM $tbl_session s
7563 7563
                     LEFT JOIN $tbl_session_field_values fv ON (fv.session_id = s.id)
@@ -7581,7 +7581,7 @@  discard block
 block discarded – undo
7581 7581
         $formatted_sessions = array();
7582 7582
 
7583 7583
         if (Database::num_rows($result)) {
7584
-            $sessions   = Database::store_result($result, 'ASSOC');
7584
+            $sessions = Database::store_result($result, 'ASSOC');
7585 7585
             foreach ($sessions as $session) {
7586 7586
                 $session_id = $session['id'];
7587 7587
                 $session['name'] = Display::url($session['name'], "resume_session.php?id_session=".$session['id']);
@@ -7596,14 +7596,14 @@  discard block
 block discarded – undo
7596 7596
 
7597 7597
                 switch ($session['visibility']) {
7598 7598
                     case SESSION_VISIBLE_READ_ONLY: //1
7599
-                        $session['visibility'] =  get_lang('ReadOnly');
7599
+                        $session['visibility'] = get_lang('ReadOnly');
7600 7600
                         break;
7601 7601
                     case SESSION_VISIBLE:           //2
7602 7602
                     case SESSION_AVAILABLE:         //4
7603
-                        $session['visibility'] =  get_lang('Visible');
7603
+                        $session['visibility'] = get_lang('Visible');
7604 7604
                         break;
7605 7605
                     case SESSION_INVISIBLE:         //3
7606
-                        $session['visibility'] =  api_ucfirst(get_lang('Invisible'));
7606
+                        $session['visibility'] = api_ucfirst(get_lang('Invisible'));
7607 7607
                         break;
7608 7608
                 }
7609 7609
 
@@ -7679,7 +7679,7 @@  discard block
 block discarded – undo
7679 7679
         if (empty($session)) {
7680 7680
             return false;
7681 7681
         }
7682
-        return api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $id;
7682
+        return api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$id;
7683 7683
     }
7684 7684
 
7685 7685
     /**
@@ -7697,7 +7697,7 @@  discard block
 block discarded – undo
7697 7697
             return false;
7698 7698
         }
7699 7699
         if (empty($courseId)) {
7700
-            return api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $id;
7700
+            return api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$id;
7701 7701
         } else {
7702 7702
             $courseInfo = api_get_course_info_by_id($courseId);
7703 7703
             if ($courseInfo) {
@@ -7908,7 +7908,7 @@  discard block
 block discarded – undo
7908 7908
             // sort $listCat by catSessionName
7909 7909
             usort($listCat, 'self::compareBySessionName');
7910 7910
             // in each catSession sort sessionList by sessionName
7911
-            foreach($listCat as $i => $listCatSessionInfo) {
7911
+            foreach ($listCat as $i => $listCatSessionInfo) {
7912 7912
                 $listSessionList = $listCatSessionInfo['sessionList'];
7913 7913
                 usort($listSessionList, 'self::compareCatSessionInfo');
7914 7914
                 $listCat[$i]['sessionList'] = $listSessionList;
@@ -7923,8 +7923,8 @@  discard block
 block discarded – undo
7923 7923
             );
7924 7924
 
7925 7925
             $userCatId = intval($userCatId);
7926
-            $listResults[$userCatId]['courseInUserCategoryId'] =  $userCatId;
7927
-            $listResults[$userCatId]['courseInUserCategoryTitle'] =  $userCatTitle;
7926
+            $listResults[$userCatId]['courseInUserCategoryId'] = $userCatId;
7927
+            $listResults[$userCatId]['courseInUserCategoryTitle'] = $userCatTitle;
7928 7928
             $listResults[$userCatId]['courseInUserCatList'][] = $listOneCourse;
7929 7929
         }
7930 7930
 
@@ -7950,7 +7950,7 @@  discard block
 block discarded – undo
7950 7950
     {
7951 7951
         if ($listA['sessionName'] == $listB['sessionName']) {
7952 7952
             return 0;
7953
-        } else if($listA['sessionName'] > $listB['sessionName']) {
7953
+        } else if ($listA['sessionName'] > $listB['sessionName']) {
7954 7954
             return 1;
7955 7955
         } else {
7956 7956
             return -1;
@@ -7970,7 +7970,7 @@  discard block
 block discarded – undo
7970 7970
             return 1;
7971 7971
         } else if ($listA['catSessionName'] == $listB['catSessionName']) {
7972 7972
             return 0;
7973
-        } else if($listA['catSessionName'] > $listB['catSessionName']) {
7973
+        } else if ($listA['catSessionName'] > $listB['catSessionName']) {
7974 7974
             return 1;
7975 7975
         } else {
7976 7976
             return -1;
@@ -7986,7 +7986,7 @@  discard block
 block discarded – undo
7986 7986
     {
7987 7987
         if ($listA['courseInUserCategoryTitle'] == $listB['courseInUserCategoryTitle']) {
7988 7988
             return 0;
7989
-        } else if($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) {
7989
+        } else if ($listA['courseInUserCategoryTitle'] > $listB['courseInUserCategoryTitle']) {
7990 7990
             return 1;
7991 7991
         } else {
7992 7992
             return -1;
@@ -8002,7 +8002,7 @@  discard block
 block discarded – undo
8002 8002
     {
8003 8003
         if ($listA['title'] == $listB['title']) {
8004 8004
             return 0;
8005
-        } else if($listA['title'] > $listB['title']) {
8005
+        } else if ($listA['title'] > $listB['title']) {
8006 8006
             return 1;
8007 8007
         } else {
8008 8008
             return -1;
@@ -8048,8 +8048,8 @@  discard block
 block discarded – undo
8048 8048
 
8049 8049
                 $marginShift = 20;
8050 8050
                 if ($catSessionName != '') {
8051
-                    $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">' .
8052
-                        CourseManager::course_item_html($listParamsCatSession, true) . '</div>';
8051
+                    $htmlCatSessions .= '<div style="margin-left:'.$marginShift.'px;">'.
8052
+                        CourseManager::course_item_html($listParamsCatSession, true).'</div>';
8053 8053
                     $marginShift = 40;
8054 8054
                 }
8055 8055
 
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   +39 added lines, -39 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,7 +505,7 @@  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();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
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);
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
775 775
         $result = true;
776 776
         if (!empty($user_id) && !empty($url_id)) {
777
-            $sql= "DELETE FROM $table_url_rel_user
777
+            $sql = "DELETE FROM $table_url_rel_user
778 778
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
779 779
             $result = Database::query($sql);
780 780
         }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
795 795
         $result = true;
796 796
         if (!empty($userId)) {
797
-            $sql= "DELETE FROM $table_url_rel_user
797
+            $sql = "DELETE FROM $table_url_rel_user
798 798
                    WHERE user_id = ".intval($userId);
799 799
             Database::query($sql);
800 800
         }
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
     * */
813 813
     public static function delete_url_rel_course($courseId, $urlId)
814 814
     {
815
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
816
-        $sql= "DELETE FROM $table_url_rel_course
815
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
816
+        $sql = "DELETE FROM $table_url_rel_course
817 817
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
818 818
         $result = Database::query($sql);
819 819
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
832 832
     {
833 833
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
834
-        $sql= "DELETE FROM $table
834
+        $sql = "DELETE FROM $table
835 835
                WHERE usergroup_id = '".intval($userGroupId)."' AND
836 836
                      access_url_id = ".intval($urlId);
837 837
         $result = Database::query($sql);
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
851 851
     {
852 852
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
853
-        $sql= "DELETE FROM $table
853
+        $sql = "DELETE FROM $table
854 854
                WHERE course_category_id = '".intval($userGroupId)."' AND
855 855
                      access_url_id=".intval($urlId)."  ";
856 856
         $result = Database::query($sql);
@@ -869,9 +869,9 @@  discard block
 block discarded – undo
869 869
     public static function delete_url_rel_session($session_id, $url_id)
870 870
     {
871 871
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
872
-        $sql= "DELETE FROM $table_url_rel_session
872
+        $sql = "DELETE FROM $table_url_rel_session
873 873
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
874
-        $result = Database::query($sql,'ASSOC');
874
+        $result = Database::query($sql, 'ASSOC');
875 875
 
876 876
         return $result;
877 877
     }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
      * */
885 885
     public static function update_urls_rel_user($user_list, $access_url_id)
886 886
     {
887
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
887
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
888 888
         $sql = "SELECT user_id 
889 889
                 FROM $table_url_rel_user 
890 890
                 WHERE access_url_id = ".intval($access_url_id);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
         $result = Database::query($sql);
941 941
 
942 942
         $existing_courses = array();
943
-        while ($row = Database::fetch_array($result)){
943
+        while ($row = Database::fetch_array($result)) {
944 944
             $existing_courses[] = $row['c_id'];
945 945
         }
946 946
 
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
         $result = Database::query($sql);
974 974
         $existingItems = array();
975 975
 
976
-        while ($row = Database::fetch_array($result)){
976
+        while ($row = Database::fetch_array($result)) {
977 977
             $existingItems[] = $row['usergroup_id'];
978 978
         }
979 979
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         $result = Database::query($sql);
1007 1007
         $existingItems = array();
1008 1008
 
1009
-        while ($row = Database::fetch_array($result)){
1009
+        while ($row = Database::fetch_array($result)) {
1010 1010
             $existingItems[] = $row['course_category_id'];
1011 1011
         }
1012 1012
 
@@ -1046,13 +1046,13 @@  discard block
 block discarded – undo
1046 1046
      * */
1047 1047
     public static function update_urls_rel_session($session_list, $access_url_id)
1048 1048
     {
1049
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1049
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1050 1050
 
1051 1051
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1052 1052
         $result = Database::query($sql);
1053 1053
         $existing_sessions = array();
1054 1054
 
1055
-        while ($row = Database::fetch_array($result)){
1055
+        while ($row = Database::fetch_array($result)) {
1056 1056
             $existing_sessions[] = $row['session_id'];
1057 1057
         }
1058 1058
 
@@ -1082,13 +1082,13 @@  discard block
 block discarded – undo
1082 1082
      */
1083 1083
     public static function get_access_url_from_user($user_id)
1084 1084
     {
1085
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1086
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1085
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1086
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1087 1087
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1088 1088
                 ON (url_rel_user.access_url_id = u.id)
1089 1089
                 WHERE user_id = ".intval($user_id);
1090 1090
         $result = Database::query($sql);
1091
-        $url_list = Database::store_result($result,'ASSOC');
1091
+        $url_list = Database::store_result($result, 'ASSOC');
1092 1092
 
1093 1093
         return $url_list;
1094 1094
     }
@@ -1099,14 +1099,14 @@  discard block
 block discarded – undo
1099 1099
      */
1100 1100
     public static function get_access_url_from_course($courseId)
1101 1101
     {
1102
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1103
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1102
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1103
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1104 1104
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1105 1105
                 ON (c.access_url_id = u.id)
1106 1106
                 WHERE c_id = ".intval($courseId);
1107 1107
 
1108 1108
         $result = Database::query($sql);
1109
-        $url_list = Database::store_result($result,'ASSOC');
1109
+        $url_list = Database::store_result($result, 'ASSOC');
1110 1110
         return $url_list;
1111 1111
     }
1112 1112
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
     public static function get_access_url_from_session($session_id)
1118 1118
     {
1119 1119
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1120
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1120
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1121 1121
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1122 1122
                 ON (url_rel_session.access_url_id = u.id)
1123 1123
                 WHERE session_id = ".intval($session_id);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public static function get_url_id($url)
1135 1135
     {
1136
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1136
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1137 1137
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1138 1138
         $result = Database::query($sql);
1139 1139
         $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   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1371 1371
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1372 1372
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1373
-               break;
1373
+                break;
1374 1374
             case 'custom':
1375 1375
                 if (!empty($start_date) && !empty($end_date)) {
1376 1376
                     $start_date = Database::escape_string($start_date);
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                 break;
1381 1381
         }
1382 1382
 
1383
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1383
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1384 1384
     	        FROM '.$tbl_track_login.'
1385 1385
                 WHERE '.$userCondition.$condition_time;
1386
-    	$rs = Database::query($sql);
1386
+        $rs = Database::query($sql);
1387 1387
         $row = Database::fetch_array($rs, 'ASSOC');
1388 1388
         $diff = $row['diff'];
1389 1389
 
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1406 1406
     {
1407 1407
         $courseId = intval($courseId);
1408
-    	$session_id  = intval($session_id);
1409
-
1410
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
-    	if (is_array($user_id)) {
1412
-    	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
-    	} else {
1415
-    		$user_id = intval($user_id);
1416
-    		$condition_user = " AND user_id = $user_id ";
1417
-    	}
1418
-
1419
-    	$sql = "SELECT
1408
+        $session_id  = intval($session_id);
1409
+
1410
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
+        if (is_array($user_id)) {
1412
+            $user_id = array_map('intval', $user_id);
1413
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
+        } else {
1415
+            $user_id = intval($user_id);
1416
+            $condition_user = " AND user_id = $user_id ";
1417
+        }
1418
+
1419
+        $sql = "SELECT
1420 1420
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1421 1421
                 FROM $tbl_track_course
1422 1422
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1431,9 +1431,9 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
         $sql .= $condition_user;
1433 1433
         $rs = Database::query($sql);
1434
-    	$row = Database::fetch_array($rs);
1434
+        $row = Database::fetch_array($rs);
1435 1435
 
1436
-    	return $row['nb_seconds'];
1436
+        return $row['nb_seconds'];
1437 1437
     }
1438 1438
 
1439 1439
     /**
@@ -1444,25 +1444,25 @@  discard block
 block discarded – undo
1444 1444
      */
1445 1445
     public static function get_first_connection_date($student_id)
1446 1446
     {
1447
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
-    	$sql = 'SELECT login_date
1447
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
+        $sql = 'SELECT login_date
1449 1449
     	        FROM ' . $tbl_track_login . '
1450 1450
                 WHERE login_user_id = ' . intval($student_id) . '
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454
-    	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1456
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1454
+        $rs = Database::query($sql);
1455
+        if (Database::num_rows($rs)>0) {
1456
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
1459 1459
                     DATE_FORMAT_SHORT,
1460 1460
                     date_default_timezone_get()
1461 1461
                 );
1462
-    		}
1463
-    	}
1462
+            }
1463
+        }
1464 1464
 
1465
-    	return false;
1465
+        return false;
1466 1466
     }
1467 1467
 
1468 1468
     /**
@@ -1475,38 +1475,38 @@  discard block
 block discarded – undo
1475 1475
      */
1476 1476
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1477 1477
     {
1478
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
-    	$sql = 'SELECT login_date
1478
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
+        $sql = 'SELECT login_date
1480 1480
     	        FROM ' . $table . '
1481 1481
                 WHERE login_user_id = ' . intval($student_id) . '
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
1485
-    	$rs = Database::query($sql);
1486
-    	if (Database::num_rows($rs) > 0) {
1487
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1488
-    			$last_login_date = api_get_local_time($last_login_date);
1489
-    			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1491
-    			} else {
1492
-    				if (!$warning_message) {
1493
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
-    				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1496
-    					$currentTimestamp = time();
1497
-
1498
-    					//If the last connection is > than 7 days, the text is red
1499
-    					//345600 = 7 days in seconds
1500
-    					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
-    					} else {
1503
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
-    					}
1505
-    				}
1506
-    			}
1507
-    		}
1508
-    	}
1509
-    	return false;
1485
+        $rs = Database::query($sql);
1486
+        if (Database::num_rows($rs) > 0) {
1487
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1488
+                $last_login_date = api_get_local_time($last_login_date);
1489
+                if ($return_timestamp) {
1490
+                    return api_strtotime($last_login_date,'UTC');
1491
+                } else {
1492
+                    if (!$warning_message) {
1493
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
+                    } else {
1495
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1496
+                        $currentTimestamp = time();
1497
+
1498
+                        //If the last connection is > than 7 days, the text is red
1499
+                        //345600 = 7 days in seconds
1500
+                        if ($currentTimestamp - $timestamp > 604800) {
1501
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
+                        } else {
1503
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
+                        }
1505
+                    }
1506
+                }
1507
+            }
1508
+        }
1509
+        return false;
1510 1510
     }
1511 1511
 
1512 1512
     /**
@@ -1560,30 +1560,30 @@  discard block
 block discarded – undo
1560 1560
         $session_id = 0,
1561 1561
         $convert_date = true
1562 1562
     ) {
1563
-    	$student_id  = intval($student_id);
1563
+        $student_id  = intval($student_id);
1564 1564
         $courseId = intval($courseId);
1565
-    	$session_id  = intval($session_id);
1565
+        $session_id  = intval($session_id);
1566 1566
 
1567
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
-    	$sql = 'SELECT login_course_date
1567
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
+        $sql = 'SELECT login_course_date
1569 1569
     	        FROM '.$tbl_track_login.'
1570 1570
                 WHERE
1571 1571
                     user_id = '.$student_id.' AND
1572 1572
                     c_id = '.$courseId.' AND
1573 1573
                     session_id = '.$session_id.'
1574 1574
                 ORDER BY login_course_date ASC LIMIT 0,1';
1575
-    	$rs = Database::query($sql);
1576
-    	if (Database::num_rows($rs) > 0) {
1577
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1578
-    			if ($convert_date) {
1579
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
-    			} else {
1581
-    				return $first_login_date;
1582
-    			}
1583
-    		}
1584
-    	}
1585
-
1586
-    	return false;
1575
+        $rs = Database::query($sql);
1576
+        if (Database::num_rows($rs) > 0) {
1577
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1578
+                if ($convert_date) {
1579
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
+                } else {
1581
+                    return $first_login_date;
1582
+                }
1583
+            }
1584
+        }
1585
+
1586
+        return false;
1587 1587
     }
1588 1588
 
1589 1589
     /**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
         $session_id = 0,
1600 1600
         $convert_date = true
1601 1601
     ) {
1602
-    	// protect data
1603
-    	$student_id  = intval($student_id);
1602
+        // protect data
1603
+        $student_id  = intval($student_id);
1604 1604
         $courseId = $courseInfo['real_id'];
1605
-    	$session_id  = intval($session_id);
1605
+        $session_id  = intval($session_id);
1606 1606
 
1607
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
-    	$sql = 'SELECT access_date
1607
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
+        $sql = 'SELECT access_date
1609 1609
                 FROM '.$tbl_track_e_access.'
1610 1610
                 WHERE   access_user_id = '.$student_id.' AND
1611 1611
                         c_id = "'.$courseId.'" AND
@@ -1613,39 +1613,39 @@  discard block
 block discarded – undo
1613 1613
                 ORDER BY access_date DESC
1614 1614
                 LIMIT 0,1';
1615 1615
 
1616
-    	$rs = Database::query($sql);
1617
-    	if (Database::num_rows($rs) > 0) {
1618
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1616
+        $rs = Database::query($sql);
1617
+        if (Database::num_rows($rs) > 0) {
1618
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1619 1619
                 if (empty($last_login_date)) {
1620 1620
                     return false;
1621 1621
                 }
1622 1622
                 //see #5736
1623 1623
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1624
-    			$now = time();
1625
-    			//If the last connection is > than 7 days, the text is red
1626
-    			//345600 = 7 days in seconds
1627
-    			if ($now - $last_login_date_timestamp > 604800) {
1628
-    				if ($convert_date) {
1624
+                $now = time();
1625
+                //If the last connection is > than 7 days, the text is red
1626
+                //345600 = 7 days in seconds
1627
+                if ($now - $last_login_date_timestamp > 604800) {
1628
+                    if ($convert_date) {
1629 1629
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1630 1630
                         $icon = api_is_allowed_to_edit() ?
1631 1631
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1636
-    				} else {
1637
-    					return $last_login_date;
1638
-    				}
1639
-    			} else {
1640
-    				if ($convert_date) {
1641
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
-    				} else {
1643
-    					return $last_login_date;
1644
-    				}
1645
-    			}
1646
-    		}
1647
-    	}
1648
-    	return false;
1635
+                        return $icon. Display::label($last_login_date, 'warning');
1636
+                    } else {
1637
+                        return $last_login_date;
1638
+                    }
1639
+                } else {
1640
+                    if ($convert_date) {
1641
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
+                    } else {
1643
+                        return $last_login_date;
1644
+                    }
1645
+                }
1646
+            }
1647
+        }
1648
+        return false;
1649 1649
     }
1650 1650
 
1651 1651
     /**
@@ -1659,11 +1659,11 @@  discard block
 block discarded – undo
1659 1659
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1660 1660
     {
1661 1661
         if ($start < 0) {
1662
-    		$start = 0;
1663
-    	}
1664
-    	if (!isset($stop) or ($stop < 0)) {
1665
-    		$stop = api_get_utc_datetime();
1666
-    	}
1662
+            $start = 0;
1663
+        }
1664
+        if (!isset($stop) or ($stop < 0)) {
1665
+            $stop = api_get_utc_datetime();
1666
+        }
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
1675
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1675
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1676 1676
 
1677 1677
         $courseId = intval($courseId);
1678
-    	$session_id  = intval($session_id);
1679
-    	$count = 0;
1678
+        $session_id  = intval($session_id);
1679
+        $count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681 1681
         $sql =  "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             }
1716 1716
         }
1717 1717
 
1718
-    	return $count;
1718
+        return $count;
1719 1719
     }
1720 1720
 
1721 1721
     /**
@@ -1726,25 +1726,25 @@  discard block
 block discarded – undo
1726 1726
      */
1727 1727
     public static function count_course_per_student($user_id, $include_sessions = true)
1728 1728
     {
1729
-    	$user_id = intval($user_id);
1730
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1729
+        $user_id = intval($user_id);
1730
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733
-    	$sql = 'SELECT DISTINCT c_id
1733
+        $sql = 'SELECT DISTINCT c_id
1734 1734
                 FROM ' . $tbl_course_rel_user . '
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736
-    	$rs = Database::query($sql);
1737
-    	$nb_courses = Database::num_rows($rs);
1736
+        $rs = Database::query($sql);
1737
+        $nb_courses = Database::num_rows($rs);
1738 1738
 
1739
-    	if ($include_sessions) {
1740
-    		$sql = 'SELECT DISTINCT c_id
1739
+        if ($include_sessions) {
1740
+            $sql = 'SELECT DISTINCT c_id
1741 1741
                     FROM ' . $tbl_session_course_rel_user . '
1742 1742
                     WHERE user_id = ' . $user_id;
1743
-    		$rs = Database::query($sql);
1744
-    		$nb_courses += Database::num_rows($rs);
1745
-    	}
1743
+            $rs = Database::query($sql);
1744
+            $nb_courses += Database::num_rows($rs);
1745
+        }
1746 1746
 
1747
-    	return $nb_courses;
1747
+        return $nb_courses;
1748 1748
     }
1749 1749
 
1750 1750
     /**
@@ -1775,25 +1775,25 @@  discard block
 block discarded – undo
1775 1775
         $into_lp = 0
1776 1776
     ) {
1777 1777
         $course_code = Database::escape_string($course_code);
1778
-    	$course_info = api_get_course_info($course_code);
1779
-    	if (!empty($course_info)) {
1780
-    		// table definition
1781
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
-
1784
-    		// Compose a filter based on optional exercise given
1785
-    		$condition_quiz = "";
1786
-    		if (!empty($exercise_id)) {
1787
-    			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1789
-    		}
1790
-
1791
-    		// Compose a filter based on optional session id given
1792
-    		$condition_session = "";
1793
-    		if (isset($session_id)) {
1794
-    			$session_id = intval($session_id);
1795
-    			$condition_session = " AND session_id = $session_id ";
1796
-    		}
1778
+        $course_info = api_get_course_info($course_code);
1779
+        if (!empty($course_info)) {
1780
+            // table definition
1781
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
+
1784
+            // Compose a filter based on optional exercise given
1785
+            $condition_quiz = "";
1786
+            if (!empty($exercise_id)) {
1787
+                $exercise_id = intval($exercise_id);
1788
+                $condition_quiz =" AND id = $exercise_id ";
1789
+            }
1790
+
1791
+            // Compose a filter based on optional session id given
1792
+            $condition_session = "";
1793
+            if (isset($session_id)) {
1794
+                $session_id = intval($session_id);
1795
+                $condition_session = " AND session_id = $session_id ";
1796
+            }
1797 1797
             if ($active_filter == 1) {
1798 1798
                 $condition_active = 'AND active <> -1';
1799 1799
             } elseif ($active_filter == 0) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
                 $select_lp_id = ', orig_lp_id as lp_id ';
1810 1810
             }
1811 1811
 
1812
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1812
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1813 1813
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1814 1814
             $count_quiz = 0;
1815 1815
             $countQuizResult = Database::query($sql);
@@ -1817,21 +1817,21 @@  discard block
 block discarded – undo
1817 1817
                 $count_quiz = Database::fetch_row($countQuizResult);
1818 1818
             }
1819 1819
 
1820
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
-    			if (is_array($student_id)) {
1820
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
+                if (is_array($student_id)) {
1822 1822
                     $student_id = array_map('intval', $student_id);
1823
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
-    			} else {
1823
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
+                } else {
1825 1825
                     $student_id = intval($student_id);
1826
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1827
-    			}
1826
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1827
+                }
1828 1828
 
1829
-    			if (empty($exercise_id)) {
1830
-    				$sql = "SELECT id FROM $tbl_course_quiz
1829
+                if (empty($exercise_id)) {
1830
+                    $sql = "SELECT id FROM $tbl_course_quiz
1831 1831
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1832 1832
                     $result = Database::query($sql);
1833 1833
                     $exercise_list = array();
1834
-    				$exercise_id = null;
1834
+                    $exercise_id = null;
1835 1835
                     if (!empty($result) && Database::num_rows($result)) {
1836 1836
                         while ($row = Database::fetch_array($result)) {
1837 1837
                             $exercise_list[] = $row['id'];
@@ -1840,11 +1840,11 @@  discard block
 block discarded – undo
1840 1840
                     if (!empty($exercise_list)) {
1841 1841
                         $exercise_id = implode("','",$exercise_list);
1842 1842
                     }
1843
-    			}
1843
+                }
1844 1844
 
1845
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1845
+                $count_quiz = Database::fetch_row(Database::query($sql));
1846 1846
 
1847
-    			$sql = "SELECT
1847
+                $sql = "SELECT
1848 1848
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1849 1849
     			        COUNT(*) as num_attempts
1850 1850
     			        $select_lp_id
@@ -1858,20 +1858,20 @@  discard block
 block discarded – undo
1858 1858
                             $condition_into_lp
1859 1859
                         ORDER BY exe_date DESC";
1860 1860
 
1861
-    			$res = Database::query($sql);
1862
-    			$row = Database::fetch_array($res);
1863
-    			$quiz_avg_score = null;
1861
+                $res = Database::query($sql);
1862
+                $row = Database::fetch_array($res);
1863
+                $quiz_avg_score = null;
1864 1864
 
1865
-    			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1867
-    			}
1865
+                if (!empty($row['avg_score'])) {
1866
+                    $quiz_avg_score = round($row['avg_score'],2);
1867
+                }
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1870
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
-    			}
1872
-    			if (is_array($student_id)) {
1873
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
-    			}
1869
+                if(!empty($row['num_attempts'])) {
1870
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
+                }
1872
+                if (is_array($student_id)) {
1873
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
+                }
1875 1875
                 if ($into_lp == 0) {
1876 1876
                     return $quiz_avg_score;
1877 1877
                 } else {
@@ -1894,9 +1894,9 @@  discard block
 block discarded – undo
1894 1894
                         return array($quiz_avg_score, null);
1895 1895
                     }
1896 1896
                 }
1897
-    		}
1898
-    	}
1899
-    	return null;
1897
+            }
1898
+        }
1899
+        return null;
1900 1900
     }
1901 1901
 
1902 1902
     /**
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
         $find_all_lp = 0
1930 1930
     ) {
1931 1931
         $courseId = intval($courseId);
1932
-    	$student_id  = intval($student_id);
1933
-    	$exercise_id = intval($exercise_id);
1934
-    	$session_id  = intval($session_id);
1932
+        $student_id  = intval($student_id);
1933
+        $exercise_id = intval($exercise_id);
1934
+        $session_id  = intval($session_id);
1935 1935
 
1936
-    	$lp_id = intval($lp_id);
1936
+        $lp_id = intval($lp_id);
1937 1937
         $lp_item_id = intval($lp_item_id);
1938
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1938
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1939 1939
 
1940
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1940
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1941 1941
                 WHERE  ex.c_id = $courseId
1942 1942
                 AND ex.exe_exo_id = $exercise_id
1943 1943
                 AND status = ''
@@ -1952,11 +1952,11 @@  discard block
 block discarded – undo
1952 1952
                 AND orig_lp_item_id = $lp_item_id";
1953 1953
         }
1954 1954
 
1955
-    	$rs = Database::query($sql);
1956
-    	$row = Database::fetch_row($rs);
1957
-    	$count_attempts = $row[0];
1955
+        $rs = Database::query($sql);
1956
+        $row = Database::fetch_row($rs);
1957
+        $count_attempts = $row[0];
1958 1958
 
1959
-    	return $count_attempts;
1959
+        return $count_attempts;
1960 1960
     }
1961 1961
 
1962 1962
     /**
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
      * @param int    $user_id
1967 1967
      * @param int    $courseId
1968 1968
      * @param int    $session_id
1969
-    */
1969
+     */
1970 1970
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1971 1971
     {
1972 1972
         $courseId = intval($courseId);
@@ -3634,8 +3634,8 @@  discard block
 block discarded – undo
3634 3634
 
3635 3635
         $condition_session = '';
3636 3636
         if (isset($session_id)) {
3637
-             $session_id = intval($session_id);
3638
-             $condition_session = ' AND f.session_id = '. $session_id;
3637
+                $session_id = intval($session_id);
3638
+                $condition_session = ' AND f.session_id = '. $session_id;
3639 3639
         }
3640 3640
 
3641 3641
         $groupId = intval($groupId);
@@ -5564,9 +5564,9 @@  discard block
 block discarded – undo
5564 5564
     }
5565 5565
 
5566 5566
     /**
5567
-    * @param FormValidator $form
5568
-    * @return mixed
5569
-    */
5567
+     * @param FormValidator $form
5568
+     * @return mixed
5569
+     */
5570 5570
     public static function setUserSearchForm($form)
5571 5571
     {
5572 5572
         global $_configuration;
@@ -5961,26 +5961,26 @@  discard block
 block discarded – undo
5961 5961
         $session_id = api_get_session_id();
5962 5962
         $course_id = api_get_course_int_id();
5963 5963
 
5964
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5964
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5966 5966
 
5967
-    	$sql = "SELECT count(tool) AS total_number_of_items
5967
+        $sql = "SELECT count(tool) AS total_number_of_items
5968 5968
     	        FROM $table_item_property track_resource, $table_user user
5969 5969
     	        WHERE
5970 5970
                     track_resource.c_id = $course_id AND
5971 5971
                     track_resource.insert_user_id = user.user_id AND
5972 5972
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5973 5973
 
5974
-    	if (isset($_GET['keyword'])) {
5975
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5976
-    		$sql .= " AND (
5974
+        if (isset($_GET['keyword'])) {
5975
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5976
+            $sql .= " AND (
5977 5977
     		            user.username LIKE '%".$keyword."%' OR
5978 5978
     		            lastedit_type LIKE '%".$keyword."%' OR
5979 5979
     		            tool LIKE '%".$keyword."%'
5980 5980
                     )";
5981
-    	}
5981
+        }
5982 5982
 
5983
-    	$sql .= " AND tool IN (
5983
+        $sql .= " AND tool IN (
5984 5984
     	            'document',
5985 5985
     	            'learnpath',
5986 5986
     	            'quiz',
@@ -5992,10 +5992,10 @@  discard block
 block discarded – undo
5992 5992
     	            'thematic_advance',
5993 5993
     	            'thematic_plan'
5994 5994
                 )";
5995
-    	$res = Database::query($sql);
5996
-    	$obj = Database::fetch_object($res);
5995
+        $res = Database::query($sql);
5996
+        $obj = Database::fetch_object($res);
5997 5997
 
5998
-    	return $obj->total_number_of_items;
5998
+        return $obj->total_number_of_items;
5999 5999
     }
6000 6000
 
6001 6001
     /**
@@ -6010,12 +6010,12 @@  discard block
 block discarded – undo
6010 6010
         $session_id = api_get_session_id();
6011 6011
         $course_id = api_get_course_int_id();
6012 6012
 
6013
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
-    	$session_id = intval($session_id);
6013
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
+        $session_id = intval($session_id);
6017 6017
 
6018
-    	$sql = "SELECT
6018
+        $sql = "SELECT
6019 6019
                     tool as col0,
6020 6020
                     lastedit_type as col1,
6021 6021
                     ref as ref,
@@ -6029,16 +6029,16 @@  discard block
 block discarded – undo
6029 6029
                   track_resource.insert_user_id = user.user_id AND
6030 6030
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6031 6031
 
6032
-    	if (isset($_GET['keyword'])) {
6033
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
6034
-    		$sql .= " AND (
6032
+        if (isset($_GET['keyword'])) {
6033
+            $keyword = Database::escape_string(trim($_GET['keyword']));
6034
+            $sql .= " AND (
6035 6035
     		            user.username LIKE '%".$keyword."%' OR
6036 6036
     		            lastedit_type LIKE '%".$keyword."%' OR
6037 6037
     		            tool LIKE '%".$keyword."%'
6038 6038
                      ) ";
6039
-    	}
6039
+        }
6040 6040
 
6041
-    	$sql .= " AND tool IN (
6041
+        $sql .= " AND tool IN (
6042 6042
     	            'document',
6043 6043
     	            'learnpath',
6044 6044
     	            'quiz',
@@ -6051,41 +6051,41 @@  discard block
 block discarded – undo
6051 6051
     	            'thematic_plan'
6052 6052
                 )";
6053 6053
 
6054
-    	if ($column == 0) {
6055
-    		$column = '0';
6056
-    	}
6057
-    	if ($column != '' && $direction != '') {
6058
-    		if ($column != 2 && $column != 4) {
6059
-    			$sql .= " ORDER BY col$column $direction";
6060
-    		}
6061
-    	} else {
6062
-    		$sql .= " ORDER BY col5 DESC ";
6063
-    	}
6054
+        if ($column == 0) {
6055
+            $column = '0';
6056
+        }
6057
+        if ($column != '' && $direction != '') {
6058
+            if ($column != 2 && $column != 4) {
6059
+                $sql .= " ORDER BY col$column $direction";
6060
+            }
6061
+        } else {
6062
+            $sql .= " ORDER BY col5 DESC ";
6063
+        }
6064 6064
 
6065 6065
         $from = intval($from);
6066 6066
         $number_of_items = intval($number_of_items);
6067 6067
 
6068
-    	$sql .= " LIMIT $from, $number_of_items ";
6069
-
6070
-    	$res = Database::query($sql);
6071
-    	$resources = array();
6072
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
-    	while ($row = Database::fetch_array($res)) {
6074
-    		$ref = $row['ref'];
6075
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
6068
+        $sql .= " LIMIT $from, $number_of_items ";
6077 6069
 
6078
-    		$id = $table_name['id_tool'];
6079
-    		$recorset = false;
6080
-
6081
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
-    			$sql = "SELECT thematic_id FROM $table_tool
6070
+        $res = Database::query($sql);
6071
+        $resources = array();
6072
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
+        while ($row = Database::fetch_array($res)) {
6074
+            $ref = $row['ref'];
6075
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
+            $table_tool = Database :: get_course_table($table_name['table_name']);
6077
+
6078
+            $id = $table_name['id_tool'];
6079
+            $recorset = false;
6080
+
6081
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
+                $sql = "SELECT thematic_id FROM $table_tool
6084 6084
     			        WHERE c_id = $course_id AND id = $ref";
6085
-    			$rs_thematic  = Database::query($sql);
6086
-    			if (Database::num_rows($rs_thematic)) {
6087
-    				$row_thematic = Database::fetch_array($rs_thematic);
6088
-    				$thematic_id = $row_thematic['thematic_id'];
6085
+                $rs_thematic  = Database::query($sql);
6086
+                if (Database::num_rows($rs_thematic)) {
6087
+                    $row_thematic = Database::fetch_array($rs_thematic);
6088
+                    $thematic_id = $row_thematic['thematic_id'];
6089 6089
 
6090 6090
                     $sql = "SELECT session.id, session.name, user.username
6091 6091
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -6094,9 +6094,9 @@  discard block
 block discarded – undo
6094 6094
                               t.session_id = session.id AND
6095 6095
                               session.id_coach = user.user_id AND
6096 6096
                               t.id = $thematic_id";
6097
-    				$recorset = Database::query($sql);
6098
-    			}
6099
-    		} else {
6097
+                    $recorset = Database::query($sql);
6098
+                }
6099
+            } else {
6100 6100
                 $sql = "SELECT session.id, session.name, user.username
6101 6101
                           FROM $table_tool tool, $table_session session, $table_user user
6102 6102
     			          WHERE
@@ -6104,134 +6104,134 @@  discard block
 block discarded – undo
6104 6104
     			              tool.session_id = session.id AND
6105 6105
     			              session.id_coach = user.user_id AND
6106 6106
     			              tool.$id = $ref";
6107
-    			$recorset = Database::query($sql);
6108
-    		}
6109
-
6110
-    		if (!empty($recorset)) {
6111
-    			$obj = Database::fetch_object($recorset);
6112
-
6113
-    			$name_session = '';
6114
-    			$coach_name = '';
6115
-    			if (!empty($obj)) {
6116
-    				$name_session = $obj->name;
6117
-    				$coach_name   = $obj->username;
6118
-    			}
6119
-
6120
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
-    			$row[0] = '';
6122
-    			if ($row['col6'] != 2) {
6123
-    				if (in_array($row['col0'], $thematic_tools)) {
6124
-
6125
-    					$exp_thematic_tool = explode('_', $row['col0']);
6126
-    					$thematic_tool_title = '';
6127
-    					if (is_array($exp_thematic_tool)) {
6128
-    						foreach ($exp_thematic_tool as $exp) {
6129
-    							$thematic_tool_title .= api_ucfirst($exp);
6130
-    						}
6131
-    					} else {
6132
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6133
-    					}
6134
-
6135
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
-    				} else {
6137
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
-    				}
6139
-    			} else {
6140
-    				$row[0] = api_ucfirst($row['col0']);
6141
-    			}
6142
-    			$row[1] = get_lang($row[1]);
6143
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
-    			$row[5] = '';
6145
-    			//@todo Improve this code please
6146
-    			switch ($table_name['table_name']) {
6147
-    				case 'document':
6148
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
6107
+                $recorset = Database::query($sql);
6108
+            }
6109
+
6110
+            if (!empty($recorset)) {
6111
+                $obj = Database::fetch_object($recorset);
6112
+
6113
+                $name_session = '';
6114
+                $coach_name = '';
6115
+                if (!empty($obj)) {
6116
+                    $name_session = $obj->name;
6117
+                    $coach_name   = $obj->username;
6118
+                }
6119
+
6120
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
+                $row[0] = '';
6122
+                if ($row['col6'] != 2) {
6123
+                    if (in_array($row['col0'], $thematic_tools)) {
6124
+
6125
+                        $exp_thematic_tool = explode('_', $row['col0']);
6126
+                        $thematic_tool_title = '';
6127
+                        if (is_array($exp_thematic_tool)) {
6128
+                            foreach ($exp_thematic_tool as $exp) {
6129
+                                $thematic_tool_title .= api_ucfirst($exp);
6130
+                            }
6131
+                        } else {
6132
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6133
+                        }
6134
+
6135
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
+                    } else {
6137
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
+                    }
6139
+                } else {
6140
+                    $row[0] = api_ucfirst($row['col0']);
6141
+                }
6142
+                $row[1] = get_lang($row[1]);
6143
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
+                $row[5] = '';
6145
+                //@todo Improve this code please
6146
+                switch ($table_name['table_name']) {
6147
+                    case 'document':
6148
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6149 6149
                                 WHERE c_id = $course_id AND id = $ref";
6150
-    					$rs_document = Database::query($sql);
6151
-    					$obj_document = Database::fetch_object($rs_document);
6150
+                        $rs_document = Database::query($sql);
6151
+                        $obj_document = Database::fetch_object($rs_document);
6152 6152
                         if ($obj_document) {
6153 6153
                             $row[5] = $obj_document->title;
6154 6154
                         }
6155
-    					break;
6156
-    				case 'announcement':
6155
+                        break;
6156
+                    case 'announcement':
6157 6157
                         $sql = "SELECT title FROM $table_tool
6158 6158
                                 WHERE c_id = $course_id AND id = $ref";
6159
-    					$rs_document = Database::query($sql);
6160
-    					$obj_document = Database::fetch_object($rs_document);
6159
+                        $rs_document = Database::query($sql);
6160
+                        $obj_document = Database::fetch_object($rs_document);
6161 6161
                         if ($obj_document) {
6162 6162
                             $row[5] = $obj_document->title;
6163 6163
                         }
6164
-    					break;
6165
-    				case 'glossary':
6164
+                        break;
6165
+                    case 'glossary':
6166 6166
                         $sql = "SELECT name FROM $table_tool
6167 6167
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6168
-    					$rs_document = Database::query($sql);
6169
-    					$obj_document = Database::fetch_object($rs_document);
6168
+                        $rs_document = Database::query($sql);
6169
+                        $obj_document = Database::fetch_object($rs_document);
6170 6170
                         if ($obj_document) {
6171 6171
                             $row[5] = $obj_document->name;
6172 6172
                         }
6173
-    					break;
6174
-    				case 'lp':
6173
+                        break;
6174
+                    case 'lp':
6175 6175
                         $sql = "SELECT name
6176 6176
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6177
-    					$rs_document = Database::query($sql);
6178
-    					$obj_document = Database::fetch_object($rs_document);
6179
-    					$row[5] = $obj_document->name;
6180
-    					break;
6181
-    				case 'quiz':
6177
+                        $rs_document = Database::query($sql);
6178
+                        $obj_document = Database::fetch_object($rs_document);
6179
+                        $row[5] = $obj_document->name;
6180
+                        break;
6181
+                    case 'quiz':
6182 6182
                         $sql = "SELECT title FROM $table_tool
6183 6183
                                 WHERE c_id = $course_id AND id = $ref";
6184
-    					$rs_document = Database::query($sql);
6185
-    					$obj_document = Database::fetch_object($rs_document);
6184
+                        $rs_document = Database::query($sql);
6185
+                        $obj_document = Database::fetch_object($rs_document);
6186 6186
                         if ($obj_document) {
6187 6187
                             $row[5] = $obj_document->title;
6188 6188
                         }
6189
-    					break;
6190
-    				case 'course_description':
6189
+                        break;
6190
+                    case 'course_description':
6191 6191
                         $sql = "SELECT title FROM $table_tool
6192 6192
                                 WHERE c_id = $course_id AND id = $ref";
6193
-    					$rs_document = Database::query($sql);
6194
-    					$obj_document = Database::fetch_object($rs_document);
6193
+                        $rs_document = Database::query($sql);
6194
+                        $obj_document = Database::fetch_object($rs_document);
6195 6195
                         if ($obj_document) {
6196 6196
                             $row[5] = $obj_document->title;
6197 6197
                         }
6198
-    					break;
6199
-    				case 'thematic':
6200
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
-    					if (Database::num_rows($rs) > 0) {
6202
-    						$obj = Database::fetch_object($rs);
6198
+                        break;
6199
+                    case 'thematic':
6200
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
+                        if (Database::num_rows($rs) > 0) {
6202
+                            $obj = Database::fetch_object($rs);
6203 6203
                             if ($obj) {
6204 6204
                                 $row[5] = $obj->title;
6205 6205
                             }
6206
-    					}
6207
-    					break;
6208
-    				case 'thematic_advance':
6209
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
-    					if (Database::num_rows($rs) > 0) {
6211
-    						$obj = Database::fetch_object($rs);
6206
+                        }
6207
+                        break;
6208
+                    case 'thematic_advance':
6209
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
+                        if (Database::num_rows($rs) > 0) {
6211
+                            $obj = Database::fetch_object($rs);
6212 6212
                             if ($obj) {
6213 6213
                                 $row[5] = $obj->content;
6214 6214
                             }
6215
-    					}
6216
-    					break;
6217
-    				case 'thematic_plan':
6218
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
-    					if (Database::num_rows($rs) > 0) {
6220
-    						$obj = Database::fetch_object($rs);
6215
+                        }
6216
+                        break;
6217
+                    case 'thematic_plan':
6218
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
+                        if (Database::num_rows($rs) > 0) {
6220
+                            $obj = Database::fetch_object($rs);
6221 6221
                             if ($obj) {
6222 6222
                                 $row[5] = $obj->title;
6223 6223
                             }
6224
-    					}
6225
-    					break;
6226
-    				default:
6227
-    					break;
6228
-    			}
6229
-
6230
-    			$row2 = $name_session;
6231
-    			if (!empty($coach_name)) {
6232
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
-    			}
6234
-    			$row[2] = $row2;
6224
+                        }
6225
+                        break;
6226
+                    default:
6227
+                        break;
6228
+                }
6229
+
6230
+                $row2 = $name_session;
6231
+                if (!empty($coach_name)) {
6232
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
+                }
6234
+                $row[2] = $row2;
6235 6235
                 if (!empty($row['col3'])) {
6236 6236
                     $userInfo = api_get_user_info($row['user_id']);
6237 6237
                     $row['col3'] = Display::url(
@@ -6247,11 +6247,11 @@  discard block
 block discarded – undo
6247 6247
                     $row[4] = $ip;
6248 6248
                 }
6249 6249
 
6250
-    			$resources[] = $row;
6251
-    		}
6252
-    	}
6250
+                $resources[] = $row;
6251
+            }
6252
+        }
6253 6253
 
6254
-    	return $resources;
6254
+        return $resources;
6255 6255
     }
6256 6256
 
6257 6257
     /**
@@ -6261,63 +6261,63 @@  discard block
 block discarded – undo
6261 6261
      */
6262 6262
     public static function get_tool_name_table($tool)
6263 6263
     {
6264
-    	switch ($tool) {
6265
-    		case 'document':
6266
-    			$table_name = TABLE_DOCUMENT;
6267
-    			$link_tool = 'document/document.php';
6268
-    			$id_tool = 'id';
6269
-    			break;
6270
-    		case 'learnpath':
6271
-    			$table_name = TABLE_LP_MAIN;
6272
-    			$link_tool = 'lp/lp_controller.php';
6273
-    			$id_tool = 'id';
6274
-    			break;
6275
-    		case 'quiz':
6276
-    			$table_name = TABLE_QUIZ_TEST;
6277
-    			$link_tool = 'exercise/exercise.php';
6278
-    			$id_tool = 'id';
6279
-    			break;
6280
-    		case 'glossary':
6281
-    			$table_name = TABLE_GLOSSARY;
6282
-    			$link_tool = 'glossary/index.php';
6283
-    			$id_tool = 'glossary_id';
6284
-    			break;
6285
-    		case 'link':
6286
-    			$table_name = TABLE_LINK;
6287
-    			$link_tool = 'link/link.php';
6288
-    			$id_tool = 'id';
6289
-    			break;
6290
-    		case 'course_description':
6291
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6292
-    			$link_tool = 'course_description/';
6293
-    			$id_tool = 'id';
6294
-    			break;
6295
-    		case 'announcement':
6296
-    			$table_name = TABLE_ANNOUNCEMENT;
6297
-    			$link_tool = 'announcements/announcements.php';
6298
-    			$id_tool = 'id';
6299
-    			break;
6300
-    		case 'thematic':
6301
-    			$table_name = TABLE_THEMATIC;
6302
-    			$link_tool = 'course_progress/index.php';
6303
-    			$id_tool = 'id';
6304
-    			break;
6305
-    		case 'thematic_advance':
6306
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6307
-    			$link_tool = 'course_progress/index.php';
6308
-    			$id_tool = 'id';
6309
-    			break;
6310
-    		case 'thematic_plan':
6311
-    			$table_name = TABLE_THEMATIC_PLAN;
6312
-    			$link_tool = 'course_progress/index.php';
6313
-    			$id_tool = 'id';
6314
-    			break;
6315
-    		default:
6316
-    			$table_name = $tool;
6317
-    		break;
6318
-    	}
6319
-
6320
-    	return array(
6264
+        switch ($tool) {
6265
+            case 'document':
6266
+                $table_name = TABLE_DOCUMENT;
6267
+                $link_tool = 'document/document.php';
6268
+                $id_tool = 'id';
6269
+                break;
6270
+            case 'learnpath':
6271
+                $table_name = TABLE_LP_MAIN;
6272
+                $link_tool = 'lp/lp_controller.php';
6273
+                $id_tool = 'id';
6274
+                break;
6275
+            case 'quiz':
6276
+                $table_name = TABLE_QUIZ_TEST;
6277
+                $link_tool = 'exercise/exercise.php';
6278
+                $id_tool = 'id';
6279
+                break;
6280
+            case 'glossary':
6281
+                $table_name = TABLE_GLOSSARY;
6282
+                $link_tool = 'glossary/index.php';
6283
+                $id_tool = 'glossary_id';
6284
+                break;
6285
+            case 'link':
6286
+                $table_name = TABLE_LINK;
6287
+                $link_tool = 'link/link.php';
6288
+                $id_tool = 'id';
6289
+                break;
6290
+            case 'course_description':
6291
+                $table_name = TABLE_COURSE_DESCRIPTION;
6292
+                $link_tool = 'course_description/';
6293
+                $id_tool = 'id';
6294
+                break;
6295
+            case 'announcement':
6296
+                $table_name = TABLE_ANNOUNCEMENT;
6297
+                $link_tool = 'announcements/announcements.php';
6298
+                $id_tool = 'id';
6299
+                break;
6300
+            case 'thematic':
6301
+                $table_name = TABLE_THEMATIC;
6302
+                $link_tool = 'course_progress/index.php';
6303
+                $id_tool = 'id';
6304
+                break;
6305
+            case 'thematic_advance':
6306
+                $table_name = TABLE_THEMATIC_ADVANCE;
6307
+                $link_tool = 'course_progress/index.php';
6308
+                $id_tool = 'id';
6309
+                break;
6310
+            case 'thematic_plan':
6311
+                $table_name = TABLE_THEMATIC_PLAN;
6312
+                $link_tool = 'course_progress/index.php';
6313
+                $id_tool = 'id';
6314
+                break;
6315
+            default:
6316
+                $table_name = $tool;
6317
+            break;
6318
+        }
6319
+
6320
+        return array(
6321 6321
             'table_name' => $table_name,
6322 6322
             'link_tool' => $link_tool,
6323 6323
             'id_tool' => $id_tool
@@ -6326,45 +6326,45 @@  discard block
 block discarded – undo
6326 6326
 
6327 6327
     public static function display_additional_profile_fields()
6328 6328
     {
6329
-    	// getting all the extra profile fields that are defined by the platform administrator
6330
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
-
6332
-    	// creating the form
6333
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
-
6335
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
-    	// the information the users have entered or selected.
6337
-    	$return .= '<select name="additional_profile_field">';
6338
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
-    	$extra_fields_to_show = 0;
6340
-    	foreach ($extra_fields as $key=>$field) {
6341
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
-    		if ($field[6]==1 && $field[8] == 1) {
6343
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
-    				$selected = 'selected="selected"';
6345
-    			} else {
6346
-    				$selected = '';
6347
-    			}
6348
-    			$extra_fields_to_show++;
6349
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
-    		}
6351
-    	}
6352
-    	$return .= '</select>';
6353
-
6354
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6355
-    	foreach ($_GET as $key=>$value){
6356
-    		if ($key <> 'additional_profile_field')    {
6357
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
-    		}
6359
-    	}
6360
-    	// the submit button
6361
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
-    	$return .= '</form>';
6363
-    	if ($extra_fields_to_show > 0) {
6364
-    		return $return;
6365
-    	} else {
6366
-    		return '';
6367
-    	}
6329
+        // getting all the extra profile fields that are defined by the platform administrator
6330
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
+
6332
+        // creating the form
6333
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
+
6335
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
+        // the information the users have entered or selected.
6337
+        $return .= '<select name="additional_profile_field">';
6338
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
+        $extra_fields_to_show = 0;
6340
+        foreach ($extra_fields as $key=>$field) {
6341
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
+            if ($field[6]==1 && $field[8] == 1) {
6343
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
+                    $selected = 'selected="selected"';
6345
+                } else {
6346
+                    $selected = '';
6347
+                }
6348
+                $extra_fields_to_show++;
6349
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
+            }
6351
+        }
6352
+        $return .= '</select>';
6353
+
6354
+        // the form elements for the $_GET parameters (because the form is passed through GET
6355
+        foreach ($_GET as $key=>$value){
6356
+            if ($key <> 'additional_profile_field')    {
6357
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
+            }
6359
+        }
6360
+        // the submit button
6361
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
+        $return .= '</form>';
6363
+        if ($extra_fields_to_show > 0) {
6364
+            return $return;
6365
+        } else {
6366
+            return '';
6367
+        }
6368 6368
     }
6369 6369
 
6370 6370
     /**
@@ -6383,31 +6383,31 @@  discard block
 block discarded – undo
6383 6383
      */
6384 6384
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6385 6385
     {
6386
-    	// Database table definition
6387
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6386
+        // Database table definition
6387
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6389 6389
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6390
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6391
-
6392
-    	if (!empty($users)) {
6393
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
-    			foreach($users as $user_id) {
6395
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6396
-    				$tag_list = array();
6397
-    				foreach($user_result as $item) {
6398
-    					$tag_list[] = $item['tag'];
6399
-    				}
6400
-    				$return[$user_id][] = implode(', ',$tag_list);
6401
-    			}
6402
-    		} else {
6403
-    			$new_user_array = array();
6404
-    			foreach ($users as $user_id) {
6405
-    				$new_user_array[]= "'".$user_id."'";
6406
-    			}
6407
-    			$users = implode(',',$new_user_array);
6390
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6391
+
6392
+        if (!empty($users)) {
6393
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
+                foreach($users as $user_id) {
6395
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6396
+                    $tag_list = array();
6397
+                    foreach($user_result as $item) {
6398
+                        $tag_list[] = $item['tag'];
6399
+                    }
6400
+                    $return[$user_id][] = implode(', ',$tag_list);
6401
+                }
6402
+            } else {
6403
+                $new_user_array = array();
6404
+                foreach ($users as $user_id) {
6405
+                    $new_user_array[]= "'".$user_id."'";
6406
+                }
6407
+                $users = implode(',',$new_user_array);
6408 6408
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6409
-    			// Selecting only the necessary information NOT ALL the user list
6410
-    			$sql = "SELECT user.user_id, v.value
6409
+                // Selecting only the necessary information NOT ALL the user list
6410
+                $sql = "SELECT user.user_id, v.value
6411 6411
     			        FROM $table_user user
6412 6412
     			        INNER JOIN $table_user_field_values v
6413 6413
                         ON (user.user_id = v.item_id)
@@ -6418,27 +6418,27 @@  discard block
 block discarded – undo
6418 6418
                             v.field_id=".intval($field_id)." AND
6419 6419
                             user.user_id IN ($users)";
6420 6420
 
6421
-    			$result = Database::query($sql);
6422
-    			while($row = Database::fetch_array($result)) {
6423
-    				// get option value for field type double select by id
6424
-    				if (!empty($row['value'])) {
6425
-    					if ($result_extra_field['field_type'] ==
6421
+                $result = Database::query($sql);
6422
+                while($row = Database::fetch_array($result)) {
6423
+                    // get option value for field type double select by id
6424
+                    if (!empty($row['value'])) {
6425
+                        if ($result_extra_field['field_type'] ==
6426 6426
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6427 6427
                         ) {
6428
-    						$id_double_select = explode(';', $row['value']);
6429
-    						if (is_array($id_double_select)) {
6430
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
-    							$row['value'] = ($value1.';'.$value2);
6433
-    						}
6434
-    					}
6435
-    				}
6436
-    				// get other value from extra field
6437
-    				$return[$row['user_id']][] = $row['value'];
6438
-    			}
6439
-    		}
6440
-    	}
6441
-    	return $return;
6428
+                            $id_double_select = explode(';', $row['value']);
6429
+                            if (is_array($id_double_select)) {
6430
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
+                                $row['value'] = ($value1.';'.$value2);
6433
+                            }
6434
+                        }
6435
+                    }
6436
+                    // get other value from extra field
6437
+                    $return[$row['user_id']][] = $row['value'];
6438
+                }
6439
+            }
6440
+        }
6441
+        return $return;
6442 6442
     }
6443 6443
 
6444 6444
     /**
@@ -6447,18 +6447,18 @@  discard block
 block discarded – undo
6447 6447
      */
6448 6448
     public function count_student_in_course()
6449 6449
     {
6450
-    	global $nbStudents;
6451
-    	return $nbStudents;
6450
+        global $nbStudents;
6451
+        return $nbStudents;
6452 6452
     }
6453 6453
 
6454 6454
     public function sort_users($a, $b)
6455 6455
     {
6456
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6456
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6457 6457
     }
6458 6458
 
6459 6459
     public function sort_users_desc($a, $b)
6460 6460
     {
6461
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6461
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6462 6462
     }
6463 6463
 
6464 6464
     /**
@@ -6467,8 +6467,8 @@  discard block
 block discarded – undo
6467 6467
      */
6468 6468
     public static function get_number_of_users()
6469 6469
     {
6470
-    	global $user_ids;
6471
-    	return count($user_ids);
6470
+        global $user_ids;
6471
+        return count($user_ids);
6472 6472
     }
6473 6473
 
6474 6474
     /**
@@ -6484,37 +6484,37 @@  discard block
 block discarded – undo
6484 6484
     {
6485 6485
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6486 6486
 
6487
-    	$course_code = Database::escape_string($course_code);
6488
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6487
+        $course_code = Database::escape_string($course_code);
6488
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6490 6490
 
6491
-    	$access_url_id = api_get_current_access_url_id();
6491
+        $access_url_id = api_get_current_access_url_id();
6492 6492
 
6493
-    	// get all users data from a course for sortable with limit
6494
-    	if (is_array($user_ids)) {
6495
-    		$user_ids = array_map('intval', $user_ids);
6496
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
-    	} else {
6498
-    		$user_ids = intval($user_ids);
6499
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6500
-    	}
6493
+        // get all users data from a course for sortable with limit
6494
+        if (is_array($user_ids)) {
6495
+            $user_ids = array_map('intval', $user_ids);
6496
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
+        } else {
6498
+            $user_ids = intval($user_ids);
6499
+            $condition_user = " WHERE user.user_id = $user_ids ";
6500
+        }
6501 6501
 
6502
-    	if (!empty($_GET['user_keyword'])) {
6503
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
-    		$condition_user .=  " AND (
6502
+        if (!empty($_GET['user_keyword'])) {
6503
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
+            $condition_user .=  " AND (
6505 6505
                 user.firstname LIKE '%".$keyword."%' OR
6506 6506
                 user.lastname LIKE '%".$keyword."%'  OR
6507 6507
                 user.username LIKE '%".$keyword."%'  OR
6508 6508
                 user.email LIKE '%".$keyword."%'
6509 6509
              ) ";
6510
-    	}
6510
+        }
6511 6511
 
6512 6512
         $url_table = null;
6513 6513
         $url_condition = null;
6514
-    	if (api_is_multiple_url_enabled()) {
6515
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6516
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
-    	}
6514
+        if (api_is_multiple_url_enabled()) {
6515
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6516
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
+        }
6518 6518
 
6519 6519
         $invitedUsersCondition = '';
6520 6520
 
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6523 6523
         }
6524 6524
 
6525
-    	$sql = "SELECT  user.user_id as user_id,
6525
+        $sql = "SELECT  user.user_id as user_id,
6526 6526
                     user.official_code  as col0,
6527 6527
                     user.lastname       as col1,
6528 6528
                     user.firstname      as col2,
@@ -6530,16 +6530,16 @@  discard block
 block discarded – undo
6530 6530
                 FROM $tbl_user as user $url_table
6531 6531
     	        $condition_user $url_condition $invitedUsersCondition";
6532 6532
 
6533
-    	if (!in_array($direction, array('ASC','DESC'))) {
6534
-    		$direction = 'ASC';
6535
-    	}
6533
+        if (!in_array($direction, array('ASC','DESC'))) {
6534
+            $direction = 'ASC';
6535
+        }
6536 6536
 
6537
-    	$column = intval($column);
6538
-    	$from = intval($from);
6539
-    	$number_of_items = intval($number_of_items);
6537
+        $column = intval($column);
6538
+        $from = intval($from);
6539
+        $number_of_items = intval($number_of_items);
6540 6540
 
6541
-    	$sql .= " ORDER BY col$column $direction ";
6542
-    	$sql .= " LIMIT $from,$number_of_items";
6541
+        $sql .= " ORDER BY col$column $direction ";
6542
+        $sql .= " LIMIT $from,$number_of_items";
6543 6543
 
6544 6544
         $res = Database::query($sql);
6545 6545
         $users = array();
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
             }
6574 6574
         }
6575 6575
 
6576
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6576
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6577 6577
             $courseInfo = api_get_course_info($course_code);
6578 6578
             $courseId = $courseInfo['real_id'];
6579 6579
 
@@ -6604,10 +6604,10 @@  discard block
 block discarded – undo
6604 6604
                 $session_id
6605 6605
             );
6606 6606
 
6607
-    		if (empty($avg_student_progress)) {
6607
+            if (empty($avg_student_progress)) {
6608 6608
                 $avg_student_progress = 0;
6609
-    		}
6610
-    		$user['average_progress'] = $avg_student_progress.'%';
6609
+            }
6610
+            $user['average_progress'] = $avg_student_progress.'%';
6611 6611
 
6612 6612
             $total_user_exercise = Tracking::get_exercise_student_progress(
6613 6613
                 $total_exercises,
@@ -6627,11 +6627,11 @@  discard block
 block discarded – undo
6627 6627
 
6628 6628
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6629 6629
 
6630
-    		if (is_numeric($avg_student_score)) {
6631
-    			$user['student_score']  = $avg_student_score.'%';
6632
-    		} else {
6633
-    			$user['student_score']  = $avg_student_score;
6634
-    		}
6630
+            if (is_numeric($avg_student_score)) {
6631
+                $user['student_score']  = $avg_student_score.'%';
6632
+            } else {
6633
+                $user['student_score']  = $avg_student_score;
6634
+            }
6635 6635
 
6636 6636
             $user['count_assignments'] = Tracking::count_student_assignments(
6637 6637
                 $user['user_id'],
@@ -6654,29 +6654,29 @@  discard block
 block discarded – undo
6654 6654
                 $session_id
6655 6655
             );
6656 6656
 
6657
-    		// we need to display an additional profile field
6658
-    		$user['additional'] = '';
6657
+            // we need to display an additional profile field
6658
+            $user['additional'] = '';
6659 6659
 
6660
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6660
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6662 6662
                     is_array($additional_user_profile_info[$user['user_id']])
6663 6663
                 ) {
6664
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
-    			}
6666
-    		}
6664
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
+                }
6666
+            }
6667 6667
 
6668 6668
             if (empty($session_id)) {
6669 6669
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6670 6670
             }
6671 6671
 
6672
-    		$user['link'] = '<center>
6672
+            $user['link'] = '<center>
6673 6673
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6674 6674
     		                 '.Display::return_icon('2rightarrow.png').'
6675 6675
     		                 </a>
6676 6676
                          </center>';
6677 6677
 
6678
-    		// store columns in array $users
6679
-    		$is_western_name_order = api_is_western_name_order();
6678
+            // store columns in array $users
6679
+            $is_western_name_order = api_is_western_name_order();
6680 6680
             $user_row = array();
6681 6681
             $user_row[]= $user['official_code']; //0
6682 6682
             if ($is_western_name_order) {
@@ -6712,21 +6712,21 @@  discard block
 block discarded – undo
6712 6712
 
6713 6713
             $users[] = $user_row;
6714 6714
 
6715
-    		if ($export_csv) {
6716
-    		    if (empty($session_id)) {
6715
+            if ($export_csv) {
6716
+                if (empty($session_id)) {
6717 6717
                     $user_row = array_map('strip_tags', $user_row);
6718
-    			    unset($user_row[14]);
6719
-    			    unset($user_row[15]);
6718
+                    unset($user_row[14]);
6719
+                    unset($user_row[15]);
6720 6720
                 } else {
6721 6721
                     $user_row = array_map('strip_tags', $user_row);
6722 6722
                     unset($user_row[13]);
6723 6723
                     unset($user_row[14]);
6724 6724
                 }
6725 6725
 
6726
-    			$csv_content[] = $user_row;
6727
-    		}
6728
-    	}
6729
-    	return $users;
6726
+                $csv_content[] = $user_row;
6727
+            }
6728
+        }
6729
+        return $users;
6730 6730
     }
6731 6731
 }
6732 6732
 
@@ -6744,18 +6744,18 @@  discard block
 block discarded – undo
6744 6744
      */
6745 6745
     public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6746 6746
     {
6747
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6748
-
6749
-    	// protected data
6750
-    	$user_id = intval($user_id);
6751
-    	$session_id = intval($session_id);
6752
-    	$course_id = Database::escape_string($course_id);
6753
-
6754
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
-    	$tempView = $view;
6756
-    	if(substr($view,0,1) == '1') {
6757
-    		$new_view = substr_replace($view,'0',0,1);
6758
-    		echo "
6747
+        $MonthsLong = $GLOBALS['MonthsLong'];
6748
+
6749
+        // protected data
6750
+        $user_id = intval($user_id);
6751
+        $session_id = intval($session_id);
6752
+        $course_id = Database::escape_string($course_id);
6753
+
6754
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
+        $tempView = $view;
6756
+        if(substr($view,0,1) == '1') {
6757
+            $new_view = substr_replace($view,'0',0,1);
6758
+            echo "
6759 6759
                 <tr>
6760 6760
                     <td valign='top'>
6761 6761
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6763,9 +6763,9 @@  discard block
 block discarded – undo
6763 6763
                     </td>
6764 6764
                 </tr>
6765 6765
                 ";
6766
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6766
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6767 6767
 
6768
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6768
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6769 6769
                         FROM $track_access_table
6770 6770
                         WHERE access_user_id = $user_id
6771 6771
                         AND c_id = $course_id
@@ -6773,11 +6773,11 @@  discard block
 block discarded – undo
6773 6773
                         GROUP BY YEAR(access_date),MONTH(access_date)
6774 6774
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6775 6775
 
6776
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
-    		$results = getManyResults3Col($sql);
6776
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
+            $results = getManyResults3Col($sql);
6778 6778
 
6779
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
-    		echo "<tr>
6779
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
+            echo "<tr>
6781 6781
                     <td class='secLine'>
6782 6782
                     ".get_lang('LoginsTitleMonthColumn')."
6783 6783
                     </td>
@@ -6785,36 +6785,36 @@  discard block
 block discarded – undo
6785 6785
                     ".get_lang('LoginsTitleCountColumn')."
6786 6786
                     </td>
6787 6787
                 </tr>";
6788
-    		$total = 0;
6789
-    		if (is_array($results)) {
6790
-    			for($j = 0 ; $j < count($results) ; $j++) {
6791
-    				echo "<tr>";
6792
-    				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>";
6793
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
-    				echo"</tr>";
6795
-    				$total = $total + $results[$j][1];
6796
-    			}
6797
-    			echo "<tr>";
6798
-    			echo "<td>".get_lang('Total')."</td>";
6799
-    			echo "<td align='right' class='content'>".$total."</td>";
6800
-    			echo"</tr>";
6801
-    		} else {
6802
-    			echo "<tr>";
6803
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
-    			echo"</tr>";
6805
-    		}
6806
-    		echo "</table>";
6807
-    		echo "</td></tr>";
6808
-    	} else {
6809
-    		$new_view = substr_replace($view,'1',0,1);
6810
-    		echo "
6788
+            $total = 0;
6789
+            if (is_array($results)) {
6790
+                for($j = 0 ; $j < count($results) ; $j++) {
6791
+                    echo "<tr>";
6792
+                    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>";
6793
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
+                    echo"</tr>";
6795
+                    $total = $total + $results[$j][1];
6796
+                }
6797
+                echo "<tr>";
6798
+                echo "<td>".get_lang('Total')."</td>";
6799
+                echo "<td align='right' class='content'>".$total."</td>";
6800
+                echo"</tr>";
6801
+            } else {
6802
+                echo "<tr>";
6803
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
+                echo"</tr>";
6805
+            }
6806
+            echo "</table>";
6807
+            echo "</td></tr>";
6808
+        } else {
6809
+            $new_view = substr_replace($view,'1',0,1);
6810
+            echo "
6811 6811
                 <tr>
6812 6812
                     <td valign='top'>
6813 6813
                     +<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>
6814 6814
                     </td>
6815 6815
                 </tr>
6816 6816
             ";
6817
-    	}
6817
+        }
6818 6818
     }
6819 6819
 
6820 6820
     /**
@@ -6827,38 +6827,38 @@  discard block
 block discarded – undo
6827 6827
      */
6828 6828
     public static function display_exercise_tracking_info($view, $user_id, $courseCode)
6829 6829
     {
6830
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6830
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6831 6831
         $courseId = api_get_course_int_id($courseCode);
6832
-    	if(substr($view,1,1) == '1') {
6833
-    		$new_view = substr_replace($view,'0',1,1);
6834
-    		echo "<tr>
6832
+        if(substr($view,1,1) == '1') {
6833
+            $new_view = substr_replace($view,'0',1,1);
6834
+            echo "<tr>
6835 6835
                     <td valign='top'>
6836 6836
                         <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>]
6837 6837
                     </td>
6838 6838
                 </tr>";
6839
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6839
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6840 6840
 
6841
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6841
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6842 6842
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6843 6843
                     WHERE te.c_id = $courseId
6844 6844
                         AND te.exe_user_id = ".intval($user_id)."
6845 6845
                         AND te.exe_exo_id = ce.id
6846 6846
                     ORDER BY ce.title ASC, te.exe_date ASC";
6847 6847
 
6848
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6848
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6849 6849
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6850 6850
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6851 6851
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6852 6852
 
6853
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6853
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6854 6854
 
6855
-    		$NoTestRes = 0;
6856
-    		$NoHPTestRes = 0;
6855
+            $NoTestRes = 0;
6856
+            $NoHPTestRes = 0;
6857 6857
 
6858
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6860
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
-    		echo "
6858
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6860
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
+            echo "
6862 6862
                 <tr bgcolor='#E6E6E6'>
6863 6863
                     <td>
6864 6864
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6871,28 +6871,28 @@  discard block
 block discarded – undo
6871 6871
                     </td>
6872 6872
                 </tr>";
6873 6873
 
6874
-    		if (is_array($results)) {
6875
-    			for($i = 0; $i < sizeof($results); $i++) {
6876
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
-    				echo "<tr>\n";
6878
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
-    				echo "<td class='content'>".$display_date."</td>\n";
6880
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
-    				echo "</tr>\n";
6882
-    			}
6883
-    		} else {
6884
-    			// istvan begin
6885
-    			$NoTestRes = 1;
6886
-    		}
6887
-
6888
-    		// The Result of Tests
6889
-    		if (is_array($hpresults)) {
6890
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6891
-    				$title = GetQuizName($hpresults[$i][0],'');
6892
-    				if ($title == '')
6893
-    				$title = basename($hpresults[$i][0]);
6894
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
-    				?>
6874
+            if (is_array($results)) {
6875
+                for($i = 0; $i < sizeof($results); $i++) {
6876
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
+                    echo "<tr>\n";
6878
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
+                    echo "<td class='content'>".$display_date."</td>\n";
6880
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
+                    echo "</tr>\n";
6882
+                }
6883
+            } else {
6884
+                // istvan begin
6885
+                $NoTestRes = 1;
6886
+            }
6887
+
6888
+            // The Result of Tests
6889
+            if (is_array($hpresults)) {
6890
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6891
+                    $title = GetQuizName($hpresults[$i][0],'');
6892
+                    if ($title == '')
6893
+                    $title = basename($hpresults[$i][0]);
6894
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
+                    ?>
6896 6896
                     <tr>
6897 6897
                         <td class="content"><?php echo $title; ?></td>
6898 6898
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6902,26 +6902,26 @@  discard block
 block discarded – undo
6902 6902
 
6903 6903
                     <?php
6904 6904
                 }
6905
-    		} else {
6906
-    			$NoHPTestRes = 1;
6907
-    		}
6908
-
6909
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
-    			echo "<tr>\n";
6911
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
-    			echo "</tr>\n";
6913
-    		}
6914
-    		echo "</table>";
6915
-    		echo "</td>\n</tr>\n";
6916
-    	} else {
6917
-    		$new_view = substr_replace($view,'1',1,1);
6918
-    		echo "
6905
+            } else {
6906
+                $NoHPTestRes = 1;
6907
+            }
6908
+
6909
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
+                echo "<tr>\n";
6911
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
+                echo "</tr>\n";
6913
+            }
6914
+            echo "</table>";
6915
+            echo "</td>\n</tr>\n";
6916
+        } else {
6917
+            $new_view = substr_replace($view,'1',1,1);
6918
+            echo "
6919 6919
                 <tr>
6920 6920
                     <td valign='top'>
6921 6921
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6922 6922
                     </td>
6923 6923
                 </tr>";
6924
-    	}
6924
+        }
6925 6925
     }
6926 6926
 
6927 6927
     /**
@@ -6930,27 +6930,27 @@  discard block
 block discarded – undo
6930 6930
      */
6931 6931
     public static function display_student_publications_tracking_info($view, $user_id, $course_id)
6932 6932
     {
6933
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6933
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6934 6934
         $_course = api_get_course_info_by_id($course_id);
6935 6935
 
6936
-    	if (substr($view,2,1) == '1') {
6937
-    		$new_view = substr_replace($view,'0',2,1);
6938
-    		echo "<tr>
6936
+        if (substr($view,2,1) == '1') {
6937
+            $new_view = substr_replace($view,'0',2,1);
6938
+            echo "<tr>
6939 6939
                     <td valign='top'>
6940 6940
                     <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>]
6941 6941
                     </td>
6942 6942
                 </tr>";
6943
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6943
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6945 6945
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6946 6946
                     WHERE u.upload_work_id = w.id
6947 6947
                         AND u.upload_user_id = '".intval($user_id)."'
6948 6948
                         AND u.c_id = '".intval($course_id)."'
6949 6949
                     ORDER BY u.upload_date DESC";
6950
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6952
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
-    		echo "<tr>
6950
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6952
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
+            echo "<tr>
6954 6954
                     <td class='secLine' width='40%'>
6955 6955
                     ".get_lang('WorkTitle')."
6956 6956
                     </td>
@@ -6961,35 +6961,35 @@  discard block
 block discarded – undo
6961 6961
                     ".get_lang('Date')."
6962 6962
                     </td>
6963 6963
                 </tr>";
6964
-    		if (is_array($results)) {
6965
-    			for($j = 0 ; $j < count($results) ; $j++) {
6966
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>"
6970
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
-    				."</td>";
6972
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6973
-    				echo "<td class='content'>".$beautifulDate."</td>";
6974
-    				echo"</tr>";
6975
-    			}
6976
-    		} else {
6977
-    			echo "<tr>";
6978
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
-    			echo"</tr>";
6980
-    		}
6981
-    		echo "</table>";
6982
-    		echo "</td></tr>";
6983
-    	} else {
6984
-    		$new_view = substr_replace($view,'1',2,1);
6985
-    		echo "
6964
+            if (is_array($results)) {
6965
+                for($j = 0 ; $j < count($results) ; $j++) {
6966
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>"
6970
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
+                    ."</td>";
6972
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6973
+                    echo "<td class='content'>".$beautifulDate."</td>";
6974
+                    echo"</tr>";
6975
+                }
6976
+            } else {
6977
+                echo "<tr>";
6978
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
+                echo"</tr>";
6980
+            }
6981
+            echo "</table>";
6982
+            echo "</td></tr>";
6983
+        } else {
6984
+            $new_view = substr_replace($view,'1',2,1);
6985
+            echo "
6986 6986
                 <tr>
6987 6987
                     <td valign='top'>
6988 6988
                     +<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>
6989 6989
                     </td>
6990 6990
                 </tr>
6991 6991
             ";
6992
-    	}
6992
+        }
6993 6993
     }
6994 6994
 
6995 6995
     /**
@@ -6998,55 +6998,55 @@  discard block
 block discarded – undo
6998 6998
      */
6999 6999
     public static function display_links_tracking_info($view, $user_id, $courseCode)
7000 7000
     {
7001
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7001
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7002 7002
         $courseId = api_get_course_int_id($courseCode);
7003
-    	if (substr($view,3,1) == '1') {
7004
-    		$new_view = substr_replace($view,'0',3,1);
7005
-    		echo "
7003
+        if (substr($view,3,1) == '1') {
7004
+            $new_view = substr_replace($view,'0',3,1);
7005
+            echo "
7006 7006
                 <tr>
7007 7007
                         <td valign='top'>
7008 7008
                         <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>]
7009 7009
                         </td>
7010 7010
                 </tr>
7011 7011
             ";
7012
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
-    		$sql = "SELECT cl.title, cl.url
7012
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
+            $sql = "SELECT cl.title, cl.url
7014 7014
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7015 7015
                     WHERE sl.links_link_id = cl.id
7016 7016
                         AND sl.c_id = $courseId
7017 7017
                         AND sl.links_user_id = ".intval($user_id)."
7018 7018
                     GROUP BY cl.title, cl.url";
7019
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
-    		$results = StatsUtils::getManyResults2Col($sql);
7021
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
-    		echo "<tr>
7019
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
+            $results = StatsUtils::getManyResults2Col($sql);
7021
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
+            echo "<tr>
7023 7023
                     <td class='secLine'>
7024 7024
                     ".get_lang('LinksTitleLinkColumn')."
7025 7025
                     </td>
7026 7026
                 </tr>";
7027
-    		if (is_array($results)) {
7028
-    			for($j = 0 ; $j < count($results) ; $j++) {
7029
-    				echo "<tr>";
7030
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
-    				echo"</tr>";
7032
-    			}
7033
-    		} else {
7034
-    			echo "<tr>";
7035
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
-    			echo"</tr>";
7037
-    		}
7038
-    		echo "</table>";
7039
-    		echo "</td></tr>";
7040
-    	} else {
7041
-    		$new_view = substr_replace($view,'1',3,1);
7042
-    		echo "
7027
+            if (is_array($results)) {
7028
+                for($j = 0 ; $j < count($results) ; $j++) {
7029
+                    echo "<tr>";
7030
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
+                    echo"</tr>";
7032
+                }
7033
+            } else {
7034
+                echo "<tr>";
7035
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
+                echo"</tr>";
7037
+            }
7038
+            echo "</table>";
7039
+            echo "</td></tr>";
7040
+        } else {
7041
+            $new_view = substr_replace($view,'1',3,1);
7042
+            echo "
7043 7043
                 <tr>
7044 7044
                     <td valign='top'>
7045 7045
                     +<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>
7046 7046
                     </td>
7047 7047
                 </tr>
7048 7048
             ";
7049
-    	}
7049
+        }
7050 7050
     }
7051 7051
 
7052 7052
     /**
@@ -7059,61 +7059,61 @@  discard block
 block discarded – undo
7059 7059
      */
7060 7060
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
7061 7061
     {
7062
-    	// protect data
7062
+        // protect data
7063 7063
         $user_id = intval($user_id);
7064 7064
         $courseId = api_get_course_int_id($course_code);
7065
-    	$session_id = intval($session_id);
7065
+        $session_id = intval($session_id);
7066 7066
 
7067
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
-    	if(substr($view,4,1) == '1') {
7069
-    		$new_view = substr_replace($view,'0',4,1);
7070
-    		echo "
7067
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
+        if(substr($view,4,1) == '1') {
7069
+            $new_view = substr_replace($view,'0',4,1);
7070
+            echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
7073 7073
                     <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>]
7074 7074
                     </td>
7075 7075
                 </tr>
7076 7076
             ";
7077
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7077
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7078 7078
 
7079
-    		$sql = "SELECT down_doc_path
7079
+            $sql = "SELECT down_doc_path
7080 7080
                     FROM $downloads_table
7081 7081
                     WHERE c_id = $courseId
7082 7082
                         AND down_user_id = $user_id
7083 7083
                         AND down_session_id = $session_id
7084 7084
                     GROUP BY down_doc_path";
7085 7085
 
7086
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
-    		$results = StatsUtils::getManyResults1Col($sql);
7088
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
-    		echo "<tr>
7086
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
+            $results = StatsUtils::getManyResults1Col($sql);
7088
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
+            echo "<tr>
7090 7090
                     <td class='secLine'>
7091 7091
                     ".get_lang('DocumentsTitleDocumentColumn')."
7092 7092
                     </td>
7093 7093
                 </tr>";
7094
-    		if (is_array($results)) {
7095
-    			for($j = 0 ; $j < count($results) ; $j++) {
7096
-    				echo "<tr>";
7097
-    				echo "<td class='content'>".$results[$j]."</td>";
7098
-    				echo"</tr>";
7099
-    			}
7100
-    		} else {
7101
-    			echo "<tr>";
7102
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
-    			echo"</tr>";
7104
-    		}
7105
-    		echo "</table>";
7106
-    		echo "</td></tr>";
7107
-    	} else {
7108
-    		$new_view = substr_replace($view,'1',4,1);
7109
-    		echo "
7094
+            if (is_array($results)) {
7095
+                for($j = 0 ; $j < count($results) ; $j++) {
7096
+                    echo "<tr>";
7097
+                    echo "<td class='content'>".$results[$j]."</td>";
7098
+                    echo"</tr>";
7099
+                }
7100
+            } else {
7101
+                echo "<tr>";
7102
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
+                echo"</tr>";
7104
+            }
7105
+            echo "</table>";
7106
+            echo "</td></tr>";
7107
+        } else {
7108
+            $new_view = substr_replace($view,'1',4,1);
7109
+            echo "
7110 7110
                 <tr>
7111 7111
                     <td valign='top'>
7112 7112
                     +<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>
7113 7113
                     </td>
7114 7114
                 </tr>
7115 7115
             ";
7116
-    	}
7116
+        }
7117 7117
     }
7118 7118
 
7119 7119
     /**
@@ -7170,43 +7170,43 @@  discard block
 block discarded – undo
7170 7170
      */
7171 7171
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7172 7172
     {
7173
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7174
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
-
7176
-    	// protected data
7177
-    	$user_id    = intval($user_id);
7178
-    	$session_id = intval($session_id);
7179
-    	$course_id  = intval($course_id);
7180
-
7181
-    	$tempView = $view;
7182
-    	if (substr($view,0,1) == '1') {
7183
-    		$new_view = substr_replace($view,'0',0,1);
7184
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7173
+        $MonthsLong = $GLOBALS['MonthsLong'];
7174
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
+
7176
+        // protected data
7177
+        $user_id    = intval($user_id);
7178
+        $session_id = intval($session_id);
7179
+        $course_id  = intval($course_id);
7180
+
7181
+        $tempView = $view;
7182
+        if (substr($view,0,1) == '1') {
7183
+            $new_view = substr_replace($view,'0',0,1);
7184
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7186 7186
                     FROM $track_access_table
7187 7187
                     WHERE access_user_id = $user_id
7188 7188
                     AND c_id = $course_id
7189 7189
                     AND access_session_id = $session_id
7190 7190
                     GROUP BY YEAR(access_date),MONTH(access_date)
7191 7191
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7192
-    		//$results = getManyResults2Col($sql);
7193
-    		$results = getManyResults3Col($sql);
7194
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
-    		$line='';
7196
-    		$total = 0;
7197
-    		if (is_array($results)) {
7198
-    			for($j = 0 ; $j < count($results) ; $j++) {
7199
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
-    				$total = $total + $results[$j][1];
7201
-    			}
7202
-    			$line .= get_lang('Total').";".$total."\n";
7203
-    		} else {
7204
-    			$line= get_lang('NoResult')."</center></td>";
7205
-    		}
7206
-    	} else {
7207
-    		$new_view = substr_replace($view,'1',0,1);
7208
-    	}
7209
-    	return array($title_line, $line);
7192
+            //$results = getManyResults2Col($sql);
7193
+            $results = getManyResults3Col($sql);
7194
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
+            $line='';
7196
+            $total = 0;
7197
+            if (is_array($results)) {
7198
+                for($j = 0 ; $j < count($results) ; $j++) {
7199
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
+                    $total = $total + $results[$j][1];
7201
+                }
7202
+                $line .= get_lang('Total').";".$total."\n";
7203
+            } else {
7204
+                $line= get_lang('NoResult')."</center></td>";
7205
+            }
7206
+        } else {
7207
+            $new_view = substr_replace($view,'1',0,1);
7208
+        }
7209
+        return array($title_line, $line);
7210 7210
     }
7211 7211
 
7212 7212
     /**
@@ -7219,67 +7219,67 @@  discard block
 block discarded – undo
7219 7219
      */
7220 7220
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7221 7221
     {
7222
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7222
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7223 7223
         $courseId = api_get_course_int_id($courseCode);
7224 7224
         $userId = intval($userId);
7225
-    	if (substr($view,1,1) == '1') {
7226
-    		$new_view = substr_replace($view,'0',1,1);
7227
-    		$title[1] = get_lang('ExercicesDetails');
7228
-    		$line = '';
7229
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7225
+        if (substr($view,1,1) == '1') {
7226
+            $new_view = substr_replace($view,'0',1,1);
7227
+            $title[1] = get_lang('ExercicesDetails');
7228
+            $line = '';
7229
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7230 7230
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7231 7231
                     WHERE te.c_id = $courseId
7232 7232
                         AND te.exe_user_id = $userId
7233 7233
                         AND te.exe_exo_id = ce.id
7234 7234
                     ORDER BY ce.title ASC, te.exe_date ASC";
7235 7235
 
7236
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7236
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7237 7237
                         FROM $TABLETRACK_HOTPOTATOES AS te
7238 7238
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7239 7239
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7240 7240
 
7241
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7241
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7242 7242
 
7243
-    		$NoTestRes = 0;
7244
-    		$NoHPTestRes = 0;
7243
+            $NoTestRes = 0;
7244
+            $NoHPTestRes = 0;
7245 7245
 
7246
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7247
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7246
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7247
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7248 7248
 
7249
-    		if (is_array($results)) {
7250
-    			for($i = 0; $i < sizeof($results); $i++)
7251
-    			{
7252
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
-    			}
7255
-    		} else {
7249
+            if (is_array($results)) {
7250
+                for($i = 0; $i < sizeof($results); $i++)
7251
+                {
7252
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
+                }
7255
+            } else {
7256 7256
                 // istvan begin
7257
-    			$NoTestRes = 1;
7258
-    		}
7259
-
7260
-    		// The Result of Tests
7261
-    		if (is_array($hpresults)) {
7262
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7263
-    				$title = GetQuizName($hpresults[$i][0],'');
7264
-
7265
-    				if ($title == '')
7266
-    				$title = basename($hpresults[$i][0]);
7267
-
7268
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
-
7270
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
-    			}
7272
-    		} else {
7273
-    			$NoHPTestRes = 1;
7274
-    		}
7275
-
7276
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
-    			$line=get_lang('NoResult');
7278
-    		}
7279
-    	} else {
7280
-    		$new_view = substr_replace($view,'1',1,1);
7281
-    	}
7282
-    	return array($title_line, $line);
7257
+                $NoTestRes = 1;
7258
+            }
7259
+
7260
+            // The Result of Tests
7261
+            if (is_array($hpresults)) {
7262
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7263
+                    $title = GetQuizName($hpresults[$i][0],'');
7264
+
7265
+                    if ($title == '')
7266
+                    $title = basename($hpresults[$i][0]);
7267
+
7268
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
+
7270
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
+                }
7272
+            } else {
7273
+                $NoHPTestRes = 1;
7274
+            }
7275
+
7276
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
+                $line=get_lang('NoResult');
7278
+            }
7279
+        } else {
7280
+            $new_view = substr_replace($view,'1',1,1);
7281
+        }
7282
+        return array($title_line, $line);
7283 7283
     }
7284 7284
 
7285 7285
     /**
@@ -7288,37 +7288,37 @@  discard block
 block discarded – undo
7288 7288
      */
7289 7289
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7290 7290
     {
7291
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7291
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7292 7292
         $_course = api_get_course_info();
7293 7293
         $user_id = intval($user_id);
7294 7294
         $course_id = intval($course_id);
7295 7295
 
7296
-    	if (substr($view,2,1) == '1') {
7297
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7296
+        if (substr($view,2,1) == '1') {
7297
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7298 7298
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7299 7299
                     WHERE
7300 7300
                         u.upload_work_id = w.id AND
7301 7301
                         u.upload_user_id = '$user_id' AND
7302 7302
                         u.c_id = '$course_id'
7303 7303
                     ORDER BY u.upload_date DESC";
7304
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7305
-
7306
-    		$title[1]=get_lang('WorksDetails');
7307
-    		$line='';
7308
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
-
7310
-    		if (is_array($results)) {
7311
-    			for($j = 0 ; $j < count($results) ; $j++) {
7312
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
-    			}
7316
-
7317
-    		} else {
7318
-    			$line= get_lang('NoResult');
7319
-    		}
7320
-    	}
7321
-    	return array($title_line, $line);
7304
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7305
+
7306
+            $title[1]=get_lang('WorksDetails');
7307
+            $line='';
7308
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
+
7310
+            if (is_array($results)) {
7311
+                for($j = 0 ; $j < count($results) ; $j++) {
7312
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
+                }
7316
+
7317
+            } else {
7318
+                $line= get_lang('NoResult');
7319
+            }
7320
+        }
7321
+        return array($title_line, $line);
7322 7322
     }
7323 7323
 
7324 7324
     /**
@@ -7327,32 +7327,32 @@  discard block
 block discarded – undo
7327 7327
      */
7328 7328
     public function display_links_tracking_info($view, $userId, $courseCode)
7329 7329
     {
7330
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7330
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7331 7331
         $courseId = api_get_course_int_id($courseCode);
7332 7332
         $userId = intval($userId);
7333 7333
         $line = null;
7334
-    	if (substr($view,3,1) == '1') {
7335
-    		$new_view = substr_replace($view,'0',3,1);
7336
-    		$title[1]=get_lang('LinksDetails');
7337
-    		$sql = "SELECT cl.title, cl.url
7334
+        if (substr($view,3,1) == '1') {
7335
+            $new_view = substr_replace($view,'0',3,1);
7336
+            $title[1]=get_lang('LinksDetails');
7337
+            $sql = "SELECT cl.title, cl.url
7338 7338
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7339 7339
                         WHERE sl.links_link_id = cl.id
7340 7340
                             AND sl.c_id = $courseId
7341 7341
                             AND sl.links_user_id = $userId
7342 7342
                         GROUP BY cl.title, cl.url";
7343
-    		$results = StatsUtils::getManyResults2Col($sql);
7344
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
-    		if (is_array($results)) {
7346
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7347
-    				$line .= $results[$j][0]."\n";
7348
-    			}
7349
-    		} else {
7350
-    			$line=get_lang('NoResult');
7351
-    		}
7352
-    	} else {
7353
-    		$new_view = substr_replace($view,'1',3,1);
7354
-    	}
7355
-    	return array($title_line, $line);
7343
+            $results = StatsUtils::getManyResults2Col($sql);
7344
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
+            if (is_array($results)) {
7346
+                for ($j = 0 ; $j < count($results) ; $j++) {
7347
+                    $line .= $results[$j][0]."\n";
7348
+                }
7349
+            } else {
7350
+                $line=get_lang('NoResult');
7351
+            }
7352
+        } else {
7353
+            $new_view = substr_replace($view,'1',3,1);
7354
+        }
7355
+        return array($title_line, $line);
7356 7356
     }
7357 7357
 
7358 7358
     /**
@@ -7365,38 +7365,38 @@  discard block
 block discarded – undo
7365 7365
      */
7366 7366
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7367 7367
     {
7368
-    	// protect data
7369
-    	$user_id     = intval($user_id);
7368
+        // protect data
7369
+        $user_id     = intval($user_id);
7370 7370
         $courseId = api_get_course_int_id($courseCode);
7371
-    	$session_id = intval($session_id);
7371
+        $session_id = intval($session_id);
7372 7372
 
7373
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7373
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7374 7374
 
7375
-    	if (substr($view,4,1) == '1') {
7376
-    		$new_view = substr_replace($view,'0',4,1);
7377
-    		$title[1]= get_lang('DocumentsDetails');
7375
+        if (substr($view,4,1) == '1') {
7376
+            $new_view = substr_replace($view,'0',4,1);
7377
+            $title[1]= get_lang('DocumentsDetails');
7378 7378
 
7379
-    		$sql = "SELECT down_doc_path
7379
+            $sql = "SELECT down_doc_path
7380 7380
                         FROM $downloads_table
7381 7381
                         WHERE c_id = $courseId
7382 7382
                             AND down_user_id = $user_id
7383 7383
                             AND down_session_id = $session_id
7384 7384
                         GROUP BY down_doc_path";
7385 7385
 
7386
-    		$results = StatsUtils::getManyResults1Col($sql);
7387
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7386
+            $results = StatsUtils::getManyResults1Col($sql);
7387
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7388 7388
             $line = null;
7389
-    		if (is_array($results)) {
7390
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7391
-    				$line .= $results[$j]."\n";
7392
-    			}
7393
-    		} else {
7394
-    			$line = get_lang('NoResult');
7395
-    		}
7396
-    	} else {
7397
-    		$new_view = substr_replace($view,'1',4,1);
7398
-    	}
7399
-    	return array($title_line, $line);
7389
+            if (is_array($results)) {
7390
+                for ($j = 0 ; $j < count($results) ; $j++) {
7391
+                    $line .= $results[$j]."\n";
7392
+                }
7393
+            } else {
7394
+                $line = get_lang('NoResult');
7395
+            }
7396
+        } else {
7397
+            $new_view = substr_replace($view,'1',4,1);
7398
+        }
7399
+        return array($title_line, $line);
7400 7400
     }
7401 7401
 
7402 7402
     /**
Please login to merge, or discard this patch.
Spacing   +432 added lines, -432 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.png').'" 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.png').'" 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
     				}
@@ -1667,8 +1667,8 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
1670
-        $roundedStart = substr($start, 0, -2) . '00';
1671
-        $roundedStop = substr($stop, 0, -2) . '00';
1670
+        $roundedStart = substr($start, 0, -2).'00';
1671
+        $roundedStop = substr($stop, 0, -2).'00';
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
     	$session_id  = intval($session_id);
1679 1679
     	$count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681
-        $sql =  "SELECT count(*) as count_connections
1681
+        $sql = "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
1683 1683
                 WHERE
1684 1684
                     c_id = $courseId AND
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
                 $count = apcu_fetch($apc_var);
1701 1701
             } else {
1702 1702
                 $rs = Database::query($sql);
1703
-                if (Database::num_rows($rs)>0) {
1703
+                if (Database::num_rows($rs) > 0) {
1704 1704
                     $row = Database::fetch_object($rs);
1705 1705
                     $count = $row->count_connections;
1706 1706
                 }
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
             }
1710 1710
         } else {
1711 1711
             $rs = Database::query($sql);
1712
-            if (Database::num_rows($rs)>0) {
1712
+            if (Database::num_rows($rs) > 0) {
1713 1713
                 $row = Database::fetch_object($rs);
1714 1714
                 $count = $row->count_connections;
1715 1715
             }
@@ -1731,14 +1731,14 @@  discard block
 block discarded – undo
1731 1731
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733 1733
     	$sql = 'SELECT DISTINCT c_id
1734
-                FROM ' . $tbl_course_rel_user . '
1734
+                FROM ' . $tbl_course_rel_user.'
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736 1736
     	$rs = Database::query($sql);
1737 1737
     	$nb_courses = Database::num_rows($rs);
1738 1738
 
1739 1739
     	if ($include_sessions) {
1740 1740
     		$sql = 'SELECT DISTINCT c_id
1741
-                    FROM ' . $tbl_session_course_rel_user . '
1741
+                    FROM ' . $tbl_session_course_rel_user.'
1742 1742
                     WHERE user_id = ' . $user_id;
1743 1743
     		$rs = Database::query($sql);
1744 1744
     		$nb_courses += Database::num_rows($rs);
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     		$condition_quiz = "";
1786 1786
     		if (!empty($exercise_id)) {
1787 1787
     			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1788
+    			$condition_quiz = " AND id = $exercise_id ";
1789 1789
     		}
1790 1790
 
1791 1791
     		// Compose a filter based on optional session id given
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
                         }
1839 1839
                     }
1840 1840
                     if (!empty($exercise_list)) {
1841
-                        $exercise_id = implode("','",$exercise_list);
1841
+                        $exercise_id = implode("','", $exercise_list);
1842 1842
                     }
1843 1843
     			}
1844 1844
 
@@ -1863,10 +1863,10 @@  discard block
 block discarded – undo
1863 1863
     			$quiz_avg_score = null;
1864 1864
 
1865 1865
     			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1866
+    				$quiz_avg_score = round($row['avg_score'], 2);
1867 1867
     			}
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1869
+    			if (!empty($row['num_attempts'])) {
1870 1870
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871 1871
     			}
1872 1872
     			if (is_array($student_id)) {
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
             $row = Database::fetch_row($rs);
1997 1997
             $count = $row[0];
1998 1998
         }
1999
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1999
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
2000 2000
         return $count;
2001 2001
     }
2002 2002
 
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
                 );
2022 2022
 
2023 2023
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
2024
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
2024
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
2025 2025
                 }
2026 2026
             }
2027 2027
             $result = $result / count($exercise_list);
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
         $query = sprintf($sql, intval($courseId), $sessionId);
2059 2059
         $rs = Database::query($query);
2060 2060
         $teachers = array();
2061
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2061
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2062 2062
             $teachers[] = $teacher;
2063 2063
         }
2064 2064
         $data = array();
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
             $data[] = array(
2183 2183
                 'course' => $course['title'],
2184 2184
                 'session' => $teacher['name'],
2185
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2185
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2186 2186
                 'documents' => $totalDocuments,
2187 2187
                 'links' => $totalLinks,
2188 2188
                 'forums' => $totalForums,
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
             for ($i = 0; $i < count($lpIdList); $i++) {
2246 2246
                 $placeHolders[] = '?';
2247 2247
             }
2248
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2248
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2249 2249
         }
2250 2250
 
2251 2251
         if ($onlySeriousGame) {
@@ -2265,14 +2265,14 @@  discard block
 block discarded – undo
2265 2265
 
2266 2266
         $conditions = [
2267 2267
             " c_id = {$courseInfo['real_id']} ",
2268
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2268
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2269 2269
         ];
2270 2270
 
2271 2271
         $groupBy = 'GROUP BY lp_id';
2272 2272
 
2273 2273
         if (is_array($studentId)) {
2274 2274
             $studentId = array_map('intval', $studentId);
2275
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2275
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2276 2276
 
2277 2277
 
2278 2278
         } else {
@@ -2407,7 +2407,7 @@  discard block
 block discarded – undo
2407 2407
             // Compose a filter based on optional learning paths list given
2408 2408
             $condition_lp = "";
2409 2409
             if (count($lp_ids) > 0) {
2410
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2410
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2411 2411
             }
2412 2412
 
2413 2413
             // Compose a filter based on optional session id
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
             // prepare filter on users
2448 2448
             if (is_array($student_id)) {
2449 2449
                 array_walk($student_id, 'intval');
2450
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2450
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2451 2451
             } else {
2452
-                $condition_user1 =" AND user_id = $student_id ";
2452
+                $condition_user1 = " AND user_id = $student_id ";
2453 2453
             }
2454 2454
 
2455 2455
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
                                     ORDER BY lp_item_id";
2493 2493
                             $res_lp_item = Database::query($sql);
2494 2494
 
2495
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2495
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2496 2496
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2497 2497
 
2498 2498
                                 // Getting the most recent attempt
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
                                         ORDER BY view_count DESC
2516 2516
                                         LIMIT 1";
2517 2517
                                 $res_lp_item_result = Database::query($sql);
2518
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2519
-                                    $list[]= $row_max_score;
2518
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2519
+                                    $list[] = $row_max_score;
2520 2520
                                 }
2521 2521
                             }
2522 2522
                         } else {
@@ -2540,8 +2540,8 @@  discard block
 block discarded – undo
2540 2540
                             if ($debug) echo $sql.'<br />';
2541 2541
                             $res_max_score = Database::query($sql);
2542 2542
 
2543
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2544
-                                $list[]= $row_max_score;
2543
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2544
+                                $list[] = $row_max_score;
2545 2545
                             }
2546 2546
                         }
2547 2547
 
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2557 2557
                             $score = $row_max_score['score'];
2558 2558
 
2559
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2559
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2560 2560
 
2561 2561
                             if ($row_max_score['item_type'] == 'sco') {
2562 2562
                                 /* Check if it is sco (easier to get max_score)
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
                                 }
2575 2575
                                 // Avoid division by zero errors
2576 2576
                                 if (!empty($max_score)) {
2577
-                                    $lp_partial_total += $score/$max_score;
2577
+                                    $lp_partial_total += $score / $max_score;
2578 2578
                                 }
2579 2579
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2580 2580
                             } else {
@@ -2598,10 +2598,10 @@  discard block
 block discarded – undo
2598 2598
                                         ORDER BY exe_date DESC
2599 2599
                                         LIMIT 1";
2600 2600
 
2601
-                                if ($debug) echo $sql .'<br />';
2601
+                                if ($debug) echo $sql.'<br />';
2602 2602
                                 $result_last_attempt = Database::query($sql);
2603 2603
                                 $num = Database :: num_rows($result_last_attempt);
2604
-                                if ($num > 0 ) {
2604
+                                if ($num > 0) {
2605 2605
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2606 2606
                                     if ($debug) echo $id_last_attempt.'<br />';
2607 2607
 
@@ -2630,13 +2630,13 @@  discard block
 block discarded – undo
2630 2630
                                         $max_score = $row_max_score_bis['maxscore'];
2631 2631
                                     }
2632 2632
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2633
-                                        $lp_partial_total += $score/$max_score;
2633
+                                        $lp_partial_total += $score / $max_score;
2634 2634
                                     }
2635 2635
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2636 2636
                                 }
2637 2637
                             }
2638 2638
 
2639
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2639
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2640 2640
                                 // Normal way
2641 2641
                                 if ($use_max_score[$lp_id]) {
2642 2642
                                     $count_items++;
@@ -2671,8 +2671,8 @@  discard block
 block discarded – undo
2671 2671
                     if ($debug) echo $sql;
2672 2672
                     $result_have_quiz = Database::query($sql);
2673 2673
 
2674
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2675
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2674
+                    if (Database::num_rows($result_have_quiz) > 0) {
2675
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2676 2676
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2677 2677
                             $lp_with_quiz++;
2678 2678
                         }
@@ -2684,7 +2684,7 @@  discard block
 block discarded – undo
2684 2684
 
2685 2685
                 if ($lp_with_quiz != 0) {
2686 2686
                     if (!$return_array) {
2687
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2687
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2688 2688
                         if ($debug) var_dump($score_of_scorm_calculate);
2689 2689
                         if (empty($lp_ids)) {
2690 2690
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2758,9 +2758,9 @@  discard block
 block discarded – undo
2758 2758
 
2759 2759
         if (is_array($student_id)) {
2760 2760
             array_walk($student_id, 'intval');
2761
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2761
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2762 2762
         } else {
2763
-            $conditions[] =" lp_view.user_id = $student_id ";
2763
+            $conditions[] = " lp_view.user_id = $student_id ";
2764 2764
         }
2765 2765
 
2766 2766
         $conditionsToString = implode('AND ', $conditions);
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
             // Compose a filter based on optional learning paths list given
2815 2815
             $condition_lp = "";
2816 2816
             if (count($lp_ids) > 0) {
2817
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2817
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2818 2818
             }
2819 2819
 
2820 2820
             // Compose a filter based on optional session id
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 
2877 2877
         if (!empty($course)) {
2878 2878
 
2879
-            $course_id	 = $course['real_id'];
2879
+            $course_id = $course['real_id'];
2880 2880
 
2881 2881
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2882 2882
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2890,8 +2890,8 @@  discard block
 block discarded – undo
2890 2890
             // calculates last connection time
2891 2891
             if ($count_row_lp > 0) {
2892 2892
                 $sql = 'SELECT MAX(start_time)
2893
-                        FROM ' . $t_lpiv . ' AS item_view
2894
-                        INNER JOIN ' . $t_lpv . ' AS view
2893
+                        FROM ' . $t_lpiv.' AS item_view
2894
+                        INNER JOIN ' . $t_lpv.' AS view
2895 2895
                             ON item_view.lp_view_id = view.id
2896 2896
                         WHERE
2897 2897
                             item_view.c_id 		= '.$course_id.' AND
@@ -2927,15 +2927,15 @@  discard block
 block discarded – undo
2927 2927
 
2928 2928
         // At first, courses where $coach_id is coach of the course //
2929 2929
         $sql = 'SELECT session_id, c_id
2930
-                FROM ' . $tbl_session_course_user . '
2930
+                FROM ' . $tbl_session_course_user.'
2931 2931
                 WHERE user_id=' . $coach_id.' AND status=2';
2932 2932
 
2933 2933
         if (api_is_multiple_url_enabled()) {
2934
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2934
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2935 2935
             $access_url_id = api_get_current_access_url_id();
2936 2936
             if ($access_url_id != -1) {
2937 2937
                 $sql = 'SELECT scu.session_id, scu.c_id
2938
-                    FROM ' . $tbl_session_course_user . ' scu
2938
+                    FROM ' . $tbl_session_course_user.' scu
2939 2939
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2940 2940
                     ON (scu.session_id=sru.session_id)
2941 2941
                     WHERE
@@ -2969,28 +2969,28 @@  discard block
 block discarded – undo
2969 2969
 
2970 2970
         // Then, courses where $coach_id is coach of the session    //
2971 2971
         $sql = 'SELECT session_course_user.user_id
2972
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2972
+                FROM ' . $tbl_session_course_user.' as session_course_user
2973 2973
                 INNER JOIN     '.$tbl_session_user.' sru
2974 2974
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2975
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2975
+                INNER JOIN ' . $tbl_session_course.' as session_course
2976 2976
                 ON session_course.c_id = session_course_user.c_id
2977 2977
                 AND session_course_user.session_id = session_course.session_id
2978
-                INNER JOIN ' . $tbl_session . ' as session
2978
+                INNER JOIN ' . $tbl_session.' as session
2979 2979
                 ON session.id = session_course.session_id
2980 2980
                 AND session.id_coach = ' . $coach_id;
2981 2981
         if (api_is_multiple_url_enabled()) {
2982
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2982
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2983 2983
             $access_url_id = api_get_current_access_url_id();
2984
-            if ($access_url_id != -1){
2984
+            if ($access_url_id != -1) {
2985 2985
                 $sql = 'SELECT session_course_user.user_id
2986
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2986
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2987 2987
                         INNER JOIN     '.$tbl_session_user.' sru
2988 2988
                             ON session_course_user.user_id = sru.user_id AND
2989 2989
                                session_course_user.session_id = sru.session_id
2990
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2990
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2991 2991
                             ON session_course.c_id = session_course_user.c_id AND
2992 2992
                             session_course_user.session_id = session_course.session_id
2993
-                        INNER JOIN ' . $tbl_session . ' as session
2993
+                        INNER JOIN ' . $tbl_session.' as session
2994 2994
                             ON session.id = session_course.session_id AND
2995 2995
                             session.id_coach = ' . $coach_id.'
2996 2996
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -3020,8 +3020,8 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
         $students = [];
3022 3022
         // At first, courses where $coach_id is coach of the course //
3023
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
3024
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
3023
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
3024
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
3025 3025
         $result = Database::query($sql);
3026 3026
 
3027 3027
         while ($a_courses = Database::fetch_array($result)) {
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
                     FROM $tbl_session_course_user AS srcru
3032 3032
                     WHERE
3033 3033
                         c_id = '$courseId' AND
3034
-                        session_id = '" . $id_session . "'";
3034
+                        session_id = '".$id_session."'";
3035 3035
             $rs = Database::query($sql);
3036 3036
             while ($row = Database::fetch_array($rs)) {
3037 3037
                 $students[$row['user_id']] = $row['user_id'];
@@ -3039,15 +3039,15 @@  discard block
 block discarded – undo
3039 3039
         }
3040 3040
 
3041 3041
         // Then, courses where $coach_id is coach of the session
3042
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3043
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3042
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3043
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3044 3044
         $result = Database::query($sql);
3045 3045
 
3046 3046
         //He is the session_coach so we select all the users in the session
3047 3047
         if (Database::num_rows($result) > 0) {
3048 3048
             $sql = 'SELECT DISTINCT srcru.user_id
3049
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3050
-                    WHERE session_id="' . $id_session . '"';
3049
+                    FROM ' . $tbl_session_course_user.' AS srcru
3050
+                    WHERE session_id="' . $id_session.'"';
3051 3051
             $result = Database::query($sql);
3052 3052
             while ($row = Database::fetch_array($result)) {
3053 3053
                 $students[$row['user_id']] = $row['user_id'];
@@ -3074,8 +3074,8 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
         // At first, courses where $coach_id is coach of the course //
3076 3076
 
3077
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3078
-                WHERE user_id=' . $coach_id .' AND status=2';
3077
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3078
+                WHERE user_id=' . $coach_id.' AND status=2';
3079 3079
         $result = Database::query($sql);
3080 3080
         if (Database::num_rows($result) > 0) {
3081 3081
             return true;
@@ -3083,12 +3083,12 @@  discard block
 block discarded – undo
3083 3083
 
3084 3084
         // Then, courses where $coach_id is coach of the session
3085 3085
         $sql = 'SELECT session_course_user.user_id
3086
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3087
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3086
+                FROM ' . $tbl_session_course_user.' as session_course_user
3087
+                INNER JOIN ' . $tbl_session_course.' as session_course
3088 3088
                     ON session_course.c_id = session_course_user.c_id
3089
-                INNER JOIN ' . $tbl_session . ' as session
3089
+                INNER JOIN ' . $tbl_session.' as session
3090 3090
                     ON session.id = session_course.session_id
3091
-                    AND session.id_coach = ' . $coach_id . '
3091
+                    AND session.id_coach = ' . $coach_id.'
3092 3092
                 WHERE user_id = ' . $student_id;
3093 3093
         $result = Database::query($sql);
3094 3094
         if (Database::num_rows($result) > 0) {
@@ -3120,16 +3120,16 @@  discard block
 block discarded – undo
3120 3120
         // At first, courses where $coach_id is coach of the course.
3121 3121
 
3122 3122
         $sql = 'SELECT DISTINCT c.code
3123
-                FROM ' . $tbl_session_course_user . ' sc
3123
+                FROM ' . $tbl_session_course_user.' sc
3124 3124
                 INNER JOIN '.$tbl_course.' c
3125 3125
                 ON (c.id = sc.c_id)
3126 3126
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3127 3127
 
3128 3128
         if (api_is_multiple_url_enabled()) {
3129 3129
             $access_url_id = api_get_current_access_url_id();
3130
-            if ($access_url_id != -1){
3130
+            if ($access_url_id != -1) {
3131 3131
                 $sql = 'SELECT DISTINCT c.code
3132
-                        FROM ' . $tbl_session_course_user . ' scu
3132
+                        FROM ' . $tbl_session_course_user.' scu
3133 3133
                         INNER JOIN '.$tbl_course.' c
3134 3134
                         ON (c.code = scu.c_id)
3135 3135
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3142,7 +3142,7 @@  discard block
 block discarded – undo
3142 3142
         }
3143 3143
 
3144 3144
         if (!empty($id_session)) {
3145
-            $sql .= ' AND session_id=' . $id_session;
3145
+            $sql .= ' AND session_id='.$id_session;
3146 3146
         }
3147 3147
 
3148 3148
         $courseList = array();
@@ -3154,25 +3154,25 @@  discard block
 block discarded – undo
3154 3154
         // Then, courses where $coach_id is coach of the session
3155 3155
 
3156 3156
         $sql = 'SELECT DISTINCT course.code
3157
-                FROM ' . $tbl_session_course . ' as session_course
3158
-                INNER JOIN ' . $tbl_session . ' as session
3157
+                FROM ' . $tbl_session_course.' as session_course
3158
+                INNER JOIN ' . $tbl_session.' as session
3159 3159
                     ON session.id = session_course.session_id
3160
-                    AND session.id_coach = ' . $coach_id . '
3161
-                INNER JOIN ' . $tbl_course . ' as course
3160
+                    AND session.id_coach = ' . $coach_id.'
3161
+                INNER JOIN ' . $tbl_course.' as course
3162 3162
                     ON course.id = session_course.c_id';
3163 3163
 
3164 3164
         if (api_is_multiple_url_enabled()) {
3165 3165
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3166 3166
             $access_url_id = api_get_current_access_url_id();
3167
-            if ($access_url_id != -1){
3167
+            if ($access_url_id != -1) {
3168 3168
                 $sql = 'SELECT DISTINCT c.code
3169
-                    FROM ' . $tbl_session_course . ' as session_course
3169
+                    FROM ' . $tbl_session_course.' as session_course
3170 3170
                     INNER JOIN '.$tbl_course.' c
3171 3171
                     ON (c.id = session_course.c_id)
3172
-                    INNER JOIN ' . $tbl_session . ' as session
3172
+                    INNER JOIN ' . $tbl_session.' as session
3173 3173
                     ON session.id = session_course.session_id
3174
-                        AND session.id_coach = ' . $coach_id . '
3175
-                    INNER JOIN ' . $tbl_course . ' as course
3174
+                        AND session.id_coach = ' . $coach_id.'
3175
+                    INNER JOIN ' . $tbl_course.' as course
3176 3176
                         ON course.id = session_course.c_id
3177 3177
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3178 3178
                     ON (course_rel_url.c_id = c.id)';
@@ -3180,12 +3180,12 @@  discard block
 block discarded – undo
3180 3180
         }
3181 3181
 
3182 3182
         if (!empty ($id_session)) {
3183
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3183
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3184 3184
             if (api_is_multiple_url_enabled())
3185
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3186
-        }  else {
3185
+            $sql .= ' AND access_url_id = '.$access_url_id;
3186
+        } else {
3187 3187
             if (api_is_multiple_url_enabled())
3188
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3188
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3189 3189
         }
3190 3190
 
3191 3191
         $result = Database::query($sql);
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
             }
3242 3242
         }
3243 3243
 
3244
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3244
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3245 3245
         $access_url_id = api_get_current_access_url_id();
3246 3246
 
3247 3247
         $sql = "
@@ -3365,7 +3365,7 @@  discard block
 block discarded – undo
3365 3365
             // table definition
3366 3366
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3367 3367
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3368
-            $course_id	 = $a_course['real_id'];
3368
+            $course_id = $a_course['real_id'];
3369 3369
             if (is_array($student_id)) {
3370 3370
                 $studentList = array_map('intval', $student_id);
3371 3371
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
         $a_course = CourseManager::get_course_information($course_code);
3419 3419
         if (!empty($a_course)) {
3420 3420
             $course_id = $a_course['real_id'];
3421
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3421
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3422 3422
         }
3423 3423
 
3424 3424
         // table definition
@@ -3427,14 +3427,14 @@  discard block
 block discarded – undo
3427 3427
 
3428 3428
         if (is_array($student_id)) {
3429 3429
             $studentList = array_map('intval', $student_id);
3430
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3430
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3431 3431
         } else {
3432 3432
             $student_id = intval($student_id);
3433
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3433
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3434 3434
         }
3435 3435
         if (isset($session_id)) {
3436 3436
             $session_id = intval($session_id);
3437
-            $conditions[]= " pub.session_id = $session_id ";
3437
+            $conditions[] = " pub.session_id = $session_id ";
3438 3438
         }
3439 3439
         $conditionToString = implode('AND', $conditions);
3440 3440
 
@@ -3471,10 +3471,10 @@  discard block
 block discarded – undo
3471 3471
         $conditions = array();
3472 3472
         if (is_array($student_id)) {
3473 3473
             $studentList = array_map('intval', $student_id);
3474
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3474
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3475 3475
         } else {
3476 3476
             $student_id = intval($student_id);
3477
-            $conditions[]= " post.poster_id = '$student_id' ";
3477
+            $conditions[] = " post.poster_id = '$student_id' ";
3478 3478
         }
3479 3479
 
3480 3480
         $conditionsToString = implode('AND ', $conditions);
@@ -3500,13 +3500,13 @@  discard block
 block discarded – undo
3500 3500
         if (!empty($courseInfo)) {
3501 3501
             $forums = get_forums('', $courseCode, true, $session_id);
3502 3502
             $course_id = $courseInfo['real_id'];
3503
-            $conditions[]= " post.c_id  = $course_id ";
3503
+            $conditions[] = " post.c_id  = $course_id ";
3504 3504
         }
3505 3505
 
3506 3506
         if (!empty($forums)) {
3507 3507
             $idList = array_column($forums, 'forum_id');
3508 3508
             $idListToString = implode("', '", $idList);
3509
-            $conditions[]= " post.forum_id  IN ('$idListToString')";
3509
+            $conditions[] = " post.forum_id  IN ('$idListToString')";
3510 3510
         }
3511 3511
 
3512 3512
         $conditionsToString = implode('AND ', $conditions);
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
             $condition_session = '';
3542 3542
             if (isset($session_id)) {
3543 3543
                 $session_id = intval($session_id);
3544
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3544
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3545 3545
             }
3546 3546
 
3547 3547
             $course_id = $courseInfo['real_id'];
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
         $condition_session = '';
3598 3598
         if (isset($session_id)) {
3599 3599
             $session_id = intval($session_id);
3600
-            $condition_session = ' AND f.session_id = '. $session_id;
3600
+            $condition_session = ' AND f.session_id = '.$session_id;
3601 3601
         }
3602 3602
 
3603 3603
         $groupId = intval($groupId);
@@ -3658,7 +3658,7 @@  discard block
 block discarded – undo
3658 3658
         $condition_session = '';
3659 3659
         if (isset($session_id)) {
3660 3660
              $session_id = intval($session_id);
3661
-             $condition_session = ' AND f.session_id = '. $session_id;
3661
+             $condition_session = ' AND f.session_id = '.$session_id;
3662 3662
         }
3663 3663
 
3664 3664
         $groupId = intval($groupId);
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
     {
3738 3738
         $student_id = intval($student_id);
3739 3739
         $courseId = intval($courseId);
3740
-        $session_id    = intval($session_id);
3740
+        $session_id = intval($session_id);
3741 3741
         $date_time  = '';
3742 3742
 
3743 3743
         // table definition
@@ -3806,7 +3806,7 @@  discard block
 block discarded – undo
3806 3806
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3807 3807
 
3808 3808
         $sql = 'SELECT 1
3809
-                FROM ' . $table . '
3809
+                FROM ' . $table.'
3810 3810
                 WHERE down_user_id = '.$student_id.'
3811 3811
                 AND c_id  = "'.$courseId.'"
3812 3812
                 AND down_session_id = '.$session_id.' ';
@@ -3884,30 +3884,30 @@  discard block
 block discarded – undo
3884 3884
                 '.$inner.'
3885 3885
                 WHERE c.id = '.$courseId.'
3886 3886
                 GROUP BY stats_login.user_id
3887
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3887
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3888 3888
 
3889 3889
         if ($since == 'never') {
3890 3890
             if (empty($session_id)) {
3891 3891
                 $sql = 'SELECT course_user.user_id
3892
-                        FROM ' . $table_course_rel_user . ' course_user
3893
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3892
+                        FROM ' . $table_course_rel_user.' course_user
3893
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3894 3894
                         ON course_user.user_id = stats_login.user_id AND
3895
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3896
-                        INNER JOIN ' . $tableCourse . ' c
3895
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3896
+                        INNER JOIN ' . $tableCourse.' c
3897 3897
                         ON (c.id = course_user.c_id)
3898 3898
                         WHERE
3899
-                            course_user.c_id = ' . $courseId . ' AND
3899
+                            course_user.c_id = ' . $courseId.' AND
3900 3900
                             stats_login.login_course_date IS NULL
3901 3901
                         GROUP BY course_user.user_id';
3902 3902
             } else {
3903 3903
                 $sql = 'SELECT session_course_user.user_id
3904 3904
                         FROM '.$tbl_session_course_user.' session_course_user
3905
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3905
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3906 3906
                         ON session_course_user.user_id = stats_login.user_id
3907
-                        INNER JOIN ' . $tableCourse . ' c
3907
+                        INNER JOIN ' . $tableCourse.' c
3908 3908
                         ON (c.id = session_course_user.c_id)
3909 3909
                         WHERE
3910
-                            session_course_user.c_id = ' . $courseId . ' AND
3910
+                            session_course_user.c_id = ' . $courseId.' AND
3911 3911
                             stats_login.login_course_date IS NULL
3912 3912
                         GROUP BY session_course_user.user_id';
3913 3913
             }
@@ -3915,7 +3915,7 @@  discard block
 block discarded – undo
3915 3915
 
3916 3916
         $rs = Database::query($sql);
3917 3917
         $inactive_users = array();
3918
-        while($user = Database::fetch_array($rs)) {
3918
+        while ($user = Database::fetch_array($rs)) {
3919 3919
             $inactive_users[] = $user['user_id'];
3920 3920
         }
3921 3921
 
@@ -3937,10 +3937,10 @@  discard block
 block discarded – undo
3937 3937
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3938 3938
 
3939 3939
         $sql = 'SELECT '.$student_id.'
3940
-                FROM ' . $table . '
3940
+                FROM ' . $table.'
3941 3941
                 WHERE
3942
-                    access_user_id=' . $student_id . ' AND
3943
-                    c_id="' . $courseId . '" AND
3942
+                    access_user_id=' . $student_id.' AND
3943
+                    c_id="' . $courseId.'" AND
3944 3944
                     access_session_id = "'.$session_id.'" ';
3945 3945
 
3946 3946
         $rs = Database::query($sql);
@@ -3958,13 +3958,13 @@  discard block
 block discarded – undo
3958 3958
     {
3959 3959
         $hr_dept_id = intval($hr_dept_id);
3960 3960
         $a_students = array();
3961
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3961
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3962 3962
 
3963 3963
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3964 3964
                 WHERE hr_dept_id='.$hr_dept_id;
3965 3965
         $rs = Database::query($sql);
3966 3966
 
3967
-        while($user = Database :: fetch_array($rs)) {
3967
+        while ($user = Database :: fetch_array($rs)) {
3968 3968
             $a_students[$user['user_id']] = $user['user_id'];
3969 3969
         }
3970 3970
 
@@ -3989,7 +3989,7 @@  discard block
 block discarded – undo
3989 3989
         $condition_session     = '';
3990 3990
         if (isset($session_id)) {
3991 3991
             $session_id = intval($session_id);
3992
-            $condition_session = ' AND access_session_id = '. $session_id;
3992
+            $condition_session = ' AND access_session_id = '.$session_id;
3993 3993
         }
3994 3994
         $sql = "SELECT
3995 3995
                     access_tool,
@@ -4101,7 +4101,7 @@  discard block
 block discarded – undo
4101 4101
             if (!empty($date_from) && !empty($date_to)) {
4102 4102
                 $fieldStartDate = $fields['start_date'];
4103 4103
                 if (!isset($fields['end_date'])) {
4104
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4104
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4105 4105
                 } else {
4106 4106
                     $fieldEndDate = $fields['end_date'];
4107 4107
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4117,12 +4117,12 @@  discard block
 block discarded – undo
4117 4117
                 $where
4118 4118
                 GROUP BY %s";
4119 4119
             $sql = sprintf($sql,
4120
-                $fields['user'],    //user field
4121
-                $tableName,         //FROM
4122
-                $fields['course'],  //course condition
4123
-                $course['real_id'],    //course condition
4124
-                $fields['user'],    //user condition
4125
-                $userId,            //user condition
4120
+                $fields['user'], //user field
4121
+                $tableName, //FROM
4122
+                $fields['course'], //course condition
4123
+                $course['real_id'], //course condition
4124
+                $fields['user'], //user condition
4125
+                $userId, //user condition
4126 4126
                 $fields['user']     //GROUP BY
4127 4127
                 );
4128 4128
             $rs = Database::query($sql);
@@ -4130,7 +4130,7 @@  discard block
 block discarded – undo
4130 4130
             //iterate query
4131 4131
             if (Database::num_rows($rs) > 0) {
4132 4132
                 while ($row = Database::fetch_array($rs)) {
4133
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4133
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4134 4134
                 }
4135 4135
             }
4136 4136
         }
@@ -4153,11 +4153,11 @@  discard block
 block discarded – undo
4153 4153
         $courseId = api_get_course_int_id($course_code);
4154 4154
         $data = array();
4155 4155
 
4156
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4156
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4157 4157
         $condition_session = '';
4158 4158
         $session_id = intval($session_id);
4159 4159
         if (!empty($session_id)) {
4160
-            $condition_session = ' AND down_session_id = '. $session_id;
4160
+            $condition_session = ' AND down_session_id = '.$session_id;
4161 4161
         }
4162 4162
         $sql = "SELECT 
4163 4163
                     down_doc_path, 
@@ -4345,7 +4345,7 @@  discard block
 block discarded – undo
4345 4345
 
4346 4346
             $final_course_data = array();
4347 4347
 
4348
-            foreach($my_course_data as $course_id => $value) {
4348
+            foreach ($my_course_data as $course_id => $value) {
4349 4349
                 $final_course_data[$course_id] = $course_list[$course_id];
4350 4350
             }
4351 4351
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4368,7 +4368,7 @@  discard block
 block discarded – undo
4368 4368
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4369 4369
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4370 4370
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4371
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4371
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4372 4372
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4373 4373
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4374 4374
                         </tr>';
@@ -4457,7 +4457,7 @@  discard block
 block discarded – undo
4457 4457
             $all_exercise_start_time = array();
4458 4458
 
4459 4459
             foreach ($course_in_session as $my_session_id => $session_data) {
4460
-                $course_list  = $session_data['course_list'];
4460
+                $course_list = $session_data['course_list'];
4461 4461
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4462 4462
                 $exercise_graph_name_list = array();
4463 4463
                 //$user_results = array();
@@ -4502,20 +4502,20 @@  discard block
 block discarded – undo
4502 4502
 
4503 4503
                             $score = 0;
4504 4504
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4505
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4505
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4506 4506
                             }
4507 4507
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4508 4508
                             $all_exercise_start_time[] = $time;
4509 4509
                             $my_results[] = $score;
4510
-                            if (count($exercise_list)<=10) {
4510
+                            if (count($exercise_list) <= 10) {
4511 4511
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4512
-                                $exercise_graph_name_list[]= $title;
4512
+                                $exercise_graph_name_list[] = $title;
4513 4513
                                 $all_exercise_graph_name_list[] = $title;
4514 4514
                             } else {
4515 4515
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4516 4516
                                 $title = cut($exercise_data['title'], 30);
4517
-                                $exercise_graph_name_list[]= $title;
4518
-                                $all_exercise_graph_name_list[]= $title;
4517
+                                $exercise_graph_name_list[] = $title;
4518
+                                $all_exercise_graph_name_list[] = $title;
4519 4519
                             }
4520 4520
                         }
4521 4521
                     }
@@ -4548,7 +4548,7 @@  discard block
 block discarded – undo
4548 4548
             }
4549 4549
 
4550 4550
             $html .= Display::page_subheader(
4551
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4551
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4552 4552
             );
4553 4553
 
4554 4554
             $html .= '<div class="table-responsive">';
@@ -4602,7 +4602,7 @@  discard block
 block discarded – undo
4602 4602
                                 $courseInfo['real_id'],
4603 4603
                                 $my_session_id
4604 4604
                             );
4605
-                            if ($attempts > 1)  {
4605
+                            if ($attempts > 1) {
4606 4606
                                 $answered_exercises++;
4607 4607
                             }
4608 4608
                         }
@@ -4615,7 +4615,7 @@  discard block
 block discarded – undo
4615 4615
                     $all_average += $average;
4616 4616
                 }
4617 4617
 
4618
-                $all_average = $all_average /  count($course_list);
4618
+                $all_average = $all_average / count($course_list);
4619 4619
 
4620 4620
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4621 4621
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4641,16 +4641,16 @@  discard block
 block discarded – undo
4641 4641
             }
4642 4642
             $html .= '</tbody>';
4643 4643
             $html .= '</table></div><br />';
4644
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4644
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4645 4645
 
4646 4646
             // Checking selected session.
4647 4647
 
4648 4648
             if (isset($_GET['session_id'])) {
4649 4649
                 $session_id_from_get = intval($_GET['session_id']);
4650
-                $session_data 	= $course_in_session[$session_id_from_get];
4651
-                $course_list 	= $session_data['course_list'];
4650
+                $session_data = $course_in_session[$session_id_from_get];
4651
+                $course_list = $session_data['course_list'];
4652 4652
 
4653
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4653
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4654 4654
 
4655 4655
                 $html .= '<div class="table-responsive">';
4656 4656
                 $html .= '<table class="table table-hover table-striped">';
@@ -4659,15 +4659,15 @@  discard block
 block discarded – undo
4659 4659
                     <thead>
4660 4660
                     <tr>
4661 4661
                       <th width="300px">'.get_lang('Course').'</th>
4662
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4663
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4664
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4665
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4666
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4667
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4668
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4669
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4670
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4662
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4663
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4664
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4665
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4666
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4667
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4668
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4669
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4670
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4671 4671
                     </tr>
4672 4672
                     </thead>
4673 4673
                     <tbody>
@@ -4686,14 +4686,14 @@  discard block
 block discarded – undo
4686 4686
                         $count_exercises = count($exercises);
4687 4687
                     }
4688 4688
                     $answered_exercises = 0;
4689
-                    foreach($exercises as $exercise_item) {
4689
+                    foreach ($exercises as $exercise_item) {
4690 4690
                         $attempts = Event::count_exercise_attempts_by_user(
4691 4691
                             api_get_user_id(),
4692 4692
                             $exercise_item['id'],
4693 4693
                             $courseId,
4694 4694
                             $session_id_from_get
4695 4695
                         );
4696
-                        if ($attempts > 1)  {
4696
+                        if ($attempts > 1) {
4697 4697
                             $answered_exercises++;
4698 4698
                         }
4699 4699
                     }
@@ -4702,7 +4702,7 @@  discard block
 block discarded – undo
4702 4702
 
4703 4703
                     // Average
4704 4704
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4705
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4705
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4706 4706
 
4707 4707
                     $stats_array[$course_code] = array(
4708 4708
                         'exercises' => $count_exercises,
@@ -4779,7 +4779,7 @@  discard block
 block discarded – undo
4779 4779
 
4780 4780
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4781 4781
                         $details = '<a href="#">';
4782
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4782
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4783 4783
                     } else {
4784 4784
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4785 4785
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4879,7 +4879,7 @@  discard block
 block discarded – undo
4879 4879
                     );
4880 4880
 
4881 4881
                     $html .= '<tr class="row_even">';
4882
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4882
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4883 4883
 
4884 4884
                     if ($visible_return['value'] == true) {
4885 4885
                         $exercices['title'] = Display::url(
@@ -4908,7 +4908,7 @@  discard block
 block discarded – undo
4908 4908
                         );
4909 4909
 
4910 4910
                         $latest_attempt_url = '';
4911
-                        $best_score = $position = $percentage_score_result  = '-';
4911
+                        $best_score = $position = $percentage_score_result = '-';
4912 4912
                         $graph = $normal_graph = null;
4913 4913
 
4914 4914
                         // Getting best results
@@ -4940,11 +4940,11 @@  discard block
 block discarded – undo
4940 4940
                                 $weighting      = $exercise_stat['exe_weighting'];
4941 4941
                                 $exe_id         = $exercise_stat['exe_id'];
4942 4942
 
4943
-                                $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;
4943
+                                $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;
4944 4944
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4945 4945
                                 $my_score = 0;
4946 4946
                                 if (!empty($weighting) && intval($weighting) != 0) {
4947
-                                    $my_score = $score/$weighting;
4947
+                                    $my_score = $score / $weighting;
4948 4948
                                 }
4949 4949
                                 //@todo this function slows the page
4950 4950
                                 if (is_int($user_list)) {
@@ -4958,14 +4958,14 @@  discard block
 block discarded – undo
4958 4958
                         }
4959 4959
                         $html .= Display::div(
4960 4960
                             $normal_graph,
4961
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4961
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4962 4962
                         );
4963 4963
 
4964 4964
                         if (empty($graph)) {
4965 4965
                             $graph = '-';
4966 4966
                         } else {
4967 4967
                             $graph = Display::url(
4968
-                                '<img src="' . $graph . '" >',
4968
+                                '<img src="'.$graph.'" >',
4969 4969
                                 $normal_graph,
4970 4970
                                 array(
4971 4971
                                     'id' => $exercices['id'],
@@ -4999,7 +4999,7 @@  discard block
 block discarded – undo
4999 4999
 
5000 5000
             // LP table results
5001 5001
             $html .= '<div class="table-responsive">';
5002
-            $html .='<table class="table table-striped table-hover">';
5002
+            $html .= '<table class="table table-striped table-hover">';
5003 5003
             $html .= '<thead><tr>';
5004 5004
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
5005 5005
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -5035,7 +5035,7 @@  discard block
 block discarded – undo
5035 5035
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
5036 5036
 
5037 5037
                     $html .= '<tr class="row_even">';
5038
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5038
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5039 5039
 
5040 5040
                     if ($learnpath['lp_visibility'] == 0) {
5041 5041
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -5054,7 +5054,7 @@  discard block
 block discarded – undo
5054 5054
                     if (!empty($last_connection_in_lp)) {
5055 5055
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5056 5056
                     }
5057
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5057
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5058 5058
                     $html .= "</tr>";
5059 5059
                 }
5060 5060
             } else {
@@ -5064,7 +5064,7 @@  discard block
 block discarded – undo
5064 5064
                         </td>
5065 5065
                       </tr>';
5066 5066
             }
5067
-            $html .='</tbody></table></div>';
5067
+            $html .= '</tbody></table></div>';
5068 5068
 
5069 5069
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5070 5070
         }
@@ -5093,7 +5093,7 @@  discard block
 block discarded – undo
5093 5093
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5094 5094
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5095 5095
         $myData->setAxisUnit(0, '%');
5096
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5096
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5097 5097
         // Cache definition
5098 5098
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5099 5099
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5101,9 +5101,9 @@  discard block
 block discarded – undo
5101 5101
 
5102 5102
         if ($myCache->isInCache($chartHash)) {
5103 5103
             //if we already created the img
5104
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5104
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5105 5105
             $myCache->saveFromCache($chartHash, $imgPath);
5106
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5106
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5107 5107
         } else {
5108 5108
             /* Define width, height and angle */
5109 5109
             $mainWidth = 860;
@@ -5132,7 +5132,7 @@  discard block
 block discarded – undo
5132 5132
             /* Set the default font */
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
             /* Write the chart title */
@@ -5149,7 +5149,7 @@  discard block
 block discarded – undo
5149 5149
             /* Set the default font */
5150 5150
             $myPicture->setFontProperties(
5151 5151
                 array(
5152
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5152
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5153 5153
                     'FontSize' => 6
5154 5154
                 )
5155 5155
             );
@@ -5191,7 +5191,7 @@  discard block
 block discarded – undo
5191 5191
             /* Draw the line chart */
5192 5192
             $myPicture->setFontProperties(
5193 5193
                 array(
5194
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5194
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5195 5195
                     'FontSize' => 10
5196 5196
                 )
5197 5197
             );
@@ -5224,12 +5224,12 @@  discard block
 block discarded – undo
5224 5224
             );
5225 5225
 
5226 5226
             $myCache->writeToCache($chartHash, $myPicture);
5227
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5227
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5228 5228
             $myCache->saveFromCache($chartHash, $imgPath);
5229
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5229
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5230 5230
         }
5231 5231
 
5232
-        $html = '<img src="' . $imgPath . '">';
5232
+        $html = '<img src="'.$imgPath.'">';
5233 5233
 
5234 5234
         return $html;
5235 5235
     }
@@ -5250,12 +5250,12 @@  discard block
 block discarded – undo
5250 5250
 
5251 5251
         foreach ($attempts as $attempt) {
5252 5252
             if (api_get_user_id() == $attempt['exe_user_id']) {
5253
-                if ($attempt['exe_weighting'] != 0 ) {
5254
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5253
+                if ($attempt['exe_weighting'] != 0) {
5254
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5255 5255
                 }
5256 5256
             } else {
5257
-                if ($attempt['exe_weighting'] != 0 ) {
5258
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5257
+                if ($attempt['exe_weighting'] != 0) {
5258
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5259 5259
                 }
5260 5260
             }
5261 5261
         }
@@ -5264,27 +5264,27 @@  discard block
 block discarded – undo
5264 5264
         rsort($my_exercise_result_array);
5265 5265
         $my_exercise_result = 0;
5266 5266
         if (isset($my_exercise_result_array[0])) {
5267
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5267
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5268 5268
         }
5269 5269
 
5270 5270
         $max     = 100;
5271
-        $pieces  = 5 ;
5271
+        $pieces  = 5;
5272 5272
         $part    = round($max / $pieces);
5273 5273
         $x_axis = array();
5274 5274
         $final_array = array();
5275 5275
         $my_final_array = array();
5276 5276
 
5277
-        for ($i=1; $i <=$pieces; $i++) {
5277
+        for ($i = 1; $i <= $pieces; $i++) {
5278 5278
             $sum = 1;
5279 5279
             if ($i == 1) {
5280 5280
                 $sum = 0;
5281 5281
             }
5282
-            $min = ($i-1)*$part + $sum;
5283
-            $max = ($i)*$part;
5284
-            $x_axis[]= $min." - ".$max;
5282
+            $min = ($i - 1) * $part + $sum;
5283
+            $max = ($i) * $part;
5284
+            $x_axis[] = $min." - ".$max;
5285 5285
             $count = 0;
5286
-            foreach($exercise_result as $result) {
5287
-                $percentage = $result*100;
5286
+            foreach ($exercise_result as $result) {
5287
+                $percentage = $result * 100;
5288 5288
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5289 5289
                 if ($percentage >= $min && $percentage <= $max) {
5290 5290
                     //echo ' is > ';
@@ -5292,7 +5292,7 @@  discard block
 block discarded – undo
5292 5292
                 }
5293 5293
             }
5294 5294
             //echo '<br />';
5295
-            $final_array[]= $count;
5295
+            $final_array[] = $count;
5296 5296
 
5297 5297
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5298 5298
                 $my_final_array[] = 1;
@@ -5302,9 +5302,9 @@  discard block
 block discarded – undo
5302 5302
         }
5303 5303
 
5304 5304
         //Fix to remove the data of the user with my data
5305
-        for($i = 0; $i<=count($my_final_array); $i++) {
5305
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5306 5306
             if (!empty($my_final_array[$i])) {
5307
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5307
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5308 5308
                 $final_array[$i] = 0;
5309 5309
             }
5310 5310
         }
@@ -5314,16 +5314,16 @@  discard block
 block discarded – undo
5314 5314
         $dataSet->addPoints($final_array, 'Serie1');
5315 5315
         $dataSet->addPoints($my_final_array, 'Serie2');
5316 5316
         $dataSet->normalize(100, "%");
5317
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5317
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5318 5318
 
5319 5319
         // Cache definition
5320 5320
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5321 5321
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5322 5322
         $chartHash = $myCache->getHash($dataSet);
5323 5323
         if ($myCache->isInCache($chartHash)) {
5324
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5324
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5325 5325
             $myCache->saveFromCache($chartHash, $imgPath);
5326
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5326
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5327 5327
         } else {
5328 5328
             /* Create the pChart object */
5329 5329
             $widthSize = 80;
@@ -5339,7 +5339,7 @@  discard block
 block discarded – undo
5339 5339
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5340 5340
 
5341 5341
             /* Set the default font */
5342
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5342
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5343 5343
 
5344 5344
             /* Do not write the chart title */
5345 5345
 
@@ -5403,9 +5403,9 @@  discard block
 block discarded – undo
5403 5403
 
5404 5404
             /* Save and write in cache */
5405 5405
             $myCache->writeToCache($chartHash, $myPicture);
5406
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5406
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5407 5407
             $myCache->saveFromCache($chartHash, $imgPath);
5408
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5408
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5409 5409
         }
5410 5410
 
5411 5411
         return $imgPath;
@@ -5425,12 +5425,12 @@  discard block
 block discarded – undo
5425 5425
         }
5426 5426
         foreach ($attempts as $attempt) {
5427 5427
             if (api_get_user_id() == $attempt['exe_user_id']) {
5428
-                if ($attempt['exe_weighting'] != 0 ) {
5429
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5428
+                if ($attempt['exe_weighting'] != 0) {
5429
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5430 5430
                 }
5431 5431
             } else {
5432
-                if ($attempt['exe_weighting'] != 0 ) {
5433
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5432
+                if ($attempt['exe_weighting'] != 0) {
5433
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5434 5434
                 }
5435 5435
             }
5436 5436
         }
@@ -5439,32 +5439,32 @@  discard block
 block discarded – undo
5439 5439
         rsort($my_exercise_result_array);
5440 5440
         $my_exercise_result = 0;
5441 5441
         if (isset($my_exercise_result_array[0])) {
5442
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5442
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5443 5443
         }
5444 5444
 
5445 5445
         $max = 100;
5446
-        $pieces = 5 ;
5446
+        $pieces = 5;
5447 5447
         $part = round($max / $pieces);
5448 5448
         $x_axis = array();
5449 5449
         $final_array = array();
5450 5450
         $my_final_array = array();
5451 5451
 
5452
-        for ($i=1; $i <=$pieces; $i++) {
5452
+        for ($i = 1; $i <= $pieces; $i++) {
5453 5453
             $sum = 1;
5454 5454
             if ($i == 1) {
5455 5455
                 $sum = 0;
5456 5456
             }
5457
-            $min = ($i-1)*$part + $sum;
5458
-            $max = ($i)*$part;
5459
-            $x_axis[]= $min." - ".$max;
5457
+            $min = ($i - 1) * $part + $sum;
5458
+            $max = ($i) * $part;
5459
+            $x_axis[] = $min." - ".$max;
5460 5460
             $count = 0;
5461
-            foreach($exercise_result as $result) {
5462
-                $percentage = $result*100;
5461
+            foreach ($exercise_result as $result) {
5462
+                $percentage = $result * 100;
5463 5463
                 if ($percentage >= $min && $percentage <= $max) {
5464 5464
                     $count++;
5465 5465
                 }
5466 5466
             }
5467
-            $final_array[]= $count;
5467
+            $final_array[] = $count;
5468 5468
 
5469 5469
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5470 5470
                 $my_final_array[] = 1;
@@ -5475,9 +5475,9 @@  discard block
 block discarded – undo
5475 5475
 
5476 5476
         //Fix to remove the data of the user with my data
5477 5477
 
5478
-        for($i = 0; $i<=count($my_final_array); $i++) {
5478
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5479 5479
             if (!empty($my_final_array[$i])) {
5480
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5480
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5481 5481
                 $final_array[$i] = 0;
5482 5482
             }
5483 5483
         }
@@ -5495,7 +5495,7 @@  discard block
 block discarded – undo
5495 5495
         $dataSet->setXAxisName(get_lang('Score'));
5496 5496
         $dataSet->normalize(100, "%");
5497 5497
 
5498
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5498
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5499 5499
 
5500 5500
         // Cache definition
5501 5501
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5503,9 +5503,9 @@  discard block
 block discarded – undo
5503 5503
         $chartHash = $myCache->getHash($dataSet);
5504 5504
 
5505 5505
         if ($myCache->isInCache($chartHash)) {
5506
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5506
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5507 5507
             $myCache->saveFromCache($chartHash, $imgPath);
5508
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5508
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5509 5509
         } else {
5510 5510
             /* Create the pChart object */
5511 5511
             $widthSize = 480;
@@ -5521,7 +5521,7 @@  discard block
 block discarded – undo
5521 5521
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5522 5522
 
5523 5523
             /* Set the default font */
5524
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5524
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5525 5525
 
5526 5526
             /* Write the chart title */
5527 5527
             $myPicture->drawText(
@@ -5580,9 +5580,9 @@  discard block
 block discarded – undo
5580 5580
 
5581 5581
             /* Write and save into cache */
5582 5582
             $myCache->writeToCache($chartHash, $myPicture);
5583
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5583
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5584 5584
             $myCache->saveFromCache($chartHash, $imgPath);
5585
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5585
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5586 5586
         }
5587 5587
 
5588 5588
         return $imgPath;
@@ -5657,7 +5657,7 @@  discard block
 block discarded – undo
5657 5657
         $tquiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
5658 5658
         $tquiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
5659 5659
         $tquiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
5660
-        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5660
+        $ttrack_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5661 5661
         $ttrack_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
5662 5662
 
5663 5663
         $sessions = array();
@@ -5709,7 +5709,7 @@  discard block
 block discarded – undo
5709 5709
                         $whereSessionParams .= $sessionIdx.',';
5710 5710
                     }
5711 5711
                 }
5712
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5712
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5713 5713
             }
5714 5714
 
5715 5715
             if (!empty($exerciseId)) {
@@ -5773,7 +5773,7 @@  discard block
 block discarded – undo
5773 5773
                     qq.position = rq.question_order AND
5774 5774
                     ta.question_id = rq.question_id
5775 5775
                 WHERE
5776
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5776
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5777 5777
                     AND q.c_id = $courseIdx
5778 5778
                     $where $order $limit";
5779 5779
             $sql_query = vsprintf($sql, $whereParams);
@@ -5821,7 +5821,7 @@  discard block
 block discarded – undo
5821 5821
             // Now fill users data
5822 5822
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5823 5823
                          FROM $tuser
5824
-                         WHERE user_id IN (".implode(',',$userIds).")";
5824
+                         WHERE user_id IN (".implode(',', $userIds).")";
5825 5825
             $resUsers = Database::query($sqlUsers);
5826 5826
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5827 5827
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5925,7 +5925,7 @@  discard block
 block discarded – undo
5925 5925
                 <table class="table" id="skillList">
5926 5926
                     <thead>
5927 5927
                         <tr>
5928
-                            <th>' . get_lang('AchievedSkills') . '</th>
5928
+                            <th>' . get_lang('AchievedSkills').'</th>
5929 5929
                         </tr>
5930 5930
                     </thead>
5931 5931
                     <tbody>
@@ -5944,10 +5944,10 @@  discard block
 block discarded – undo
5944 5944
 
5945 5945
                 $html .= '
5946 5946
                                             <li class="thumbnail">
5947
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5948
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5947
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5948
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5949 5949
                                                     <div class="caption">
5950
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5950
+                                                        <p class="text-center">' . $skill->getName().'</p>
5951 5951
                                                     </div>
5952 5952
                                                 </a>
5953 5953
                                             </li>
@@ -5997,7 +5997,7 @@  discard block
 block discarded – undo
5997 5997
     	        WHERE
5998 5998
                     track_resource.c_id = $course_id AND
5999 5999
                     track_resource.insert_user_id = user.user_id AND
6000
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6000
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6001 6001
 
6002 6002
     	if (isset($_GET['keyword'])) {
6003 6003
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6055,7 +6055,7 @@  discard block
 block discarded – undo
6055 6055
                 WHERE
6056 6056
                   track_resource.c_id = $course_id AND
6057 6057
                   track_resource.insert_user_id = user.user_id AND
6058
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6058
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6059 6059
 
6060 6060
     	if (isset($_GET['keyword'])) {
6061 6061
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6355,7 +6355,7 @@  discard block
 block discarded – undo
6355 6355
     public static function display_additional_profile_fields()
6356 6356
     {
6357 6357
     	// getting all the extra profile fields that are defined by the platform administrator
6358
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6358
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6359 6359
 
6360 6360
     	// creating the form
6361 6361
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6367,8 +6367,8 @@  discard block
 block discarded – undo
6367 6367
     	$extra_fields_to_show = 0;
6368 6368
     	foreach ($extra_fields as $key=>$field) {
6369 6369
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6370
-    		if ($field[6]==1 && $field[8] == 1) {
6371
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6370
+    		if ($field[6] == 1 && $field[8] == 1) {
6371
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6372 6372
     				$selected = 'selected="selected"';
6373 6373
     			} else {
6374 6374
     				$selected = '';
@@ -6380,8 +6380,8 @@  discard block
 block discarded – undo
6380 6380
     	$return .= '</select>';
6381 6381
 
6382 6382
     	// the form elements for the $_GET parameters (because the form is passed through GET
6383
-    	foreach ($_GET as $key=>$value){
6384
-    		if ($key <> 'additional_profile_field')    {
6383
+    	foreach ($_GET as $key=>$value) {
6384
+    		if ($key <> 'additional_profile_field') {
6385 6385
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6386 6386
     		}
6387 6387
     	}
@@ -6418,21 +6418,21 @@  discard block
 block discarded – undo
6418 6418
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6419 6419
 
6420 6420
     	if (!empty($users)) {
6421
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6422
-    			foreach($users as $user_id) {
6421
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6422
+    			foreach ($users as $user_id) {
6423 6423
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6424 6424
     				$tag_list = array();
6425
-    				foreach($user_result as $item) {
6425
+    				foreach ($user_result as $item) {
6426 6426
     					$tag_list[] = $item['tag'];
6427 6427
     				}
6428
-    				$return[$user_id][] = implode(', ',$tag_list);
6428
+    				$return[$user_id][] = implode(', ', $tag_list);
6429 6429
     			}
6430 6430
     		} else {
6431 6431
     			$new_user_array = array();
6432 6432
     			foreach ($users as $user_id) {
6433
-    				$new_user_array[]= "'".$user_id."'";
6433
+    				$new_user_array[] = "'".$user_id."'";
6434 6434
     			}
6435
-    			$users = implode(',',$new_user_array);
6435
+    			$users = implode(',', $new_user_array);
6436 6436
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6437 6437
     			// Selecting only the necessary information NOT ALL the user list
6438 6438
     			$sql = "SELECT user.user_id, v.value
@@ -6447,7 +6447,7 @@  discard block
 block discarded – undo
6447 6447
                             user.user_id IN ($users)";
6448 6448
 
6449 6449
     			$result = Database::query($sql);
6450
-    			while($row = Database::fetch_array($result)) {
6450
+    			while ($row = Database::fetch_array($result)) {
6451 6451
     				// get option value for field type double select by id
6452 6452
     				if (!empty($row['value'])) {
6453 6453
     					if ($result_extra_field['field_type'] ==
@@ -6486,7 +6486,7 @@  discard block
 block discarded – undo
6486 6486
 
6487 6487
     public function sort_users_desc($a, $b)
6488 6488
     {
6489
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6489
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6490 6490
     }
6491 6491
 
6492 6492
     /**
@@ -6521,7 +6521,7 @@  discard block
 block discarded – undo
6521 6521
     	// get all users data from a course for sortable with limit
6522 6522
     	if (is_array($user_ids)) {
6523 6523
     		$user_ids = array_map('intval', $user_ids);
6524
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6524
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6525 6525
     	} else {
6526 6526
     		$user_ids = intval($user_ids);
6527 6527
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6529,7 +6529,7 @@  discard block
 block discarded – undo
6529 6529
 
6530 6530
     	if (!empty($_GET['user_keyword'])) {
6531 6531
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6532
-    		$condition_user .=  " AND (
6532
+    		$condition_user .= " AND (
6533 6533
                 user.firstname LIKE '%".$keyword."%' OR
6534 6534
                 user.lastname LIKE '%".$keyword."%'  OR
6535 6535
                 user.username LIKE '%".$keyword."%'  OR
@@ -6547,7 +6547,7 @@  discard block
 block discarded – undo
6547 6547
         $invitedUsersCondition = '';
6548 6548
 
6549 6549
         if (!$includeInvitedUsers) {
6550
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6550
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6551 6551
         }
6552 6552
 
6553 6553
     	$sql = "SELECT  user.user_id as user_id,
@@ -6558,7 +6558,7 @@  discard block
 block discarded – undo
6558 6558
                 FROM $tbl_user as user $url_table
6559 6559
     	        $condition_user $url_condition $invitedUsersCondition";
6560 6560
 
6561
-    	if (!in_array($direction, array('ASC','DESC'))) {
6561
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6562 6562
     		$direction = 'ASC';
6563 6563
     	}
6564 6564
 
@@ -6694,7 +6694,7 @@  discard block
 block discarded – undo
6694 6694
     		}
6695 6695
 
6696 6696
             if (empty($session_id)) {
6697
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6697
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6698 6698
             }
6699 6699
 
6700 6700
     		$user['link'] = '<center>
@@ -6706,37 +6706,37 @@  discard block
 block discarded – undo
6706 6706
     		// store columns in array $users
6707 6707
     		$is_western_name_order = api_is_western_name_order();
6708 6708
             $user_row = array();
6709
-            $user_row[]= $user['official_code']; //0
6709
+            $user_row[] = $user['official_code']; //0
6710 6710
             if ($is_western_name_order) {
6711
-                $user_row[]= $user['firstname'];
6712
-                $user_row[]= $user['lastname'];
6711
+                $user_row[] = $user['firstname'];
6712
+                $user_row[] = $user['lastname'];
6713 6713
             } else {
6714
-                $user_row[]= $user['lastname'];
6715
-                $user_row[]= $user['firstname'];
6714
+                $user_row[] = $user['lastname'];
6715
+                $user_row[] = $user['firstname'];
6716 6716
             }
6717
-            $user_row[]= $user['username'];
6718
-            $user_row[]= $user['time'];
6719
-            $user_row[]= $user['average_progress'];
6720
-            $user_row[]= $user['exercise_progress'];
6721
-            $user_row[]= $user['exercise_average_best_attempt'];
6722
-            $user_row[]= $user['student_score'];
6723
-            $user_row[]= $user['count_assignments'];
6724
-            $user_row[]= $user['count_messages'];
6717
+            $user_row[] = $user['username'];
6718
+            $user_row[] = $user['time'];
6719
+            $user_row[] = $user['average_progress'];
6720
+            $user_row[] = $user['exercise_progress'];
6721
+            $user_row[] = $user['exercise_average_best_attempt'];
6722
+            $user_row[] = $user['student_score'];
6723
+            $user_row[] = $user['count_assignments'];
6724
+            $user_row[] = $user['count_messages'];
6725 6725
 
6726 6726
             $userGroupManager = new UserGroup();
6727 6727
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6728 6728
 
6729 6729
             if (empty($session_id)) {
6730
-                $user_row[]= $user['survey'];
6730
+                $user_row[] = $user['survey'];
6731 6731
             }
6732 6732
 
6733
-            $user_row[]= $user['first_connection'];
6734
-            $user_row[]= $user['last_connection'];
6733
+            $user_row[] = $user['first_connection'];
6734
+            $user_row[] = $user['last_connection'];
6735 6735
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6736
-                $user_row[]= $user['additional'];
6736
+                $user_row[] = $user['additional'];
6737 6737
             }
6738 6738
 
6739
-            $user_row[]= $user['link'];
6739
+            $user_row[] = $user['link'];
6740 6740
 
6741 6741
             $users[] = $user_row;
6742 6742
 
@@ -6781,8 +6781,8 @@  discard block
 block discarded – undo
6781 6781
 
6782 6782
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6783 6783
     	$tempView = $view;
6784
-    	if(substr($view,0,1) == '1') {
6785
-    		$new_view = substr_replace($view,'0',0,1);
6784
+    	if (substr($view, 0, 1) == '1') {
6785
+    		$new_view = substr_replace($view, '0', 0, 1);
6786 6786
     		echo "
6787 6787
                 <tr>
6788 6788
                     <td valign='top'>
@@ -6815,9 +6815,9 @@  discard block
 block discarded – undo
6815 6815
                 </tr>";
6816 6816
     		$total = 0;
6817 6817
     		if (is_array($results)) {
6818
-    			for($j = 0 ; $j < count($results) ; $j++) {
6818
+    			for ($j = 0; $j < count($results); $j++) {
6819 6819
     				echo "<tr>";
6820
-    				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>";
6820
+    				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>";
6821 6821
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6822 6822
     				echo"</tr>";
6823 6823
     				$total = $total + $results[$j][1];
@@ -6834,7 +6834,7 @@  discard block
 block discarded – undo
6834 6834
     		echo "</table>";
6835 6835
     		echo "</td></tr>";
6836 6836
     	} else {
6837
-    		$new_view = substr_replace($view,'1',0,1);
6837
+    		$new_view = substr_replace($view, '1', 0, 1);
6838 6838
     		echo "
6839 6839
                 <tr>
6840 6840
                     <td valign='top'>
@@ -6857,8 +6857,8 @@  discard block
 block discarded – undo
6857 6857
     {
6858 6858
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6859 6859
         $courseId = api_get_course_int_id($courseCode);
6860
-    	if(substr($view,1,1) == '1') {
6861
-    		$new_view = substr_replace($view,'0',1,1);
6860
+    	if (substr($view, 1, 1) == '1') {
6861
+    		$new_view = substr_replace($view, '0', 1, 1);
6862 6862
     		echo "<tr>
6863 6863
                     <td valign='top'>
6864 6864
                         <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>]
@@ -6900,7 +6900,7 @@  discard block
 block discarded – undo
6900 6900
                 </tr>";
6901 6901
 
6902 6902
     		if (is_array($results)) {
6903
-    			for($i = 0; $i < sizeof($results); $i++) {
6903
+    			for ($i = 0; $i < sizeof($results); $i++) {
6904 6904
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6905 6905
     				echo "<tr>\n";
6906 6906
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6915,8 +6915,8 @@  discard block
 block discarded – undo
6915 6915
 
6916 6916
     		// The Result of Tests
6917 6917
     		if (is_array($hpresults)) {
6918
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6919
-    				$title = GetQuizName($hpresults[$i][0],'');
6918
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6919
+    				$title = GetQuizName($hpresults[$i][0], '');
6920 6920
     				if ($title == '')
6921 6921
     				$title = basename($hpresults[$i][0]);
6922 6922
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6942,7 +6942,7 @@  discard block
 block discarded – undo
6942 6942
     		echo "</table>";
6943 6943
     		echo "</td>\n</tr>\n";
6944 6944
     	} else {
6945
-    		$new_view = substr_replace($view,'1',1,1);
6945
+    		$new_view = substr_replace($view, '1', 1, 1);
6946 6946
     		echo "
6947 6947
                 <tr>
6948 6948
                     <td valign='top'>
@@ -6961,8 +6961,8 @@  discard block
 block discarded – undo
6961 6961
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6962 6962
         $_course = api_get_course_info_by_id($course_id);
6963 6963
 
6964
-    	if (substr($view,2,1) == '1') {
6965
-    		$new_view = substr_replace($view,'0',2,1);
6964
+    	if (substr($view, 2, 1) == '1') {
6965
+    		$new_view = substr_replace($view, '0', 2, 1);
6966 6966
     		echo "<tr>
6967 6967
                     <td valign='top'>
6968 6968
                     <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>]
@@ -6976,7 +6976,7 @@  discard block
 block discarded – undo
6976 6976
                         AND u.c_id = '".intval($course_id)."'
6977 6977
                     ORDER BY u.upload_date DESC";
6978 6978
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6979
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6979
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6980 6980
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6981 6981
     		echo "<tr>
6982 6982
                     <td class='secLine' width='40%'>
@@ -6990,7 +6990,7 @@  discard block
 block discarded – undo
6990 6990
                     </td>
6991 6991
                 </tr>";
6992 6992
     		if (is_array($results)) {
6993
-    			for($j = 0 ; $j < count($results) ; $j++) {
6993
+    			for ($j = 0; $j < count($results); $j++) {
6994 6994
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6995 6995
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6996 6996
     				echo "<tr>";
@@ -7009,7 +7009,7 @@  discard block
 block discarded – undo
7009 7009
     		echo "</table>";
7010 7010
     		echo "</td></tr>";
7011 7011
     	} else {
7012
-    		$new_view = substr_replace($view,'1',2,1);
7012
+    		$new_view = substr_replace($view, '1', 2, 1);
7013 7013
     		echo "
7014 7014
                 <tr>
7015 7015
                     <td valign='top'>
@@ -7028,8 +7028,8 @@  discard block
 block discarded – undo
7028 7028
     {
7029 7029
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7030 7030
         $courseId = api_get_course_int_id($courseCode);
7031
-    	if (substr($view,3,1) == '1') {
7032
-    		$new_view = substr_replace($view,'0',3,1);
7031
+    	if (substr($view, 3, 1) == '1') {
7032
+    		$new_view = substr_replace($view, '0', 3, 1);
7033 7033
     		echo "
7034 7034
                 <tr>
7035 7035
                         <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'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></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',3,1);
7069
+    		$new_view = substr_replace($view, '1', 3, 1);
7070 7070
     		echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
@@ -7093,8 +7093,8 @@  discard block
 block discarded – undo
7093 7093
     	$session_id = intval($session_id);
7094 7094
 
7095 7095
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7096
-    	if(substr($view,4,1) == '1') {
7097
-    		$new_view = substr_replace($view,'0',4,1);
7096
+    	if (substr($view, 4, 1) == '1') {
7097
+    		$new_view = substr_replace($view, '0', 4, 1);
7098 7098
     		echo "
7099 7099
                 <tr>
7100 7100
                     <td valign='top'>
@@ -7120,7 +7120,7 @@  discard block
 block discarded – undo
7120 7120
                     </td>
7121 7121
                 </tr>";
7122 7122
     		if (is_array($results)) {
7123
-    			for($j = 0 ; $j < count($results) ; $j++) {
7123
+    			for ($j = 0; $j < count($results); $j++) {
7124 7124
     				echo "<tr>";
7125 7125
     				echo "<td class='content'>".$results[$j]."</td>";
7126 7126
     				echo"</tr>";
@@ -7133,7 +7133,7 @@  discard block
 block discarded – undo
7133 7133
     		echo "</table>";
7134 7134
     		echo "</td></tr>";
7135 7135
     	} else {
7136
-    		$new_view = substr_replace($view,'1',4,1);
7136
+    		$new_view = substr_replace($view, '1', 4, 1);
7137 7137
     		echo "
7138 7138
                 <tr>
7139 7139
                     <td valign='top'>
@@ -7167,11 +7167,11 @@  discard block
 block discarded – undo
7167 7167
                    ORDER BY login_date DESC LIMIT 1";
7168 7168
         $ip = '';
7169 7169
         $res_ip = Database::query($sql_ip);
7170
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7170
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7171 7171
             $row_ip = Database::fetch_row($res_ip);
7172 7172
             if ($return_as_link) {
7173 7173
                 $ip = Display::url(
7174
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7174
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7175 7175
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7176 7176
                 );
7177 7177
             } else {
@@ -7207,9 +7207,9 @@  discard block
 block discarded – undo
7207 7207
     	$course_id  = intval($course_id);
7208 7208
 
7209 7209
     	$tempView = $view;
7210
-    	if (substr($view,0,1) == '1') {
7211
-    		$new_view = substr_replace($view,'0',0,1);
7212
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7210
+    	if (substr($view, 0, 1) == '1') {
7211
+    		$new_view = substr_replace($view, '0', 0, 1);
7212
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7213 7213
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7214 7214
                     FROM $track_access_table
7215 7215
                     WHERE access_user_id = $user_id
@@ -7219,20 +7219,20 @@  discard block
 block discarded – undo
7219 7219
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7220 7220
     		//$results = getManyResults2Col($sql);
7221 7221
     		$results = getManyResults3Col($sql);
7222
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7223
-    		$line='';
7222
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7223
+    		$line = '';
7224 7224
     		$total = 0;
7225 7225
     		if (is_array($results)) {
7226
-    			for($j = 0 ; $j < count($results) ; $j++) {
7226
+    			for ($j = 0; $j < count($results); $j++) {
7227 7227
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7228 7228
     				$total = $total + $results[$j][1];
7229 7229
     			}
7230 7230
     			$line .= get_lang('Total').";".$total."\n";
7231 7231
     		} else {
7232
-    			$line= get_lang('NoResult')."</center></td>";
7232
+    			$line = get_lang('NoResult')."</center></td>";
7233 7233
     		}
7234 7234
     	} else {
7235
-    		$new_view = substr_replace($view,'1',0,1);
7235
+    		$new_view = substr_replace($view, '1', 0, 1);
7236 7236
     	}
7237 7237
     	return array($title_line, $line);
7238 7238
     }
@@ -7250,8 +7250,8 @@  discard block
 block discarded – undo
7250 7250
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7251 7251
         $courseId = api_get_course_int_id($courseCode);
7252 7252
         $userId = intval($userId);
7253
-    	if (substr($view,1,1) == '1') {
7254
-    		$new_view = substr_replace($view,'0',1,1);
7253
+    	if (substr($view, 1, 1) == '1') {
7254
+    		$new_view = substr_replace($view, '0', 1, 1);
7255 7255
     		$title[1] = get_lang('ExercicesDetails');
7256 7256
     		$line = '';
7257 7257
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7275,7 +7275,7 @@  discard block
 block discarded – undo
7275 7275
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7276 7276
 
7277 7277
     		if (is_array($results)) {
7278
-    			for($i = 0; $i < sizeof($results); $i++)
7278
+    			for ($i = 0; $i < sizeof($results); $i++)
7279 7279
     			{
7280 7280
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7281 7281
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7287,8 +7287,8 @@  discard block
 block discarded – undo
7287 7287
 
7288 7288
     		// The Result of Tests
7289 7289
     		if (is_array($hpresults)) {
7290
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7291
-    				$title = GetQuizName($hpresults[$i][0],'');
7290
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7291
+    				$title = GetQuizName($hpresults[$i][0], '');
7292 7292
 
7293 7293
     				if ($title == '')
7294 7294
     				$title = basename($hpresults[$i][0]);
@@ -7302,10 +7302,10 @@  discard block
 block discarded – undo
7302 7302
     		}
7303 7303
 
7304 7304
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7305
-    			$line=get_lang('NoResult');
7305
+    			$line = get_lang('NoResult');
7306 7306
     		}
7307 7307
     	} else {
7308
-    		$new_view = substr_replace($view,'1',1,1);
7308
+    		$new_view = substr_replace($view, '1', 1, 1);
7309 7309
     	}
7310 7310
     	return array($title_line, $line);
7311 7311
     }
@@ -7321,7 +7321,7 @@  discard block
 block discarded – undo
7321 7321
         $user_id = intval($user_id);
7322 7322
         $course_id = intval($course_id);
7323 7323
 
7324
-    	if (substr($view,2,1) == '1') {
7324
+    	if (substr($view, 2, 1) == '1') {
7325 7325
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7326 7326
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7327 7327
                     WHERE
@@ -7329,21 +7329,21 @@  discard block
 block discarded – undo
7329 7329
                         u.upload_user_id = '$user_id' AND
7330 7330
                         u.c_id = '$course_id'
7331 7331
                     ORDER BY u.upload_date DESC";
7332
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7332
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7333 7333
 
7334
-    		$title[1]=get_lang('WorksDetails');
7335
-    		$line='';
7336
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7334
+    		$title[1] = get_lang('WorksDetails');
7335
+    		$line = '';
7336
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7337 7337
 
7338 7338
     		if (is_array($results)) {
7339
-    			for($j = 0 ; $j < count($results) ; $j++) {
7339
+    			for ($j = 0; $j < count($results); $j++) {
7340 7340
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7341 7341
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7342 7342
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7343 7343
     			}
7344 7344
 
7345 7345
     		} else {
7346
-    			$line= get_lang('NoResult');
7346
+    			$line = get_lang('NoResult');
7347 7347
     		}
7348 7348
     	}
7349 7349
     	return array($title_line, $line);
@@ -7359,9 +7359,9 @@  discard block
 block discarded – undo
7359 7359
         $courseId = api_get_course_int_id($courseCode);
7360 7360
         $userId = intval($userId);
7361 7361
         $line = null;
7362
-    	if (substr($view,3,1) == '1') {
7363
-    		$new_view = substr_replace($view,'0',3,1);
7364
-    		$title[1]=get_lang('LinksDetails');
7362
+    	if (substr($view, 3, 1) == '1') {
7363
+    		$new_view = substr_replace($view, '0', 3, 1);
7364
+    		$title[1] = get_lang('LinksDetails');
7365 7365
     		$sql = "SELECT cl.title, cl.url
7366 7366
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7367 7367
                         WHERE sl.links_link_id = cl.id
@@ -7369,16 +7369,16 @@  discard block
 block discarded – undo
7369 7369
                             AND sl.links_user_id = $userId
7370 7370
                         GROUP BY cl.title, cl.url";
7371 7371
     		$results = StatsUtils::getManyResults2Col($sql);
7372
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7372
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7373 7373
     		if (is_array($results)) {
7374
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7374
+    			for ($j = 0; $j < count($results); $j++) {
7375 7375
     				$line .= $results[$j][0]."\n";
7376 7376
     			}
7377 7377
     		} else {
7378
-    			$line=get_lang('NoResult');
7378
+    			$line = get_lang('NoResult');
7379 7379
     		}
7380 7380
     	} else {
7381
-    		$new_view = substr_replace($view,'1',3,1);
7381
+    		$new_view = substr_replace($view, '1', 3, 1);
7382 7382
     	}
7383 7383
     	return array($title_line, $line);
7384 7384
     }
@@ -7400,9 +7400,9 @@  discard block
 block discarded – undo
7400 7400
 
7401 7401
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7402 7402
 
7403
-    	if (substr($view,4,1) == '1') {
7404
-    		$new_view = substr_replace($view,'0',4,1);
7405
-    		$title[1]= get_lang('DocumentsDetails');
7403
+    	if (substr($view, 4, 1) == '1') {
7404
+    		$new_view = substr_replace($view, '0', 4, 1);
7405
+    		$title[1] = get_lang('DocumentsDetails');
7406 7406
 
7407 7407
     		$sql = "SELECT down_doc_path
7408 7408
                         FROM $downloads_table
@@ -7415,14 +7415,14 @@  discard block
 block discarded – undo
7415 7415
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7416 7416
             $line = null;
7417 7417
     		if (is_array($results)) {
7418
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7418
+    			for ($j = 0; $j < count($results); $j++) {
7419 7419
     				$line .= $results[$j]."\n";
7420 7420
     			}
7421 7421
     		} else {
7422 7422
     			$line = get_lang('NoResult');
7423 7423
     		}
7424 7424
     	} else {
7425
-    		$new_view = substr_replace($view,'1',4,1);
7425
+    		$new_view = substr_replace($view, '1', 4, 1);
7426 7426
     	}
7427 7427
     	return array($title_line, $line);
7428 7428
     }
Please login to merge, or discard this patch.