86ebd6d3b3e1294b00e86ee7dad50e5b2c8d0da4
[atutor.git] / docs / mods / _standard / tracker / lib / tracker_stats2.inc.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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 // $Id$
14
15 // NOTE: this script should not be altered. its use will soon be deprecated.
16
17 if (!defined('AT_INCLUDE_PATH')) { exit; }
18
19 //how many content pages are in this course
20 $sql25 = "SELECT content_id from ".TABLE_PREFIX."content where course_id = $_SESSION[course_id]";
21 $result29 = mysql_query($sql25, $db);
22 $num_rows_total = @mysql_num_rows($result29);
23
24 //get the title for each content_id
25 $sql7 = "select
26                         C.title,
27                         C.content_id
28
29                 from
30                         ".TABLE_PREFIX."content C
31                 where
32                         course_id='$_SESSION[course_id]'";
33
34         if(!$result7 = mysql_query($sql7, $db)){
35                 echo "query failed";
36                 require(AT_INCLUDE_PATH.'footer.inc.php');
37                 exit;
38         }
39         $title_refs = array();
40         while ($row= mysql_fetch_array($result7)) {
41                 $title_refs[$row['content_id']] = $row['title'];
42
43         }
44
45 $sql2 = "SELECT * FROM ".TABLE_PREFIX."g_click_data WHERE member_id = $_GET[member_id] AND course_id = $_SESSION[course_id]";
46 $result28 = mysql_query($sql2, $db);
47
48 echo '<br /><h3>'._AT('tracker_summary_read', $this_user[$_GET['member_id']]).'</h3>';
49
50 echo '<table class="data static" rules="cols" summary="">';
51 echo '<thead>';
52 echo '<tr>';
53 echo '<th>' . _AT('page')         . '</th>';
54 echo '<th>' . _AT('visits')       . '</th>';
55 echo '<th>' . _AT('duration_sec') . '</th>';
56 echo '</tr>';
57 echo '</thead>';
58
59 while ($row2= @mysql_fetch_assoc($result28)){
60         $duration[$row2['to_cid']] = ($duration[$row2['to_cid']] + $row2['duration']);
61         $visits[$row2['to_cid']] = ($visits[$row2['to_cid']] +1);
62 }
63
64 $sql= "SELECT DISTINCT to_cid FROM ".TABLE_PREFIX."g_click_data WHERE member_id = $_GET[member_id] AND course_id = $_SESSION[course_id]";
65 $result27 = mysql_query($sql, $db);
66
67 echo '<tbody>';
68 while ($row= @mysql_fetch_array($result27)) {
69         if($row['to_cid']){
70                 $num_rows_read = ($num_rows_read +1);
71                 echo '<tr>';
72                 echo '<td>' . $title_refs[$row['to_cid']] . '</td>';
73                 echo '<td>' . $visits[$row['to_cid']] . '</td>';
74                 echo '<td>' . number_format($duration[$row['to_cid']]) . '</td>';
75                 echo '</tr>';
76         }
77 }
78
79 echo '<tr>';
80 echo '<td>' . _AT('tracker_pages_total', $num_rows_total, $num_rows_read).'</td>';
81 echo '<td>' . _AT('tracker_percent_read',@number_format((($num_rows_read/$num_rows_total)*100),1)) . '%</td>';
82 echo '</tr>';
83
84 echo '<tbody>';
85 echo '</table>';
86
87 ?>