Add c_id in track tables

Change function parameters to use c_id instead of course code
1.10.x
Julio Montoya 10 years ago
parent afa1c7f180
commit 277c7fdb37
  1. 2
      index.php
  2. 8
      main/admin/access_url_add_courses_to_url.php
  3. 2
      main/admin/inactive_user_list.php
  4. 13
      main/admin/teacher_time_report.php
  5. 10
      main/admin/user_information.php
  6. 2
      main/admin/user_list.php
  7. 35
      main/admin/user_move_stats.php
  8. 2
      main/auth/my_progress.php
  9. 6
      main/cron/fix_online_time.php
  10. 10
      main/dropbox/dropbox_functions.inc.php
  11. 2
      main/exercice/admin.php
  12. 9
      main/exercice/exercice.php
  13. 62
      main/exercice/exercise.class.php
  14. 4
      main/exercice/exercise_history.php
  15. 6
      main/exercice/exercise_report.php
  16. 2
      main/exercice/exercise_result.php
  17. 14
      main/exercice/exercise_show.php
  18. 9
      main/exercice/exercise_submit.php
  19. 2
      main/exercice/result.php
  20. 2
      main/forum/forumfunction.inc.php
  21. 16
      main/inc/ajax/course_home.ajax.php
  22. 28
      main/inc/ajax/exercise.ajax.php
  23. 11
      main/inc/ajax/myspace.ajax.php
  24. 3
      main/inc/ajax/skill.ajax.php
  25. 3
      main/inc/lib/attendance.lib.php
  26. 6
      main/inc/lib/auth.lib.php
  27. 206
      main/inc/lib/course.lib.php
  28. 8
      main/inc/lib/course_category.lib.php
  29. 2
      main/inc/lib/database.constants.inc.php
  30. 4
      main/inc/lib/display.lib.php
  31. 168
      main/inc/lib/events.lib.inc.php
  32. 77
      main/inc/lib/exercise.lib.php
  33. 23
      main/inc/lib/login.lib.php
  34. 228
      main/inc/lib/myspace.lib.php
  35. 25
      main/inc/lib/online.inc.php
  36. 19
      main/inc/lib/sessionmanager.lib.php
  37. 68
      main/inc/lib/statistics.lib.php
  38. 14
      main/inc/lib/stats.lib.inc.php
  39. 442
      main/inc/lib/tracking.lib.php
  40. 8
      main/inc/lib/usermanager.lib.php
  41. 19
      main/inc/local.inc.php
  42. 8
      main/install/db_main.sql
  43. 42
      main/install/db_stats.sql
  44. 16
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  45. 45
      main/install/update-db-1.9.0-1.10.0.inc.php
  46. 8
      main/mySpace/access_details.php
  47. 2
      main/mySpace/course.php
  48. 17
      main/mySpace/current_courses.php
  49. 15
      main/mySpace/myStudents.php
  50. 4
      main/mySpace/student.php
  51. 4
      main/mySpace/teachers.php
  52. 5
      main/mySpace/users.php
  53. 14
      main/reports/modules/course.php
  54. 11
      main/session/index.php
  55. 61
      main/tracking/courseLogCSV.php
  56. 54
      main/tracking/course_access_details.php
  57. 3
      main/tracking/course_log_tools.php
  58. 6
      main/tracking/course_session_report.php
  59. 159
      main/tracking/logins_details.php
  60. 6
      main/tracking/lp_results_by_user.php
  61. 29
      main/tracking/personnalLog.php
  62. 2
      main/tracking/question_course_report.php
  63. 22
      main/tracking/toolaccess_details.php
  64. 23
      main/tracking/userLog.php
  65. 9
      main/tracking/userlogCSV.php
  66. 13
      main/user/user.php
  67. 111
      main/webservices/webservice.php
  68. 4
      main/webservices/webservice_report.php
  69. 40
      main/work/work.lib.php
  70. 6
      plugin/dashboard/block_course/block_course.class.php
  71. 4
      plugin/dashboard/block_student/block_student.class.php
  72. 4
      plugin/ticket/src/report.php
  73. 18
      tests/datafiller/fill_whoisonline.php
  74. 52
      tests/main/mySpace/myspace.lib.test.php
  75. 23
      whoisonlinesession.php

@ -95,7 +95,7 @@ if (!api_get_user_id() && CustomPages::enabled()) {
if (!empty($_POST['submitAuth'])) {
// The user has been already authenticated, we are now to find the last login of the user.
if (isset ($_user['user_id'])) {
$track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$track_login_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
FROM $track_login_table
WHERE login_user_id = '".$_user['user_id']."'

@ -28,10 +28,10 @@ $courses = array ();
$url_list = array();
$users = array();
$tbl_access_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_access_url_rel_course = Database:: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_access_url = Database:: get_main_table(TABLE_MAIN_ACCESS_URL);
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
$tbl_course = Database:: get_main_table(TABLE_MAIN_COURSE);
/* Header */
$tool_name = get_lang('AddCoursesToURL');

@ -14,7 +14,7 @@ $language_file = array ('registration','admin');
$cidReset = true;
require_once '../inc/global.inc.php';
$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$tbl_stats_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true);

@ -65,17 +65,14 @@ $timeReport = new TeacherTimeReport();
if (!empty($selectedCourse)) {
$withFilter = true;
$course = api_get_course_info($selectedCourse);
$reportTitle = sprintf(get_lang('TimeReportForCourseX'), $course['title']);
$teachers = CourseManager::get_teacher_list_from_course_code($selectedCourse);
foreach ($teachers as $teacher) {
$totalTime = UserManager::getExpendedTimeInCourses(
$teacher['user_id'],
$selectedCourse,
$course['real_id'],
0,
$selectedFrom,
$selectedUntil
@ -108,7 +105,7 @@ if (!empty($selectedCourse)) {
foreach ($coaches as $coach) {
$totalTime = UserManager::getExpendedTimeInCourses(
$coach['user_id'],
$selectedCourse,
$course['real_id'],
$session['id'],
$selectedFrom,
$selectedUntil
@ -163,7 +160,7 @@ if (!empty($selectedSession)) {
foreach ($coaches as $coach) {
$totalTime = UserManager::getExpendedTimeInCourses(
$coach['user_id'],
$course['code'],
$course['id'],
$selectedSession,
$selectedFrom,
$selectedUntil
@ -210,7 +207,7 @@ if (!empty($selectedTeacher)) {
$totalTime = UserManager::getExpendedTimeInCourses(
$selectedTeacher,
$course['code'],
$course['real_id'],
0,
$selectedFrom,
$selectedUntil
@ -242,7 +239,7 @@ if (!empty($selectedTeacher)) {
$totalTime = UserManager::getExpendedTimeInCourses(
$selectedTeacher,
$course['course_code'],
$course['real_id'],
$session['id'],
$selectedFrom,
$selectedUntil

@ -188,7 +188,7 @@ if (count($sessions) > 0) {
$timeSpent = api_time_to_hms(
Tracking :: get_time_spent_on_the_course(
$user['user_id'],
$courseInfo['code'],
$courseInfo['real_id'],
$id_session
)
);
@ -286,19 +286,21 @@ if (Database::num_rows($res) > 0) {
$data = array();
$courseToolInformationTotal = null;
while ($course = Database::fetch_object($res)) {
$courseInfo = api_get_course_info($course->code);
$courseToolInformation = null;
$tools = '<a href="course_information.php?code='.$course->code.'">'.Display::return_icon('synthese_view.gif', get_lang('Overview')).'</a>'.
'<a href="'.api_get_path(WEB_COURSE_PATH).$course->directory.'">'.Display::return_icon('course_home.gif', get_lang('CourseHomepage')).'</a>' .
'<a href="course_edit.php?course_code='.$course->code.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
if ($course->status == STUDENT) {
$tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
$tools .= '<a href="user_information.php?action=unsubscribe&course_code='.$course->code.'&user_id='.$user['user_id'].'">'.
Display::return_icon('delete.png', get_lang('Delete')).'</a>';
}
$timeSpent = api_time_to_hms(
Tracking :: get_time_spent_on_the_course(
$user['user_id'],
$course->code,
$courseInfo['real_id'],
0
)
);
@ -308,7 +310,7 @@ if (Database::num_rows($res) > 0) {
$course->id,
0
);
$courseInfo = api_get_course_info($course->code);
$row = array(
Display::url($course->code, $courseInfo['course_public_url']),
$course->title,

@ -324,7 +324,7 @@ function login_user($user_id) {
$main_user_table = Database::get_main_table(TABLE_MAIN_USER);
$main_admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$track_e_login_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$track_e_login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
unset($_user['user_id']); // uid not in session ? prevent any hacking

@ -116,10 +116,10 @@ if (isset($_REQUEST['load_ajax'])) {
$course_info = api_get_course_info($origin_course_code);
$course_id = $course_info['real_id'];
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_E_COURSE_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$TBL_TRACK_E_LAST_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$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);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK);
@ -127,9 +127,9 @@ if (isset($_REQUEST['load_ajax'])) {
$TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
$TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST);
$TBL_AGENDA = Database::get_course_table(TABLE_AGENDA);
$TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
$TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST);
$TBL_AGENDA = Database::get_course_table(TABLE_AGENDA);
//1. track_e_exercises
//ORIGINAL COURSE
@ -161,7 +161,8 @@ if (isset($_REQUEST['load_ajax'])) {
if (!$update_database) {
$sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE exe_cours_id = '$origin_course_code' AND session_id = $new_session_id AND exe_user_id = $user_id ";
$sql = "SELECT * FROM $TABLETRACK_EXERCICES
WHERE exe_cours_id = '$origin_course_code' AND session_id = $new_session_id AND exe_user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@ -188,8 +189,8 @@ if (isset($_REQUEST['load_ajax'])) {
//Nothing to do because there are not relationship with a session
//3. track_e_course_access
$sql = "SELECT * FROM $TBL_TRACK_E_COURSE_ACCESS WHERE course_code = '$origin_course_code' AND session_id = $origin_session_id AND user_id = $user_id ";
$sql = "SELECT * FROM $TBL_TRACK_E_COURSE_ACCESS
WHERE c_id = '$course_id' AND session_id = $origin_session_id AND user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@ -204,14 +205,12 @@ if (isset($_REQUEST['load_ajax'])) {
$res = Database::query($sql);
if ($debug) var_dump($res);
$result_message[$TBL_TRACK_E_COURSE_ACCESS]++;
} else {
//$result_message[$TBL_TRACK_E_COURSE_ACCESS][$id] = $data;
}
}
//4. track_e_lastaccess
$sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS WHERE access_cours_code = '$origin_course_code' AND access_session_id = $origin_session_id AND access_user_id = $user_id ";
$sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS
WHERE c_id = '$course_id' AND access_session_id = $origin_session_id AND access_user_id = $user_id ";
$res = Database::query($sql);
$list = array();
while($row = Database::fetch_array($res,'ASSOC')) {
@ -231,7 +230,8 @@ if (isset($_REQUEST['load_ajax'])) {
//5. lp_item_view
//CHECK ORIGIN
$sql = "SELECT * FROM $TBL_LP_VIEW WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id ";
$sql = "SELECT * FROM $TBL_LP_VIEW
WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id ";
$res = Database::query($sql);
//Getting the list of LPs in the new session
@ -581,10 +581,11 @@ $htmlHeadXtra[] = '<script type="text/javascript">
</script>';
function get_courses_list_by_user_id_based_in_exercises($user_id) {
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$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 FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_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
FROM $TABLETRACK_EXERCICES WHERE exe_user_id = $user_id ORDER by exe_user_id, exe_cours_id ASC";
$res = Database::query($sql);
$course_list = array();

@ -65,7 +65,7 @@ if (!empty($course_user_list)) {
if ($count == $last_item) {
$last = '<a href="#'.$login.'">'.get_lang('Last').'</a>';
}
$course_info = api_get_course_info($result['course_code']);
$course_info = api_get_course_info_by_id($result['c_id']);
$course_image = '<img src="'.$course_info['course_image'].'">';
$dates .= '<li><a href="#'.$login.'">'.api_get_utc_datetime($login).'</a></li>';
$issues .= '<li id ="'.$login.'">

@ -20,7 +20,7 @@ function getTeachersInCourseIds()
'login_user_id', $table . $joinStatement,
array(
'where' => array(
'course IS NOT NULL AND status = ?' => array(
'c_id IS NOT NULL AND status = ?' => array(
COURSEMANAGER
)
)
@ -87,7 +87,7 @@ function updateTeachersInCourseIdleForTimeLimit($teachersInCourseIds)
*/
$userId = intval($value);
$updateOnLineSql = "UPDATE $onLineTrackTable SET "
. "COURSE = NULL "
. "c_id = NULL "
. "WHERE login_user_id = $userId";
Database::query($updateOnLineSql);
}
@ -102,4 +102,4 @@ if (php_sapi_name() != 'cli') {
$teachersInCourseIds = getTeachersInCourseIds();
if (!empty($teachersInCourseIds)) {
updateTeachersInCourseIdleForTimeLimit($teachersInCourseIds);
}
}

@ -1241,7 +1241,7 @@ function check_number_feedback($key, $array) {
/**
* Get the last access to a given tool of a given user
* @param $tool string the tool constant
* @param $course_code the course_id
* @param $courseId the course_id
* @param $user_id the id of the user
* @return string last tool access date
*
@ -1250,11 +1250,11 @@ function check_number_feedback($key, $array) {
*
* @todo consider moving this function to a more appropriate place.
*/
function get_last_tool_access($tool, $course_code = '', $user_id='')
function get_last_tool_access($tool, $courseId = null, $user_id = null)
{
// The default values of the parameters
if (empty($course_code)) {
$course_code = api_get_course_id();
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
if (empty($user_id)) {
$user_id = api_get_user_id();
@ -1266,7 +1266,7 @@ function get_last_tool_access($tool, $course_code = '', $user_id='')
$sql = "SELECT access_date FROM $table_last_access
WHERE
access_user_id = ".intval($user_id)." AND
access_cours_code='".Database::escape_string($course_code)."' AND
c_id='".intval($courseId)."' AND
access_tool='".Database::escape_string($tool)."'
ORDER BY access_date DESC
LIMIT 1";

@ -116,7 +116,7 @@ $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
Event::delete_all_incomplete_attempts(
api_get_user_id(),
$exerciseId,
api_get_course_id(),
api_get_course_int_id(),
api_get_session_id()
);

@ -476,7 +476,6 @@ $offline_icon = Display::return_icon('offline.png', get_lang('Invisible'), array
$exercise_list = array();
$exercise_obj = new Exercise();
//$list_ordered = $exercise_obj->get_exercise_list_ordered();
$list_ordered = null;
while ($row = Database :: fetch_array($result, 'ASSOC')) {
@ -623,7 +622,13 @@ if (!empty($exercise_list)) {
$title = $cut_title;
}
$count_exercise_not_validated = intval(Event::count_exercise_result_not_validated($my_exercise_id, $course_code, $session_id));
$count_exercise_not_validated = intval(
Event::count_exercise_result_not_validated(
$my_exercise_id,
$courseId,
$session_id
)
);
$move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
$move = null;

@ -1571,8 +1571,8 @@ class Exercise
*/
public function clean_results($cleanLpTests = false, $cleanResultBeforeDate = null)
{
$table_track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$table_track_e_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$table_track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$table_track_e_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql_where = ' AND
orig_lp_id = 0 AND
@ -1710,7 +1710,7 @@ class Exercise
$lp_item_view_id = 0,
$status = 'incomplete'
) {
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (empty($lp_id)) {
$lp_id = 0;
}
@ -1758,7 +1758,7 @@ class Exercise
$questionList = array(),
$weight = 0
) {
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$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);
@ -1772,20 +1772,30 @@ class Exercise
if (empty($clock_expired_time)) {
$clock_expired_time = 0;
}
$questionList = array_map('intval', $questionList);
$params = array(
'exe_exo_id' => $this->id ,
'exe_user_id' => api_get_user_id(),
'exe_cours_id' => api_get_course_id(),
'c_id' => api_get_course_int_id(),
'status' => 'incomplete',
'session_id' => api_get_session_id(),
'data_tracking' => implode(',', $questionList) ,
'start_date' => api_get_utc_datetime(),
'orig_lp_id' => $safe_lp_id,
'orig_lp_item_id' => $safe_lp_item_id,
'orig_lp_item_view_id' => $safe_lp_item_view_id,
'exe_weighting'=> $weight,
);
if ($this->expired_time != 0) {
$sql_fields = "expired_time_control, ";
$sql_fields_values = "'"."$clock_expired_time"."',";
} else {
$sql_fields = "";
$sql_fields_values = "";
$params['expired_time_control'] = $clock_expired_time;
}
$questionList = array_map('intval', $questionList);
$weight = Database::escape_string($weight);
$sql = "INSERT INTO $track_exercises ($sql_fields exe_exo_id, exe_user_id, exe_cours_id, status,session_id, data_tracking, start_date, orig_lp_id, orig_lp_item_id, orig_lp_item_view_id, exe_weighting)
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "', '" . api_get_utc_datetime() . "', '$safe_lp_id', '$safe_lp_item_id', '$safe_lp_item_view_id', '$weight')";
Database::query($sql);
$id = Database::insert_id();
$id = Database::insert($track_exercises, $params);
return $id;
}
@ -2141,7 +2151,7 @@ class Exercise
$questionId = intval($questionId);
$exeId = intval($exeId);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
// Creates a temporary Question object
@ -2809,7 +2819,7 @@ class Exercise
}
case HOT_SPOT :
if ($from_database) {
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$sql = "SELECT hotspot_correct
FROM $TBL_TRACK_HOTSPOT
WHERE
@ -2847,7 +2857,7 @@ class Exercise
case HOT_SPOT_DELINEATION :
if ($from_database) {
// getting the user answer
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$query = "SELECT hotspot_correct, hotspot_coordinate
FROM $TBL_TRACK_HOTSPOT
WHERE
@ -2949,11 +2959,7 @@ class Exercise
$user_array = substr($user_array,0,-1);
if ($next) {
//$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
/* $sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($user_array)."')";
$result = api_sql_query($sql,__FILE__,__LINE__);*/
$user_answer = $user_array;
// we compare only the delineation not the other points
@ -3144,7 +3150,7 @@ class Exercise
case HOT_SPOT_DELINEATION:
$user_answer = $user_array;
if ($next) {
//$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
//$tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
// Save into db
/* $sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate )
VALUES ('".Database::escape_string($_user['user_id'])."', '".Database::escape_string($_course['id'])."', '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', '".Database::escape_string($answerId)."', '".Database::escape_string($studentChoice)."', '".Database::escape_string($user_array)."')";
@ -3593,7 +3599,7 @@ class Exercise
}
if ($saved_results) {
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = 'UPDATE ' . $stat_table . ' SET
exe_result = exe_result + ' . floatval($questionScore) . '
WHERE exe_id = ' . $exeId;
@ -4275,7 +4281,7 @@ class Exercise
public function get_stat_track_exercise_info_by_exe_id($exe_id)
{
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$exe_id = intval($exe_id);
$sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
$result = Database::query($sql_track);
@ -4309,7 +4315,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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if ($exercise_info) {
if (empty($exercise_info['questions_to_check'])) {
@ -4547,7 +4553,7 @@ class Exercise
$ids = is_array($quizId) ? $quizId : array($quizId);
$ids = array_map('intval', $ids);
$ids = implode(',', $ids);
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if ($sessionId != 0) {
$sql = "SELECT * FROM $track_exercises te "
. "INNER JOIN c_quiz cq ON cq.id = te.exe_exo_id "

@ -43,8 +43,8 @@ $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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT_RECORDING= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT_RECORDING= Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
Display::display_header($nameTools,get_lang('Exercise'));
if (isset($_GET['message'])) {

@ -42,9 +42,9 @@ $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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT_RECORDING = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_TRACK_EXERCICES = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$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);
$course_id = api_get_course_int_id();

@ -19,7 +19,7 @@ use \ChamiloSession as Session;
// Name of the language file that needs to be included
$language_file = 'exercice';
$debug = false;
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;

@ -19,7 +19,7 @@ use \ChamiloSession as Session;
$language_file = array('exercice');
require_once '../inc/global.inc.php';
$debug = false;
if (empty($origin) ) {
$origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
}
@ -462,9 +462,8 @@ foreach ($questionList as $questionId) {
$url=$url_hotspot;
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
$comment=$answerComment = $objAnswerTmp->selectComment($nbrAnswers);
$answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
}
}
@ -685,7 +684,12 @@ if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type'])))
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
}
$total_score_text .= get_question_ribbon($objExercise, $my_total_score_temp, $totalWeighting, true);
$total_score_text .= ExerciseLib::get_question_ribbon(
$objExercise,
$my_total_score_temp,
$totalWeighting,
true
);
$total_score_text .= '</div>';
}
}

@ -33,13 +33,8 @@ $language_file = 'exercice';
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;
$this_section = SECTION_COURSES;
if ($debug) {
error_log('--- Enter to the exercise_submit.php ---- ');
error_log('0. POST variables : ' . print_r($_POST, 1));
}
$debug = false;
// Notice for unauthorized people.
api_protect_course_script(true);
@ -302,7 +297,7 @@ if (empty($exercise_stat_info)) {
}
// Array to check in order to block the chat
create_chat_exercise_session($exe_id);
ExerciseLib::create_chat_exercise_session($exe_id);
if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };

@ -65,7 +65,7 @@ if ($show_headers) {
Display::display_reduced_header();
}
display_question_list_by_attempt($objExercise, $id, false);
ExerciseLib::display_question_list_by_attempt($objExercise, $id, false);
if ($show_headers) {
Display::display_footer();

@ -3154,7 +3154,7 @@ function get_whats_new()
$sql = "SELECT * FROM ".$tracking_last_tool_access."
WHERE
access_user_id='".Database::escape_string($_user['user_id'])."' AND
access_cours_code='".Database::escape_string($_course['sysCode'])."' AND
c_id ='".$course_id."' AND
access_tool='".Database::escape_string($tool)."'";
$result = Database::query($sql);
$row = Database::fetch_array($result);

@ -149,7 +149,7 @@ switch ($action) {
$last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(),
$item['code'],
$item['id'],
$session_id,
false
);
@ -279,7 +279,12 @@ switch ($action) {
$temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false);
$last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(),
$item['id'],
$session_id,
false
);
if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
$lp_date = api_get_local_time($lp_item['created_on']);
$image = 'new.gif';
@ -402,7 +407,12 @@ switch ($action) {
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
$last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false);
$last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(),
$item['id'],
$session_id,
false
);
if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
$lp_date = api_get_local_time($lp_item['created_on']);
$image = 'new.gif';

@ -6,7 +6,7 @@
*/
require_once '../global.inc.php';
$debug = false;
api_protect_course_script(true);
$action = $_REQUEST['a'];
@ -399,12 +399,26 @@ switch ($action) {
if ($debug) {
error_log("delete_attempt exe_id : $exe_id, my_question_id: $my_question_id");
}
Event::delete_attempt($exe_id, api_get_user_id(), $course_code, $session_id, $my_question_id);
Event::delete_attempt(
$exe_id,
api_get_user_id(),
$course_id,
$session_id,
$my_question_id
);
if ($objQuestionTmp->type == HOT_SPOT) {
Event::delete_attempt_hotspot($exe_id, api_get_user_id(), $course_code, $session_id, $my_question_id);
Event::delete_attempt_hotspot(
$exe_id,
api_get_user_id(),
$course_id,
$session_id,
$my_question_id
);
}
if (isset($attempt_list[$my_question_id]) && isset($attempt_list[$my_question_id]['marks'])) {
if (isset($attempt_list[$my_question_id]) &&
isset($attempt_list[$my_question_id]['marks'])
) {
$total_score -= $attempt_list[$my_question_id]['marks'];
}
}
@ -438,7 +452,11 @@ switch ($action) {
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
}
$key = ExerciseLib::get_time_control_key($exercise_id, $exercise_stat_info['orig_lp_id'], $exercise_stat_info['orig_lp_item_id']);
$key = ExerciseLib::get_time_control_key(
$exercise_id,
$exercise_stat_info['orig_lp_id'],
$exercise_stat_info['orig_lp_item_id']
);
if (isset($_SESSION['duration_time'][$key]) && !empty($_SESSION['duration_time'][$key])) {
$duration = $now - $_SESSION['duration_time'][$key];

@ -17,19 +17,22 @@ switch ($action) {
$type = Security::remove_XSS($_REQUEST['type']);
$range = Security::remove_XSS($_REQUEST['range']);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
if ($range == 1) {
$start_date = Security::remove_XSS($_REQUEST['sd']);
$end_date = Security::remove_XSS($_REQUEST['ed']);
$sql_result = get_connections_to_course_by_date(
$user_id,
$course_code,
$courseId,
$start_date,
$end_date
);
} else {
$sql_result = MySpace::get_connections_to_course(
$user_id,
$course_code
$courseId
);
}
$foo_print = grapher($sql_result, $start_date, $end_date, $type);
@ -44,10 +47,12 @@ switch ($action) {
$user_id = isset($_REQUEST['student']) ? $_REQUEST['student'] : "";
$course_code = isset($_REQUEST['course']) ? $_REQUEST['course'] : "";
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "";
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$sql_result = get_connections_to_course_by_date(
$user_id,
$course_code,
$courseId,
$start_date,
$end_date
);

@ -74,8 +74,7 @@ switch ($action) {
break;
case 'get_course_info_popup':
$course_info = api_get_course_info($_REQUEST['code']);
$course_info['course_code'] = $course_info['code'];
$courses = CourseManager::process_hot_course_item(array($course_info));
$courses = CourseManager::process_hot_course_item(array($course_info['real_id']));
Display::display_no_header();
Display::$global_template->assign('hot_courses', $courses);
echo Display::$global_template->fetch('default/layout/hot_course_item_popup.tpl');

@ -1520,6 +1520,7 @@ class Attendance
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
$courseId = api_get_course_int_id();
if (!empty($sessionId)) {
$users = CourseManager:: get_user_list_from_course_code(
$courseCode,
@ -1558,7 +1559,7 @@ class Attendance
}
$accessData = CourseManager::getCourseAccessPerCourseAndSession(
$courseCode,
$courseId,
$sessionId,
$dateTimeStartOriginal->format('Y-m-d H:i:s'),
$dateTimeEnd->format('Y-m-d H:i:s')

@ -515,7 +515,11 @@ class Auth
while ($row = Database::fetch_array($result_find)) {
$row['registration_code'] = !empty($row['registration_code']);
$count_users = count(CourseManager::get_user_list_from_course_code($row['code']));
$count_connections_last_month = Tracking::get_course_connections_count($row['code'], 0, api_get_utc_datetime(time() - (30 * 86400)));
$count_connections_last_month = Tracking::get_course_connections_count(
$row['id'],
0,
api_get_utc_datetime(time() - (30 * 86400))
);
$point_info = CourseManager::get_course_ranking($row['id'], 0);

@ -1378,6 +1378,9 @@ class CourseManager
// variable initialisation
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$where = array();
if (empty($order_by)) {
@ -1558,7 +1561,7 @@ class CourseManager
}
$users[$row_key]['extra_'.$extra['1']] = $name;
$users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, 0);
$users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, 0);
$users[$row_key]['count_users'] += $counter;
$registered_users_with_extra_field = 0;
@ -1600,7 +1603,7 @@ class CourseManager
} else {
$report_info['course'] = $user['title'];
$report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']);
$report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, 0));
$report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, 0));
$category = Category :: load (null, null, $course_code);
$report_info['certificate'] = Display::label(get_lang('No'));
@ -2197,28 +2200,26 @@ class CourseManager
*/
public static function delete_course($code)
{
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
//$table_course_class = Database::get_main_table(TABLE_MAIN_COURSE_CLASS);
$table_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_course_survey = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY);
$table_course_survey_question = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_course_survey = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY);
$table_course_survey_question = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
$table_course_survey_question_option= Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
$table_course_rel_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$table_stats_hotpots = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$table_stats_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$table_stats_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$table_stats_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$table_stats_lastaccess = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$table_stats_course_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$table_stats_online = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$table_stats_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_stats_downloads = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$table_stats_links = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$table_stats_uploads = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$table_course_rel_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$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_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);
$table_stats_online = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$table_stats_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_stats_downloads = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$table_stats_links = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$table_stats_uploads = Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$codeFiltered = Database::escape_string($code);
$sql = "SELECT * FROM $table_course WHERE code='".$codeFiltered."'";
@ -2237,77 +2238,26 @@ class CourseManager
}
if ($count == 0) {
self::create_database_dump($code);
if (!self::is_virtual_course_from_system_code($code)) {
// If this is not a virtual course, look for virtual courses that depend on this one, if any
$virtual_courses = self::get_virtual_courses_linked_to_real_course($code);
foreach ($virtual_courses as $index => $virtual_course) {
// Unsubscribe all classes from the virtual course
/*$sql = "DELETE FROM $table_course_class WHERE course_code='".$virtual_course['code']."'";
Database::query($sql);*/
// Unsubscribe all users from the virtual course
$sql = "DELETE FROM $table_course_user WHERE course_code='".$virtual_course['code']."'";
Database::query($sql);
// Delete the course from the sessions tables
$sql = "DELETE FROM $table_session_course WHERE course_code='".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_session_course_user WHERE course_code='".$virtual_course['code']."'";
Database::query($sql);
// Delete the course from the survey tables
$sql = "DELETE FROM $table_course_survey WHERE course_code='".$virtual_course['code']."'";
Database::query($sql);
/*$sql = "DELETE FROM $table_course_survey_user WHERE db_name='".$virtual_course['db_name']."'";
Database::query($sql);
$sql = "DELETE FROM $table_course_survey_reminder WHERE db_name='".$virtual_course['db_name']."'";
Database::query($sql);*/
// Delete the course from the stats tables
$sql = "DELETE FROM $table_stats_hotpots WHERE exe_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_attempt WHERE course_code = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_exercises WHERE exe_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_access WHERE access_cours_code = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_lastaccess WHERE access_cours_code = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_course_access WHERE course_code = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_online WHERE course = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_default WHERE default_cours_code = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_downloads WHERE down_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_links WHERE links_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_uploads WHERE upload_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
// Delete the course from the course table
$sql = "DELETE FROM $table_course WHERE code='".$virtual_course['code']."'";
$sql = "SELECT * FROM $table_course WHERE code='".$codeFiltered."'";
$res = Database::query($sql);
$course = Database::fetch_array($res);
$course_tables = AddCourse::get_course_tables();
$courseId = $course['id'];
// Cleaning c_x tables
if (!empty($courseId)) {
foreach ($course_tables as $table) {
$table = Database::get_course_table($table);
$sql = "DELETE FROM $table WHERE c_id = $courseId ";
Database::query($sql);
}
}
$sql = "SELECT * FROM $table_course WHERE code='".$codeFiltered."'";
$res = Database::query($sql);
$course = Database::fetch_array($res);
$course_tables = AddCourse::get_course_tables();
//Cleaning c_x tables
if (!empty($course['id'])) {
foreach($course_tables as $table) {
$table = Database::get_course_table($table);
$sql = "DELETE FROM $table WHERE c_id = {$course['id']} ";
Database::query($sql);
}
}
$course_dir = api_get_path(SYS_COURSE_PATH).$course['directory'];
$archive_dir = api_get_path(SYS_ARCHIVE_PATH).$course['directory'].'_'.time();
if (is_dir($course_dir)) {
rename($course_dir, $archive_dir);
}
$course_dir = api_get_path(SYS_COURSE_PATH).$course['directory'];
$archive_dir = api_get_path(SYS_ARCHIVE_PATH).$course['directory'].'_'.time();
if (is_dir($course_dir)) {
rename($course_dir, $archive_dir);
}
// Unsubscribe all classes from the course
@ -2346,21 +2296,21 @@ class CourseManager
Database::query($sql);
$sql = "DELETE FROM $table_stats_exercises WHERE exe_cours_id = '".$codeFiltered."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_access WHERE access_cours_code = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_access WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_lastaccess WHERE access_cours_code = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_lastaccess WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_course_access WHERE course_code = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_course_access WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_online WHERE course = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_online WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_default WHERE default_cours_code = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_default WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_downloads WHERE down_cours_id = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_downloads WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_links WHERE links_cours_id = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_links WHERE c_id = '".$courseId."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_uploads WHERE upload_cours_id = '".$codeFiltered."'";
$sql = "DELETE FROM $table_stats_uploads WHERE c_id = '".$courseId."'";
Database::query($sql);
// Delete the course from the database
@ -2368,13 +2318,13 @@ class CourseManager
Database::query($sql);
// delete extra course fields
$t_cf = Database::get_main_table(TABLE_MAIN_COURSE_FIELD);
$t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
$t_cf = Database::get_main_table(TABLE_MAIN_COURSE_FIELD);
$t_cfv = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
$sql = "SELECT distinct field_id FROM $t_cfv WHERE course_code = '$codeFiltered'";
$res_field_ids = Database::query($sql);
$field_ids = array();
while($row_field_id = Database::fetch_row($res_field_ids)){
while($row_field_id = Database::fetch_row($res_field_ids)) {
$field_ids[] = $row_field_id[0];
}
@ -2682,11 +2632,10 @@ class CourseManager
$user_id = intval($user_id);
$course_list = array();
$codes = array();
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user_course_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$special_course_list = self::get_special_course_list();
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user_course_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$special_course_list = self::get_special_course_list();
$with_special_courses = $without_special_courses = '';
if (!empty($special_course_list)) {
@ -4674,16 +4623,18 @@ class CourseManager
//$table_course_access table uses the now() and interval ...
$now = api_get_utc_datetime(time());
$sql = "SELECT COUNT(course_access_id) course_count, a.course_code, visibility ".
"FROM $table_course c INNER JOIN $table_course_access a ".
" ON (c.code = a.course_code) INNER JOIN $table_course_url u ON u.course_code = a.course_code ".
" WHERE u.access_url_id = ".$_configuration['access_url']." AND".
" login_course_date <= '$now' AND ".
" login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND".
" visibility <> '".COURSE_VISIBILITY_CLOSED."' AND visibility <> '".COURSE_VISIBILITY_HIDDEN."'".
" GROUP BY course_code".
" ORDER BY course_count DESC".
" LIMIT $limit";
$sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility
FROM $table_course c INNER JOIN $table_course_access a
ON (c.code = a.c_id) INNER JOIN $table_course_url u ON u.course_code = c.code
WHERE
u.access_url_id = ".api_get_current_access_url_id()." AND
login_course_date <= '$now' AND
login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND
visibility <> '".COURSE_VISIBILITY_CLOSED."' AND visibility <> '".COURSE_VISIBILITY_HIDDEN."'
GROUP BY a.c_id
ORDER BY course_count DESC
LIMIT $limit
";
$result = Database::query($sql);
$courses = array();
@ -4705,14 +4656,19 @@ class CourseManager
$stok = Security::get_existing_token();
foreach ($courses as &$my_course) {
$course_info = api_get_course_info($my_course['course_code']);
$courseCode = $my_course['course_code'];
$categoryCode = !empty($my_course['categoryCode']) ? $my_course['categoryCode'] : "";
foreach ($courses as $courseId) {
$course_info = api_get_course_info_by_id($courseId);
$courseCode = $course_info['code'];
$categoryCode = !empty($course_info['categoryCode']) ? $course_info['categoryCode'] : "";
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
$my_course['extra_info']['register_button'] = '';
$access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
$access_link = self::get_access_link_by_user(
api_get_user_id(),
$course_info,
$my_course_code_list
);
//Course visibility
if ($access_link && in_array('register', $access_link)) {
@ -5187,27 +5143,27 @@ class CourseManager
/**
* Get information from the track_e_course_access table
* @param string $courseCode
* @param int $courseId
* @param int $sessionId
* @param string $startDate
* @param string $endDate
* @return array
*/
public static function getCourseAccessPerCourseAndSession(
$courseCode,
$courseId,
$sessionId,
$startDate,
$endDate
) {
$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$courseCode = Database::escape_string($courseCode);
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$startDate = Database::escape_string($startDate);
$endDate = Database::escape_string($endDate);
$sql = "SELECT * FROM $table
WHERE
course_code = '$courseCode' AND
c_id = '$courseId' AND
session_id = $sessionId AND
login_course_date BETWEEN '$startDate' AND '$endDate'
";

@ -689,12 +689,14 @@ function browseCoursesInCategory($category_code, $random_value = null, $limit =
$url_access_id = api_get_current_access_url_id();
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
if ($category_code != "ALL") {
$sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course
$sql = "SELECT * FROM $tbl_course as course
INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=course.code)
WHERE access_url_id = $url_access_id AND category_code='$category_code' $without_special_courses $visibilityCondition
ORDER BY title $limitFilter";
} else {
$sql = "SELECT * FROM $tbl_course as course INNER JOIN $tbl_url_rel_course as url_rel_course
$sql = "SELECT * FROM $tbl_course as course
INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=course.code)
WHERE access_url_id = $url_access_id $without_special_courses $visibilityCondition
ORDER BY title $limitFilter";
@ -709,7 +711,7 @@ function browseCoursesInCategory($category_code, $random_value = null, $limit =
$row['registration_code'] = !empty($row['registration_code']);
$count_users = CourseManager::get_users_count_in_course($row['code']);
$count_connections_last_month = Tracking::get_course_connections_count(
$row['code'],
$row['id'],
0,
api_get_utc_datetime(time() - (30 * 86400))
);

@ -345,7 +345,7 @@ define('TABLE_MAIN_SKILL_REL_PROFILE', 'skill_rel_profile');
define('TABLE_MAIN_CHAT', 'chat');
define('TABLE_TIMELINE', 'timeline');
//Gradebook model
// Gradebook model
define('TABLE_GRADE_MODEL', 'grade_model');
define('TABLE_GRADE_MODEL_COMPONENTS', 'grade_components');

@ -1265,9 +1265,9 @@ class Display
// Get the user's last access dates to all tools of this course
$sql = "SELECT *
FROM $t_track_e_access USE INDEX (access_cours_code, access_user_id)
FROM $t_track_e_access
WHERE
access_cours_code = '".$course_code."' AND
c_id = $course_id AND
access_user_id = '$user_id' AND
access_session_id ='".$course_info['id_session']."'";
$resLastTrackInCourse = Database::query($sql);

@ -245,25 +245,27 @@ class Event
public static function event_upload($doc_id)
{
$TABLETRACK_UPLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$courseCode = api_get_course_id();
$courseId = api_get_course_int_id();
$reallyNow = api_get_utc_datetime();
$user_id = api_get_user_id();
$doc_id = intval($doc_id);
$sql = "INSERT INTO ".$TABLETRACK_UPLOADS."
( upload_user_id,
upload_cours_id,
c_id,
upload_work_id,
upload_date,
upload_session_id
)
VALUES (
".$user_id.",
'".$courseCode."',
'".$courseId."',
'".$doc_id."',
'".$reallyNow."',
'".api_get_session_id()."'
)";
Database::query($sql);
return 1;
}
@ -489,6 +491,7 @@ class Event
}
$session_id = api_get_session_id();
$courseInfo = api_get_course_info_by_id($course_id);
if (!empty($question_id) && !empty($exe_id) && !empty($user_id)) {
$attempt = array(
@ -496,6 +499,7 @@ class Event
'question_id' => $question_id,
'answer' => $answer,
'marks' => $score,
'course_code' => $courseInfo['real_id'],
'c_id' => $course_id,
'session_id' => $session_id,
'position' => $position,
@ -503,7 +507,6 @@ class Event
'filename' => $file,
);
// Check if attempt exists.
$sql = "SELECT exe_id FROM $TBL_TRACK_ATTEMPT
@ -612,13 +615,14 @@ class Event
$question_id,
$answer_id,
$answer_id
)));
} else {
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, c_id, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)".
" VALUES ('".api_get_user_id()."',".
" '".api_get_course_int_id()."', ".
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_course_code, hotspot_user_id, c_id, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)
VALUES (
'".api_get_course_id()."',
".api_get_user_id()."',".
" ".api_get_course_int_id().", ".
" '".Database :: escape_string($exe_id)."', ".
" '".Database :: escape_string($question_id)."',".
" '".Database :: escape_string($answer_id)."',".
@ -678,8 +682,6 @@ class Event
if (!empty($course_info)) {
$course_id = $course_info['real_id'];
$course_code = $course_info['code'];
$course_code = Database::escape_string($course_code);
} else {
$course_id = null;
$course_code = null;
@ -695,25 +697,15 @@ class Event
$user_id = api_get_user_id();
}
$user_id = intval($user_id);
$sql = "INSERT INTO $TABLETRACK_DEFAULT
(default_user_id,
default_cours_code,
c_id,
default_date,
default_event_type,
default_value_type,
default_value
)
VALUES('$user_id.',
'$course_code',
'$course_id',
'$datetime',
'$event_type',
'$event_value_type',
'$event_value')";
Database::query($sql);
$params = array(
'default_user_id' => $user_id,
'c_id' => $course_id,
'default_date' => $datetime,
'default_event_type' => $event_type,
'default_value_type' => $event_value_type,
'default_value' => $event_value,
);
Database::insert($TABLETRACK_DEFAULT, $params);
return true;
}
@ -1106,7 +1098,7 @@ class Event
*
* @param int user id
* @param int exercise id
* @param string course code
* @param int $course_id
* @param int session id
*/
public static function delete_all_incomplete_attempts($user_id, $exercise_id, $course_id, $session_id = 0)
@ -1118,20 +1110,29 @@ class Event
$session_id = intval($session_id);
if (!empty($user_id) && !empty($exercise_id) && !empty($course_code)) {
$sql = "DELETE FROM $track_e_exercises
WHERE exe_user_id = $user_id AND
exe_exo_id = $exercise_id AND
c_id = '$course_id' AND
session_id = $session_id AND
status = 'incomplete' ";
WHERE
exe_user_id = $user_id AND
exe_exo_id = $exercise_id AND
c_id = '$course_id' AND
session_id = $session_id AND
status = 'incomplete' ";
Database::query($sql);
Event::addEvent(LOG_EXERCISE_RESULT_DELETE, LOG_EXERCISE_AND_USER_ID, $exercise_id.'-'.$user_id, null, null, $course_code, $session_id);
Event::addEvent(
LOG_EXERCISE_RESULT_DELETE,
LOG_EXERCISE_AND_USER_ID,
$exercise_id . '-' . $user_id,
null,
null,
$course_code,
$session_id
);
}
}
/**
* Gets all exercise results (NO Exercises in LPs ) from a given exercise id, course, session
* @param int exercise id
* @param string course code
* @param int $courseId
* @param int session id
* @return array with the results
*
@ -1150,13 +1151,14 @@ class Event
$user_condition = "AND exe_user_id = $user_id ";
}
$sql = "SELECT * FROM $TABLETRACK_EXERCICES
WHERE status = '' AND
c_id = '$courseId' AND
exe_exo_id = '$exercise_id' AND
session_id = $session_id AND
orig_lp_id =0 AND
orig_lp_item_id = 0
$user_condition
WHERE
status = '' AND
c_id = '$courseId' AND
exe_exo_id = '$exercise_id' AND
session_id = $session_id AND
orig_lp_id =0 AND
orig_lp_item_id = 0
$user_condition
ORDER BY exe_id";
$res = Database::query($sql);
$list = array();
@ -1175,7 +1177,7 @@ class Event
/**
* Gets all exercise results (NO Exercises in LPs ) from a given exercise id, course, session
* @param string course code
* @param int $courseId
* @param int session id
* @return array with the results
*
@ -1219,7 +1221,7 @@ class Event
/**
* Gets all exercise results (NO Exercises in LPs) from a given exercise id, course, session
* @param int exercise id
* @param string course code
* @param int $courseId
* @param int session id
* @return array with the results
*
@ -1356,8 +1358,9 @@ class Event
/**
* Count exercise attempts (NO Exercises in LPs ) from a given exercise id, course, session
* @param int $user_id
* @param int exercise id
* @param int course id
* @param int $courseId
* @param int session id
* @return array with the results
*
@ -1385,17 +1388,17 @@ class Event
$row = Database::fetch_array($res, 'ASSOC');
$result = $row['count'];
}
return $result;
}
/**
* Gets all exercise BEST results attempts (NO Exercises in LPs ) from a given exercise id, course, session per user
* @param int exercise id
* @param int course id
* @param int session id
* @param int $exercise_id
* @param int $courseId
* @param int $session_id
* @return array with the results
* @todo rename this function
*
*/
public static function get_best_exercise_results_by_user($exercise_id, $courseId, $session_id = 0)
{
@ -1505,14 +1508,17 @@ class Event
$exercise_id = intval($exercise_id);
$sql = "SELECT count(e.exe_id) as count
FROM $table_track_exercises e LEFT JOIN $table_track_attempt a ON e.exe_id = a.exe_id
WHERE exe_exo_id = $exercise_id AND
c_id = '$courseId' AND
e.session_id = $session_id AND
orig_lp_id = 0 AND
marks IS NULL AND
status = '' AND
orig_lp_item_id = 0 ORDER BY e.exe_id";
FROM $table_track_exercises e
LEFT JOIN $table_track_attempt a
ON e.exe_id = a.exe_id
WHERE
exe_exo_id = $exercise_id AND
c_id = '$courseId' AND
e.session_id = $session_id AND
orig_lp_id = 0 AND
marks IS NULL AND
status = '' AND
orig_lp_item_id = 0 ORDER BY e.exe_id";
$res = Database::query($sql);
$row = Database::fetch_array($res, 'ASSOC');
@ -1552,7 +1558,7 @@ class Event
/**
* Gets all exercise events from a Learning Path within a Course nd Session
* @param int exercise id
* @param string course_code
* @param int $courseId
* @param int session id
* @return array
*/
@ -1565,12 +1571,13 @@ class Event
$session_id = intval($session_id);
$sql = "SELECT * FROM $table_track_exercises
WHERE status = '' AND
c_id = $courseId AND
exe_exo_id = '$exercise_id' AND
session_id = $session_id AND
orig_lp_id !=0 AND
orig_lp_item_id != 0";
WHERE
status = '' AND
c_id = $courseId AND
exe_exo_id = '$exercise_id' AND
session_id = $session_id AND
orig_lp_id !=0 AND
orig_lp_item_id != 0";
$res = Database::query($sql);
$list = array();
@ -1666,20 +1673,21 @@ class Event
$question_id = intval($question_id);
$sql = "DELETE FROM $table_track_attempt
WHERE exe_id = $exe_id AND
user_id = $user_id AND
c_id = $courseId AND
session_id = $session_id AND
question_id = $question_id ";
WHERE
exe_id = $exe_id AND
user_id = $user_id AND
c_id = $courseId AND
session_id = $session_id AND
question_id = $question_id ";
Database::query($sql);
$courseInfo = api_get_course_info_by_id($courseId);
Event::addEvent(
LOG_QUESTION_RESULT_DELETE,
LOG_EXERCISE_ATTEMPT_QUESTION_ID,
$exe_id . '-' . $question_id,
null,
null,
$course_code,
$courseInfo['code'],
$session_id
);
}
@ -1750,21 +1758,21 @@ class Event
/**
* User logs in for the first time to a course
* @param $course_code
* @param $user_id
* @param $session_id
* @param int $courseId
* @param int $user_id
* @param int $session_id
*/
public static function event_course_login($courseId, $user_id, $session_id)
{
$course_tracking_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$time = api_get_datetime();
$courseId = Database::escape_string($courseId);
$user_id = Database::escape_string($user_id);
$session_id = Database::escape_string($session_id);
$courseId = intval($courseId);
$user_id = intval($user_id);
$session_id = intval($session_id);
$sql = "INSERT INTO $course_tracking_table(c_id, user_id, login_course_date, logout_course_date, counter, session_id)
VALUES('".$courseId."', '".$user_id."', '$time', '$time', '1', '".$session_id."')";
VALUES('".$courseId."', '".$user_id."', '$time', '$time', '1', '".$session_id."')";
Database::query($sql);
//Course catalog stats modifications see #4191

@ -684,7 +684,7 @@ class ExerciseLib
*/
if ($origin !== null) {
global $exe_id;
$trackAttempts = Database::get_statistic_table(
$trackAttempts = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_ATTEMPT
);
$sqlTrackAttempt = 'SELECT answer FROM ' . $trackAttempts . ' WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId;
@ -1137,7 +1137,7 @@ class ExerciseLib
public static function get_exercise_track_exercise_info($exe_id)
{
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(
$TBL_TRACK_EXERCICES = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCICES
);
$TBL_COURSE = Database::get_main_table(TABLE_MAIN_COURSE);
@ -1224,7 +1224,13 @@ class ExerciseLib
$exercise_id = intval($exercise_id);
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
return api_get_course_int_id() . '_' . api_get_session_id() . '_' . $exercise_id . '_' . api_get_user_id() . '_' . $lp_id . '_' . $lp_item_id;
return
api_get_course_int_id() . '_' .
api_get_session_id() . '_' .
$exercise_id . '_' .
api_get_user_id() . '_' .
$lp_id . '_' .
$lp_item_id;
}
/**
@ -1313,7 +1319,7 @@ class ExerciseLib
$in_number_of_items = intval($in_number_of_items);
$in_from = intval($in_from);
$TBL_TRACK_HOTPOTATOES = Database:: get_statistic_table(
$TBL_TRACK_HOTPOTATOES = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_HOTPOTATOES
);
$TBL_USER = Database:: get_main_table(TABLE_MAIN_USER);
@ -1381,7 +1387,7 @@ class ExerciseLib
$courseId,
$sessionId
) {
$table = Database:: get_statistic_table(
$table = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_HOTPOTATOES
);
@ -1443,13 +1449,13 @@ class ExerciseLib
$TBL_EXERCICES = Database:: get_course_table(TABLE_QUIZ_TEST);
$TBL_GROUP_REL_USER = Database:: get_course_table(TABLE_GROUP_USER);
$TBL_GROUP = Database:: get_course_table(TABLE_GROUP);
$TBL_TRACK_EXERCICES = Database:: get_statistic_table(
$TBL_TRACK_EXERCICES = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCICES
);
$TBL_TRACK_HOTPOTATOES = Database:: get_statistic_table(
$TBL_TRACK_HOTPOTATOES = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_HOTPOTATOES
);
$TBL_TRACK_ATTEMPT_RECORDING = Database:: get_statistic_table(
$TBL_TRACK_ATTEMPT_RECORDING = Database:: get_main_table(
TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING
);
@ -2407,7 +2413,7 @@ class ExerciseLib
$my_score,
$my_exe_id,
$exercise_id,
$course_code,
$courseId,
$session_id = 0,
$return_string = true
) {
@ -2419,7 +2425,7 @@ class ExerciseLib
}
$user_results = Event::get_all_exercise_results(
$exercise_id,
$course_code,
$courseId,
$session_id,
false
);
@ -2472,16 +2478,16 @@ class ExerciseLib
/**
* Get the best attempt in a exercise (NO Exercises in LPs )
* @param int $exercise_id
* @param string $course_code
* @param int $courseId
* @param int $session_id
*
* @return array
*/
public static function get_best_attempt_in_course($exercise_id, $course_code, $session_id)
public static function get_best_attempt_in_course($exercise_id, $courseId, $session_id)
{
$user_results = Event::get_all_exercise_results(
$exercise_id,
$course_code,
$courseId,
$session_id,
false
);
@ -2508,7 +2514,7 @@ class ExerciseLib
* Get the best score in a exercise (NO Exercises in LPs )
* @param int $user_id
* @param int $exercise_id
* @param string $course_code
* @param int $courseId
* @param int $session_id
*
* @return array
@ -2516,12 +2522,12 @@ class ExerciseLib
public static function get_best_attempt_by_user(
$user_id,
$exercise_id,
$course_code,
$courseId,
$session_id
) {
$user_results = Event::get_all_exercise_results(
$exercise_id,
$course_code,
$courseId,
$session_id,
false,
$user_id
@ -2546,15 +2552,15 @@ class ExerciseLib
/**
* Get average score (NO Exercises in LPs )
* @param int exercise id
* @param string course code
* @param int $courseId
* @param int session id
* @return float Average score
*/
public static function get_average_score($exercise_id, $course_code, $session_id)
public static function get_average_score($exercise_id, $courseId, $session_id)
{
$user_results = Event::get_all_exercise_results(
$exercise_id,
$course_code,
$courseId,
$session_id
);
$avg_score = 0;
@ -2577,14 +2583,14 @@ class ExerciseLib
/**
* Get average score by score (NO Exercises in LPs )
* @param int exercise id
* @param string course code
* @param int $courseId
* @param int session id
* @return float Average score
*/
public static function get_average_score_by_course($course_code, $session_id)
public static function get_average_score_by_course($courseId, $session_id)
{
$user_results = Event::get_all_exercise_results_by_course(
$course_code,
$courseId,
$session_id,
false
);
@ -2601,7 +2607,6 @@ class ExerciseLib
}
}
//We asume that all exe_weighting
//$avg_score = show_score( $avg_score / count($user_results) , $result['exe_weighting']);
$avg_score = ($avg_score / count($user_results));
}
@ -2610,19 +2615,19 @@ class ExerciseLib
/**
* @param int $user_id
* @param string $course_code
* @param int $courseId
* @param int $session_id
*
* @return float|int
*/
public static function get_average_score_by_course_by_user(
$user_id,
$course_code,
$courseId,
$session_id
) {
$user_results = Event::get_all_exercise_results_by_user(
$user_id,
$course_code,
$courseId,
$session_id
);
$avg_score = 0;
@ -2647,28 +2652,25 @@ class ExerciseLib
/**
* Get average score by score (NO Exercises in LPs )
* @param int exercise id
* @param string course code
* @param int $courseId
* @param int session id
* @return float Best average score
*/
public static function get_best_average_score_by_exercise(
$exercise_id,
$course_code,
$courseId,
$session_id,
$user_count
) {
$user_results = Event::get_best_exercise_results_by_user(
$exercise_id,
$course_code,
$courseId,
$session_id
);
$avg_score = 0;
if (!empty($user_results)) {
foreach ($user_results as $result) {
if (!empty($result['exe_weighting']) && intval(
$result['exe_weighting']
) != 0
) {
if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) {
$score = $result['exe_result'] / $result['exe_weighting'];
$avg_score += $score;
}
@ -2682,6 +2684,7 @@ class ExerciseLib
$avg_score = 0;
}
}
return $avg_score;
}
@ -3210,6 +3213,9 @@ class ExerciseLib
return $res;
}
/**
* @param int $exe_id
*/
public static function create_chat_exercise_session($exe_id)
{
if (!isset($_SESSION['current_exercises'])) {
@ -3218,6 +3224,9 @@ class ExerciseLib
$_SESSION['current_exercises'][$exe_id] = true;
}
/**
* @param int $exe_id
*/
public static function delete_chat_exercise_session($exe_id)
{
if (isset($_SESSION['current_exercises'])) {
@ -3450,7 +3459,7 @@ class ExerciseLib
if ($origin != 'learnpath') {
if ($show_results || $show_only_score) {
$total_score_text .= '<div class="question_row">';
$total_score_text .= get_question_ribbon(
$total_score_text .= self::get_question_ribbon(
$objExercise,
$total_score,
$total_weight,

@ -380,8 +380,6 @@ class Login
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
if (!empty($_GET['id_session'])) {
$_SESSION['id_session'] = intval($_GET['id_session']);
@ -396,7 +394,7 @@ class Login
if (!isset($_SESSION['login_as'])) {
//Course login
if (isset($_user['user_id'])) {
Event::event_course_login($_course['sysCode'], $_user['user_id'], api_get_session_id());
Event::event_course_login(api_get_course_int_id(), $_user['user_id'], api_get_session_id());
}
}
} else {
@ -479,24 +477,23 @@ class Login
//We select the last record for the current course in the course tracking table
//But only if the login date is < than now + max_life_time
$sql = "SELECT course_access_id FROM $course_tracking_table
WHERE user_id = " . intval($_user ['user_id']) . " AND
course_code = '$course_code' AND
session_id = " . api_get_session_id() . " AND
login_course_date > now() - INTERVAL $session_lifetime SECOND
ORDER BY login_course_date DESC LIMIT 0,1";
WHERE
user_id = " . intval($_user ['user_id']) . " AND
c_id = '".api_get_course_int_id()."' AND
session_id = " . api_get_session_id() . " AND
login_course_date > now() - INTERVAL $session_lifetime SECOND
ORDER BY login_course_date DESC LIMIT 0,1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$i_course_access_id = Database::result($result, 0, 0);
//We update the course tracking table
$sql = "UPDATE $course_tracking_table SET logout_course_date = '$time', counter = counter+1
WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id();
//error_log($sql);
WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id();
Database::query($sql);
} else {
$sql = "INSERT INTO $course_tracking_table (course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('" . $course_code . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')";
//error_log($sql);
$sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('" . api_get_course_int_id() . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')";
Database::query($sql);
}
}

@ -88,23 +88,23 @@ class MySpace
* Gets the connections to a course as an array of login and logout time
*
* @param int User ud
* @param string Course code
* @param int $courseId
* @param int Session id (optional, default = 0)
* @return array Conections
*/
static function get_connections_to_course($user_id, $course_code, $session_id = 0)
static function get_connections_to_course($user_id, $courseId, $session_id = 0)
{
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
// protect data
$user_id = intval($user_id);
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = '.$user_id.' AND
course_code="'.$course_code.'" AND
c_id="'.$courseId.'" AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC';
$rs = Database::query($sql);
@ -118,7 +118,14 @@ class MySpace
return $connections;
}
static function get_connections_from_course_list($user_id, $course_list, $session_id = 0) {
/**
* @param $user_id
* @param $course_list
* @param int $session_id
* @return array|bool
*/
static function get_connections_from_course_list($user_id, $course_list, $session_id = 0)
{
// Database table definitions
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
if (empty($course_list)) {
@ -130,16 +137,19 @@ class MySpace
$session_id = intval($session_id);
$new_course_list = array();
foreach ($course_list as $course_item) {
$new_course_list[] = '"'.Database::escape_string($course_item['code']).'"';
$courseInfo = api_get_course_info($course_item['code']);
$courseId = $courseInfo['real_id'];
$new_course_list[] = '"'.$courseId.'"';
}
$course_list = implode(', ', $new_course_list);
if (empty($course_list)) {
return false;
}
$sql = 'SELECT login_course_date, logout_course_date, course_code FROM ' . $tbl_track_course . '
$sql = 'SELECT login_course_date, logout_course_date, course_code
FROM ' . $tbl_track_course . '
WHERE user_id = '.$user_id.' AND
course_code IN ('.$course_list.') AND
c_id IN ('.$course_list.') AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC';
$rs = Database::query($sql);
@ -148,38 +158,11 @@ class MySpace
while ($row = Database::fetch_array($rs)) {
$timestamp_login_date = api_strtotime($row['login_course_date'], 'UTC');
$timestamp_logout_date = api_strtotime($row['logout_course_date'], 'UTC');
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date,'course_code' => $row['course_code']);
}
return $connections;
}
/**
* TODO: Not used, to b deleted?
* Enter description here...
* @param int $user_id
* @param string $course_code
* @param date $year
* @param date $month
* @param date $day
* @return unknown
*/
static function get_connections_to_course_by_time($user_id, $course_code, $year = '', $month = '', $day = '') {
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
AND course_code="' . Database::escape_string($course_code) . '"
ORDER BY login_course_date DESC';
$rs = Database::query($sql);
$connections = array();
while ($row = Database::fetch_array($rs)) {
$login_date = $row['login_course_date'];
$logout_date = $row['logout_course_date'];
$timestamp_login_date = strtotime($login_date);
$timestamp_logout_date = strtotime($logout_date);
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date);
$connections[] = array(
'login' => $timestamp_login_date,
'logout' => $timestamp_logout_date,
'c_id' => $row['c_id']
);
}
return $connections;
}
@ -216,18 +199,23 @@ class MySpace
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course_user WHERE user_id = '".intval($user_id)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$sql = "SELECT * FROM $tbl_course_user
WHERE user_id = '".intval($user_id)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$result = Database::query($sql);
while ($row = Database::fetch_row($result)) {
$courseCode = $row[0];
$courseInfo = api_get_course_info($courseCode);
$courseId = $courseInfo['real_id'];
$return .= '<tr>';
// course code
$return .= ' <td width="157px" >'.cut($row[0], 20, true).'</td>';
$return .= ' <td width="157px" >'.cut($courseCode, 20, true).'</td>';
// time spent in the course
$return .= ' <td><div>'.api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_id, $row[0])).'</div></td>';
$return .= ' <td><div>'.api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_id, $courseId)).'</div></td>';
// student progress in course
$return .= ' <td><div>'.round(Tracking :: get_avg_student_progress($user_id, $row[0]), 2).'</div></td>';
$return .= ' <td><div>'.round(Tracking :: get_avg_student_progress($user_id, $courseCode), 2).'</div></td>';
// student score
$avg_score = Tracking :: get_avg_student_score($user_id, $row[0]);
$avg_score = Tracking :: get_avg_student_score($user_id, $courseCode);
if (is_numeric($avg_score)) {
$avg_score = round($avg_score,2);
} else {
@ -236,21 +224,17 @@ class MySpace
$return .= ' <td><div>'.$avg_score.'</div></td>';
// student tes score
//$return .= ' <td><div style="width:40px">'.round(Tracking :: get_avg_student_exercise_score ($user_id, $row[0]),2).'%</div></td>';
//$return .= ' <td><div style="width:40px">'.round(Tracking :: get_avg_student_exercise_score ($user_id, $courseCode),2).'%</div></td>';
// student messages
$return .= ' <td><div>'.Tracking :: count_student_messages($user_id, $row[0]).'</div></td>';
$return .= ' <td><div>'.Tracking :: count_student_messages($user_id, $courseCode).'</div></td>';
// student assignments
$return .= ' <td><div>'.Tracking :: count_student_assignments($user_id, $row[0]).'</div></td>';
$return .= ' <td><div>'.Tracking :: count_student_assignments($user_id, $courseCode).'</div></td>';
// student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
$exercises_results = MySpace::exercises_results($user_id, $row[0]);
$exercises_results = MySpace::exercises_results($user_id, $courseCode);
$return .= ' <td width="105px"><div>'.(is_null($exercises_results['percentage']) ? '' : $exercises_results['score_obtained'].'/'.$exercises_results['score_possible'].' ( '.$exercises_results['percentage'].'% )').'</div></td>';
//$return .= ' <td><div>'.$exercises_results['score_possible'].'</div></td>';
$return .= ' <td><div>'.$exercises_results['questions_answered'].'</div></td>';
//$return .= ' <td><div>'.$exercises_results['percentage'].'% </div></td>';
// first connection
//$return .= ' <td width="60px">'.Tracking :: get_first_connection_date_on_the_course ($user_id, $row[0]).'</td>';
// last connection
$return .= ' <td><div>'.Tracking :: get_last_connection_date_on_the_course ($user_id, $row[0]).'</div></td>';
$return .= ' <td><div>'.Tracking :: get_last_connection_date_on_the_course ($user_id, $courseId).'</div></td>';
$return .= '<tr>';
}
$return .= '</table>';
@ -1239,16 +1223,21 @@ class MySpace
public static function course_tracking_filter($course_code, $url_params, $row)
{
$course_code = $row[0];
$courseInfo = api_get_course_info($course_code);
// the table header
$return = '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
// database table definition
$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_user AS u INNER JOIN $tbl_course_rel_user AS cu ON cu.user_id = u.user_id WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);";
$sql = "SELECT *
FROM $tbl_user AS u
INNER JOIN $tbl_course_rel_user AS cu
ON cu.user_id = u.user_id
WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);";
$result = Database::query($sql);
$time_spent = 0;
$progress = 0;
@ -1263,7 +1252,7 @@ class MySpace
$total_questions_answered = 0;
while ($row = Database::fetch_object($result)) {
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row->user_id, $course_code);
$time_spent += Tracking::get_time_spent_on_the_course($row->user_id, $courseInfo['real_id']);
$progress_tmp = Tracking::get_avg_student_progress($row->user_id, $course_code, array(), null, true);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
@ -1274,8 +1263,7 @@ class MySpace
}
$nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $course_code, null, false);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $courseInfo['real_id'], null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
$last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
@ -1344,7 +1332,6 @@ class MySpace
{
// database table definition
$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
// the values of the sortable table
@ -1387,13 +1374,19 @@ class MySpace
// the other lines (the data)
foreach ($course_data as $key => $course) {
$course_code = $course[0];
$course_title = $course[1];
$courseInfo = api_get_course_info($course_code);
$course_title = $courseInfo['title'];
$courseId = $courseInfo['real_id'];
$csv_row = array();
$csv_row[] = $course_title;
// getting all the courses of the session
$sql = "SELECT * FROM $tbl_user AS u INNER JOIN $tbl_course_rel_user AS cu ON cu.user_id = u.user_id WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);";
$sql = "SELECT *
FROM $tbl_user AS u
INNER JOIN $tbl_course_rel_user AS cu
ON cu.user_id = u.user_id
WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);";
$result = Database::query($sql);
$time_spent = 0;
$progress = 0;
@ -1408,7 +1401,7 @@ class MySpace
$total_questions_answered = 0;
while ($row = Database::fetch_object($result)) {
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row->user_id, $course_code);
$time_spent += Tracking::get_time_spent_on_the_course($row->user_id, $courseId);
$progress_tmp = Tracking::get_avg_student_progress($row->user_id, $course_code, array(), null, true);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
@ -1420,7 +1413,7 @@ class MySpace
$nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $course_code, null, false);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $courseId, null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
@ -1602,14 +1595,24 @@ class MySpace
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course AS c INNER JOIN $tbl_session_rel_course AS sc ON sc.course_code = c.code WHERE sc.id_session = '".$session_id."';";
$sql = "SELECT * FROM $tbl_course AS c
INNER JOIN $tbl_session_rel_course AS sc
ON sc.course_code = c.code
WHERE sc.id_session = '".$session_id."';";
$result = Database::query($sql);
while ($row = Database::fetch_object($result)) {
$courseCode = $row->code;
$courseInfo = api_get_course_info($row->code);
$courseId = $courseInfo['real_id'];
$return .= '<tr>';
// course code
$return .= ' <td width="157px" >'.$row->title.'</td>';
// get the users in the course
$sql = "SELECT user_id FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu ON u.user_id = scu.id_user WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$row->code."';";
$sql = "SELECT user_id
FROM $tbl_user AS u
INNER JOIN $tbl_session_rel_course_rel_user AS scu
ON u.user_id = scu.id_user
WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$courseCode."';";
$result_users = Database::query($sql);
$time_spent = 0;
$progress = 0;
@ -1624,7 +1627,7 @@ class MySpace
$total_questions_answered = 0;
while($row_user = Database::fetch_object($result_users)) {
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $row->code, $session_id);
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
@ -1635,8 +1638,7 @@ class MySpace
}
$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->code, $session_id, false);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $courseId, $session_id, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition! To be cleaned.
@ -1753,14 +1755,22 @@ class MySpace
$session_title = $session[1];
// getting all the courses of the session
$sql = "SELECT * FROM $tbl_course AS c INNER JOIN $tbl_session_rel_course AS sc ON sc.course_code = c.code WHERE sc.id_session = '".$session_id."';";
$sql = "SELECT * FROM $tbl_course AS c
INNER JOIN $tbl_session_rel_course AS sc
ON sc.course_code = c.code
WHERE sc.id_session = '".$session_id."';";
$result = Database::query($sql);
while ($row = Database::fetch_object($result)) {
$courseInfo = api_get_course_info($row->code);
$courseId = $courseInfo['real_id'];
$csv_row = array();
$csv_row[] = $session_title;
$csv_row[] = $row->title;
// get the users in the course
$sql = "SELECT user_id FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu ON u.user_id = scu.id_user WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$row->code."';";
$sql = "SELECT user_id FROM $tbl_user AS u
INNER JOIN $tbl_session_rel_course_rel_user AS scu
ON u.user_id = scu.id_user
WHERE scu.id_session = '".$session_id."' AND scu.course_code = '".$row->code."';";
$result_users = Database::query($sql);
$time_spent = 0;
$progress = 0;
@ -1775,7 +1785,7 @@ class MySpace
$total_questions_answered = 0;
while($row_user = Database::fetch_object($result_users)) {
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $row->code, $session_id);
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
@ -1787,7 +1797,7 @@ class MySpace
$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->code, $session_id, false);
$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $courseId, $session_id, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
@ -1975,9 +1985,13 @@ class MySpace
// the other lines (the data)
foreach ($user_data as $key => $user) {
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course_user WHERE user_id = '".intval($user[4])."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$sql = "SELECT * FROM $tbl_course_user
WHERE user_id = '".intval($user[4])."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$result = Database::query($sql);
while ($row = Database::fetch_row($result)) {
$courseInfo = api_get_course_info($row['course_code']);
$courseId = $courseInfo['real_id'];
$csv_row = array();
// user official code
$csv_row[] = $user[0];
@ -1998,7 +2012,7 @@ class MySpace
}
}
// time spent in the course
$csv_row[] = api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user[4], $row[0]));
$csv_row[] = api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user[4], $courseId));
// student progress in course
$csv_row[] = round(Tracking :: get_avg_student_progress ($user[4], $row[0]), 2);
// student score
@ -2016,9 +2030,9 @@ class MySpace
$csv_row[] = $exercises_results['questions_answered'];
$csv_row[] = $exercises_results['percentage'];
// first connection
$csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $row[0]);
$csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $courseId);
// last connection
$csv_row[] = strip_tags(Tracking :: get_last_connection_date_on_the_course ($user[4], $row[0]));
$csv_row[] = strip_tags(Tracking :: get_last_connection_date_on_the_course ($user[4], $courseId));
$csv_content[] = $csv_row;
}
@ -2062,20 +2076,23 @@ class MySpace
$res = Database::query($sql);
while ($row_course = Database::fetch_row($res)) {
$course_code = $row_course[0];
$course_info = api_get_course_info($course_code);
$courseInfo = api_get_course_info($course_code);
$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
// students directly subscribed to the course
if (empty($session_id)) {
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user
WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
} else {
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2";
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu
WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2";
}
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
while ($row = Database::fetch_array($rs)) {
$users[] = $row['user_id'];
}
if (count($users) > 0) {
$nb_students_in_course = count($users);
@ -2084,7 +2101,7 @@ class MySpace
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_score_in_course = Tracking::get_avg_student_score($users, $course_code, array(), $session_id);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code, 0, $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $course_code, $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $courseInfo['real_id'], $session_id);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
if (is_numeric($avg_score_in_course)) {
@ -2641,13 +2658,19 @@ class MySpace
}
}
function get_stats($user_id, $course_code, $start_date = null, $end_date = null) {
/**
* @param $user_id
* @param int $courseId
* @param null $start_date
* @param null $end_date
* @return array
*/
function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
{
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info($course_code);
$course_info = api_get_course_info_by_id($courseId);
if (!empty($course_info)) {
$strg_sd = "";
$strg_ed = "";
@ -2656,13 +2679,15 @@ function get_stats($user_id, $course_code, $start_date = null, $end_date = null)
$strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
$strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
}
$sql = 'SELECT SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
count(user_id) as times
FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
AND course_code = "' . Database::escape_string($course_code) . '" '.$strg_sd.' '.$strg_ed.' '.'
ORDER BY login_course_date ASC';
$sql = 'SELECT
SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
count(user_id) as times
FROM ' . $tbl_track_course . '
WHERE
user_id = ' . intval($user_id) . ' AND
c_id = "' . intval($courseId) . '" '.$strg_sd.' '.$strg_ed.' '.'
ORDER BY login_course_date ASC';
$rs = Database::query($sql);
$result = array();
@ -2689,18 +2714,19 @@ function add_day_to($end_date) {
* Gets the connections to a course as an array of login and logout time
*
* @param int $user_id
* @param string $course_code
* @param int $courseId
* @author Jorge Frisancho Jibaja
* @author Julio Montoya <gugli100@gmail.com> fixing the function
* @version OCT-22- 2010
* @return array
*/
function get_connections_to_course_by_date($user_id, $course_code, $start_date, $end_date)
function get_connections_to_course_by_date($user_id, $courseId, $start_date, $end_date)
{
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info($course_code);
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info_by_id($courseId);
$user_id = intval($user_id);
$courseId = intval($courseId);
$connections = array();
if (!empty($course_info)) {
@ -2709,7 +2735,7 @@ function get_connections_to_course_by_date($user_id, $course_code, $start_date,
FROM $tbl_track_course
WHERE
user_id = $user_id AND
course_code = '$course_code' AND
c_id = '$courseId' AND
login_course_date BETWEEN '$start_date' AND '$end_date' AND
logout_course_date BETWEEN '$start_date' AND '$end_date'
ORDER BY login_course_date ASC";

@ -38,7 +38,7 @@ 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, course, session_id, access_url_id) VALUES ($uid,$uid,'$login_date','$login_ip', '".$_course['id']."' , '$session_id' , '$access_url_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' )";
} 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')";
}
@ -97,7 +97,7 @@ function online_logout($user_id = null, $logout_redirect = false) {
global $_configuration, $extAuthSource;
// Database table definition
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
if (empty($user_id)) {
$user_id = intval($_GET['uid']);
@ -159,10 +159,10 @@ function online_logout($user_id = null, $logout_redirect = false) {
*/
function LoginDelete($user_id)
{
$online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$user_id = intval($user_id);
$query = "DELETE FROM ".$online_table ." WHERE login_user_id = '".$user_id."'";
@Database::query($query);
Database::query($query);
}
/**
@ -171,7 +171,7 @@ function LoginDelete($user_id)
*/
function user_is_online($user_id)
{
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_id = api_get_current_access_url_id();
@ -230,7 +230,7 @@ function who_is_online($from, $number_of_items, $column = null, $direction = nul
$online_time = time() - $time_limit*60;
$current_date = api_get_utc_datetime($online_time);
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$query = '';
@ -272,7 +272,8 @@ function who_is_online($from, $number_of_items, $column = null, $direction = nul
LIMIT $from, $number_of_items";
} else {
// all users online
$query = "SELECT login_user_id, login_date FROM ".$track_online_table ." track
$query = "SELECT login_user_id, login_date
FROM ".$track_online_table ." track
INNER JOIN ".$table_user ." u
ON (u.user_id=track.login_user_id)
WHERE u.status != ".ANONYMOUS." AND track.access_url_id = $access_url_id AND
@ -308,7 +309,7 @@ function who_is_online_count($time_limit = null, $friends = false)
} else {
$time_limit = intval($time_limit);
}
$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
@ -395,12 +396,14 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
$current_date = api_get_utc_datetime($online_time);
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$course_code = Database::escape_string($course_code);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$from = intval($from);
$number_of_items = intval($number_of_items);
$query = "SELECT login_user_id, login_date FROM $track_online_table
WHERE login_user_id <> 2 AND course='$course_code' AND login_date >= '$current_date'
WHERE login_user_id <> 2 AND c_id='$courseId' AND login_date >= '$current_date'
LIMIT $from, $number_of_items ";
$result = Database::query($query);
@ -430,10 +433,12 @@ function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null)
$online_time = time() - $time_limit * 60;
$current_date = api_get_utc_datetime($online_time);
$courseInfo = api_get_course_info($coursecode);
$courseId = $courseInfo['real_id'];
$query = "SELECT count(login_user_id) as count
FROM ".$track_online_table ."
WHERE login_user_id <> 2 AND course='".$coursecode."' AND login_date >= '$current_date' ";
WHERE login_user_id <> 2 AND c_id='".$courseId."' AND login_date >= '$current_date' ";
$result = Database::query($query);
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);

@ -981,10 +981,10 @@ class SessionManager
$sql = "SELECT count(*) as count
FROM $table_stats_access
WHERE access_tool = 'course_description'
AND access_cours_code = '%s'
AND c_id = '%s'
AND access_session_id = %s
AND access_user_id = %s ";
$sql_query = sprintf($sql, $course['code'], $user['id_session'], $user['user_id']);
$sql_query = sprintf($sql, $course['real_id'], $user['id_session'], $user['user_id']);
$result = Database::query($sql_query);
$row = Database::fetch_array($result);
@ -1028,12 +1028,13 @@ class SessionManager
//count visited wiki pages
$sql = "SELECT count(distinct default_value) as count
FROM $table_stats_default
WHERE default_user_id = %s
AND default_cours_code = '%s'
AND default_event_type = 'wiki_page_view'
AND default_value_type = 'wiki_page_id'
AND c_id = %s";
$sql_query = sprintf($sql, $user['user_id'], $course['code'], $course['real_id']);
WHERE
default_user_id = %s AND
default_event_type = 'wiki_page_view' AND
default_value_type = 'wiki_page_id' AND
c_id = %s
";
$sql_query = sprintf($sql, $user['user_id'], $course['real_id']);
$result = Database::query($sql_query);
$row = Database::fetch_array($result);
@ -1231,7 +1232,7 @@ class SessionManager
a.session_id
FROM $track_e_course_access a
INNER JOIN $user u ON a.user_id = u.user_id
INNER JOIN $course c ON a.course_code = c.code
INNER JOIN $course c ON a.c_id = c.id
$where $order $limit";
$result = Database::query(sprintf($sql, $sessionId, $courseId));

@ -142,7 +142,7 @@ class Statistics
{
// Database table definitions
global $_configuration;
$track_e_default = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
@ -173,7 +173,7 @@ class Statistics
static function get_activities_data($from, $number_of_items, $column, $direction)
{
global $dateTimeFormatLong;
$track_e_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
@ -354,7 +354,7 @@ class Statistics
*/
static function print_login_stats($type)
{
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
@ -430,7 +430,7 @@ class Statistics
static function print_recent_login_stats()
{
$total_logins = array();
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
@ -456,23 +456,40 @@ class Statistics
*/
static function print_tool_stats()
{
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
$tools = array('announcement','assignment','calendar_event',
'chat','conference','course_description','document',
'dropbox','group','learnpath','link','quiz',
'student_publication','user','forum');
$tools = array(
'announcement',
'assignment',
'calendar_event',
'chat',
'conference',
'course_description',
'document',
'dropbox',
'group',
'learnpath',
'link',
'quiz',
'student_publication',
'user',
'forum'
);
$tool_names = array();
foreach ($tools as $tool) {
$tool_names[$tool] = get_lang(ucfirst($tool), '');
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT access_tool, count( access_id ) ".
"AS number_of_logins FROM $table, $access_url_rel_course_table ".
"WHERE access_tool IN ('".implode("','",$tools)."') AND course_code = access_cours_code AND access_url_id='".$current_url_id."' ".
"GROUP BY access_tool ";
$sql = "SELECT access_tool, count( access_id ) AS number_of_logins
FROM $table t , $access_url_rel_course_table a
WHERE
access_tool IN ('".implode("','",$tools)."') AND
t.c_id = a.c_id AND
access_url_id='".$current_url_id."'
GROUP BY access_tool
";
} else {
$sql = "SELECT access_tool, count( access_id ) ".
"AS number_of_logins FROM $table ".
@ -583,7 +600,7 @@ class Statistics
$access_url_rel_course_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
$columns[0] = 'access_cours_code';
$columns[0] = 'c_id';
$columns[1] = 'access_date';
$sql_order[SORT_ASC] = 'ASC';
$sql_order[SORT_DESC] = 'DESC';
@ -610,20 +627,22 @@ class Statistics
$form->display();
$values = $form->exportValues();
$date_diff = $values['date_diff'];
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
if (api_is_multiple_url_enabled()) {
$sql = "SELECT * FROM $table, $access_url_rel_course_table WHERE course_code = access_cours_code AND access_url_id='".$current_url_id."' ".
"GROUP BY access_cours_code ".
"HAVING access_cours_code <> '' ".
"AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
$sql = "SELECT * FROM $table t , $access_url_rel_course_table a
WHERE
t.c_id = a.c_id AND
access_url_id='".$current_url_id."'
GROUP BY c_id
HAVING c_id <> ''
AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
} else {
$sql = "SELECT * FROM $table ".
"GROUP BY access_cours_code ".
"HAVING access_cours_code <> '' ".
"GROUP BY c_id ".
"HAVING c_id <> '' ".
"AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
}
$res = Database::query($sql);
$number_of_courses = Database::num_rows($res);
$sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction];
$from = ($page_nr -1) * $per_page;
$sql .= ' LIMIT '.$from.','.$per_page;
@ -632,8 +651,9 @@ class Statistics
if (Database::num_rows($res) > 0) {
$courses = array ();
while ($obj = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($obj->c_id);
$course = array ();
$course[]= '<a href="'.api_get_path(WEB_PATH).'courses/'.$obj->access_cours_code.'">'.$obj->access_cours_code.' <a>';
$course[]= '<a href="'.api_get_path(WEB_PATH).'courses/'.$courseInfo['code'].'">'.$courseInfo['code'].' <a>';
//Allow sort by date hiding the numerical date
$course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date);
$courses[] = $course;
@ -731,7 +751,7 @@ class Statistics
static function print_users_not_logged_in_stats()
{
$total_logins = array();
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$total = self::count_users();

@ -1,4 +1,4 @@
<?php
<?php
/* For licensing terms, see /license.txt */
/**
@ -44,12 +44,12 @@
// regroup table names for maintenance purpose
//we can use the database class: this file is only called in the /index.php file before the global.inc.php
$TABLETRACK_OPEN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLESTATS_PROVIDERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_PROVIDERS);
$TABLESTATS_COUNTRIES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_COUNTRIES);
$TABLESTATS_BROWSERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_BROWSERS);
$TABLESTATS_OS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_OS);
$TABLESTATS_REFERERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_REFERERS);
$TABLETRACK_OPEN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLESTATS_PROVIDERS = Database::get_main_table(TABLE_STATISTIC_TRACK_C_PROVIDERS);
$TABLESTATS_COUNTRIES = Database::get_main_table(TABLE_STATISTIC_TRACK_C_COUNTRIES);
$TABLESTATS_BROWSERS = Database::get_main_table(TABLE_STATISTIC_TRACK_C_BROWSERS);
$TABLESTATS_OS = Database::get_main_table(TABLE_STATISTIC_TRACK_C_OS);
$TABLESTATS_REFERERS = Database::get_main_table(TABLE_STATISTIC_TRACK_C_REFERERS);
/*
Main : decodeOpenInfos launch all processes

@ -119,8 +119,8 @@ 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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql = "SELECT max(view_count)
FROM $TBL_LP_VIEW
@ -1221,7 +1221,7 @@ class Tracking
$start_date = null,
$end_date = null
) {
$tbl_track_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$condition_time = '';
if (is_array($userId)) {
@ -1272,17 +1272,17 @@ class Tracking
/**
* Calculates the time spent on the course
* @param integer $user_id
* @param string $course_code
* @param integer $courseId
* @param int Session id (optional)
*
* @return int Time in seconds
*/
public static function get_time_spent_on_the_course($user_id, $course_code, $session_id = 0)
public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
{
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
if (is_array($user_id)) {
$user_id = array_map('intval', $user_id);
$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
@ -1295,7 +1295,7 @@ class Tracking
FROM $tbl_track_course
WHERE
UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) AND
course_code='$course_code' AND
c_id = '$courseId' AND
session_id = '$session_id' $condition_user";
$rs = Database::query($sql);
@ -1311,7 +1311,7 @@ class Tracking
*/
public static function get_first_connection_date($student_id)
{
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date ASC LIMIT 0,1';
@ -1336,7 +1336,7 @@ class Tracking
*/
public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
{
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date DESC LIMIT 0,1';
@ -1384,7 +1384,7 @@ class Tracking
$date = api_get_utc_datetime(strtotime($days.' days ago'));
$studentList = array_map('intval', $studentList);
$tbl_track_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$select = " SELECT login_user_id ";
if ($getCount) {
$select = " SELECT count(DISTINCT login_user_id) as count";
@ -1409,27 +1409,28 @@ class Tracking
/**
* Get first user's connection date on the course
* @param int User id
* @param string Course code
* @param int $courseId
* @param int Session id (optional, default=0)
* @return string|bool Date with format long without day or false if there is no date
*/
public static function get_first_connection_date_on_the_course(
$student_id,
$course_code,
$courseId,
$session_id = 0,
$convert_date = true
) {
// protect data
$student_id = intval($student_id);
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date FROM '.$tbl_track_login.'
WHERE user_id = '.$student_id.'
AND course_code = "'.$course_code.'"
AND session_id = '.$session_id.'
ORDER BY login_course_date ASC LIMIT 0,1';
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date
FROM '.$tbl_track_login.'
WHERE
user_id = '.$student_id.' AND
c_id = "'.$courseId.'" AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($first_login_date = Database::result($rs, 0, 0)) {
@ -1440,6 +1441,7 @@ class Tracking
}
}
}
return false;
}
@ -1452,20 +1454,20 @@ class Tracking
*/
public static function get_last_connection_date_on_the_course(
$student_id,
$course_code,
$courseId,
$session_id = 0,
$convert_date = true
) {
// protect data
$student_id = intval($student_id);
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_track_e_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT access_date
FROM '.$tbl_track_e_access.'
WHERE access_user_id = '.$student_id.' AND
access_cours_code = "'.$course_code.'" AND
c_id = "'.$courseId.'" AND
access_session_id = '.$session_id.'
ORDER BY access_date DESC
LIMIT 0,1';
@ -1504,13 +1506,13 @@ class Tracking
/**
* Get count of the connections to the course during a specified period
* @param string Course code
* @param int $courseId
* @param int Session id (optional)
* @param int Datetime from which to collect data (defaults to 0)
* @param int Datetime to which to collect data (defaults to now)
* @return int count connections
*/
public static function get_course_connections_count($course_code, $session_id = 0, $start = 0, $stop = null)
public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
{
if ($start < 0) {
$start = 0;
@ -1524,15 +1526,15 @@ class Tracking
$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$count = 0;
$tbl_track_e_course_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = "SELECT count(*) as count_connections
FROM $tbl_track_e_course_access
WHERE
course_code = '$course_code' AND
c_id = '$courseId' AND
session_id = $session_id
$month_filter";
$rs = Database::query($sql);
@ -1604,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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_exercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
// Compose a filter based on optional exercise given
$condition_quiz = "";
@ -1754,7 +1756,7 @@ class Tracking
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercices AS ex
WHERE ex.exe_cours_id = '$course_code'
@ -1795,7 +1797,7 @@ class Tracking
if (empty($exercise_list)) {
return '0%';
}
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$exercise_list = array_keys($exercise_list);
$exercise_list = array_map('intval', $exercise_list);
@ -1822,11 +1824,11 @@ class Tracking
/**
* @param array $exercise_list
* @param int $user_id
* @param string $course_code
* @param int $courseId
* @param int $session_id
* @return string
*/
public static function get_exercise_student_average_best_attempt($exercise_list, $user_id, $course_code, $session_id)
public static function get_exercise_student_average_best_attempt($exercise_list, $user_id, $courseId, $session_id)
{
$result = 0;
if (!empty($exercise_list)) {
@ -1835,7 +1837,7 @@ class Tracking
$best_attempt = Event::get_best_attempt_exercise_results_per_user(
$user_id,
$exercise_id,
$course_code,
$courseId,
$session_id
);
@ -2121,8 +2123,8 @@ class Tracking
}
if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$course = api_get_course_info($course_code);
@ -3034,7 +3036,6 @@ class Tracking
* @param int Session id (optional), if param $session_id is null(default) return count of assignments including sessions, 0 = session is not filtered
* @return int Number of documents
*/
public static function count_student_uploaded_documents($student_id, $course_code, $session_id = null)
{
// get the information of the course
@ -3067,7 +3068,7 @@ class Tracking
ip.tool = 'document'
$condition_user $condition_session ";
$rs = Database::query($sql);
$row = Database::fetch_row($rs);
$row = Database::fetch_array($rs, 'ASSOC');
return $row['count'];
}
return null;
@ -3294,10 +3295,14 @@ class Tracking
$last_days = intval($last_days);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$tbl_stats_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = "SELECT count(*) FROM $tbl_stats_access WHERE DATE_SUB(NOW(),INTERVAL $last_days DAY) <= access_date
AND access_cours_code = '$course_code' AND access_tool='".TOOL_CHAT."' AND access_session_id='$session_id' ";
$sql = "SELECT count(*) FROM $tbl_stats_access
WHERE
DATE_SUB(NOW(),INTERVAL $last_days DAY) <= access_date AND
c_id = '$course_id' AND
access_tool='".TOOL_CHAT."' AND
access_session_id='$session_id' ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$row = Database::fetch_row($result);
@ -3315,21 +3320,21 @@ class Tracking
* @param int Session id (optional)
* @return string datetime formatted without day (e.g: February 23, 2010 10:20:50 )
*/
public static function chat_last_connection($student_id, $course_code, $session_id = 0)
public static function chat_last_connection($student_id, $courseId, $session_id = 0)
{
$student_id = intval($student_id);
$course_code= Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$date_time = '';
// table definition
$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$tbl_stats_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$sql = "SELECT access_date
FROM $tbl_stats_access
WHERE
access_tool='".TOOL_CHAT."' AND
access_user_id='$student_id' AND
access_cours_code = '$course_code' AND
c_id = $courseId AND
access_session_id = '$session_id'
ORDER BY access_date DESC limit 1";
$rs = Database::query($sql);
@ -3343,26 +3348,24 @@ class Tracking
/**
* Get count student's visited links
* @param int Student id
* @param string Course code
* @param int $courseId
* @param int Session id (optional)
* @return int count of visited links
*/
public static function count_student_visited_links($student_id, $course_code, $session_id = 0)
public static function count_student_visited_links($student_id, $courseId, $session_id = 0)
{
// protect datas
$student_id = intval($student_id);
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
// table definition
$tbl_stats_links = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$tbl_stats_links = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$sql = 'SELECT 1
FROM '.$tbl_stats_links.'
WHERE
links_user_id= '.$student_id.' AND
links_cours_id = "'.$course_code.'" AND
c_id = "'.$courseId.'" AND
links_session_id = '.$session_id.' ';
$rs = Database::query($sql);
@ -3372,24 +3375,23 @@ class Tracking
/**
* Get count student downloaded documents
* @param int Student id
* @param string Course code
* @param int $courseId
* @param int Session id (optional)
* @return int Count downloaded documents
*/
public static function count_student_downloaded_documents($student_id, $course_code, $session_id = 0)
public static function count_student_downloaded_documents($student_id, $courseId, $session_id = 0)
{
// protect datas
$student_id = intval($student_id);
$course_code = Database::escape_string($course_code);
$course_code = intval($courseId);
$session_id = intval($session_id);
// table definition
$tbl_stats_documents = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$tbl_stats_documents = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$sql = 'SELECT 1
FROM ' . $tbl_stats_documents . '
WHERE down_user_id = '.$student_id.'
AND down_cours_id = "'.$course_code.'"
AND c_id = "'.$courseId.'"
AND down_session_id = '.$session_id.' ';
$rs = Database::query($sql);
return Database::num_rows($rs);
@ -3420,37 +3422,44 @@ class Tracking
}
/**
* Get inactives students in course
* @param string Course code
* Get inactive students in course
* @param int $courseId
* @param string Since login course date (optional, default = 'never')
* @param int Session id (optional)
* @return array Inactives users
*/
public static function get_inactives_students_in_course($course_code, $since = 'never', $session_id=0)
{
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$table_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tableCourse = Database :: get_main_table(TABLE_MAIN_COURSE);
$inner = '';
if ($session_id!=0) {
$inner = ' INNER JOIN '.$tbl_session_course_user.' session_course_user
ON stats_login.course_code = session_course_user.course_code
ON c.code = session_course_user.course_code
AND session_course_user.id_session = '.intval($session_id).'
AND session_course_user.id_user = stats_login.user_id ';
}
$sql = 'SELECT user_id, MAX(login_course_date) max_date FROM'.$tbl_track_login.' stats_login'.$inner.'
$sql = 'SELECT user_id, MAX(login_course_date) max_date
FROM '.$tbl_track_login.' stats_login '.$inner.'
INNER JOIN '.$tableCourse.' c
ON (c.id = stats_login.c_id)
GROUP BY user_id
HAVING DATE_SUB( NOW(), INTERVAL '.$since.' DAY) > max_date ';
//HAVING DATE_ADD(max_date, INTERVAL '.$since.' DAY) < NOW() ';
if ($since == 'never') {
$sql = 'SELECT course_user.user_id FROM '.$table_course_rel_user.' course_user
$sql = 'SELECT course_user.user_id
FROM '.$table_course_rel_user.' course_user
LEFT JOIN '. $tbl_track_login.' stats_login
ON course_user.user_id = stats_login.user_id AND relation_type<>'.COURSE_RELATION_TYPE_RRHH.' '.
$inner.'
WHERE course_user.course_code = \''.Database::escape_string($course_code).'\'
AND stats_login.login_course_date IS NULL
GROUP BY course_user.user_id';
ON course_user.user_id = stats_login.user_id AND
relation_type<>'.COURSE_RELATION_TYPE_RRHH.'
INNER JOIN '.$tableCourse.' c
ON (c.id = stats_login.c_id)
'.$inner.'
WHERE course_user.course_code = \''.Database::escape_string($course_code).'\'
AND stats_login.login_course_date IS NULL
GROUP BY course_user.user_id';
}
$rs = Database::query($sql);
$inactive_users = array();
@ -3463,21 +3472,23 @@ class Tracking
/**
* Get count login per student
* @param int Student id
* @param string Course code
* @param int $courseId
* @param int Session id (optional)
* @return int count login
*/
public static function count_login_per_student($student_id, $course_code, $session_id = 0)
public static function count_login_per_student($student_id, $courseId, $session_id = 0)
{
$student_id = intval($student_id);
$course_code = Database::escape_string($course_code);
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_course_rel_user = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$tbl_course_rel_user = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT '.$student_id.'
FROM ' . $tbl_course_rel_user . '
WHERE access_user_id=' . $student_id . '
AND access_cours_code="' . $course_code . '" AND access_session_id = "'.$session_id.'" ';
WHERE
access_user_id=' . $student_id . ' AND
c_id="' . $courseId . '" AND
access_session_id = "'.$session_id.'" ';
$rs = Database::query($sql);
$nb_login = Database::num_rows($rs);
@ -3626,16 +3637,15 @@ class Tracking
/**
* get count clicks about tools most used by course
* @param string Course code
* @param int $courseId
* @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered
* @return array tools data
*/
public static function get_tools_most_used_by_course($course_code, $session_id = null)
public static function get_tools_most_used_by_course($courseId, $session_id = null)
{
//protect data
$course_code = Database::escape_string($course_code);
$course_code = intval($courseId);
$data = array();
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
@ -3646,7 +3656,7 @@ class Tracking
WHERE
access_tool IS NOT NULL AND
access_tool != '' AND
access_cours_code = '$course_code'
c_id = '$courseId'
$condition_session
GROUP BY access_tool
ORDER BY count_access_tool DESC
@ -3676,36 +3686,36 @@ class Tracking
$course = api_get_course_info_by_id($courseId);
$tables = array(
TABLE_STATISTIC_TRACK_E_LASTACCESS => array(
'course' => 'access_cours_code',
'course' => 'c_id',
'session' => 'access_session_id',
'user' => 'access_user_id',
'start_date'=> 'access_date',
),
),
TABLE_STATISTIC_TRACK_E_ACCESS => array(
'course' => 'access_cours_code',
'course' => 'c_id',
'session' => 'access_session_id',
'user' => 'access_user_id',
'start_date'=> 'access_date',
),
),
#TABLE_STATISTIC_TRACK_E_LOGIN, array(,, 'login_date', 'logout_date');
TABLE_STATISTIC_TRACK_E_DOWNLOADS => array(
'course' => 'down_cours_id',
'course' => 'c_id',
'session' => 'down_session_id',
'user' => 'down_user_id',
'start_date'=> 'down_date',
),
TABLE_STATISTIC_TRACK_E_LINKS => array(
'course' => 'links_cours_id',
'course' => 'c_id',
'session' => 'links_session_id',
'user' => 'links_user_id',
'start_date'=> 'links_date',
),
),
TABLE_STATISTIC_TRACK_E_ONLINE => array(
'course' => 'course',
'course' => 'c_id',
'session' => 'session_id',
'user' => 'login_user_id',
'start_date'=> 'login_date',
),
),
#TABLE_STATISTIC_TRACK_E_HOTPOTATOES,
/*TABLE_STATISTIC_TRACK_E_COURSE_ACCESS => array(
'course' => 'course_code',
@ -3715,29 +3725,29 @@ class Tracking
'end_date' => 'logout_course_date',
),*/
TABLE_STATISTIC_TRACK_E_EXERCICES => array(
'course' => 'exe_cours_id',
'course' => 'c_id',
'session' => 'session_id',
'user' => 'exe_user_id',
'start_date'=> 'exe_date',
),
),
TABLE_STATISTIC_TRACK_E_ATTEMPT => array(
'course' => 'course_code',
'course' => 'c_id',
'session' => 'session_id',
'user' => 'user_id',
'start_date'=> 'tms',
),
),
#TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING,
#TABLE_STATISTIC_TRACK_E_DEFAULT,
TABLE_STATISTIC_TRACK_E_UPLOADS => array(
'course' => 'upload_cours_id',
'course' => 'c_id',
'session' => 'upload_session_id',
'user' => 'upload_user_id',
'start_date'=> 'upload_date',
),
),
#TABLE_STATISTIC_TRACK_E_HOTSPOT,
#TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY,
#TABLE_STATISTIC_TRACK_E_OPEN,
);
);
$error_sql = '';
foreach ($tables as $tableName => $fields) {
@ -3771,7 +3781,7 @@ class Tracking
$fields['user'], //user field
$tableName, //FROM
$fields['course'], //course condition
$course['code'], //course condition
$course['real_id'], //course condition
$fields['user'], //user condition
$userId, //user condition
$fields['user'] //GROUP BY
@ -3801,7 +3811,7 @@ class Tracking
$course_code = Database::escape_string($course_code);
$data = array();
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
@ -3839,7 +3849,7 @@ class Tracking
$data = array();
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_LINKS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
$condition_session = '';
@ -3991,9 +4001,12 @@ class Tracking
</tr>';
foreach ($courses as $course_code => $course_title) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$total_time_login = Tracking :: get_time_spent_on_the_course(
$user_id,
$course_code
$courseId
);
$time = api_time_to_hms($total_time_login);
$progress = Tracking :: get_avg_student_progress(
@ -4007,7 +4020,7 @@ class Tracking
);
$last_connection = Tracking :: get_last_connection_date_on_the_course(
$user_id,
$course_code
$courseId
);
if (is_null($progress)) {
@ -4094,18 +4107,19 @@ class Tracking
$best_average = intval(
ExerciseLib::get_best_average_score_by_exercise(
$exercise_data['id'],
$course_data['code'],
$course_data['id'],
$my_session_id,
$user_count
)
);
$exercise_graph_list[] = $best_average;
$all_exercise_graph_list[] = $best_average;
$exercise_graph_list[] = $best_average;
$all_exercise_graph_list[] = $best_average;
$user_result_data = ExerciseLib::get_best_attempt_by_user(
api_get_user_id(),
$exercise_data['id'],
$course_data['code'],
$course_data['real_id'],
$my_session_id
);
@ -4182,25 +4196,29 @@ class Tracking
$all_exercises = 0;
$all_unanswered_exercises_by_user = 0;
$all_average = 0;
$stats_array = array();
foreach($course_list as $course_data) {
foreach ($course_list as $course_data) {
//All exercises in the course @todo change for a real count
$exercises = ExerciseLib::get_all_exercises($course_data, $my_session_id);
$exercises = ExerciseLib::get_all_exercises($course_data, $my_session_id);
$count_exercises = 0;
if (is_array($exercises) && !empty($exercises)) {
$count_exercises = count($exercises);
$count_exercises = count($exercises);
}
//Count of user results
//$done_exercises = Event::get_count_exercises_attempted_by_course($course_data['code'], $my_session_id);
$done_exercises = null;
// Count of user results
$done_exercises = null;
$courseInfo = api_get_course_info($course_data['code']);
$answered_exercises = 0;
if (!empty($exercises)) {
foreach($exercises as $exercise_item) {
$attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_data['code'], $my_session_id);
foreach ($exercises as $exercise_item) {
$attempts = Event::count_exercise_attempts_by_user(
api_get_user_id(),
$exercise_item['id'],
$courseInfo['real_id'],
$my_session_id
);
if ($attempts > 1) {
$answered_exercises++;
}
@ -4208,14 +4226,10 @@ class Tracking
}
// Average
$average = ExerciseLib::get_average_score_by_course($course_data['code'], $my_session_id);
$average = ExerciseLib::get_average_score_by_course($courseInfo['real_id'], $my_session_id);
$all_exercises += $count_exercises;
$all_unanswered_exercises_by_user += $count_exercises - $answered_exercises;
//$all_done_exercise += $done_exercises;
$all_average += $average;
//$stats_array[$course_data['code']] = array('exercises'=>$count_exercises, 'unanswered_exercises_by_user'=>$answered_exercises,'done_exercises'=>$done_exercises, 'average'=>$average);
}
$all_average = $all_average / count($course_list);
@ -4272,14 +4286,16 @@ class Tracking
</tr>';
foreach ($course_list as $course_data) {
$course_code = $course_data['code'];
$course_title = $course_data['title'];
$course_code = $course_data['code'];
$course_title = $course_data['title'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
//All exercises in the course @todo change for a real count
$exercises = ExerciseLib::get_all_exercises($course_data, $session_id_from_get);
// All exercises in the course @todo change for a real count
$exercises = ExerciseLib::get_all_exercises($course_data, $session_id_from_get);
$count_exercises = 0;
if (!empty($exercises)) {
$count_exercises = count($exercises);
$count_exercises = count($exercises);
}
//Count of user results
//$done_exercises = get_best_exercise_results_by_course($course_code, $session_id_from_get);
@ -4288,7 +4304,12 @@ class Tracking
//$done_exercises = Event::get_count_exercises_attempted_by_course($course_code, $session_id_from_get);
$answered_exercises = 0;
foreach($exercises as $exercise_item) {
$attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_code, $session_id_from_get);
$attempts = Event::count_exercise_attempts_by_user(
api_get_user_id(),
$exercise_item['id'],
$courseId,
$session_id_from_get
);
if ($attempts > 1) {
$answered_exercises++;
}
@ -4297,23 +4318,23 @@ class Tracking
$unanswered_exercises = $count_exercises - $answered_exercises;
// Average
$average = ExerciseLib::get_average_score_by_course($course_code, $session_id_from_get);
$my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $course_code, $session_id_from_get);
$average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
$my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
$stats_array[$course_code] = array(
'exercises' => $count_exercises,
'unanswered_exercises_by_user' => $unanswered_exercises,
'done_exercises' => $done_exercises,
'average' => $average,
'my_average' => $my_average
'exercises' => $count_exercises,
'unanswered_exercises_by_user' => $unanswered_exercises,
'done_exercises' => $done_exercises,
'average' => $average,
'my_average' => $my_average
);
$weighting = 0;
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $course_code, $session_id_from_get);
$progress = Tracking :: get_avg_student_progress($user_id, $course_code,array(), $session_id_from_get);
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $course_code, $session_id_from_get);
$time = api_time_to_hms($total_time_login);
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array(), $session_id_from_get);
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $courseId, $session_id_from_get);
$progress = Tracking :: get_avg_student_progress($user_id, $course_code,array(), $session_id_from_get);
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $courseId, $session_id_from_get);
$time = api_time_to_hms($total_time_login);
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array(), $session_id_from_get);
$courseCodeFromGet = isset($_GET['course']) ? $_GET['course'] : null;
if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
@ -4362,12 +4383,9 @@ class Tracking
$html .= '</tr>';
}
$html .= '</table>';
if (!empty($session_graph[$session_id_from_get])) {
//$html .= Display::div($session_graph[$session_id_from_get], array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
}
}
}
return $html;
}
@ -4383,12 +4401,11 @@ class Tracking
$html = '';
if (isset($course_code)) {
$user_id = intval($user_id);
$session_id = intval($session_id);
$course = Database::escape_string($course_code);
$course_info = CourseManager::get_course_information($course);
//$course_id = $course_info['real_id'];
$user_id = intval($user_id);
$session_id = intval($session_id);
$course = Database::escape_string($course_code);
$course_info = CourseManager::get_course_information($course);
$course_id = $course_info['real_id'];
//$session_name = api_get_session_name($session_id);
$html .= Display::page_subheader($course_info['title']);
@ -4435,8 +4452,13 @@ class Tracking
$score = $weighting = $attempts = 0;
//Getting count of attempts by user
$attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
// Getting count of attempts by user
$attempts = Event::count_exercise_attempts_by_user(
api_get_user_id(),
$exercices['id'],
$course_info['real_id'],
$session_id
);
$html .= '<tr class="row_even">';
$url = api_get_path(WEB_CODE_PATH)."exercice/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
@ -4450,19 +4472,39 @@ class Tracking
//Exercise configuration show results or show only score
if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
//For graphics
$best_exercise_stats = Event::get_best_exercise_results_by_user($exercices['id'], $course_info['code'], $session_id);
$to_graph_exercise_result[$exercices['id']] = array('title'=>$exercices['title'], 'data'=>$best_exercise_stats);
$best_exercise_stats = Event::get_best_exercise_results_by_user(
$exercices['id'],
$course_info['real_id'],
$session_id
);
$to_graph_exercise_result[$exercices['id']] = array(
'title' => $exercices['title'],
'data' => $best_exercise_stats
);
$latest_attempt_url = '';
$best_score = $position = $percentage_score_result = '-';
$graph = $normal_graph = null;
//Getting best results
$best_score_data = ExerciseLib::get_best_attempt_in_course($exercices['id'], $course_info['code'], $session_id);
$best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
// Getting best results
$best_score_data = ExerciseLib::get_best_attempt_in_course(
$exercices['id'],
$course_info['real_id'],
$session_id
);
$best_score = ExerciseLib::show_score(
$best_score_data['exe_result'],
$best_score_data['exe_weighting']
);
if ($attempts > 0) {
$exercise_stat = ExerciseLib::get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
$exercise_stat = ExerciseLib::get_best_attempt_by_user(
api_get_user_id(),
$exercices['id'],
$course_info['real_id'],
$session_id
);
if (!empty($exercise_stat)) {
//Always getting the BEST attempt
@ -5147,8 +5189,8 @@ 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_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$ttrack_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$ttrack_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$ttrack_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sessions = array();
$courses = array();
@ -5972,11 +6014,14 @@ class TrackingCourseLog
}
while ($user = Database::fetch_array($res, 'ASSOC')) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$user['official_code'] = $user['col0'];
$user['lastname'] = $user['col1'];
$user['firstname'] = $user['col2'];
$user['username'] = $user['col3'];
$user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, $session_id));
$user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $session_id));
$avg_student_score = Tracking::get_avg_student_score(
$user['user_id'],
@ -6008,11 +6053,11 @@ class TrackingCourseLog
$total_user_exercise = Tracking::get_exercise_student_average_best_attempt(
$total_exercises,
$user['user_id'],
$course_code,
$courseId,
$session_id
);
$user['exercise_average_best_attempt'] = $total_user_exercise;
$user['exercise_average_best_attempt'] = $total_user_exercise;
if (is_numeric($avg_student_score)) {
$user['student_score'] = $avg_student_score.'%';
@ -6020,10 +6065,10 @@ class TrackingCourseLog
$user['student_score'] = $avg_student_score;
}
$user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id);
$user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
$user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $course_code, $session_id);
$user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $course_code, $session_id);
$user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id);
$user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
$user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id);
$user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseId, $session_id);
// we need to display an additional profile field
$user['additional'] = '';
@ -6102,9 +6147,12 @@ class TrackingCourseLog
*/
class TrackingUserLog
{
/**
* Displays the number of logins every month for a specific user in a specific course.
* @param $view
* @param int $user_id
* @param int $course_id
* @param int $session_id
*/
public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
{
@ -6132,7 +6180,7 @@ class TrackingUserLog
$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
FROM $track_access_table
WHERE access_user_id = '$user_id'
AND access_cours_code = '$course_id'
AND c_id = '$course_id'
AND access_session_id = '$session_id'
GROUP BY YEAR(access_date),MONTH(access_date)
ORDER BY YEAR(access_date),MONTH(access_date) ASC";
@ -6299,11 +6347,11 @@ class TrackingUserLog
</tr>";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
$sql = "SELECT u.upload_date, w.title, w.author,w.url
FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
WHERE u.upload_work_id = w.id
AND u.upload_user_id = '".intval($user_id)."'
AND u.upload_cours_id = '".Database::escape_string($course_id)."'
ORDER BY u.upload_date DESC";
FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
WHERE u.upload_work_id = w.id
AND u.upload_user_id = '".intval($user_id)."'
AND u.c_id = '".intval($course_id)."'
ORDER BY u.upload_date DESC";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = getManyResultsXCol($sql,4);
echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
@ -6420,7 +6468,7 @@ class TrackingUserLog
$course_id = Database::escape_string($course_id);
$session_id = intval($session_id);
$downloads_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
if(substr($view,4,1) == '1') {
$new_view = substr_replace($view,'0',4,1);
echo "
@ -6506,32 +6554,35 @@ class TrackingUserLog
*/
class TrackingUserLogCSV
{
/**
* Displays the number of logins every month for a specific user in a specific course.
* @param $view
* @param int $user_id
* @param int $course_id
* @param int $session_id
* @return array
*/
public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
{
$MonthsLong = $GLOBALS['MonthsLong'];
$track_access_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
// protected data
$user_id = intval($user_id);
$session_id = intval($session_id);
$course_id = Database::escape_string($course_id);
$course_id = intval($course_id);
$tempView = $view;
if(substr($view,0,1) == '1')
{
if (substr($view,0,1) == '1') {
$new_view = substr_replace($view,'0',0,1);
$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
FROM $track_access_table
WHERE access_user_id = '$user_id'
AND access_cours_code = '".$course_id."'
AND access_session_id = '$session_id'
GROUP BY YEAR(access_date),MONTH(access_date)
ORDER BY YEAR(access_date),MONTH(access_date) ASC";
FROM $track_access_table
WHERE access_user_id = '$user_id'
AND c_id = '".$course_id."'
AND access_session_id = '$session_id'
GROUP BY YEAR(access_date),MONTH(access_date)
ORDER BY YEAR(access_date),MONTH(access_date) ASC";
//$results = getManyResults2Col($sql);
$results = getManyResults3Col($sql);
$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
@ -6626,13 +6677,16 @@ class TrackingUserLogCSV
public function display_student_publications_tracking_info($view, $user_id, $course_id)
{
global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK, $dateTimeFormatLong, $_course;
$user_id = intval($user_id);
$course_id = intval($course_id);
if (substr($view,2,1) == '1') {
$new_view = substr_replace($view,'0',2,1);
$sql = "SELECT u.upload_date, w.title, w.author, w.url
FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
WHERE u.upload_work_id = w.id
AND u.upload_user_id = '$user_id'
AND u.upload_cours_id = '$course_id'
WHERE
u.upload_work_id = w.id AND
u.upload_user_id = '$user_id' AND
u.c_id = '$course_id'
ORDER BY u.upload_date DESC";
$results = getManyResultsXCol($sql,4);
@ -6650,8 +6704,6 @@ class TrackingUserLogCSV
} else {
$line= get_lang('NoResult');
}
} else {
$new_view = substr_replace($view,'1',2,1);
}
return array($title_line, $line);
}
@ -6703,7 +6755,7 @@ class TrackingUserLogCSV
$course_id = Database::escape_string($course_id);
$session_id = intval($session_id);
$downloads_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
if (substr($view,4,1) == '1') {
$new_view = substr_replace($view,'0',4,1);

@ -5073,22 +5073,22 @@ EOF;
/**
* Calc the expended time (in seconds) by a user in a course
* @param int $userId The user id
* @param string $courseCode The course id
* @param int $courseId The course id
* @param int $sessionId Optional. The session id
* @param string $from Optional. From date
* @param string $until Optional. Until date
* @return int The time
*/
public static function getExpendedTimeInCourses($userId, $courseCode, $sessionId = 0, $from = '', $until = '')
public static function getExpendedTimeInCourses($userId, $courseId, $sessionId = 0, $from = '', $until = '')
{
$userId = intval($userId);
$sessionId = intval($sessionId);
$trackCourseAccessTable = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$trackCourseAccessTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$whereConditions = array(
'user_id = ? ' => $userId,
"AND course_code = '?' " => $courseCode,
"AND c_i = '?' " => $courseId,
'AND session_id = ? ' => $sessionId
);

@ -837,7 +837,11 @@ if (isset($cidReset) && $cidReset) {
if (!isset($_SESSION['login_as'])) {
//Course login
if (isset($_user['user_id'])) {
Event::event_course_login($_course['code'], $_user['user_id'], api_get_session_id());
Event::event_course_login(
api_get_course_int_id(),
api_get_user_id(),
api_get_session_id()
);
}
}
} else {
@ -954,10 +958,11 @@ if (isset($cidReset) && $cidReset) {
//We select the last record for the current course in the course tracking table
//But only if the login date is < than now + max_life_time
$sql = "SELECT course_access_id FROM $course_tracking_table
WHERE user_id = ".intval($_user ['user_id'])." AND
course_code = '$course_code' AND
session_id = ".api_get_session_id()." AND
login_course_date > '$time' - INTERVAL $session_lifetime SECOND
WHERE
user_id = ".intval($_user['user_id'])." AND
c_id = ".$_course['real_id']." AND
session_id = ".api_get_session_id()." AND
login_course_date > '$time' - INTERVAL $session_lifetime SECOND
ORDER BY login_course_date DESC LIMIT 0,1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -967,8 +972,8 @@ if (isset($cidReset) && $cidReset) {
WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
Database::query($sql);
} else {
$sql="INSERT INTO $course_tracking_table (course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('".$course_code."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
$sql="INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('".$_course['real_id']."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
Database::query($sql);
}
}

@ -884,7 +884,7 @@ VALUES
('tool_visible_by_default_at_creation','forums','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Forums', 1),
('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),
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.8','DatabaseVersion','', NULL, NULL, 0);
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.9','DatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */;
@ -3018,9 +3018,9 @@ ALTER TABLE gradebook_category ADD COLUMN grade_model_id INT DEFAULT 0;
DROP TABLE IF EXISTS course_type;
CREATE TABLE course_type (
id int unsigned not null auto_increment primary key,
name varchar(50) not null,
translation_var char(40) default 'UndefinedCourseTypeLabel',
description TEXT default '',
name varchar(50) not null,
translation_var char(40) default 'UndefinedCourseTypeLabel',
description TEXT default '',
props text default ''
);

@ -55,10 +55,12 @@ CREATE TABLE track_e_access (
access_user_id int unsigned default NULL,
access_date datetime NOT NULL default '0000-00-00 00:00:00',
access_cours_code varchar(40) NOT NULL default '',
c_id int not null,
access_tool varchar(30) default NULL,
access_session_id int NOT NULL default 0,
PRIMARY KEY (access_id),
KEY access_user_id (access_user_id),
KEY access_c_id (c_id),
KEY access_cours_code (access_cours_code)
);
@ -68,11 +70,13 @@ CREATE TABLE track_e_lastaccess (
access_user_id int unsigned default NULL,
access_date datetime NOT NULL default '0000-00-00 00:00:00',
access_cours_code varchar(40) NOT NULL,
c_id int not null,
access_tool varchar(30) default NULL,
access_session_id int unsigned default NULL,
PRIMARY KEY (access_id),
KEY access_user_id (access_user_id),
KEY access_cours_code (access_cours_code),
KEY access_c_id (c_id),
KEY access_session_id (access_session_id)
);
@ -81,6 +85,7 @@ CREATE TABLE track_e_default (
default_id int NOT NULL auto_increment,
default_user_id int unsigned NOT NULL default 0,
default_cours_code varchar(40) NOT NULL default '',
c_id int not null,
default_date datetime NOT NULL default '0000-00-00 00:00:00',
default_event_type varchar(20) NOT NULL default '',
default_value_type varchar(20) NOT NULL default '',
@ -95,6 +100,7 @@ CREATE TABLE track_e_downloads (
down_user_id int unsigned default NULL,
down_date datetime NOT NULL default '0000-00-00 00:00:00',
down_cours_id varchar(40) NOT NULL default '',
c_id int NOT NULL,
down_doc_path varchar(255) NOT NULL default '',
down_session_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (down_id),
@ -108,6 +114,7 @@ CREATE TABLE track_e_exercices (
exe_user_id int unsigned default NULL,
exe_date datetime NOT NULL default '0000-00-00 00:00:00',
exe_cours_id varchar(40) NOT NULL default '',
c_id int NOT NULL,
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,
@ -139,24 +146,25 @@ CREATE TABLE track_e_attempt (
teacher_comment text NOT NULL,
marks float(6,2) NOT NULL default 0,
course_code varchar(40) NOT NULL default '',
c_id int NOT NULL,
position int default 0,
tms datetime NOT NULL default '0000-00-00 00:00:00',
session_id INT NOT NULL DEFAULT 0,
filename VARCHAR(255) DEFAULT NULL
);
ALTER TABLE track_e_attempt ADD INDEX (exe_id);
ALTER TABLE track_e_attempt ADD INDEX (user_id);
ALTER TABLE track_e_attempt ADD INDEX (user_id);
ALTER TABLE track_e_attempt ADD INDEX (question_id);
ALTER TABLE track_e_attempt ADD INDEX (session_id);
DROP TABLE IF EXISTS track_e_attempt_recording;
CREATE TABLE track_e_attempt_recording (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
exe_id int unsigned NOT NULL,
question_id int unsigned NOT NULL,
marks int NOT NULL,
insert_date datetime NOT NULL default '0000-00-00 00:00:00',
author int unsigned NOT NULL,
exe_id int unsigned NOT NULL,
question_id int unsigned NOT NULL,
marks int NOT NULL,
insert_date datetime NOT NULL default '0000-00-00 00:00:00',
author int unsigned NOT NULL,
teacher_comment text NOT NULL,
session_id INT NOT NULL DEFAULT 0
);
@ -170,7 +178,8 @@ CREATE TABLE track_e_hotpotatoes (
exe_name VARCHAR( 255 ) NOT NULL ,
exe_user_id int unsigned DEFAULT NULL ,
exe_date DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL ,
exe_cours_id varchar(40) NOT NULL ,
exe_cours_id varchar(40) NOT NULL,
c_id int NOT NULL,
exe_result smallint default 0 NOT NULL ,
exe_weighting smallint default 0 NOT NULL,
KEY exe_user_id (exe_user_id),
@ -183,6 +192,7 @@ CREATE TABLE track_e_links (
links_user_id int unsigned default NULL,
links_date datetime NOT NULL default '0000-00-00 00:00:00',
links_cours_id varchar(40) NOT NULL default '' ,
c_id int NOT NULL,
links_link_id int NOT NULL default 0,
links_session_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (links_id),
@ -208,6 +218,7 @@ CREATE TABLE track_e_online (
login_date datetime NOT NULL default '0000-00-00 00:00:00',
login_ip varchar(39) NOT NULL default '',
course varchar(40) default NULL,
c_id int NOT NULL,
session_id INT NOT NULL DEFAULT 0,
access_url_id INT NOT NULL DEFAULT 1,
PRIMARY KEY (login_id),
@ -229,6 +240,7 @@ CREATE TABLE track_e_uploads (
upload_user_id int unsigned default NULL,
upload_date datetime NOT NULL default '0000-00-00 00:00:00',
upload_cours_id varchar(40) NOT NULL default '',
c_id int unsigned default NULL,
upload_work_id int NOT NULL default 0,
upload_session_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (upload_id),
@ -240,6 +252,7 @@ DROP TABLE IF EXISTS track_e_course_access;
CREATE TABLE track_e_course_access (
course_access_id int NOT NULL auto_increment,
course_code varchar(40) NOT NULL,
c_id int NOT NULL,
user_id int NOT NULL,
login_course_date datetime NOT NULL default '0000-00-00 00:00:00',
logout_course_date datetime default NULL,
@ -253,6 +266,7 @@ CREATE TABLE track_e_hotspot (
hotspot_id int NOT NULL auto_increment,
hotspot_user_id int NOT NULL,
hotspot_course_code varchar(50) NOT NULL,
c_id int unsigned default NULL,
hotspot_exe_id int NOT NULL,
hotspot_question_id int NOT NULL,
hotspot_answer_id int NOT NULL,
@ -289,21 +303,21 @@ ALTER TABLE track_e_online ADD INDEX (course);
ALTER TABLE track_e_online ADD INDEX (session_id);
ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
ALTER TABLE track_e_downloads ADD INDEX (down_session_id);
ALTER TABLE track_e_links ADD INDEX (links_session_id);
ALTER TABLE track_e_uploads ADD INDEX (upload_session_id);
ALTER TABLE track_e_downloads ADD INDEX (down_session_id);
ALTER TABLE track_e_links ADD INDEX (links_session_id);
ALTER TABLE track_e_uploads ADD INDEX (upload_session_id);
--
-- Table structure for LP custom storage API
--
DROP TABLE IF EXISTS track_stored_values;
CREATE TABLE IF NOT EXISTS track_stored_values (
id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
sco_id INT NOT NULL,
course_id CHAR(40) NOT NULL,
sv_key CHAR(64) NOT NULL,
sv_value TEXT NOT NULL
sv_value TEXT NOT NULL
);
ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
@ -324,6 +338,6 @@ ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv
DROP TABLE IF EXISTS track_e_attempt_coeff;
CREATE TABLE track_e_attempt_coeff (
id int unsigned not null auto_increment primary key,
attempt_id INT NOT NULL,
attempt_id INT NOT NULL,
marks_coeff float(6,2)
);
);

@ -36,8 +36,22 @@ ALTER TABLE skill ADD COLUMN criteria text DEFAULT '';
ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0;
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_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;
ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL;
ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL;
ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.8' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.9' WHERE variable = 'chamilo_database_version';
-- xxCOURSExx

@ -40,7 +40,7 @@ if (defined('SYSTEM_INSTALLATION')) {
}
$_configuration['db_glue'] = get_config_param('dbGlu');
if ($singleDbForm) {
$_configuration['table_prefix'] = get_config_param('courseTablePrefix');
$_configuration['main_database'] = get_config_param('mainDbName');
@ -94,16 +94,33 @@ if (defined('SYSTEM_INSTALLATION')) {
}
if (INSTALL_TYPE_UPDATE == 'update') {
/*
$sql = "SELECT selected_value FROM $dbNameForm.settings_current WHERE variable='use_session_mode' ";
// Updating track tables with c_id
$res = iDatabase::query("SELECT id, code FROM $dbNameForm.course");
$result = iDatabase::query($sql);
$result = Database::fetch_array($result);
$session_mode = $result['selected_value'];
if ($session_mode == 'true')
{ ... }
*/
$courses = Database::store_result($result);
foreach ($courses as $course) {
$courseId = $course['id'];
$courseCode = $course['code'];
$fields = array(
'track_e_access' => 'access_cours_code',
'track_e_default' => 'default_cours_code',
'track_e_lastaccess' => 'access_cours_code',
'track_e_downloads' => 'down_cours_id',
'track_e_hotpotatoes' => 'exe_cours_id',
'track_e_links' => 'links_cours_id',
'track_e_course_access' => 'course_code',
'track_e_online' => 'course',
'track_e_attempt' => 'course_code',
'track_e_exercices' => 'exe_cours_id'
);
foreach ($fields as $table => $key) {
$sql = "UPDATE $dbNameForm.$table SET c_id = '$courseId'
WHERE $key = '$courseCode'";
iDatabase::query($sql);
}
}
}
}
@ -111,7 +128,7 @@ if (defined('SYSTEM_INSTALLATION')) {
if ($singleDbForm) {
$prefix = get_config_param('table_prefix');
}
Log::notice("Database prefix: '$prefix'");
// Get the courses databases queries list (c_q_list)
@ -137,7 +154,7 @@ if (defined('SYSTEM_INSTALLATION')) {
die('Error while querying the courses list in update_db-1.9.0-1.10.0.inc.php');
}
$errors = array();
if (iDatabase::num_rows($res) > 0) {
$i = 0;
$list = array();
@ -145,13 +162,13 @@ if (defined('SYSTEM_INSTALLATION')) {
$list[] = $row;
$i++;
}
foreach ($list as $rowCourse) {
if (!$singleDbForm) { // otherwise just use the main one
iDatabase::select_db($rowCourse['db_name']);
}
Log::notice('Course db ' . $rowCourse['db_name']);
// Now use the $c_q_list
foreach ($courseQueriesList as $query) {
if ($singleDbForm) {

@ -30,7 +30,9 @@ $user_id = intval($_REQUEST['student']);
$session_id = intval($_GET['id_session']);
$type = Security::remove_XSS($_REQUEST['type']);
$course_code = Security::remove_XSS($_REQUEST['course']);
$connections = MySpace::get_connections_to_course($user_id, $course_code, $session_id);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$connections = MySpace::get_connections_to_course($user_id, $courseId, $session_id);
$quote_simple = "'";
$form = new FormValidator('myform', 'get', api_get_self(), null, array('id' => 'myform'));
@ -112,7 +114,7 @@ $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AccessDetails'));
Display :: display_header('');
$userInfo = api_get_user_info($user_id);
$result_to_print = '';
$sql_result = MySpace::get_connections_to_course($user_id, $course_code);
$sql_result = MySpace::get_connections_to_course($user_id, $courseId);
$result_to_print = convert_to_string($sql_result);
echo Display::page_header(get_lang('DetailsStudentInCourse'));
@ -130,7 +132,7 @@ $form->display();
<div id="cev_cont_stats">
<?php
if ($result_to_print != "") {
$rst = get_stats($user_id, $course_code);
$rst = get_stats($user_id, $courseId);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';

@ -253,7 +253,7 @@ function get_courses($from, $limit, $column, $direction)
// tracking data
$avgProgressInCourse = Tracking :: get_avg_student_progress($userIdList, $courseCode, array(), $sessionId);
$avgScoreInCourse = Tracking :: get_avg_student_score($userIdList, $courseCode, array(), $sessionId);
$avgTimeSpentInCourse = Tracking :: get_time_spent_on_the_course($userIdList, $courseCode, $sessionId);
$avgTimeSpentInCourse = Tracking :: get_time_spent_on_the_course($userIdList, $courseInfo['real_id'], $sessionId);
$messagesInCourse = Tracking :: count_student_messages($userIdList, $courseCode, $sessionId);
$assignmentsInCourse = Tracking :: count_student_assignments($userIdList, $courseCode, $sessionId);
$avgTimeSpentInCourse = api_time_to_hms($avgTimeSpentInCourse / $countStudents);

@ -67,14 +67,7 @@ if (!empty($my_courses)) {
$t_lpi = Database :: get_course_table(TABLE_LP_ITEM);
$t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
//No needed
/*$nb_assignments = Tracking::count_student_assignments($students, $course_code, $session_id);
$messages = Tracking::count_student_messages($students, $course_code, $session_id);
$links = Tracking::count_student_visited_links($students, $course_code, $session_id);
$chat_last_connection = Tracking::chat_last_connection($students, $course_code, $session_id);
$documents = Tracking::count_student_downloaded_documents($students, $course_code, $session_id);*/
$total_tools_list = Tracking::get_tools_most_used_by_course($course_code, $session_id);
$total_tools_list = Tracking::get_tools_most_used_by_course($course_id, $session_id);
$total_tools = 0;
foreach($total_tools_list as $tool) {
@ -94,8 +87,6 @@ if (!empty($my_courses)) {
}
$array[$i]['course_name'] = $course['title'];
$count_students_accessing = 0;
$count_students_complete_all_activities = 0;
$count_students_complete_all_activities_at_50 = 0;
@ -116,7 +107,7 @@ if (!empty($my_courses)) {
}
$total_average_progress +=$avg_progress_in_course;
$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_code, $session_id);
$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
$total_time_spent += $time_spent;
if (!empty($time_spent)) {
$count_students_accessing++;
@ -146,7 +137,9 @@ if (!empty($my_courses)) {
//registering the number of each category of
//items in learning path
$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi WHERE c_id = $course_id AND lpi.lp_id = $lp_id ORDER BY item_type";
$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
WHERE c_id = $course_id AND lpi.lp_id = $lp_id
ORDER BY item_type";
$res_lpi = Database::query($sql_lpi);
while ($row_lpi = Database::fetch_array($res_lpi)) {
switch($row_lpi['item_type']) {

@ -385,11 +385,12 @@ if (!empty($student_id)) {
$avg_student_progress = round($avg_student_progress, 2);
// time spent on the course
$courseInfo = api_get_course_info($course_code);
$time_spent_on_the_course = api_time_to_hms(
Tracking:: get_time_spent_on_the_course(
$user_info['user_id'],
$course_code,
$courseInfo['real_id'],
$session_id
)
);
@ -445,7 +446,7 @@ if (!empty($student_id)) {
$info_course = CourseManager :: get_course_information($course_code);
$coachs_name = '';
$session_name = '';
$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']);
$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $info_course['real_id']);
//get coach and session_name if there is one and if session_mode is activated
if ($session_id > 0) {
@ -668,11 +669,13 @@ if (!empty($student_id)) {
if (!empty($courses)) {
foreach ($courses as $course_code) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$course_info = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $session_id));
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
@ -1092,9 +1095,9 @@ if (!empty($student_id)) {
$csv_content[] = array ();
$nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
$messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
$links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
$chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
$documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
$links = Tracking::count_student_visited_links($student_id, $info_course['real_id'], $session_id);
$chat_last_connection = Tracking::chat_last_connection($student_id, $info_course['real_id'], $session_id);
$documents = Tracking::count_student_downloaded_documents($student_id, $info_course['real_id'], $session_id);
$uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
$csv_content[] = array(

@ -123,8 +123,10 @@ function get_users($from, $limit, $column, $direction)
$nb_courses_student = 0;
if (!empty($courses)) {
foreach ($courses as $course_code) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $course_code, $_GET['id_session']);
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
$my_average = Tracking :: get_avg_student_score($student_id, $course_code);
if (is_numeric($my_average)) {
$avg_student_score += $my_average;

@ -121,8 +121,10 @@ function get_users($from, $limit, $column, $direction)
$nb_courses_student = 0;
if (!empty($courses)) {
foreach ($courses as $course_code) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $course_code, $_GET['id_session']);
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
$my_average = Tracking :: get_avg_student_score($student_id, $course_code);
if (is_numeric($my_average)) {
$avg_student_score += $my_average;

@ -122,8 +122,11 @@ function get_users($from, $limit, $column, $direction)
$nb_courses_student = 0;
if (!empty($courses)) {
foreach ($courses as $course_code) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $course_code, $_GET['id_session']);
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
$my_average = Tracking :: get_avg_student_score($student_id, $course_code);
if (is_numeric($my_average)) {
$avg_student_score += $my_average;

@ -1,4 +1,4 @@
<?php
<?php
$reports_modules['course'] = array ();
@ -8,22 +8,22 @@ function reports_modules_course_init() {
function reports_modules_course_init_forEachCourses($course_code, $course_id, $course_db) {
global $reports_modules;
// $reports_modules_course_toolid = reports_getToolId(TOOL_QUIZ);
array_push($reports_modules['course'],
array('keys_query' =>
array_push($reports_modules['course'],
array('keys_query' =>
'select '.$course_id.' as course_id, "'.$course_code.'" as course_code',
'values_query_function' => 'reports_modules_course_val'));
'values_query_function' => 'reports_modules_course_val'));
}
function reports_modules_course_val($course, $key_id) {
return array('type'=> 'sql', 'sql' =>
return array('type'=> 'sql', 'sql' =>
'select '.$key_id.', user_id as uid, '.
'-1 as session_id, -1 as attempt, null as score, '.
'NULL as progress, '.
'(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '.
Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS).
' where course_code = '."'".$course['course_code']."'".
' where c_id = '."'".$course['real_id']."'".
' group by user_id');
}

@ -145,7 +145,7 @@ if (!empty($course_list)) {
}
}
$course_info = api_get_course_info($course_data['code']);
$course_info = api_get_course_info($course_data['code']);
$exercise_count = count(
ExerciseLib::get_all_exercises(
$course_info,
@ -160,7 +160,7 @@ if (!empty($course_list)) {
$last_date = Tracking::get_last_connection_date_on_the_course(
api_get_user_id(),
$course_data['code'],
$course_info['real_id'],
$session_id,
false
);
@ -244,6 +244,7 @@ foreach ($final_array as $session_data) {
$my_course_list = isset($session_data['data']) ? $session_data['data']: array();
if (!empty($my_course_list)) {
foreach ($my_course_list as $my_course_code=>$course_data) {
$courseInfo = api_get_course_info($my_course_code);
if (isset($course_id) && !empty($course_id)) {
if ($course_id != $course_data['id']) {
continue;
@ -253,7 +254,11 @@ foreach ($final_array as $session_data) {
if (!empty($course_data['exercises'])) {
// Exercises
foreach ($course_data['exercises'] as $my_exercise_id => $exercise_data) {
$best_score_data = ExerciseLib::get_best_attempt_in_course($my_exercise_id, $my_course_code, $session_id);
$best_score_data = ExerciseLib::get_best_attempt_in_course(
$my_exercise_id,
$courseInfo['real_id'],
$session_id
);
$best_score = '';
if (!empty($best_score_data)) {

@ -71,6 +71,10 @@ $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || api_is_drh();
$title[0] = get_lang('StatsOfCourse') . " : " . $_course['official_code'];
$courseInfo = api_get_course_info($_course['official_code']);
$courseId = $courseInfo['real_id'];
// check if uid is prof of this group
if ($is_allowedToTrack) {
@ -95,16 +99,15 @@ if ($is_allowedToTrack) {
// BEGIN users in this course
$sql = "SELECT $TABLECOURSUSER.user_i, $table_user.lastname, $table_user.firstname
FROM $TABLECOURSUSER, $table_user
WHERE $TABLECOURSUSER.course_code = '" . $_cid . "' AND $TABLECOURSUSER.user_id = $table_user.user_id AND $TABLECOURSUSER.relation_type<>" . COURSE_RELATION_TYPE_RRHH . "
ORDER BY $table_user.lastname";
FROM $TABLECOURSUSER, $table_user
WHERE $TABLECOURSUSER.course_code = '" . $_cid . "' AND $TABLECOURSUSER.user_id = $table_user.user_id AND $TABLECOURSUSER.relation_type<>" . COURSE_RELATION_TYPE_RRHH . "
ORDER BY $table_user.lastname";
$results = getManyResults3Col($sql);
//BUGFIX: get visual code instead of real course code. Scormpaths use the visual code... (should be fixed in future versions)
$sql = "SELECT visual_code FROM $TABLECOURSE WHERE code = '" . $_cid . "'";
$_course['visual_code'] = getOneResult($sql);
if (is_array($results)) {
$line = '';
$title_line = get_lang('Name') . ";" . get_lang('FirstAccess') . ";" . get_lang('LastAccess') . ";" . get_lang('Visited') . "\n";
@ -138,12 +141,14 @@ if ($is_allowedToTrack) {
// END % visited
// BEGIN first/last access
// first access
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS_2 WHERE access_user_id = '" . $results[$j][0] . "' AND access_cours_code = '" . $_course['official_code'] . "' AND access_tool = 'learnpath' AND access_session_id = '" . api_get_session_id() . "' ORDER BY access_id ASC LIMIT 1";
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS_2
WHERE access_user_id = '" . $results[$j][0] . "' AND c_id = '" . $courseId . "' AND access_tool = 'learnpath' AND access_session_id = '" . api_get_session_id() . "'
ORDER BY access_id ASC LIMIT 1";
$first_access = getOneResult($sql);
$first_access = empty($first_access) ? "-" : date('d.m.y', strtotime($first_access));
// last access
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS WHERE access_user_id = '" . $results[$j][0] . "' AND access_cours_code = '" . $_course['official_code'] . "' AND access_tool = 'learnpath'";
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS WHERE access_user_id = '" . $results[$j][0] . "' AND c_id = '" . $courseId . "' AND access_tool = 'learnpath'";
$last_access = getOneResult($sql);
$last_access = empty($last_access) ? "-" : date('d.m.y', strtotime($last_access));
// END first/last access
@ -157,70 +162,62 @@ if ($is_allowedToTrack) {
}
}
/* Main */
$tempView = $view;
if ($view[0] == '1') {
$title[1] = $nameTools;
$tempView[0] = '0';
$sql = "SELECT count(*)
FROM $TABLECOURSUSER
WHERE course_code = '" . $_cid . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . "";
FROM $TABLECOURSUSER
WHERE course_code = '" . $_cid . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . "";
$count = getOneResult($sql);
$title_line = get_lang('CountUsers') . " ; " . $count . "\n";
}
/* Access to this course */
$tempView = $view;
if ($view[1] == '1') {
$tempView[1] = '0';
$title[1] = get_lang('ConnectionsToThisCourse');
$title_line = '';
$line = '';
//Total
$sql = "SELECT count(*)
FROM $TABLETRACK_ACCESS
WHERE access_cours_code = '" . $_cid . "'
AND access_tool IS NULL";
FROM $TABLETRACK_ACCESS
WHERE c_id = '" . $courseId . "'
AND access_tool IS NULL";
$count = getOneResult($sql);
$line .= get_lang('CountToolAccess') . " ; " . $count . "\n";
// last 31 days
$sql = "SELECT count(*)
FROM $TABLETRACK_ACCESS
WHERE access_cours_code = '$_cid'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -31 DAY))
AND access_tool IS NULL";
FROM $TABLETRACK_ACCESS
WHERE c_id = '$courseId'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -31 DAY))
AND access_tool IS NULL";
$count = getOneResult($sql);
$line .= get_lang('Last31days') . " ; " . $count . "\n";
// last 7 days
$sql = "SELECT count(*)
FROM $TABLETRACK_ACCESS
WHERE access_cours_code = '$_cid'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -7 DAY))
AND access_tool IS NULL";
FROM $TABLETRACK_ACCESS
WHERE c_id = '$courseId'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -7 DAY))
AND access_tool IS NULL";
$count = getOneResult($sql);
$line .= get_lang('Last7days') . " ; " . $count . "\n";
// today
$sql = "SELECT count(*)
FROM $TABLETRACK_ACCESS
WHERE access_cours_code = '$_cid'
AND ( access_date > CURDATE() )
AND access_tool IS NULL";
FROM $TABLETRACK_ACCESS
WHERE c_id = '$courseId'
AND ( access_date > CURDATE() )
AND access_tool IS NULL";
$count = getOneResult($sql);
$line .= get_lang('Thisday') . " ; " . $count . "\n";
}
@ -241,7 +238,7 @@ if ($is_allowedToTrack) {
$sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool )
FROM $TABLETRACK_ACCESS
WHERE access_tool IS NOT NULL
AND access_cours_code = '$_cid'
AND c_id = '$courseId'
GROUP BY access_tool";
$results = getManyResults3Col($sql);

@ -8,10 +8,6 @@
*
* @package chamilo.tracking
*/
/**
* Code
*/
// TODO: Is this file deprecated?
/*
@ -24,6 +20,8 @@ $displayType = $_REQUEST['displayType'];
$language_file = "tracking";
require_once '../inc/global.inc.php';
$courseId = api_get_course_int_id();
$interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> get_lang('ToolName'));
$nameTools = get_lang('TrafficDetails');
@ -145,31 +143,25 @@ $is_allowedToTrack = $is_courseAdmin;
</td>
</tr>
";
//**
// display information about this period
switch($period)
{
switch($period) {
// all days
case "year" :
$sql = "SELECT UNIX_TIMESTAMP( access_date )
FROM $TABLETRACK_ACCESS
WHERE YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND access_cours_code = '$_cid'
AND access_tool IS NULL ";
if($displayType == "month")
{
FROM $TABLETRACK_ACCESS
WHERE YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND c_id = '$courseId'
AND access_tool IS NULL ";
if ($displayType == "month") {
$sql .= "ORDER BY UNIX_TIMESTAMP( access_date)";
$month_array = monthTab($sql);
makeHitsTable($month_array,get_lang('PeriodMonth'));
}
elseif($displayType == "day")
{
} elseif($displayType == "day") {
$sql .= "ORDER BY DAYOFYEAR( access_date)";
$days_array = daysTab($sql);
makeHitsTable($days_array,get_lang('PeriodDay'));
}
else // by hours by default
{
} else {
// by hours by default
$sql .= "ORDER BY HOUR( access_date)";
$hours_array = hoursTab($sql);
makeHitsTable($hours_array,get_lang('PeriodHour'));
@ -178,11 +170,11 @@ $is_allowedToTrack = $is_courseAdmin;
// all days
case "month" :
$sql = "SELECT UNIX_TIMESTAMP( access_date )
FROM $TABLETRACK_ACCESS
WHERE MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND access_cours_code = '$_cid'
AND access_tool IS NULL ";
FROM $TABLETRACK_ACCESS
WHERE MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND c_id = '$courseId'
AND access_tool IS NULL ";
if($displayType == "day")
{
$sql .= "ORDER BY DAYOFYEAR( access_date)";
@ -199,13 +191,13 @@ $is_allowedToTrack = $is_courseAdmin;
// all hours
case "day" :
$sql = "SELECT UNIX_TIMESTAMP( access_date )
FROM $TABLETRACK_ACCESS
WHERE DAYOFMONTH(access_date) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) )
AND MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND access_cours_code = '$_cid'
AND access_tool IS NULL
ORDER BY HOUR( access_date )";
FROM $TABLETRACK_ACCESS
WHERE DAYOFMONTH(access_date) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) )
AND MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
AND c_id = '$courseId'
AND access_tool IS NULL
ORDER BY HOUR( access_date )";
$hours_array = hoursTab($sql,$reqdate);
makeHitsTable($hours_array,get_lang('PeriodHour'));
break;

@ -99,6 +99,7 @@ echo '</span>';
echo '</div>';
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$list = new LearnpathList(null, $course_code, $session_id);
@ -238,7 +239,7 @@ echo '<div class="report_section">
'.Display::page_subheader(Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed')).'
<table class="data_table">';
$tools_most_used = Tracking::get_tools_most_used_by_course($course_code, $session_id);
$tools_most_used = Tracking::get_tools_most_used_by_course($course_id, $session_id);
if ($export_csv) {
$temp = array(get_lang('ToolsMostUsed'), '');

@ -102,7 +102,11 @@ foreach ($course_list as $current_course ) {
$exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
// Looping Chamilo Exercises in LP
foreach ($exercise_list as $exercise) {
$exercise_stats = Event::get_all_exercise_event_from_lp($exercise['path'], $course_info['id'], $session_id);
$exercise_stats = Event::get_all_exercise_event_from_lp(
$exercise['path'],
$course_info['real_id'],
$session_id
);
// Looping Exercise Attempts
foreach ($exercise_stats as $stats) {
$attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting'];

@ -52,7 +52,8 @@ $TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
Display::display_header($nameTools, "Tracking");
include(api_get_path(LIBRARY_PATH) . "statsUtils.lib.inc.php");
$courseId = api_get_course_int_id();
// the variables for the days and the months
// Defining the shorts for the days
@ -140,91 +141,91 @@ $is_allowedToTrackEverybodyInCourse = $is_courseAdmin; // allowed to track all s
";
/* * ***** END OF MENU ******* */
switch ($period) {
case "month" :
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND access_cours_code = '" . $_cid . "'
AND MONTH(access_date) = MONTH( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$displayedDate = $MonthsLong[date("n", $reqdate) - 1] . date(" Y", $reqdate);
break;
case "week" :
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND access_cours_code = '" . $_cid . "'
AND WEEK(access_date) = WEEK( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$weeklowreqdate = ($reqdate - (86400 * date("w", $reqdate)));
$weekhighreqdate = ($reqdate + (86400 * (6 - date("w", $reqdate)) ));
$displayedDate = get_lang('From') . " " . date("d ", $weeklowreqdate) . $MonthsLong[date("n", $weeklowreqdate) - 1] . date(" Y", $weeklowreqdate)
. " " . get_lang('To') . " " . date("d ", $weekhighreqdate) . $MonthsLong[date("n", $weekhighreqdate) - 1] . date(" Y", $weekhighreqdate);
break;
}
echo "<tr><td>";
$results = getManyResults1Col($sql);
/* * * display of the displayed period ** */
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<td bgcolor='#E6E6E6'>" . $displayedDate . "</td>";
if (is_array($results)) {
for ($j = 0; $j < sizeof($results); $j++) {
$beautifulDateTime = api_convert_and_format_date($results[$j], null, date_default_timezone_get());
echo "<tr>";
echo "<td style='padding-left : 40px;' valign='top'>" . $beautifulDateTime . "</td>";
echo"</tr>";
// $limit is used to select only results between $results[$j] (current login) and next one
if ($j == ( sizeof($results) - 1 ))
$limit = date("Y-m-d H:i:s", $nextReqDate);
else
$limit = $results[$j + 1];
// select all access to tool between displayed date and next displayed date or now() if
// displayed date is the last login date
$sql = "SELECT access_tool, count(access_tool)
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND access_tool IS NOT NULL
AND access_date > '" . $results[$j] . "'
AND access_date < '" . $limit . "'
AND access_cours_code = '" . $_cid . "'
GROUP BY access_tool
ORDER BY access_tool ASC";
$results2 = getManyResults2Col($sql);
switch ($period) {
case "month" :
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND c_id = '" . $courseId . "'
AND MONTH(access_date) = MONTH( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$displayedDate = $MonthsLong[date("n", $reqdate) - 1] . date(" Y", $reqdate);
break;
case "week" :
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND c_id = '" . $courseId . "'
AND WEEK(access_date) = WEEK( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$weeklowreqdate = ($reqdate - (86400 * date("w", $reqdate)));
$weekhighreqdate = ($reqdate + (86400 * (6 - date("w", $reqdate)) ));
$displayedDate = get_lang('From') . " " . date("d ", $weeklowreqdate) . $MonthsLong[date("n", $weeklowreqdate) - 1] . date(" Y", $weeklowreqdate)
. " " . get_lang('To') . " " . date("d ", $weekhighreqdate) . $MonthsLong[date("n", $weekhighreqdate) - 1] . date(" Y", $weekhighreqdate);
break;
}
echo "<tr><td>";
$results = getManyResults1Col($sql);
/* * * display of the displayed period ** */
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<td bgcolor='#E6E6E6'>" . $displayedDate . "</td>";
if (is_array($results)) {
for ($j = 0; $j < sizeof($results); $j++) {
$beautifulDateTime = api_convert_and_format_date($results[$j], null, date_default_timezone_get());
echo "<tr>";
echo "<td style='padding-left : 40px;' valign='top'>" . $beautifulDateTime . "</td>";
echo"</tr>";
// $limit is used to select only results between $results[$j] (current login) and next one
if ($j == ( sizeof($results) - 1 ))
$limit = date("Y-m-d H:i:s", $nextReqDate);
else
$limit = $results[$j + 1];
// select all access to tool between displayed date and next displayed date or now() if
// displayed date is the last login date
$sql = "SELECT access_tool, count(access_tool)
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '$uInfo'
AND access_tool IS NOT NULL
AND access_date > '" . $results[$j] . "'
AND access_date < '" . $limit . "'
AND c_id = '" . $courseId . "'
GROUP BY access_tool
ORDER BY access_tool ASC";
$results2 = getManyResults2Col($sql);
if (is_array($results2)) {
echo "<tr><td colspan='2'>\n";
echo "<table width='50%' cellpadding='0' cellspacing='0' border='0'>\n";
for ($k = 0; $k < count($results2); $k++) {
echo "<tr>\n";
echo "<td width='70%' style='padding-left : 60px;'>" . get_lang($results2[$k][0]) . "</td>\n";
echo "<td width='30%' align='right' style='padding-right : 40px'>" . $results2[$k][1] . " " . get_lang('Visits') . "</td>\n";
echo "</tr>";
}
echo "</table>\n";
echo "</td></tr>\n";
if (is_array($results2)) {
echo "<tr><td colspan='2'>\n";
echo "<table width='50%' cellpadding='0' cellspacing='0' border='0'>\n";
for ($k = 0; $k < count($results2); $k++) {
echo "<tr>\n";
echo "<td width='70%' style='padding-left : 60px;'>" . get_lang($results2[$k][0]) . "</td>\n";
echo "<td width='30%' align='right' style='padding-right : 40px'>" . $results2[$k][1] . " " . get_lang('Visits') . "</td>\n";
echo "</tr>";
}
$previousDate = $value;
echo "</table>\n";
echo "</td></tr>\n";
}
} else {
echo "<tr>";
echo "<td colspan='2' bgcolor='#eeeeee'>" . get_lang('NoResult') . "</td>";
echo "</tr>";
$previousDate = $value;
}
echo "</table>";
echo "</td></tr>";
} else {
echo get_lang('ErrorUserNotInGroup');
echo "<tr>";
echo "<td colspan='2' bgcolor='#eeeeee'>" . get_lang('NoResult') . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
// not allowed
api_not_allowed();
echo get_lang('ErrorUserNotInGroup');
}
?>
} else {
// not allowed
api_not_allowed();
}
?>
</table>
<?php
Display::display_footer();
Display::display_footer();

@ -140,7 +140,11 @@ foreach($course_list as $current_course ) {
$attempt_result = array();
//Looping Chamilo Exercises in LP
foreach ($exercise_list as $exercise) {
$exercise_stats = Event::get_all_exercise_event_from_lp($exercise['path'], $course_info['id'], $session_id);
$exercise_stats = Event::get_all_exercise_event_from_lp(
$exercise['path'],
$course_info['real_id'],
$session_id
);
//Looping Exercise Attempts
foreach($exercise_stats as $stats) {
//$attempt_result[$exercise['id']]['users'][$stats['exe_user_id']][$stats['exe_id']] = array('exe_result' =>$stats['exe_result'],'exe_weighting' =>$stats['exe_weighting']);

@ -47,11 +47,11 @@ td {border-bottom: thin dashed gray;}
$view = preg_replace('/[^01]/','',$_REQUEST['view']);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$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);
$limitOfDisplayedLogins = 25; // number of logins to display
@ -122,21 +122,18 @@ api_display_tool_title($nameTools);
$previousDate = getOneResult($sql);
}
$sql = "SELECT access_tool, count(access_tool), access_cours_code
$sql = "SELECT access_tool, count(access_tool), c_id
FROM $TABLETRACK_ACCESS
WHERE access_user_id = '".$_user['user_id']."'".
//AND access_tool IS NOT NULL
"AND access_date > '".$value."'
AND access_date < '".$previousDate."'
GROUP BY access_tool, access_cours_code
ORDER BY access_cours_code ASC";
WHERE
access_user_id = '".$_user['user_id']."' AND
access_date > '".$value."' AND
access_date < '".$previousDate."'
GROUP BY access_tool, c_id
ORDER BY c_id ASC";
$results2 = getManyResults3Col($sql);
if (is_array($results2))
{
if (is_array($results2)) {
echo "
<tr>
<td colspan='2'>

@ -99,7 +99,7 @@ if (!empty($course_info)) {
$exercise_stats = Event::get_all_exercise_event_from_lp(
$exercise['path'],
$course_info['id'],
$course_info['real_id'],
$session_id
);

@ -51,7 +51,6 @@ Display::display_header($nameTools,"Tracking");
</h3>
<?php
include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
// the variables for the days and the months
// Defining the shorts for the days
@ -69,27 +68,22 @@ $reqdate=$_REQUEST['reqdate'];
?>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<?php
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
if(isset($_cid)) //stats for the current course
{
$courseId = api_get_course_int_id();
//stats for the current course
if(isset($_cid)) {
// to see stats of one course user must be courseAdmin of this course
$is_allowedToTrack = $is_courseAdmin;
$courseCodeEqualcidIfNeeded = "AND access_cours_code = '$_cid'";
}
else // stats for all courses
{
$courseCodeEqualcidIfNeeded = "AND c_id = '$courseId'";
} else {
// stats for all courses
// to see stats of all courses user must be platformAdmin
$is_allowedToTrack = $is_platformAdmin;
$courseCodeEqualcidIfNeeded = "";
}
if( $is_allowedToTrack)
{
if( $is_allowedToTrack) {
// list of all tools
if (!isset($tool))
{
if (!isset($tool)) {
$sql = "SELECT access_tool, count( access_tool )
FROM $TABLETRACK_ACCESS
WHERE access_tool IS NOT NULL

@ -23,6 +23,7 @@ $this_section = "session_my_space";
// variables
$user_id = api_get_user_id();
$course_id = api_get_course_id();
$courseId = api_get_course_int_id();
//YW Hack security to quick fix RolesRights bug
$is_allowed = true;
@ -80,7 +81,7 @@ $sql = "SELECT 1
AND ((date_start<=NOW()
AND date_end>=NOW())
OR (date_start='0000-00-00' AND date_end='0000-00-00'))
WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'";
WHERE id_session='".api_get_session_id()."' AND course_code='$_cid'";
//echo $sql;
$result=Database::query($sql);
if(!Database::num_rows($result)){
@ -174,17 +175,17 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
if ($is_allowedToTrackEverybodyInCourse) {
// list of users in this course
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND cu.course_code = '".Database::escape_string($_cid)."'
LIMIT $offset,$step";
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND cu.course_code = '".Database::escape_string($_cid)."'
LIMIT $offset,$step";
} else {
// list of users of this group
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '".intval($_gid)."'
LIMIT $offset,$step";
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '".intval($_gid)."'
LIMIT $offset,$step";
}
$list_users = getManyResults3Col($sql);
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0'>\n"
@ -253,13 +254,13 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
$view ='0000000';
}
//Logins
TrackingUserLog::display_login_tracking_info($view, $uInfo, $_cid);
TrackingUserLog::display_login_tracking_info($view, $uInfo, $courseId);
//Exercise results
TrackingUserLog::display_exercise_tracking_info($view, $uInfo, $_cid);
//Student publications uploaded
TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $_cid);
TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $courseId);
//Links usage
TrackingUserLog::display_links_tracking_info($view, $uInfo, $_cid);

@ -23,6 +23,7 @@ require_once '../inc/global.inc.php';
// Roles and rights system
$user_id = api_get_user_id();
$course_id = api_get_course_id();
$courseId = api_get_course_int_id();
/*
$role_id = RolesRights::get_local_user_role_id($user_id, $course_id);
@ -38,9 +39,7 @@ $is_allowed = true;
/* Libraries */
require_once api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php';
require_once api_get_path(
SYS_CODE_PATH
) . 'resourcelinker/resourcelinker.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'resourcelinker/resourcelinker.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/hotpotatoes.lib.php';
/* Header */
@ -228,7 +227,7 @@ if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
list($title_line1, $line1) = TrackingUserLogCSV::display_login_tracking_info(
$view,
$uInfo,
$_cid
$courseId
);
//Exercise results
@ -242,7 +241,7 @@ if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
list($title_line3, $line3) = TrackingUserLogCSV::display_student_publications_tracking_info(
$view,
$uInfo,
$_cid
$courseId
);
//Links usage

@ -386,7 +386,7 @@ if (api_is_allowed_to_edit(null, true)) {
if (api_is_allowed_to_edit(null, true)) {
// Unregister user from course
if ($_REQUEST['unregister']) {
if (isset($_REQUEST['unregister']) && $_REQUEST['unregister']) {
if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) &&
($_GET['user_id'] != $_user['user_id'] || api_is_platform_admin())
) {
@ -443,7 +443,10 @@ if (!$is_allowed_in_course) {
}
/* Header */
if ($origin != 'learnpath') {
if (isset($origin) && $origin == 'learnpath') {
Display::display_reduced_header();
} else {
if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
$tool_name = get_lang('SearchResults');
@ -452,8 +455,6 @@ if ($origin != 'learnpath') {
$origin = 'users';
}
Display::display_header($tool_name, "User");
} else {
Display::display_reduced_header();
}
// Statistics
@ -500,7 +501,9 @@ if (api_is_allowed_to_edit(null, true)) {
$actions .= ' <a class="btn" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
}
if (api_is_allowed_to_edit() && $_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
if (api_is_allowed_to_edit() &&
isset($_configuration['allow_tutors_to_assign_students_to_session']) &&
$_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$actions .= ' <a class="btn" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
}

@ -6,33 +6,35 @@
require_once(dirname(__FILE__).'/../inc/global.inc.php');
/**
* Error returned by one of the methods of the web service. Contains an error code and an error message
* Error returned by one of the methods of the web service.
* Contains an error code and an error message
*/
class WSError {
class WSError
{
/**
* Error handler. This needs to be a class that implements the interface WSErrorHandler
*
*
* @var WSErrorHandler
*/
protected static $_handler;
/**
* Error code
*
*
* @var int
*/
public $code;
/**
* Error message
*
*
* @var string
*/
public $message;
/**
* Constructor
*
*
* @param int Error code
* @param string Error message
*/
@ -40,10 +42,10 @@ class WSError {
$this->code = $code;
$this->message = $message;
}
/**
* Sets the error handler
*
*
* @param WSErrorHandler Error handler
*/
public static function setErrorHandler($handler) {
@ -51,19 +53,19 @@ class WSError {
self::$_handler = $handler;
}
}
/**
* Returns the error handler
*
*
* @return WSErrorHandler Error handler
*/
public static function getErrorHandler() {
return self::$_handler;
}
/**
* Transforms the error into an array
*
*
* @return array Associative array with code and message
*/
public function toArray() {
@ -77,7 +79,7 @@ class WSError {
interface WSErrorHandler {
/**
* Handle method
*
*
* @param WSError Error
*/
public function handle($error);
@ -89,11 +91,11 @@ interface WSErrorHandler {
class WS {
/**
* Chamilo configuration
*
*
* @var array
*/
protected $_configuration;
/**
* Constructor
*/
@ -103,13 +105,13 @@ class WS {
/**
* Verifies the API key
*
*
* @param string Secret key
* @return mixed WSError in case of failure, null in case of success
*/
protected function verifyKey($secret_key) {
$ip = trim($_SERVER['REMOTE_ADDR']);
// if we are behind a reverse proxy, assume it will send the
// if we are behind a reverse proxy, assume it will send the
// HTTP_X_FORWARDED_FOR header and use this IP instead
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
@ -123,11 +125,12 @@ class WS {
return null;
}
}
/**
* Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
* Gets the real user id based on the user id field name and value.
* Note that if the user id field name is "chamilo_user_id", it will use the user id
* in the system database
*
*
* @param string User id field name
* @param string User id value
* @return mixed System user id if the user was found, WSError otherwise
@ -148,44 +151,48 @@ class WS {
}
}
}
/**
* Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
* Gets the real course id based on the course id field name and value.
* Note that if the course id field name is "chamilo_course_id", it will use the course id
* in the system database
*
*
* @param string Course id field name
* @param string Course id value
* @return mixed System course id if the course was found, WSError otherwise
*/
protected function getCourseId($course_id_field_name, $course_id_value) {
if($course_id_field_name == "chamilo_course_id") {
if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
protected function getCourseId($course_id_field_name, $course_id_value)
{
if ($course_id_field_name == "chamilo_course_id") {
if (CourseManager::get_course_code_from_course_id(
intval($course_id_value)
) != null
) {
return intval($course_id_value);
} else {
return new WSError(200, "Course not found");
}
} else {
$course_code = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
if (!empty($course_code)) {
$course_info = CourseManager::get_course_information($course_code);
return $course_info['id'];
} else {
return new WSError(200, "Course not found");
}
/*
if($course_code == 0) {
return new WSError(200, "Course not found");
} else {
$course_code = CourseManager::get_course_code_from_original_id(
$course_id_value,
$course_id_field_name
);
if (!empty($course_code)) {
$course_info = CourseManager::get_course_information(
$course_code
);
return $course_info['id'];
}
*/
} else {
return new WSError(200, "Course not found");
}
}
}
/**
* Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
* Gets the real session id based on the session id field name and value.
* Note that if the session id field name is "chamilo_session_id", it will use the session id
* in the system database
*
*
* @param string Session id field name
* @param string Session id value
* @return mixed System session id if the session was found, WSError otherwise
@ -207,35 +214,33 @@ class WS {
}
}
}
/**
* Handles an error by calling the WSError error handler
*
*
* @param WSError Error
*/
protected function handleError($error) {
$handler = WSError::getErrorHandler();
$handler->handle($error);
}
/**
* Gets a successful result
*
*
* @return array Array with a code of 0 and a message 'Operation was successful'
*/
protected function getSuccessfulResult() {
return array('code' => 0, 'message' => 'Operation was successful');
}
/**
* Test function. Returns the string success
*
*
* @return string Success
*/
public function test() {
return "success";
}
}

@ -47,7 +47,7 @@ class WSReport extends WS {
} else {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
}
return Tracking::get_time_spent_on_the_course($user_id, $course_code);
return Tracking::get_time_spent_on_the_course($user_id, $course_id);
}
/**
@ -74,7 +74,7 @@ class WSReport extends WS {
if($session_id instanceof WSError) {
return $session_id;
}
return Tracking::get_time_spent_on_the_course($user_id, $course_code, $session_id);
return Tracking::get_time_spent_on_the_course($user_id, $course_id, $session_id);
}
/**
* Gets a list of learning paths by course

@ -3881,44 +3881,6 @@ function sendAlertToTeacher($workId, $courseInfo, $session_id)
}
}
/**
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @author Julio Montoya
* @desc Record information for upload event
* @param int $docId
* @param int $userId
* @param string $courseCode
* @param int $sessionId
* @return int
*/
function event_upload($docId, $userId, $courseCode, $sessionId)
{
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$reallyNow = api_get_utc_datetime();
$userId = intval($userId);
$docId = intval($docId);
$sessionId = intval($sessionId);
$courseCode = Database::escape_string($courseCode);
$sql = "INSERT INTO ".$table."
( upload_user_id,
upload_cours_id,
upload_work_id,
upload_date,
upload_session_id
)
VALUES (
".$userId.",
'".$courseCode."',
'".$docId."',
'".$reallyNow."',
'".$sessionId."'
)";
Database::query($sql);
return 1;
}
/**
* @param array $workInfo
* @param array $values
@ -4007,7 +3969,7 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
$groupId
);
sendAlertToTeacher($workId, $courseInfo, $sessionId);
Event::event_upload($workId, $userId, $courseInfo['code'], $sessionId);
Event::event_upload($workId);
$message = Display::return_message(get_lang('DocAdd'));
}
} else {

@ -155,12 +155,12 @@ class BlockCourse extends Block
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_data = array();
$courses = $this->courses;
$thematic = new Thematic();
foreach ($courses as $row_course) {
$course_code = $row_course['code'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
// students directly subscribed to the course
@ -174,7 +174,7 @@ class BlockCourse extends Block
if (count($users) > 0) {
$nb_students_in_course = count($users);
$avg_time_spent_in_course = api_time_to_hms(
Tracking::get_time_spent_on_the_course($users, $course_code ) / $nb_students_in_course);
Tracking::get_time_spent_on_the_course($users, $courseId) / $nb_students_in_course);
} else {
$avg_time_spent_in_course = null;
}

@ -118,8 +118,10 @@ class BlockStudent extends Block
if (!empty($courses_by_user)) {
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$course_title = $course['title'];
$time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course_code));
$time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $courseId));
$students_table .= '<tr '.$style.'>
<td align="right">'.$course_title.'</td>
<td align="right">'.$time.'</td>

@ -278,8 +278,8 @@ if (isset($_POST['report'])) {
c.title AS course, access_tool AS tool
FROM " . Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS) . " access
LEFT JOIN " . Database::get_main_table(TABLE_MAIN_USER) . " u ON access.access_user_id = u.user_id
LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE) . " c ON access.access_cours_code = c.CODE
WHERE access.access_cours_code = '" . $course_info['code'] . "' AND u.user_id = '$user_id' ";
LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE) . " c ON access.c_id = c.id
WHERE access.c_id = '" . $course_info['real_id'] . "' AND u.user_id = '$user_id' ";
if ($tool != '') {
$sql.="AND access.access_tool = '$tool' ";
}

@ -4,29 +4,25 @@
* @author Julio Montoya <gugli100@gmail.com>
*
*/
/**
* Initialisation section
*/
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
/**
* Loads the data and injects it into the Dokeos database, using the Dokeos
* internal functions.
* @return array List of user IDs for the users that have just been inserted
*/
function fill_whoisonline() {
function fill_whoisonline()
{
$table_e_online = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$max = 100;
//Cleaning the table
$sql = "TRUNCATE $table_e_online";
$sql = "TRUNCATE $table_e_online";
$rs = Database::query($sql);
//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, course, session_id, access_url_id)
$sql = "INSERT INTO $table_e_online (login_id, login_user_id, login_date, login_ip, c_id, session_id, access_url_id)
VALUES ('$i', '$i', '$date', '127.0.0.1', '', '0','1')";
$rs = Database::query($sql);
}
}
}
}

@ -2,14 +2,14 @@
class TestMySpaceLib extends UnitTestCase {
public function TestMySpaceLib() {
$this->UnitTestCase('Test My Space');
}
}
public function __construct() {
// The constructor acts like a global setUp for the class
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
}
/*
@ -21,7 +21,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
*/
*/
public function testGetConnectionsToCourse() {
//ob_start();
$res = MySpace::get_connections_to_course($user_id = 1, $course_code = 'COURSETEST');
@ -30,14 +30,6 @@ class TestMySpaceLib extends UnitTestCase {
//var_dump($res);
}
public function testGetConnectionsToCourseByTime() {
//ob_start();
$res = MySpace::get_connections_to_course_by_time($user_id = 1, $course_code = 'COURSETEST', $year = '', $month = '', $day = '');
$this->assertTrue(is_array($res));
//ob_end_clean();
//var_dump($res);
}
public function testCourseInfoTrackingFilter() {
//ob_start();
$res = MySpace::course_info_tracking_filter($user_id = 1, $url_params = array(), $row = array());
@ -53,7 +45,7 @@ class TestMySpaceLib extends UnitTestCase {
ob_end_clean();
//var_dump($res);
}
public function testDisplayUserOverviewExportOptions() {
//ob_start();
$res = MySpace::display_user_overview_export_options();
@ -61,7 +53,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testExercisesResults() {
//ob_start();
$res = MySpace::exercises_results($user_id = 1, $course_code = 'COURSETEST');
@ -77,7 +69,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testGetCourseData() {
//ob_start();
$res = MySpace::get_course_data($from = 1, $number_of_items = 2, $column = 2, $direction = 1);
@ -109,7 +101,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testMakeUsername() {
//ob_start();
$res = MySpace::make_username($firstname = 'Vargas', $lastname = 'Carlos', $username = 'cvargas', $language = null, $encoding = null);
@ -117,7 +109,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testCheckUserInArray() {
//ob_start();
$res = MySpace::check_user_in_array($usernames = array(), $user_array = array());
@ -125,7 +117,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testUserAvailableInSession() {
//ob_start();
$res = MySpace::user_available_in_session($username = 1, $course_list = array(), $id_session = 1);
@ -141,7 +133,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testGetUserCreator() {
//ob_start();
$res = MySpace::get_user_creator($users = array(), $course_list = array(), $id_session = 1);
@ -149,7 +141,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testValidate_data() {
//ob_start();
$res = MySpace::validate_data($users = array(), $id_session = null);
@ -165,7 +157,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}*//*
public function testSaveData() {
//ob_start();
$res = MySpace::save_data($users = array(), $course_list = array(), $id_session = 1);
@ -173,7 +165,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testParseCsvData() {
//ob_start();
$res = MySpace::parse_csv_data($file = '');
@ -189,7 +181,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testElementEnd() {
//ob_start();
$res = MySpace::element_end($parser = 'Contact', $data = '');
@ -197,7 +189,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testCharacterData() {
//ob_start();
$res = MySpace::character_data($parser = 'Contact', $data = '');
@ -205,7 +197,7 @@ class TestMySpaceLib extends UnitTestCase {
//ob_end_clean();
//var_dump($res);
}
public function testParseXmlData() {
//ob_start();
$res = MySpace::parse_xml_data($file = '');
@ -215,7 +207,7 @@ class TestMySpaceLib extends UnitTestCase {
}
public function __destruct() {
// The destructor acts like a global tearDown for the class
//require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
// The destructor acts like a global tearDown for the class
//require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
}
}
}

@ -76,17 +76,19 @@ Display::display_header(get_lang('UserOnlineListSession'));
$students_online = array();
foreach ($session_is_coach as $session) {
$sql = "SELECT DISTINCT last_access.access_user_id,
last_access.access_date,
last_access.access_cours_code,
last_access.access_session_id,
".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
user.email
FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
$sql = "SELECT DISTINCT
last_access.access_user_id,
last_access.access_date,
last_access.c_id,
last_access.access_session_id,
".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
user.email
FROM ".Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
ON user.user_id = last_access.access_user_id
WHERE access_session_id='".$session['id']."'
AND NOW()-access_date<1000 GROUP BY access_user_id";
AND NOW()-access_date<1000
GROUP BY access_user_id";
$result = Database::query($sql);
@ -104,7 +106,8 @@ Display::display_header(get_lang('UserOnlineListSession'));
echo " </td>
<td align='center'>
";
echo $student_online['access_cours_code'];
$courseInfo = api_get_course_info($student_online['c_id']);
echo $courseInfo['title'];
echo " </td>
<td align='center'>
";
@ -116,7 +119,7 @@ Display::display_header(get_lang('UserOnlineListSession'));
echo " </td>
<td align='center'>
";
echo '<a href="main/chat/chat.php?cidReq='.$student_online['access_cours_code'].'&id_session='.$student_online['access_session_id'].'"> -> </a>';
echo '<a href="main/chat/chat.php?cidReq='.$courseInfo['code'].'&id_session='.$student_online['access_session_id'].'"> -> </a>';
echo " </td>
</tr>
";

Loading…
Cancel
Save