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 /****************************************************************/
13 /////////////////////////////
14 //Display the g_data bar chart for the member selected
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
17 // NOTE: this script should not be altered. its use will soon be deprecated.
20 //get the summary data for all pages
22 //get the translations for the g numbers
23 $to_cid = $_GET['to_cid'];
24 $stats = $_GET['stats'];
25 $g_id = $_GET['g_id'];
26 $sql5 = "select * from ".TABLE_PREFIX."g_refs";
27 $result = mysql_query($sql5, $db);
29 while ($row= mysql_fetch_array($result)) {
30 $refs[$row['g_id']] = $row['reference'];
34 //get the g translation for non content pages
40 ".TABLE_PREFIX."g_click_data G,
41 ".TABLE_PREFIX."g_refs R
45 course_id='$_SESSION[course_id]'";
47 if(!$result8 = mysql_query($sql8, $db)){
48 require(AT_INCLUDE_PATH.'footer.inc.php');
52 $title_refs = array();
53 while ($row= mysql_fetch_assoc($result8)) {
54 $title_refs2[$row['g']] = $row['reference'];
58 //get the translations for the content id numbers
64 ".TABLE_PREFIX."content C
67 course_id='$_SESSION[course_id]'";
68 if(!$result7 = mysql_query($sql7, $db)){
69 require(AT_INCLUDE_PATH.'footer.inc.php');
72 $title_refs = array();
73 while ($row= mysql_fetch_array($result7)) {
74 $title_refs[$row['content_id']] = $row['title'];
78 //get tools ATutor tools traffic
87 ".TABLE_PREFIX."g_click_data G,
88 ".TABLE_PREFIX."g_refs R
92 course_id='$_SESSION[course_id]'";
93 $title_tools = array();
94 $result9 = mysql_query($sql9, $db);
95 while ($row= mysql_fetch_array($result9)) {
96 if($row['g'] == $row['g_id']){
97 $title_tools[$row['g_id']] = $row['reference'];
98 $tool_grefs[$row['g_id']] = $row['g_id'];
99 $gcount[$row['g_id']]++;
102 $sql10 = "select count(g) from ".TABLE_PREFIX."g_click_data where course_id='$_SESSION[course_id]' GROUP BY g";
103 $result10 = mysql_query($sql10, $db);
104 while($row=mysql_fetch_array($result10)){
109 if($_GET['stats']="summary" && !$to_cid &&!$_GET['csv'] && !$_GET['g_id']){
111 $sql12= "select to_cid, g, AVG(duration) AS t, count(g) as c from ".TABLE_PREFIX."g_click_data where to_cid='0' AND course_id='$_SESSION[course_id]' GROUP BY g";
113 if($result12=mysql_query($sql12, $db)){
114 while($row=mysql_fetch_array($result12)){
116 $nav_total = ($nav_total + $row['c']);
118 if($row['to_cid']==0){
119 $that_time[$row['g']]= $row['t'];
123 echo _AT('unknown_error');
127 <a name="show_pages"></a>
128 <h3><?php echo _AT('tool_summary'); ?></h3>
129 <table class="data static" rules="cols" summary="">
132 <th><?php echo _AT('at_tools'); ?></th>
133 <th><?php echo _AT('hit_count'); ?></th>
134 <th><?php echo _AT('avg_duration'); ?></th>
135 <th><?php echo _AT('details'); ?></th>
141 //this array needs to be created from the database
142 //(eventually add new field to g_refs table called "timed" values true/false
143 $timed_tools=array(14=>14, 15=>15, 16=>16, 17=>17, 18=>18, 20=>20, 21=>21, 23=>23, 27=>27, 28=>28, 29=>29, 31=>31, 32=>32, 35=>35);
145 foreach($title_tools as $key=>$value) {
146 $tool_names[$key] = $gcount[$key];
149 if (is_array($tool_names)) {
152 foreach($tool_names as $key=>$value) {
154 echo '<td>' . _AT($title_tools[$key]) . '</td>';
155 echo '<td><img src="images/bar.gif" height="12" width="' . ((($gcount[$key]/$nav_total)*100)*2) . '" alt="" />' . $value . '</td>';
158 if($timed_tools[$key]==$key) {
159 $that_avgtime=number_format((number_format($that_time[$key], 1 )/$gcount[$key]),1);
170 echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?g_id=' . $key . '#show_pages">' . _AT('details') . '</a></td>';
180 <h3><?php echo _AT('page_stats'); ?></h3>
181 <table class="data static" rules="cols" summary="">
184 <th><?php echo _AT('page_title'); ?></th>
185 <th><?php echo _AT('hit_count'); ?></th>
186 <th><?php echo _AT('avg_duration'); ?></th>
187 <th><?php echo _AT('details'); ?></th>
191 //get content page traffic
192 $sql6 = "SELECT G.to_cid, count(*) AS pages, G.g
193 FROM ".TABLE_PREFIX."g_click_data G
194 WHERE G.to_cid <> 0 AND course_id='$_SESSION[course_id]'
197 $result6 = mysql_query($sql6, $db);
201 require(AT_INCLUDE_PATH.'footer.inc.php');
205 $sql11 = "SELECT to_cid, AVG(duration) AS t FROM ".TABLE_PREFIX."g_click_data WHERE course_id='$_SESSION[course_id]' GROUP BY to_cid";
206 $result11 = mysql_query($sql11, $db);
209 while($row = mysql_fetch_array($result11)) {
210 $this_time[$row['to_cid']]= $row['t'];
215 echo _AT('unknown_error');
218 $max_bar_width='180';
219 $result9 = mysql_query($sql6, $db);
221 while($row = mysql_fetch_array($result9)) {
222 $total_hits=($total_hits + $row["pages"]);
225 $bar_factor = ($max_bar_width/$total_hits);
228 if ($result6 = mysql_query($sql6, $db)) {
232 while($row = mysql_fetch_array($result6)) {
233 if($title_refs[$row['to_cid']] != '') {
235 echo '<td>' . $title_refs[$row['to_cid']] . '</td>';
236 echo '<td><img src="images/bar.gif" height="12" width="' . ($row["pages"]*$bar_factor) . '" alt="" />' . $row["pages"] . '</td>';
238 $this_avgtime=(number_format($this_time[$row['to_cid']], 1 )/$row["pages"]);
240 echo '<td>' . number_format($this_avgtime, 1) . '</td>';
241 echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?stats=details' . SEP . 'to_cid=' . $row['to_cid'] . '#show_pages">' . _AT('details') . '</a></td>';
252 //get the rawdata for a single page
253 if(authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)){
255 ".TABLE_PREFIX."content.title,
256 ".TABLE_PREFIX."content.content_id,
257 ".TABLE_PREFIX."g_click_data.member_id as m,
258 ".TABLE_PREFIX."g_click_data.to_cid,
259 ".TABLE_PREFIX."g_click_data.g,
260 ".TABLE_PREFIX."g_click_data.timestamp AS t
262 ".TABLE_PREFIX."content,
263 ".TABLE_PREFIX."g_click_data
265 ".TABLE_PREFIX."content.content_id=".TABLE_PREFIX."g_click_data.to_cid
267 ".TABLE_PREFIX."g_click_data.to_cid=$to_cid
269 ".TABLE_PREFIX."g_click_data.course_id=$_SESSION[course_id]";
273 $result3=mysql_query($sql3, $db);
275 while($row=mysql_fetch_array($result3)){
276 $this_data[$row["t"]]= $row;
277 $this_user[$row["t"]]= $row['m'];
280 $current = current($this_data);
281 $pre_time = $current[t];
290 <a name="show_pages"></a>
292 [<a href="<?php echo $_SERVER['PHP_SELF'].'?stats=summary';?>#show_pages"><?php echo _AT('back_to_summary'); ?></a>]
295 <h3><?php echo _AT('access_stats'); ?>: <?php echo $current['title']; ?></h3>
298 <table class="data static" rules="cols" summary="">
301 <th scope="col"><?php echo _AT('access_method'); ?></th>
302 <th scope="col"><?php echo _AT('count'); ?></th>
307 //get the number of clicks per g
312 ".TABLE_PREFIX."g_click_data
316 course_id='$_SESSION[course_id]'
320 if($result2 = mysql_query($sql2, $db)){
322 while($row = mysql_fetch_array($result2)){
325 foreach($refs AS $key => $value){
331 echo '<td><img src="images/bar.gif" height="12" width="' . ($row["cnt"]*2) . '" alt="" />' . $row["cnt"] . '</td>';
342 ".TABLE_PREFIX."g_click_data.g,
343 ".TABLE_PREFIX."g_click_data.member_id AS m,
344 ".TABLE_PREFIX."g_click_data.to_cid,
345 ".TABLE_PREFIX."g_click_data.timestamp AS t
347 ".TABLE_PREFIX."g_click_data
349 ".TABLE_PREFIX."g_click_data.to_cid=0
351 ".TABLE_PREFIX."g_click_data.to_cid=$to_cid
353 ".TABLE_PREFIX."g_click_data.course_id=$_SESSION[course_id]
357 $result4 = mysql_query($sql4, $db);
363 echo '<a name="show_pages"></a>';
364 echo '<h3>'._AT('pages_stats', $current["title"]).'</h3>';
366 echo '<table class="data static" rules="cols" summary="">';
369 echo '<th scope="col">' . _AT('access_method') . '</th>';
370 echo '<th scope="col">' . _AT('duration_sec') . '</th>';
371 echo '<th scope="col">' . _AT('date') . '</th>';
372 echo '<th scope="col">' . _AT('student_id') . '</th>';
376 foreach($this_data AS $key => $value){
378 $start_date=$pre_time;
380 $diff = abs($value[t] - $pre_time);
385 if($start_date>0 && $start_date!=$pre_time){
386 echo _AT('session_start').' '.date("F j, Y, g:i a", $start_date).' '._AT('session_end').' '.date("F j, Y, g:i a", $pre_time).' ('._AT('duration').':'.date('i \m\i\n s \s\e\c',($pre_time-$start_date)).')';
391 else if($value[g]==19) {
392 //don't do anything if its a logout
395 echo _AT('invalid_session');
402 $start_date=$value[t];
407 $that_g=$refs[$value['g']];
417 $this_time=date('i.s', $diff);
419 $session_time=($session_time+$diff);
421 $remainder = $diff / 60;
426 echo '<td>'.$this_user[$value['m']].'</td>';
428 $that_date=date("M-j-y g:i:s:a", $value[t]);
429 $that_title=$value[title]." ";
430 $pre_time = $value['t'];
436 } /// end page detail
439 $sql14 = "select member_id, login, first_name, last_name from ".TABLE_PREFIX."members";
440 $result14=mysql_query($sql14, $db);
441 while($row=mysql_fetch_array($result14)){
442 if($row['first_name'] && $row['last_name']){
443 $this_user[$row['member_id']]= $row['first_name'].' '. $row['last_name'];
445 $this_user[$row['member_id']]= $row['login'];
449 $sql13 = "select *, timestamp as t from ".TABLE_PREFIX."g_click_data where to_cid='0' AND g='$_GET[g_id]' AND course_id='$_SESSION[course_id]'";
450 $result13 = mysql_query($sql13, $db);
451 echo '<a name="show_pages"></a>';
452 echo '<h3>'._AT('tools_details').' ('._AT($title_refs2[$g_id]).')</h3>';
453 echo '<p>[<a href="'.$_SERVER['PHP_SELF'].'?stats=summary#show_pages">'._AT('back_to_summary'),'</a>]</p>';
455 echo '<table class="data static" rules="cols" summary="">';
458 echo '<th scope="col">' . _AT('origin_page') . '</th>';
459 echo '<th scope="col">' . _AT('duration_sec') . '</th>';
460 echo '<th scope="col">' . _AT('date') . '</th>';
461 echo '<th scope="col">' . _AT('student_id') . '</th>';
467 while ($row=mysql_fetch_array($result13)){
469 if ($row['from_cid'] == 0) {
470 echo '<td>'._AT($title_refs2[$row['g']]).'</td>';
472 else if ($title_refs[$row['from_cid']] != '') {
473 echo '<td>'.$title_refs[$row['from_cid']].'</td>';
477 if ($title_refs[$row['from_cid']] != '' || $row['from_cid'] == 0) {
478 echo '<td>'.$row['duration'].'</td>';
479 echo '<td>'.date("M-j-y g:i:s:a",$row['t'] ).'</td>';
480 echo '<td>'.$this_user[$row['member_id']].'</td>';