'../user/userInfo.php?uInfo='.Security::remove_XSS($uInfo),
"name"=> api_ucfirst(get_lang('Users'))
);
}
$nameTools = get_lang('ToolName');
$htmlHeadXtra[] = "
";
Display::display_header($nameTools, "Tracking");
/* Constants and variables */
$is_allowedToTrack = $is_courseAdmin;
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $courseId);
// Database Table Definitions
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$now = api_get_utc_datetime();
$sql = "SELECT 1
FROM $tbl_session_course_user AS session_course_user
INNER JOIN $tbl_session AS session
ON session_course_user.session_id = session.id
AND ((access_start_date <= '$now'
AND access_end_date >= '$now')
OR (access_start_date IS NULL AND access_end_date IS NULL))
WHERE session_id='".api_get_session_id()."' AND c_id = $courseId";
//echo $sql;
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$disabled = true;
}
$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// The variables for the days and the months
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$MonthsShort = api_get_months_short();
//$is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
//$is_allowedToTrackEverybodyInCourse = $is_allowed[EDIT_RIGHT]; // allowed to track all students in course
//YW hack security to fix RolesRights bug
$is_allowedToTrack = true; // allowed to track only user of one group
$is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course
/* MAIN SECTION */
?>
".get_lang('ListStudents')."";
if ($is_allowedToTrackEverybodyInCourse) {
// if user can track everybody : list user of course
$sql = "SELECT count(user_id)
FROM $TABLECOURSUSER
WHERE c_id = '".$courseId."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
} else {
// if user can only track one group : list users of this group
$sql = "SELECT count(user)
FROM $TABLECOURSE_GROUPSUSER
WHERE group_id = '".intval($_gid)."'";
}
$userGroupNb = StatsUtils::getOneResult($sql);
$step = 25; // number of student per page
if ($userGroupNb > $step) {
if (!isset($offset)) {
$offset = 0;
}
$next = $offset + $step;
$previous = $offset - $step;
$navLink = "\n";
} else {
$offset = 0;
}
echo $navLink;
//sanity check of integer vars
if (!settype($offset, 'integer') || !settype($step, 'integer')) {
die('Offset or step variables are not integers.');
}
if ($is_allowedToTrackEverybodyInCourse) {
// list of users in this course
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE
cu.user_id = u.user_id AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
cu.c_id = '".$courseId."'
LIMIT $offset,$step";
} else {
// list of users of this group
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE
gu.user_id = u.user_id AND
gu.group_id = '".intval($_gid)."'
LIMIT $offset,$step";
}
$list_users = getManyResults3Col($sql);
echo "";
echo $navLink;
} else {
// if uInfo is set
/*
* Information about student uInfo
*/
// these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from
// another course, or group
if ($is_allowedToTrackEverybodyInCourse) {
// check if user is in this course
$tracking_is_accepted = $is_course_member;
$tracked_user_info = api_get_user_info($uInfo);
} else {
// check if user is in the group of this tutor
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '".intval($_gid)."'
AND u.user_id = '".intval($uInfo)."'";
$query = Database::query($sql);
$tracked_user_info = @Database::fetch_assoc($query);
if (is_array($tracked_user_info)) {
$tracking_is_accepted = true;
}
}
if ($tracking_is_accepted) {
$tracked_user_info['email'] == '' ? $mail_link = get_lang('NoEmail') : $mail_link = Display::encrypted_mailto_link($tracked_user_info['email']);
echo "";
echo get_lang('informationsAbout').' :';
echo "\n"
."- ".get_lang('FirstName')." : ".$tracked_user_info['firstname']."
\n"
."- ".get_lang('LastName')." : ".$tracked_user_info['lastname']."
\n"
."- ".get_lang('Email')." : ".$mail_link."
\n"
." ";
echo " |
\n";
// show all : number of 1 is equal to or bigger than number of categories
// show none : number of 0 is equal to or bigger than number of categories
echo "
[".get_lang('ShowAll')."]
[".get_lang('ShowNone')."]".
//"||[".get_lang('BackToList')."]".
" |
";
if (!isset($view)) {
$view = '0000000';
}
//Logins
TrackingUserLog::display_login_tracking_info($view, $uInfo, $courseId);
//Exercise results
TrackingUserLog::display_exercise_tracking_info($view, $uInfo, $_cid);
//Student publications uploaded
TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $courseId);
//Links usage
TrackingUserLog::display_links_tracking_info($view, $uInfo, $_cid);
//Documents downloaded
TrackingUserLog::display_document_tracking_info($view, $uInfo, $_cid);
} else {
echo get_lang('ErrorUserNotInGroup');
}
/*
* Scorm contents and Learning Path
*/
if (substr($view, 5, 1) == '1') {
$new_view = substr_replace($view, '0', 5, 1);
echo "
- ".get_lang('ScormAccess')." [".get_lang('Close')."] [".get_lang('ExportAsCSV')."]
|
";
$sql = "SELECT id, name FROM $tbl_learnpath_main";
$result = Database::query($sql);
$ar = Database::fetch_array($result);
echo "";
echo "
".get_lang('ScormContentColumn')."
|
";
if (is_array($ar)) {
while ($ar['id'] != '') {
$lp_title = stripslashes($ar['name']);
echo "";
echo "$lp_title";
echo " | ";
if ($ar['id'] == $scormcontopen) {
//have to list the students here
$contentId = intval($ar['id']);
$sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time ".
"FROM $tbl_learnpath_item i ".
"INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id ".
"INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id ".
"WHERE (v.user_id=".intval($uInfo)." and v.lp_id=$contentId)
ORDER BY v.id, i.id";
$result3 = Database::query($sql3);
$ar3 = Database::fetch_array($result3);
if (is_array($ar3)) {
echo " |
".get_lang('ScormTitleColumn')."
|
".get_lang('ScormStatusColumn')."
|
".get_lang('ScormScoreColumn')."
|
".get_lang('ScormTimeColumn')."
|
";
while ($ar3['status'] != '') {
require_once '../lp/learnpathItem.class.php';
$time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
echo " | ";
echo "$title | {$ar3['status']} | {$ar3['score']} | $time | ";
echo " ";
$ar3 = Database::fetch_array($result3);
}
} else {
echo "";
echo "".get_lang('ScormNeverOpened')." | ";
echo" ";
}
}
$ar = Database::fetch_array($result);
}
} else {
$noscorm = true;
}
if ($noscorm) {
echo "";
echo "".get_lang('NoResult')." | ";
echo " ";
}
echo " ";
echo " |
";
} else {
$new_view = substr_replace($view, '1', 5, 1);
echo "
+ ".get_lang('ScormAccess')."
|
";
}
}
} else {
// not allowed
api_not_allowed();
}
?>