From 0a9c787fe5a72f13a13737918bc18611176381b2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 11 Apr 2011 17:25:46 +0200 Subject: [PATCH] Removing $_configuration['tracking_enabled'] because its always true see #2808 --- main/admin/statistics/index.php | 8 +- main/admin/user_list.php | 27 +++--- main/exercice/mark_free_answer.php | 111 +++++++++++------------- main/exercice/savescores.php | 7 +- main/inc/global.inc.php | 2 +- main/inc/local.inc.php | 29 +++---- main/newscorm/lp_ajax_save_item.php | 2 +- main/newscorm/lp_comm.server.php | 2 +- main/tracking/courseLogCSV.php | 21 +---- main/tracking/course_access_details.php | 17 +--- main/tracking/logins_details.php | 9 +- main/tracking/personnalLog.php | 24 ++--- main/tracking/toolaccess_details.php | 15 +--- main/tracking/userLog.php | 7 +- main/tracking/userlogCSV.php | 11 +-- main/user/user.php | 2 +- main/user/userInfo.php | 26 ++---- 17 files changed, 104 insertions(+), 216 deletions(-) diff --git a/main/admin/statistics/index.php b/main/admin/statistics/index.php index dea9c786ca..2da83ff097 100755 --- a/main/admin/statistics/index.php +++ b/main/admin/statistics/index.php @@ -18,13 +18,7 @@ $tool_name = get_lang('Statistics'); Display::display_header($tool_name); api_display_tool_title($tool_name); -if (!$_configuration['tracking_enabled']) { - Display::display_warning_message(get_lang('TrackingDisabled')); - Display::display_footer(); - exit; -} -require_once ('statistics.lib.php'); - +require_once 'statistics.lib.php'; $strCourse = get_lang('Courses'); $strUsers = get_lang('Users'); diff --git a/main/admin/user_list.php b/main/admin/user_list.php index 5ac290095d..c1d19f2e6b 100755 --- a/main/admin/user_list.php +++ b/main/admin/user_list.php @@ -252,23 +252,16 @@ function login_user($user_id) { $uidReset = false; if ($user_id) { // a uid is given (log in succeeded) - if ($_configuration['tracking_enabled']) { - $sql_query = "SELECT user.*, a.user_id is_admin, - UNIX_TIMESTAMP(login.login_date) login_date - FROM $main_user_table - LEFT JOIN $main_admin_table a - ON user.user_id = a.user_id - LEFT JOIN $track_e_login_table login - ON user.user_id = login.login_user_id - WHERE user.user_id = '".$user_id."' - ORDER BY login.login_date DESC LIMIT 1"; - } else { - $sql_query = "SELECT user.*, a.user_id is_admin - FROM $main_user_table - LEFT JOIN $main_admin_table a - ON user.user_id = a.user_id - WHERE user.user_id = '".$user_id."'"; - } + + $sql_query = "SELECT user.*, a.user_id is_admin, + UNIX_TIMESTAMP(login.login_date) login_date + FROM $main_user_table + LEFT JOIN $main_admin_table a + ON user.user_id = a.user_id + LEFT JOIN $track_e_login_table login + ON user.user_id = login.login_user_id + WHERE user.user_id = '".$user_id."' + ORDER BY login.login_date DESC LIMIT 1"; $sql_result = Database::query($sql_query); diff --git a/main/exercice/mark_free_answer.php b/main/exercice/mark_free_answer.php index fe8f8322b1..315fdb3f07 100755 --- a/main/exercice/mark_free_answer.php +++ b/main/exercice/mark_free_answer.php @@ -103,70 +103,61 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices') $my_msg = 'No change.'; -if($action == 'mark'){ - if (!empty($_POST['score']) AND $_POST['score'] < $obj_question->selectWeighting() AND $_POST['score'] >= 0){ - +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: - global $_configuration; - - if($_configuration['tracking_enabled']) - { - $exercise_table = Database::get_statistic_table('track_e_exercices'); - #$tbl_learnpath_user = Database::get_course_table('learnpath_user'); - #global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id; - $sql = "SELECT * FROM $exercise_table - WHERE exe_user_id = '".Database::escape_string($my_usr)."' AND exe_cours_id = '".Database::escape_string($my_cid)."' AND exe_exo_id = '".Database::escape_string($my_exe)."' - ORDER BY exe_date DESC"; + + $exercise_table = Database::get_statistic_table('track_e_exercices'); + #$tbl_learnpath_user = Database::get_course_table('learnpath_user'); + #global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id; + $sql = "SELECT * FROM $exercise_table + WHERE exe_user_id = '".Database::escape_string($my_usr)."' AND exe_cours_id = '".Database::escape_string($my_cid)."' AND exe_exo_id = '".Database::escape_string($my_exe)."' + ORDER BY exe_date DESC"; + #echo $sql; + $res = Database::query($sql); + if(Database::num_rows($res)>0){ + $row = Database::fetch_array($res); + //@todo Check that just summing past score and the new free answer mark doesn't come up + // with a score higher than the possible score for that exercise + $my_score = $row['exe_result'] + $_POST['score']; + $sql = "UPDATE $exercise_table SET exe_result = '$my_score' + WHERE exe_id = '".$row['exe_id']."'"; #echo $sql; $res = Database::query($sql); - if(Database::num_rows($res)>0){ - $row = Database::fetch_array($res); - //@todo Check that just summing past score and the new free answer mark doesn't come up - // with a score higher than the possible score for that exercise - $my_score = $row['exe_result'] + $_POST['score']; - $sql = "UPDATE $exercise_table SET exe_result = '$my_score' - WHERE exe_id = '".$row['exe_id']."'"; - #echo $sql; - $res = Database::query($sql); - $my_msg = get_lang('MarkIsUpdated'); - }else{ - $my_score = $_POST['score']; - $reallyNow = time(); - $sql = "INSERT INTO $exercise_table - ( - exe_user_id, - exe_cours_id, - exe_exo_id, - exe_result, - exe_weighting, - exe_date - ) - - VALUES - ( - '".Database::escape_string($my_usr)."', - '".Database::escape_string($my_cid)."', - '".Database::escape_string($my_exe)."', - '".Database::escape_string($my_score)."', - '".Database::escape_string($obj_question->selectWeighting())."', - FROM_UNIXTIME(".$reallyNow.") - )"; - #if ($origin == 'learnpath') - #{ - # if ($user_id == "NULL") - # { - # $user_id = '0'; - # } - # $sql2 = "update $tbl_learnpath_user set score='$score' where (user_id=$user_id and learnpath_id='$learnpath_id' and learnpath_item_id='$learnpath_item_id')"; - # $res2 = Database::query($sql2); - #} - $res = Database::query($sql); - $my_msg = get_lang('MarkInserted'); - } - //Database::query($sql); - //return 0; + $my_msg = get_lang('MarkIsUpdated'); + }else{ + $my_score = $_POST['score']; + $reallyNow = time(); + $sql = "INSERT INTO $exercise_table ( + exe_user_id, + exe_cours_id, + exe_exo_id, + exe_result, + exe_weighting, + exe_date + ) VALUES ( + '".Database::escape_string($my_usr)."', + '".Database::escape_string($my_cid)."', + '".Database::escape_string($my_exe)."', + '".Database::escape_string($my_score)."', + '".Database::escape_string($obj_question->selectWeighting())."', + FROM_UNIXTIME(".$reallyNow.") + )"; + #if ($origin == 'learnpath') + #{ + # if ($user_id == "NULL") + # { + # $user_id = '0'; + # } + # $sql2 = "update $tbl_learnpath_user set score='$score' where (user_id=$user_id and learnpath_id='$learnpath_id' and learnpath_item_id='$learnpath_item_id')"; + # $res2 = Database::query($sql2); + #} + $res = Database::query($sql); + $my_msg = get_lang('MarkInserted'); } - }else{ + //Database::query($sql); + //return 0; + } else { $my_msg .= get_lang('TotalScoreTooBig'); } } diff --git a/main/exercice/savescores.php b/main/exercice/savescores.php index 9f740c321c..d829fea5b1 100755 --- a/main/exercice/savescores.php +++ b/main/exercice/savescores.php @@ -50,18 +50,13 @@ $jscript2run = ''; * @return void */ function save_scores($file, $score) { - global $_configuration, $origin, - $_user, $_cid, + global $origin, $_user, $_cid, $TABLETRACK_HOTPOTATOES; // if tracking is disabled record nothing $weighting = 100; // 100% $reallyNow = time(); $date = date("Y-m-d H:i:s", $reallyNow); - if (!$_configuration['tracking_enabled']) { - return 0; - } - if ($_user['user_id']) { $user_id = $_user['user_id']; } else { diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index ecf97973fb..0591d7bb90 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -517,7 +517,7 @@ $text_dir = api_get_text_direction(); //Update of the logout_date field in the table track_e_login (needed for the calculation of the total connection time) -if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as']) && isset($_user)) { +if (!isset($_SESSION['login_as']) && isset($_user)) { // if $_SESSION['login_as'] is set, then the user is an admin logged as the user $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index 66c0540201..755d881611 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -585,22 +585,15 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested { $user_table = Database::get_main_table(TABLE_MAIN_USER); $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); - if ($_configuration['tracking_enabled']) { - $sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date - FROM $user_table - LEFT JOIN $admin_table a - ON user.user_id = a.user_id - LEFT JOIN ".$_configuration['statistics_database'].".track_e_login login - ON user.user_id = login.login_user_id - WHERE user.user_id = '".$_user['user_id']."' - ORDER BY login.login_date DESC LIMIT 1"; - } else { - $sql = "SELECT user.*, a.user_id is_admin - FROM $user_table - LEFT JOIN $admin_table a - ON user.user_id = a.user_id - WHERE user.user_id = '".$_user['user_id']."'"; - } + + $sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date + FROM $user_table + LEFT JOIN $admin_table a + ON user.user_id = a.user_id + LEFT JOIN ".$_configuration['statistics_database'].".track_e_login login + ON user.user_id = login.login_user_id + WHERE user.user_id = '".$_user['user_id']."' + ORDER BY login.login_date DESC LIMIT 1"; $result = Database::query($sql); @@ -707,7 +700,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or } } - if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as'])) { + if (!isset($_SESSION['login_as'])) { //We add a new record in the course tracking table $course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $time = api_get_datetime(); @@ -760,7 +753,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or list($_SESSION['session_name']) = Database::fetch_array($rs); } - if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as'])) { + if (!isset($_SESSION['login_as'])) { $course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); if (isset($_configuration['session_lifetime'])) { diff --git a/main/newscorm/lp_ajax_save_item.php b/main/newscorm/lp_ajax_save_item.php index 1b9b4da89d..7485f744e2 100755 --- a/main/newscorm/lp_ajax_save_item.php +++ b/main/newscorm/lp_ajax_save_item.php @@ -179,7 +179,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, if ($debug > 1) { error_log('End of save_item()', 0); } } - if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as'])) { + if (!isset($_SESSION['login_as'])) { // If $_SESSION['login_as'] is set, then the user is an admin logged as the user. $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); diff --git a/main/newscorm/lp_comm.server.php b/main/newscorm/lp_comm.server.php index 24dc7f0900..e28c180b5d 100755 --- a/main/newscorm/lp_comm.server.php +++ b/main/newscorm/lp_comm.server.php @@ -163,7 +163,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, if ($debug > 1) { error_log('End of xajax_save_item()', 0); } } - if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as'])) { + if (!isset($_SESSION['login_as'])) { // If $_SESSION['login_as'] is set, then the user is an admin logged as the user. $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); diff --git a/main/tracking/courseLogCSV.php b/main/tracking/courseLogCSV.php index 6c9662b60e..7c22852fa8 100755 --- a/main/tracking/courseLogCSV.php +++ b/main/tracking/courseLogCSV.php @@ -72,8 +72,7 @@ $title[0]=get_lang('StatsOfCourse')." : ".$_course['official_code']; // check if uid is prof of this group -if($is_allowedToTrack && $_configuration['tracking_enabled']) -{ +if ($is_allowedToTrack) { // show all : view must be equal to the sum of all view values (1024+512+...+64) // show none : less than the tiniest value /*echo "
@@ -463,18 +462,6 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) echo api_html_entity_decode($title_line, ENT_COMPAT); echo api_html_entity_decode($line, ENT_COMPAT); exit; - - -} -// not allowed -else -{ - if(!$_configuration['tracking_enabled']) - { - echo get_lang('TrackingDisabled'); - } - else - { - api_not_allowed(); - } -} +} else { + api_not_allowed(); +} \ No newline at end of file diff --git a/main/tracking/course_access_details.php b/main/tracking/course_access_details.php index b043f5278e..3c870ab6b6 100755 --- a/main/tracking/course_access_details.php +++ b/main/tracking/course_access_details.php @@ -58,7 +58,7 @@ $is_allowedToTrack = $is_courseAdmin; 2149372861 ) $reqdate = time(); @@ -210,22 +210,9 @@ $is_allowedToTrack = $is_courseAdmin; } else // not allowed to track { - if(!$_configuration['tracking_enabled']) - { - echo get_lang('TrackingDisabled'); - } - else - { api_not_allowed(); - } } - - - ?> -
- +Display::display_footer(); \ No newline at end of file diff --git a/main/tracking/logins_details.php b/main/tracking/logins_details.php index 3c5a43c5ac..48508024d3 100755 --- a/main/tracking/logins_details.php +++ b/main/tracking/logins_details.php @@ -76,7 +76,7 @@ $is_allowedToTrackEverybodyInCourse = $is_courseAdmin; // allowed to track all s diff --git a/main/tracking/personnalLog.php b/main/tracking/personnalLog.php index d61de7ad09..c048083eb8 100755 --- a/main/tracking/personnalLog.php +++ b/main/tracking/personnalLog.php @@ -60,15 +60,10 @@ include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php"); Display::display_header($nameTools,"Tracking"); api_display_tool_title($nameTools); -/* -============================================================================== - MAIN SECTION -============================================================================== -*/ -if ( $_configuration['tracking_enabled'] ) -{ - // show all : view must be equal to the sum of all view values (1024+512+...+64) - // show none : 0 +/* MAIN SECTION */ + +// show all : view must be equal to the sum of all view values (1024+512+...+64) +// show none : 0 echo " @@ -277,12 +272,5 @@ if ( $_configuration['tracking_enabled'] ) "; } */ - echo "\n
"; -} -else -{ - echo get_lang('TrackingDisabled'); -} - -Display::display_footer(); -?> + echo ""; +Display::display_footer(); \ No newline at end of file diff --git a/main/tracking/toolaccess_details.php b/main/tracking/toolaccess_details.php index da9f68dd5b..b54ca53fb5 100755 --- a/main/tracking/toolaccess_details.php +++ b/main/tracking/toolaccess_details.php @@ -88,7 +88,7 @@ $reqdate=$_REQUEST['reqdate']; $is_allowedToTrack = $is_platformAdmin; $courseCodeEqualcidIfNeeded = ""; } - if( $is_allowedToTrack && $_configuration['tracking_enabled']) + if( $is_allowedToTrack) { // list of all tools if (!isset($tool)) @@ -268,17 +268,8 @@ $reqdate=$_REQUEST['reqdate']; break; } } - } - else // not allowed to track - { - if(!$_configuration['tracking_enabled']) - { - echo $langTrackingDisabled; - } - else - { - echo get_lang('NotAllowed'); - } + } else { // not allowed to track + echo get_lang('NotAllowed'); } echo ''; // footer diff --git a/main/tracking/userLog.php b/main/tracking/userLog.php index f47953c2a0..d3b6ba79da 100755 --- a/main/tracking/userLog.php +++ b/main/tracking/userLog.php @@ -134,7 +134,7 @@ $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track al
diff --git a/main/tracking/userlogCSV.php b/main/tracking/userlogCSV.php index 4126d7a151..88e77b3b41 100755 --- a/main/tracking/userlogCSV.php +++ b/main/tracking/userlogCSV.php @@ -122,7 +122,7 @@ $line=''; $title_line=''; // check if uid is tutor of this group -if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configuration['tracking_enabled'] ) +if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) { if(!$uInfo && !isset($uInfo) ) { @@ -366,12 +366,5 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura // not allowed else { - if(!$_configuration['tracking_enabled']) - { - echo get_lang('TrackingDisabled'); - } - else - { - api_not_allowed(); - } + api_not_allowed(); } diff --git a/main/user/user.php b/main/user/user.php index 169f683ae7..d48224a718 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -312,7 +312,7 @@ if (isset($message)) { //statistics event_access_tool(TOOL_USER); /* Setting the permissions for this page */ -$is_allowed_to_track = ($is_courseAdmin || $is_courseTutor) && $_configuration['tracking_enabled']; +$is_allowed_to_track = ($is_courseAdmin || $is_courseTutor); // Tool introduction diff --git a/main/user/userInfo.php b/main/user/userInfo.php index 3f8304e331..1ad2afaab2 100755 --- a/main/user/userInfo.php +++ b/main/user/userInfo.php @@ -1,4 +1,4 @@ - 'user.php', 'name' => get_lang('Users')); } -if ($origin != 'learnpath') -{ //so we are not in learnpath tool +if ($origin != 'learnpath') { //so we are not in learnpath tool Display :: display_header($nameTools, "User"); $origin = Security::remove_XSS($_GET['origin']); -} -else -{ +} else { ?> ".get_lang('BackUser')."
\n"; /* FOOTER */ -Display :: display_footer(); -?> \ No newline at end of file +Display :: display_footer(); \ No newline at end of file