remove old readme
[atutor.git] / docs / mods / _standard / polls / tools / index.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 define('AT_INCLUDE_PATH', '../../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17
18 authenticate(AT_PRIV_POLLS);
19
20 if (isset($_POST['edit'], $_POST['poll'])) {
21         header('Location: edit.php?poll_id=' . $_POST['poll']);
22         exit;
23 } else if (isset($_POST['delete'], $_POST['poll'])) { 
24         header('Location: delete.php?pid=' . $_POST['poll'] );
25         exit;
26 } else if (!empty($_POST)) {
27         $msg->addError('NO_ITEM_SELECTED');
28 }
29
30 require(AT_INCLUDE_PATH.'header.inc.php'); 
31
32 $orders = array('asc' => 'desc', 'desc' => 'asc');
33 $cols   = array('question' => 1, 'created_date' => 1, 'total' => 1);
34
35 if (isset($_GET['asc'])) {
36         $order = 'asc';
37         $col   = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'created_date';
38 } else if (isset($_GET['desc'])) {
39         $order = 'desc';
40         $col   = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'created_date';
41 } else {
42         // no order set
43         $order = 'desc';
44         $col   = 'created_date';
45 }
46
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);
49 $savant->assign('col', $col);
50 $savant->assign('order', $order);
51 $savant->assign('orders', $orders);
52 $savant->assign('result', $result);
53 $savant->display('instructor/polls/index.tmpl.php');
54 require(AT_INCLUDE_PATH.'footer.inc.php');  ?>