Source for file courseLogCSV.php
Documentation is available at courseLogCSV.php
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2006 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Author: Frederic Vauthier (frederic.vauthier@dokeos.com)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
==============================================================================
==============================================================================
* @author Thomas Depraetere
* @author Christophe Gesche
* @author Sebastien Piraux
* @author Toon Keppens (Vi-Host.net)
* @package dokeos.tracking
==============================================================================
==============================================================================
==============================================================================
$pathopen = isset ($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
// name of the language file that needs to be included
$language_file = "tracking";
include('../inc/global.inc.php');
//includes for SCORM and LP
require_once('../newscorm/learnpath.class.php');
require_once('../newscorm/learnpathItem.class.php');
require_once('../newscorm/scorm.class.php');
require_once('../newscorm/scormItem.class.php');
if ($_GET['scormcontopen'])
$contopen = (int) $_GET['scormcontopen'];
$sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ". $contopen;
$lp_charset = $row['default_encoding'];
//header('Content-Type: text/html; charset='. $row['default_encoding']);
-----------------------------------------------------------
-----------------------------------------------------------
// regroup table names for maintenance purpose
//$table_scormdata = Database::get_scorm_table(TABLE_SCORM_SCO_DATA);
//$table_scormmain = Database::get_scorm_table(TABLE_SCORM_MAIN);
//$tbl_learnpath_main = Database::get_course_table(TABLE_LEARNPATH_MAIN);
//$tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
//$tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
$view = $_REQUEST['view'];
if($view== "0000001") $nameTools= get_lang('SynthesisView');
if($view== "1000000") $nameTools= get_lang('CourseStats');
if($view== "0100000") $nameTools= get_lang('CourseAccess');
if($view== "0010000") $nameTools= get_lang('ToolsAccess');
if($view== "0001000") $nameTools= get_lang('LinksAccess');
if($view== "0000100") $nameTools= get_lang('DocumentsAccess');
if($view== "00000010") $nameTools= get_lang('ScormAccess');
$interbreadcrumb[] = array ("url" => api_get_self(). "?view=0000000", "name" => get_lang('ToolName'));
include(api_get_path(LIBRARY_PATH). "statsUtils.lib.inc.php");
include("../resourcelinker/resourcelinker.inc.php");
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin;
==============================================================================
==============================================================================
$title[0]= get_lang('StatsOfCourse'). " : ". $_course['official_code'];
// check if uid is prof of this group
if($is_allowedToTrack && $_configuration['tracking_enabled'])
// show all : view must be equal to the sum of all view values (1024+512+...+64)
// show none : less than the tiniest value
[<a href='".api_get_self()."?view=1111111'>".get_lang('ShowAll')."</a>]
[<a href='".api_get_self()."?view=0000000'>".get_lang('ShowNone')."</a>]
if(!isset ($view)) $view = "0000000";
/***************************************************************************
***************************************************************************/
//--------------------------------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`";
//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. "'";
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];
// 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')";
// calculation & bgcolor setting
$lpath_pct_completed = empty($total_lpath_items) ? "-" : round(($total_lpath_items_completed / $total_lpath_items) * 100);
//--------------------------------END % visited
//--------------------------------BEGIN first/last 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 = empty($first_access) ? "-" : date('d.m.y',strtotime($first_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 = empty($last_access) ? "-" : date('d.m.y',strtotime($last_access));
//--------------------------------END first/last access
//--------------------------------BEGIN presentation of data
$line .= $results[$j][1]. " ". $results[$j][2]. ";". $first_access. ";". $last_access. ";". $lpath_pct_completed. "\n";
//--------------------------------END presentation of data
/***************************************************************************
***************************************************************************/
WHERE course_code = '". $_cid. "'";
$title_line = get_lang('CountUsers'). " ; ". $count. "\n";
/***************************************************************************
***************************************************************************/
$title[1]= get_lang('ConnectionsToThisCourse');
WHERE access_cours_code = '". $_cid. "'
AND access_tool IS NULL";
$line .= get_lang('CountToolAccess'). " ; ". $count. "\n";
WHERE `access_cours_code` = '$_cid'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -31 DAY))
AND access_tool IS NULL";
$line .= get_lang('Last31days'). " ; ". $count. "\n";
WHERE `access_cours_code` = '$_cid'
AND (access_date > DATE_ADD(CURDATE(), INTERVAL -7 DAY))
AND access_tool IS NULL";
$line .= get_lang('Last7days'). " ; ". $count. "\n";
WHERE `access_cours_code` = '$_cid'
AND ( access_date > CURDATE() )
AND access_tool IS NULL";
$line .= get_lang('Thisday'). " ; ". $count. "\n";
/***************************************************************************
***************************************************************************/
$title_line = get_lang('ToolTitleToolnameColumn'). ";". get_lang('ToolTitleUsersColumn'). ";". get_lang('ToolTitleCountColumn'). "\n";
$sql = "SELECT `access_tool`, COUNT(DISTINCT `access_user_id`),count( `access_tool` )
WHERE `access_tool` IS NOT NULL
AND `access_cours_code` = '$_cid'
for($j = 0 ; $j < count($results) ; $j++ )
$line .= $results[$j][0]. "/". get_lang($results[$j][0]). ";". $results[$j][1]. ";". $results[$j][2]. "\n";
/***************************************************************************
***************************************************************************/
$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`";
$title_line = get_lang('LinksTitleLinkColumn'). ";". get_lang('LinksTitleUsersColumn'). ";". get_lang('LinksTitleCountColumn'). "\n";
for($j = 0 ; $j < count($results) ; $j++ )
$line .= $results[$j][1]. "'>". $results[$j][0]. ";". $results[$j][2]. ";". $results[$j][3]. "\n";
/***************************************************************************
***************************************************************************/
$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`";
$title_line = get_lang('DocumentsTitleDocumentColumn'). ";". get_lang('DocumentsTitleUsersColumn'). ";". get_lang('DocumentsTitleCountColumn'). "\n";
for($j = 0 ; $j < count($results) ; $j++ )
$line .= $results[$j][0]. ";". $results[$j][1]. ";". $results[$j][2]. "\n";
/***************************************************************************
* Scorm contents and Learning Path
***************************************************************************/
FROM $tbl_learnpath_main";
//WHERE dokeosCourse='$_cid'"; we are using a table inside the course now, so no need for course id
$title_line = get_lang('ScormContentColumn');
$scormcontopen= $_REQUEST["scormcontopen"];
$scormstudentopen= $_REQUEST["scormstudentopen"];
while ($ar['id'] != '') {
//echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."' class='specialLink'>$lp_title</a>";
if ($ar['id']== $scormcontopen) { //have to list the students here
$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";
if (isset ($_REQUEST["scormstudentopen"]) && $ar2['user_id']== $scormstudentopen) {
$line .= $ar['id']. " ". $ar2['user_id']. " ". $ar2['lastname']. " ". $ar2['firstname'];
$line .= $ar['id']. " ". $ar2['user_id']. " ". $ar2['lastname']. " ". $ar2['firstname'];
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";
while ($ar3['status'] != '') {
require_once('../newscorm/learnpathItem.class.php');
$title = htmlentities($ar3['title'],ENT_QUOTES,$lp_charset);
$line .= $title. ";". $ar3['status']. ";". $ar3['score']. ";". $time;
/***************************************************************************
* force the browser to save the file instead of opening it
***************************************************************************/
$len = strlen($title_line. $line);
header('Content-type: application/octet-stream');
//header('Content-Type: application/force-download');
header('Content-length: '. $len);
if(preg_match("/MSIE 5.5/",$_SERVER['HTTP_USER_AGENT']))
header('Content-Disposition: filename= '. $filename);
header('Content-Disposition: attachment; filename= '. $filename);
if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
header('Cache-Control: public'); // IE cannot download from sessions without a cache
header('Content-Description: '. $filename);
header('Content-transfer-encoding: binary');
if(!$_configuration['tracking_enabled'])
|