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 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN);
19 $year = intval($_GET['year']);
20 $month = intval($_GET['month']);
28 $sql = "SELECT * FROM ".TABLE_PREFIX."course_stats WHERE course_id=$_SESSION[course_id] AND MONTH(login_date)=$month AND YEAR(login_date)=$year ORDER BY login_date ASC";
29 $result = mysql_query($sql, $db);
30 //$today = 1; /* we start on the 1st of the month */
31 $max_total_logins = 0;
32 $min_total_logins = (int) 99999999;
36 while ($row = mysql_fetch_array($result)) {
38 $row_day = substr($row['login_date'], 8, 2);
40 if (substr($row_day, 0,1) == '0') {
41 $row_day = substr($row_day, 1, 1);
44 while ($today < $row_day-1) {
46 $days[$today] = array(0, 0);
47 $min_total_logins = 0;
50 $today = $row_day; /* skip this day in the fill-in-the-blanks-loop */
52 $days[$row_day] = array($row['guests'], $row['members']);
54 if ($max_total_logins < $row['guests']+$row['members']) {
55 $max_total_logins = $row['guests']+$row['members'];
58 if ($min_total_logins > $row['guests']+$row['members']) {
59 $min_total_logins = $row['guests']+$row['members'];
62 $total_logins += $row['guests']+$row['members'];
65 /* add zeros to the end of the month, only if it isn't the current month */
66 $now_month = date('m');
67 $now_year = date('Y');
68 if ( (($month < $now_month) && ($now_year == $year)) || ($now_year < $year) ) {
70 while (checkdate($month, $today,$year)) {
71 $days[$today] = array(0, 0);
75 $num_days = count($days);
77 if ($total_logins > 0) {
78 $avg_total_logins = $total_logins/$num_days;
80 $avg_total_logins = 0;
84 $multiplyer_height = 5; /* should be multiples of 5 */
88 $next_year = $year + 1;
90 $next_month = $month + 1;
96 $last_year = $year - 1;
98 $last_month = $month - 1;
102 require(AT_INCLUDE_PATH.'header.inc.php');
104 $savant->assign('last_month', $last_month);
105 $savant->assign('last_year', $last_year);
106 $savant->assign('month', $month);
107 $savant->assign('next_month', $next_month);
108 $savant->assign('next_year', $next_year);
109 $savant->assign('num_days', $num_days);
110 $savant->assign('empty', $empty);
111 $savant->assign('total_logins', $total_logins);
112 $savant->assign('min_total_logins', $min_total_logins);
113 $savant->assign('max_total_logins', $max_total_logins);
114 $savant->assign('avg_total_logins', $avg_total_logins);
115 $savant->assign('multiplyer_height', $multiplyer_height);
116 $savant->assign('block_height', $block_height);
117 $savant->assign('days', $days);
118 $savant->assign('result', $result);
119 $savant->assign('short_name', $short_name);
120 $savant->display('instructor/statistics/course_stats.tmpl.php');
121 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>