123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?php
- /* For licensing terms, see /license.txt */
- // TODO: Is this file deprecated?
- /**
- * @package chamilo.tracking
- * @todo clean code - structure is unclear and difficult to modify
- */
- $uInfo = intval($_REQUEST['uInfo']);
- $view = Security::remove_XSS($_REQUEST['view']);
- // Including the global initialization file
- //require_once '../inc/global.inc.php';
- // the section (for the tabs)
- $this_section = "session_my_space";
- // variables
- $user_id = api_get_user_id();
- $course_id = api_get_course_id();
- $courseId = api_get_course_int_id();
- //YW Hack security to quick fix RolesRights bug
- $is_allowed = true;
- require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
- /* Header */
- /*
- $interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('BredCrumpGroups'));
- $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=$_gid", "name"=> get_lang('BredCrumpGroupSpace'));
- */
- if(isset($uInfo)) {
- $interbreadcrumb[]= array ('url'=>'../user/userInfo.php?uInfo='.Security::remove_XSS($uInfo), "name"=> api_ucfirst(get_lang('Users')));
- }
- $nameTools = get_lang('ToolName');
- $htmlHeadXtra[] = "<style type='text/css'>
- /*<![CDATA[*/
- .secLine {background-color : #E6E6E6;}
- .content {padding-left : 15px;padding-right : 15px; }
- .specialLink{color : #0000FF;}
- /*]]>*/
- </style>
- <style media='print' type='text/css'>
- /*<![CDATA[*/
- td {border-bottom: thin dashed gray;}
- /*]]>*/
- </style>";
- 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='0000-00-00' AND access_end_date='0000-00-00'))
- 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 */
- ?>
- <h3>
- <?php echo $nameTools ?>
- </h3>
- <h4>
- <?php echo get_lang('StatsOfUser'); ?>
- </h4>
- <table width="100%" cellpadding="2" cellspacing="3" border="0">
- <?php
- // check if uid is tutor of this group
- if (( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
- if (!$uInfo && !isset($uInfo)) {
- /*
- * Display list of user of this group
- */
- echo "<h4>".get_lang('ListStudents')."</h4>";
- 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 = "<table width='100%' border='0'>\n"
- ."<tr>\n"
- ."<td align='left'>";
- if ($previous >= 0) {
- $navLink .= "<a href='".api_get_self()."?offset=$previous'><< ".get_lang('PreviousPage')."</a>";
- }
- $navLink .= "</td>\n"
- ."<td align='right'>";
- if ($next < $userGroupNb) {
- $navLink .= "<a href='".api_get_self()."?offset=$next'>".get_lang('NextPage')." >></a>";
- }
- $navLink .= "</td>\n"
- ."</tr>\n"
- ."</table>\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 "<table width='100%' cellpadding='2' cellspacing='1' border='0'>\n"
- ."<tr align='center' valign='top' bgcolor='#E6E6E6'>\n"
- ."<td align='left'>",get_lang('UserName'),"</td>\n"
- ."</tr>\n";
- for ($i = 0; $i < sizeof($list_users); $i++) {
- echo "<tr valign='top' align='center'>\n"
- ."<td align='left'>"
- ."<a href='".api_get_self()."?uInfo=",$list_users[$i][0],"'>"
- .$list_users[$i][1]," ",$list_users[$i][2]
- ."</a>".
- "</td>\n";
- }
- echo "</table>";
- 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 "<tr><td>";
- echo get_lang('informationsAbout').' :';
- echo "<ul>\n"
- ."<li>".get_lang('FirstName')." : ".$tracked_user_info['firstname']."</li>\n"
- ."<li>".get_lang('LastName')." : ".$tracked_user_info['lastname']."</li>\n"
- ."<li>".get_lang('Email')." : ".$mail_link."</li>\n"
- ."</ul>";
- echo "</td></tr>\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 "<tr>
- <td>
- [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=1111111'>".get_lang('ShowAll')."</a>]
- [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=0000000'>".get_lang('ShowNone')."</a>]".
- //"||[<a href='".api_get_self()."'>".get_lang('BackToList')."</a>]".
- "</td>
- </tr>
- ";
- 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 "<tr>
- <td valign='top'>
- <font color='#0000FF'>- </font><b>".get_lang('ScormAccess')."</b> [<a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=000001'>".get_lang('ExportAsCSV')."</a>]
- </td>
- </tr>";
- $sql = "SELECT id, name FROM $tbl_learnpath_main";
- $result=Database::query($sql);
- $ar=Database::fetch_array($result);
- echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
- echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>
- <td class='secLine'>
- ".get_lang('ScormContentColumn')."
- </td>
- </tr>";
- if (is_array($ar)) {
- while ($ar['id'] != '') {
- $lp_title = stripslashes($ar['name']);
- echo "<tr><td>";
- echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>$lp_title</a>";
- echo "</td></tr>";
- 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 "<tr><td> </td>
- <td class='secLine'>
- ".get_lang('ScormTitleColumn')."
- </td>
- <td class='secLine'>
- ".get_lang('ScormStatusColumn')."
- </td>
- <td class='secLine'>
- ".get_lang('ScormScoreColumn')."
- </td>
- <td class='secLine'>
- ".get_lang('ScormTimeColumn')."
- </td>
- </tr>";
- while ($ar3['status'] != '') {
- require_once '../newscorm/learnpathItem.class.php';
- $time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
- echo "<tr><td> </td><td>";
- echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
- echo "</tr>";
- $ar3=Database::fetch_array($result3);
- }
- } else {
- echo "<tr>";
- echo "<td colspan='3'><center>".get_lang('ScormNeverOpened')."</center></td>";
- echo"</tr>";
- }
- }
- $ar = Database::fetch_array($result);
- }
- } else {
- $noscorm=true;
- }
- if ($noscorm) {
- echo "<tr>";
- echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
- echo "</tr>";
- }
- echo "</table>";
- echo "</td></tr>";
- } else {
- $new_view = substr_replace($view, '1', 5, 1);
- echo "
- <tr>
- <td valign='top'>
- +<font color='#0000FF'> </font><a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>".get_lang('ScormAccess')."</a>
- </td>
- </tr>
- ";
- }
- }
- } else {
- // not allowed
- api_not_allowed();
- }
- ?>
- </table>
- <?php
- Display::display_footer();
|