2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 require_once(AT_INCLUDE_PATH.'lib/test_result_functions.inc.php');
18 /* help for content pages */
20 if (FALSE && defined('AT_SHOW_TEST_BOX') && AT_SHOW_TEST_BOX) {
21 // print new available tests
23 $sql = "SELECT T.test_id, T.title FROM ".TABLE_PREFIX."tests T WHERE T.course_id=$_SESSION[course_id] AND T.start_date<=NOW() AND T.end_date>= NOW() ORDER BY T.start_date, T.title";
24 $result = mysql_query($sql, $db);
25 $num_tests = mysql_num_rows($result);
27 while (($row = mysql_fetch_assoc($result)) && authenticate_test($row['test_id'])) {
28 $tests .= '<a href="'.$_base_path.'tools/take_test.php?tid='.$row['test_id'].'">'.$row['title'].'</a><br />';
32 <table border="0" cellspacing="0" cellpadding="0" align="center">
34 <td class="test-box"><small><a href="<?php echo AT_BASE_HREF; ?>tools/my_tests.php?g=32"><?php echo _AT('curren_tests_surveys'); ?></a></small></td>
37 <td class="dropdown"><?php echo $tests; ?></td>
44 /* the "home" links: */
45 $home_links = get_home_navigation();
46 $savant->assign('home_links', $home_links);
49 /* the news announcements: */
52 $page = intval($_GET['p']);
57 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."news WHERE course_id=$_SESSION[course_id]";
58 $result = mysql_query($sql, $db);
60 if ($row = mysql_fetch_assoc($result)) {
61 $num_results = $row['cnt'];
62 $results_per_page = NUM_ANNOUNCEMENTS;
63 $num_pages = ceil($num_results / $results_per_page);
65 $count = (($page-1) * $results_per_page) + 1;
67 $offset = ($page-1)*$results_per_page;
69 $sql = "SELECT N.* FROM ".TABLE_PREFIX."news N WHERE N.course_id=$_SESSION[course_id] ORDER BY date DESC LIMIT $offset, $results_per_page";
71 $result = mysql_query($sql, $db);
72 while ($row = mysql_fetch_assoc($result)) {
73 /* this can't be cached because it called _AT */
75 $news[$row['news_id']] = array(
76 'date' => AT_date( _AT('announcement_date_format'),
78 AT_DATE_MYSQL_DATETIME),
79 'title' => AT_print($row['title'], 'news.title'),
80 'body' => AT_print($row['body'], 'news.body', $row['formatting']));
84 $savant->assign('announcements', $news);
85 $savant->assign('num_pages', $num_pages);
86 $savant->assign('current_page', $page);
87 $savant->display('index.tmpl.php');