* $wanted_code = 'sess' if there are names like sess, sess1, sess2 in the
@@ -737,7 +737,7 @@ class SessionManager {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-
+
if (empty($nolimit)) {
$date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
$date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
@@ -746,20 +746,20 @@ class SessionManager {
$date_end = "0000-00-00";
$id_visibility = 1;//force read only
}
-
+
if (!empty($no_end_limit)) {
$date_end = "0000-00-00";
}
-
+
if (empty($end_limit)) {
$date_end ="0000-00-00";
$id_visibility = 1;//force read only
}
-
+
if (empty($start_limit)) {
$date_start ="0000-00-00";
}
-
+
if (empty($name)) {
$msg=get_lang('SessionNameIsRequired');
return $msg;
@@ -814,9 +814,9 @@ class SessionManager {
$tbl_session= Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
- $tbl_session_rel_user= Database::get_main_table(TABLE_MAIN_SESSION_USER);
+ $tbl_session_rel_user= Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
-
+
global $_user;
if(is_array($id_checked)) {
$id_checked = Database::escape_string(implode(',',$id_checked));
@@ -898,7 +898,7 @@ class SessionManager {
}
}
*/
- // Add event to system log
+ // Add event to system log
$user_id = api_get_user_id();
event_system(LOG_SESSION_DELETE, LOG_SESSION_ID, $id_checked, api_get_utc_datetime(), $user_id);
}
@@ -923,14 +923,14 @@ class SessionManager {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$session_info = api_get_session_info($id_session);
-
+
if ($session_info) {
$session_name = $session_info['name'];
} else {
return false;
- }
+ }
- //from function parameter
+ //from function parameter
if (empty($session_visibility)) {
$session_visibility = $session_info['visibility']; //loaded from DB
//default status loaded if empty
@@ -942,29 +942,29 @@ class SessionManager {
}
}
- $sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$id_session' AND status = 0";
+ $sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$id_session' AND status = 0";
$result = Database::query($sql);
$existingUsers = array();
while ($row = Database::fetch_array($result)) {
$existingUsers[] = $row['id_user'];
}
-
+
$sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session = '$id_session'";
$result = Database::query($sql);
$course_list = array();
while ($row = Database::fetch_array($result)) {
$course_list[] = $row['course_code'];
- }
-
- if ($send_email) {
+ }
+
+ if ($send_email) {
//sending emails only
if (is_array($user_list) && count($user_list)>0) {
- foreach ($user_list as $user_id) {
- if (!in_array($user_id, $existingUsers)) {
+ foreach ($user_list as $user_id) {
+ if (!in_array($user_id, $existingUsers)) {
$subject = '['.get_setting('siteName').'] '.get_lang('YourReg').' '.get_setting('siteName');
$user_info = api_get_user_info($user_id);
- $content = get_lang('Dear')." ".stripslashes($user_info['complete_name']).",\n\n".sprintf(get_lang('YouAreRegisterToSessionX'), $session_name) ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". api_get_path(WEB_PATH) ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
- MessageManager::send_message($user_id, $subject, $content, array(), array(), null, null, null, null, null);
+ $content = get_lang('Dear')." ".stripslashes($user_info['complete_name']).",\n\n".sprintf(get_lang('YouAreRegisterToSessionX'), $session_name) ." \n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". api_get_path(WEB_PATH) ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
+ MessageManager::send_message($user_id, $subject, $content, array(), array(), null, null, null, null, null);
}
}
}
@@ -986,7 +986,7 @@ class SessionManager {
}
}
}
-
+
//Replace with this new function
//
// insert new users into session_rel_course_rel_user and ignore if they already exist
@@ -995,7 +995,7 @@ class SessionManager {
$enreg_user = Database::escape_string($enreg_user);
$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session, course_code, id_user, visibility, status) VALUES('$id_session','$enreg_course','$enreg_user','$session_visibility', '0')";
Database::query($insert_sql);
-
+
if(Database::affected_rows()) {
$nbr_users++;
}
@@ -1014,50 +1014,50 @@ class SessionManager {
if ($empty_users === true) {
Database::query("DELETE FROM $tbl_session_rel_user WHERE id_session = $id_session AND relation_type<>".SESSION_RELATION_TYPE_RRHH."");
}
-
+
// Insert missing users into session
- $nbr_users = 0;
+ $nbr_users = 0;
foreach ($user_list as $enreg_user) {
- $enreg_user = Database::escape_string($enreg_user);
- $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user) VALUES ('$id_session', '$enreg_user')";
+ $enreg_user = Database::escape_string($enreg_user);
+ $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user) VALUES ('$id_session', '$enreg_user')";
Database::query($insert_sql);
-
+
//Reset moved_to just in case
- $update_sql = "UPDATE $tbl_session_rel_user SET moved_to = 0, moved_status = 0, moved_at ='0000-00-00 00:00:00'
- WHERE id_session = $id_session AND id_user = $enreg_user";
+ $update_sql = "UPDATE $tbl_session_rel_user SET moved_to = 0, moved_status = 0, moved_at ='0000-00-00 00:00:00'
+ WHERE id_session = $id_session AND id_user = $enreg_user";
Database::query($update_sql);
$nbr_users++;
}
// update number of users in the session
- $nbr_users = count($user_list);
+ $nbr_users = count($user_list);
if ($empty_users) {
- // update number of users in the session
+ // update number of users in the session
$update_sql = "UPDATE $tbl_session SET nbr_users = $nbr_users WHERE id='$id_session' ";
Database::query($update_sql);
} else {
$update_sql = "UPDATE $tbl_session SET nbr_users = nbr_users + $nbr_users WHERE id='$id_session' ";
- Database::query($update_sql);
+ Database::query($update_sql);
}
}
-
+
function subscribe_users_to_session_course($user_list, $session_id, $course_code, $session_visibility = SESSION_VISIBLE_READ_ONLY ) {
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
if (empty($user_list) || empty($session_id) || empty($course_code)) {
- return false;
+ return false;
}
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
- $session_visibility = intval($session_visibility);
+ $session_visibility = intval($session_visibility);
$nbr_users = 0;
foreach ($user_list as $enreg_user) {
//if (!in_array($enreg_user, $existingUsers)) {
$enreg_user = intval($enreg_user);
- $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user,visibility)
+ $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user,visibility)
VALUES ('$session_id','$course_code','$enreg_user','$session_visibility')";
Database::query($insert_sql);
if (Database::affected_rows()) {
@@ -1091,9 +1091,9 @@ class SessionManager {
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
-
+
$user_status = SessionManager::get_user_status_in_session($session_id, $user_id);
-
+
if ($user_status['moved_to'] != 0) {
//You can't subscribe a user that was moved
return false;
@@ -1109,24 +1109,24 @@ class SessionManager {
// Get the list of courses related to this session
$course_list = SessionManager::get_course_list_by_session_id($session_id);
-
+
if (!empty($course_list)) {
foreach($course_list as $course) {
$course_code = $course['code'];
// Delete user from course
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$session_id' AND course_code='$course_code' AND id_user='$user_id'");
-
+
if(Database::affected_rows()) {
// Update number of users in this relation
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users - 1 WHERE id_session='$session_id' AND course_code='$course_code'");
}
}
- }
+ }
return true;
}
-
+
/**
- *
+ *
* @param int $session_id
* @param array user id list
* @param string $course_code
@@ -1141,12 +1141,12 @@ class SessionManager {
}
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
-
+
if (!empty($user_list)) {
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$session_id' AND course_code='".$course_code."' AND id_user IN($user_list)");
$nbr_affected_rows = Database::affected_rows();
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$session_id' AND course_code='".$course_code."'");
- }
+ }
}
/** Subscribes courses to the given session and optionally (default) unsubscribes previous users
@@ -1159,13 +1159,13 @@ class SessionManager {
public static function add_courses_to_session ($id_session, $course_list, $empty_courses=true) {
// security checks
if ($id_session!= strval(intval($id_session))) { return false; }
-
+
// initialisation
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-
+
// get general coach ID
$id_coach = Database::query("SELECT id_coach FROM $tbl_session WHERE id=$id_session");
$id_coach = Database::fetch_array($id_coach);
@@ -1274,8 +1274,8 @@ class SessionManager {
public static function create_session_extra_field ($fieldvarname, $fieldtype, $fieldtitle) {
// database table definition
$params = array('field_variable' => $fieldvarname,
- 'field_type' => $fieldtype,
- 'field_display_text' => $fieldtitle
+ 'field_type' => $fieldtype,
+ 'field_display_text' => $fieldtitle
);
$session_field = new SessionField();
$field_id = $session_field->save($params);
@@ -1290,7 +1290,7 @@ class SessionManager {
* @return boolean true if field updated, false otherwise
*/
public static function update_session_extra_field_value ($session_id, $fname, $fvalue = null) {
-
+
$session_field_value = new SessionFieldValue();
$session_field_value->update($params);
@@ -1299,7 +1299,7 @@ class SessionManager {
$fname = Database::escape_string($fname);
$session_id = (int)$session_id;
$tms = api_get_utc_datetime();
-
+
$fvalues = '';
if (is_array($fvalue)) {
foreach($fvalue as $val) {
@@ -1314,11 +1314,11 @@ class SessionManager {
$sqlsf = "SELECT * FROM $t_sf WHERE field_variable='$fname'";
$ressf = Database::query($sqlsf);
- if (Database::num_rows($ressf)==1) {
+ if (Database::num_rows($ressf)==1) {
// ok, the field exists
// Check if enumerated field, if the option is available
$rowsf = Database::fetch_array($ressf);
-
+
$sqlsfv = "SELECT * FROM $t_sfv WHERE session_id = '$session_id' AND field_id = '".$rowsf['id']."' ORDER BY id";
$ressfv = Database::query($sqlsfv);
$n = Database::num_rows($ressfv);
@@ -1385,7 +1385,7 @@ class SessionManager {
* */
public static function get_session_by_name ($session_name) {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
- $sql = 'SELECT * FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name).'"';
+ $sql = 'SELECT * FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name).'"';
$result = Database::query($sql);
$num = Database::num_rows($result);
if ($num) {
@@ -1440,7 +1440,7 @@ class SessionManager {
VALUES('".Database::escape_string($name)."','$date_start','$date_end', '$access_url_id')";
Database::query($sql);
$id_session = Database::insert_id();
- // Add event to system log
+ // Add event to system log
$user_id = api_get_user_id();
event_system(LOG_SESSION_CATEGORY_CREATE, LOG_SESSION_CATEGORY_ID, $id_session, api_get_utc_datetime(), $user_id);
return $id_session;
@@ -1517,11 +1517,11 @@ class SessionManager {
} else {
$id_checked = intval($id_checked);
}
-
+
//Setting session_category_id to 0
$sql = "UPDATE $tbl_session SET session_category_id = 0 WHERE session_category_id IN (".$id_checked.")";
Database::query($sql);
-
+
$sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
$result = @Database::query($sql);
while ($rows = Database::fetch_array($result)) {
@@ -1538,9 +1538,9 @@ class SessionManager {
$rs = @Database::query($sql);
$result = Database::affected_rows();
- // Add event to system log
+ // Add event to system log
$user_id = api_get_user_id();
-
+
event_system(LOG_SESSION_CATEGORY_DELETE, LOG_SESSION_CATEGORY_ID, $id_checked, api_get_utc_datetime(), $user_id);
@@ -1583,9 +1583,9 @@ class SessionManager {
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
-
+
$access_url_id = api_get_current_access_url_id();
-
+
$return_array = array();
$sql_query = " SELECT s.id, s.name, s.nbr_courses, s.access_start_date, s.access_end_date, u.firstname, u.lastname, sc.name as category_name, s.promotion_id
@@ -1594,7 +1594,7 @@ class SessionManager {
INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id
LEFT JOIN $session_category_table sc ON s.session_category_id = sc.id
WHERE ar.access_url_id = $access_url_id ";
-
+
if (count($conditions) > 0) {
$sql_query .= ' AND ';
foreach ($conditions as $field=>$value) {
@@ -1615,7 +1615,7 @@ class SessionManager {
}
return $return_array;
}
-
+
/**
* Get the session category information by id
* @param string session category ID
@@ -1633,16 +1633,16 @@ class SessionManager {
return false;
}
}
-
+
/**
* Get all session categories (filter by access_url_id)
* @return mixed false if the session category does not exist, array if the session category exists
*/
- public static function get_all_session_category() {
+ public static function get_all_session_category() {
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$id = api_get_current_access_url_id();
$sql = 'SELECT * FROM '.$tbl_session_category.' WHERE access_url_id ="'.$id.'" ORDER BY name ASC';
- $result = Database::query($sql);
+ $result = Database::query($sql);
if (Database::num_rows($result) > 0 ){
$data = Database::store_result($result,'ASSOC');
return $data;
@@ -1743,19 +1743,19 @@ class SessionManager {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
- $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
- $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+ $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$hr_manager_id = intval($hr_manager_id);
$affected_rows = 0;
//Deleting assigned sessions to hrm_id
- if ($_configuration['multiple_access_urls']) {
+ if ($_configuration['multiple_access_urls']) {
$sql = "SELECT id_session FROM $tbl_session_rel_user s INNER JOIN $tbl_session_rel_access_url a ON (a.session_id = s.id_session) WHERE id_user = $hr_manager_id AND relation_type=".SESSION_RELATION_TYPE_RRHH." AND access_url_id = ".api_get_current_access_url_id()."";
} else {
$sql = "SELECT id_session FROM $tbl_session_rel_user s WHERE id_user = $hr_manager_id AND relation_type=".SESSION_RELATION_TYPE_RRHH."";
}
- $result = Database::query($sql);
+ $result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
@@ -1802,12 +1802,12 @@ class SessionManager {
$hr_manager_id = intval($hr_manager_id);
$assigned_sessions_to_hrm = array();
- if ($_configuration['multiple_access_urls']) {
+ if ($_configuration['multiple_access_urls']) {
$sql = "SELECT * FROM $tbl_session s INNER JOIN $tbl_session_rel_user sru ON (sru.id_session = s.id) LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
WHERE sru.id_user = '$hr_manager_id' AND sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND access_url_id = ".api_get_current_access_url_id()."";
} else {
$sql = "SELECT * FROM $tbl_session s
- INNER JOIN $tbl_session_rel_user sru ON sru.id_session = s.id AND sru.id_user = '$hr_manager_id' AND sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' ";
+ INNER JOIN $tbl_session_rel_user sru ON sru.id_session = s.id AND sru.id_user = '$hr_manager_id' AND sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' ";
}
$rs_assigned_sessions = Database::query($sql);
if (Database::num_rows($rs_assigned_sessions) > 0) {
@@ -1816,7 +1816,7 @@ class SessionManager {
}
}
return $assigned_sessions_to_hrm;
- }
+ }
/**
* Gets the list of courses by session filtered by access_url
@@ -1826,9 +1826,9 @@ class SessionManager {
public static function get_course_list_by_session_id ($session_id) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-
+
// select the courses
- $sql = "SELECT * FROM $tbl_course c INNER JOIN $tbl_session_rel_course src ON c.code = src.course_code
+ $sql = "SELECT * FROM $tbl_course c INNER JOIN $tbl_session_rel_course src ON c.code = src.course_code
WHERE src.id_session = '$session_id' ORDER BY title;";
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
@@ -1860,24 +1860,24 @@ class SessionManager {
return 0;
}
}
-
+
/**
* Get users by session
* @param int session id
- * @param int filter by status
+ * @param int filter by status
* @return array a list with an user list
*/
public static function get_users_by_session($id, $with_status = null) {
if (empty($id)) {
return array();
- }
+ }
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
-
+
$id = intval($id);
-
+
if (api_is_multiple_url_enabled()) {
- $url_id = api_get_current_access_url_id();
+ $url_id = api_get_current_access_url_id();
$sql = "SELECT u.user_id, lastname, firstname, username, access_url_id, moved_to, moved_status, moved_at
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
@@ -1887,35 +1887,35 @@ class SessionManager {
} else {
$sql = "SELECT u.user_id, lastname, firstname, username, moved_to, moved_status, moved_at
FROM $tbl_user u INNER JOIN $tbl_session_rel_user su
- ON u.user_id = su.id_user AND
- su.id_session = $id
+ ON u.user_id = su.id_user AND
+ su.id_session = $id
";
}
-
+
if (isset($with_status) && $with_status != '') {
$with_status = intval($with_status);
$sql .= " WHERE relation_type = $with_status ";
}
-
+
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
-
+
$sql .= $order_clause;
-
+
$result = Database::query($sql);
while ($row = Database::fetch_array($result,'ASSOC')) {
$return_array[] = $row;
- }
+ }
return $return_array;
}
-
+
/**
- * The general coach (field: session.id_coach)
+ * The general coach (field: session.id_coach)
* @param int user id
*/
- public function get_sessions_by_general_coach($user_id) {
+ public static function get_sessions_by_general_coach($user_id) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_id = intval($user_id);
-
+
// session where we are general coach
$sql = "SELECT DISTINCT *
FROM $session_table
@@ -1933,16 +1933,16 @@ class SessionManager {
}
$sql .= ' ORDER by name';
$result = Database::query($sql);
- return Database::store_result($result, 'ASSOC');
- }
-
+ return Database::store_result($result, 'ASSOC');
+ }
+
/**
* Get all sessions if the user is a sesion course coach of any session
* @param int user id
*/
static function get_sessions_by_coach($user_id) {
// table definition
- $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
+ $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql = 'SELECT DISTINCT session.*
FROM ' . $tbl_session . ' as session
@@ -1964,11 +1964,11 @@ class SessionManager {
}
}
//$sql .= " ORDER BY session.name";
-
+
$result = Database::query($sql);
- return Database::store_result($result, 'ASSOC');
+ return Database::store_result($result, 'ASSOC');
}
-
+
public static function get_sessions_coached_by_user($coach_id, $check_session_rel_user_visibility = false) {
$sessions = self::get_sessions_by_general_coach($coach_id);
$sessions_by_coach = self::get_sessions_by_coach($coach_id);
@@ -1978,13 +1978,13 @@ class SessionManager {
}
//Remove repeated sessions
if (!empty($sessions)) {
- $clean_sessions = array();
+ $clean_sessions = array();
foreach ($sessions as $session) {
$clean_sessions[$session['id']] = $session;
}
$sessions = $clean_sessions;
}
-
+
if ($check_session_rel_user_visibility) {
if (!empty($sessions)) {
$new_session = array();
@@ -1992,7 +1992,7 @@ class SessionManager {
$visibility = api_get_session_visibility($session['id']);
if ($visibility == SESSION_INVISIBLE) {
continue;
- }
+ }
$new_session[] = $session;
}
$sessions = $new_session;
@@ -2000,9 +2000,9 @@ class SessionManager {
}
return $sessions;
}
-
+
/**
- * Gets user status within a session
+ * Gets user status within a session
* @param $user_id
* @param $course_code
* @param $session_id
@@ -2010,14 +2010,14 @@ class SessionManager {
*/
public static function get_user_status_in_course_session($user_id, $course_code, $session_id) {
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
- $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
+ $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT session_rcru.status
FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
- WHERE session_rcru.id_user = user.user_id AND
- session_rcru.id_session = '".intval($session_id)."' AND
- session_rcru.course_code ='".Database::escape_string($course_code)."' AND
- user.user_id = ".intval($user_id);
-
+ WHERE session_rcru.id_user = user.user_id AND
+ session_rcru.id_session = '".intval($session_id)."' AND
+ session_rcru.course_code ='".Database::escape_string($course_code)."' AND
+ user.user_id = ".intval($user_id);
+
$result = Database::query($sql);
$status = false;
if (Database::num_rows($result)) {
@@ -2026,12 +2026,12 @@ class SessionManager {
}
return $status;
}
-
+
static function get_user_status_in_session($session_id, $user_id) {
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$session_id = intval($session_id);
$user_id = intval($user_id);
-
+
$sql = "SELECT * FROM $tbl_session_rel_user WHERE id_user = $user_id AND id_session = $session_id";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@@ -2039,28 +2039,28 @@ class SessionManager {
return $result[0];
}
return array();
- }
-
+ }
+
function get_all_sessions_by_promotion($id) {
$t = Database::get_main_table(TABLE_MAIN_SESSION);
return Database::select('*', $t, array('where'=>array('promotion_id = ?'=>$id)));
}
-
+
function suscribe_sessions_to_promotion($promotion_id, $list) {
$t = Database::get_main_table(TABLE_MAIN_SESSION);
$params = array();
- $params['promotion_id'] = 0;
+ $params['promotion_id'] = 0;
Database::update($t, $params, array('promotion_id = ?'=>$promotion_id));
-
+
$params['promotion_id'] = $promotion_id;
if (!empty($list)) {
foreach ($list as $session_id) {
$session_id= intval($session_id);
Database::update($t, $params, array('id = ?'=>$session_id));
- }
+ }
}
}
-
+
/**
* Updates a session status
* @param int session id
@@ -2071,9 +2071,9 @@ class SessionManager {
$params['visibility'] = $status;
Database::update($t, $params, array('id = ?'=>$session_id));
}
-
+
/**
- * Copies a session with the same data to a new session.
+ * Copies a session with the same data to a new session.
* The new copy is not assigned to the same promotion. @see suscribe_sessions_to_promotions() for that
* @param int Session ID
* @param bool Whether to copy the relationship with courses
@@ -2093,17 +2093,17 @@ class SessionManager {
public function copy_session($id, $copy_courses = true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false) {
$id = intval($id);
$params = self::fetch($id);
-
+
$params['name'] = $params['name'].' '.get_lang('CopyLabelSuffix');
$sid = self::add($params);
if (!is_numeric($sid) || empty($sid)) {
return false;
}
-
+
if ($copy_courses) {
// Register courses from the original session to the new session
$courses = self::get_course_list_by_session_id($id);
-
+
$short_courses = $new_short_courses = array();
if (is_array($courses) && count($courses)>0) {
foreach ($courses as $course) {
@@ -2111,7 +2111,7 @@ class SessionManager {
}
}
$courses = null;
-
+
//We will copy the current courses of the session to new courses
if (!empty($short_courses)) {
if ($create_new_courses) {
@@ -2119,35 +2119,35 @@ class SessionManager {
if (function_exists('ini_set')) {
ini_set('memory_limit','256M');
ini_set('max_execution_time',0);
- }
- $params = array();
- $params['skip_lp_dates'] = true;
-
+ }
+ $params = array();
+ $params['skip_lp_dates'] = true;
+
foreach ($short_courses as $course_data) {
$course_info = CourseManager::copy_course_simple($course_data['title'].' '.get_lang('CopyLabelSuffix'), $course_data['course_code'], $id, $sid, $params);
if ($course_info) {
//By default new elements are invisible
- if ($set_exercises_lp_invisible) {
+ if ($set_exercises_lp_invisible) {
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$list = new LearnpathList('', $course_info['code'], $sid);
$flat_list = $list->get_flat_list();
- if (!empty($flat_list)) {
- foreach($flat_list as $lp_id => $data) {
+ if (!empty($flat_list)) {
+ foreach($flat_list as $lp_id => $data) {
api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0 ,0, 0, 0, $sid);
api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0 ,0, 0, 0);
}
}
$quiz_table = Database::get_course_table(TABLE_QUIZ_TEST);
$course_id = $course_info['real_id'];
-
+
//@todo check this query
//Disabling quiz items
$sql = "UPDATE $quiz_table SET active = 0 WHERE c_id = $course_id ";
- Database::query($sql);
+ Database::query($sql);
}
$new_short_courses[] = $course_info['code'];
- }
- }
+ }
+ }
} else {
foreach($short_courses as $course_data) {
$new_short_courses[] = $course_data['code'];
@@ -2174,15 +2174,15 @@ class SessionManager {
}
return $sid;
}
-
+
static function user_is_general_coach($user_id, $session_id) {
$session_id = intval($session_id);
$user_id = intval($user_id);
- $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
+ $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = "SELECT DISTINCT id
FROM $session_table
WHERE session.id_coach = '".$user_id."' AND id = '$session_id'";
- $result = Database::query($sql);
+ $result = Database::query($sql);
if ($result && Database::num_rows($result)) {
return true;
}
@@ -2219,7 +2219,7 @@ class SessionManager {
}
}
}
-
+
static function get_session_by_course($course_code) {
$table_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$table_session = Database::get_main_table(TABLE_MAIN_SESSION);
@@ -2229,7 +2229,7 @@ class SessionManager {
$result = Database::query($sql);
return Database::store_result($result);
}
-
+
/**
* @todo Add constatns in a DB table
*/
@@ -2241,7 +2241,7 @@ class SessionManager {
//self::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION => get_lang('EnrollmentAnnulation'),
);
}
-
+
static function get_session_change_user_reasons_variations() {
return array (
self::SESSION_CHANGE_USER_REASON_SCHEDULE => array(
@@ -2252,7 +2252,7 @@ class SessionManager {
self::SESSION_CHANGE_USER_REASON_CLASSROOM => array(
'default' => get_lang('ClassRoomChanged'),
'from' => get_lang('ClassRoomChangedFrom'),
- 'to' => get_lang('ClassRoomChangedTo'),
+ 'to' => get_lang('ClassRoomChangedTo'),
),
self::SESSION_CHANGE_USER_REASON_LOCATION => array(
'default' => get_lang('LocationChanged'),
@@ -2261,32 +2261,32 @@ class SessionManager {
)
);
}
-
+
static function get_session_change_user_reasons_variations_by_id($id, $type) {
$reasons = self::get_session_change_user_reasons_variations();
- $my_reason = isset($reasons[$id]) ? $reasons[$id] : null;
- return isset($my_reason[$type]) ? $my_reason[$type] : null;
+ $my_reason = isset($reasons[$id]) ? $reasons[$id] : null;
+ return isset($my_reason[$type]) ? $my_reason[$type] : null;
}
-
+
static function get_session_changed_reason_label($id, $type) {
switch ($type) {
case 'origin':
break;
case 'destination':
- break;
+ break;
}
-
+
}
-
- /**
- * Gets the reason name
+
+ /**
+ * Gets the reason name
* @param int reason id
*/
static function get_session_change_user_reason($id) {
$reasons = self::get_session_change_user_reasons();
- return isset($reasons[$id]) ? $reasons[$id] : null;
+ return isset($reasons[$id]) ? $reasons[$id] : null;
}
-
+
/**
* Changes the user from one session to another due a reason
* @params int user_id
@@ -2300,9 +2300,9 @@ class SessionManager {
$old_session_id = intval($old_session_id);
$new_session_id = intval($new_session_id);
$reason_id = intval($reason_id);
-
- //self::unsubscribe_user_from_session($old_session_id, $user_id, $reason_id);
-
+
+ //self::unsubscribe_user_from_session($old_session_id, $user_id, $reason_id);
+
//$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
@@ -2321,86 +2321,86 @@ class SessionManager {
//Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$session_id' AND course_code='$course_code' AND id_user='$user_id'");
//if (Database::affected_rows()) {
// Update number of users in this relation
- $sql = "UPDATE $tbl_session_rel_course SET nbr_users = nbr_users - 1 WHERE id_session = '$old_session_id' AND course_code='$course_code'";
+ $sql = "UPDATE $tbl_session_rel_course SET nbr_users = nbr_users - 1 WHERE id_session = '$old_session_id' AND course_code='$course_code'";
Database::query($sql);
//}
}
}
-
+
//Deal with reasons
switch ($reason_id) {
case self::SESSION_CHANGE_USER_REASON_SCHEDULE:
case self::SESSION_CHANGE_USER_REASON_CLASSROOM:
- case self::SESSION_CHANGE_USER_REASON_LOCATION:
+ case self::SESSION_CHANGE_USER_REASON_LOCATION:
//Adding to the new session
self::suscribe_users_to_session($new_session_id, array($user_id), null, false);
-
+
//Setting move_to if session was provided
$sql = "UPDATE $tbl_session_rel_user SET moved_to = '$new_session_id'
WHERE id_session = '$old_session_id' AND id_user ='$user_id'";
Database::query($sql);
- break;
+ break;
case self::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION:
UserManager::deactivate_users(array($user_id));
break;
}
-
- $now = api_get_utc_datetime();
+
+ $now = api_get_utc_datetime();
//Setting the moved_status
$sql = "UPDATE $tbl_session_rel_user SET moved_status = $reason_id, moved_at = '$now'
- WHERE id_session = '$old_session_id' AND id_user ='$user_id'";
+ WHERE id_session = '$old_session_id' AND id_user ='$user_id'";
Database::query($sql);
-
- return true;
+
+ return true;
}
return;
}
-
+
/**
* Get users inside a course session
- */
+ */
static function get_users_in_course_session($course_code, $id_session, $sort, $direction, $from = null, $limit = null) {
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
-
+
$course_code = Database::escape_string($course_code);
$id_session = Database::escape_string($id_session);
$from = intval($from);
$limit = intval($limit);
-
+
$is_western_name_order = api_is_western_name_order();
-
+
//Select the number of users
- $sql = " SELECT DISTINCT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username, scru.id_user as is_subscribed
- FROM $tbl_session_rel_user sru INNER JOIN $tbl_user u ON (u.user_id=sru.id_user)
+ $sql = " SELECT DISTINCT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username, scru.id_user as is_subscribed
+ FROM $tbl_session_rel_user sru INNER JOIN $tbl_user u ON (u.user_id=sru.id_user)
LEFT JOIN $tbl_session_rel_course_rel_user scru ON (u.user_id = scru.id_user AND scru.course_code = '".$course_code."' )
WHERE sru.id_session = '$id_session' AND
sru.moved_to = 0 AND sru.moved_status <> ".SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION." AND
sru.relation_type<>".SESSION_RELATION_TYPE_RRHH;
$sql .= " ORDER BY $sort $direction ";
-
+
if (!empty($from) && !empty($limit)) {
- $sql .= " LIMIT $from, $limit";
- }
-
+ $sql .= " LIMIT $from, $limit";
+ }
+
$result = Database::query($sql);
if (Database::num_rows($result)) {
return Database::store_result($result);
}
return false;
}
-
+
static function get_count_users_in_course_session($course_code, $id_session) {
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-
+
//Select the number of users
$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
- WHERE srcru.id_user = sru.id_user AND
- srcru.id_session = sru.id_session AND
- srcru.course_code = '".Database::escape_string($course_code)."' AND
+ WHERE srcru.id_user = sru.id_user AND
+ srcru.id_session = sru.id_session AND
+ srcru.course_code = '".Database::escape_string($course_code)."' AND
srcru.id_session = '".intval($id_session)."' AND
(sru.moved_to = 0 AND sru.moved_status <> ".SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION.") AND
sru.relation_type<>".SESSION_RELATION_TYPE_RRHH;
@@ -2409,10 +2409,10 @@ class SessionManager {
if (Database::num_rows($result)) {
return Database::result($result,0,0);
}
- return 0;
+ return 0;
}
-
- /**
+
+ /**
* Get the list of coaches (only user ids)
* @param string course_code
* @param in session_id
@@ -2421,55 +2421,55 @@ class SessionManager {
static function get_session_course_coaches($course_code, $session_id) {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-
+
// Get coachs of the courses in session
$sql = "SELECT user.user_id FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
- WHERE session_rcru.id_user = user.user_id AND
- session_rcru.id_session = '".intval($session_id)."' AND
- session_rcru.course_code ='".Database::escape_string($course_code)."' AND
+ WHERE session_rcru.id_user = user.user_id AND
+ session_rcru.id_session = '".intval($session_id)."' AND
+ session_rcru.course_code ='".Database::escape_string($course_code)."' AND
session_rcru.status=2";
$result = Database::query($sql);
- return Database::store_result($result);
+ return Database::store_result($result);
}
-
+
static function get_session_course_coaches_by_user($course_code, $session_id, $user_id) {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-
+
// Get coachs of the courses in session
$sql = "SELECT user.user_id FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
- WHERE session_rcru.id_user = user.user_id AND
- session_rcru.id_session = '".intval($session_id)."' AND
- session_rcru.course_code ='".Database::escape_string($course_code)."' AND
+ WHERE session_rcru.id_user = user.user_id AND
+ session_rcru.id_session = '".intval($session_id)."' AND
+ session_rcru.course_code ='".Database::escape_string($course_code)."' AND
session_rcru.status=2";
$result = Database::query($sql);
- return Database::store_result($result);
+ return Database::store_result($result);
}
-
-
+
+
static function get_session_course_coaches_to_string($course_code, $session_id) {
$coaches = self::get_session_course_coaches($course_code, $session_id);
if (!empty($coaches)) {
- $coach_list = array();
+ $coach_list = array();
foreach ($coaches as $coach_info) {
$user_info = api_get_user_info($coach_info['user_id']);
$coach_list[] = $user_info['complete_name'];
- }
+ }
if (!empty($coach_list)) {
return implode(', ', $coach_list);
- }
- }
+ }
+ }
return get_lang('None');
}
-
+
static function delete_course_in_session($id_session, $course_code) {
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
-
+
$id_session = intval($id_session);
$course_code = Database::escape_string($course_code);
-
+
if (!empty($id_session) && !empty($course_code)) {
Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code = '$course_code'");
@@ -2478,7 +2478,7 @@ class SessionManager {
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code = '$course_code'");
Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
}
- }
+ }
static function get_sessions_by_user($user_id) {
$session_categories = UserManager::get_sessions_by_category($user_id);
@@ -2486,7 +2486,7 @@ class SessionManager {
if (!empty($session_categories)) {
foreach ($session_categories as $category) {
if (isset($category['sessions'])) {
- foreach ($category['sessions'] as $session) {
+ foreach ($category['sessions'] as $session) {
$session_array[] = $session;
}
}
@@ -2494,35 +2494,35 @@ class SessionManager {
}
return $session_array;
}
-
+
static function get_session_rel_user_by_moved_to($session_id, $user_id) {
- $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
- $sql = "SELECT id_session, moved_status, moved_at FROM $tbl_session_rel_user WHERE id_user = $user_id AND moved_to = $session_id LIMIT 1";
+ $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
+ $sql = "SELECT id_session, moved_status, moved_at FROM $tbl_session_rel_user WHERE id_user = $user_id AND moved_to = $session_id LIMIT 1";
$result = Database::query($sql);
$result = Database::store_result($result,'ASSOC');
return $result[0];
}
-
+
static function get_coaches_by_keyword($tag) {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
-
+
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
-
- $select ="SELECT user.user_id, lastname, firstname, username ";
+
+ $select ="SELECT user.user_id, lastname, firstname, username ";
$sql = " $select FROM $tbl_user user WHERE status='1'";
-
+
$tag = Database::escape_string($tag);
-
+
$where_condition = array();
if (!empty($tag)) {
$condition = ' LIKE "%'.$tag.'%"';
- $where_condition = array( "firstname $condition",
- "lastname $condition",
+ $where_condition = array( "firstname $condition",
+ "lastname $condition",
"username $condition"
);
$where_condition = ' AND ('.implode(' OR ', $where_condition).') ';
- }
-
+ }
+
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
@@ -2531,51 +2531,51 @@ class SessionManager {
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND status = 1';
}
- }
- $sql .= $where_condition.$order_clause;
+ }
+ $sql .= $where_condition.$order_clause;
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
-
+
/**
- * Returns a human readable string
+ * Returns a human readable string
* @params array An array with all the session dates
- * @return string
+ * @return string
*/
static function parse_session_dates($session_info) {
//This will clean the variables if 0000-00-00 00:00:00 the variable will be empty
$start_date = api_get_local_time($session_info['display_start_date'], null, null, true);
$end_date = api_get_local_time($session_info['display_end_date'], null, null, true);
-
+
if (!empty($start_date) && !empty($end_date)) {
//$msg_date = get_lang('From').' '.$start_date.' '.get_lang('To').' '.$end_date;
$msg_date = sprintf(get_lang('FromDateXToDateY'), $start_date, $end_date);
} else {
if (!empty($start_date)) {
$msg_date = get_lang('From').' '.$start_date;
- }
+ }
if (!empty($end_date)) {
$msg_date = get_lang('Until').' '.$end_date;
}
}
return $msg_date;
}
-
- static public function get_session_columns($list_type = 'simple') {
+
+ static public function get_session_columns($list_type = 'simple') {
//$activeurl = '?sidx=session_active';
//Column config
$operators = array('cn', 'nc');
$date_operators = array('gt', 'ge', 'lt', 'le');
-
+
switch ($list_type) {
case 'simple':
$columns = array(
- get_lang('Name'),
+ get_lang('Name'),
get_lang('SessionDisplayStartDate'),
get_lang('SessionDisplayEndDate'),
//get_lang('SessionCategoryName'),
//get_lang('Coach'),
- //get_lang('Status'),
+ //get_lang('Status'),
get_lang('Visibility'),
//get_lang('CourseTitle'),
);
@@ -2586,15 +2586,15 @@ class SessionManager {
// array('name'=>'category_name', 'index'=>'category_name', 'hidden' => 'true', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true', 'sopt' => $operators)),
//array('name'=>'access_start_date', 'index'=>'access_start_date', 'width'=>'60', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true')),
//array('name'=>'access_end_date', 'index'=>'access_end_date', 'width'=>'60', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true')),
- //array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
+ //array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
//array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
//for the bottom bar
- // 'searchoptions' => array(
- // 'defaultValue' => '1',
+ // 'searchoptions' => array(
+ // 'defaultValue' => '1',
// 'value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive')),
- //for the top bar
+ //for the top bar
//'editoptions' => array('value' => '" ":'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))
- //),
+ //),
//array('name'=>'course_code', 'index'=>'course_code', 'width'=>'40', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
//array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
@@ -2602,12 +2602,12 @@ class SessionManager {
break;
case 'complete':
$columns = array(
- get_lang('Name'),
+ get_lang('Name'),
get_lang('SessionDisplayStartDate'),
get_lang('SessionDisplayEndDate'),
//get_lang('SessionCategoryName'),
get_lang('Coach'),
- get_lang('Status'),
+ get_lang('Status'),
get_lang('Visibility'),
get_lang('CourseTitle'),
);
@@ -2618,32 +2618,32 @@ class SessionManager {
// array('name'=>'category_name', 'index'=>'category_name', 'hidden' => 'true', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true', 'sopt' => $operators)),
//array('name'=>'access_start_date', 'index'=>'access_start_date', 'width'=>'60', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true')),
//array('name'=>'access_end_date', 'index'=>'access_end_date', 'width'=>'60', 'align'=>'left', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true')),
- array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
+ array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)),
array('name'=>'session_active', 'index'=>'session_active', 'width'=>'25', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
//for the bottom bar
- 'searchoptions' => array(
- 'defaultValue' => '1',
+ 'searchoptions' => array(
+ 'defaultValue' => '1',
'value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive')),
- //for the top bar
+ //for the top bar
'editoptions' => array('value' => '" ":'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))
- ),
+ ),
//array('name'=>'course_code', 'index'=>'course_code', 'width'=>'40', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
array('name'=>'course_title', 'index'=>'course_title', 'width'=>'50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' =>'true','sopt' => $operators)),
);
break;
}
-
+
//Inject extra session fields
$session_field = new SessionField();
$session_field_option = new SessionFieldOption();
- $fields = $session_field->get_all(array('field_visible = ? AND field_filter = ?' => array(1, 1)), 'option_display_text');
-
+ $fields = $session_field->get_all(array('field_visible = ? AND field_filter = ?' => array(1, 1)), 'option_display_text');
+
$rules = array();
if (!empty($fields)) {
foreach ($fields as $field) {
$search_options = array();
- $type = 'text';
+ $type = 'text';
if (in_array($field['field_type'], array(ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_DOUBLE_SELECT))) {
$type = 'select';
$search_options['sopt'] = array('eq', 'ne'); //equal not equal
@@ -2662,7 +2662,7 @@ class SessionManager {
if (!empty($options)) {
foreach ($options as $option) {
- foreach ($option as $sub_option) {
+ foreach ($option as $sub_option) {
if ($sub_option['option_value'] == 0) {
$first_options[] = $sub_option['field_id'].'#'.$sub_option['id'].':'.$sub_option['option_display_text'];
} else {
@@ -2672,7 +2672,7 @@ class SessionManager {
}
$search_options['value'] = implode(';', $first_options);
- $search_options['dataInit'] = 'fill_second_select';
+ $search_options['dataInit'] = 'fill_second_select';
//First
$column_model[] = array(
@@ -2685,7 +2685,7 @@ class SessionManager {
'searchoptions' => $search_options
);
$columns[] = $field['field_display_text'].' (1)';
- $rules[] = array('field' => 'extra_'.$field['field_variable'], 'op' => 'cn');
+ $rules[] = array('field' => 'extra_'.$field['field_variable'], 'op' => 'cn');
//Second
$search_options['value'] = $field['id'].':';
@@ -2697,14 +2697,14 @@ class SessionManager {
'width' => '100',
'hidden' => 'true',
'search' => 'true',
- 'stype' => 'select',
+ 'stype' => 'select',
'searchoptions' => $search_options
- );
+ );
$columns[] = $field['field_display_text'].' (2)';
$rules[] = array('field' => 'extra_'.$field['field_variable'].'_second', 'op' => 'cn');
continue;
- } else {
- $search_options['value'] = $session_field_option->get_field_options_to_string($field['id'], false, 'option_display_text');
+ } else {
+ $search_options['value'] = $session_field_option->get_field_options_to_string($field['id'], false, 'option_display_text');
}
$column_model[] = array(
@@ -2715,25 +2715,25 @@ class SessionManager {
'search' => 'true',
'stype' => $type,
'searchoptions' => $search_options
- );
+ );
$columns[] = $field['field_display_text'];
- $rules[] = array('field' => 'extra_'.$field['field_variable'], 'op' => 'cn');
+ $rules[] = array('field' => 'extra_'.$field['field_variable'], 'op' => 'cn');
}
}
$column_model[] = array('name'=>'actions', 'index'=>'actions', 'width'=>'80', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false');
$columns[] = get_lang('Actions');
-
+
foreach ($column_model as $col_model) {
$simple_column_name[] = $col_model['name'];
}
-
+
$return_array = array(
- 'columns' => $columns,
- 'column_model' => $column_model,
+ 'columns' => $columns,
+ 'column_model' => $column_model,
'rules' => $rules,
- 'simple_column_name' => $simple_column_name
- );
+ 'simple_column_name' => $simple_column_name
+ );
return $return_array;
- }
+ }
}
diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php
index 59198955e2..735f4b54b0 100644
--- a/main/inc/lib/tracking.lib.php
+++ b/main/inc/lib/tracking.lib.php
@@ -32,15 +32,15 @@ class Tracking {
*/
public static function get_time_spent_on_the_platform($user_id, $time_filter = 'last_7_days', $start_date = null, $end_date = null) {
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
- $condition_time = null;
+ $condition_time = null;
if (empty($time_filter)) {
$time_filter = 'last_7_days';
- }
+ }
$today = api_get_utc_datetime();
-
+
switch ($time_filter) {
case 'last_7_days':
- $new_date = strtotime('-7 day');
+ $new_date = strtotime('-7 day');
$new_date = api_get_utc_datetime($new_date);
$condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
break;
@@ -51,24 +51,24 @@ class Tracking {
break;
case 'custom':
$start_date = Database::escape_string($start_date);
- $end_date = Database::escape_string($end_date);
-
+ $end_date = Database::escape_string($end_date);
+
if (!empty($start_date) && !empty($end_date)) {
$condition_time = ' AND (login_date >= "'.$start_date.'" AND logout_date <= "'.$end_date.'" ) ';
} else {
- if (!empty($start_date)) {
+ if (!empty($start_date)) {
$condition_time = ' AND (login_date >= "'.$start_date.'" ) ';
}
- if (!empty($end_date)) {
+ if (!empty($end_date)) {
$condition_time = ' AND (logout_date <= "'.$end_date.'" ) ';
}
- }
+ }
break;
}
$sql = 'SELECT login_date, logout_date FROM '.$tbl_track_login.'
WHERE login_user_id = '.intval($user_id).$condition_time;
-
+
$rs = Database::query($sql);
$nb_seconds = 0;
@@ -134,7 +134,7 @@ class Tracking {
$sql = "SELECT SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
FROM $tbl_track_course
WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) AND course_code='$course_code' AND session_id = '$session_id' $condition_user";
-
+
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
return $row['nb_seconds'];
@@ -250,12 +250,12 @@ class Tracking {
$session_id = intval($session_id);
$tbl_track_e_course_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
- $sql = 'SELECT login_course_date
+ $sql = 'SELECT login_course_date
FROM '.$tbl_track_e_course_access.'
- WHERE user_id = '.$student_id.' AND
- course_code = "'.$course_code.'" AND
+ WHERE user_id = '.$student_id.' AND
+ course_code = "'.$course_code.'" AND
session_id = '.$session_id.'
- ORDER BY login_course_date DESC
+ ORDER BY login_course_date DESC
LIMIT 0,1';
$rs = Database::query($sql);
@@ -266,13 +266,13 @@ class Tracking {
}
//$last_login_date_timestamp = api_strtotime($last_login_date, 'UTC');
//see #5736
- $last_login_date_timestamp = api_strtotime($last_login_date);
-
+ $last_login_date_timestamp = api_strtotime($last_login_date);
+
$now = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
if ($now - $last_login_date_timestamp > 604800) {
- if ($convert_date) {
+ if ($convert_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
$icon = api_is_allowed_to_edit() ? '
': null;
return $icon. Display::label($last_login_date, 'warning');
@@ -365,7 +365,7 @@ class Tracking {
*/
public static function get_avg_student_exercise_score($student_id, $course_code, $exercise_id = 0, $session_id = null) {
$course_info = api_get_course_info($course_code);
-
+
if (!empty($course_info)) {
// table definition
$tbl_course_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
@@ -384,32 +384,32 @@ class Tracking {
$session_id = intval($session_id);
$condition_session = " AND session_id = $session_id ";
}
- $sql = "SELECT count(id) FROM $tbl_course_quiz
- WHERE c_id = {$course_info['real_id']} AND active <> -1 $condition_quiz ";
+ $sql = "SELECT count(id) FROM $tbl_course_quiz
+ WHERE c_id = {$course_info['real_id']} AND active <> -1 $condition_quiz ";
$count_quiz = Database::fetch_row(Database::query($sql));
if (!empty($count_quiz[0]) && !empty($student_id)) {
- $condition_user = "";
+ $condition_user = "";
if (is_array($student_id)) {
$condition_user = " AND exe_user_id IN (".implode(',',$student_id).") ";
} else {
$condition_user = " AND exe_user_id = '$student_id' ";
}
- if (empty($exercise_id)) {
- $sql = "SELECT id FROM $tbl_course_quiz
+ if (empty($exercise_id)) {
+ $sql = "SELECT id FROM $tbl_course_quiz
WHERE c_id = {$course_info['real_id']} AND active <> -1 $condition_quiz";
$result = Database::query($sql);
$exercise_list = array();
$exercise_id = null;
if (Database::num_rows($result)) {
- while ($row = Database::fetch_array($result)) {
+ while ($row = Database::fetch_array($result)) {
$exercise_list[] = $row['id'];
}
}
if (!empty($exercise_list)) {
$exercise_id = implode("','",$exercise_list);
- }
+ }
}
$count_quiz = Database::fetch_row(Database::query($sql));
@@ -423,19 +423,19 @@ class Tracking {
exe_cours_id = '$course_code' AND
orig_lp_item_id = 0 $condition_session
ORDER BY exe_date DESC";
-
+
$res = Database::query($sql);
$row = Database::fetch_array($res);
$quiz_avg_score = 0;
-
- if (!empty($row['avg_score'])) {
- $quiz_avg_score = round($row['avg_score'],2);
+
+ if (!empty($row['avg_score'])) {
+ $quiz_avg_score = round($row['avg_score'],2);
}
-
- if(!empty($row['num_attempts'])) {
- $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
+
+ if(!empty($row['num_attempts'])) {
+ $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
}
- if (is_array($student_id)) {
+ if (is_array($student_id)) {
$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
}
return $quiz_avg_score;
@@ -446,7 +446,7 @@ class Tracking {
/**
- * Get count student's exercise COMPLETED attempts
+ * Get count student's exercise COMPLETED attempts
* @param int Student id
* @param string Course code
* @param int Exercise id
@@ -464,7 +464,7 @@ class Tracking {
if (!empty($lp_id)) $lp_id = intval($lp_id);
if (!empty($lp_item_id)) $lp_id = intval($lp_item_id);
-
+
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercices AS ex
@@ -473,13 +473,13 @@ class Tracking {
AND status = ''
AND orig_lp_id = $lp_id
AND orig_lp_item_id = $lp_item_id
- AND exe_user_id= $student_id
+ AND exe_user_id= $student_id
AND session_id = $session_id ";
-
+
$rs = Database::query($sql);
$row = Database::fetch_row($rs);
$count_attempts = $row[0];
-
+
return $count_attempts;
}
@@ -489,32 +489,32 @@ class Tracking {
* @param string course code
* @param int session id
*/
-
+
static function get_exercise_student_progress($exercise_list, $user_id, $course_code, $session_id) {
$course_code = Database::escape_string($course_code);
$user_id = intval($user_id);
- $session_id = intval($session_id);
-
+ $session_id = intval($session_id);
+
if (empty($exercise_list)) {
return '0%';
- }
+ }
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $exercise_list = array_keys($exercise_list);
+ $exercise_list = array_keys($exercise_list);
$exercise_list = array_map('intval', $exercise_list);
-
+
$exercise_list_imploded = implode("' ,'", $exercise_list);
-
+
$sql = "SELECT COUNT(DISTINCT ex.exe_exo_id) FROM $tbl_stats_exercices AS ex
WHERE ex.exe_cours_id = '$course_code' AND
ex.session_id = $session_id AND
ex.exe_user_id = $user_id AND ex.exe_exo_id IN ('$exercise_list_imploded') ";
-
+
$rs = Database::query($sql);
$count = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$count = $row[0];
- }
+ }
$count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
return $count;
}
@@ -524,19 +524,19 @@ class Tracking {
$result = 0;
if (!empty($exercise_list)) {
foreach ($exercise_list as $exercise_data) {
- $exercise_id = $exercise_data['id'];
+ $exercise_id = $exercise_data['id'];
$best_attempt = get_best_attempt_exercise_results_per_user($user_id, $exercise_id , $course_code, $session_id);
- if (!empty($best_attempt)) {
- $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
+ if (!empty($best_attempt)) {
+ $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
}
}
$result = $result/ count($exercise_list);
$result = round($result, 2)*100;
}
-
- return $result.'%';
-
+
+ return $result.'%';
+
}
/**
@@ -589,11 +589,11 @@ class Tracking {
}
// Get last view for each student (in case of multi-attempt)
// Also filter on LPs of this session
- $sql_maxes = "SELECT MAX(view_count), progress FROM $tbl_course_lp_view lp_view
- WHERE c_id = {$course_info['real_id']} AND
- $condition_user session_id = $session_id AND
- lp_view.lp_id IN (".implode(',',$lp_id).")
- GROUP BY lp_id, user_id";
+ $sql_maxes = "SELECT MAX(view_count), progress FROM $tbl_course_lp_view lp_view
+ WHERE c_id = {$course_info['real_id']} AND
+ $condition_user session_id = $session_id AND
+ lp_view.lp_id IN (".implode(',',$lp_id).")
+ GROUP BY lp_id, user_id";
$res_maxes = Database::query($sql_maxes);
$sum = 0;
while ($row_maxes = Database::fetch_array($res_maxes)) {
@@ -640,7 +640,7 @@ class Tracking {
}
if ($debug) echo 'Tracking::get_avg_student_score
';
- // get global tables names
+ // get global tables names
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@@ -654,7 +654,7 @@ class Tracking {
$lp_item_table = Database :: get_course_table(TABLE_LP_ITEM);
$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
-
+
$course_id = $course['real_id'];
// Compose a filter based on optional learning paths list given
@@ -668,7 +668,7 @@ class Tracking {
$condition_session = "";
$session_id = intval($session_id);
-
+
if (count($lp_ids) > 0) {
$condition_session = " AND session_id = $session_id ";
} else {
@@ -715,10 +715,10 @@ class Tracking {
// Getting latest LP result for a student
//@todo problem when a course have more than 1500 users
$sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id FROM $lp_view_table
- WHERE c_id = $course_id AND
- lp_id IN (".implode(',',$lp_list).")
- $condition_user1 AND
- session_id = $session_id
+ WHERE c_id = $course_id AND
+ lp_id IN (".implode(',',$lp_list).")
+ $condition_user1 AND
+ session_id = $session_id
GROUP BY lp_id, user_id";
if ($debug) echo $sql;
$rs_last_lp_view_id = Database::query($sql);
@@ -726,7 +726,7 @@ class Tracking {
$global_result = 0;
if (Database::num_rows($rs_last_lp_view_id) > 0) {
- // Cycle through each line of the results (grouped by lp_id, user_id)
+ // Cycle through each line of the results (grouped by lp_id, user_id)
while ($row_lp_view = Database::fetch_array($rs_last_lp_view_id)) {
$count_items = 0;
$lp_partial_total = 0;
@@ -738,12 +738,12 @@ class Tracking {
$user_id = $row_lp_view['user_id'];
if ($debug) echo 'LP id '.$lp_id.'
';
- if ($get_only_latest_attempt_results) {
+ if ($get_only_latest_attempt_results) {
//Getting lp_items done by the user
- $sql = "SELECT DISTINCT lp_item_id
+ $sql = "SELECT DISTINCT lp_item_id
FROM $lp_item_view_table
- WHERE c_id = $course_id AND
- lp_view_id = $lp_view_id
+ WHERE c_id = $course_id AND
+ lp_view_id = $lp_view_id
ORDER BY lp_item_id";
$res_lp_item = Database::query($sql);
@@ -751,22 +751,22 @@ class Tracking {
$my_lp_item_id = $row_lp_item['lp_item_id'];
//Getting the most recent attempt
- $sql = "SELECT lp_iv.id as lp_item_view_id,
+ $sql = "SELECT lp_iv.id as lp_item_view_id,
lp_iv.score as score,
- lp_i.max_score,
- lp_iv.max_score as max_score_item_view,
- lp_i.path,
- lp_i.item_type,
+ lp_i.max_score,
+ lp_iv.max_score as max_score_item_view,
+ lp_i.path,
+ lp_i.item_type,
lp_i.id as iid
- FROM $lp_item_view_table as lp_iv
- INNER JOIN $lp_item_table as lp_i
- ON lp_i.id = lp_iv.lp_item_id AND
- lp_iv.c_id = $course_id AND
- lp_i.c_id = $course_id AND
- (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
- WHERE lp_item_id = $my_lp_item_id AND
- lp_view_id = $lp_view_id
- ORDER BY view_count DESC
+ FROM $lp_item_view_table as lp_iv
+ INNER JOIN $lp_item_table as lp_i
+ ON lp_i.id = lp_iv.lp_item_id AND
+ lp_iv.c_id = $course_id AND
+ lp_i.c_id = $course_id AND
+ (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
+ WHERE lp_item_id = $my_lp_item_id AND
+ lp_view_id = $lp_view_id
+ ORDER BY view_count DESC
LIMIT 1";
$res_lp_item_result = Database::query($sql);
while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
@@ -776,15 +776,15 @@ class Tracking {
} else {
// For the currently analysed view, get the score and
// max_score of each item if it is a sco or a TOOL_QUIZ
- $sql_max_score = "SELECT lp_iv.id as lp_item_view_id,
+ $sql_max_score = "SELECT lp_iv.id as lp_item_view_id,
lp_iv.score as score,
- lp_i.max_score,
- lp_iv.max_score as max_score_item_view,
- lp_i.path,
- lp_i.item_type,
+ lp_i.max_score,
+ lp_iv.max_score as max_score_item_view,
+ lp_i.path,
+ lp_i.item_type,
lp_i.id as iid
- FROM $lp_item_view_table as lp_iv
- INNER JOIN $lp_item_table as lp_i
+ FROM $lp_item_view_table as lp_iv
+ INNER JOIN $lp_item_table as lp_i
ON lp_i.id = lp_iv.lp_item_id AND
lp_iv.c_id = $course_id AND
lp_i.c_id = $course_id AND
@@ -793,14 +793,14 @@ class Tracking {
if ($debug) echo $sql_max_score.'
';
$res_max_score = Database::query($sql_max_score);
-
+
while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
$list[]= $row_max_score;
}
- }
+ }
// Go through each scorable element of this view
-
+
$score_of_scorm_calculate = 0;
foreach ($list as $row_max_score) {
@@ -837,12 +837,12 @@ class Tracking {
// Get last attempt to this exercise through
// the current lp for the current user
$sql_last_attempt = "SELECT exe_id FROM $tbl_stats_exercices WHERE
- exe_exo_id = '$item_path' AND
- exe_user_id = $user_id AND
- orig_lp_item_id = $item_id AND
- orig_lp_item_view_id = $lp_item_view_id AND
+ exe_exo_id = '$item_path' AND
+ exe_user_id = $user_id AND
+ orig_lp_item_id = $item_id AND
+ orig_lp_item_view_id = $lp_item_view_id AND
exe_cours_id = '$course_code' AND
- session_id = $session_id
+ session_id = $session_id
ORDER BY exe_date DESC LIMIT 1";
if ($debug) echo $sql_last_attempt .'
';
$result_last_attempt = Database::query($sql_last_attempt);
@@ -860,16 +860,16 @@ class Tracking {
// the max_scores of all questions that it was
// made of (we need to make this call dynamic because of random questions selection)
$sql = "SELECT SUM(t.ponderation) as maxscore FROM
- (
- SELECT DISTINCT question_id, marks, ponderation
- FROM $tbl_stats_attempts AS at INNER JOIN $tbl_quiz_questions AS q ON (q.id = at.question_id)
+ (
+ SELECT DISTINCT question_id, marks, ponderation
+ FROM $tbl_stats_attempts AS at INNER JOIN $tbl_quiz_questions AS q ON (q.id = at.question_id)
WHERE exe_id ='$id_last_attempt' AND q.c_id = $course_id
)
AS t";
if ($debug) echo '$sql: '.$sql.'
';
$res_max_score_bis = Database::query($sql);
$row_max_score_bis = Database::fetch_array($res_max_score_bis);
-
+
if (!empty($row_max_score_bis['maxscore'])) {
$max_score = $row_max_score_bis['maxscore'];
}
@@ -897,7 +897,7 @@ class Tracking {
if ($debug) echo '$count_items '.$count_items.'
';
if ($debug) echo '$score_of_scorm_calculate '.$score_of_scorm_calculate.'
';
-
+
// var_dump($score_of_scorm_calculate);
$global_result += $score_of_scorm_calculate;
if ($debug) echo '$global_result '.$global_result.'
';
@@ -908,7 +908,7 @@ class Tracking {
if ($debug) var_dump($lp_list);
foreach ($lp_list as $lp_id) {
//Check if LP have a score we asume that all SCO have an score
- $sql = "SELECT count(id) as count FROM $lp_item_table
+ $sql = "SELECT count(id) as count FROM $lp_item_table
WHERE c_id = $course_id AND (item_type = 'quiz' OR item_type = 'sco') AND lp_id = ".$lp_id;
if ($debug) echo $sql;
$result_have_quiz = Database::query($sql);
@@ -965,7 +965,7 @@ class Tracking {
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$t_lpv = Database :: get_course_table(TABLE_LP_VIEW);
$t_lpiv = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
-
+
$course_id = $course['real_id'];
// Compose a filter based on optional learning paths list given
@@ -978,7 +978,7 @@ class Tracking {
$condition_session = "";
$session_id = intval($session_id);
-
+
if (isset($session_id)) {
$condition_session = " AND session_id = $session_id ";
}
@@ -999,9 +999,9 @@ class Tracking {
ON item_view.lp_view_id = view.id
WHERE
item_view.c_id = '.$course_id.' AND
- view.c_id = '.$course_id.' AND
+ view.c_id = '.$course_id.' AND
view.lp_id = '.$lp_id.'
- AND view.user_id = '.$student_id.' AND
+ AND view.user_id = '.$student_id.' AND
session_id = '.$session_id;
$rs = Database::query($sql);
@@ -1029,7 +1029,7 @@ class Tracking {
$session_id = intval($session_id);
if (!empty($course)) {
-
+
$course_id = $course['real_id'];
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
@@ -1049,9 +1049,9 @@ class Tracking {
ON item_view.lp_view_id = view.id
WHERE
item_view.c_id = '.$course_id.' AND
- view.c_id = '.$course_id.' AND
+ view.c_id = '.$course_id.' AND
view.lp_id = '.$lp_id.'
- AND view.user_id = '.$student_id.'
+ AND view.user_id = '.$student_id.'
AND view.session_id = '.$session_id;
$rs = Database::query($sql);
if (Database :: num_rows($rs) > 0) {
@@ -1080,8 +1080,7 @@ class Tracking {
// At first, courses where $coach_id is coach of the course //
$sql = 'SELECT id_session, course_code FROM ' . $tbl_session_course_user . ' WHERE id_user=' . $coach_id.' AND status=2';
- global $_configuration;
- if ($_configuration['multiple_access_urls']) {
+ if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
@@ -1121,7 +1120,7 @@ class Tracking {
INNER JOIN ' . $tbl_session . ' as session
ON session.id = session_course.id_session
AND session.id_coach = ' . $coach_id;
- if ($_configuration['multiple_access_urls']) {
+ if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
@@ -1140,7 +1139,6 @@ class Tracking {
}
$result = Database::query($sql);
-
while ($row = Database::fetch_array($result)) {
$a_students[$row['id_user']] = $row['id_user'];
}
@@ -1258,7 +1256,7 @@ class Tracking {
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
// At first, courses where $coach_id is coach of the course
-
+
$sql = 'SELECT DISTINCT course_code FROM ' . $tbl_session_course_user . ' WHERE id_user=' . $coach_id.' AND status=2';
global $_configuration;
@@ -1278,9 +1276,9 @@ class Tracking {
while ($row = Database::fetch_array($result)) {
$a_courses[$row['course_code']] = $row['course_code'];
}
-
+
// Then, courses where $coach_id is coach of the session
-
+
$sql = 'SELECT DISTINCT session_course.course_code
FROM ' . $tbl_session_course . ' as session_course
INNER JOIN ' . $tbl_session . ' as session
@@ -1314,7 +1312,7 @@ class Tracking {
$sql .= ' WHERE access_url_id = '.$access_url_id;
}
- $result = Database::query($sql);
+ $result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$a_courses[$row['course_code']] = $row['course_code'];
}
@@ -1332,7 +1330,7 @@ class Tracking {
$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);
-
+
// protect datas
$coach_id = intval($coach_id);
@@ -1456,7 +1454,7 @@ class Tracking {
// table definition
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
-
+
$course_id = $a_course['real_id'];
$condition_user = "";
@@ -1472,13 +1470,13 @@ class Tracking {
$condition_session = " AND pub.session_id = $session_id ";
}
- $sql = "SELECT count(ip.tool)
- FROM $tbl_item_property ip INNER JOIN $tbl_document pub
- ON ip.ref = pub.id
- WHERE ip.c_id = $course_id AND
+ $sql = "SELECT count(ip.tool)
+ FROM $tbl_item_property ip INNER JOIN $tbl_document pub
+ ON ip.ref = pub.id
+ WHERE ip.c_id = $course_id AND
pub.c_id = $course_id AND
pub.filetype ='file' AND
- ip.tool = 'document'
+ ip.tool = 'document'
$condition_user $condition_session ";
$rs = Database::query($sql);
$row = Database::fetch_row($rs);
@@ -1504,7 +1502,7 @@ class Tracking {
// table definition
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$tbl_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
-
+
$course_id = $a_course['real_id'];
$condition_user = "";
@@ -1520,12 +1518,12 @@ class Tracking {
$condition_session = " AND pub.session_id = $session_id ";
}
- $sql = "SELECT count(ip.tool)
- FROM $tbl_item_property ip INNER JOIN $tbl_student_publication pub
- ON ip.ref = pub.id
- WHERE ip.c_id = $course_id AND
+ $sql = "SELECT count(ip.tool)
+ FROM $tbl_item_property ip INNER JOIN $tbl_student_publication pub
+ ON ip.ref = pub.id
+ WHERE ip.c_id = $course_id AND
pub.c_id = $course_id AND
- ip.tool='work'
+ ip.tool='work'
$condition_user $condition_session ";
$rs = Database::query($sql);
$row = Database::fetch_row($rs);
@@ -1543,7 +1541,7 @@ class Tracking {
* @return int Count of messages
*/
public static function count_student_messages($student_id, $course_code, $session_id = null) {
-
+
// protect datas
$student_id = intval($student_id);
$course_code = addslashes($course_code);
@@ -1552,11 +1550,11 @@ class Tracking {
$a_course = CourseManager :: get_course_information($course_code);
if (!empty($a_course)) {
-
+
// table definition
$tbl_forum_post = Database :: get_course_table(TABLE_FORUM_POST);
$tbl_forum = Database :: get_course_table(TABLE_FORUM);
-
+
$course_id = $a_course['real_id'];
$condition_user = "";
@@ -1572,11 +1570,11 @@ class Tracking {
$condition_session = " AND forum.session_id = $session_id";
}
- $sql = "SELECT 1 FROM $tbl_forum_post post INNER JOIN $tbl_forum forum
- ON forum.forum_id = post.forum_id
+ $sql = "SELECT 1 FROM $tbl_forum_post post INNER JOIN $tbl_forum forum
+ ON forum.forum_id = post.forum_id
WHERE post.c_id = $course_id AND
forum.c_id = $course_id
- $condition_user $condition_session ";
+ $condition_user $condition_session ";
$rs = Database::query($sql);
return Database::num_rows($rs);
} else {
@@ -1599,20 +1597,20 @@ class Tracking {
if (!empty($a_course)) {
$tbl_posts = Database :: get_course_table(TABLE_FORUM_POST);
$tbl_forums = Database :: get_course_table(TABLE_FORUM);
-
+
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
$condition_session = ' AND f.session_id = '. $session_id;
}
-
+
$course_id = $a_course['real_id'];
-
- $sql = "SELECT count(*) FROM $tbl_posts p INNER JOIN $tbl_forums f
+
+ $sql = "SELECT count(*) FROM $tbl_posts p INNER JOIN $tbl_forums f
ON f.forum_id = p.forum_id
- WHERE p.c_id = $course_id AND
+ WHERE p.c_id = $course_id AND
f.c_id = $course_id
- $condition_session
+ $condition_session
";
$result = Database::query($sql);
$row = Database::fetch_row($result);
@@ -1633,11 +1631,11 @@ class Tracking {
$course_info = api_get_course_info($course_code);
if (empty($course_info)) {
return null;
- }
+ }
$course_id = $course_info['real_id'];
-
+
$count = 0;
-
+
$tbl_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$tbl_forums = Database :: get_course_table(TABLE_FORUM);
$condition_session = '';
@@ -1645,8 +1643,8 @@ class Tracking {
$session_id = intval($session_id);
$condition_session = ' AND f.session_id = '. $session_id;
}
-
- $sql = "SELECT count(*) FROM $tbl_threads t INNER JOIN $tbl_forums f ON f.forum_id = t.forum_id
+
+ $sql = "SELECT count(*) FROM $tbl_threads t INNER JOIN $tbl_forums f ON f.forum_id = t.forum_id
WHERE t.c_id = $course_id AND f.c_id = $course_id $condition_session ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@@ -1668,14 +1666,14 @@ class Tracking {
$course_info = api_get_course_info($course_code);
if (empty($course_info)) {
return null;
- }
+ }
$course_id = $course_info['real_id'];
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
$condition_session = ' session_id = '. $session_id;
- }
+ }
$tbl_forums = Database :: get_course_table(TABLE_FORUM);
$sql = "SELECT count(*) FROM $tbl_forums WHERE c_id = $course_id AND $condition_session";
@@ -1696,26 +1694,26 @@ class Tracking {
* @param int Session id (optional)
* @return int Chat last connections by course in x days
*/
- public static function chat_connections_during_last_x_days_by_course($course_code,$last_days, $session_id = 0) {
+ public static function chat_connections_during_last_x_days_by_course($course_code,$last_days, $session_id = 0) {
$course_info = api_get_course_info($course_code);
if (empty($course_info)) {
return null;
- }
+ }
$course_id = $course_info['real_id'];
-
+
//protect data
$last_days = intval($last_days);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
-
+
$count = 0;
-
+
$tbl_stats_access = Database :: get_statistic_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' ";
$result = Database::query($sql);
- if (Database::num_rows($result)) {
+ if (Database::num_rows($result)) {
$row = Database::fetch_row($result);
$count = $row[0];
return $count;
@@ -1919,7 +1917,7 @@ class Tracking {
* @param int User id
* @param string Course id
* @return float average of test
- * @author isaac flores paz
+ * @author isaac flores paz
* @deprecated get_avg_student_score should be use
*/
public static function get_average_test_scorm_and_lp ($user_id, $course_id) {
@@ -1927,12 +1925,12 @@ class Tracking {
//the score inside the Reporting table
$course_info = api_get_course_info($course_id);
$course_id = $course_info['real_id'];
-
+
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
$lp_item_table = Database :: get_course_table(TABLE_LP_ITEM);
-
+
$sql_type = "SELECT id, lp_type FROM $lp_table WHERE c_id = $course_id";
$rs_type=Database::query($sql_type);
$average_data=0;
@@ -1947,12 +1945,12 @@ class Tracking {
$rs_last_lp_view_id = Database::query($sql);
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id'));
- $sql_list_view="SELECT li.max_score,lv.user_id,liw.score,(liw.score/li.max_score) as sum_data
+ $sql_list_view="SELECT li.max_score,lv.user_id,liw.score,(liw.score/li.max_score) as sum_data
FROM $lp_item_table li INNER JOIN $lp_view_table lv
- ON li.lp_id=lv.lp_id INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id
- WHERE li.c_id = $course_id AND
+ ON li.lp_id=lv.lp_id INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id
+ WHERE li.c_id = $course_id AND
liw.c_id = $course_id AND
- lv.c_id = $course_id AND
+ lv.c_id = $course_id AND
lv.user_id= $user_id AND li.item_type = 'quiz' AND liw.lp_view_id= $lp_view_id";
$sum=0;
$tot=0;
@@ -1975,12 +1973,12 @@ class Tracking {
$rs_last_lp_view_id = Database::query($sql);
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id'));
- $sql_list_view = "SELECT li.max_score,lv.user_id,liw.score,((liw.score/li.max_score)*100) as sum_data
+ $sql_list_view = "SELECT li.max_score,lv.user_id,liw.score,((liw.score/li.max_score)*100) as sum_data
FROM $lp_item_table li INNER JOIN $lp_view_table lv
- ON li.lp_id=lv.lp_id INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id
- WHERE li.c_id = $course_id AND
+ ON li.lp_id=lv.lp_id INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id
+ WHERE li.c_id = $course_id AND
liw.c_id = $course_id AND
- lv.c_id = $course_id AND
+ lv.c_id = $course_id AND
lv.user_id= $user_id AND (li.item_type = 'sco' OR li.item_type='quiz') AND liw.lp_view_id = $lp_view_id";
$tot=0;
$sum=0;
@@ -2006,7 +2004,7 @@ class Tracking {
foreach($lp_list as $lp_id) {
//check if LP have a score
- $sql = "SELECT count(id) as count FROM $lp_item_table
+ $sql = "SELECT count(id) as count FROM $lp_item_table
WHERE c_id = $course_id AND item_type = 'quiz' AND lp_id = ".$lp_id." ";
$result_have_quiz = Database::query($sql);
@@ -2102,9 +2100,9 @@ class Tracking {
//protect data
$course_code = Database::escape_string($course_code);
$course_info = api_get_course_info($course_code);
-
- $course_id = $course_info['real_id'];
-
+
+ $course_id = $course_info['real_id'];
+
$data = array();
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
@@ -2118,7 +2116,7 @@ class Tracking {
$sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits
FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
- WHERE cl.c_id = $course_id AND
+ WHERE cl.c_id = $course_id AND
sl.links_link_id = cl.id
AND sl.links_cours_id = '$course_code'
$condition_session
@@ -2144,10 +2142,10 @@ class Tracking {
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
- $tbl_access_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+ $tbl_access_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_access_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
-
+
$user_id = intval($user_id);
// get course list
@@ -2156,19 +2154,19 @@ class Tracking {
FROM '.$tbl_course_user.' cu INNER JOIN '.$tbl_access_rel_course.' a ON(a.course_code = cu.course_code) INNER JOIN '.$tbl_course.' c ON( cu.course_code = c.code)
WHERE user_id='.$user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND access_url_id = '.api_get_current_access_url_id().' ORDER BY title ';
} else {
- $sql = 'SELECT course_code as code, title FROM '.$tbl_course_user.' u INNER JOIN '.$tbl_course.' c ON(course_code = c.code)
+ $sql = 'SELECT course_code as code, title FROM '.$tbl_course_user.' u INNER JOIN '.$tbl_course.' c ON(course_code = c.code)
WHERE u.user_id='.$user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH.' ORDER BY title ';
}
$rs = Database::query($sql);
- $courses = $course_in_session = $temp_course_in_session = array();
+ $courses = $course_in_session = $temp_course_in_session = array();
while($row = Database :: fetch_array($rs, 'ASSOC')) {
$courses[$row['code']] = $row['title'];
}
-
+
// Get the list of sessions where the user is subscribed as student
if ($_configuration['multiple_access_urls']) {
- $sql = 'SELECT DISTINCT cu.course_code, id_session as session_id, name FROM '.$tbl_session_course_user.' cu INNER JOIN '.$tbl_access_rel_session.' a ON(a.session_id = cu.id_session) INNER JOIN '.$tbl_session.' s ON(s.id = a.session_id)
+ $sql = 'SELECT DISTINCT cu.course_code, id_session as session_id, name FROM '.$tbl_session_course_user.' cu INNER JOIN '.$tbl_access_rel_session.' a ON(a.session_id = cu.id_session) INNER JOIN '.$tbl_session.' s ON(s.id = a.session_id)
WHERE id_user='.$user_id.' AND access_url_id = '.api_get_current_access_url_id().' ORDER BY name ';
} else {
$sql = 'SELECT DISTINCT course_code, id_session as session_id, name FROM '.$tbl_session_course_user.' u INNER JOIN '.$tbl_session.' s ON(s.id = u.id_session)
@@ -2182,27 +2180,27 @@ class Tracking {
$temp_course_in_session[$row['session_id']]['course_list'][$course_info['id']] = $course_info;
$temp_course_in_session[$row['session_id']]['name'] = $row['name'];
$simple_session_array[$row['session_id']] = $row['name'];
- }
+ }
foreach($simple_session_array as $my_session_id => $session_name) {
$course_list = $temp_course_in_session[$my_session_id]['course_list'];
- $my_course_data = array();
+ $my_course_data = array();
foreach ($course_list as $course_data) {
$my_course_data[$course_data['id']] = $course_data['title'];
}
- $my_course_data = utf8_sort($my_course_data);
+ $my_course_data = utf8_sort($my_course_data);
$final_course_data = array();
-
+
foreach($my_course_data as $course_id => $value) {
$final_course_data[$course_id] = $course_list[$course_id];
}
$course_in_session[$my_session_id]['course_list'] = $final_course_data;
$course_in_session[$my_session_id]['name'] = $session_name;
- }
-
+ }
+
$html = '';
// Course list
-
+
if ($show_courses) {
if (!empty($courses)) {
$html .= Display::page_subheader(Display::return_icon('course.png', get_lang('MyCourses'), array(), ICON_SIZE_SMALL).' '.get_lang('MyCourses'));
@@ -2212,7 +2210,7 @@ class Tracking {
'.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
- '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
';
@@ -2221,10 +2219,10 @@ class Tracking {
$total_time_login = Tracking :: get_time_spent_on_the_course($user_id, $course_code);
$time = api_time_to_hms($total_time_login);
- $progress = Tracking :: get_avg_student_progress($user_id, $course_code);
+ $progress = Tracking :: get_avg_student_progress($user_id, $course_code);
$percentage_score = Tracking :: get_avg_student_score($user_id, $course_code, array());
$last_connection = Tracking :: get_last_connection_date_on_the_course($user_id, $course_code);
-
+
if (is_null($progress)) {
$progress = '0%';
} else {
@@ -2269,50 +2267,50 @@ class Tracking {
// Session list
if (!empty($course_in_session)) {
$main_session_graph = '';
-
+
if (!isset($_GET['session_id']) && !isset($_GET['course'])) {
-
- //Load graphics only when calling to an specific session
+
+ //Load graphics only when calling to an specific session
$session_graph = array();
-
+
$all_exercise_graph_name_list = array();
$my_results = array();
$all_exercise_graph_list = array();
-
+
$all_exercise_start_time = array();
-
+
foreach ($course_in_session as $my_session_id => $session_data) {
-
- $course_list = $session_data['course_list'];
+
+ $course_list = $session_data['course_list'];
$session_name = $session_data['name'];
-
+
$user_count = count(SessionManager::get_users_by_session($my_session_id));
-
+
$exercise_graph_name_list = array();
//$user_results = array();
$exercise_graph_list = array();
-
+
foreach ($course_list as $course_data) {
-
+
$exercise_list = get_all_exercises($course_data, $my_session_id);
-
- foreach ($exercise_list as $exercise_data) {
+
+ foreach ($exercise_list as $exercise_data) {
$exercise_obj = new Exercise($course_data['id']);
$exercise_obj->read($exercise_data['id']);
//Exercise is not necessary to be visible to show results check the result_disable configuration instead
//$visible_return = $exercise_obj->is_visible();
-
+
if ($exercise_data['results_disabled'] == 0 || $exercise_data['results_disabled'] == 2) {
//if ($visible_return['value'] == true) {
$best_average = intval(get_best_average_score_by_exercise($exercise_data['id'], $course_data['code'], $my_session_id, $user_count));
$exercise_graph_list[] = $best_average;
$all_exercise_graph_list[] = $best_average;
-
+
$user_result_data = get_best_attempt_by_user(api_get_user_id(), $exercise_data['id'], $course_data['code'], $my_session_id);
$score = 0;
if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
$score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
- }
+ }
//$user_results[] = $score;
$time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
$all_exercise_start_time[] = $time;
@@ -2328,19 +2326,19 @@ class Tracking {
$all_exercise_graph_name_list[]= $title;
}
}
- }
- }
- }
-
+ }
+ }
+ }
+
//Complete graph
- if (!empty($my_results) && !empty($all_exercise_graph_list)) {
+ if (!empty($my_results) && !empty($all_exercise_graph_list)) {
asort($all_exercise_start_time);
-
+
//Fix exams order
$final_all_exercise_graph_name_list = array();
$my_results_final = array();
$final_all_exercise_graph_list = array();
-
+
foreach ($all_exercise_start_time as $key => $time) {
$label_time = '';
if (!empty($time)) {
@@ -2355,48 +2353,48 @@ class Tracking {
$main_session_graph = self::generate_session_exercise_graph($final_all_exercise_graph_name_list, $my_results_final, $final_all_exercise_graph_list);
}
}
-
-
+
+
$html .= Display::page_subheader(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions'));
-
+
$html .= '';
//'.Display::tag('th', get_lang('DoneExercises'), array('class'=>'head')).'
$html .= '
'.Display::tag('th', get_lang('Session'), array('width'=>'300px')).'
'.Display::tag('th', get_lang('PublishedExercises'), array('width'=>'300px')).'
- '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
- '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
';
foreach ($course_in_session as $my_session_id => $session_data) {
$course_list = $session_data['course_list'];
$session_name = $session_data['name'];
-
+
if (isset($session_id) && !empty($session_id)) {
if ($session_id != $my_session_id) {
continue;
}
}
-
+
$all_exercises = 0;
- $all_unanswered_exercises_by_user = 0;
+ $all_unanswered_exercises_by_user = 0;
$all_average = 0;
$stats_array = array();
- foreach($course_list as $course_data) {
- //All exercises in the course @todo change for a real count
+ foreach($course_list as $course_data) {
+ //All exercises in the course @todo change for a real count
$exercises = get_all_exercises($course_data, $my_session_id);
$count_exercises = 0;
if (is_array($exercises) && !empty($exercises)) {
$count_exercises = count($exercises);
}
-
- //Count of user results
+
+ //Count of user results
//$done_exercises = get_count_exercises_attempted_by_course($course_data['code'], $my_session_id);
$done_exercises = null;
-
+
$answered_exercises = 0;
if (!empty($exercises)) {
foreach($exercises as $exercise_item) {
@@ -2404,14 +2402,14 @@ class Tracking {
if ($attempts > 1) {
$answered_exercises++;
}
- }
+ }
}
-
+
//Average
$average = get_average_score_by_course($course_data['code'], $my_session_id);
$all_exercises += $count_exercises;
-
+
$all_unanswered_exercises_by_user += $count_exercises - $answered_exercises;
//$all_done_exercise += $done_exercises;
$all_average += $average;
@@ -2426,14 +2424,14 @@ class Tracking {
$html .= '';
}
$url = api_get_path(WEB_CODE_PATH)."session/?session_id={$my_session_id}";
-
+
$html .= Display::tag('td', Display::url($session_name, $url, array('target'=>SESSION_LINK_TARGET)));
$html .= Display::tag('td', $all_exercises);
$html .= Display::tag('td', $all_unanswered_exercises_by_user);
-
+
//$html .= Display::tag('td', $all_done_exercise);
$html .= Display::tag('td', convert_to_percentage($all_average));
-
+
if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
$icon = Display::url(Display::return_icon('2rightarrow_na.gif', get_lang('Details')), '?session_id='.$my_session_id);
} else {
@@ -2442,9 +2440,9 @@ class Tracking {
$html .= Display::tag('td', $icon);
$html .= ' ';
}
- $html .= '
';
+ $html .= '
';
$html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
-
+
//Checking selected session
if (isset($_GET['session_id'])) {
@@ -2452,7 +2450,7 @@ class Tracking {
$session_data = $course_in_session[$session_id_from_get];
$course_list = $session_data['course_list'];
-
+
$html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
$html .= '';
@@ -2462,18 +2460,18 @@ class Tracking {
'.get_lang('Course').'
'.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
'.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
- '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
- '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
'.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
'.Display::tag('th', get_lang('LPProgress') , array('class'=>'head')).'
'.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
- '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
+ '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
'.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
';
foreach ($course_list as $course_data) {
$course_code = $course_data['code'];
- $course_title = $course_data['title'];
+ $course_title = $course_data['title'];
//All exercises in the course @todo change for a real count
$exercises = get_all_exercises($course_data, $session_id_from_get);
@@ -2483,27 +2481,27 @@ class Tracking {
}
//Count of user results
//$done_exercises = get_best_exercise_results_by_course($course_code, $session_id_from_get);
-
+
//From course exercises NOT from LP exercises!!!
- //$done_exercises = get_count_exercises_attempted_by_course($course_code, $session_id_from_get);
+ //$done_exercises = get_count_exercises_attempted_by_course($course_code, $session_id_from_get);
$answered_exercises = 0;
- foreach($exercises as $exercise_item) {
- $attempts = count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_code, $session_id_from_get);
+ foreach($exercises as $exercise_item) {
+ $attempts = count_exercise_attempts_by_user(api_get_user_id(), $exercise_item['id'], $course_code, $session_id_from_get);
if ($attempts > 1) {
$answered_exercises++;
}
}
-
+
$unanswered_exercises = $count_exercises - $answered_exercises;
-
+
//Average
$average = get_average_score_by_course($course_code, $session_id_from_get);
$my_average = get_average_score_by_course_by_user(api_get_user_id(), $course_code, $session_id_from_get);
-
- $stats_array[$course_code] = array( 'exercises' => $count_exercises,
+
+ $stats_array[$course_code] = array( 'exercises' => $count_exercises,
'unanswered_exercises_by_user' => $unanswered_exercises,
- 'done_exercises' => $done_exercises,
- 'average' => $average,
+ 'done_exercises' => $done_exercises,
+ 'average' => $average,
'my_average' => $my_average);
$weighting = 0;
@@ -2527,8 +2525,8 @@ class Tracking {
$html .= Display::tag('td', $stats_array[$course_code]['unanswered_exercises_by_user']);
//$html .= Display::tag('td', $stats_array[$course_code]['done_exercises']);
$html .= Display::tag('td', convert_to_percentage($stats_array[$course_code]['my_average']));
-
- $html .= Display::tag('td', $stats_array[$course_code]['average'] == 0 ? '-' : '('.convert_to_percentage($stats_array[$course_code]['average']).')');
+
+ $html .= Display::tag('td', $stats_array[$course_code]['average'] == 0 ? '-' : '('.convert_to_percentage($stats_array[$course_code]['average']).')');
$html .= Display::tag('td', $time, array('align'=>'center'));
if (is_numeric($progress)) {
@@ -2542,8 +2540,8 @@ class Tracking {
$percentage_score = $percentage_score.'%';
} else {
$percentage_score = '0%';
- }
- //Score
+ }
+ //Score
$html .= Display::tag('td', $percentage_score, array('align'=>'center'));
$html .= Display::tag('td', $last_connection, array('align'=>'center'));
@@ -2562,9 +2560,9 @@ class Tracking {
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;
}
@@ -2577,65 +2575,65 @@ class Tracking {
*/
static function show_course_detail($user_id, $course_code, $session_id) {
$html = '';
- if (isset($course_code)) {
+ 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'];
+
+ //$course_id = $course_info['real_id'];
//$session_name = api_get_session_name($session_id);
-
+
$html .= Display::page_subheader($course_info['title']);
-
+
$html .= '';
-
+
//Course details
$html .= '
'.get_lang('Exercices').'
- '.get_lang('Attempts').'
+ '.get_lang('Attempts').'
'.get_lang('BestAttempt').'
'.get_lang('Ranking').'
'.get_lang('BestResultInCourse').'
- '.get_lang('Statistics').' '.Display :: return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')).'
+ '.get_lang('Statistics').' '.Display :: return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')).'
';
-
+
if (empty($session_id)) {
$user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, STUDENT);
- } else {
+ } else {
$user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, 0);
}
-
- //$exercise_list = get_all_exercises($course_info, $session_id, true);
+
+ //$exercise_list = get_all_exercises($course_info, $session_id, true);
// Show exercise results of invisible exercises? see BT#4091
$exercise_list = get_all_exercises($course_info, $session_id, false);
-
- $to_graph_exercise_result = array();
-
+
+ $to_graph_exercise_result = array();
+
if (!empty($exercise_list)) {
$score = $weighting = $exe_id = 0;
foreach ($exercise_list as $exercices) {
-
+
$exercise_obj = new Exercise($course_info['real_id']);
$exercise_obj->read($exercices['id']);
$visible_return = $exercise_obj->is_visible();
-
-
+
+
$score = $weighting = $attempts = 0;
-
+
//Getting count of attempts by user
$attempts = count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
-
+
$html .= '';
$url = api_get_path(WEB_CODE_PATH)."exercice/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
-
+
if ($visible_return['value'] == true) {
$exercices['title'] = Display::url($exercices['title'], $url, array('target'=>SESSION_LINK_TARGET));
}
-
+
$html .= Display::tag('td', $exercices['title']);
-
+
//Exercise configuration show results or show only score
if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
//For graphics
@@ -2645,20 +2643,20 @@ class Tracking {
$latest_attempt_url = '';
$best_score = $position = $percentage_score_result = '-';
$graph = $normal_graph = null;
-
+
//Getting best results
$best_score_data = get_best_attempt_in_course($exercices['id'], $course_info['code'], $session_id);
$best_score = show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
-
+
if ($attempts > 0) {
$exercise_stat = get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
if (!empty($exercise_stat)) {
-
+
//Always getting the BEST attempt
$score = $exercise_stat['exe_result'];
$weighting = $exercise_stat['exe_weighting'];
$exe_id = $exercise_stat['exe_id'];
-
+
//$latest_attempt_url .= ' '.Display::return_icon('quiz.gif', get_lang('Quiz')).' ';
$latest_attempt_url .= '../exercice/exercise_show.php?origin=myprogress&id='.$exe_id.'&cidReq='.$course_info['code'].'&id_session='.$session_id;
$percentage_score_result = Display::url(show_score($score, $weighting), $latest_attempt_url);
@@ -2667,27 +2665,27 @@ class Tracking {
$my_score = $score/$weighting;
}
$position = get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
-
+
$graph = self::generate_exercise_result_thumbnail_graph($to_graph_exercise_result[$exercices['id']]);
$normal_graph = self::generate_exercise_result_graph($to_graph_exercise_result[$exercices['id']]);
}
}
-
+
$html .= Display::div($normal_graph, array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none') );
-
+
if (empty($graph)) {
$graph = '-';
} else {
$graph = Display::url($graph, '#', array('id'=>$exercices['id'], 'class'=>'opener'));
}
-
+
$html .= Display::tag('td', $attempts, array('align'=>'center'));
$html .= Display::tag('td', $percentage_score_result, array('align'=>'center'));
$html .= Display::tag('td', $position, array('align'=>'center'));
$html .= Display::tag('td', $best_score, array('align'=>'center'));
$html .= Display::tag('td', $graph, array('align'=>'center'));
//$html .= Display::tag('td', $latest_attempt_url, array('align'=>'center', 'width'=>'25'));
-
+
} else {
// Exercise configuration NO results
$html .= Display::tag('td', $attempts, array('align'=>'center'));
@@ -2702,9 +2700,9 @@ class Tracking {
$html .= ' '.get_lang('NoEx').' ';
}
$html .= '
';
-
-
- //LP table results
+
+
+ //LP table results
$html .='';
$html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
$html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -2713,12 +2711,12 @@ class Tracking {
$html .= Display::tag('th', get_lang('LastConnexion'), array('class'=>'head', 'style'=>'color:#000'));
$html .= '';
- $list = new LearnpathList(api_get_user_id(), $course_info['code'], $session_id, 'publicated_on ASC', true);
+ $list = new LearnpathList(api_get_user_id(), $course_info['code'], $session_id, 'publicated_on ASC', true);
$lp_list = $list->get_flat_list();
-
+
if (!empty($lp_list) > 0) {
foreach($lp_list as $lp_id => $learnpath) {
-
+
$progress = Tracking::get_avg_student_progress($user_id, $course, array($lp_id), $session_id);
$last_connection_in_lp = Tracking::get_last_connection_time_in_lp($user_id, $course, $lp_id, $session_id);
$time_spent_in_lp = Tracking::get_time_spent_in_lp($user_id, $course, array($lp_id), $session_id);
@@ -2732,7 +2730,7 @@ class Tracking {
$time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
$html .= '';
- $url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
+ $url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
$html .= Display::tag('td', Display::url($learnpath['lp_name'], $url, array('target'=>SESSION_LINK_TARGET)));
$html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
if (is_numeric($progress)) {
@@ -2756,7 +2754,7 @@ class Tracking {
';
}
$html .='
';
- }
+ }
return $html;
}
@@ -2801,7 +2799,7 @@ class Tracking {
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$graph->setGraphArea(65,50,$main_width-20, $main_height-140);
-
+
$graph->drawFilledRoundedRectangle(7,7,$main_width-7,$main_height-7,5,240,240,240);
$graph->drawRoundedRectangle(5,5,$main_width-5,$main_height -5,5,230,230,230);
$graph->drawGraphArea(255,255,255,TRUE);
@@ -2821,7 +2819,7 @@ class Tracking {
// Finish the graph
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
$graph->drawLegend($main_width - 150,70,$data_set->GetDataDescription(),255,255,255);
-
+
$graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',11);
$graph->drawTitle(50, 30, get_lang('ExercisesInTimeProgressChart'), 50,50,50,$main_width-110, true);
@@ -2861,7 +2859,7 @@ class Tracking {
if (empty($attempts)) {
return null;
}
-
+
foreach ($attempts as $attempt) {
if (api_get_user_id() == $attempt['exe_user_id']) {
if ($attempt['exe_weighting'] != 0 ) {
@@ -2930,7 +2928,7 @@ class Tracking {
//var_dump($my_final_array, $final_array); echo '
';
//echo ''; var_dump($my_exercise_result, $exercise_result,$x_axis);
-
+
$cache = new pCache();
// Dataset definition
@@ -2939,7 +2937,7 @@ class Tracking {
$data_set->AddPoint($my_final_array,"Serie2");
//$data_set->AddPoint($x_axis,"Serie3");
$data_set->AddAllSeries();
-
+
// Initialise the graph
$main_width = 80;
@@ -3093,7 +3091,7 @@ class Tracking {
//SCALE_NORMAL, SCALE_START0, SCALE_ADDALLSTART0
$main_graph->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALLSTART0, 150,150,150,TRUE,0,1,TRUE);
-
+
$main_graph->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
@@ -3163,7 +3161,7 @@ class TrackingCourseLog {
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
-
+
$session_id = intval($session_id);
$sql = "SELECT
@@ -3174,8 +3172,8 @@ class TrackingCourseLog {
insert_date as col5,
visibility as col6
FROM $table_item_property track_resource, $table_user user
- WHERE track_resource.c_id = $course_id AND
- track_resource.insert_user_id = user.user_id AND
+ WHERE track_resource.c_id = $course_id AND
+ track_resource.insert_user_id = user.user_id AND
id_session = $session_id ";
if (isset($_GET['keyword'])) {
@@ -3229,7 +3227,7 @@ class TrackingCourseLog {
if (!empty($recorset)) {
$obj = Database::fetch_object($recorset);
-
+
$name_session = '';
$coach_name = '';
if (!empty($obj)) {
@@ -3573,7 +3571,7 @@ class TrackingCourseLog {
$user_ids = intval($user_ids);
$condition_user = " WHERE user.user_id = $user_ids ";
}
-
+
if (!empty($_GET['user_keyword'])) {
$keyword = trim(Database::escape_string($_GET['user_keyword']));
$condition_user .= " AND (user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%' OR user.email LIKE '%".$keyword."%' ) ";
@@ -3595,7 +3593,7 @@ class TrackingCourseLog {
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
-
+
$column = intval($column);
if ($is_western_name_order) {
@@ -3616,26 +3614,26 @@ class TrackingCourseLog {
$res = Database::query($sql);
$users = array();
$t = time();
-
+
$course_info = api_get_course_info($course_code);
- $total_surveys = 0;
+ $total_surveys = 0;
$total_exercises = get_all_exercises($course_info, $session_id);
-
+
if (empty($session_id)) {
$survey_user_list = array();
$survey_list = survey_manager::get_surveys($course_code, $session_id);
-
+
$total_surveys = count($survey_list);
$survey_data = array();
foreach ($survey_list as $survey) {
$user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']);
-
+
foreach ($user_list as $user_id) {
isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : $survey_user_list[$user_id] = 1;
}
}
}
-
+
while ($user = Database::fetch_array($res, 'ASSOC')) {
$user['official_code'] = $user['col0'];
if ($is_western_name_order) {
@@ -3647,7 +3645,7 @@ class TrackingCourseLog {
}
$user['username'] = $user['col3'];
$user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, $session_id));
-
+
$avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id);
$avg_student_progress = Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $session_id);
@@ -3655,20 +3653,20 @@ class TrackingCourseLog {
$avg_student_progress=0;
}
$user['average_progress'] = $avg_student_progress.'%';
-
- $total_user_exercise = Tracking::get_exercise_student_progress($total_exercises, $user['user_id'], $course_code, $session_id);
+
+ $total_user_exercise = Tracking::get_exercise_student_progress($total_exercises, $user['user_id'], $course_code, $session_id);
$user['exercise_progress'] = $total_user_exercise;
-
+
$total_user_exercise = Tracking::get_exercise_student_average_best_attempt($total_exercises, $user['user_id'], $course_code, $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.'%';
} else {
$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);
@@ -3676,7 +3674,7 @@ class TrackingCourseLog {
// we need to display an additional profile field
$user['additional'] = '';
-
+
if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
if (isset($additional_user_profile_info[$user['user_id']]) && is_array($additional_user_profile_info[$user['user_id']])) {
$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
@@ -3686,16 +3684,16 @@ class TrackingCourseLog {
if (empty($session_id)) {
$user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
}
-
+
$user['link'] = '.'2rightarrow.gif)
';
// store columns in array $users
-
+
$is_western_name_order = api_is_western_name_order();
$user_row = array();
-
+
$user_row[]= $user['official_code']; //0
-
+
if ($is_western_name_order) {
$user_row[]= $user['lastname'];
$user_row[]= $user['firstname'];
@@ -3704,31 +3702,31 @@ class TrackingCourseLog {
$user_row[]= $user['lastname'];
}
$user_row[]= $user['username'];
- $user_row[]= $user['time'];
- $user_row[]= $user['average_progress'];
+ $user_row[]= $user['time'];
+ $user_row[]= $user['average_progress'];
$user_row[]= $user['exercise_progress'];
-
- $user_row[]= $user['exercise_average_best_attempt'];
-
+ $user_row[]= $user['exercise_average_best_attempt'];
+
+
$user_row[]= $user['student_score'];
$user_row[]= $user['count_assignments'];
$user_row[]= $user['count_messages'];
-
+
if (empty($session_id)) {
$user_row[]= $user['survey'];
}
-
+
$user_row[]= $user['first_connection'];
- $user_row[]= $user['last_connection'];
+ $user_row[]= $user['last_connection'];
if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
- $user_row[]= $user['additional'];
+ $user_row[]= $user['additional'];
}
-
+
$user_row[]= $user['link'];
-
+
$users[] = $user_row;
-
+
if ($export_csv) {
if (empty($session_id)) {
$user_row = array_map('strip_tags', $user_row);
@@ -3739,7 +3737,7 @@ class TrackingCourseLog {
unset($user_row[13]);
unset($user_row[14]);
}
-
+
$csv_content[] = $user_row;
}
}
diff --git a/main/mySpace/index.php b/main/mySpace/index.php
index aaf0cbc2c6..2cff56de52 100644
--- a/main/mySpace/index.php
+++ b/main/mySpace/index.php
@@ -24,7 +24,6 @@ $csv_content = array();
$nameTools = get_lang('MySpace');
$user_id = api_get_user_id();
-$is_coach = api_is_coach($_GET['session_id']); // This is used?
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
@@ -120,15 +119,15 @@ if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
$menu_items = array();
global $_configuration;
-if ($is_platform_admin) {
+if ($is_platform_admin) {
if ($view == 'admin') {
$title = get_lang('CoachList');
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_self().'?view=teacher');
- $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), api_get_self().'?view=admin');
- $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
- $menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
- } else {
- $menu_items[] = Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), 32);
+ $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), api_get_self().'?view=admin');
+ $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
+ $menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
+ } else {
+ $menu_items[] = Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), 32);
$menu_items[] = Display::url(Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32), api_get_self().'?view=admin');
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
@@ -147,73 +146,73 @@ echo '';
echo '';
-if ($display == 'useroverview' || $display == 'sessionoverview' || $display == 'courseoverview') {
+if ($display == 'useroverview' || $display == 'sessionoverview' || $display == 'courseoverview') {
echo '';
echo Display::return_icon("export_csv.png", get_lang('ExportAsCSV'),array(), 32);
- echo '';
+ echo '';
}
echo ''.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'';
echo '';
-
+
if (!empty($session_id)) {
echo ''.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'';
} else {
echo Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
-}
+}
// Actions menu
$nb_menu_items = count($menu_items);
if (empty($session_id)) {
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
- echo $item;
+ echo $item;
}
}
-}
+}
echo '';
if (empty($session_id)) {
-
+
//Getting courses followed by a coach (No session courses)
- $courses = CourseManager::get_course_list_as_coach($user_id, false);
-
+ $courses = CourseManager::get_course_list_as_coach($user_id, false);
+
if (isset($courses[0])) {
- $courses = $courses[0];
+ $courses = $courses[0];
}
-
+
//Getting students from courses and courses in sessions (To show the total students that the user follows)
$students = CourseManager::get_user_list_from_courses_as_coach($user_id);
-
+
// Sessions for the coach
$sessions = SessionManager::get_sessions_coached_by_user($user_id);
-
- //If is drh
+
+ //If is drh
if ($is_drh) {
$students = array_keys(UserManager::get_users_followed_by_drh($user_id, STUDENT));
- $courses_of_the_platform = CourseManager :: get_courses_followed_by_drh($user_id);
-
+ $courses_of_the_platform = CourseManager :: get_courses_followed_by_drh($user_id);
+
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
- }
- $sessions = SessionManager::get_sessions_followed_by_drh($user_id);
- }
-
+ }
+ $sessions = SessionManager::get_sessions_followed_by_drh($user_id);
+ }
+
//Courses for the user
$count_courses = count($courses);
-
+
//Sessions for the user
$count_sessions = count($sessions);
-
- //Students
- $nb_students = count($students);
-
+
+ //Students
+ $nb_students = count($students);
+
$total_time_spent = 0;
$total_courses = 0;
$avg_total_progress = 0;
$avg_results_to_exercises = 0;
$nb_inactive_students = 0;
$nb_posts = $nb_assignments = 0;
-
+
if (!empty($students))
foreach ($students as $student_id) {
// inactive students
@@ -225,7 +224,7 @@ if (empty($session_id)) {
} else {
$nb_inactive_students++;
}
-
+
$total_time_spent += Tracking :: get_time_spent_on_the_platform($student_id);
$total_courses += Tracking :: count_course_per_student($student_id);
$avg_student_progress = 0;
@@ -238,10 +237,10 @@ if (empty($session_id)) {
$nb_assignments += Tracking :: count_student_assignments($student_id, $course_code);
$avg_student_progress += Tracking :: get_avg_student_progress($student_id, $course_code);
$myavg_temp = Tracking :: get_avg_student_score($student_id, $course_code);
-
+
if (is_numeric($myavg_temp))
$avg_student_score += $myavg_temp;
-
+
if ($nb_posts !== null && $nb_assignments !== null && $avg_student_progress !== null && $avg_student_score !== null) {
//if one of these scores is null, it means that we had a problem connecting to the right database, so don't count it in
$nb_courses_student++;
@@ -251,14 +250,14 @@ if (empty($session_id)) {
// average progress of the student
$avg_student_progress = $nb_courses_student ? $avg_student_progress / $nb_courses_student:0;
$avg_total_progress += $avg_student_progress;
-
+
// average test results of the student
$avg_student_score = $avg_student_score ? $avg_student_score / $nb_courses_student:0;
$avg_results_to_exercises += $avg_student_score;
}
if ($nb_students > 0 && $view != 'admin') {
-
+
// average progress
$avg_total_progress = $avg_total_progress / $nb_students;
// average results to the tests
@@ -270,10 +269,10 @@ if (empty($session_id)) {
// average assignments
$nb_assignments = $nb_assignments / $nb_students;
// average posts
- $nb_posts = $nb_posts / $nb_students;
-
+ $nb_posts = $nb_posts / $nb_students;
+
echo Display::page_subheader('
'.get_lang('Overview'));
-
+
echo '
@@ -290,9 +289,9 @@ if (empty($session_id)) {
';
echo '';
-
+
echo Display::page_subheader('
'.get_lang('Students').' ('.$nb_students.')');
-
+
if ($export_csv) {
//csv part
$csv_content[] = array(get_lang('Students', ''));
@@ -307,21 +306,21 @@ if (empty($session_id)) {
} else {
// html part
echo '
-
+
'.get_lang('AverageCoursePerStudent').'
'.(is_null($avg_courses_per_student) ? '' : $avg_courses_per_student).'
-
+
'.get_lang('InactivesStudents').'
'.$nb_inactive_students.'
-
+
'.get_lang('AverageTimeSpentOnThePlatform').'
'.(is_null($avg_time_spent) ? '' : api_time_to_hms($avg_time_spent)).'
-
+
'.get_lang('AverageProgressInLearnpath').'
'.(is_null($avg_total_progress) ? '' : round($avg_total_progress, 2).'%').'
@@ -341,7 +340,7 @@ if (empty($session_id)) {
'.get_lang('SeeStudentList').'
';
- }
+ }
} else {
$avg_total_progress = null;
$avg_results_to_exercises = null;
@@ -351,38 +350,38 @@ if (empty($session_id)) {
$nb_posts = null;
}
} else {
-
+
$visibility = api_get_session_visibility($session_id);
if ($visibility == SESSION_INVISIBLE) {
Display::display_warning_message(get_lang('NotAvailable'));
Display::display_footer();
- }
+ }
$courses = Tracking::get_courses_followed_by_coach($user_id, $session_id);
-
- //If is drh
+
+ //If is drh
if ($is_drh) {
- $courses_of_the_platform = CourseManager :: get_courses_followed_by_drh($user_id);
-
+ $courses_of_the_platform = CourseManager :: get_courses_followed_by_drh($user_id);
+
$courses = array();
$courses_from_session = SessionManager::get_course_list_by_session_id($session_id);
-
- foreach ($courses_from_session as $course_item) {
- if (isset($courses_of_the_platform[$course_item['code']])) {
+
+ foreach ($courses_from_session as $course_item) {
+ if (isset($courses_of_the_platform[$course_item['code']])) {
$courses[$course_item['code']] = $course_item['code'];
}
- }
-
+ }
+
if (empty($courses)) {
Display::display_warning_message(get_lang('NoResults'));
}
}
-
+
//Courses for the user
$count_courses = count($courses);
-
+
//Sessions for the user
- $count_sessions = count($sessions);
+ $count_sessions = count($sessions);
}
if ($count_courses || $count_sessions) {
@@ -400,10 +399,10 @@ if ($count_courses || $count_sessions) {
}
if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array('teacher', 'drh'))) {
-
+
//Courses
if ($count_courses) {
- echo Display::page_subheader($title);
+ echo Display::page_subheader($title);
$table = new SortableTable('courses_my_space', 'get_number_of_courses', array('MySpace','get_course_data'));
$parameters['view'] = 'teacher';
$parameters['class'] = 'data_table';
@@ -433,14 +432,14 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
// Display list of sessions
if ($count_sessions > 0 && !isset($_GET['session_id'])) {
-
+
$columns = array(
- get_lang('Title'),
+ get_lang('Title'),
get_lang('SessionDisplayStartDate'),
get_lang('SessionDisplayEndDate'),
get_lang('NbStudentPerSession'),
get_lang('NbCoursesPerSession'),
- get_lang('Details')
+ get_lang('Details')
);
//'formatter'=>'action_formatter',
$column_model = array (
@@ -450,42 +449,42 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
array('name'=>'number_student_per_session', 'index'=>'number_student_per_session', 'width'=>'70', 'align'=>'left', 'search' => 'true', 'searchoptions' => array(), 'sorttype' => 'numeric'),
array('name'=>'courses_per_session', 'index'=>'courses_per_session','width'=>'70', 'align'=>'left', 'search' => 'false', 'searchoptions' => array(), 'sorttype' => 'numeric'),
array('name'=>'details', 'index'=>'details', 'width'=>'80', 'align'=>'left', 'sortable'=>'false', 'search' => 'false'),
- );
+ );
- //Autowidth
+ //Autowidth
$extra_params['autowidth'] = 'true';
- //height auto
+ //height auto
$extra_params['height'] = 'auto';
$extra_params['sortname'] = 'display_start_date';
$extra_params['sortorder'] = 'desc';
//$extra_params['excel'] = 'excel';
$extra_params['rowList'] = array(10, 20 ,30);
-
+
$all_data = array();
-
+
foreach ($sessions as $session) {
$visibility = api_get_session_visibility($session['id']);
-
+
$count_courses_in_session = count(Tracking::get_courses_followed_by_coach($user_id, $session['id']));
$count_users_in_session = count(SessionManager::get_users_by_session($session['id'], 0));
$row = array();
- $row['name'] = $session['name'];
+ $row['name'] = $session['name'];
$row['display_start_date'] = api_get_local_time($session['display_start_date'], null, null, true);
- $row['display_end_date'] = api_get_local_time($session['display_end_date'], null, null, true);
+ $row['display_end_date'] = api_get_local_time($session['display_end_date'], null, null, true);
$row['number_student_per_session'] = $count_courses_in_session;
$row['courses_per_session'] = $count_users_in_session;
-
- if ($visibility == SESSION_INVISIBLE) {
+
+ if ($visibility == SESSION_INVISIBLE) {
$row['details'] = '
';
} else {
$row['details'] = '
';
- }
+ }
$all_data[] = $row;
}
-
+
echo "";
$nb_sessions_past = $nb_sessions_current = 0;
$courses = array();
-
- foreach ($sessions as $session) {
- $visibility = api_get_session_visibility($session['id']);
+
+ foreach ($sessions as $session) {
+ $visibility = api_get_session_visibility($session['id']);
if ($visibility == SESSION_AVAILABLE) {
$nb_sessions_current ++;
} else {
$nb_sessions_past++;
- }
+ }
$courses = array_merge($courses, Tracking::get_courses_list_from_session($session['id']));
}
-
- $nb_courses_per_session = null;
+
+ $nb_courses_per_session = null;
$nb_students_per_session = null;
-
+
if ($count_sessions > 0) {
$nb_courses_per_session = round(count($courses) / $count_sessions, 2);
$nb_students_per_session = round($nb_students / $count_sessions, 2);
}
-
+
if ($export_csv) {
//csv part
$csv_content[] = array(get_lang('Sessions', ''));
@@ -519,11 +518,11 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
$csv_content[] = array(get_lang('NbInactiveSessions', '').';'.$nb_sessions_past);
//$csv_content[] = array(get_lang('NbFutureSessions', '').';'.$nb_sessions_future);
$csv_content[] = array(get_lang('NbCoursesPerSession', '').';'.$nb_courses_per_session);
- $csv_content[] = array(get_lang('NbStudentPerSession', '').';'.$nb_students_per_session);
+ $csv_content[] = array(get_lang('NbStudentPerSession', '').';'.$nb_students_per_session);
$csv_content[] = array();
} else {
echo '
-
+
'.get_lang('NbActiveSessions').'
@@ -532,31 +531,31 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
'.get_lang('NbInactiveSessions').'
'.$nb_sessions_past.'
-
-
+
+
';
}
-
+
echo Display::grid_html('sessions');
-
- /* End session overview */
+
+ /* End session overview */
}
}
if ($is_platform_admin && $view == 'admin' && $display != 'yourstudents') {
-
+
echo ''.get_lang('DisplayCoaches').' | ';
echo ''.get_lang('DisplayUserOverview').'';
if ($display == 'useroverview') {
echo ' ( '.get_lang('ExportUserOverviewOptions').' )';
}
echo ' | '.get_lang('DisplaySessionOverview').'';
- echo ' | '.get_lang('DisplayCourseOverview').'';
- echo ' | '.get_lang('LPQuestionListResults').'';
+ echo ' | '.get_lang('DisplayCourseOverview').'';
+ echo ' | '.get_lang('LPQuestionListResults').'';
echo ' | '.get_lang('LPExerciseResultsBySession').'';
-
-
+
+
echo '
';
if ($display === 'useroverview') {
MySpace::display_tracking_user_overview();