remove old readme
[atutor.git] / mods / _standard / tracker / tools / index.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2010                                              */\r
6 /* Inclusive Design Institute                                       */\r
7 /* http://atutor.ca                                                     */\r
8 /*                                                                      */\r
9 /* This program is free software. You can redistribute it and/or        */\r
10 /* modify it under the terms of the GNU General Public License          */\r
11 /* as published by the Free Software Foundation.                        */\r
12 /************************************************************************/\r
13 // $Id$\r
14 \r
15 define('AT_INCLUDE_PATH', '../../../../include/');\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
17 authenticate(AT_PRIV_CONTENT);\r
18 \r
19 require(AT_INCLUDE_PATH.'header.inc.php');\r
20 \r
21 \r
22 $orders = array('asc' => 'desc', 'desc' => 'asc');\r
23 $cols   = array('total_hits' => 1, 'unique_hits' => 1, 'average_duration' => 1, 'total_duration' => 1);\r
24 \r
25 if (isset($_GET['asc'])) {\r
26         $order = 'asc';\r
27         $col   = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'total_hits';\r
28 } else if (isset($_GET['desc'])) {\r
29         $order = 'desc';\r
30         $col   = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'total_hits';\r
31 } else {\r
32         // no order set\r
33         $order = 'desc';\r
34         $col   = 'total_hits';\r
35 }\r
36 \r
37 $page_string = SEP.$order.'='.$col;\r
38 \r
39 if (!isset($_GET['cnt'])) {\r
40         $sql    = "SELECT COUNT(DISTINCT content_id) AS cnt FROM ".TABLE_PREFIX."member_track WHERE course_id=$_SESSION[course_id]";\r
41         $result = mysql_query($sql, $db);\r
42         $row = mysql_fetch_assoc($result);\r
43         $cnt = $row['cnt'];\r
44 } else {\r
45         $cnt = intval($_GET['cnt']);\r
46 }\r
47 \r
48 $num_results = $cnt;\r
49 $results_per_page = 15;\r
50 $num_pages = max(ceil($num_results / $results_per_page), 1);\r
51 $page = intval($_GET['p']);\r
52 if (!$page) {\r
53         $page = 1;\r
54 }       \r
55 $count = (($page-1) * $results_per_page) + 1;\r
56 \r
57 $offset = ($page-1)*$results_per_page;\r
58 \r
59 /*create a table that lists all the content pages and the number of time they were viewed*/\r
60 $sql = "SELECT content_id, COUNT(*) AS unique_hits, SUM(counter) AS total_hits, SEC_TO_TIME(SUM(duration)/SUM(counter)) AS average_duration, SEC_TO_TIME(SUM(duration)) AS total_duration FROM ".TABLE_PREFIX."member_track WHERE course_id=$_SESSION[course_id] GROUP BY content_id ORDER BY $col $order LIMIT $offset, $results_per_page";\r
61 $result = mysql_query($sql, $db);\r
62 $savant->assign('result', $result);\r
63 $savant->assign('col', $col);\r
64 $savant->assign('page_string', $page_string);\r
65 $savant->assign('page', $page);\r
66 $savant->assign('num_pages', $num_pages);\r
67 $savant->display('instructor/content/tracker/index.tmpl.php');\r
68 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>