/**/ "; /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ // regroup table names for maintenance purpose $TABLETRACK_ACCESS = Database::get_statistic_table(STATISTIC_TRACK_E_LASTACCESS_TABLE); $TABLETRACK_LINKS = Database::get_statistic_table(STATISTIC_TRACK_E_LINKS_TABLE); $TABLETRACK_DOWNLOADS = Database::get_statistic_table(STATISTIC_TRACK_E_DOWNLOADS_TABLE); $TABLETRACK_ACCESS_2 = Database::get_statistic_table("track_e_access"); $TABLECOURSUSER = Database::get_main_table(MAIN_COURSE_USER_TABLE); $TABLECOURSE = Database::get_main_table(MAIN_COURSE_TABLE); $TABLECOURSE_LINKS = Database::get_course_table(LINK_TABLE); $table_user = Database::get_main_table(MAIN_USER_TABLE); //$table_scormdata = Database::get_scorm_table(SCORM_SCO_DATA_TABLE); //$table_scormmain = Database::get_scorm_table(SCORM_MAIN_TABLE); //$tbl_learnpath_main = Database::get_course_table(LEARNPATH_MAIN_TABLE); //$tbl_learnpath_item = Database::get_course_table(LEARNPATH_ITEM_TABLE); //$tbl_learnpath_chapter = Database::get_course_table(LEARNPATH_CHAPTER_TABLE); $tbl_learnpath_main = Database::get_course_table('lp'); $tbl_learnpath_item = Database::get_course_table('lp_item'); $tbl_learnpath_view = Database::get_course_table('lp_view'); $tbl_learnpath_item_view = Database::get_course_table('lp_item_view'); $view = $_REQUEST['view']; Display::display_header($nameTools, "Tracking"); include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php"); include("../resourcelinker/resourcelinker.inc.php"); $is_allowedToTrack = $is_courseAdmin; /* ============================================================================== MAIN CODE ============================================================================== */ ?>


"; if(!isset($view)) $view ="0000000"; /*************************************************************************** * * Reporting * ***************************************************************************/ $tempView = $view; if($view[6] == '1') { $tempView[6] = '0'; echo " "; //--------------------------------END users in this course } else { $tempView[6] = '1'; echo " "; } /*************************************************************************** * * Main * ***************************************************************************/ $tempView = $view; if($view[0] == '1') { $tempView[0] = '0'; echo " "; $sql = "SELECT count(*) FROM $TABLECOURSUSER WHERE course_code = '".$_cid."'"; $count = getOneResult($sql); echo " "; } else { $tempView[0] = '1'; echo " "; } /*************************************************************************** * * Access to this course * ***************************************************************************/ $tempView = $view; if($view[1] == '1') { $tempView[1] = '0'; echo " "; $sql = "SELECT count(*) FROM $TABLETRACK_ACCESS WHERE access_cours_code = '".$_cid."' AND access_tool IS NULL"; $count = getOneResult($sql); echo " "; // last 31 days $sql = "SELECT count(*) FROM $TABLETRACK_ACCESS WHERE `access_cours_code` = '$_cid' AND (access_date > DATE_ADD(CURDATE(), INTERVAL -31 DAY)) AND access_tool IS NULL"; $count = getOneResult($sql); echo " "; // last 7 days $sql = "SELECT count(*) FROM $TABLETRACK_ACCESS WHERE `access_cours_code` = '$_cid' AND (access_date > DATE_ADD(CURDATE(), INTERVAL -7 DAY)) AND access_tool IS NULL"; $count = getOneResult($sql); echo " "; // today $sql = "SELECT count(*) FROM $TABLETRACK_ACCESS WHERE `access_cours_code` = '$_cid' AND ( access_date > CURDATE() ) AND access_tool IS NULL"; $count = getOneResult($sql); echo " "; //-- view details of traffic echo " "; } else { $tempView[1] = '1'; echo " "; } /*************************************************************************** * * Tools * ***************************************************************************/ $tempView = $view; if($view[2] == '1') { $tempView[2] = '0'; echo " "; $sql = "SELECT `access_tool`, COUNT(DISTINCT `access_user_id`),count( `access_tool` ) FROM $TABLETRACK_ACCESS WHERE `access_tool` IS NOT NULL AND `access_cours_code` = '$_cid' GROUP BY `access_tool`"; echo ""; } else { $tempView[2] = '1'; echo " "; } /*************************************************************************** * * Links * ***************************************************************************/ $tempView = $view; if($view[3] == '1') { $tempView[3] = '0'; echo " "; $sql = "SELECT `cl`.`title`, `cl`.`url`,count(DISTINCT `sl`.`links_user_id`), count(`cl`.`title`) FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl WHERE `sl`.`links_link_id` = `cl`.`id` AND `sl`.`links_cours_id` = '$_cid' GROUP BY `cl`.`title`, `cl`.`url`"; echo ""; } else { $tempView[3] = '1'; echo " "; } /*************************************************************************** * * Documents * ***************************************************************************/ $tempView = $view; if($view[4] == '1') { $tempView[4] = '0'; echo " "; $sql = "SELECT `down_doc_path`, COUNT(DISTINCT `down_user_id`), COUNT(`down_doc_path`) FROM $TABLETRACK_DOWNLOADS WHERE `down_cours_id` = '$_cid' GROUP BY `down_doc_path`"; echo ""; } else { $tempView[4] = '1'; echo " "; } /*************************************************************************** * * Scorm contents and Learning Path * ***************************************************************************/ $tempView = $view; if($view[5] == '1') { $tempView[5] = '0'; echo " "; $sql = "SELECT id, name FROM $tbl_learnpath_main"; //WHERE dokeosCourse='$_cid'"; we are using a table inside the course now, so no need for course id $result=api_sql_query($sql,__FILE__,__LINE__); $ar=Database::fetch_array($result); echo ""; } else { $tempView[5] = '1'; echo " "; } } // not allowed else { if(!$is_trackingEnabled) { echo get_lang('TrackingDisabled'); } else { api_not_allowed(); } } ?>
[".get_lang('ShowAll')."] [".get_lang('ShowNone')."]
-   ".get_lang('SynthesisView')."   [".get_lang('Close')."]
"; //--------------------------------BEGIN users in this course $sql = "SELECT $TABLECOURSUSER.`user_id`, $table_user.`lastname`, $table_user.`firstname` FROM $TABLECOURSUSER, $table_user WHERE $TABLECOURSUSER.course_code = '".$_cid."' AND $TABLECOURSUSER.`user_id` = $table_user.`user_id` ORDER BY $table_user.`lastname`"; $results = getManyResults3Col($sql); //BUGFIX: get visual code instead of real course code. Scormpaths use the visual code... (should be fixed in future versions) $sql = "SELECT visual_code FROM $TABLECOURSE WHERE code = '".$_cid."'"; $_course['visual_code'] = getOneResult($sql); if (is_array($results)) { for($j = 0 ; $j < count($results) ; $j++) { //--------------------------------BEGIN % visited // sum of all items (= multiple learningpaths + SCORM imported paths) $sql = "SELECT COUNT(DISTINCT(iv.lp_item_id)) " . "FROM $tbl_learnpath_item_view iv " . "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id = v.id " . "WHERE v.user_id = ".$results[$j][0]; $total_lpath_items = getOneResult($sql); // sum of all completed items (= multiple learningpaths + SCORM imported paths) $sql = "SELECT COUNT(DISTINCT(iv.lp_item_id)) " . "FROM $tbl_learnpath_item_view iv " . "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id = v.id " . "WHERE v.user_id = ".$results[$j][0]." " . "AND (status = 'completed' OR status='passed')"; $total_lpath_items_completed = getOneResult($sql); // calculation & bgcolor setting $lpath_pct_completed = empty($total_lpath_items) ? "-" : round(($total_lpath_items_completed / $total_lpath_items) * 100); $lpath_pct_completed_color = $lpath_pct_completed < 75 ? " bgcolor='#CC3333'" : " bgcolor='#99CC66'"; //--------------------------------END % visited //--------------------------------BEGIN first/last access // first access $sql = "SELECT access_date FROM $TABLETRACK_ACCESS_2 WHERE `access_user_id` = '".$results[$j][0]."' AND `access_cours_code` = '".$_course['official_code']."' AND `access_tool` = 'learnpath' ORDER BY access_id ASC LIMIT 1"; $first_access = getOneResult($sql); $first_access = empty($first_access) ? "-" : date('d.m.y',strtotime($first_access)); // last access $sql = "SELECT access_date FROM $TABLETRACK_ACCESS WHERE `access_user_id` = '".$results[$j][0]."' AND `access_cours_code` = '".$_course['official_code']."' AND `access_tool` = 'learnpath'"; $last_access = getOneResult($sql); $last_access = empty($last_access) ? "-" : date('d.m.y',strtotime($last_access)); //--------------------------------END first/last access //--------------------------------BEGIN presentation of data echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; //--------------------------------END presentation of data } } else { echo ""; echo ""; echo""; } echo "
".get_lang('Name')." ".get_lang('FirstAccess')." ".get_lang('LastAccess')." % ".get_lang('Visited')."
".$results[$j][1]." ".$results[$j][2]."".$first_access."".$last_access."".$lpath_pct_completed."
".get_lang('NoResult')."
+  ".get_lang('SynthesisView')."
-   ".get_lang('CourseStats')."   [".get_lang('Close')."]
".get_lang('CountUsers')." : ".$count."
+  ".get_lang('CourseStats')."
-   ".get_lang('CourseAccess')."   [".get_lang('Close')."]
" .get_lang('CountToolAccess')." : ".$count."
".get_lang('Last31days')." : ".$count."
".get_lang('Last7days')." : ".$count."
".get_lang('Thisday')." : ".$count."
".get_lang('TrafficDetails')."
+  ".get_lang('CourseAccess')."
-   ".get_lang('ToolsAccess')."   [".get_lang('Close')."]
"; $results = getManyResults3Col($sql); echo ""; echo ""; if (is_array($results)) { for($j = 0 ; $j < count($results) ; $j++) { echo ""; echo ""; echo ""; echo ""; echo""; } } else { echo ""; echo ""; echo""; } echo "
 ".get_lang('ToolTitleToolnameColumn')."   ".get_lang('ToolTitleUsersColumn')."   ".get_lang('ToolTitleCountColumn')." 
".get_lang($results[$j][0])."".$results[$j][1]."".$results[$j][2]."
".get_lang('NoResult')."
"; echo "
+  ".get_lang('ToolsAccess')."
-   ".get_lang('LinksAccess')."   [".get_lang('Close')."]
"; $results = getManyResultsXCol($sql,4); echo ""; echo ""; if (is_array($results)) { for($j = 0 ; $j < count($results) ; $j++) { echo ""; echo ""; echo ""; echo ""; echo""; } } else { echo ""; echo ""; echo""; } echo "
 ".get_lang('LinksTitleLinkColumn')."   ".get_lang('LinksTitleUsersColumn')."   ".get_lang('LinksTitleCountColumn')." 
".$results[$j][0]."".$results[$j][2]."".$results[$j][3]."
".get_lang('NoResult')."
"; echo "
+  ".get_lang('LinksAccess')."
-   ".get_lang('DocumentsAccess')."   [".get_lang('Close')."]
"; $results = getManyResults3Col($sql); echo ""; echo ""; if (is_array($results)) { for($j = 0 ; $j < count($results) ; $j++) { echo ""; echo ""; echo ""; echo ""; echo""; } } else { echo ""; echo ""; echo""; } echo "
 ".get_lang('DocumentsTitleDocumentColumn')."   ".get_lang('DocumentsTitleUsersColumn')."   ".get_lang('DocumentsTitleCountColumn')." 
".$results[$j][0]."".$results[$j][1]."".$results[$j][2]."
".get_lang('NoResult')."
"; echo "
+  ".get_lang('DocumentsAccess')."
-   ".get_lang('ScormAccess')."   [".get_lang('Close')."]
"; echo ""; if (is_array($ar)) { while ($ar['id'] != '') { $lp_title = stripslashes($ar['name']); echo ""; if ($ar['id']==$scormcontopen) { //have to list the students here $contentId=$ar['id']; $sql2 = "SELECT u.user_id, u.lastname, u.firstname " . "FROM $tbl_learnpath_view sd " . "INNER JOIN $table_user u " . "ON u.user_id = sd.user_id " . "WHERE sd.lp_id=$contentId group by u.user_id"; //error_log($sql2,0); $result2=api_sql_query($sql2,__FILE__,__LINE__); $ar2=Database::fetch_array($result2); while ($ar2 != '') { echo ""; if ($ar2['user_id']==$scormstudentopen) { //have to list the student's results $studentId=$ar2['user_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=$studentId and v.lp_id=$contentId) ORDER BY v.id, i.id"; $result3=api_sql_query($sql3,__FILE__,__LINE__); $ar3=Database::fetch_array($result3); echo ""; while ($ar3['status'] != '') { require_once('../newscorm/learnpathItem.class.php'); $time = learnpathItem::get_scorm_time('php',$ar3['total_time']); $title = htmlentities($ar3['title'],ENT_QUOTES,$lp_charset); echo ""; echo ""; $ar3=Database::fetch_array($result3); } } $ar2=Database::fetch_array($result2); } } $ar=Database::fetch_array($result); } } else { $noscorm=true; } if ($noscorm) { echo ""; echo ""; echo""; } echo "
 ".get_lang('ScormContentColumn')."   ".get_lang('ScormStudentColumn')." 
"; echo "$lp_title"; echo "
   "; echo "{$ar2['lastname']} {$ar2['firstname']}"; echo "
     ".get_lang('ScormTitleColumn')."   ".get_lang('ScormStatusColumn')."   ".get_lang('ScormScoreColumn')."   ".get_lang('ScormTimeColumn')." 
   "; echo "$title{$ar3['status']}{$ar3['score']}$time
".get_lang('NoResult')."
"; echo "
+  ".get_lang('ScormAccess')."