';
- $total_score_text .= get_question_ribbon(
+ $total_score_text .= self::get_question_ribbon(
$objExercise,
$total_score,
$total_weight,
diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php
index 15a8dbcafe..4b05a5710c 100755
--- a/main/inc/lib/login.lib.php
+++ b/main/inc/lib/login.lib.php
@@ -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);
}
}
diff --git a/main/inc/lib/myspace.lib.php b/main/inc/lib/myspace.lib.php
index 082479b103..369e634caf 100644
--- a/main/inc/lib/myspace.lib.php
+++ b/main/inc/lib/myspace.lib.php
@@ -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 .= '
";
$results = getManyResultsXCol($sql,4);
echo "";
@@ -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);
diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php
index 3a87765aa7..fad9964b24 100755
--- a/main/inc/lib/usermanager.lib.php
+++ b/main/inc/lib/usermanager.lib.php
@@ -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
);
diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php
index 1d0af91b71..0ec85bf9cd 100755
--- a/main/inc/local.inc.php
+++ b/main/inc/local.inc.php
@@ -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);
}
}
diff --git a/main/install/db_main.sql b/main/install/db_main.sql
index 0fb8b0d301..1ffb5714e3 100755
--- a/main/install/db_main.sql
+++ b/main/install/db_main.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 ''
);
diff --git a/main/install/db_stats.sql b/main/install/db_stats.sql
index aa660d83cf..61da033c34 100755
--- a/main/install/db_stats.sql
+++ b/main/install/db_stats.sql
@@ -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)
-);
\ No newline at end of file
+);
diff --git a/main/install/migrate-db-1.9.0-1.10.0-pre.sql b/main/install/migrate-db-1.9.0-1.10.0-pre.sql
index de3f29e5bc..fb68028fd1 100644
--- a/main/install/migrate-db-1.9.0-1.10.0-pre.sql
+++ b/main/install/migrate-db-1.9.0-1.10.0-pre.sql
@@ -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
diff --git a/main/install/update-db-1.9.0-1.10.0.inc.php b/main/install/update-db-1.9.0-1.10.0.inc.php
index 7260246f0b..01117f2709 100644
--- a/main/install/update-db-1.9.0-1.10.0.inc.php
+++ b/main/install/update-db-1.9.0-1.10.0.inc.php
@@ -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) {
diff --git a/main/mySpace/access_details.php b/main/mySpace/access_details.php
index 669ebc798a..ba9f95b96c 100755
--- a/main/mySpace/access_details.php
+++ b/main/mySpace/access_details.php
@@ -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();
'.get_lang('Total').': '.$rst['total'].' ';
$foo_stats .= ''.get_lang('Average').': '.$rst['avg'].' ';
$foo_stats .= ''.get_lang('Quantity').' : '.$rst['times'].' ';
diff --git a/main/mySpace/course.php b/main/mySpace/course.php
index f9b82e75d8..705849455f 100755
--- a/main/mySpace/course.php
+++ b/main/mySpace/course.php
@@ -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);
diff --git a/main/mySpace/current_courses.php b/main/mySpace/current_courses.php
index 0c46114798..5647365d65 100755
--- a/main/mySpace/current_courses.php
+++ b/main/mySpace/current_courses.php
@@ -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']) {
diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php
index 02b0a8f40a..c3c50cf14d 100755
--- a/main/mySpace/myStudents.php
+++ b/main/mySpace/myStudents.php
@@ -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(
diff --git a/main/mySpace/student.php b/main/mySpace/student.php
index eb7f474fc9..1ab100dbba 100755
--- a/main/mySpace/student.php
+++ b/main/mySpace/student.php
@@ -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;
diff --git a/main/mySpace/teachers.php b/main/mySpace/teachers.php
index f3230b55bc..071fea033b 100755
--- a/main/mySpace/teachers.php
+++ b/main/mySpace/teachers.php
@@ -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;
diff --git a/main/mySpace/users.php b/main/mySpace/users.php
index ed35b3cf1a..339df52474 100755
--- a/main/mySpace/users.php
+++ b/main/mySpace/users.php
@@ -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;
diff --git a/main/reports/modules/course.php b/main/reports/modules/course.php
index 1b9fd71055..572afb4550 100755
--- a/main/reports/modules/course.php
+++ b/main/reports/modules/course.php
@@ -1,4 +1,4 @@
-
+ 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');
}
diff --git a/main/session/index.php b/main/session/index.php
index 217c3a43ae..01d6c2aee8 100755
--- a/main/session/index.php
+++ b/main/session/index.php
@@ -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)) {
diff --git a/main/tracking/courseLogCSV.php b/main/tracking/courseLogCSV.php
index dccc53401a..c8cfbf11b7 100755
--- a/main/tracking/courseLogCSV.php
+++ b/main/tracking/courseLogCSV.php
@@ -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);
diff --git a/main/tracking/course_access_details.php b/main/tracking/course_access_details.php
index d4bb0979c8..8a832638fb 100755
--- a/main/tracking/course_access_details.php
+++ b/main/tracking/course_access_details.php
@@ -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;
";
- //**
// 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;
diff --git a/main/tracking/course_log_tools.php b/main/tracking/course_log_tools.php
index 2035addc47..0a4a49efea 100755
--- a/main/tracking/course_log_tools.php
+++ b/main/tracking/course_log_tools.php
@@ -99,6 +99,7 @@ echo '';
echo ' ';
$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 '
'.Display::page_subheader(Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed')).'
';
-$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'), '');
diff --git a/main/tracking/course_session_report.php b/main/tracking/course_session_report.php
index 3ea98e552a..b20d3aef23 100755
--- a/main/tracking/course_session_report.php
+++ b/main/tracking/course_session_report.php
@@ -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'];
diff --git a/main/tracking/logins_details.php b/main/tracking/logins_details.php
index c03ee9140f..90b1e949c7 100755
--- a/main/tracking/logins_details.php
+++ b/main/tracking/logins_details.php
@@ -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 "";
- $results = getManyResults1Col($sql);
- /* * * display of the displayed period ** */
- echo "";
- echo "" . $displayedDate . " | ";
- 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 "";
- echo "" . $beautifulDateTime . " | ";
- echo" ";
- // $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 "";
+ $results = getManyResults1Col($sql);
+ /* * * display of the displayed period ** */
+ echo "";
+ echo "" . $displayedDate . " | ";
+ 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 "";
+ echo "" . $beautifulDateTime . " | ";
+ echo" ";
+ // $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 "\n";
- echo "\n";
- for ($k = 0; $k < count($results2); $k++) {
- echo "\n";
- echo "" . get_lang($results2[$k][0]) . " | \n";
- echo "" . $results2[$k][1] . " " . get_lang('Visits') . " | \n";
- echo " ";
- }
- echo " \n";
- echo " | \n";
+ if (is_array($results2)) {
+ echo "\n";
+ echo "\n";
+ for ($k = 0; $k < count($results2); $k++) {
+ echo "\n";
+ echo "" . get_lang($results2[$k][0]) . " | \n";
+ echo "" . $results2[$k][1] . " " . get_lang('Visits') . " | \n";
+ echo " ";
}
- $previousDate = $value;
+ echo " \n";
+ echo " | \n";
}
- } else {
- echo "";
- echo "" . get_lang('NoResult') . " | ";
- echo " ";
+ $previousDate = $value;
}
- echo " ";
- echo " | ";
} else {
- echo get_lang('ErrorUserNotInGroup');
+ echo "";
+ echo "" . get_lang('NoResult') . " | ";
+ echo " ";
}
+ echo " ";
+ echo " | ";
} else {
- // not allowed
- api_not_allowed();
+ echo get_lang('ErrorUserNotInGroup');
}
- ?>
+} else {
+ // not allowed
+ api_not_allowed();
+}
+?>
$stats['exe_result'],'exe_weighting' =>$stats['exe_weighting']);
diff --git a/main/tracking/personnalLog.php b/main/tracking/personnalLog.php
index 587d3edd18..136ea4ff87 100755
--- a/main/tracking/personnalLog.php
+++ b/main/tracking/personnalLog.php
@@ -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 "
diff --git a/main/tracking/question_course_report.php b/main/tracking/question_course_report.php
index c3af55cc3a..b2478b1ec0 100755
--- a/main/tracking/question_course_report.php
+++ b/main/tracking/question_course_report.php
@@ -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
);
diff --git a/main/tracking/toolaccess_details.php b/main/tracking/toolaccess_details.php
index 31ef088124..51e10e3ff8 100755
--- a/main/tracking/toolaccess_details.php
+++ b/main/tracking/toolaccess_details.php
@@ -51,7 +51,6 @@ Display::display_header($nameTools,"Tracking");
=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 "\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);
diff --git a/main/tracking/userlogCSV.php b/main/tracking/userlogCSV.php
index 694078d24c..ba642f294c 100755
--- a/main/tracking/userlogCSV.php
+++ b/main/tracking/userlogCSV.php
@@ -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
diff --git a/main/user/user.php b/main/user/user.php
index 237d8d3927..779e0c6e2d 100755
--- a/main/user/user.php
+++ b/main/user/user.php
@@ -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 .= ' '.get_lang('Classes').'';
}
- 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 .= ' '.get_lang('Sessions').'';
}
diff --git a/main/webservices/webservice.php b/main/webservices/webservice.php
index f796a1110c..c86bb88a3b 100755
--- a/main/webservices/webservice.php
+++ b/main/webservices/webservice.php
@@ -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";
}
-
-
}
diff --git a/main/webservices/webservice_report.php b/main/webservices/webservice_report.php
index c087f3dbaa..1ad1da692e 100755
--- a/main/webservices/webservice_report.php
+++ b/main/webservices/webservice_report.php
@@ -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
diff --git a/main/work/work.lib.php b/main/work/work.lib.php
index a8558f21f6..f98e0017dd 100755
--- a/main/work/work.lib.php
+++ b/main/work/work.lib.php
@@ -3881,44 +3881,6 @@ function sendAlertToTeacher($workId, $courseInfo, $session_id)
}
}
-/**
- * @author Sebastien Piraux
- * @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 {
diff --git a/plugin/dashboard/block_course/block_course.class.php b/plugin/dashboard/block_course/block_course.class.php
index 5c30433fe3..6948ba95e6 100755
--- a/plugin/dashboard/block_course/block_course.class.php
+++ b/plugin/dashboard/block_course/block_course.class.php
@@ -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;
}
diff --git a/plugin/dashboard/block_student/block_student.class.php b/plugin/dashboard/block_student/block_student.class.php
index c07243c3a2..5be5cf8598 100755
--- a/plugin/dashboard/block_student/block_student.class.php
+++ b/plugin/dashboard/block_student/block_student.class.php
@@ -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 .= '
'.$course_title.' |
'.$time.' |
diff --git a/plugin/ticket/src/report.php b/plugin/ticket/src/report.php
index 898f4253c5..9e991d01a8 100755
--- a/plugin/ticket/src/report.php
+++ b/plugin/ticket/src/report.php
@@ -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' ";
}
diff --git a/tests/datafiller/fill_whoisonline.php b/tests/datafiller/fill_whoisonline.php
index d0bd4c2a7a..3320891b95 100755
--- a/tests/datafiller/fill_whoisonline.php
+++ b/tests/datafiller/fill_whoisonline.php
@@ -4,29 +4,25 @@
* @author Julio Montoya
*
*/
-
-/**
- * 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);
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/tests/main/mySpace/myspace.lib.test.php b/tests/main/mySpace/myspace.lib.test.php
index 503647085e..3541e33ef4 100755
--- a/tests/main/mySpace/myspace.lib.test.php
+++ b/tests/main/mySpace/myspace.lib.test.php
@@ -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';
}
-}
\ No newline at end of file
+}
diff --git a/whoisonlinesession.php b/whoisonlinesession.php
index 612c4ec411..1c06c0f8d7 100755
--- a/whoisonlinesession.php
+++ b/whoisonlinesession.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 "
";
- echo $student_online['access_cours_code'];
+ $courseInfo = api_get_course_info($student_online['c_id']);
+ echo $courseInfo['title'];
echo " |
";
@@ -116,7 +119,7 @@ Display::display_header(get_lang('UserOnlineListSession'));
echo " |
";
- echo ' -> ';
+ echo ' -> ';
echo " |
";
| |