Completed
Pull Request — 1.11.x (#1700)
by José
28:48
created
main/auth/shibboleth/test/shibboleth_test.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@
 block discarded – undo
205 205
             $message = "Assert failed $message <br/>";
206 206
             echo $message;
207 207
             // Dump variable for debug
208
-            error_log(print_r(debug_backtrace(),1));
208
+            error_log(print_r(debug_backtrace(), 1));
209 209
             die;
210 210
         }
211 211
         else
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -207,8 +207,7 @@
 block discarded – undo
207 207
             // Dump variable for debug
208 208
             error_log(print_r(debug_backtrace(),1));
209 209
             die;
210
-        }
211
-        else
210
+        } else
212 211
         {
213 212
             $message = "Assert successful $message <br/>";
214 213
             echo $message;
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/Language.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@
 block discarded – undo
230 230
     /**
231 231
      * Get id
232 232
      *
233
-     * @return boolean
233
+     * @return integer
234 234
      */
235 235
     public function getId()
236 236
     {
Please login to merge, or discard this patch.
custompages/language.inc.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
     krsort($langs, SORT_NUMERIC);
30 30
     // Choosing the best match
31 31
     foreach($langs as $weight => $codes) {
32
-		foreach ($codes as $code) {
33
-        	if (in_array($code, $available_langs)) {
34
-            	return $code;
35
-        	}
36
-		}
32
+        foreach ($codes as $code) {
33
+            if (in_array($code, $available_langs)) {
34
+                return $code;
35
+            }
36
+        }
37 37
     }
38 38
     // No match
39 39
     return null;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
     }
29 29
     krsort($langs, SORT_NUMERIC);
30 30
     // Choosing the best match
31
-    foreach($langs as $weight => $codes) {
31
+    foreach ($langs as $weight => $codes) {
32 32
 		foreach ($codes as $code) {
33 33
         	if (in_array($code, $available_langs)) {
34 34
             	return $code;
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 4 patches
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.
Braces   +74 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2387,7 +2387,9 @@  discard block
 block discarded – undo
2387 2387
             $debug = false;
2388 2388
         }
2389 2389
 
2390
-        if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
2390
+        if ($debug) {
2391
+            echo '<h1>Tracking::get_avg_student_score</h1>';
2392
+        }
2391 2393
         $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
2392 2394
         $tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
2393 2395
 
@@ -2464,7 +2466,9 @@  discard block
 block discarded – undo
2464 2466
                             $condition_user1 AND
2465 2467
                             session_id = $session_id
2466 2468
                         GROUP BY lp_id, user_id";
2467
-                if ($debug) echo $sql;
2469
+                if ($debug) {
2470
+                    echo $sql;
2471
+                }
2468 2472
 
2469 2473
                 $rs_last_lp_view_id = Database::query($sql);
2470 2474
 
@@ -2480,7 +2484,9 @@  discard block
 block discarded – undo
2480 2484
                         $lp_view_id = $row_lp_view['id'];
2481 2485
                         $lp_id      = $row_lp_view['lp_id'];
2482 2486
                         $user_id    = $row_lp_view['user_id'];
2483
-                        if ($debug) echo '<h2>LP id '.$lp_id.'</h2>';
2487
+                        if ($debug) {
2488
+                            echo '<h2>LP id '.$lp_id.'</h2>';
2489
+                        }
2484 2490
 
2485 2491
                         if ($get_only_latest_attempt_results) {
2486 2492
                             //Getting lp_items done by the user
@@ -2537,7 +2543,9 @@  discard block
 block discarded – undo
2537 2543
                                          lp_i.c_id  = $course_id AND
2538 2544
                                          (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
2539 2545
                                       WHERE lp_view_id = $lp_view_id ";
2540
-                            if ($debug) echo $sql.'<br />';
2546
+                            if ($debug) {
2547
+                                echo $sql.'<br />';
2548
+                            }
2541 2549
                             $res_max_score = Database::query($sql);
2542 2550
 
2543 2551
                             while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
@@ -2556,7 +2564,9 @@  discard block
 block discarded – undo
2556 2564
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2557 2565
                             $score = $row_max_score['score'];
2558 2566
 
2559
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2567
+                            if ($debug) {
2568
+                                echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2569
+                            }
2560 2570
 
2561 2571
                             if ($row_max_score['item_type'] == 'sco') {
2562 2572
                                 /* Check if it is sco (easier to get max_score)
@@ -2576,7 +2586,9 @@  discard block
 block discarded – undo
2576 2586
                                 if (!empty($max_score)) {
2577 2587
                                     $lp_partial_total += $score/$max_score;
2578 2588
                                 }
2579
-                                if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2589
+                                if ($debug) {
2590
+                                    echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2591
+                                }
2580 2592
                             } else {
2581 2593
                                 // Case of a TOOL_QUIZ element
2582 2594
                                 $item_id = $row_max_score['iid'];
@@ -2598,12 +2610,16 @@  discard block
 block discarded – undo
2598 2610
                                         ORDER BY exe_date DESC
2599 2611
                                         LIMIT 1";
2600 2612
 
2601
-                                if ($debug) echo $sql .'<br />';
2613
+                                if ($debug) {
2614
+                                    echo $sql .'<br />';
2615
+                                }
2602 2616
                                 $result_last_attempt = Database::query($sql);
2603 2617
                                 $num = Database :: num_rows($result_last_attempt);
2604 2618
                                 if ($num > 0 ) {
2605 2619
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2606
-                                    if ($debug) echo $id_last_attempt.'<br />';
2620
+                                    if ($debug) {
2621
+                                        echo $id_last_attempt.'<br />';
2622
+                                    }
2607 2623
 
2608 2624
                                     // Within the last attempt number tracking, get the sum of
2609 2625
                                     // the max_scores of all questions that it was
@@ -2622,7 +2638,9 @@  discard block
 block discarded – undo
2622 2638
                                                     q.c_id = $course_id
2623 2639
                                             )
2624 2640
                                             AS t";
2625
-                                    if ($debug) echo '$sql: '.$sql.' <br />';
2641
+                                    if ($debug) {
2642
+                                        echo '$sql: '.$sql.' <br />';
2643
+                                    }
2626 2644
                                     $res_max_score_bis = Database::query($sql);
2627 2645
                                     $row_max_score_bis = Database::fetch_array($res_max_score_bis);
2628 2646
 
@@ -2632,7 +2650,9 @@  discard block
 block discarded – undo
2632 2650
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2633 2651
                                         $lp_partial_total += $score/$max_score;
2634 2652
                                     }
2635
-                                    if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2653
+                                    if ($debug) {
2654
+                                        echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2655
+                                    }
2636 2656
                                 }
2637 2657
                             }
2638 2658
 
@@ -2645,17 +2665,25 @@  discard block
 block discarded – undo
2645 2665
                                         $count_items++;
2646 2666
                                     }
2647 2667
                                 }
2648
-                                if ($debug) echo '$count_items: '.$count_items;
2668
+                                if ($debug) {
2669
+                                    echo '$count_items: '.$count_items;
2670
+                                }
2649 2671
                             }
2650 2672
                         } //end for
2651 2673
 
2652 2674
                         $score_of_scorm_calculate += $count_items ? (($lp_partial_total / $count_items) * 100) : 0;
2653 2675
 
2654
-                        if ($debug) echo '<h3>$count_items '.$count_items.'</h3>';
2655
-                        if ($debug) echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2676
+                        if ($debug) {
2677
+                            echo '<h3>$count_items '.$count_items.'</h3>';
2678
+                        }
2679
+                        if ($debug) {
2680
+                            echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2681
+                        }
2656 2682
 
2657 2683
                         $global_result += $score_of_scorm_calculate;
2658
-                        if ($debug) echo '<h3>$global_result '.$global_result.'</h3>';
2684
+                        if ($debug) {
2685
+                            echo '<h3>$global_result '.$global_result.'</h3>';
2686
+                        }
2659 2687
                     } // end while
2660 2688
                 }
2661 2689
 
@@ -2668,7 +2696,9 @@  discard block
 block discarded – undo
2668 2696
                                 c_id = $course_id AND
2669 2697
                                 (item_type = 'quiz' OR item_type = 'sco') AND
2670 2698
                                 lp_id = ".$lp_id;
2671
-                    if ($debug) echo $sql;
2699
+                    if ($debug) {
2700
+                        echo $sql;
2701
+                    }
2672 2702
                     $result_have_quiz = Database::query($sql);
2673 2703
 
2674 2704
                     if (Database::num_rows($result_have_quiz) > 0 ) {
@@ -2679,19 +2709,29 @@  discard block
 block discarded – undo
2679 2709
                     }
2680 2710
                 }
2681 2711
 
2682
-                if ($debug) echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2683
-                if ($debug) echo '<h3>Final return</h3>';
2712
+                if ($debug) {
2713
+                    echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2714
+                }
2715
+                if ($debug) {
2716
+                    echo '<h3>Final return</h3>';
2717
+                }
2684 2718
 
2685 2719
                 if ($lp_with_quiz != 0) {
2686 2720
                     if (!$return_array) {
2687 2721
                         $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2688
-                        if ($debug) var_dump($score_of_scorm_calculate);
2722
+                        if ($debug) {
2723
+                            var_dump($score_of_scorm_calculate);
2724
+                        }
2689 2725
                         if (empty($lp_ids)) {
2690
-                            if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2726
+                            if ($debug) {
2727
+                                echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2728
+                            }
2691 2729
                         }
2692 2730
                         return $score_of_scorm_calculate;
2693 2731
                     } else {
2694
-                        if ($debug) var_dump($global_result, $lp_with_quiz);
2732
+                        if ($debug) {
2733
+                            var_dump($global_result, $lp_with_quiz);
2734
+                        }
2695 2735
                         return array($global_result, $lp_with_quiz);
2696 2736
                     }
2697 2737
                 } else {
@@ -3181,11 +3221,13 @@  discard block
 block discarded – undo
3181 3221
 
3182 3222
         if (!empty ($id_session)) {
3183 3223
             $sql .= ' WHERE session_course.session_id=' . $id_session;
3184
-            if (api_is_multiple_url_enabled())
3185
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3186
-        }  else {
3187
-            if (api_is_multiple_url_enabled())
3188
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3224
+            if (api_is_multiple_url_enabled()) {
3225
+                        $sql .=  ' AND access_url_id = '.$access_url_id;
3226
+            }
3227
+        } else {
3228
+            if (api_is_multiple_url_enabled()) {
3229
+                        $sql .=  ' WHERE access_url_id = '.$access_url_id;
3230
+            }
3189 3231
         }
3190 3232
 
3191 3233
         $result = Database::query($sql);
@@ -3297,8 +3339,7 @@  discard block
 block discarded – undo
3297 3339
                 if (empty($session['access_start_date'])
3298 3340
                 ) {
3299 3341
                     $session['status'] = get_lang('SessionActive');
3300
-                }
3301
-                else {
3342
+                } else {
3302 3343
                     $time_start = api_strtotime($session['access_start_date'], 'UTC');
3303 3344
                     $time_end = api_strtotime($session['access_end_date'], 'UTC');
3304 3345
                     if ($time_start < time() && time() < $time_end) {
@@ -6917,8 +6958,9 @@  discard block
 block discarded – undo
6917 6958
     		if (is_array($hpresults)) {
6918 6959
     			for($i = 0; $i < sizeof($hpresults); $i++) {
6919 6960
     				$title = GetQuizName($hpresults[$i][0],'');
6920
-    				if ($title == '')
6921
-    				$title = basename($hpresults[$i][0]);
6961
+    				if ($title == '') {
6962
+    				    				$title = basename($hpresults[$i][0]);
6963
+    				}
6922 6964
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6923 6965
     				?>
6924 6966
                     <tr>
@@ -7290,8 +7332,9 @@  discard block
 block discarded – undo
7290 7332
     			for($i = 0; $i < sizeof($hpresults); $i++) {
7291 7333
     				$title = GetQuizName($hpresults[$i][0],'');
7292 7334
 
7293
-    				if ($title == '')
7294
-    				$title = basename($hpresults[$i][0]);
7335
+    				if ($title == '') {
7336
+    				    				$title = basename($hpresults[$i][0]);
7337
+    				}
7295 7338
 
7296 7339
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7297 7340
 
Please login to merge, or discard this patch.
Spacing   +430 added lines, -430 removed lines patch added patch discarded remove patch
@@ -137,22 +137,22 @@  discard block
 block discarded – undo
137 137
         $extend_all = 0;
138 138
 
139 139
         if ($origin == 'tracking') {
140
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
140
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
141 141
         } else {
142
-            $url_suffix = '&lp_id=' . $lp_id;
142
+            $url_suffix = '&lp_id='.$lp_id;
143 143
         }
144 144
 
145 145
         if (!empty($extendedAll)) {
146 146
             $extend_all_link = Display::url(
147 147
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
148
-                api_get_self() . '?action=stats' . $url_suffix
148
+                api_get_self().'?action=stats'.$url_suffix
149 149
             );
150 150
 
151 151
             $extend_all = 1;
152 152
         } else {
153 153
             $extend_all_link = Display::url(
154 154
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
155
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
155
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
156 156
             );
157 157
         }
158 158
 
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 
165 165
         $actionColumn = null;
166 166
         if ($type == 'classic') {
167
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
167
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
168 168
         }
169 169
         $output .= '<div class="table-responsive">';
170 170
         $output .= '<table class="table tracking">
171 171
             <thead>
172 172
             <tr class="table-header">
173
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
173
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
174 174
                 <th colspan="4">
175
-                    ' . get_lang('ScormLessonTitle') .'
175
+                    ' . get_lang('ScormLessonTitle').'
176 176
                 </th>
177 177
                 <th colspan="2">
178
-                    ' . get_lang('ScormStatus') . '
178
+                    ' . get_lang('ScormStatus').'
179 179
                 </th>
180 180
                 <th colspan="2">
181
-                    ' . get_lang('ScormScore') . '
181
+                    ' . get_lang('ScormScore').'
182 182
                 </th>
183 183
                 <th colspan="2">
184
-                    ' . get_lang('ScormTime') . '
184
+                    ' . get_lang('ScormTime').'
185 185
                 </th>
186 186
                 '.$actionColumn.'
187 187
                 </tr>
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 // Prepare statement to go through each attempt.
245 245
                 $viewCondition = null;
246 246
                 if (!empty($view)) {
247
-                    $viewCondition =  " AND v.view_count = $view  ";
247
+                    $viewCondition = " AND v.view_count = $view  ";
248 248
                 }
249 249
 
250 250
                 $sql = "SELECT
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                                 FROM $TBL_QUIZ
293 293
                                 WHERE
294 294
                                     c_id = $course_id AND
295
-                                    id ='" . $my_path . "'";
295
+                                    id ='".$my_path."'";
296 296
                         $res_result_disabled = Database::query($sql);
297 297
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
298 298
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
                     if (!empty($inter_num)) {
315 315
                         $extend_link = Display::url(
316 316
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
317
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
318 318
                         );
319 319
                     }
320 320
                     $title = $row['mytitle'];
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
                     $action = null;
334 334
                     if ($type == 'classic') {
335
-                        $action =  '<td></td>';
335
+                        $action = '<td></td>';
336 336
                     }
337 337
 
338 338
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
                                 $extend_this_attempt = 1;
377 377
                                 $extend_attempt_link = Display::url(
378 378
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
379
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
379
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
380 380
                                 );
381 381
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
382 382
                                 // The extend button for this attempt has not been clicked.
383 383
                                 $extend_attempt_link = Display::url(
384 384
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
385
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
385
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
386 386
                                 );
387 387
                             }
388 388
                         }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
                         }
416 416
 
417 417
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
418
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
418
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
419 419
 
420 420
                         if ($row['item_type'] != 'dir') {
421 421
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
                                 $action = '<td></td>';
444 444
                             }
445 445
 
446
-                            $output .= '<tr class="' . $oddclass . '">
446
+                            $output .= '<tr class="'.$oddclass.'">
447 447
                                     <td></td>
448
-                                    <td>' . $extend_attempt_link . '</td>
449
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
450
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
451
-                                    <td colspan="2">' . $view_score . '</td>
452
-                                    <td colspan="2">' . $time . '</td>
448
+                                    <td>' . $extend_attempt_link.'</td>
449
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
450
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
451
+                                    <td colspan="2">' . $view_score.'</td>
452
+                                    <td colspan="2">' . $time.'</td>
453 453
                                     '.$action.'
454 454
                                 </tr>';
455 455
                             $attemptCount++;
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
463 463
                                         $temp[] = '/';
464 464
                                     } else {
465
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
465
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
466 466
                                     }
467 467
                                 } else {
468
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
468
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
469 469
                                 }
470 470
                                 $temp[] = $time;
471 471
                                 $csv_content[] = $temp;
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
                                         <td></td>
502 502
                                         <td></td>
503 503
                                         <td></td>
504
-                                        <td>'.$interaction['order_id'] . '</td>
505
-                                        <td>'.$interaction['id'] . '</td>
504
+                                        <td>'.$interaction['order_id'].'</td>
505
+                                        <td>'.$interaction['id'].'</td>
506 506
                                         <td colspan="2">' . $interaction['type'].'</td>
507
-                                        <td>'.$student_response . '</td>
508
-                                        <td>'.$interaction['result'] . '</td>
509
-                                        <td>'.$interaction['latency'] . '</td>
510
-                                        <td>'.$interaction['time'] . '</td>
507
+                                        <td>'.$student_response.'</td>
508
+                                        <td>'.$interaction['result'].'</td>
509
+                                        <td>'.$interaction['latency'].'</td>
510
+                                        <td>'.$interaction['time'].'</td>
511 511
                                         '.$action.'
512 512
                                     </tr>';
513 513
                                 $counter++;
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
                                         <td></td>
525 525
                                         <td></td>
526 526
                                         <td></td>
527
-                                        <td>' . $interaction['order_id'] . '</td>
528
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
529
-                                        <td colspan="2">' . $interaction['status'] .'</td>
530
-                                        <td>' . $interaction['score_raw'] . '</td>
531
-                                        <td>' . $interaction['score_max'] . '</td>
532
-                                        <td>' . $interaction['score_min'] . '</td>
527
+                                        <td>' . $interaction['order_id'].'</td>
528
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
529
+                                        <td colspan="2">' . $interaction['status'].'</td>
530
+                                        <td>' . $interaction['score_raw'].'</td>
531
+                                        <td>' . $interaction['score_max'].'</td>
532
+                                        <td>' . $interaction['score_min'].'</td>
533 533
                                         '.$action.'
534 534
                                      </tr>';
535 535
                                 $counter++;
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
                         $my_path = Database::escape_string($my_path);
552 552
                         $sql = "SELECT results_disabled
553 553
                                 FROM $TBL_QUIZ
554
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
554
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
555 555
                         $res_result_disabled = Database::query($sql);
556 556
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
557 557
 
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
                             $extend_this_attempt = 1;
575 575
                             $extend_attempt_link = Display::url(
576 576
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
577
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
577
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
578 578
                             );
579 579
                         } else {
580 580
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
581 581
                             // The extend button for this attempt has not been clicked.
582 582
                             $extend_attempt_link = Display::url(
583 583
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
584
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
584
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
585 585
                             );
586 586
                         }
587 587
                     }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
                     if ($inter_num > 1) {
597 597
                         $extend_link = Display::url(
598 598
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
599
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
599
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
600 600
                         );
601 601
                     }
602 602
 
@@ -611,15 +611,15 @@  discard block
 block discarded – undo
611 611
                     $title = $row['mytitle'];
612 612
 
613 613
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
614
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
614
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
615 615
                              WHERE
616
-                                exe_exo_id="' . $row['path'] . '" AND
617
-                                exe_user_id="' . $user_id . '" AND
618
-                                orig_lp_id = "' . $lp_id . '" AND
619
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
620
-                                c_id = ' . $course_id . ' AND
616
+                                exe_exo_id="' . $row['path'].'" AND
617
+                                exe_user_id="' . $user_id.'" AND
618
+                                orig_lp_id = "' . $lp_id.'" AND
619
+                                orig_lp_item_id = "' . $row['myid'].'" AND
620
+                                c_id = ' . $course_id.' AND
621 621
                                 status <> "incomplete" AND
622
-                                session_id = ' . $session_id . '
622
+                                session_id = ' . $session_id.'
623 623
                              ORDER BY exe_date DESC
624 624
                              LIMIT 1';
625 625
 
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
                                     FROM $TBL_LP_ITEM_VIEW
649 649
                                     WHERE
650 650
                                         c_id = $course_id AND
651
-                                        lp_item_id = '" . (int) $my_id . "' AND
652
-                                        lp_view_id = '" . (int) $my_lp_view_id . "'
651
+                                        lp_item_id = '".(int) $my_id."' AND
652
+                                        lp_view_id = '" . (int) $my_lp_view_id."'
653 653
                                     ORDER BY view_count DESC limit 1";
654 654
                             $res_score = Database::query($sql);
655 655
                             $row_score = Database::fetch_array($res_score);
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
                                     FROM $TBL_LP_ITEM_VIEW
659 659
                                     WHERE
660 660
                                         c_id = $course_id AND
661
-                                        lp_item_id = '" . (int) $my_id . "' AND
662
-                                        lp_view_id = '" . (int) $my_lp_view_id . "'";
661
+                                        lp_item_id = '".(int) $my_id."' AND
662
+                                        lp_view_id = '" . (int) $my_lp_view_id."'";
663 663
                             $res_time = Database::query($sql);
664 664
                             $row_time = Database::fetch_array($res_time);
665 665
 
@@ -726,16 +726,16 @@  discard block
 block discarded – undo
726 726
                     } else {
727 727
                         $correct_test_link = '-';
728 728
                         if ($row['item_type'] == 'quiz') {
729
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
730
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
729
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
730
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
731 731
                                      WHERE
732
-                                        exe_exo_id="' . $row['path'] . '" AND
733
-                                        exe_user_id="' . $user_id . '" AND
734
-                                        orig_lp_id = "' . $lp_id . '" AND
735
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
736
-                                        c_id = ' . $course_id . ' AND
732
+                                        exe_exo_id="' . $row['path'].'" AND
733
+                                        exe_user_id="' . $user_id.'" AND
734
+                                        orig_lp_id = "' . $lp_id.'" AND
735
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
736
+                                        c_id = ' . $course_id.' AND
737 737
                                         status <> "incomplete" AND
738
-                                        session_id = ' . $session_id . '
738
+                                        session_id = ' . $session_id.'
739 739
                                      ORDER BY exe_date DESC ';
740 740
 
741 741
                             $resultLastAttempt = Database::query($sql);
@@ -772,13 +772,13 @@  discard block
 block discarded – undo
772 772
                         $title = Security::remove_XSS($title);
773 773
                         $action = null;
774 774
                         if ($type == 'classic') {
775
-                            $action =  '<td>' . $correct_test_link . '</td>';
775
+                            $action = '<td>'.$correct_test_link.'</td>';
776 776
                         }
777 777
 
778 778
                         if ($lp_id == $my_lp_id && false) {
779
-                            $output .= '<tr class =' . $oddclass . '>
780
-                                    <td>' . $extend_link . '</td>
781
-                                    <td colspan="4">' . $title . '</td>
779
+                            $output .= '<tr class ='.$oddclass.'>
780
+                                    <td>' . $extend_link.'</td>
781
+                                    <td colspan="4">' . $title.'</td>
782 782
                                     <td colspan="2">&nbsp;</td>
783 783
                                     <td colspan="2">&nbsp;</td>
784 784
                                     <td colspan="2">&nbsp;</td>
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
804 804
                                 }
805 805
                             } else {
806
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
806
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
807 807
                             }
808 808
 
809 809
                             $output .= '
810 810
                                 <td>'.$extend_link.'</td>
811
-                                <td colspan="4">' . $title . '</td>
812
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
811
+                                <td colspan="4">' . $title.'</td>
812
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
813 813
                                 <td colspan="2">'.$scoreItem.'</td>
814 814
                                 <td colspan="2">'.$time.'</td>
815 815
                                 '.$action.'
@@ -826,10 +826,10 @@  discard block
 block discarded – undo
826 826
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
827 827
                                     $temp[] = '/';
828 828
                                 } else {
829
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
829
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
830 830
                                 }
831 831
                             } else {
832
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
832
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
833 833
                             }
834 834
                             $temp[] = $time;
835 835
                             $csv_content[] = $temp;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
                     $action = null;
842 842
                     if ($type == 'classic') {
843
-                        $action =  '<td></td>';
843
+                        $action = '<td></td>';
844 844
                     }
845 845
 
846 846
                     if ($extend_this_attempt || $extend_all) {
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
                                     <td></td>
878 878
                                     <td></td>
879 879
                                     <td></td>
880
-                                    <td>' . $interaction['order_id'] . '</td>
881
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
882
-                                    <td colspan="2">' . $interaction['status'] . '</td>
880
+                                    <td>' . $interaction['order_id'].'</td>
881
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
882
+                                    <td colspan="2">' . $interaction['status'].'</td>
883 883
                                     <td>' . $interaction['score_raw'].'</td>
884
-                                    <td>' . $interaction['score_max'] .'</td>
884
+                                    <td>' . $interaction['score_max'].'</td>
885 885
                                     <td>' . $interaction['score_min'].'</td>
886 886
                                     '.$action.'
887 887
                                </tr>';
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                     }
891 891
 
892 892
                     // Attempts listing by exercise.
893
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
893
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
894 894
                         // Get attempts of a exercise.
895 895
                         if (!empty($lp_id) &&
896 896
                             !empty($lp_item_id) &&
@@ -905,15 +905,15 @@  discard block
 block discarded – undo
905 905
                             $row_path = Database::fetch_array($res_path);
906 906
 
907 907
                             if (Database::num_rows($res_path) > 0) {
908
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
908
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
909 909
                                         WHERE
910
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
910
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
911 911
                                             status <> "incomplete" AND
912
-                                            exe_user_id="' . $user_id . '" AND
913
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
914
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
915
-                                            c_id = ' . $course_id . '  AND
916
-                                            session_id = ' . $session_id . '
912
+                                            exe_user_id="' . $user_id.'" AND
913
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
914
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
915
+                                            c_id = ' . $course_id.'  AND
916
+                                            session_id = ' . $session_id.'
917 917
                                         ORDER BY exe_date';
918 918
                                 $res_attempts = Database::query($sql);
919 919
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                                         if ($mktime_start_date && $mktime_exe_date) {
932 932
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
933 933
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
934
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
934
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
935 935
                                         } else {
936 936
                                             $time_attemp = ' - ';
937 937
                                         }
@@ -957,33 +957,33 @@  discard block
 block discarded – undo
957 957
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
958 958
                                         }
959 959
 
960
-                                        $output .= '<tr class="' . $oddclass . '" >
960
+                                        $output .= '<tr class="'.$oddclass.'" >
961 961
                                         <td></td>
962
-                                        <td>' . $extend_attempt_link . '</td>
963
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
964
-                                        <td colspan="2">' . $my_lesson_status . '</td>
965
-                                        <td colspan="2">'.$view_score . '</td>
966
-                                        <td colspan="2">'.$time_attemp . '</td>';
962
+                                        <td>' . $extend_attempt_link.'</td>
963
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
964
+                                        <td colspan="2">' . $my_lesson_status.'</td>
965
+                                        <td colspan="2">'.$view_score.'</td>
966
+                                        <td colspan="2">'.$time_attemp.'</td>';
967 967
                                         if ($action == 'classic') {
968 968
                                             if ($origin != 'tracking') {
969 969
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
970 970
                                                     $output .= '<td>
971
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
971
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
972 972
                                                             </td>';
973 973
                                                 } else {
974 974
                                                     $output .= '<td>
975
-                                                            <a href="../exercise/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
976
-                                                            <img src="' . Display::returnIconPath('quiz.png').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
975
+                                                            <a href="../exercise/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
976
+                                                            <img src="' . Display::returnIconPath('quiz.png').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
977 977
                                                             </a></td>';
978 978
                                                 }
979 979
                                             } else {
980 980
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
981 981
                                                     $output .= '<td>
982
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
982
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
983 983
                                                 } else {
984 984
                                                     $output .= '<td>
985
-                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
986
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
985
+                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
986
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
987 987
                                                 }
988 988
                                             }
989 989
                                         }
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
         }
1043 1043
 
1044 1044
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1045
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1045
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1046 1046
 
1047 1047
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1048 1048
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1049 1049
         } else {
1050 1050
             if (is_numeric($total_score)) {
1051
-                $final_score = $total_score . '%';
1051
+                $final_score = $total_score.'%';
1052 1052
             } else {
1053 1053
                 $final_score = $total_score;
1054 1054
             }
@@ -1064,19 +1064,19 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
         $action = null;
1066 1066
         if ($type == 'classic') {
1067
-            $action =  '<td></td>';
1067
+            $action = '<td></td>';
1068 1068
         }
1069 1069
 
1070 1070
         $output .= '<tr class="'.$oddclass.'">
1071 1071
                 <td></td>
1072 1072
                 <td colspan="4">
1073
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1073
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1074 1074
                 </td>
1075 1075
                 <td colspan="2">'.$progress.'%</td>
1076 1076
                 <td colspan="2">
1077 1077
                     ' . $final_score.'
1078 1078
                 </td>
1079
-                <td colspan="2">' . $total_time . '</div>
1079
+                <td colspan="2">' . $total_time.'</div>
1080 1080
                 '.$action.'
1081 1081
            </tr>';
1082 1082
 
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1421 1421
     	if (is_array($user_id)) {
1422 1422
     	    $user_id = array_map('intval', $user_id);
1423
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1423
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1424 1424
     	} else {
1425 1425
     		$user_id = intval($user_id);
1426 1426
     		$condition_user = " AND user_id = $user_id ";
@@ -1456,13 +1456,13 @@  discard block
 block discarded – undo
1456 1456
     {
1457 1457
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1458 1458
     	$sql = 'SELECT login_date
1459
-    	        FROM ' . $tbl_track_login . '
1460
-                WHERE login_user_id = ' . intval($student_id) . '
1459
+    	        FROM ' . $tbl_track_login.'
1460
+                WHERE login_user_id = ' . intval($student_id).'
1461 1461
                 ORDER BY login_date ASC
1462 1462
                 LIMIT 0,1';
1463 1463
 
1464 1464
     	$rs = Database::query($sql);
1465
-    	if (Database::num_rows($rs)>0) {
1465
+    	if (Database::num_rows($rs) > 0) {
1466 1466
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1467 1467
                 return api_convert_and_format_date(
1468 1468
                     $first_login_date,
@@ -1487,8 +1487,8 @@  discard block
 block discarded – undo
1487 1487
     {
1488 1488
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1489 1489
     	$sql = 'SELECT login_date
1490
-    	        FROM ' . $table . '
1491
-                WHERE login_user_id = ' . intval($student_id) . '
1490
+    	        FROM ' . $table.'
1491
+                WHERE login_user_id = ' . intval($student_id).'
1492 1492
                 ORDER BY login_date
1493 1493
                 DESC LIMIT 0,1';
1494 1494
 
@@ -1497,18 +1497,18 @@  discard block
 block discarded – undo
1497 1497
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1498 1498
     			$last_login_date = api_get_local_time($last_login_date);
1499 1499
     			if ($return_timestamp) {
1500
-    				return api_strtotime($last_login_date,'UTC');
1500
+    				return api_strtotime($last_login_date, 'UTC');
1501 1501
     			} else {
1502 1502
     				if (!$warning_message) {
1503 1503
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504 1504
     				} else {
1505
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1505
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1506 1506
     					$currentTimestamp = time();
1507 1507
 
1508 1508
     					//If the last connection is > than 7 days, the text is red
1509 1509
     					//345600 = 7 days in seconds
1510 1510
     					if ($currentTimestamp - $timestamp > 604800) {
1511
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1511
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1512 1512
     					} else {
1513 1513
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1514 1514
     					}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
         $sql = "$select
1544 1544
                 FROM $tbl_track_login
1545 1545
                 WHERE
1546
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1546
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1547 1547
                     login_date < '$date'
1548 1548
                 ";
1549 1549
         $rs = Database::query($sql);
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
                               '.Display::return_icon('messagebox_warning.gif').'
1643 1643
                              </a>'
1644 1644
                             : null;
1645
-    					return $icon. Display::label($last_login_date, 'warning');
1645
+    					return $icon.Display::label($last_login_date, 'warning');
1646 1646
     				} else {
1647 1647
     					return $last_login_date;
1648 1648
     				}
@@ -1677,8 +1677,8 @@  discard block
 block discarded – undo
1677 1677
 
1678 1678
         // Given we're storing in cache, round the start and end times
1679 1679
         // to the lower minute
1680
-        $roundedStart = substr($start, 0, -2) . '00';
1681
-        $roundedStop = substr($stop, 0, -2) . '00';
1680
+        $roundedStart = substr($start, 0, -2).'00';
1681
+        $roundedStop = substr($stop, 0, -2).'00';
1682 1682
         $roundedStart = Database::escape_string($roundedStart);
1683 1683
         $roundedStop = Database::escape_string($roundedStop);
1684 1684
 
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
     	$session_id  = intval($session_id);
1689 1689
     	$count = 0;
1690 1690
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1691
-        $sql =  "SELECT count(*) as count_connections
1691
+        $sql = "SELECT count(*) as count_connections
1692 1692
                 FROM $tbl_track_e_course_access
1693 1693
                 WHERE
1694 1694
                     c_id = $courseId AND
@@ -1702,14 +1702,14 @@  discard block
 block discarded – undo
1702 1702
         if (!empty($cacheAvailable)) {
1703 1703
             $apc = apcu_cache_info(true);
1704 1704
             $apc_end = $apc['start_time'] + $apc['ttl'];
1705
-            $apc_var = api_get_configuration_value('apc_prefix') . 'course_access_' . $courseId . '_' . $session_id . '_' . strtotime($roundedStart) . '_' . strtotime($roundedStop);
1705
+            $apc_var = api_get_configuration_value('apc_prefix').'course_access_'.$courseId.'_'.$session_id.'_'.strtotime($roundedStart).'_'.strtotime($roundedStop);
1706 1706
             if (apcu_exists($apc_var) && (time() < $apc_end) &&
1707 1707
                 apcu_fetch($apc_var) > 0
1708 1708
             ) {
1709 1709
                 $count = apcu_fetch($apc_var);
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
                 }
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
             }
1719 1719
         } else {
1720 1720
             $rs = Database::query($sql);
1721
-            if (Database::num_rows($rs)>0) {
1721
+            if (Database::num_rows($rs) > 0) {
1722 1722
                 $row = Database::fetch_object($rs);
1723 1723
                 $count = $row->count_connections;
1724 1724
             }
@@ -1740,14 +1740,14 @@  discard block
 block discarded – undo
1740 1740
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1741 1741
 
1742 1742
     	$sql = 'SELECT DISTINCT c_id
1743
-                FROM ' . $tbl_course_rel_user . '
1743
+                FROM ' . $tbl_course_rel_user.'
1744 1744
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1745 1745
     	$rs = Database::query($sql);
1746 1746
     	$nb_courses = Database::num_rows($rs);
1747 1747
 
1748 1748
     	if ($include_sessions) {
1749 1749
     		$sql = 'SELECT DISTINCT c_id
1750
-                    FROM ' . $tbl_session_course_rel_user . '
1750
+                    FROM ' . $tbl_session_course_rel_user.'
1751 1751
                     WHERE user_id = ' . $user_id;
1752 1752
     		$rs = Database::query($sql);
1753 1753
     		$nb_courses += Database::num_rows($rs);
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
     		$condition_quiz = "";
1795 1795
     		if (!empty($exercise_id)) {
1796 1796
     			$exercise_id = intval($exercise_id);
1797
-    			$condition_quiz =" AND id = $exercise_id ";
1797
+    			$condition_quiz = " AND id = $exercise_id ";
1798 1798
     		}
1799 1799
 
1800 1800
     		// Compose a filter based on optional session id given
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
                         }
1848 1848
                     }
1849 1849
                     if (!empty($exercise_list)) {
1850
-                        $exercise_id = implode("','",$exercise_list);
1850
+                        $exercise_id = implode("','", $exercise_list);
1851 1851
                     }
1852 1852
     			}
1853 1853
 
@@ -1872,10 +1872,10 @@  discard block
 block discarded – undo
1872 1872
     			$quiz_avg_score = null;
1873 1873
 
1874 1874
     			if (!empty($row['avg_score'])) {
1875
-    				$quiz_avg_score = round($row['avg_score'],2);
1875
+    				$quiz_avg_score = round($row['avg_score'], 2);
1876 1876
     			}
1877 1877
 
1878
-    			if(!empty($row['num_attempts'])) {
1878
+    			if (!empty($row['num_attempts'])) {
1879 1879
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1880 1880
     			}
1881 1881
     			if (is_array($student_id)) {
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
             $row = Database::fetch_row($rs);
2006 2006
             $count = $row[0];
2007 2007
         }
2008
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
2008
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
2009 2009
         return $count;
2010 2010
     }
2011 2011
 
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
                 );
2031 2031
 
2032 2032
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
2033
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
2033
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
2034 2034
                 }
2035 2035
             }
2036 2036
             $result = $result / count($exercise_list);
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
         $query = sprintf($sql, intval($courseId), $sessionId);
2068 2068
         $rs = Database::query($query);
2069 2069
         $teachers = array();
2070
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2070
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2071 2071
             $teachers[] = $teacher;
2072 2072
         }
2073 2073
         $data = array();
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
             $data[] = array(
2192 2192
                 'course' => $course['title'],
2193 2193
                 'session' => $teacher['name'],
2194
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2194
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2195 2195
                 'documents' => $totalDocuments,
2196 2196
                 'links' => $totalLinks,
2197 2197
                 'forums' => $totalForums,
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
             for ($i = 0; $i < count($lpIdList); $i++) {
2255 2255
                 $placeHolders[] = '?';
2256 2256
             }
2257
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2257
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2258 2258
         }
2259 2259
 
2260 2260
         if ($onlySeriousGame) {
@@ -2274,14 +2274,14 @@  discard block
 block discarded – undo
2274 2274
 
2275 2275
         $conditions = [
2276 2276
             " c_id = {$courseInfo['real_id']} ",
2277
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2277
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2278 2278
         ];
2279 2279
 
2280 2280
         $groupBy = 'GROUP BY lp_id';
2281 2281
 
2282 2282
         if (is_array($studentId)) {
2283 2283
             $studentId = array_map('intval', $studentId);
2284
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2284
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2285 2285
 
2286 2286
 
2287 2287
         } else {
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
             // Compose a filter based on optional learning paths list given
2417 2417
             $condition_lp = "";
2418 2418
             if (count($lp_ids) > 0) {
2419
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2419
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2420 2420
             }
2421 2421
 
2422 2422
             // Compose a filter based on optional session id
@@ -2456,9 +2456,9 @@  discard block
 block discarded – undo
2456 2456
             // prepare filter on users
2457 2457
             if (is_array($student_id)) {
2458 2458
                 array_walk($student_id, 'intval');
2459
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2459
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2460 2460
             } else {
2461
-                $condition_user1 =" AND user_id = $student_id ";
2461
+                $condition_user1 = " AND user_id = $student_id ";
2462 2462
             }
2463 2463
 
2464 2464
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
                                     ORDER BY lp_item_id";
2502 2502
                             $res_lp_item = Database::query($sql);
2503 2503
 
2504
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2504
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2505 2505
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2506 2506
 
2507 2507
                                 // Getting the most recent attempt
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
                                         ORDER BY view_count DESC
2525 2525
                                         LIMIT 1";
2526 2526
                                 $res_lp_item_result = Database::query($sql);
2527
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2528
-                                    $list[]= $row_max_score;
2527
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2528
+                                    $list[] = $row_max_score;
2529 2529
                                 }
2530 2530
                             }
2531 2531
                         } else {
@@ -2549,8 +2549,8 @@  discard block
 block discarded – undo
2549 2549
                             if ($debug) echo $sql.'<br />';
2550 2550
                             $res_max_score = Database::query($sql);
2551 2551
 
2552
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2553
-                                $list[]= $row_max_score;
2552
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2553
+                                $list[] = $row_max_score;
2554 2554
                             }
2555 2555
                         }
2556 2556
 
@@ -2565,7 +2565,7 @@  discard block
 block discarded – undo
2565 2565
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2566 2566
                             $score = $row_max_score['score'];
2567 2567
 
2568
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2568
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2569 2569
 
2570 2570
                             if ($row_max_score['item_type'] == 'sco') {
2571 2571
                                 /* Check if it is sco (easier to get max_score)
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
                                 }
2584 2584
                                 // Avoid division by zero errors
2585 2585
                                 if (!empty($max_score)) {
2586
-                                    $lp_partial_total += $score/$max_score;
2586
+                                    $lp_partial_total += $score / $max_score;
2587 2587
                                 }
2588 2588
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2589 2589
                             } else {
@@ -2607,10 +2607,10 @@  discard block
 block discarded – undo
2607 2607
                                         ORDER BY exe_date DESC
2608 2608
                                         LIMIT 1";
2609 2609
 
2610
-                                if ($debug) echo $sql .'<br />';
2610
+                                if ($debug) echo $sql.'<br />';
2611 2611
                                 $result_last_attempt = Database::query($sql);
2612 2612
                                 $num = Database :: num_rows($result_last_attempt);
2613
-                                if ($num > 0 ) {
2613
+                                if ($num > 0) {
2614 2614
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2615 2615
                                     if ($debug) echo $id_last_attempt.'<br />';
2616 2616
 
@@ -2639,13 +2639,13 @@  discard block
 block discarded – undo
2639 2639
                                         $max_score = $row_max_score_bis['maxscore'];
2640 2640
                                     }
2641 2641
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2642
-                                        $lp_partial_total += $score/$max_score;
2642
+                                        $lp_partial_total += $score / $max_score;
2643 2643
                                     }
2644 2644
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2645 2645
                                 }
2646 2646
                             }
2647 2647
 
2648
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2648
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2649 2649
                                 // Normal way
2650 2650
                                 if ($use_max_score[$lp_id]) {
2651 2651
                                     $count_items++;
@@ -2680,8 +2680,8 @@  discard block
 block discarded – undo
2680 2680
                     if ($debug) echo $sql;
2681 2681
                     $result_have_quiz = Database::query($sql);
2682 2682
 
2683
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2684
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2683
+                    if (Database::num_rows($result_have_quiz) > 0) {
2684
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2685 2685
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2686 2686
                             $lp_with_quiz++;
2687 2687
                         }
@@ -2693,7 +2693,7 @@  discard block
 block discarded – undo
2693 2693
 
2694 2694
                 if ($lp_with_quiz != 0) {
2695 2695
                     if (!$return_array) {
2696
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2696
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2697 2697
                         if ($debug) var_dump($score_of_scorm_calculate);
2698 2698
                         if (empty($lp_ids)) {
2699 2699
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2767,9 +2767,9 @@  discard block
 block discarded – undo
2767 2767
 
2768 2768
         if (is_array($student_id)) {
2769 2769
             array_walk($student_id, 'intval');
2770
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2770
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2771 2771
         } else {
2772
-            $conditions[] =" lp_view.user_id = $student_id ";
2772
+            $conditions[] = " lp_view.user_id = $student_id ";
2773 2773
         }
2774 2774
 
2775 2775
         $conditionsToString = implode('AND ', $conditions);
@@ -2823,7 +2823,7 @@  discard block
 block discarded – undo
2823 2823
             // Compose a filter based on optional learning paths list given
2824 2824
             $condition_lp = "";
2825 2825
             if (count($lp_ids) > 0) {
2826
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2826
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2827 2827
             }
2828 2828
 
2829 2829
             // Compose a filter based on optional session id
@@ -2885,7 +2885,7 @@  discard block
 block discarded – undo
2885 2885
 
2886 2886
         if (!empty($course)) {
2887 2887
 
2888
-            $course_id	 = $course['real_id'];
2888
+            $course_id = $course['real_id'];
2889 2889
 
2890 2890
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2891 2891
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2899,8 +2899,8 @@  discard block
 block discarded – undo
2899 2899
             // calculates last connection time
2900 2900
             if ($count_row_lp > 0) {
2901 2901
                 $sql = 'SELECT MAX(start_time)
2902
-                        FROM ' . $t_lpiv . ' AS item_view
2903
-                        INNER JOIN ' . $t_lpv . ' AS view
2902
+                        FROM ' . $t_lpiv.' AS item_view
2903
+                        INNER JOIN ' . $t_lpv.' AS view
2904 2904
                             ON item_view.lp_view_id = view.id
2905 2905
                         WHERE
2906 2906
                             item_view.c_id 		= '.$course_id.' AND
@@ -2936,15 +2936,15 @@  discard block
 block discarded – undo
2936 2936
 
2937 2937
         // At first, courses where $coach_id is coach of the course //
2938 2938
         $sql = 'SELECT session_id, c_id
2939
-                FROM ' . $tbl_session_course_user . '
2939
+                FROM ' . $tbl_session_course_user.'
2940 2940
                 WHERE user_id=' . $coach_id.' AND status=2';
2941 2941
 
2942 2942
         if (api_is_multiple_url_enabled()) {
2943
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2943
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2944 2944
             $access_url_id = api_get_current_access_url_id();
2945 2945
             if ($access_url_id != -1) {
2946 2946
                 $sql = 'SELECT scu.session_id, scu.c_id
2947
-                    FROM ' . $tbl_session_course_user . ' scu
2947
+                    FROM ' . $tbl_session_course_user.' scu
2948 2948
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2949 2949
                     ON (scu.session_id=sru.session_id)
2950 2950
                     WHERE
@@ -2978,28 +2978,28 @@  discard block
 block discarded – undo
2978 2978
 
2979 2979
         // Then, courses where $coach_id is coach of the session    //
2980 2980
         $sql = 'SELECT session_course_user.user_id
2981
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2981
+                FROM ' . $tbl_session_course_user.' as session_course_user
2982 2982
                 INNER JOIN     '.$tbl_session_user.' sru
2983 2983
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2984
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2984
+                INNER JOIN ' . $tbl_session_course.' as session_course
2985 2985
                 ON session_course.c_id = session_course_user.c_id
2986 2986
                 AND session_course_user.session_id = session_course.session_id
2987
-                INNER JOIN ' . $tbl_session . ' as session
2987
+                INNER JOIN ' . $tbl_session.' as session
2988 2988
                 ON session.id = session_course.session_id
2989 2989
                 AND session.id_coach = ' . $coach_id;
2990 2990
         if (api_is_multiple_url_enabled()) {
2991
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2991
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2992 2992
             $access_url_id = api_get_current_access_url_id();
2993
-            if ($access_url_id != -1){
2993
+            if ($access_url_id != -1) {
2994 2994
                 $sql = 'SELECT session_course_user.user_id
2995
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2995
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2996 2996
                         INNER JOIN     '.$tbl_session_user.' sru
2997 2997
                             ON session_course_user.user_id = sru.user_id AND
2998 2998
                                session_course_user.session_id = sru.session_id
2999
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2999
+                        INNER JOIN ' . $tbl_session_course.' as session_course
3000 3000
                             ON session_course.c_id = session_course_user.c_id AND
3001 3001
                             session_course_user.session_id = session_course.session_id
3002
-                        INNER JOIN ' . $tbl_session . ' as session
3002
+                        INNER JOIN ' . $tbl_session.' as session
3003 3003
                             ON session.id = session_course.session_id AND
3004 3004
                             session.id_coach = ' . $coach_id.'
3005 3005
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -3029,8 +3029,8 @@  discard block
 block discarded – undo
3029 3029
 
3030 3030
         $students = [];
3031 3031
         // At first, courses where $coach_id is coach of the course //
3032
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
3033
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
3032
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
3033
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
3034 3034
         $result = Database::query($sql);
3035 3035
 
3036 3036
         while ($a_courses = Database::fetch_array($result)) {
@@ -3040,7 +3040,7 @@  discard block
 block discarded – undo
3040 3040
                     FROM $tbl_session_course_user AS srcru
3041 3041
                     WHERE
3042 3042
                         c_id = '$courseId' AND
3043
-                        session_id = '" . $id_session . "'";
3043
+                        session_id = '".$id_session."'";
3044 3044
             $rs = Database::query($sql);
3045 3045
             while ($row = Database::fetch_array($rs)) {
3046 3046
                 $students[$row['user_id']] = $row['user_id'];
@@ -3048,15 +3048,15 @@  discard block
 block discarded – undo
3048 3048
         }
3049 3049
 
3050 3050
         // Then, courses where $coach_id is coach of the session
3051
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3052
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3051
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3052
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3053 3053
         $result = Database::query($sql);
3054 3054
 
3055 3055
         //He is the session_coach so we select all the users in the session
3056 3056
         if (Database::num_rows($result) > 0) {
3057 3057
             $sql = 'SELECT DISTINCT srcru.user_id
3058
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3059
-                    WHERE session_id="' . $id_session . '"';
3058
+                    FROM ' . $tbl_session_course_user.' AS srcru
3059
+                    WHERE session_id="' . $id_session.'"';
3060 3060
             $result = Database::query($sql);
3061 3061
             while ($row = Database::fetch_array($result)) {
3062 3062
                 $students[$row['user_id']] = $row['user_id'];
@@ -3083,8 +3083,8 @@  discard block
 block discarded – undo
3083 3083
 
3084 3084
         // At first, courses where $coach_id is coach of the course //
3085 3085
 
3086
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3087
-                WHERE user_id=' . $coach_id .' AND status=2';
3086
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3087
+                WHERE user_id=' . $coach_id.' AND status=2';
3088 3088
         $result = Database::query($sql);
3089 3089
         if (Database::num_rows($result) > 0) {
3090 3090
             return true;
@@ -3092,12 +3092,12 @@  discard block
 block discarded – undo
3092 3092
 
3093 3093
         // Then, courses where $coach_id is coach of the session
3094 3094
         $sql = 'SELECT session_course_user.user_id
3095
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3096
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3095
+                FROM ' . $tbl_session_course_user.' as session_course_user
3096
+                INNER JOIN ' . $tbl_session_course.' as session_course
3097 3097
                     ON session_course.c_id = session_course_user.c_id
3098
-                INNER JOIN ' . $tbl_session . ' as session
3098
+                INNER JOIN ' . $tbl_session.' as session
3099 3099
                     ON session.id = session_course.session_id
3100
-                    AND session.id_coach = ' . $coach_id . '
3100
+                    AND session.id_coach = ' . $coach_id.'
3101 3101
                 WHERE user_id = ' . $student_id;
3102 3102
         $result = Database::query($sql);
3103 3103
         if (Database::num_rows($result) > 0) {
@@ -3129,16 +3129,16 @@  discard block
 block discarded – undo
3129 3129
         // At first, courses where $coach_id is coach of the course.
3130 3130
 
3131 3131
         $sql = 'SELECT DISTINCT c.code
3132
-                FROM ' . $tbl_session_course_user . ' sc
3132
+                FROM ' . $tbl_session_course_user.' sc
3133 3133
                 INNER JOIN '.$tbl_course.' c
3134 3134
                 ON (c.id = sc.c_id)
3135 3135
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3136 3136
 
3137 3137
         if (api_is_multiple_url_enabled()) {
3138 3138
             $access_url_id = api_get_current_access_url_id();
3139
-            if ($access_url_id != -1){
3139
+            if ($access_url_id != -1) {
3140 3140
                 $sql = 'SELECT DISTINCT c.code
3141
-                        FROM ' . $tbl_session_course_user . ' scu
3141
+                        FROM ' . $tbl_session_course_user.' scu
3142 3142
                         INNER JOIN '.$tbl_course.' c
3143 3143
                         ON (c.code = scu.c_id)
3144 3144
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
         }
3152 3152
 
3153 3153
         if (!empty($id_session)) {
3154
-            $sql .= ' AND session_id=' . $id_session;
3154
+            $sql .= ' AND session_id='.$id_session;
3155 3155
         }
3156 3156
 
3157 3157
         $courseList = array();
@@ -3163,25 +3163,25 @@  discard block
 block discarded – undo
3163 3163
         // Then, courses where $coach_id is coach of the session
3164 3164
 
3165 3165
         $sql = 'SELECT DISTINCT course.code
3166
-                FROM ' . $tbl_session_course . ' as session_course
3167
-                INNER JOIN ' . $tbl_session . ' as session
3166
+                FROM ' . $tbl_session_course.' as session_course
3167
+                INNER JOIN ' . $tbl_session.' as session
3168 3168
                     ON session.id = session_course.session_id
3169
-                    AND session.id_coach = ' . $coach_id . '
3170
-                INNER JOIN ' . $tbl_course . ' as course
3169
+                    AND session.id_coach = ' . $coach_id.'
3170
+                INNER JOIN ' . $tbl_course.' as course
3171 3171
                     ON course.id = session_course.c_id';
3172 3172
 
3173 3173
         if (api_is_multiple_url_enabled()) {
3174 3174
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3175 3175
             $access_url_id = api_get_current_access_url_id();
3176
-            if ($access_url_id != -1){
3176
+            if ($access_url_id != -1) {
3177 3177
                 $sql = 'SELECT DISTINCT c.code
3178
-                    FROM ' . $tbl_session_course . ' as session_course
3178
+                    FROM ' . $tbl_session_course.' as session_course
3179 3179
                     INNER JOIN '.$tbl_course.' c
3180 3180
                     ON (c.id = session_course.c_id)
3181
-                    INNER JOIN ' . $tbl_session . ' as session
3181
+                    INNER JOIN ' . $tbl_session.' as session
3182 3182
                     ON session.id = session_course.session_id
3183
-                        AND session.id_coach = ' . $coach_id . '
3184
-                    INNER JOIN ' . $tbl_course . ' as course
3183
+                        AND session.id_coach = ' . $coach_id.'
3184
+                    INNER JOIN ' . $tbl_course.' as course
3185 3185
                         ON course.id = session_course.c_id
3186 3186
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3187 3187
                     ON (course_rel_url.c_id = c.id)';
@@ -3189,12 +3189,12 @@  discard block
 block discarded – undo
3189 3189
         }
3190 3190
 
3191 3191
         if (!empty ($id_session)) {
3192
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3192
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3193 3193
             if (api_is_multiple_url_enabled())
3194
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3195
-        }  else {
3194
+            $sql .= ' AND access_url_id = '.$access_url_id;
3195
+        } else {
3196 3196
             if (api_is_multiple_url_enabled())
3197
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3197
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3198 3198
         }
3199 3199
 
3200 3200
         $result = Database::query($sql);
@@ -3250,7 +3250,7 @@  discard block
 block discarded – undo
3250 3250
             }
3251 3251
         }
3252 3252
 
3253
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3253
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3254 3254
         $access_url_id = api_get_current_access_url_id();
3255 3255
 
3256 3256
         $sql = "
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
             // table definition
3375 3375
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3376 3376
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3377
-            $course_id	 = $a_course['real_id'];
3377
+            $course_id = $a_course['real_id'];
3378 3378
             if (is_array($student_id)) {
3379 3379
                 $studentList = array_map('intval', $student_id);
3380 3380
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3427,7 +3427,7 @@  discard block
 block discarded – undo
3427 3427
         $a_course = CourseManager::get_course_information($course_code);
3428 3428
         if (!empty($a_course)) {
3429 3429
             $course_id = $a_course['real_id'];
3430
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3430
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3431 3431
         }
3432 3432
 
3433 3433
         // table definition
@@ -3436,14 +3436,14 @@  discard block
 block discarded – undo
3436 3436
 
3437 3437
         if (is_array($student_id)) {
3438 3438
             $studentList = array_map('intval', $student_id);
3439
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3439
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3440 3440
         } else {
3441 3441
             $student_id = intval($student_id);
3442
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3442
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3443 3443
         }
3444 3444
         if (isset($session_id)) {
3445 3445
             $session_id = intval($session_id);
3446
-            $conditions[]= " pub.session_id = $session_id ";
3446
+            $conditions[] = " pub.session_id = $session_id ";
3447 3447
         }
3448 3448
         $conditionToString = implode('AND', $conditions);
3449 3449
 
@@ -3480,10 +3480,10 @@  discard block
 block discarded – undo
3480 3480
         $conditions = array();
3481 3481
         if (is_array($student_id)) {
3482 3482
             $studentList = array_map('intval', $student_id);
3483
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3483
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3484 3484
         } else {
3485 3485
             $student_id = intval($student_id);
3486
-            $conditions[]= " post.poster_id = '$student_id' ";
3486
+            $conditions[] = " post.poster_id = '$student_id' ";
3487 3487
         }
3488 3488
 
3489 3489
         $conditionsToString = implode('AND ', $conditions);
@@ -3509,13 +3509,13 @@  discard block
 block discarded – undo
3509 3509
         if (!empty($courseInfo)) {
3510 3510
             $forums = get_forums('', $courseCode, true, $session_id);
3511 3511
             $course_id = $courseInfo['real_id'];
3512
-            $conditions[]= " post.c_id  = $course_id ";
3512
+            $conditions[] = " post.c_id  = $course_id ";
3513 3513
         }
3514 3514
 
3515 3515
         if (!empty($forums)) {
3516 3516
             $idList = array_column($forums, 'forum_id');
3517 3517
             $idListToString = implode("', '", $idList);
3518
-            $conditions[]= " post.forum_id  IN ('$idListToString')";
3518
+            $conditions[] = " post.forum_id  IN ('$idListToString')";
3519 3519
         }
3520 3520
 
3521 3521
         $conditionsToString = implode('AND ', $conditions);
@@ -3550,7 +3550,7 @@  discard block
 block discarded – undo
3550 3550
             $condition_session = '';
3551 3551
             if (isset($session_id)) {
3552 3552
                 $session_id = intval($session_id);
3553
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3553
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3554 3554
             }
3555 3555
 
3556 3556
             $course_id = $courseInfo['real_id'];
@@ -3606,7 +3606,7 @@  discard block
 block discarded – undo
3606 3606
         $condition_session = '';
3607 3607
         if (isset($session_id)) {
3608 3608
             $session_id = intval($session_id);
3609
-            $condition_session = ' AND f.session_id = '. $session_id;
3609
+            $condition_session = ' AND f.session_id = '.$session_id;
3610 3610
         }
3611 3611
 
3612 3612
         $groupId = intval($groupId);
@@ -3667,7 +3667,7 @@  discard block
 block discarded – undo
3667 3667
         $condition_session = '';
3668 3668
         if (isset($session_id)) {
3669 3669
              $session_id = intval($session_id);
3670
-             $condition_session = ' AND f.session_id = '. $session_id;
3670
+             $condition_session = ' AND f.session_id = '.$session_id;
3671 3671
         }
3672 3672
 
3673 3673
         $groupId = intval($groupId);
@@ -3746,7 +3746,7 @@  discard block
 block discarded – undo
3746 3746
     {
3747 3747
         $student_id = intval($student_id);
3748 3748
         $courseId = intval($courseId);
3749
-        $session_id    = intval($session_id);
3749
+        $session_id = intval($session_id);
3750 3750
         $date_time  = '';
3751 3751
 
3752 3752
         // table definition
@@ -3815,7 +3815,7 @@  discard block
 block discarded – undo
3815 3815
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3816 3816
 
3817 3817
         $sql = 'SELECT 1
3818
-                FROM ' . $table . '
3818
+                FROM ' . $table.'
3819 3819
                 WHERE down_user_id = '.$student_id.'
3820 3820
                 AND c_id  = "'.$courseId.'"
3821 3821
                 AND down_session_id = '.$session_id.' ';
@@ -3893,30 +3893,30 @@  discard block
 block discarded – undo
3893 3893
                 '.$inner.'
3894 3894
                 WHERE c.id = '.$courseId.'
3895 3895
                 GROUP BY stats_login.user_id
3896
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3896
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3897 3897
 
3898 3898
         if ($since == 'never') {
3899 3899
             if (empty($session_id)) {
3900 3900
                 $sql = 'SELECT course_user.user_id
3901
-                        FROM ' . $table_course_rel_user . ' course_user
3902
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3901
+                        FROM ' . $table_course_rel_user.' course_user
3902
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3903 3903
                         ON course_user.user_id = stats_login.user_id AND
3904
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3905
-                        INNER JOIN ' . $tableCourse . ' c
3904
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3905
+                        INNER JOIN ' . $tableCourse.' c
3906 3906
                         ON (c.id = course_user.c_id)
3907 3907
                         WHERE
3908
-                            course_user.c_id = ' . $courseId . ' AND
3908
+                            course_user.c_id = ' . $courseId.' AND
3909 3909
                             stats_login.login_course_date IS NULL
3910 3910
                         GROUP BY course_user.user_id';
3911 3911
             } else {
3912 3912
                 $sql = 'SELECT session_course_user.user_id
3913 3913
                         FROM '.$tbl_session_course_user.' session_course_user
3914
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3914
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3915 3915
                         ON session_course_user.user_id = stats_login.user_id
3916
-                        INNER JOIN ' . $tableCourse . ' c
3916
+                        INNER JOIN ' . $tableCourse.' c
3917 3917
                         ON (c.id = session_course_user.c_id)
3918 3918
                         WHERE
3919
-                            session_course_user.c_id = ' . $courseId . ' AND
3919
+                            session_course_user.c_id = ' . $courseId.' AND
3920 3920
                             stats_login.login_course_date IS NULL
3921 3921
                         GROUP BY session_course_user.user_id';
3922 3922
             }
@@ -3924,7 +3924,7 @@  discard block
 block discarded – undo
3924 3924
 
3925 3925
         $rs = Database::query($sql);
3926 3926
         $inactive_users = array();
3927
-        while($user = Database::fetch_array($rs)) {
3927
+        while ($user = Database::fetch_array($rs)) {
3928 3928
             $inactive_users[] = $user['user_id'];
3929 3929
         }
3930 3930
 
@@ -3946,10 +3946,10 @@  discard block
 block discarded – undo
3946 3946
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3947 3947
 
3948 3948
         $sql = 'SELECT '.$student_id.'
3949
-                FROM ' . $table . '
3949
+                FROM ' . $table.'
3950 3950
                 WHERE
3951
-                    access_user_id=' . $student_id . ' AND
3952
-                    c_id="' . $courseId . '" AND
3951
+                    access_user_id=' . $student_id.' AND
3952
+                    c_id="' . $courseId.'" AND
3953 3953
                     access_session_id = "'.$session_id.'" ';
3954 3954
 
3955 3955
         $rs = Database::query($sql);
@@ -3967,13 +3967,13 @@  discard block
 block discarded – undo
3967 3967
     {
3968 3968
         $hr_dept_id = intval($hr_dept_id);
3969 3969
         $a_students = array();
3970
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3970
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3971 3971
 
3972 3972
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3973 3973
                 WHERE hr_dept_id='.$hr_dept_id;
3974 3974
         $rs = Database::query($sql);
3975 3975
 
3976
-        while($user = Database :: fetch_array($rs)) {
3976
+        while ($user = Database :: fetch_array($rs)) {
3977 3977
             $a_students[$user['user_id']] = $user['user_id'];
3978 3978
         }
3979 3979
 
@@ -3998,7 +3998,7 @@  discard block
 block discarded – undo
3998 3998
         $condition_session     = '';
3999 3999
         if (isset($session_id)) {
4000 4000
             $session_id = intval($session_id);
4001
-            $condition_session = ' AND access_session_id = '. $session_id;
4001
+            $condition_session = ' AND access_session_id = '.$session_id;
4002 4002
         }
4003 4003
         $sql = "SELECT
4004 4004
                     access_tool,
@@ -4110,7 +4110,7 @@  discard block
 block discarded – undo
4110 4110
             if (!empty($date_from) && !empty($date_to)) {
4111 4111
                 $fieldStartDate = $fields['start_date'];
4112 4112
                 if (!isset($fields['end_date'])) {
4113
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4113
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4114 4114
                 } else {
4115 4115
                     $fieldEndDate = $fields['end_date'];
4116 4116
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4126,12 +4126,12 @@  discard block
 block discarded – undo
4126 4126
                 $where
4127 4127
                 GROUP BY %s";
4128 4128
             $sql = sprintf($sql,
4129
-                $fields['user'],    //user field
4130
-                $tableName,         //FROM
4131
-                $fields['course'],  //course condition
4132
-                $course['real_id'],    //course condition
4133
-                $fields['user'],    //user condition
4134
-                $userId,            //user condition
4129
+                $fields['user'], //user field
4130
+                $tableName, //FROM
4131
+                $fields['course'], //course condition
4132
+                $course['real_id'], //course condition
4133
+                $fields['user'], //user condition
4134
+                $userId, //user condition
4135 4135
                 $fields['user']     //GROUP BY
4136 4136
                 );
4137 4137
             $rs = Database::query($sql);
@@ -4139,7 +4139,7 @@  discard block
 block discarded – undo
4139 4139
             //iterate query
4140 4140
             if (Database::num_rows($rs) > 0) {
4141 4141
                 while ($row = Database::fetch_array($rs)) {
4142
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4142
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4143 4143
                 }
4144 4144
             }
4145 4145
         }
@@ -4162,11 +4162,11 @@  discard block
 block discarded – undo
4162 4162
         $courseId = api_get_course_int_id($course_code);
4163 4163
         $data = array();
4164 4164
 
4165
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4165
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4166 4166
         $condition_session = '';
4167 4167
         $session_id = intval($session_id);
4168 4168
         if (!empty($session_id)) {
4169
-            $condition_session = ' AND down_session_id = '. $session_id;
4169
+            $condition_session = ' AND down_session_id = '.$session_id;
4170 4170
         }
4171 4171
         $sql = "SELECT 
4172 4172
                     down_doc_path, 
@@ -4354,7 +4354,7 @@  discard block
 block discarded – undo
4354 4354
 
4355 4355
             $final_course_data = array();
4356 4356
 
4357
-            foreach($my_course_data as $course_id => $value) {
4357
+            foreach ($my_course_data as $course_id => $value) {
4358 4358
                 $final_course_data[$course_id] = $course_list[$course_id];
4359 4359
             }
4360 4360
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4377,7 +4377,7 @@  discard block
 block discarded – undo
4377 4377
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4378 4378
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4379 4379
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4380
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4380
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4381 4381
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4382 4382
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4383 4383
                         </tr>';
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
             $all_exercise_start_time = array();
4467 4467
 
4468 4468
             foreach ($course_in_session as $my_session_id => $session_data) {
4469
-                $course_list  = $session_data['course_list'];
4469
+                $course_list = $session_data['course_list'];
4470 4470
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4471 4471
                 $exercise_graph_name_list = array();
4472 4472
                 //$user_results = array();
@@ -4511,20 +4511,20 @@  discard block
 block discarded – undo
4511 4511
 
4512 4512
                             $score = 0;
4513 4513
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4514
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4514
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4515 4515
                             }
4516 4516
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4517 4517
                             $all_exercise_start_time[] = $time;
4518 4518
                             $my_results[] = $score;
4519
-                            if (count($exercise_list)<=10) {
4519
+                            if (count($exercise_list) <= 10) {
4520 4520
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4521
-                                $exercise_graph_name_list[]= $title;
4521
+                                $exercise_graph_name_list[] = $title;
4522 4522
                                 $all_exercise_graph_name_list[] = $title;
4523 4523
                             } else {
4524 4524
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4525 4525
                                 $title = cut($exercise_data['title'], 30);
4526
-                                $exercise_graph_name_list[]= $title;
4527
-                                $all_exercise_graph_name_list[]= $title;
4526
+                                $exercise_graph_name_list[] = $title;
4527
+                                $all_exercise_graph_name_list[] = $title;
4528 4528
                             }
4529 4529
                         }
4530 4530
                     }
@@ -4557,7 +4557,7 @@  discard block
 block discarded – undo
4557 4557
             }
4558 4558
 
4559 4559
             $html .= Display::page_subheader(
4560
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4560
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4561 4561
             );
4562 4562
 
4563 4563
             $html .= '<div class="table-responsive">';
@@ -4611,7 +4611,7 @@  discard block
 block discarded – undo
4611 4611
                                 $courseInfo['real_id'],
4612 4612
                                 $my_session_id
4613 4613
                             );
4614
-                            if ($attempts > 1)  {
4614
+                            if ($attempts > 1) {
4615 4615
                                 $answered_exercises++;
4616 4616
                             }
4617 4617
                         }
@@ -4624,7 +4624,7 @@  discard block
 block discarded – undo
4624 4624
                     $all_average += $average;
4625 4625
                 }
4626 4626
 
4627
-                $all_average = $all_average /  count($course_list);
4627
+                $all_average = $all_average / count($course_list);
4628 4628
 
4629 4629
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4630 4630
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4650,16 +4650,16 @@  discard block
 block discarded – undo
4650 4650
             }
4651 4651
             $html .= '</tbody>';
4652 4652
             $html .= '</table></div><br />';
4653
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4653
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4654 4654
 
4655 4655
             // Checking selected session.
4656 4656
 
4657 4657
             if (isset($_GET['session_id'])) {
4658 4658
                 $session_id_from_get = intval($_GET['session_id']);
4659
-                $session_data 	= $course_in_session[$session_id_from_get];
4660
-                $course_list 	= $session_data['course_list'];
4659
+                $session_data = $course_in_session[$session_id_from_get];
4660
+                $course_list = $session_data['course_list'];
4661 4661
 
4662
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4662
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4663 4663
 
4664 4664
                 $html .= '<div class="table-responsive">';
4665 4665
                 $html .= '<table class="table table-hover table-striped">';
@@ -4668,15 +4668,15 @@  discard block
 block discarded – undo
4668 4668
                     <thead>
4669 4669
                     <tr>
4670 4670
                       <th width="300px">'.get_lang('Course').'</th>
4671
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4672
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4673
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4674
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4675
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4676
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4677
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4678
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4679
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4671
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4672
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4673
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4674
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4675
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4676
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4677
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4678
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4679
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4680 4680
                     </tr>
4681 4681
                     </thead>
4682 4682
                     <tbody>
@@ -4695,14 +4695,14 @@  discard block
 block discarded – undo
4695 4695
                         $count_exercises = count($exercises);
4696 4696
                     }
4697 4697
                     $answered_exercises = 0;
4698
-                    foreach($exercises as $exercise_item) {
4698
+                    foreach ($exercises as $exercise_item) {
4699 4699
                         $attempts = Event::count_exercise_attempts_by_user(
4700 4700
                             api_get_user_id(),
4701 4701
                             $exercise_item['id'],
4702 4702
                             $courseId,
4703 4703
                             $session_id_from_get
4704 4704
                         );
4705
-                        if ($attempts > 1)  {
4705
+                        if ($attempts > 1) {
4706 4706
                             $answered_exercises++;
4707 4707
                         }
4708 4708
                     }
@@ -4711,7 +4711,7 @@  discard block
 block discarded – undo
4711 4711
 
4712 4712
                     // Average
4713 4713
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4714
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4714
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4715 4715
 
4716 4716
                     $stats_array[$course_code] = array(
4717 4717
                         'exercises' => $count_exercises,
@@ -4788,7 +4788,7 @@  discard block
 block discarded – undo
4788 4788
 
4789 4789
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4790 4790
                         $details = '<a href="#">';
4791
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4791
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4792 4792
                     } else {
4793 4793
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4794 4794
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4888,7 +4888,7 @@  discard block
 block discarded – undo
4888 4888
                     );
4889 4889
 
4890 4890
                     $html .= '<tr class="row_even">';
4891
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4891
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4892 4892
 
4893 4893
                     if ($visible_return['value'] == true) {
4894 4894
                         $exercices['title'] = Display::url(
@@ -4917,7 +4917,7 @@  discard block
 block discarded – undo
4917 4917
                         );
4918 4918
 
4919 4919
                         $latest_attempt_url = '';
4920
-                        $best_score = $position = $percentage_score_result  = '-';
4920
+                        $best_score = $position = $percentage_score_result = '-';
4921 4921
                         $graph = $normal_graph = null;
4922 4922
 
4923 4923
                         // Getting best results
@@ -4949,11 +4949,11 @@  discard block
 block discarded – undo
4949 4949
                                 $weighting      = $exercise_stat['exe_weighting'];
4950 4950
                                 $exe_id         = $exercise_stat['exe_id'];
4951 4951
 
4952
-                                $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;
4952
+                                $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;
4953 4953
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4954 4954
                                 $my_score = 0;
4955 4955
                                 if (!empty($weighting) && intval($weighting) != 0) {
4956
-                                    $my_score = $score/$weighting;
4956
+                                    $my_score = $score / $weighting;
4957 4957
                                 }
4958 4958
                                 //@todo this function slows the page
4959 4959
                                 if (is_int($user_list)) {
@@ -4967,14 +4967,14 @@  discard block
 block discarded – undo
4967 4967
                         }
4968 4968
                         $html .= Display::div(
4969 4969
                             $normal_graph,
4970
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4970
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4971 4971
                         );
4972 4972
 
4973 4973
                         if (empty($graph)) {
4974 4974
                             $graph = '-';
4975 4975
                         } else {
4976 4976
                             $graph = Display::url(
4977
-                                '<img src="' . $graph . '" >',
4977
+                                '<img src="'.$graph.'" >',
4978 4978
                                 $normal_graph,
4979 4979
                                 array(
4980 4980
                                     'id' => $exercices['id'],
@@ -5008,7 +5008,7 @@  discard block
 block discarded – undo
5008 5008
 
5009 5009
             // LP table results
5010 5010
             $html .= '<div class="table-responsive">';
5011
-            $html .='<table class="table table-striped table-hover">';
5011
+            $html .= '<table class="table table-striped table-hover">';
5012 5012
             $html .= '<thead><tr>';
5013 5013
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
5014 5014
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -5044,7 +5044,7 @@  discard block
 block discarded – undo
5044 5044
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
5045 5045
 
5046 5046
                     $html .= '<tr class="row_even">';
5047
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5047
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5048 5048
 
5049 5049
                     if ($learnpath['lp_visibility'] == 0) {
5050 5050
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -5063,7 +5063,7 @@  discard block
 block discarded – undo
5063 5063
                     if (!empty($last_connection_in_lp)) {
5064 5064
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5065 5065
                     }
5066
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5066
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5067 5067
                     $html .= "</tr>";
5068 5068
                 }
5069 5069
             } else {
@@ -5073,7 +5073,7 @@  discard block
 block discarded – undo
5073 5073
                         </td>
5074 5074
                       </tr>';
5075 5075
             }
5076
-            $html .='</tbody></table></div>';
5076
+            $html .= '</tbody></table></div>';
5077 5077
 
5078 5078
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5079 5079
         }
@@ -5102,7 +5102,7 @@  discard block
 block discarded – undo
5102 5102
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5103 5103
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5104 5104
         $myData->setAxisUnit(0, '%');
5105
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5105
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5106 5106
         // Cache definition
5107 5107
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5108 5108
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5110,9 +5110,9 @@  discard block
 block discarded – undo
5110 5110
 
5111 5111
         if ($myCache->isInCache($chartHash)) {
5112 5112
             //if we already created the img
5113
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5113
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5114 5114
             $myCache->saveFromCache($chartHash, $imgPath);
5115
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5115
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5116 5116
         } else {
5117 5117
             /* Define width, height and angle */
5118 5118
             $mainWidth = 860;
@@ -5141,7 +5141,7 @@  discard block
 block discarded – undo
5141 5141
             /* Set the default font */
5142 5142
             $myPicture->setFontProperties(
5143 5143
                 array(
5144
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5144
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5145 5145
                     'FontSize' => 10)
5146 5146
             );
5147 5147
             /* Write the chart title */
@@ -5158,7 +5158,7 @@  discard block
 block discarded – undo
5158 5158
             /* Set the default font */
5159 5159
             $myPicture->setFontProperties(
5160 5160
                 array(
5161
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5161
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5162 5162
                     'FontSize' => 6
5163 5163
                 )
5164 5164
             );
@@ -5200,7 +5200,7 @@  discard block
 block discarded – undo
5200 5200
             /* Draw the line chart */
5201 5201
             $myPicture->setFontProperties(
5202 5202
                 array(
5203
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5203
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5204 5204
                     'FontSize' => 10
5205 5205
                 )
5206 5206
             );
@@ -5233,12 +5233,12 @@  discard block
 block discarded – undo
5233 5233
             );
5234 5234
 
5235 5235
             $myCache->writeToCache($chartHash, $myPicture);
5236
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5236
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5237 5237
             $myCache->saveFromCache($chartHash, $imgPath);
5238
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5238
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5239 5239
         }
5240 5240
 
5241
-        $html = '<img src="' . $imgPath . '">';
5241
+        $html = '<img src="'.$imgPath.'">';
5242 5242
 
5243 5243
         return $html;
5244 5244
     }
@@ -5259,12 +5259,12 @@  discard block
 block discarded – undo
5259 5259
 
5260 5260
         foreach ($attempts as $attempt) {
5261 5261
             if (api_get_user_id() == $attempt['exe_user_id']) {
5262
-                if ($attempt['exe_weighting'] != 0 ) {
5263
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5262
+                if ($attempt['exe_weighting'] != 0) {
5263
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5264 5264
                 }
5265 5265
             } else {
5266
-                if ($attempt['exe_weighting'] != 0 ) {
5267
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5266
+                if ($attempt['exe_weighting'] != 0) {
5267
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5268 5268
                 }
5269 5269
             }
5270 5270
         }
@@ -5273,27 +5273,27 @@  discard block
 block discarded – undo
5273 5273
         rsort($my_exercise_result_array);
5274 5274
         $my_exercise_result = 0;
5275 5275
         if (isset($my_exercise_result_array[0])) {
5276
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5276
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5277 5277
         }
5278 5278
 
5279 5279
         $max     = 100;
5280
-        $pieces  = 5 ;
5280
+        $pieces  = 5;
5281 5281
         $part    = round($max / $pieces);
5282 5282
         $x_axis = array();
5283 5283
         $final_array = array();
5284 5284
         $my_final_array = array();
5285 5285
 
5286
-        for ($i=1; $i <=$pieces; $i++) {
5286
+        for ($i = 1; $i <= $pieces; $i++) {
5287 5287
             $sum = 1;
5288 5288
             if ($i == 1) {
5289 5289
                 $sum = 0;
5290 5290
             }
5291
-            $min = ($i-1)*$part + $sum;
5292
-            $max = ($i)*$part;
5293
-            $x_axis[]= $min." - ".$max;
5291
+            $min = ($i - 1) * $part + $sum;
5292
+            $max = ($i) * $part;
5293
+            $x_axis[] = $min." - ".$max;
5294 5294
             $count = 0;
5295
-            foreach($exercise_result as $result) {
5296
-                $percentage = $result*100;
5295
+            foreach ($exercise_result as $result) {
5296
+                $percentage = $result * 100;
5297 5297
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5298 5298
                 if ($percentage >= $min && $percentage <= $max) {
5299 5299
                     //echo ' is > ';
@@ -5301,7 +5301,7 @@  discard block
 block discarded – undo
5301 5301
                 }
5302 5302
             }
5303 5303
             //echo '<br />';
5304
-            $final_array[]= $count;
5304
+            $final_array[] = $count;
5305 5305
 
5306 5306
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5307 5307
                 $my_final_array[] = 1;
@@ -5311,9 +5311,9 @@  discard block
 block discarded – undo
5311 5311
         }
5312 5312
 
5313 5313
         //Fix to remove the data of the user with my data
5314
-        for($i = 0; $i<=count($my_final_array); $i++) {
5314
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5315 5315
             if (!empty($my_final_array[$i])) {
5316
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5316
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5317 5317
                 $final_array[$i] = 0;
5318 5318
             }
5319 5319
         }
@@ -5323,16 +5323,16 @@  discard block
 block discarded – undo
5323 5323
         $dataSet->addPoints($final_array, 'Serie1');
5324 5324
         $dataSet->addPoints($my_final_array, 'Serie2');
5325 5325
         $dataSet->normalize(100, "%");
5326
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5326
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5327 5327
 
5328 5328
         // Cache definition
5329 5329
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5330 5330
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5331 5331
         $chartHash = $myCache->getHash($dataSet);
5332 5332
         if ($myCache->isInCache($chartHash)) {
5333
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5333
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5334 5334
             $myCache->saveFromCache($chartHash, $imgPath);
5335
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5335
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5336 5336
         } else {
5337 5337
             /* Create the pChart object */
5338 5338
             $widthSize = 80;
@@ -5348,7 +5348,7 @@  discard block
 block discarded – undo
5348 5348
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5349 5349
 
5350 5350
             /* Set the default font */
5351
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5351
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5352 5352
 
5353 5353
             /* Do not write the chart title */
5354 5354
 
@@ -5412,9 +5412,9 @@  discard block
 block discarded – undo
5412 5412
 
5413 5413
             /* Save and write in cache */
5414 5414
             $myCache->writeToCache($chartHash, $myPicture);
5415
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5415
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5416 5416
             $myCache->saveFromCache($chartHash, $imgPath);
5417
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5417
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5418 5418
         }
5419 5419
 
5420 5420
         return $imgPath;
@@ -5434,12 +5434,12 @@  discard block
 block discarded – undo
5434 5434
         }
5435 5435
         foreach ($attempts as $attempt) {
5436 5436
             if (api_get_user_id() == $attempt['exe_user_id']) {
5437
-                if ($attempt['exe_weighting'] != 0 ) {
5438
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5437
+                if ($attempt['exe_weighting'] != 0) {
5438
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5439 5439
                 }
5440 5440
             } else {
5441
-                if ($attempt['exe_weighting'] != 0 ) {
5442
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5441
+                if ($attempt['exe_weighting'] != 0) {
5442
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5443 5443
                 }
5444 5444
             }
5445 5445
         }
@@ -5448,32 +5448,32 @@  discard block
 block discarded – undo
5448 5448
         rsort($my_exercise_result_array);
5449 5449
         $my_exercise_result = 0;
5450 5450
         if (isset($my_exercise_result_array[0])) {
5451
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5451
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5452 5452
         }
5453 5453
 
5454 5454
         $max = 100;
5455
-        $pieces = 5 ;
5455
+        $pieces = 5;
5456 5456
         $part = round($max / $pieces);
5457 5457
         $x_axis = array();
5458 5458
         $final_array = array();
5459 5459
         $my_final_array = array();
5460 5460
 
5461
-        for ($i=1; $i <=$pieces; $i++) {
5461
+        for ($i = 1; $i <= $pieces; $i++) {
5462 5462
             $sum = 1;
5463 5463
             if ($i == 1) {
5464 5464
                 $sum = 0;
5465 5465
             }
5466
-            $min = ($i-1)*$part + $sum;
5467
-            $max = ($i)*$part;
5468
-            $x_axis[]= $min." - ".$max;
5466
+            $min = ($i - 1) * $part + $sum;
5467
+            $max = ($i) * $part;
5468
+            $x_axis[] = $min." - ".$max;
5469 5469
             $count = 0;
5470
-            foreach($exercise_result as $result) {
5471
-                $percentage = $result*100;
5470
+            foreach ($exercise_result as $result) {
5471
+                $percentage = $result * 100;
5472 5472
                 if ($percentage >= $min && $percentage <= $max) {
5473 5473
                     $count++;
5474 5474
                 }
5475 5475
             }
5476
-            $final_array[]= $count;
5476
+            $final_array[] = $count;
5477 5477
 
5478 5478
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5479 5479
                 $my_final_array[] = 1;
@@ -5484,9 +5484,9 @@  discard block
 block discarded – undo
5484 5484
 
5485 5485
         //Fix to remove the data of the user with my data
5486 5486
 
5487
-        for($i = 0; $i<=count($my_final_array); $i++) {
5487
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5488 5488
             if (!empty($my_final_array[$i])) {
5489
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5489
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5490 5490
                 $final_array[$i] = 0;
5491 5491
             }
5492 5492
         }
@@ -5504,7 +5504,7 @@  discard block
 block discarded – undo
5504 5504
         $dataSet->setXAxisName(get_lang('Score'));
5505 5505
         $dataSet->normalize(100, "%");
5506 5506
 
5507
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5507
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5508 5508
 
5509 5509
         // Cache definition
5510 5510
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5512,9 +5512,9 @@  discard block
 block discarded – undo
5512 5512
         $chartHash = $myCache->getHash($dataSet);
5513 5513
 
5514 5514
         if ($myCache->isInCache($chartHash)) {
5515
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5515
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5516 5516
             $myCache->saveFromCache($chartHash, $imgPath);
5517
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5517
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5518 5518
         } else {
5519 5519
             /* Create the pChart object */
5520 5520
             $widthSize = 480;
@@ -5530,7 +5530,7 @@  discard block
 block discarded – undo
5530 5530
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5531 5531
 
5532 5532
             /* Set the default font */
5533
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5533
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5534 5534
 
5535 5535
             /* Write the chart title */
5536 5536
             $myPicture->drawText(
@@ -5589,9 +5589,9 @@  discard block
 block discarded – undo
5589 5589
 
5590 5590
             /* Write and save into cache */
5591 5591
             $myCache->writeToCache($chartHash, $myPicture);
5592
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5592
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5593 5593
             $myCache->saveFromCache($chartHash, $imgPath);
5594
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5594
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5595 5595
         }
5596 5596
 
5597 5597
         return $imgPath;
@@ -5666,7 +5666,7 @@  discard block
 block discarded – undo
5666 5666
         $tquiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
5667 5667
         $tquiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
5668 5668
         $tquiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
5669
-        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5669
+        $ttrack_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5670 5670
         $ttrack_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
5671 5671
 
5672 5672
         $sessions = array();
@@ -5718,7 +5718,7 @@  discard block
 block discarded – undo
5718 5718
                         $whereSessionParams .= $sessionIdx.',';
5719 5719
                     }
5720 5720
                 }
5721
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5721
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5722 5722
             }
5723 5723
 
5724 5724
             if (!empty($exerciseId)) {
@@ -5782,7 +5782,7 @@  discard block
 block discarded – undo
5782 5782
                     qq.position = rq.question_order AND
5783 5783
                     ta.question_id = rq.question_id
5784 5784
                 WHERE
5785
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5785
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5786 5786
                     AND q.c_id = $courseIdx
5787 5787
                     $where $order $limit";
5788 5788
             $sql_query = vsprintf($sql, $whereParams);
@@ -5830,7 +5830,7 @@  discard block
 block discarded – undo
5830 5830
             // Now fill users data
5831 5831
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5832 5832
                          FROM $tuser
5833
-                         WHERE user_id IN (".implode(',',$userIds).")";
5833
+                         WHERE user_id IN (".implode(',', $userIds).")";
5834 5834
             $resUsers = Database::query($sqlUsers);
5835 5835
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5836 5836
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5934,7 +5934,7 @@  discard block
 block discarded – undo
5934 5934
                 <table class="table" id="skillList">
5935 5935
                     <thead>
5936 5936
                         <tr>
5937
-                            <th>' . get_lang('AchievedSkills') . '</th>
5937
+                            <th>' . get_lang('AchievedSkills').'</th>
5938 5938
                         </tr>
5939 5939
                     </thead>
5940 5940
                     <tbody>
@@ -5953,10 +5953,10 @@  discard block
 block discarded – undo
5953 5953
 
5954 5954
                 $html .= '
5955 5955
                                             <li class="thumbnail">
5956
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5957
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5956
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5957
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5958 5958
                                                     <div class="caption">
5959
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5959
+                                                        <p class="text-center">' . $skill->getName().'</p>
5960 5960
                                                     </div>
5961 5961
                                                 </a>
5962 5962
                                             </li>
@@ -6006,7 +6006,7 @@  discard block
 block discarded – undo
6006 6006
     	        WHERE
6007 6007
                     track_resource.c_id = $course_id AND
6008 6008
                     track_resource.insert_user_id = user.user_id AND
6009
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6009
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6010 6010
 
6011 6011
     	if (isset($_GET['keyword'])) {
6012 6012
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6064,7 +6064,7 @@  discard block
 block discarded – undo
6064 6064
                 WHERE
6065 6065
                   track_resource.c_id = $course_id AND
6066 6066
                   track_resource.insert_user_id = user.user_id AND
6067
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6067
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6068 6068
 
6069 6069
     	if (isset($_GET['keyword'])) {
6070 6070
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6364,7 +6364,7 @@  discard block
 block discarded – undo
6364 6364
     public static function display_additional_profile_fields()
6365 6365
     {
6366 6366
     	// getting all the extra profile fields that are defined by the platform administrator
6367
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6367
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6368 6368
 
6369 6369
     	// creating the form
6370 6370
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6376,8 +6376,8 @@  discard block
 block discarded – undo
6376 6376
     	$extra_fields_to_show = 0;
6377 6377
     	foreach ($extra_fields as $key=>$field) {
6378 6378
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6379
-    		if ($field[6]==1 && $field[8] == 1) {
6380
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6379
+    		if ($field[6] == 1 && $field[8] == 1) {
6380
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6381 6381
     				$selected = 'selected="selected"';
6382 6382
     			} else {
6383 6383
     				$selected = '';
@@ -6389,8 +6389,8 @@  discard block
 block discarded – undo
6389 6389
     	$return .= '</select>';
6390 6390
 
6391 6391
     	// the form elements for the $_GET parameters (because the form is passed through GET
6392
-    	foreach ($_GET as $key=>$value){
6393
-    		if ($key <> 'additional_profile_field')    {
6392
+    	foreach ($_GET as $key=>$value) {
6393
+    		if ($key <> 'additional_profile_field') {
6394 6394
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6395 6395
     		}
6396 6396
     	}
@@ -6427,21 +6427,21 @@  discard block
 block discarded – undo
6427 6427
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6428 6428
 
6429 6429
     	if (!empty($users)) {
6430
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6431
-    			foreach($users as $user_id) {
6430
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6431
+    			foreach ($users as $user_id) {
6432 6432
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6433 6433
     				$tag_list = array();
6434
-    				foreach($user_result as $item) {
6434
+    				foreach ($user_result as $item) {
6435 6435
     					$tag_list[] = $item['tag'];
6436 6436
     				}
6437
-    				$return[$user_id][] = implode(', ',$tag_list);
6437
+    				$return[$user_id][] = implode(', ', $tag_list);
6438 6438
     			}
6439 6439
     		} else {
6440 6440
     			$new_user_array = array();
6441 6441
     			foreach ($users as $user_id) {
6442
-    				$new_user_array[]= "'".$user_id."'";
6442
+    				$new_user_array[] = "'".$user_id."'";
6443 6443
     			}
6444
-    			$users = implode(',',$new_user_array);
6444
+    			$users = implode(',', $new_user_array);
6445 6445
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6446 6446
     			// Selecting only the necessary information NOT ALL the user list
6447 6447
     			$sql = "SELECT user.user_id, v.value
@@ -6456,7 +6456,7 @@  discard block
 block discarded – undo
6456 6456
                             user.user_id IN ($users)";
6457 6457
 
6458 6458
     			$result = Database::query($sql);
6459
-    			while($row = Database::fetch_array($result)) {
6459
+    			while ($row = Database::fetch_array($result)) {
6460 6460
     				// get option value for field type double select by id
6461 6461
     				if (!empty($row['value'])) {
6462 6462
     					if ($result_extra_field['field_type'] ==
@@ -6495,7 +6495,7 @@  discard block
 block discarded – undo
6495 6495
 
6496 6496
     public function sort_users_desc($a, $b)
6497 6497
     {
6498
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6498
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6499 6499
     }
6500 6500
 
6501 6501
     /**
@@ -6530,7 +6530,7 @@  discard block
 block discarded – undo
6530 6530
     	// get all users data from a course for sortable with limit
6531 6531
     	if (is_array($user_ids)) {
6532 6532
     		$user_ids = array_map('intval', $user_ids);
6533
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6533
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6534 6534
     	} else {
6535 6535
     		$user_ids = intval($user_ids);
6536 6536
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6538,7 +6538,7 @@  discard block
 block discarded – undo
6538 6538
 
6539 6539
     	if (!empty($_GET['user_keyword'])) {
6540 6540
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6541
-    		$condition_user .=  " AND (
6541
+    		$condition_user .= " AND (
6542 6542
                 user.firstname LIKE '%".$keyword."%' OR
6543 6543
                 user.lastname LIKE '%".$keyword."%'  OR
6544 6544
                 user.username LIKE '%".$keyword."%'  OR
@@ -6556,7 +6556,7 @@  discard block
 block discarded – undo
6556 6556
         $invitedUsersCondition = '';
6557 6557
 
6558 6558
         if (!$includeInvitedUsers) {
6559
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6559
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6560 6560
         }
6561 6561
 
6562 6562
     	$sql = "SELECT  user.user_id as user_id,
@@ -6567,7 +6567,7 @@  discard block
 block discarded – undo
6567 6567
                 FROM $tbl_user as user $url_table
6568 6568
     	        $condition_user $url_condition $invitedUsersCondition";
6569 6569
 
6570
-    	if (!in_array($direction, array('ASC','DESC'))) {
6570
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6571 6571
     		$direction = 'ASC';
6572 6572
     	}
6573 6573
 
@@ -6703,7 +6703,7 @@  discard block
 block discarded – undo
6703 6703
     		}
6704 6704
 
6705 6705
             if (empty($session_id)) {
6706
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6706
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6707 6707
             }
6708 6708
 
6709 6709
     		$user['link'] = '<center>
@@ -6715,37 +6715,37 @@  discard block
 block discarded – undo
6715 6715
     		// store columns in array $users
6716 6716
     		$is_western_name_order = api_is_western_name_order();
6717 6717
             $user_row = array();
6718
-            $user_row[]= $user['official_code']; //0
6718
+            $user_row[] = $user['official_code']; //0
6719 6719
             if ($is_western_name_order) {
6720
-                $user_row[]= $user['firstname'];
6721
-                $user_row[]= $user['lastname'];
6720
+                $user_row[] = $user['firstname'];
6721
+                $user_row[] = $user['lastname'];
6722 6722
             } else {
6723
-                $user_row[]= $user['lastname'];
6724
-                $user_row[]= $user['firstname'];
6723
+                $user_row[] = $user['lastname'];
6724
+                $user_row[] = $user['firstname'];
6725 6725
             }
6726
-            $user_row[]= $user['username'];
6727
-            $user_row[]= $user['time'];
6728
-            $user_row[]= $user['average_progress'];
6729
-            $user_row[]= $user['exercise_progress'];
6730
-            $user_row[]= $user['exercise_average_best_attempt'];
6731
-            $user_row[]= $user['student_score'];
6732
-            $user_row[]= $user['count_assignments'];
6733
-            $user_row[]= $user['count_messages'];
6726
+            $user_row[] = $user['username'];
6727
+            $user_row[] = $user['time'];
6728
+            $user_row[] = $user['average_progress'];
6729
+            $user_row[] = $user['exercise_progress'];
6730
+            $user_row[] = $user['exercise_average_best_attempt'];
6731
+            $user_row[] = $user['student_score'];
6732
+            $user_row[] = $user['count_assignments'];
6733
+            $user_row[] = $user['count_messages'];
6734 6734
 
6735 6735
             $userGroupManager = new UserGroup();
6736 6736
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6737 6737
 
6738 6738
             if (empty($session_id)) {
6739
-                $user_row[]= $user['survey'];
6739
+                $user_row[] = $user['survey'];
6740 6740
             }
6741 6741
 
6742
-            $user_row[]= $user['first_connection'];
6743
-            $user_row[]= $user['last_connection'];
6742
+            $user_row[] = $user['first_connection'];
6743
+            $user_row[] = $user['last_connection'];
6744 6744
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6745
-                $user_row[]= $user['additional'];
6745
+                $user_row[] = $user['additional'];
6746 6746
             }
6747 6747
 
6748
-            $user_row[]= $user['link'];
6748
+            $user_row[] = $user['link'];
6749 6749
 
6750 6750
             $users[] = $user_row;
6751 6751
 
@@ -6790,8 +6790,8 @@  discard block
 block discarded – undo
6790 6790
 
6791 6791
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6792 6792
     	$tempView = $view;
6793
-    	if(substr($view,0,1) == '1') {
6794
-    		$new_view = substr_replace($view,'0',0,1);
6793
+    	if (substr($view, 0, 1) == '1') {
6794
+    		$new_view = substr_replace($view, '0', 0, 1);
6795 6795
     		echo "
6796 6796
                 <tr>
6797 6797
                     <td valign='top'>
@@ -6824,9 +6824,9 @@  discard block
 block discarded – undo
6824 6824
                 </tr>";
6825 6825
     		$total = 0;
6826 6826
     		if (is_array($results)) {
6827
-    			for($j = 0 ; $j < count($results) ; $j++) {
6827
+    			for ($j = 0; $j < count($results); $j++) {
6828 6828
     				echo "<tr>";
6829
-    				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>";
6829
+    				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>";
6830 6830
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6831 6831
     				echo"</tr>";
6832 6832
     				$total = $total + $results[$j][1];
@@ -6843,7 +6843,7 @@  discard block
 block discarded – undo
6843 6843
     		echo "</table>";
6844 6844
     		echo "</td></tr>";
6845 6845
     	} else {
6846
-    		$new_view = substr_replace($view,'1',0,1);
6846
+    		$new_view = substr_replace($view, '1', 0, 1);
6847 6847
     		echo "
6848 6848
                 <tr>
6849 6849
                     <td valign='top'>
@@ -6866,8 +6866,8 @@  discard block
 block discarded – undo
6866 6866
     {
6867 6867
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6868 6868
         $courseId = api_get_course_int_id($courseCode);
6869
-    	if(substr($view,1,1) == '1') {
6870
-    		$new_view = substr_replace($view,'0',1,1);
6869
+    	if (substr($view, 1, 1) == '1') {
6870
+    		$new_view = substr_replace($view, '0', 1, 1);
6871 6871
     		echo "<tr>
6872 6872
                     <td valign='top'>
6873 6873
                         <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>]
@@ -6909,7 +6909,7 @@  discard block
 block discarded – undo
6909 6909
                 </tr>";
6910 6910
 
6911 6911
     		if (is_array($results)) {
6912
-    			for($i = 0; $i < sizeof($results); $i++) {
6912
+    			for ($i = 0; $i < sizeof($results); $i++) {
6913 6913
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6914 6914
     				echo "<tr>\n";
6915 6915
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6924,8 +6924,8 @@  discard block
 block discarded – undo
6924 6924
 
6925 6925
     		// The Result of Tests
6926 6926
     		if (is_array($hpresults)) {
6927
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6928
-    				$title = GetQuizName($hpresults[$i][0],'');
6927
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6928
+    				$title = GetQuizName($hpresults[$i][0], '');
6929 6929
     				if ($title == '')
6930 6930
     				$title = basename($hpresults[$i][0]);
6931 6931
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6951,7 +6951,7 @@  discard block
 block discarded – undo
6951 6951
     		echo "</table>";
6952 6952
     		echo "</td>\n</tr>\n";
6953 6953
     	} else {
6954
-    		$new_view = substr_replace($view,'1',1,1);
6954
+    		$new_view = substr_replace($view, '1', 1, 1);
6955 6955
     		echo "
6956 6956
                 <tr>
6957 6957
                     <td valign='top'>
@@ -6970,8 +6970,8 @@  discard block
 block discarded – undo
6970 6970
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6971 6971
         $_course = api_get_course_info_by_id($course_id);
6972 6972
 
6973
-    	if (substr($view,2,1) == '1') {
6974
-    		$new_view = substr_replace($view,'0',2,1);
6973
+    	if (substr($view, 2, 1) == '1') {
6974
+    		$new_view = substr_replace($view, '0', 2, 1);
6975 6975
     		echo "<tr>
6976 6976
                     <td valign='top'>
6977 6977
                     <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>]
@@ -6985,7 +6985,7 @@  discard block
 block discarded – undo
6985 6985
                         AND u.c_id = '".intval($course_id)."'
6986 6986
                     ORDER BY u.upload_date DESC";
6987 6987
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6988
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6988
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6989 6989
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6990 6990
     		echo "<tr>
6991 6991
                     <td class='secLine' width='40%'>
@@ -6999,7 +6999,7 @@  discard block
 block discarded – undo
6999 6999
                     </td>
7000 7000
                 </tr>";
7001 7001
     		if (is_array($results)) {
7002
-    			for($j = 0 ; $j < count($results) ; $j++) {
7002
+    			for ($j = 0; $j < count($results); $j++) {
7003 7003
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7004 7004
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7005 7005
     				echo "<tr>";
@@ -7018,7 +7018,7 @@  discard block
 block discarded – undo
7018 7018
     		echo "</table>";
7019 7019
     		echo "</td></tr>";
7020 7020
     	} else {
7021
-    		$new_view = substr_replace($view,'1',2,1);
7021
+    		$new_view = substr_replace($view, '1', 2, 1);
7022 7022
     		echo "
7023 7023
                 <tr>
7024 7024
                     <td valign='top'>
@@ -7037,8 +7037,8 @@  discard block
 block discarded – undo
7037 7037
     {
7038 7038
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7039 7039
         $courseId = api_get_course_int_id($courseCode);
7040
-    	if (substr($view,3,1) == '1') {
7041
-    		$new_view = substr_replace($view,'0',3,1);
7040
+    	if (substr($view, 3, 1) == '1') {
7041
+    		$new_view = substr_replace($view, '0', 3, 1);
7042 7042
     		echo "
7043 7043
                 <tr>
7044 7044
                         <td valign='top'>
@@ -7062,7 +7062,7 @@  discard block
 block discarded – undo
7062 7062
                     </td>
7063 7063
                 </tr>";
7064 7064
     		if (is_array($results)) {
7065
-    			for($j = 0 ; $j < count($results) ; $j++) {
7065
+    			for ($j = 0; $j < count($results); $j++) {
7066 7066
     				echo "<tr>";
7067 7067
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7068 7068
     				echo"</tr>";
@@ -7075,7 +7075,7 @@  discard block
 block discarded – undo
7075 7075
     		echo "</table>";
7076 7076
     		echo "</td></tr>";
7077 7077
     	} else {
7078
-    		$new_view = substr_replace($view,'1',3,1);
7078
+    		$new_view = substr_replace($view, '1', 3, 1);
7079 7079
     		echo "
7080 7080
                 <tr>
7081 7081
                     <td valign='top'>
@@ -7102,8 +7102,8 @@  discard block
 block discarded – undo
7102 7102
     	$session_id = intval($session_id);
7103 7103
 
7104 7104
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7105
-    	if(substr($view,4,1) == '1') {
7106
-    		$new_view = substr_replace($view,'0',4,1);
7105
+    	if (substr($view, 4, 1) == '1') {
7106
+    		$new_view = substr_replace($view, '0', 4, 1);
7107 7107
     		echo "
7108 7108
                 <tr>
7109 7109
                     <td valign='top'>
@@ -7129,7 +7129,7 @@  discard block
 block discarded – undo
7129 7129
                     </td>
7130 7130
                 </tr>";
7131 7131
     		if (is_array($results)) {
7132
-    			for($j = 0 ; $j < count($results) ; $j++) {
7132
+    			for ($j = 0; $j < count($results); $j++) {
7133 7133
     				echo "<tr>";
7134 7134
     				echo "<td class='content'>".$results[$j]."</td>";
7135 7135
     				echo"</tr>";
@@ -7142,7 +7142,7 @@  discard block
 block discarded – undo
7142 7142
     		echo "</table>";
7143 7143
     		echo "</td></tr>";
7144 7144
     	} else {
7145
-    		$new_view = substr_replace($view,'1',4,1);
7145
+    		$new_view = substr_replace($view, '1', 4, 1);
7146 7146
     		echo "
7147 7147
                 <tr>
7148 7148
                     <td valign='top'>
@@ -7176,11 +7176,11 @@  discard block
 block discarded – undo
7176 7176
                    ORDER BY login_date DESC LIMIT 1";
7177 7177
         $ip = '';
7178 7178
         $res_ip = Database::query($sql_ip);
7179
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7179
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7180 7180
             $row_ip = Database::fetch_row($res_ip);
7181 7181
             if ($return_as_link) {
7182 7182
                 $ip = Display::url(
7183
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7183
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7184 7184
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7185 7185
                 );
7186 7186
             } else {
@@ -7216,9 +7216,9 @@  discard block
 block discarded – undo
7216 7216
     	$course_id  = intval($course_id);
7217 7217
 
7218 7218
     	$tempView = $view;
7219
-    	if (substr($view,0,1) == '1') {
7220
-    		$new_view = substr_replace($view,'0',0,1);
7221
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7219
+    	if (substr($view, 0, 1) == '1') {
7220
+    		$new_view = substr_replace($view, '0', 0, 1);
7221
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7222 7222
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7223 7223
                     FROM $track_access_table
7224 7224
                     WHERE access_user_id = $user_id
@@ -7228,20 +7228,20 @@  discard block
 block discarded – undo
7228 7228
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7229 7229
     		//$results = getManyResults2Col($sql);
7230 7230
     		$results = getManyResults3Col($sql);
7231
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7232
-    		$line='';
7231
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7232
+    		$line = '';
7233 7233
     		$total = 0;
7234 7234
     		if (is_array($results)) {
7235
-    			for($j = 0 ; $j < count($results) ; $j++) {
7235
+    			for ($j = 0; $j < count($results); $j++) {
7236 7236
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7237 7237
     				$total = $total + $results[$j][1];
7238 7238
     			}
7239 7239
     			$line .= get_lang('Total').";".$total."\n";
7240 7240
     		} else {
7241
-    			$line= get_lang('NoResult')."</center></td>";
7241
+    			$line = get_lang('NoResult')."</center></td>";
7242 7242
     		}
7243 7243
     	} else {
7244
-    		$new_view = substr_replace($view,'1',0,1);
7244
+    		$new_view = substr_replace($view, '1', 0, 1);
7245 7245
     	}
7246 7246
     	return array($title_line, $line);
7247 7247
     }
@@ -7259,8 +7259,8 @@  discard block
 block discarded – undo
7259 7259
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7260 7260
         $courseId = api_get_course_int_id($courseCode);
7261 7261
         $userId = intval($userId);
7262
-    	if (substr($view,1,1) == '1') {
7263
-    		$new_view = substr_replace($view,'0',1,1);
7262
+    	if (substr($view, 1, 1) == '1') {
7263
+    		$new_view = substr_replace($view, '0', 1, 1);
7264 7264
     		$title[1] = get_lang('ExercicesDetails');
7265 7265
     		$line = '';
7266 7266
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7284,7 +7284,7 @@  discard block
 block discarded – undo
7284 7284
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7285 7285
 
7286 7286
     		if (is_array($results)) {
7287
-    			for($i = 0; $i < sizeof($results); $i++)
7287
+    			for ($i = 0; $i < sizeof($results); $i++)
7288 7288
     			{
7289 7289
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7290 7290
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7296,8 +7296,8 @@  discard block
 block discarded – undo
7296 7296
 
7297 7297
     		// The Result of Tests
7298 7298
     		if (is_array($hpresults)) {
7299
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7300
-    				$title = GetQuizName($hpresults[$i][0],'');
7299
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7300
+    				$title = GetQuizName($hpresults[$i][0], '');
7301 7301
 
7302 7302
     				if ($title == '')
7303 7303
     				$title = basename($hpresults[$i][0]);
@@ -7311,10 +7311,10 @@  discard block
 block discarded – undo
7311 7311
     		}
7312 7312
 
7313 7313
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7314
-    			$line=get_lang('NoResult');
7314
+    			$line = get_lang('NoResult');
7315 7315
     		}
7316 7316
     	} else {
7317
-    		$new_view = substr_replace($view,'1',1,1);
7317
+    		$new_view = substr_replace($view, '1', 1, 1);
7318 7318
     	}
7319 7319
     	return array($title_line, $line);
7320 7320
     }
@@ -7330,7 +7330,7 @@  discard block
 block discarded – undo
7330 7330
         $user_id = intval($user_id);
7331 7331
         $course_id = intval($course_id);
7332 7332
 
7333
-    	if (substr($view,2,1) == '1') {
7333
+    	if (substr($view, 2, 1) == '1') {
7334 7334
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7335 7335
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7336 7336
                     WHERE
@@ -7338,21 +7338,21 @@  discard block
 block discarded – undo
7338 7338
                         u.upload_user_id = '$user_id' AND
7339 7339
                         u.c_id = '$course_id'
7340 7340
                     ORDER BY u.upload_date DESC";
7341
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7341
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7342 7342
 
7343
-    		$title[1]=get_lang('WorksDetails');
7344
-    		$line='';
7345
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7343
+    		$title[1] = get_lang('WorksDetails');
7344
+    		$line = '';
7345
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7346 7346
 
7347 7347
     		if (is_array($results)) {
7348
-    			for($j = 0 ; $j < count($results) ; $j++) {
7348
+    			for ($j = 0; $j < count($results); $j++) {
7349 7349
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7350 7350
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7351 7351
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7352 7352
     			}
7353 7353
 
7354 7354
     		} else {
7355
-    			$line= get_lang('NoResult');
7355
+    			$line = get_lang('NoResult');
7356 7356
     		}
7357 7357
     	}
7358 7358
     	return array($title_line, $line);
@@ -7368,9 +7368,9 @@  discard block
 block discarded – undo
7368 7368
         $courseId = api_get_course_int_id($courseCode);
7369 7369
         $userId = intval($userId);
7370 7370
         $line = null;
7371
-    	if (substr($view,3,1) == '1') {
7372
-    		$new_view = substr_replace($view,'0',3,1);
7373
-    		$title[1]=get_lang('LinksDetails');
7371
+    	if (substr($view, 3, 1) == '1') {
7372
+    		$new_view = substr_replace($view, '0', 3, 1);
7373
+    		$title[1] = get_lang('LinksDetails');
7374 7374
     		$sql = "SELECT cl.title, cl.url
7375 7375
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7376 7376
                         WHERE sl.links_link_id = cl.id
@@ -7378,16 +7378,16 @@  discard block
 block discarded – undo
7378 7378
                             AND sl.links_user_id = $userId
7379 7379
                         GROUP BY cl.title, cl.url";
7380 7380
     		$results = StatsUtils::getManyResults2Col($sql);
7381
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7381
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7382 7382
     		if (is_array($results)) {
7383
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7383
+    			for ($j = 0; $j < count($results); $j++) {
7384 7384
     				$line .= $results[$j][0]."\n";
7385 7385
     			}
7386 7386
     		} else {
7387
-    			$line=get_lang('NoResult');
7387
+    			$line = get_lang('NoResult');
7388 7388
     		}
7389 7389
     	} else {
7390
-    		$new_view = substr_replace($view,'1',3,1);
7390
+    		$new_view = substr_replace($view, '1', 3, 1);
7391 7391
     	}
7392 7392
     	return array($title_line, $line);
7393 7393
     }
@@ -7409,9 +7409,9 @@  discard block
 block discarded – undo
7409 7409
 
7410 7410
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7411 7411
 
7412
-    	if (substr($view,4,1) == '1') {
7413
-    		$new_view = substr_replace($view,'0',4,1);
7414
-    		$title[1]= get_lang('DocumentsDetails');
7412
+    	if (substr($view, 4, 1) == '1') {
7413
+    		$new_view = substr_replace($view, '0', 4, 1);
7414
+    		$title[1] = get_lang('DocumentsDetails');
7415 7415
 
7416 7416
     		$sql = "SELECT down_doc_path
7417 7417
                         FROM $downloads_table
@@ -7424,14 +7424,14 @@  discard block
 block discarded – undo
7424 7424
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7425 7425
             $line = null;
7426 7426
     		if (is_array($results)) {
7427
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7427
+    			for ($j = 0; $j < count($results); $j++) {
7428 7428
     				$line .= $results[$j]."\n";
7429 7429
     			}
7430 7430
     		} else {
7431 7431
     			$line = get_lang('NoResult');
7432 7432
     		}
7433 7433
     	} else {
7434
-    		$new_view = substr_replace($view,'1',4,1);
7434
+    		$new_view = substr_replace($view, '1', 4, 1);
7435 7435
     	}
7436 7436
     	return array($title_line, $line);
7437 7437
     }
Please login to merge, or discard this patch.
main/exercise/export/qti2/qti2_classes.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -72,6 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * Return the XML flow for the possible answers.
74 74
      *
75
+     * @param string $questionStatment
75 76
      */
76 77
     public function imsExportResponses($questionIdent, $questionStatment)
77 78
     {
@@ -147,6 +148,7 @@  discard block
 block discarded – undo
147 148
      * Export the text with missing words.
148 149
      *
149 150
      *
151
+     * @param string $questionStatment
150 152
      */
151 153
     public function imsExportResponses($questionIdent, $questionStatment)
152 154
     {
@@ -204,6 +206,7 @@  discard block
 block discarded – undo
204 206
 {
205 207
     /**
206 208
      * Export the question part as a matrix-choice, with only one possible answer per line.
209
+     * @param string $questionStatment
207 210
      */
208 211
     public function imsExportResponses($questionIdent, $questionStatment)
209 212
     {
@@ -295,6 +298,7 @@  discard block
 block discarded – undo
295 298
     /**
296 299
      * TODO update this to match hot spots instead of copying matching
297 300
      * Export the question part as a matrix-choice, with only one possible answer per line.
301
+     * @param string $questionStatment
298 302
      */
299 303
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 304
     {
@@ -382,6 +386,7 @@  discard block
 block discarded – undo
382 386
     /**
383 387
      * TODO implement
384 388
      * Export the question part as a matrix-choice, with only one possible answer per line.
389
+     * @param string $questionStatment
385 390
      */
386 391
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387 392
 	{
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 
56 56
     function createAnswersForm($form)
57 57
     {
58
-    	return true;
58
+        return true;
59 59
     }
60 60
 
61 61
     function processAnswersCreation($form)
62 62
     {
63
-    	return true;
63
+        return true;
64 64
     }
65 65
 }
66 66
 /**
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
     public function imsExportResponses($questionIdent, $questionStatment)
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79
-		$this->answerList = $this->getAnswersList(true);
79
+        $this->answerList = $this->getAnswersList(true);
80 80
         $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81 81
         $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
82
-		if (is_array($this->answerList)) {
83
-	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
82
+        if (is_array($this->answerList)) {
83
+            foreach ($this->answerList as $current_answer) {
84
+                $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86
-	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
86
+                if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
+                    $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90
-	            }
91
-	            $out .= '</simpleChoice>'. "\n";
92
-	        }
93
-		}
90
+                }
91
+                $out .= '</simpleChoice>'. "\n";
92
+            }
93
+        }
94 94
         $out .= '    </choiceInteraction>'. "\n";
95 95
 
96 96
         return $out;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function imsExportResponsesDeclaration($questionIdent)
104 104
     {
105
-		$this->answerList = $this->getAnswersList(true);
106
-		$type = $this->getQuestionType();
105
+        $this->answerList = $this->getAnswersList(true);
106
+        $type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109 109
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         // Match the correct answers.
112 112
 
113 113
         $out .= '    <correctResponse>'. "\n";
114
-		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
116
-	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
-	            }
119
-	        }
120
-		}
114
+        if (is_array($this->answerList)) {
115
+            foreach($this->answerList as $current_answer) {
116
+                if ($current_answer['correct']) {
117
+                    $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
+                }
119
+            }
120
+        }
121 121
         $out .= '    </correctResponse>'. "\n";
122 122
 
123 123
         //Add the grading
124 124
 
125 125
         $out .= '    <mapping>'. "\n";
126
-		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
128
-	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
-	            }
131
-	        }
132
-		}
126
+        if (is_array($this->answerList)) {
127
+            foreach($this->answerList as $current_answer) {
128
+                if (isset($current_answer['grade'])) {
129
+                    $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
+                }
131
+            }
132
+        }
133 133
         $out .= '    </mapping>'. "\n";
134 134
         $out .= '  </responseDeclaration>'. "\n";
135 135
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function imsExportResponses($questionIdent, $questionStatment)
152 152
     {
153
-		$this->answerList = $this->getAnswersList(true);
153
+        $this->answerList = $this->getAnswersList(true);
154 154
         $text = '';
155 155
         $text .= $this->answerText;
156 156
         if (is_array($this->answerList)) {
@@ -171,28 +171,28 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function imsExportResponsesDeclaration($questionIdent)
173 173
     {
174
-		$this->answerList = $this->getAnswersList(true);
175
-		$this->gradeList = $this->getGradesList();
174
+        $this->answerList = $this->getAnswersList(true);
175
+        $this->gradeList = $this->getGradesList();
176 176
         $out = '';
177
-		if (is_array($this->answerList)) {
178
-	        foreach ($this->answerList as $answer) {
179
-	        	$answerKey = $answer['id'];
180
-	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
177
+        if (is_array($this->answerList)) {
178
+            foreach ($this->answerList as $answer) {
179
+                $answerKey = $answer['id'];
180
+                $answer = $answer['answer'];
181
+                $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
+                $out .= '    <correctResponse>'. "\n";
183 183
                 $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
185
-	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
189
-	            }
190
-
191
-	            $out .= '  </responseDeclaration>'. "\n";
192
-	        }
193
-		}
194
-
195
-       return $out;
184
+                $out .= '    </correctResponse>'. "\n";
185
+                if (isset($this->gradeList[$answerKey])) {
186
+                    $out .= '    <mapping>'. "\n";
187
+                    $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
+                    $out .= '    </mapping>'. "\n";
189
+                }
190
+
191
+                $out .= '  </responseDeclaration>'. "\n";
192
+            }
193
+        }
194
+
195
+        return $out;
196 196
     }
197 197
 }
198 198
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function imsExportResponses($questionIdent, $questionStatment)
209 209
     {
210
-		$this->answerList = $this->getAnswersList(true);
211
-		$maxAssociation = max(count($this->leftList), count($this->rightList));
210
+        $this->answerList = $this->getAnswersList(true);
211
+        $maxAssociation = max(count($this->leftList), count($this->rightList));
212 212
 
213 213
         $out = "";
214 214
 
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         //add left column
219 219
 
220 220
         $out .= '  <simpleMatchSet>'. "\n";
221
-		if (is_array($this->leftList)) {
222
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
223
-	            $out .= '
221
+        if (is_array($this->leftList)) {
222
+            foreach ($this->leftList as $leftKey=>$leftElement) {
223
+                $out .= '
224 224
 	            <simpleAssociableChoice identifier="left_'.$leftKey.'" >
225 225
 	                <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]>
226 226
 	            </simpleAssociableChoice>'. "\n";
227
-	        }
228
-    	}
227
+            }
228
+        }
229 229
 
230 230
         $out .= '  </simpleMatchSet>'. "\n";
231 231
 
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 
236 236
         $i = 0;
237 237
 
238
-		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
240
-	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
238
+        if (is_array($this->rightList)) {
239
+            foreach($this->rightList as $rightKey=>$rightElement) {
240
+                $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243
-	            $i++;
244
-	        }
245
-		}
243
+                $i++;
244
+            }
245
+        }
246 246
         $out .= '  </simpleMatchSet>'. "\n";
247 247
         $out .= '</matchInteraction>'. "\n";
248 248
 
@@ -254,30 +254,30 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257
-		$this->answerList = $this->getAnswersList(true);
257
+        $this->answerList = $this->getAnswersList(true);
258 258
         $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259 259
         $out .= '    <correctResponse>' . "\n";
260 260
 
261 261
         $gradeArray = array();
262
-		if (is_array($this->leftList)) {
263
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
265
-	            foreach ($this->rightList as $rightKey=>$rightElement) {
266
-	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
-
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
-	                }
271
-	                $i++;
272
-	            }
273
-	        }
274
-		}
262
+        if (is_array($this->leftList)) {
263
+            foreach ($this->leftList as $leftKey=>$leftElement) {
264
+                $i=0;
265
+                foreach ($this->rightList as $rightKey=>$rightElement) {
266
+                    if (($leftElement['match'] == $rightElement['code'])) {
267
+                        $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
+
269
+                        $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
+                    }
271
+                    $i++;
272
+                }
273
+            }
274
+        }
275 275
         $out .= '    </correctResponse>'. "\n";
276 276
         $out .= '    <mapping>' . "\n";
277 277
         if (is_array($gradeArray)) {
278
-	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
-	        }
278
+            foreach ($gradeArray as $gradeKey=>$grade) {
279
+                $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
+            }
281 281
         }
282 282
         $out .= '    </mapping>' . "\n";
283 283
         $out .= '  </responseDeclaration>'. "\n";
@@ -298,49 +298,49 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 300
     {
301
-		$this->answerList = $this->getAnswersList(true);
302
-		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
-		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
305
-			$mimetype = 'image/jpeg';
306
-		}
307
-
308
-		$text = '      <p>'.$questionStatment.'</p>'."\n";
309
-		$text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
-		$text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
-		$text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
301
+        $this->answerList = $this->getAnswersList(true);
302
+        $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
+        $mimetype = mime_content_type($questionMedia);
304
+        if(empty($mimetype)){
305
+            $mimetype = 'image/jpeg';
306
+        }
307
+
308
+        $text = '      <p>'.$questionStatment.'</p>'."\n";
309
+        $text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
+        $text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
+        $text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
312 312
         if (is_array($this->answerList)) {
313
-	        foreach ($this->answerList as $key=>$answer) {
314
-	        	$key = $answer['id'];
315
-	        	$answerTxt = $answer['answer'];
316
-	        	$len = api_strlen($answerTxt);
317
-	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
-	        	$coords = '';
319
-	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
321
-	        		case 'square':
322
-	        			$type = 'rect';
323
-						$res = array();
324
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
-						$coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
-	        			break;
327
-	        		case 'circle':
328
-	        			$type = 'circle';
329
-			 			$res = array();
330
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
-						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
-	        			break;
333
-	        		case 'poly':
334
-	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
-	        			break;
337
-	        		 case 'delineation' :
338
-	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
-	        			break;
341
-	        	}
342
-	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
-	        }
313
+            foreach ($this->answerList as $key=>$answer) {
314
+                $key = $answer['id'];
315
+                $answerTxt = $answer['answer'];
316
+                $len = api_strlen($answerTxt);
317
+                //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
+                $coords = '';
319
+                $type = 'default';
320
+                switch($answer['hotspot_type']){
321
+                    case 'square':
322
+                        $type = 'rect';
323
+                        $res = array();
324
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
+                        $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
+                        break;
327
+                    case 'circle':
328
+                        $type = 'circle';
329
+                            $res = array();
330
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
+                        $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
+                        break;
333
+                    case 'poly':
334
+                        $type = 'poly';
335
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
+                        break;
337
+                        case 'delineation' :
338
+                        $type = 'delineation';
339
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
+                        break;
341
+                }
342
+                $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
+            }
344 344
         }
345 345
         $text .= '      </graphicOrderInteraction>'."\n";
346 346
         $out = $text;
@@ -353,23 +353,23 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function imsExportResponsesDeclaration($questionIdent)
355 355
     {
356
-		$this->answerList = $this->getAnswersList(true);
357
-		$this->gradeList = $this->getGradesList();
356
+        $this->answerList = $this->getAnswersList(true);
357
+        $this->gradeList = $this->getGradesList();
358 358
         $out = '';
359 359
         $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360 360
         $out .= '    <correctResponse>'. "\n";
361 361
 
362
-		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
364
-	        	$answerKey = $answer['id'];
365
-	        	$answer = $answer['answer'];
366
-	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
-	        }
368
-		}
362
+        if (is_array($this->answerList)) {
363
+            foreach ($this->answerList as $answerKey=>$answer)  {
364
+                $answerKey = $answer['id'];
365
+                $answer = $answer['answer'];
366
+                $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
+            }
368
+        }
369 369
         $out .= '    </correctResponse>'. "\n";
370 370
         $out .= '  </responseDeclaration>'. "\n";
371 371
 
372
-       return $out;
372
+        return $out;
373 373
     }
374 374
 }
375 375
 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386 386
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387
-	{
388
-		return '';
389
-	}
387
+    {
388
+        return '';
389
+    }
390 390
     /**
391 391
      *
392 392
      */
393 393
     public function imsExportResponsesDeclaration($questionIdent)
394 394
     {
395
-    	return '';
395
+        return '';
396 396
     }
397 397
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function setAnswer()
16 16
     {
17
-        switch($this->type) {
17
+        switch ($this->type) {
18 18
             case MCUA:
19 19
                 $answer = new ImsAnswerMultipleChoice($this->id);
20 20
 
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79 79
 		$this->answerList = $this->getAnswersList(true);
80
-        $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81
-        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
80
+        $out  = '    <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n";
81
+        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment).']]></prompt>'."\n";
82 82
 		if (is_array($this->answerList)) {
83 83
 	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
84
+	            $out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86 86
 	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
87
+	                $out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90 90
 	            }
91
-	            $out .= '</simpleChoice>'. "\n";
91
+	            $out .= '</simpleChoice>'."\n";
92 92
 	        }
93 93
 		}
94
-        $out .= '    </choiceInteraction>'. "\n";
94
+        $out .= '    </choiceInteraction>'."\n";
95 95
 
96 96
         return $out;
97 97
     }
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 		$type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109
-        $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
109
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="'.$cardinality.'" baseType="identifier">'."\n";
110 110
 
111 111
         // Match the correct answers.
112 112
 
113
-        $out .= '    <correctResponse>'. "\n";
113
+        $out .= '    <correctResponse>'."\n";
114 114
 		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
115
+	        foreach ($this->answerList as $current_answer) {
116 116
 	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
117
+	                $out .= '      <value>answer_'.$current_answer['id'].'</value>'."\n";
118 118
 	            }
119 119
 	        }
120 120
 		}
121
-        $out .= '    </correctResponse>'. "\n";
121
+        $out .= '    </correctResponse>'."\n";
122 122
 
123 123
         //Add the grading
124 124
 
125
-        $out .= '    <mapping>'. "\n";
125
+        $out .= '    <mapping>'."\n";
126 126
 		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
127
+	        foreach ($this->answerList as $current_answer) {
128 128
 	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
129
+	                $out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n";
130 130
 	            }
131 131
 	        }
132 132
 		}
133
-        $out .= '    </mapping>'. "\n";
134
-        $out .= '  </responseDeclaration>'. "\n";
133
+        $out .= '    </mapping>'."\n";
134
+        $out .= '  </responseDeclaration>'."\n";
135 135
 
136 136
         return $out;
137 137
     }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                 $key = $answer['id'];
159 159
                 $answer = $answer['answer'];
160 160
                 $len = api_strlen($answer);
161
-                $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
161
+                $text = str_replace('['.$answer.']', '<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
162 162
             }
163 163
         }
164 164
         $out = $text;
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 	        foreach ($this->answerList as $answer) {
179 179
 	        	$answerKey = $answer['id'];
180 180
 	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
183
-                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
181
+	            $out .= '  <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n";
182
+	            $out .= '    <correctResponse>'."\n";
183
+                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'."\n";
184
+	            $out .= '    </correctResponse>'."\n";
185 185
 	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
186
+	                $out .= '    <mapping>'."\n";
187
+	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n";
188
+	                $out .= '    </mapping>'."\n";
189 189
 	            }
190 190
 
191
-	            $out .= '  </responseDeclaration>'. "\n";
191
+	            $out .= '  </responseDeclaration>'."\n";
192 192
 	        }
193 193
 		}
194 194
 
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
         $out = "";
214 214
 
215
-        $out .= '<matchInteraction responseIdentifier="' . $questionIdent . '" maxAssociations="'. $maxAssociation .'">'. "\n";
215
+        $out .= '<matchInteraction responseIdentifier="'.$questionIdent.'" maxAssociations="'.$maxAssociation.'">'."\n";
216 216
         $out .= $questionStatment;
217 217
 
218 218
         //add left column
219 219
 
220
-        $out .= '  <simpleMatchSet>'. "\n";
220
+        $out .= '  <simpleMatchSet>'."\n";
221 221
 		if (is_array($this->leftList)) {
222 222
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
223 223
 	            $out .= '
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	        }
228 228
     	}
229 229
 
230
-        $out .= '  </simpleMatchSet>'. "\n";
230
+        $out .= '  </simpleMatchSet>'."\n";
231 231
 
232 232
         //add right column
233 233
 
234
-        $out .= '  <simpleMatchSet>'. "\n";
234
+        $out .= '  <simpleMatchSet>'."\n";
235 235
 
236 236
         $i = 0;
237 237
 
238 238
 		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
239
+	        foreach ($this->rightList as $rightKey=>$rightElement) {
240 240
 	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243 243
 	            $i++;
244 244
 	        }
245 245
 		}
246
-        $out .= '  </simpleMatchSet>'. "\n";
247
-        $out .= '</matchInteraction>'. "\n";
246
+        $out .= '  </simpleMatchSet>'."\n";
247
+        $out .= '</matchInteraction>'."\n";
248 248
 
249 249
         return $out;
250 250
     }
@@ -255,32 +255,32 @@  discard block
 block discarded – undo
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257 257
 		$this->answerList = $this->getAnswersList(true);
258
-        $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259
-        $out .= '    <correctResponse>' . "\n";
258
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n";
259
+        $out .= '    <correctResponse>'."\n";
260 260
 
261 261
         $gradeArray = array();
262 262
 		if (is_array($this->leftList)) {
263 263
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
264
+	            $i = 0;
265 265
 	            foreach ($this->rightList as $rightKey=>$rightElement) {
266 266
 	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
267
+	                    $out .= '      <value>left_'.$leftKey.' right_'.$i.'</value>'."\n";
268 268
 
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
269
+	                    $gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade'];
270 270
 	                }
271 271
 	                $i++;
272 272
 	            }
273 273
 	        }
274 274
 		}
275
-        $out .= '    </correctResponse>'. "\n";
276
-        $out .= '    <mapping>' . "\n";
275
+        $out .= '    </correctResponse>'."\n";
276
+        $out .= '    <mapping>'."\n";
277 277
         if (is_array($gradeArray)) {
278 278
 	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
279
+	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n";
280 280
 	        }
281 281
         }
282
-        $out .= '    </mapping>' . "\n";
283
-        $out .= '  </responseDeclaration>'. "\n";
282
+        $out .= '    </mapping>'."\n";
283
+        $out .= '  </responseDeclaration>'."\n";
284 284
 
285 285
         return $out;
286 286
     }
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
      * TODO update this to match hot spots instead of copying matching
297 297
      * Export the question part as a matrix-choice, with only one possible answer per line.
298 298
      */
299
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
299
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
300 300
     {
301 301
 		$this->answerList = $this->getAnswersList(true);
302 302
 		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303 303
 		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
304
+		if (empty($mimetype)) {
305 305
 			$mimetype = 'image/jpeg';
306 306
 		}
307 307
 
@@ -317,26 +317,26 @@  discard block
 block discarded – undo
317 317
 	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318 318
 	        	$coords = '';
319 319
 	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
320
+	        	switch ($answer['hotspot_type']) {
321 321
 	        		case 'square':
322 322
 	        			$type = 'rect';
323 323
 						$res = array();
324
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
-						$coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
324
+						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
325
+						$coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]);
326 326
 	        			break;
327 327
 	        		case 'circle':
328 328
 	        			$type = 'circle';
329 329
 			 			$res = array();
330
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
-						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
330
+						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
331
+						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4])));
332 332
 	        			break;
333 333
 	        		case 'poly':
334 334
 	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
335
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
336 336
 	        			break;
337 337
 	        		 case 'delineation' :
338 338
 	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
339
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
340 340
 	        			break;
341 341
 	        	}
342 342
 	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
 		$this->answerList = $this->getAnswersList(true);
357 357
 		$this->gradeList = $this->getGradesList();
358 358
         $out = '';
359
-        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360
-        $out .= '    <correctResponse>'. "\n";
359
+        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">'."\n";
360
+        $out .= '    <correctResponse>'."\n";
361 361
 
362 362
 		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
363
+	        foreach ($this->answerList as $answerKey=>$answer) {
364 364
 	        	$answerKey = $answer['id'];
365 365
 	        	$answer = $answer['answer'];
366 366
 	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367 367
 	        }
368 368
 		}
369
-        $out .= '    </correctResponse>'. "\n";
370
-        $out .= '  </responseDeclaration>'. "\n";
369
+        $out .= '    </correctResponse>'."\n";
370
+        $out .= '  </responseDeclaration>'."\n";
371 371
 
372 372
        return $out;
373 373
     }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * TODO implement
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
386
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
387 387
 	{
388 388
 		return '';
389 389
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,11 @@
 block discarded – undo
104 104
     {
105 105
 		$this->answerList = $this->getAnswersList(true);
106 106
 		$type = $this->getQuestionType();
107
-        if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
107
+        if ($type == MCMA) {
108
+            $cardinality = 'multiple';
109
+        } else {
110
+            $cardinality = 'single';
111
+        }
108 112
 
109 113
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
110 114
 
Please login to merge, or discard this patch.
main/exercise/hotpotatoes.lib.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
  * @param    reference    Reference to the array to search
260 260
  * @param    string       Node we are looking for in the array
261 261
  * @param string $node
262
- * @return   mixed        Node name or false if not found
262
+ * @return   false|string        Node name or false if not found
263 263
  */
264 264
 function myarraysearch(&$array, $node)
265 265
 {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
  * Searches an image name into an array.
281 281
  * @param    reference        Reference to an array to search
282 282
  * @param    string           String to look for
283
- * @return   mixed            String given if found, false otherwise
283
+ * @return   false|string            String given if found, false otherwise
284 284
  * @uses     myarraysearch    This function is just an additional layer on the myarraysearch() function
285 285
  */
286 286
 function CheckImageName(&$imgparams, $string)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -344,7 +344,7 @@
 block discarded – undo
344 344
                     if (is_dir($full_name)) {
345 345
                         $filelist[] = $file;
346 346
                     }
347
-               }
347
+                }
348 348
             }
349 349
         }
350 350
     }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     if ($title == '') {
67 67
         $title = basename($fname);
68 68
     }
69
-    return (string)$title;
69
+    return (string) $title;
70 70
 }
71 71
 
72 72
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         if ($src == '') {
177 177
             return '';
178 178
         } else {
179
-            $tmp_src = basename($src) ;
179
+            $tmp_src = basename($src);
180 180
             if ($tmp_src == '') {
181 181
                 return $src;
182 182
             } else {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 {
199 199
     // Select src tag from img tag.
200 200
     $match = array();
201
-    preg_match("|(src=\".*\" )|U", $imgtag, $match);            //src
201
+    preg_match("|(src=\".*\" )|U", $imgtag, $match); //src
202 202
     list($key, $srctag) = each($match);
203 203
     $src = substr($srctag, 5, (strlen($srctag) - 7));
204 204
     if (stristr($src, 'http') === false) {
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
         while (list($key, $imgtag) = each($match)) {
231 231
             $imgname = GetImgName($imgtag);
232 232
             if ($imgname != '' && !in_array($imgname, $imgparams)) {
233
-                array_push($imgparams, $imgname);    // name (+ type) of the images in the html test
234
-                $imgcount = $imgcount + 1;            // number of images in the html test
233
+                array_push($imgparams, $imgname); // name (+ type) of the images in the html test
234
+                $imgcount = $imgcount + 1; // number of images in the html test
235 235
             }
236 236
         }
237 237
     }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                 if ($file != '..') {
405 405
                     $full_name = $folder.'/'.$file;
406 406
                     if (is_dir($full_name)) {
407
-                        $dflag = 1;    // first directory
407
+                        $dflag = 1; // first directory
408 408
                     }
409 409
                 }
410 410
             }
Please login to merge, or discard this patch.
main/exercise/live_stats.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 $result = $objExercise->read($exercise_id);
18 18
 
19 19
 if (!$result) {
20
-	api_not_allowed(true);
20
+    api_not_allowed(true);
21 21
 }
22 22
 
23 23
 $interbreadcrumb[] = array(
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
42 42
 
43 43
 //The order is important you need to check the the $column variable in the model.ajax.php file
44
-$columns        = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
44
+$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
45 45
 
46 46
 //Column config
47 47
 $column_model = array(
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
 $(function() {
95 95
     <?php
96
-        echo Display::grid_js('live_stats',  $url, $columns, $column_model, $extra_params, array(), null, true);
96
+        echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true);
97 97
     ?>
98 98
     refreshGrid();
99 99
 });
100 100
 </script>
101 101
 <?php
102 102
 
103
-$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' .
104
-    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
103
+$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
104
+    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
105 105
 echo $actions = Display::div($actions, array('class'=> 'actions'));
106 106
 
107 107
 echo Display::grid_html('live_stats');
Please login to merge, or discard this patch.
main/exercise/multiple_answer_combination.class.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     /**
181
-	 * abstract function which creates the form to create/edit the answers of the question
182
-	 * @param FormValidator $form
183
-	 */
181
+     * abstract function which creates the form to create/edit the answers of the question
182
+     * @param FormValidator $form
183
+     */
184 184
     public function processAnswersCreation($form)
185 185
     {
186 186
         $questionWeighting = $nbrGoodAnswers = 0;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         // sets the total weighting of the question
222 222
         $this->updateWeighting($questionWeighting);
223 223
         $this->save();
224
-	}
224
+    }
225 225
 
226 226
     function return_header($feedback_type = null, $counter = null, $score = null)
227 227
     {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
         $html = '<table class="table table-striped table-hover">';
40 40
         $html .= '<thead>';
41 41
         $html .= '<tr>';
42
-        $html .= '<th width="10">' . get_lang('Number') . '</th>';
43
-        $html .= '<th width="10">' . get_lang('True') . '</th>';
44
-        $html .= '<th width="50%">' . get_lang('Comment') . '</th>';
45
-        $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
42
+        $html .= '<th width="10">'.get_lang('Number').'</th>';
43
+        $html .= '<th width="10">'.get_lang('True').'</th>';
44
+        $html .= '<th width="50%">'.get_lang('Comment').'</th>';
45
+        $html .= '<th width="50%">'.get_lang('Answer').'</th>';
46 46
         $html .= '</tr>';
47 47
         $html .= '</thead>';
48 48
         $html .= '<tbody>';
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
             $form->addHtml('<tr>');
75 75
 
76 76
             if (is_object($answer)) {
77
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
78
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
79
-                $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
80
-                $defaults['correct[' . $i . ']'] = $answer->correct[$i];
77
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
78
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
79
+                $defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1);
80
+                $defaults['correct['.$i.']'] = $answer->correct[$i];
81 81
             } else {
82 82
                 $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
83 83
                 $defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
@@ -93,44 +93,44 @@  discard block
 block discarded – undo
93 93
 
94 94
             $renderer->setElementTemplate(
95 95
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
96
-                'correct[' . $i . ']'
96
+                'correct['.$i.']'
97 97
             );
98 98
             $renderer->setElementTemplate(
99 99
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
100
-                'counter[' . $i . ']'
100
+                'counter['.$i.']'
101 101
             );
102 102
             $renderer->setElementTemplate(
103 103
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
104
-                'answer[' . $i . ']'
104
+                'answer['.$i.']'
105 105
             );
106 106
             $renderer->setElementTemplate(
107 107
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
108
-                'comment[' . $i . ']'
108
+                'comment['.$i.']'
109 109
             );
110 110
 
111
-            $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
111
+            $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
112 112
             $answer_number->freeze();
113 113
 
114 114
             $form->addElement('checkbox',
115
-                'correct[' . $i . ']',
115
+                'correct['.$i.']',
116 116
                 null,
117 117
                 null,
118 118
                 'class="checkbox" style="margin-left: 0em;"'
119 119
             );
120
-            $boxes_names[] = 'correct[' . $i . ']';
120
+            $boxes_names[] = 'correct['.$i.']';
121 121
 
122 122
             $form->addElement(
123 123
                 'html_editor',
124
-                'answer[' . $i . ']',
124
+                'answer['.$i.']',
125 125
                 null,
126 126
                 array(),
127 127
                 array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
128 128
             );
129
-            $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
129
+            $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
130 130
 
131 131
             $form->addElement(
132 132
                 'html_editor',
133
-                'comment[' . $i . ']',
133
+                'comment['.$i.']',
134 134
                 null,
135 135
                 array(),
136 136
                 array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     function return_header($feedback_type = null, $counter = null, $score = null)
227 227
     {
228 228
         $header = parent::return_header($feedback_type, $counter, $score);
229
-        $header .= '<table class="'.$this->question_table_class .'">
229
+        $header .= '<table class="'.$this->question_table_class.'">
230 230
             <tr>
231 231
                 <th>'.get_lang("Choice").'</th>
232 232
                 <th>'. get_lang("ExpectedChoice").'</th>
Please login to merge, or discard this patch.
main/exercise/stats.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $result = $objExercise->read($exercise_id);
13 13
 
14 14
 if (!$result) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $sessionId = api_get_session_id();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 $data = array();
30 30
 // Question title 	# of students who tool it 	Lowest score 	Average 	Highest score 	Maximum score
31 31
 $headers = array(
32
-	get_lang('Question'),
32
+    get_lang('Question'),
33 33
     get_lang('QuestionType'),
34 34
     get_lang('NumberStudentWhoSelectedIt'),
35
-	get_lang('LowestScore'),
36
-	get_lang('AverageScore'),
37
-	get_lang('HighestScore'),
38
-	get_lang('Weighting')
35
+    get_lang('LowestScore'),
36
+    get_lang('AverageScore'),
37
+    get_lang('HighestScore'),
38
+    get_lang('Weighting')
39 39
 );
40 40
 
41 41
 if (!empty($question_list)) {
42
-	foreach ($question_list as $question_id) {
42
+    foreach ($question_list as $question_id) {
43 43
         $question_obj = Question::read($question_id);
44 44
 
45 45
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
74 74
         $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
75 75
         $data[$question_id]['max_score'] = round($question_obj->weighting, 2);
76
-	}
76
+    }
77 77
 }
78 78
 
79 79
 // Format A table
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 $row = 0;
82 82
 $column = 0;
83 83
 foreach ($headers as $header) {
84
-	$table->setHeaderContents($row, $column, $header);
85
-	$column++;
84
+    $table->setHeaderContents($row, $column, $header);
85
+    $column++;
86 86
 }
87 87
 $row++;
88 88
 foreach ($data as $row_table) {
89
-	$column = 0;
90
-	foreach ($row_table as $cell) {
91
-		$table->setCellContents($row, $column, $cell);
92
-		$table->updateCellAttributes($row, $column, 'align="center"');
93
-		$column++;
94
-	}
95
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
-	$row++;
89
+    $column = 0;
90
+    foreach ($row_table as $cell) {
91
+        $table->setCellContents($row, $column, $cell);
92
+        $table->updateCellAttributes($row, $column, 'align="center"');
93
+        $column++;
94
+    }
95
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
+    $row++;
97 97
 }
98 98
 $content = $table->toHtml();
99 99
 
100 100
 // Format B
101 101
 
102 102
 $headers = array(
103
-	get_lang('Question'),
104
-	get_lang('Answer'),
105
-	get_lang('Correct'),
106
-	get_lang('NumberStudentWhoSelectedIt')
103
+    get_lang('Question'),
104
+    get_lang('Answer'),
105
+    get_lang('Correct'),
106
+    get_lang('NumberStudentWhoSelectedIt')
107 107
 );
108 108
 
109 109
 $data = array();
110 110
 
111 111
 if (!empty($question_list)) {
112 112
     $id = 0;
113
-	foreach ($question_list as $question_id) {
114
-		$question_obj = Question::read($question_id);
113
+    foreach ($question_list as $question_id) {
114
+        $question_obj = Question::read($question_id);
115 115
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
116 116
             $question_id,
117 117
             $exercise_id,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         );
121 121
 
122 122
         $answer = new Answer($question_id);
123
-		$answer_count = $answer->selectNbrAnswers();
123
+        $answer_count = $answer->selectNbrAnswers();
124 124
 
125 125
         for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
126 126
             $answer_info = $answer->selectAnswer($answer_id);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
                         $correct = '';
176 176
 
177 177
                         for ($i = 1; $i <= $answer_count; $i++) {
178
-                             $is_correct_i = $answer->isCorrect($i);
179
-                             if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
-                                 $correct = $answer->selectAnswer($i);
181
-                                 break;
182
-                             }
178
+                                $is_correct_i = $answer->isCorrect($i);
179
+                                if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
+                                    $correct = $answer->selectAnswer($i);
181
+                                    break;
182
+                                }
183 183
                         }
184 184
                         $data[$id]['answer'] = $correct;
185 185
                         $data[$id]['correct'] = $answer_info;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             }
246 246
             $id++;
247 247
         }
248
-	}
248
+    }
249 249
 }
250 250
 
251 251
 // Format A table
@@ -253,19 +253,19 @@  discard block
 block discarded – undo
253 253
 $row = 0;
254 254
 $column = 0;
255 255
 foreach ($headers as $header) {
256
-	$table->setHeaderContents($row, $column, $header);
257
-	$column++;
256
+    $table->setHeaderContents($row, $column, $header);
257
+    $column++;
258 258
 }
259 259
 $row++;
260 260
 foreach ($data as $row_table) {
261
-	$column = 0;
262
-	foreach ($row_table as $cell) {
263
-		$table->setCellContents($row, $column, $cell);
264
-		$table->updateCellAttributes($row, $column, 'align="center"');
265
-		$column++;
266
-	}
267
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
-	$row++;
261
+    $column = 0;
262
+    foreach ($row_table as $cell) {
263
+        $table->setCellContents($row, $column, $cell);
264
+        $table->updateCellAttributes($row, $column, 'align="center"');
265
+        $column++;
266
+    }
267
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
+    $row++;
269 269
 }
270 270
 $content .= $table->toHtml();
271 271
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
         $data[$question_id]['type'] = $question_obj->get_question_type_name();
62 62
         $percentange = 0;
63 63
         if ($count_students) {
64
-            $percentange = $count_users / $count_students*100;
64
+            $percentange = $count_users / $count_students * 100;
65 65
         }
66 66
 
67 67
         $data[$question_id]['students_who_try_exercise'] = Display::bar_progress(
68 68
             $percentange,
69 69
             false,
70
-            $count_users .' / '.$count_students
70
+            $count_users.' / '.$count_students
71 71
         );
72 72
         $data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
                         } else {
143 143
                             $data[$id]['name'] = '-';
144 144
                         }
145
-                        $data[$id]['answer'] 	= $answer_item;
145
+                        $data[$id]['answer'] = $answer_item;
146 146
 
147 147
                         $answer_item = api_substr($answer_item, 1);
148
-                        $answer_item = api_substr($answer_item, 0, api_strlen($answer_item) -1);
148
+                        $answer_item = api_substr($answer_item, 0, api_strlen($answer_item) - 1);
149 149
                         
150
-                        $data[$id]['answer'] 	= $answer_item;
150
+                        $data[$id]['answer'] = $answer_item;
151 151
 
152
-                        $data[$id]['correct'] 	= '-';
152
+                        $data[$id]['correct'] = '-';
153 153
 
154 154
                         $count = ExerciseLib::getNumberStudentsFillBlanksAnwserCount($question_id, $exercise_id);
155 155
                         $count = $count[$counter];
156 156
                         
157 157
                         $percentange = 0;
158 158
                         if (!empty($count_students)) {
159
-                            $percentange = $count/$count_students*100;
159
+                            $percentange = $count / $count_students * 100;
160 160
                         }
161
-                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
161
+                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
162 162
                         $id++;
163 163
                         $counter++;
164 164
                     }
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
                         );
195 195
                         $percentange = 0;
196 196
                         if (!empty($count_students)) {
197
-                            $percentange = $count/$count_students*100;
197
+                            $percentange = $count / $count_students * 100;
198 198
                         }
199
-                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
199
+                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
200 200
                     }
201 201
                     break;
202 202
                 case HOT_SPOT:
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
                     );
218 218
                     $percentange = 0;
219 219
                     if (!empty($count_students)) {
220
-                        $percentange = $count/$count_students*100;
220
+                        $percentange = $count / $count_students * 100;
221 221
                     }
222
-                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
222
+                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
223 223
                     break;
224 224
                 default:
225 225
                     if ($answer_id == 1) {
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
                     );
240 240
                     $percentange = 0;
241 241
                     if (!empty($count_students)) {
242
-                        $percentange = $count/$count_students*100;
242
+                        $percentange = $count / $count_students * 100;
243 243
                     }
244
-                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
244
+                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
245 245
             }
246 246
             $id++;
247 247
         }
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 $interbreadcrumb[] = array("url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(), "name" => $objExercise->name);
274 274
 
275 275
 $tpl = new Template(get_lang('ReportByQuestion'));
276
-$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' .
277
-    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
276
+$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
277
+    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
278 278
 $actions = Display::div($actions, array('class'=> 'actions'));
279 279
 $content = $actions.$content;
280 280
 $tpl->assign('content', $content);
Please login to merge, or discard this patch.