Browse Source

Merge branch 'AngelFQC-7268' into 1.10.x

Yannick Warnier 10 years ago
parent
commit
f7e0530f2c
40 changed files with 144 additions and 119 deletions
  1. 2 2
      main/admin/user_move_stats.php
  2. 1 1
      main/exercice/exercice.php
  3. 17 10
      main/exercice/exercise.class.php
  4. 1 1
      main/exercice/exercise_history.php
  5. 3 1
      main/exercice/exercise_report.php
  6. 1 1
      main/exercice/exercise_result.class.php
  7. 4 2
      main/exercice/exercise_show.php
  8. 2 2
      main/exercice/exercise_submit.php
  9. 1 1
      main/exercice/hotpotatoes_exercise_report.php
  10. 1 1
      main/exercice/mark_free_answer.php
  11. 7 6
      main/exercice/overview.php
  12. 1 1
      main/gradebook/gradebook_result.class.php
  13. 2 2
      main/gradebook/lib/be/exerciselink.class.php
  14. 1 1
      main/inc/ajax/exercise.ajax.php
  15. 1 1
      main/inc/ajax/model.ajax.php
  16. 1 1
      main/inc/lib/course.lib.php
  17. 1 1
      main/inc/lib/database.constants.inc.php
  18. 23 22
      main/inc/lib/events.lib.inc.php
  19. 11 9
      main/inc/lib/exercise.lib.php
  20. 1 1
      main/inc/lib/myspace.lib.php
  21. 4 4
      main/inc/lib/online.inc.php
  22. 4 4
      main/inc/lib/sessionmanager.lib.php
  23. 8 8
      main/inc/lib/tracking.lib.php
  24. 1 1
      main/install/db_main.sql
  25. 19 16
      main/install/db_stats.sql
  26. 1 1
      main/install/migrate-db-1.9.0-1.10.0-post.sql
  27. 9 2
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  28. 1 1
      main/install/update-db-1.9.0-1.10.0.inc.php
  29. 2 2
      main/mySpace/myStudents.php
  30. 1 1
      main/mySpace/progression.php
  31. 1 1
      main/mySpace/reussite.php
  32. 3 3
      main/newscorm/learnpathItem.class.php
  33. 1 1
      main/newscorm/lp_view.php
  34. 1 1
      main/reports/modules/quiz.php
  35. 1 1
      main/tracking/courseLog.php
  36. 1 1
      main/tracking/exams.php
  37. 1 1
      main/tracking/personnalLog.php
  38. 1 1
      tests/datafiller/fill_whoisonline.php
  39. 1 1
      tests/scripts/fix_exercise_score_in_lp.php
  40. 1 1
      tests/scripts/move_users.php

+ 2 - 2
main/admin/user_move_stats.php

@@ -116,7 +116,7 @@ if (isset($_REQUEST['load_ajax'])) {
                 $course_info = api_get_course_info($origin_course_code);
                 $course_id = $course_info['real_id'];
 
-                $TABLETRACK_EXERCICES       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+                $TABLETRACK_EXERCICES       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
                 $TBL_TRACK_ATTEMPT          = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
                 $TBL_TRACK_E_COURSE_ACCESS  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
                 $TBL_TRACK_E_LAST_ACCESS    = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
@@ -581,7 +581,7 @@ $htmlHeadXtra[] = '<script type="text/javascript">
  </script>';
 
 function get_courses_list_by_user_id_based_in_exercises($user_id) {
-    $TABLETRACK_EXERCICES       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    $TABLETRACK_EXERCICES       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $user_id = intval($user_id);
     //$sql = "SELECT DISTINCT exe_user_id, exe_cours_id as code, session_id as id_session FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_id GROUP BY exe_user_id, exe_cours_id ORDER by exe_user_id, exe_cours_id ASC";
     $sql = "SELECT DISTINCT exe_user_id, exe_cours_id as code, session_id as id_session

+ 1 - 1
main/exercice/exercice.php

@@ -51,7 +51,7 @@ $TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
 $TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
 $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
 $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
-$TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 // document path
 $documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path']."/document";

+ 17 - 10
main/exercice/exercise.class.php

@@ -1571,7 +1571,7 @@ class Exercise
      */
     public function clean_results($cleanLpTests = false, $cleanResultBeforeDate = null)
     {
-        $table_track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_e_attempt   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
         $sql_where = '  AND
@@ -1617,7 +1617,7 @@ class Exercise
         }
 
         $session_id = api_get_session_id();
-        // delete TRACK_E_EXERCICES table
+        // delete TRACK_E_EXERCISES table
         $sql = "DELETE FROM $table_track_e_exercises
                 WHERE exe_cours_id = '".api_get_course_id()."'
                 AND exe_exo_id = ".$this->id."
@@ -1710,7 +1710,7 @@ class Exercise
         $lp_item_view_id = 0,
         $status = 'incomplete'
     ) {
-        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         if (empty($lp_id)) {
             $lp_id = 0;
         }
@@ -1758,11 +1758,13 @@ class Exercise
         $questionList = array(),
         $weight = 0
     ) {
-        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $safe_lp_id = intval($safe_lp_id);
         $safe_lp_item_id = intval($safe_lp_item_id);
         $safe_lp_item_view_id = intval($safe_lp_item_view_id);
 
+        $trackValues = array();
+
         if (empty($safe_lp_id)) {
             $safe_lp_id = 0;
         }
@@ -1788,6 +1790,7 @@ class Exercise
             'orig_lp_item_id'  => $safe_lp_item_id,
             'orig_lp_item_view_id'  => $safe_lp_item_view_id,
             'exe_weighting'=> $weight,
+            'user_ip' => api_get_real_ip()
         );
 
         if ($this->expired_time != 0) {
@@ -1795,7 +1798,6 @@ class Exercise
         }
 
         $id = Database::insert($track_exercises, $params);
-
         return $id;
     }
 
@@ -3601,7 +3603,7 @@ class Exercise
         }
 
         if ($saved_results) {
-            $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+            $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
             $sql = 'UPDATE ' . $stat_table . ' SET
                         exe_result = exe_result + ' . floatval($questionScore) . '
                     WHERE exe_id = ' . $exeId;
@@ -3876,9 +3878,10 @@ class Exercise
      * @param array $user_data result of api_get_user_info()
      * @param null $start_date
      * @param null $duration
+     * @param string $ip Optional. The user IP
      * @return string
      */
-    public function show_exercise_result_header($user_data, $start_date = null, $duration = null)
+    public function show_exercise_result_header($user_data, $start_date = null, $duration = null, $ip = null)
     {
         $array = array();
 
@@ -3908,6 +3911,10 @@ class Exercise
             $array[] = array('title' => get_lang("Duration"), 'content' => $duration);
         }
 
+        if (!empty($ip)) {
+            $array[] = array("title" => get_lang("IP"), "content" => $ip);
+        }
+
         $html  = Display::page_header(
             Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result')
         );
@@ -4283,7 +4290,7 @@ class Exercise
 
     public function get_stat_track_exercise_info_by_exe_id($exe_id)
     {
-        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $exe_id = intval($exe_id);
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
         $result = Database::query($sql_track);
@@ -4317,7 +4324,7 @@ class Exercise
         $exercise_info = self::get_stat_track_exercise_info_by_exe_id($exe_id);
         $question_id = intval($question_id);
         $exe_id = intval($exe_id);
-        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         if ($exercise_info) {
 
             if (empty($exercise_info['questions_to_check'])) {
@@ -4555,7 +4562,7 @@ class Exercise
         $ids = is_array($quizId) ? $quizId : array($quizId);
         $ids = array_map('intval', $ids);
         $ids = implode(',', $ids);
-        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         if ($sessionId != 0) {
             $sql = "SELECT * FROM $track_exercises te "
               . "INNER JOIN c_quiz cq ON cq.id = te.exe_exo_id "

+ 1 - 1
main/exercice/exercise_history.php

@@ -37,7 +37,7 @@ $interbreadcrumb[]= array ('url' => 'exercise_history.php'.'?exe_id='.intval($_G
 $TBL_USER          	    = Database::get_main_table(TABLE_MAIN_USER);
 $TBL_EXERCICES			= Database::get_course_table(TABLE_QUIZ_TEST);
 $TBL_EXERCICES_QUESTION	= Database::get_course_table(TABLE_QUIZ_QUESTION);
-$TBL_TRACK_EXERCICES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $TBL_TRACK_ATTEMPT_RECORDING= Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
 Display::display_header($nameTools,get_lang('Exercise'));
 

+ 3 - 1
main/exercice/exercise_report.php

@@ -41,7 +41,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh() || api_is
 $is_tutor = api_is_allowed_to_edit(true);
 
 $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);
-$TBL_TRACK_EXERCICES = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $TBL_TRACK_ATTEMPT = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 $TBL_TRACK_ATTEMPT_RECORDING = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
 $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
@@ -415,6 +415,7 @@ if ($is_allowedToEdit || $is_tutor) {
         get_lang('StartDate'),
         get_lang('EndDate'),
         get_lang('Score'),
+        get_lang('IP'),
         get_lang('Status'),
         get_lang('ToolLearnpath'),
         get_lang('Actions')
@@ -440,6 +441,7 @@ if ($is_allowedToEdit || $is_tutor) {
         array('name' => 'start_date', 'index' => 'start_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
         array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
         array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'true'),
+        array('name' => 'ip', 'index' => 'user_ip', 'width' => '40', 'align' => 'center', 'search' => 'true'),
         array('name' => 'status', 'index' => 'revised', 'width' => '40', 'align' => 'left', 'search' => 'true', 'stype' => 'select',
             //for the bottom bar
             'searchoptions' => array(

+ 1 - 1
main/exercice/exercise_result.class.php

@@ -52,7 +52,7 @@ class ExerciseResult
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
 
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
-        $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $TBL_TRACK_ATTEMPT_RECORDING = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
 
         $cid = api_get_course_id();

+ 4 - 2
main/exercice/exercise_show.php

@@ -33,7 +33,7 @@ if ($origin == 'learnpath') {
 // Database table definitions
 $TBL_EXERCICE_QUESTION 	= Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
 $TBL_QUESTIONS         	= Database::get_course_table(TABLE_QUIZ_QUESTION);
-$TBL_TRACK_EXERCICES    = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES    = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $TBL_TRACK_ATTEMPT		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
 // General parameters passed via POST/GET
@@ -215,7 +215,9 @@ if ($show_results || $show_only_total_score) {
     //Shows exercise header
     echo $objExercise->show_exercise_result_header(
         $user_info,
-        api_convert_and_format_date($exercise_date)
+        api_convert_and_format_date($exercise_date),
+        null,
+        $track_exercise_info['user_ip']
     );
 }
 

+ 2 - 2
main/exercice/exercise_submit.php

@@ -148,7 +148,7 @@ $current_expired_time_key = ExerciseLib::get_time_control_key($objExercise->id,
 $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
 
 if ($time_control) {
-	// Get the expired time of the current exercice in track_e_exercices
+	// Get the expired time of the current exercice in track_e_exercises
 	$total_seconds = $objExercise->expired_time*60;
 }
 
@@ -358,7 +358,7 @@ if ($time_control) {
 	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
 
 			// First we update the attempt to today
-			/* How the expired time is changed into "track_e_exercices" table,
+			/* How the expired time is changed into "track_e_exercises" table,
                then the last attempt for this student should be changed too */
 	        $sql = "UPDATE $exercice_attemp_table SET
 	                tms = '".api_get_utc_datetime()."'

+ 1 - 1
main/exercice/hotpotatoes_exercise_report.php

@@ -35,7 +35,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh();
 $is_tutor = api_is_allowed_to_edit(true);
 
 $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);
-$TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $TBL_TRACK_HOTPOTATOES_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
 $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
 

+ 1 - 1
main/exercice/mark_free_answer.php

@@ -82,7 +82,7 @@ if ($action == 'mark') {
 	if (!empty($_POST['score']) AND $_POST['score'] < $obj_question->selectWeighting() AND $_POST['score'] >= 0) {
 		//mark the user mark into the database using something similar to the following function:
 
-		$exercise_table = Database::get_statistic_table('track_e_exercices');
+		$exercise_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 		#global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id;
 		$sql = "SELECT * FROM $exercise_table
 			    WHERE exe_user_id = ".intval($my_usr)." AND exe_cours_id = '".Database::escape_string($my_cid)."' AND exe_exo_id = ".intval($my_exe)."

+ 7 - 6
main/exercice/overview.php

@@ -133,7 +133,7 @@ if ($visible_return['value'] == false) {
 $attempts = Event::getExerciseResultsByUser(
     api_get_user_id(),
     $objExercise->id,
-    api_get_course_id(),
+    api_get_course_int_id(),
     api_get_session_id(),
     $learnpath_id,
     $learnpath_item_id,
@@ -182,7 +182,8 @@ if (!empty($attempts) && $visible_return['value'] == true) {
             'date' => api_convert_and_format_date(
                 $attempt_result['start_date'],
                 DATE_TIME_FORMAT_LONG
-            )
+            ),
+            'userIp' => $attempt_result['user_ip']
         );
         $attempt_link .= "&nbsp;&nbsp;&nbsp;" . $teacher_revised;
 
@@ -217,17 +218,17 @@ if (!empty($attempts) && $visible_return['value'] == true) {
 	switch ($objExercise->results_disabled) {
 		case RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS:
         case RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES:
-			$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('Score'), get_lang('Details'));
+			$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
 			break;
 		case RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS:
-			$header_names = array(get_lang('Attempt'), get_lang('StartDate'));
+			$header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'));
 			break;
 		case RESULT_DISABLE_SHOW_SCORE_ONLY:
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
-			    $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('Score'));
+			    $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
             }
             else {
-                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('Score'), get_lang('Details'));
+                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
             }
 			break;
 	}

+ 1 - 1
main/gradebook/gradebook_result.class.php

@@ -88,7 +88,7 @@ class GradeBookResult
         $return = array();
         $TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
         $TBL_USER          	    = Database::get_main_table(TABLE_MAIN_USER);
-        $TBL_TRACK_EXERCISES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $TBL_TRACK_EXERCISES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $TBL_TRACK_HOTPOTATOES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
 
         $cid = api_get_course_id();

+ 2 - 2
main/gradebook/lib/be/exerciselink.class.php

@@ -138,7 +138,7 @@ class ExerciseLink extends AbstractLink
      */
     public function has_results()
     {
-        $tbl_stats = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tbl_stats = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $session_id = api_get_session_id();
         $sql = 'SELECT count(exe_id) AS number FROM '.$tbl_stats."
                 WHERE
@@ -159,7 +159,7 @@ class ExerciseLink extends AbstractLink
      */
     public function calc_score($stud_id = null)
     {
-        $tblStats = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tblStats = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $tblHp = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
         $tblDoc = Database::get_course_table(TABLE_DOCUMENT);
 

+ 1 - 1
main/inc/ajax/exercise.ajax.php

@@ -42,7 +42,7 @@ switch ($action) {
             $sidx = 1;
         }
 
-        $track_exercise = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_exercise = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $user_table = Database::get_main_table(TABLE_MAIN_USER);
         $track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 

+ 1 - 1
main/inc/ajax/model.ajax.php

@@ -658,7 +658,7 @@ switch ($action) {
         $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
         if ($is_allowedToEdit || api_is_student_boss()) {
             $columns = array(
-                'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'
+                'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score',  'user_ip', 'status', 'lp', 'actions'
             );
             $officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
             if ($officialCodeInList == true) {

+ 1 - 1
main/inc/lib/course.lib.php

@@ -2211,7 +2211,7 @@ class CourseManager
 
         $table_stats_hotpots = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
         $table_stats_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-        $table_stats_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_stats_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_stats_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
         $table_stats_lastaccess = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
         $table_stats_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);

+ 1 - 1
main/inc/lib/database.constants.inc.php

@@ -134,7 +134,7 @@ define('TABLE_STATISTIC_TRACK_E_LINKS',             'track_e_links');
 define('TABLE_STATISTIC_TRACK_E_ONLINE',            'track_e_online');
 define('TABLE_STATISTIC_TRACK_E_HOTPOTATOES',       'track_e_hotpotatoes');
 define('TABLE_STATISTIC_TRACK_E_COURSE_ACCESS',     'track_e_course_access');
-define('TABLE_STATISTIC_TRACK_E_EXERCICES',         'track_e_exercices');
+define('TABLE_STATISTIC_TRACK_E_EXERCISES',         'track_e_exercises');
 define('TABLE_STATISTIC_TRACK_E_ATTEMPT',           'track_e_attempt');
 define('TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING', 'track_e_attempt_recording');
 define('TABLE_STATISTIC_TRACK_E_DEFAULT',           'track_e_default');

+ 23 - 22
main/inc/lib/events.lib.inc.php

@@ -68,7 +68,7 @@ class Event
 
         $reallyNow = api_get_utc_datetime();
 
-        $sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date) VALUES
+        $sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, user_ip, login_date, logout_date) VALUES
                     ('".$userId."',
                     '".Database::escape_string(api_get_real_ip())."',
                     '".$reallyNow."',
@@ -348,7 +348,7 @@ class Event
                 $status = Database::escape_string($status);
             }
 
-            $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+            $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
             if (!empty($question_list)) {
                 $question_list = array_map('intval', $question_list);
@@ -374,11 +374,12 @@ class Event
         		   orig_lp_id 			= '".Database::escape_string($learnpath_id)."',
         		   orig_lp_item_id 		= '".Database::escape_string($learnpath_item_id)."',
                    orig_lp_item_view_id = '".Database::escape_string($learnpath_item_view_id)."',
-        		   exe_duration 		= '".Database::escape_string($duration)."',
-        		   exe_date				= '".$end_date."',
-        		   status 				= '".$status."',
-        		   questions_to_check 	= '".$remind_list."',
-        		   data_tracking    	= '".implode(',', $question_list)."'
+        		   exe_duration = '".Database::escape_string($duration)."',
+        		   exe_date = '".$end_date."',
+        		   status = '".$status."',
+        		   questions_to_check = '".$remind_list."',
+        		   data_tracking = '".implode(',', $question_list)."',
+                   user_ip = '" . Database::escape_string(api_get_real_ip()) . "'
         		 WHERE exe_id = '".Database::escape_string($exeid)."'";
             $res = Database::query($sql);
 
@@ -915,7 +916,7 @@ class Event
      */
     public static function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id, $lp_item_view_id)
     {
-        $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $user_id = intval($user_id);
         $exerciseId = intval($exerciseId);
         $lp_id = intval($lp_id);
@@ -950,7 +951,7 @@ class Event
      */
     public static function get_attempt_count_not_finished($user_id, $exerciseId, $lp_id, $lp_item_id)
     {
-        $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $user_id = intval($user_id);
         $exerciseId = intval($exerciseId);
         $lp_id = intval($lp_id);
@@ -995,7 +996,7 @@ class Event
         }
 
         $track_e_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_attempts = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_ATTEMPT
@@ -1094,7 +1095,7 @@ class Event
      */
     public static function delete_all_incomplete_attempts($user_id, $exercise_id, $course_id, $session_id = 0)
     {
-        $track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $user_id = intval($user_id);
         $exercise_id = intval($exercise_id);
         $course_id = intval($course_id);
@@ -1130,7 +1131,7 @@ class Event
      */
     public static function get_all_exercise_results($exercise_id, $courseId, $session_id = 0, $load_question_list = true, $user_id = null)
     {
-        $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $courseId = intval($courseId);
         $exercise_id = intval($exercise_id);
@@ -1175,7 +1176,7 @@ class Event
      */
     public static function get_all_exercise_results_by_course($courseId, $session_id = 0, $get_count = true)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $courseId = intval($courseId);
         $session_id = intval($session_id);
@@ -1219,7 +1220,7 @@ class Event
      */
     public static function get_all_exercise_results_by_user($user_id, $courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $courseId = intval($courseId);
         $session_id = intval($session_id);
@@ -1258,7 +1259,7 @@ class Event
      */
     public static function get_exercise_results_by_attempt($exe_id, $status = null)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $table_track_attempt_recording = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
         $exe_id = intval($exe_id);
@@ -1303,7 +1304,7 @@ class Event
      */
     public static function getExerciseResultsByUser($user_id, $exercise_id, $courseId, $session_id = 0, $lp_id = 0, $lp_item_id = 0, $order = null)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $table_track_attempt_recording = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
         $courseId = intval($courseId);
@@ -1358,7 +1359,7 @@ class Event
      */
     public static function count_exercise_attempts_by_user($user_id, $exercise_id, $courseId, $session_id = 0)
     {
-        $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $courseId = intval($courseId);
         $exercise_id = intval($exercise_id);
         $session_id = intval($session_id);
@@ -1393,7 +1394,7 @@ class Event
      */
     public static function get_best_exercise_results_by_user($exercise_id, $courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $courseId = intval($courseId);
         $exercise_id = intval($exercise_id);
@@ -1442,7 +1443,7 @@ class Event
      */
     public static function get_best_attempt_exercise_results_per_user($user_id, $exercise_id, $courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $courseId = intval($courseId);
         $exercise_id = intval($exercise_id);
         $session_id = intval($session_id);
@@ -1492,7 +1493,7 @@ class Event
      */
     public static function count_exercise_result_not_validated($exercise_id, $courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
         $courseId = intval($courseId);
         $session_id = intval($session_id);
@@ -1526,7 +1527,7 @@ class Event
      */
     public static function get_count_exercises_attempted_by_course($courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $courseId = intval($courseId);
         $session_id = intval($session_id);
 
@@ -1555,7 +1556,7 @@ class Event
      */
     public static function get_all_exercise_event_from_lp($exercise_id, $courseId, $session_id = 0)
     {
-        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
         $courseId = intval($courseId);
         $exercise_id = intval($exercise_id);

+ 11 - 9
main/inc/lib/exercise.lib.php

@@ -1133,7 +1133,7 @@ class ExerciseLib
     {
         $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
         $TBL_TRACK_EXERCICES = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $TBL_COURSE = Database::get_main_table(TABLE_MAIN_COURSE);
         $exe_id = intval($exe_id);
@@ -1445,7 +1445,7 @@ class ExerciseLib
         $TBL_GROUP_REL_USER = Database:: get_course_table(TABLE_GROUP_USER);
         $TBL_GROUP = Database:: get_course_table(TABLE_GROUP);
         $TBL_TRACK_EXERCICES = Database:: get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $TBL_TRACK_HOTPOTATOES = Database:: get_main_table(
             TABLE_STATISTIC_TRACK_E_HOTPOTATOES
@@ -1592,7 +1592,8 @@ class ExerciseLib
                     revised,
                     group_name,
                     group_id,
-                    orig_lp_id";
+                    orig_lp_id,
+                    te.user_ip";
             }
 
             $sql = " $sql_select
@@ -2722,7 +2723,7 @@ class ExerciseLib
         $session_id
     ) {
         $track_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_attempt = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_ATTEMPT
@@ -2771,7 +2772,7 @@ class ExerciseLib
         $session_id
     ) {
         $track_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_attempt = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_ATTEMPT
@@ -2841,7 +2842,7 @@ class ExerciseLib
         $session_id
     ) {
         $track_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_hotspot = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_HOTSPOT
@@ -2915,7 +2916,7 @@ class ExerciseLib
         $current_answer = null
     ) {
         $track_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_attempt = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_ATTEMPT
@@ -3130,7 +3131,7 @@ class ExerciseLib
         $session_id
     ) {
         $track_exercises = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCICES
+            TABLE_STATISTIC_TRACK_E_EXERCISES
         );
         $track_attempt = Database::get_main_table(
             TABLE_STATISTIC_TRACK_E_ATTEMPT
@@ -3301,7 +3302,8 @@ class ExerciseLib
                     $exercise_stat_info['start_date'],
                     DATE_TIME_FORMAT_LONG
                 ),
-                $exercise_stat_info['duration']
+                $exercise_stat_info['duration'],
+                $exercise_stat_info['user_ip']
             );
         }
 

+ 1 - 1
main/inc/lib/myspace.lib.php

@@ -1878,7 +1878,7 @@ class MySpace
     {
         $questions_answered = 0;
         $sql = 'SELECT exe_result , exe_weighting
-            FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES)."
+            FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)."
             WHERE exe_cours_id = '".Database::escape_string($course_code)."'
             AND exe_user_id = '".intval($user_id)."'";
         if($session_id !== false) {

+ 4 - 4
main/inc/lib/online.inc.php

@@ -24,9 +24,9 @@ function LoginCheck($uid) {
 	$uid = (int) $uid;
 	$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
     if (!empty($uid)) {
-        $login_ip = '';
+        $user_ip = '';
         if (!empty($_SERVER['REMOTE_ADDR'])) {
-            $login_ip = Database::escape_string($_SERVER['REMOTE_ADDR']);
+            $user_ip = Database::escape_string(api_get_real_ip());
         }
 
 		$login_date = api_get_utc_datetime();
@@ -38,9 +38,9 @@ function LoginCheck($uid) {
 		// if the $_course array exists this means we are in a course and we have to store this in the who's online table also
 		// to have the x users in this course feature working
 		if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) {
-            $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,login_ip, c_id, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$login_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )";
+            $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )";
 		} else {
-            $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,login_ip, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$login_ip', '$session_id', '$access_url_id')";
+            $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$user_ip', '$session_id', '$access_url_id')";
 		}
 		@Database::query($query);
 	}

+ 4 - 4
main/inc/lib/sessionmanager.lib.php

@@ -1271,17 +1271,17 @@ class SessionManager
 
         foreach ($return as $key => $info) {
             //Search for ip, we do less querys if we iterate the final array
-            $sql = sprintf("SELECT login_ip FROM $track_e_login WHERE login_user_id = %d AND login_date < '%s' ORDER BY login_date DESC LIMIT 1", $info['user_id'], $info['logindate']); //TODO add select by user too
+            $sql = sprintf("SELECT user_ip FROM $track_e_login WHERE login_user_id = %d AND login_date < '%s' ORDER BY login_date DESC LIMIT 1", $info['user_id'], $info['logindate']); //TODO add select by user too
             $result = Database::query($sql);
             $ip = Database::fetch_assoc($result);
             //if no ip founded, we search the closest higher ip
-            if (empty($ip['login_ip'])) {
-                $sql = sprintf("SELECT login_ip FROM $track_e_login WHERE login_user_id = %d AND login_date > '%s'  ORDER BY login_date ASC LIMIT 1", $info['user_id'], $info['logindate']); //TODO add select by user too
+            if (empty($ip['user_ip'])) {
+                $sql = sprintf("SELECT user_ip FROM $track_e_login WHERE login_user_id = %d AND login_date > '%s'  ORDER BY login_date ASC LIMIT 1", $info['user_id'], $info['logindate']); //TODO add select by user too
                 $result = Database::query($sql);
                 $ip = Database::fetch_assoc($result);
             }
             #add ip to final array
-            $return[$key]['ip'] = $ip['login_ip'];
+            $return[$key]['ip'] = $ip['user_ip'];
         }
         return $return;
     }

+ 8 - 8
main/inc/lib/tracking.lib.php

@@ -119,7 +119,7 @@ class Tracking
         $TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW);
         $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION);
         $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
-        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
         $sql = "SELECT max(view_count)
@@ -1606,7 +1606,7 @@ class Tracking
     	if (!empty($course_info)) {
     		// table definition
     		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
     		// Compose a filter based on optional exercise given
     		$condition_quiz = "";
@@ -1756,7 +1756,7 @@ class Tracking
 
     	$lp_id = intval($lp_id);
         $lp_item_id = intval($lp_item_id);
-    	$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    	$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
     	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercices AS ex
                 WHERE  ex.exe_cours_id = '$course_code'
@@ -1797,7 +1797,7 @@ class Tracking
         if (empty($exercise_list)) {
             return '0%';
         }
-        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $exercise_list = array_keys($exercise_list);
         $exercise_list = array_map('intval', $exercise_list);
 
@@ -2123,7 +2123,7 @@ class Tracking
         }
 
         if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
-        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
         $course = api_get_course_info($course_code);
@@ -3724,7 +3724,7 @@ class Tracking
                 'start_date'=> 'login_course_date',
                 'end_date'  => 'logout_course_date',
                 ),*/
-            TABLE_STATISTIC_TRACK_E_EXERCICES => array(
+            TABLE_STATISTIC_TRACK_E_EXERCISES => array(
                 'course'    => 'c_id',
                 'session'   => 'session_id',
                 'user'      => 'exe_user_id',
@@ -5189,7 +5189,7 @@ class Tracking
         $tquiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
         $tquiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
         $tquiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
-        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $ttrack_attempt    = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
         $sessions = array();
@@ -6534,7 +6534,7 @@ class TrackingUserLog
             return false;
         }
         $table_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-        $sql_ip = "SELECT login_date, login_ip FROM $table_login WHERE login_user_id = $user_id AND login_date < '$event_date' ORDER BY login_date DESC LIMIT 1";
+        $sql_ip = "SELECT login_date, user_ip FROM $table_login WHERE login_user_id = $user_id AND login_date < '$event_date' ORDER BY login_date DESC LIMIT 1";
         $ip = '';
         $res_ip = Database::query($sql_ip);
         if ($res_ip !== false && Database::num_rows($res_ip)>0) {

+ 1 - 1
main/install/db_main.sql

@@ -884,7 +884,7 @@ VALUES
 ('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1),
 ('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1),
 ('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1),
-('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.11','DatabaseVersion','', NULL, NULL, 0);
+('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.12','DatabaseVersion','', NULL, NULL, 0);
 UNLOCK TABLES;
 /*!40000 ALTER TABLE settings_current ENABLE KEYS */;
 

+ 19 - 16
main/install/db_stats.sql

@@ -58,6 +58,7 @@ CREATE TABLE track_e_access (
   c_id int not null,
   access_tool varchar(30) default NULL,
   access_session_id int NOT NULL default 0,
+  user_ip varchar(39) NOT NULL default '',
   PRIMARY KEY  (access_id),
   KEY access_user_id (access_user_id),
   KEY access_c_id (c_id),
@@ -108,8 +109,8 @@ CREATE TABLE track_e_downloads (
   KEY down_cours_id (down_cours_id)
 );
 
-DROP TABLE IF EXISTS track_e_exercices;
-CREATE TABLE track_e_exercices (
+DROP TABLE IF EXISTS track_e_exercises;
+CREATE TABLE track_e_exercises (
   exe_id int NOT NULL auto_increment,
   exe_user_id int unsigned default NULL,
   exe_date datetime NOT NULL default '0000-00-00 00:00:00',
@@ -118,23 +119,24 @@ CREATE TABLE track_e_exercices (
   exe_exo_id mediumint unsigned NOT NULL default 0,
   exe_result float(6,2) NOT NULL default 0,
   exe_weighting float(6,2) NOT NULL default 0,
+  user_ip varchar(39) NOT NULL default '',
   PRIMARY KEY  (exe_id),
   KEY exe_user_id (exe_user_id),
   KEY exe_cours_id (exe_cours_id)
 );
 
-ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
-ALTER TABLE track_e_exercices ADD data_tracking text NOT NULL default '';
-ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
-ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD session_id SMALLINT UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
-ALTER TABLE track_e_exercices ADD orig_lp_id int  NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD orig_lp_item_id int  NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD exe_duration int UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
-ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
-ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT  NOT NULL DEFAULT '';
+ALTER TABLE track_e_exercises ADD status varchar(20) NOT NULL default '';
+ALTER TABLE track_e_exercises ADD data_tracking text NOT NULL default '';
+ALTER TABLE track_e_exercises ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE track_e_exercises ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercises ADD session_id SMALLINT UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercises ADD INDEX ( session_id ) ;
+ALTER TABLE track_e_exercises ADD orig_lp_id int  NOT NULL default 0;
+ALTER TABLE track_e_exercises ADD orig_lp_item_id int  NOT NULL default 0;
+ALTER TABLE track_e_exercises ADD exe_duration int UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercises ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
+ALTER TABLE track_e_exercises ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
+ALTER TABLE track_e_exercises ADD COLUMN questions_to_check TEXT  NOT NULL DEFAULT '';
 
 DROP TABLE IF EXISTS track_e_attempt;
 CREATE TABLE track_e_attempt (
@@ -205,7 +207,7 @@ CREATE TABLE track_e_login (
   login_id int NOT NULL auto_increment,
   login_user_id int unsigned NOT NULL default 0,
   login_date datetime NOT NULL default '0000-00-00 00:00:00',
-  login_ip varchar(39) NOT NULL default '',
+  user_ip varchar(39) NOT NULL default '',
   logout_date datetime NULL default NULL,
   PRIMARY KEY  (login_id),
   KEY login_user_id (login_user_id)
@@ -216,7 +218,7 @@ CREATE TABLE track_e_online (
   login_id int NOT NULL auto_increment,
   login_user_id int unsigned NOT NULL default 0,
   login_date datetime NOT NULL default '0000-00-00 00:00:00',
-  login_ip varchar(39) NOT NULL default '',
+  user_ip varchar(39) NOT NULL default '',
   course varchar(40) default NULL,
   c_id int NOT NULL,
   session_id INT NOT NULL DEFAULT 0,
@@ -258,6 +260,7 @@ CREATE TABLE track_e_course_access (
   logout_course_date datetime default NULL,
   counter int NOT NULL,
   session_id int NOT NULL default 0,
+  user_ip varchar(39) NOT NULL default '',
   PRIMARY KEY  (course_access_id)
 );
 

+ 1 - 1
main/install/migrate-db-1.9.0-1.10.0-post.sql

@@ -17,7 +17,7 @@
 ALTER TABLE track_e_access DROP COLUMN access_cours_code;
 ALTER TABLE track_e_default DROP COLUMN default_cours_code;
 ALTER TABLE track_e_lastaccess DROP COLUMN access_cours_code;
-ALTER TABLE track_e_exercices DROP COLUMN exe_cours_id;
+ALTER TABLE track_e_exercises DROP COLUMN exe_cours_id;
 ALTER TABLE track_e_downloads DROP COLUMN down_cours_id;
 ALTER TABLE track_e_hotpotatoes DROP COLUMN exe_cours_id;
 ALTER TABLE track_e_links DROP COLUMN links_cours_id;

+ 9 - 2
main/install/migrate-db-1.9.0-1.10.0-pre.sql

@@ -36,12 +36,14 @@ ALTER TABLE skill ADD COLUMN criteria text DEFAULT '';
 
 ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0;
 
+RENAME TABLE track_e_exercices TO track_e_exercises;
+
 ALTER TABLE session_rel_user ADD COLUMN duration int;
 
 ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_default ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_lastaccess ADD COLUMN c_id int NOT NULL;
-ALTER TABLE track_e_exercices ADD COLUMN c_id int NOT NULL;
+ALTER TABLE track_e_exercises ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_downloads ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int NOT NULL;
 ALTER TABLE track_e_links ADD COLUMN c_id int NOT NULL;
@@ -55,9 +57,14 @@ DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages';
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('prevent_session_admins_to_manage_all_users', 'true', 'Yes'), ('prevent_session_admins_to_manage_all_users', 'false', 'No');
 
+ALTER TABLE track_e_access ADD COLUMN user_ip varchar(39) NOT NULL default '';
+ALTER TABLE track_e_exercises ADD COLUMN user_ip varchar(39) NOT NULL default '';
+ALTER TABLE track_e_course_access ADD COLUMN user_ip varchar(39) NOT NULL default '';
+ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT '';
+ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT '';
 
 -- Do not move this query
-UPDATE settings_current SET selected_value = '1.10.0.11' WHERE variable = 'chamilo_database_version';
+UPDATE settings_current SET selected_value = '1.10.0.12' WHERE variable = 'chamilo_database_version';
 
 -- xxCOURSExx
 

+ 1 - 1
main/install/update-db-1.9.0-1.10.0.inc.php

@@ -112,7 +112,7 @@ if (defined('SYSTEM_INSTALLATION')) {
                     'track_e_course_access' => 'course_code',
                     'track_e_online' => 'course',
                     'track_e_attempt' => 'course_code',
-                    'track_e_exercices' => 'exe_cours_id'
+                    'track_e_exercises' => 'exe_cours_id'
                 );
 
                 foreach ($fields as $table => $key) {

+ 2 - 2
main/mySpace/myStudents.php

@@ -164,7 +164,7 @@ if (isset($_GET['details'])) {
 
 // Database Table Definitions
 $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
-$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
     $user_id = intval($_GET['user_id']);
@@ -201,7 +201,7 @@ if ($check) {
                     $session_id
                 );
 
-                //@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334
+                //@todo delete the stats.track_e_exercises records. First implement this http://support.chamilo.org/issues/1334
                 $message = Display::return_message(
                     get_lang('LPWasReset'),
                     'success'

+ 1 - 1
main/mySpace/progression.php

@@ -29,7 +29,7 @@ $tbl_course 		= Database :: get_main_table(TABLE_MAIN_COURSE);
 $tbl_user 			= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session 		= Database :: get_main_table(TABLE_MAIN_SESSION);
-$tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 /*
  	MAIN CODE

+ 1 - 1
main/mySpace/reussite.php

@@ -27,7 +27,7 @@ $tbl_course 		= Database :: get_main_table(TABLE_MAIN_COURSE);
 $tbl_user 			= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session 		= Database :: get_main_table(TABLE_MAIN_SESSION);
-$tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 /*
 ===============================================================================

+ 3 - 3
main/newscorm/learnpathItem.class.php

@@ -2511,7 +2511,7 @@ class learnpathItem
                                             if ($returnstatus) {
                                                 //AND origin_lp_item_id = '.$user_id.'
                                                 $sql = 'SELECT exe_result, exe_weighting
-                                                        FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . '
+                                                        FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
                                                     WHERE   exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . '
                                                         AND exe_user_id = ' . $user_id . '
                                                         AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . '
@@ -2542,7 +2542,7 @@ class learnpathItem
                                             // Checking in the database.
                                             $sql = 'SELECT exe_result, exe_weighting
                                                     FROM ' . Database :: get_statistic_table(
-                                                    TABLE_STATISTIC_TRACK_E_EXERCICES
+                                                    TABLE_STATISTIC_TRACK_E_EXERCISES
                                                 ) . '
                                                     WHERE exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . '
                                                         AND exe_user_id = ' . $user_id . ' AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . ' ';
@@ -3867,7 +3867,7 @@ class learnpathItem
                         $my_status = ' ';
                         $total_time = ' ';
                         if (!empty($_REQUEST['exeId'])) {
-                            $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+                            $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
                             $safe_exe_id = intval($_REQUEST['exeId']);
                             $sql = "SELECT start_date,exe_date

+ 1 - 1
main/newscorm/lp_view.php

@@ -215,7 +215,7 @@ if (!empty($_REQUEST['exeId']) &&
     global $src;
     $_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
 
-    $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
     $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
     $safe_item_id = intval($_GET['lp_item_id']);

+ 1 - 1
main/reports/modules/quiz.php

@@ -26,7 +26,7 @@ function reports_modules_quiz_quizVal($quiz, $key_id) {
 			'session_id, -1 as attempt, exe_result as score, '.
 			REPORTS_PROGRESS_COMPLETED.' as progress, '.
 			'exe_duration as time, exe_date as ts from '.
-			Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES).
+			Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).
 			' where exe_cours_id = '."'".$quiz['course_code']."'".
 			' and exe_exo_id='.$quiz['child_id']);
 }

+ 1 - 1
main/tracking/courseLog.php

@@ -150,7 +150,7 @@ $TABLETRACK_ACCESS      = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTA
 $TABLETRACK_LINKS       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
 $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
 $TABLETRACK_ACCESS_2    = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
-$TABLETRACK_EXERCISES 	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TABLETRACK_EXERCISES 	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $TABLECOURSUSER	        = Database::get_main_table(TABLE_MAIN_COURSE_USER);
 $TABLECOURSE	        = Database::get_main_table(TABLE_MAIN_COURSE);
 $table_user             = Database::get_main_table(TABLE_MAIN_USER);

+ 1 - 1
main/tracking/exams.php

@@ -468,7 +468,7 @@ function export_complete_report_xls($filename, $array)
 
 function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
 {
-    $exerciseStatsTable = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    $exerciseStatsTable = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
     if (empty($sessionId)) {
         $students = CourseManager::get_student_list_from_course_code(

+ 1 - 1
main/tracking/personnalLog.php

@@ -51,7 +51,7 @@ $TABLETRACK_ACCESS      = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCES
 $TABLETRACK_LINKS 		= Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
 $TABLETRACK_DOWNLOADS 	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
 $TABLETRACK_LOGIN 		= Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-$TABLETRACK_EXERCICES   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TABLETRACK_EXERCICES   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 
 $limitOfDisplayedLogins = 25; // number of logins to display

+ 1 - 1
tests/datafiller/fill_whoisonline.php

@@ -21,7 +21,7 @@ function fill_whoisonline()
 	//filling the table
 	for ($i=1;$i <=$max;$i++) {
 		$date = api_get_utc_datetime();
-		$sql = "INSERT INTO	$table_e_online (login_id, login_user_id, login_date, login_ip, c_id, session_id, access_url_id)
+		$sql = "INSERT INTO	$table_e_online (login_id, login_user_id, login_date, user_ip, c_id, session_id, access_url_id)
 				VALUES ('$i', '$i', '$date', '127.0.0.1', '', '0','1')";
 		$rs = Database::query($sql);
 	}

+ 1 - 1
tests/scripts/fix_exercise_score_in_lp.php

@@ -11,7 +11,7 @@ require_once '../../main/inc/global.inc.php';
 
 api_protect_admin_script();
 
-$tableExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$tableExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
 
 $sql = "SELECT

+ 1 - 1
tests/scripts/move_users.php

@@ -66,7 +66,7 @@ function moveUserFromCourseToCourse($originCourse, $destinationCourse, $debug =
     }
     $output .= 'Moving students who have no exe results from course '.$originCourse.' to course '.$destinationCourse.$eol;
     $tableCRU = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-    $tableTEE = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    $tableTEE = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     // Get the users who have passed an exam in the course of origin
     $sql = "SELECT distinct(exe_user_id) FROM $tableTEE
         WHERE exe_cours_id = '$originCourse'";