2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton */
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 /****************************************************************************/
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 authenticate(AT_PRIV_POLLS);
20 if (isset($_POST['edit'], $_POST['poll'])) {
21 header('Location: edit.php?poll_id=' . $_POST['poll']);
23 } else if (isset($_POST['delete'], $_POST['poll'])) {
24 header('Location: delete.php?pid=' . $_POST['poll'] );
26 } else if (!empty($_POST)) {
27 $msg->addError('NO_ITEM_SELECTED');
30 require(AT_INCLUDE_PATH.'header.inc.php');
32 $orders = array('asc' => 'desc', 'desc' => 'asc');
33 $cols = array('question' => 1, 'created_date' => 1, 'total' => 1);
35 if (isset($_GET['asc'])) {
37 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'created_date';
38 } else if (isset($_GET['desc'])) {
40 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'created_date';
44 $col = 'created_date';
47 $sql = "SELECT poll_id, question, created_date, total FROM ".TABLE_PREFIX."polls WHERE course_id=$_SESSION[course_id] ORDER BY $col $order";
48 $result = mysql_query($sql, $db);
52 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
53 <table class="data" summary="" rules="cols">
55 <?php if ($col == 'question'): ?>
59 <?php elseif($col == 'created_date'): ?>
63 <?php elseif($col == 'total'): ?>
70 <th scope="col"> </th>
71 <th scope="col"><a href="tools/polls/index.php?<?php echo $orders[$order]; ?>=question"><?php echo _AT('question'); ?></a></th>
72 <th scope="col"><a href="tools/polls/index.php?<?php echo $orders[$order]; ?>=created_date"><?php echo _AT('created'); ?></a></th>
73 <th scope="col"><a href="tools/polls/index.php?<?php echo $orders[$order]; ?>=total"><?php echo _AT('total_votes'); ?></a></th>
79 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
80 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
85 <?php if ($row = mysql_fetch_assoc($result)) : ?>
87 <tr onmousedown="document.form['p_<?php echo $row['poll_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['poll_id']; ?>">
88 <td><input type="radio" id="p_<?php echo $row['poll_id']; ?>" name="poll" value="<?php echo $row['poll_id']; ?>" /></td>
89 <td><label for="p_<?php echo $row['poll_id']; ?>"><?php echo AT_print($row['question'], 'polls.question'); ?></label></td>
90 <td><?php echo AT_DATE(_AT("server_date_format"), $row['created_date']); ?></td>
91 <td><?php echo $row['total']; ?></td>
93 <?php } while($row = mysql_fetch_assoc($result)); ?>
96 <td colspan="4"><?php echo _AT('none_found'); ?></td>
103 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>