2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
14 exit('this file is no longer used');
16 define('AT_INCLUDE_PATH', '../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
19 $_section[0][0] = _AT('tools');
21 //get the login name or real name for member_id translation
22 $sql14 = "select member_id, login, first_name, last_name from ".TABLE_PREFIX."members";
23 $result14=mysql_query($sql14, $db);
24 while($row=mysql_fetch_array($result14)){
25 if($row['first_name'] && $row['last_name']){
26 $this_user[$row['member_id']]= $row['first_name'].' '. $row['last_name'];
28 $this_user[$row['member_id']]= $row['login'];
33 // Create a CSV dump of the tracking data for this course
34 if($_GET['csv']=='1'){
35 $sql5 = "select * from ".TABLE_PREFIX."g_refs";
36 $result = mysql_query($sql5,$db);
38 while ($row= mysql_fetch_array($result)) {
39 $refs[$row['g_id']] = $row['reference'];
41 //get the g translation for non content pages
47 ".TABLE_PREFIX."g_click_data G,
48 ".TABLE_PREFIX."g_refs R
52 course_id='$_SESSION[course_id]'";
54 if(!$result8 = mysql_query($sql8,$db)){
56 require(AT_INCLUDE_PATH.'footer.inc.php');
60 $title_refs = array();
61 while ($row= mysql_fetch_array($result8)) {
62 $title_refs2[$row['g']] = $row['reference'];
66 //get the translations for the content id numbers
72 ".TABLE_PREFIX."content C
75 course_id='$_SESSION[course_id]'";
76 if(!$result7 = mysql_query($sql7,$db)){
78 require(AT_INCLUDE_PATH.'footer.inc.php');
81 $title_refs = array();
82 while ($row= mysql_fetch_array($result7)) {
83 $title_refs[$row['content_id']] = $row['title'];
87 $name=str_replace(" ", "_", $_SESSION['course_title']);
88 $name=str_replace("'", "", $name);
89 header('Content-Type: text/csv');
90 header('Content-Disposition: inline; filename="'.$name.'_tracking.csv"');
92 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
93 header('Pragma: public');
95 $sqlall="select * from ".TABLE_PREFIX."g_click_data where course_id='$_SESSION[course_id]'";
97 $result_all=mysql_query($sqlall, $db);
98 $num_fields = mysql_num_fields($result_all);
99 for($i=0; $i<$num_fields; $i++){
100 if($i==($num_fields-1)){
101 $this_row .= mysql_field_name($result_all,$i);
103 $this_row .= mysql_field_name($result_all,$i).',';
108 while($row=mysql_fetch_array($result_all)){
109 $this_row .= quote_csv($this_user[$row['member_id']]).",";
110 $this_row .= quote_csv($row['course_id']).",";
111 if($row['from_cid']=='' || $row['from_cid'] == '0'){
113 }else if ($title_refs[$row['from_cid']] == ''){
114 $this_row .= quote_csv(_AT('deleted')).',';
115 }else if ($title_refs[$row['from_cid']] != ''){
116 $this_row .= quote_csv($title_refs[$row['from_cid']]).",";
120 if($row['to_cid']=='' || $row['to_cid'] == '0'){
122 }else if($title_refs[$row['to_cid']] == ''){
123 $this_row .= quote_csv(_AT('deleted')).',';
124 }else if($title_refs[$row['to_cid']] != ''){
125 $this_row .= quote_csv($title_refs[$row['to_cid']]).",";
130 $this_row .= quote_csv(_AT($title_refs2[$row['g']])).",";
131 $this_row.= AT_date(_AT('forum_date_format'),$row['timestamp'], AT_DATE_UNIX_TIMESTAMP).",";
132 $this_row.= quote_csv($row['duration'])."\n";
135 if (!@opendir(AT_CONTENT_DIR . 'export/')){
136 mkdir(AT_CONTENT_DIR . 'export/', 0777);
139 $fp = @fopen(AT_CONTENT_DIR . 'export/'.$name.'_tracking.csv', 'w');
141 $errors=array('CSV_FAILED', $name);
142 $msg->printErrors($errors);
145 @fputs($fp, $this_row); @fclose($fp);
146 @readfile(AT_CONTENT_DIR . 'export/'.escapeshellcmd($name).'_tracking.csv');
147 @unlink(AT_CONTENT_DIR . 'export/'.escapeshellcmd($name).'_tracking.csv');
154 require(AT_INCLUDE_PATH.'header.inc.php');
156 // Give the user two chances when deleting tracking data
157 if ($_GET['reset']==1){
158 echo '<a name="warning"></a>';
159 $warnings=array('DELETE_TRACKING', $_SERVER['PHP_SELF']);
160 $msg->printWarnings($warnings);
162 /* Since we do not know which choice will be taken, assume it No/Cancel, addFeedback('CENCELLED)
163 * If sent to results.php then OK, else if sent back here & if $_GET['reset']=2 then assumed choice was not taken
164 * ensure that addFeeback('CANCELLED') is properly cleaned up, see below
166 $msg->addFeedback('CANCELLED');
167 echo '<center><a href="'.$_SERVER['PHP_SELF'].'?reset=2">'._AT('yes_delete').'</a> | <a href="'.$_SERVER['PHP_SELF'].'">'._AT('no').'</a></center>';
168 require(AT_INCLUDE_PATH.'footer.inc.php');
170 } else if($_GET['reset']==2) {
171 /* We must ensure that any previous feedback is flushed,
172 * since AT_FEEDBACK_CANCELLED might be present
173 * if Yes/Delete was chosen above when reset was = 1
175 $msg->deleteFeedback('CANCELLED'); // makes sure its not there
177 $sql_delete= "delete from ".TABLE_PREFIX."g_click_data where course_id='$_SESSION[course_id]'";
178 if ($result_delete_track=mysql_query($sql_delete, $db)){
179 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
181 $msg->addError('TRACKING_NOT_DELETED');
182 require(AT_INCLUDE_PATH.'footer.inc.php');
186 /////////////////////////////
190 //This page is only for instructor/owners
191 if(!authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)){
192 $msg->printInfos('NO_PERMISSION');
193 require(AT_INCLUDE_PATH.'footer.inc.php');
198 //see if tracking is turned on
199 $sql="SELECT tracking from ".TABLE_PREFIX."courses where course_id=$_SESSION[course_id]";
200 $result=mysql_query($sql, $db);
201 while($row= mysql_fetch_array($result)){
202 if($row['tracking'] == "off"){
203 if(authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)){
204 $msg->addInfo('TRACKING_OFFIN');
206 $msg->addInfo('TRACKING_OFFST');
209 require(AT_INCLUDE_PATH.'footer.inc.php');
214 $msg->printWarnings();
218 <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?stats=summary#show_pages"><?php echo _AT('g_show_page_stats'); ?></a>
219 <br /><?php echo _AT('g_show_page_stats_desc'); ?>
221 <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?stats=student#show_members"><?php echo _AT('g_show_member_stats'); ?></a>
222 <br /><?php echo _AT('g_show_member_stats_desc'); ?>
224 <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?csv=1"><?php echo _AT('g_download_tracking_csv'); ?></a>
225 <br /><?php echo _AT('g_download_tracking_csv_desc'); ?>
227 <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?reset=1#warning"><?php echo _AT('g_reset_tracking'); ?></a>
228 <br /><?php echo _AT('g_reset_tracking_desc'); ?>
235 // present the id picker
236 if($_GET['stats']=='student' || $_GET['member_id']){
238 $sql = "select DISTINCT member_id from ".TABLE_PREFIX."g_click_data where course_id='$_SESSION[course_id]' order by member_id DESC";
239 $result = mysql_query($sql, $db);
241 //get the course enrollment
242 $sql2="select * from ".TABLE_PREFIX."course_enrollment where course_id='$_SESSION[course_id]' AND approved='y'";
243 $result2 = mysql_query($sql2, $db);
244 while($row2 = mysql_fetch_array($result2)){
245 $enrolled[$row2['member_id']] = $row2['member_id'];
248 <a name="show_members"></a>
249 <table class="data static" rules="cols" summary="">
252 <th><?php echo _AT('select_member'); ?></th>
259 if($_GET['summary2'] == "summary") {
260 $select_summary = ' checked="checked"';
261 } else if($_GET['summary2'] == "raw") {
262 $select_raw = ' checked="checked"';
265 <form action="<?php echo $_SERVER['PHP_SELF']; ?>#show_members" method="GET">
266 <input type="radio" name="summary2" id="summary2" value="summary" <?php echo $select_summary; ?>><label for="summary2"><?php echo _AT('summary'); ?> </label>
267 <input type="radio" id="summary" name="summary2" value="raw" <?php echo $select_raw; ?>><label for="summary"><?php echo _AT('raw'); ?> </label>
268 <select name="member_id">
270 while($row = mysql_fetch_array($result)){
271 if($row['member_id'] == $enrolled[$row['member_id']]){
273 echo '<option value="'.$row['member_id'].'" ';
274 if($_GET['member_id']==$row['member_id']){
275 echo ' selected="selected"';
277 echo '>'.$this_user[$row['member_id']].'</option>'."\n";
282 <input type="submit" value="<?php echo _AT('view_tracking'); ?>" class="button" />
291 if($_GET['stats'] =="details" || $_GET['stats'] == "summary" || $_GET['g_id'] || $_GET['csv']== 1) {
292 require(AT_INCLUDE_PATH.'lib/tracker_stats.inc.php');
295 else if ($_GET['summary2'] == "summary") {
296 require(AT_INCLUDE_PATH.'lib/tracker_stats2.inc.php');
300 require(AT_INCLUDE_PATH.'lib/tracker.inc.php');
303 require(AT_INCLUDE_PATH.'footer.inc.php');
306 function quote_csv($line) {
307 $line = str_replace('"', '""', $line);
309 $line = str_replace("\n", '\n', $line);
310 $line = str_replace("\r", '\r', $line);
311 $line = str_replace("\x00", '\0', $line);
313 return '"'.$line.'"';