2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\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
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
18 require(AT_INCLUDE_PATH.'header.inc.php');
\r
20 if (isset($_POST['poll_submit'], $_POST['choice'])) {
\r
21 $poll_id = intval($_POST['poll_id']);
\r
23 $sql = "INSERT INTO ".TABLE_PREFIX."polls_members VALUES($poll_id, $_SESSION[member_id])";
\r
24 if ($result = mysql_query($sql, $db)) {
\r
25 $n = intval($_POST['choice']);
\r
27 $sql = "UPDATE ".TABLE_PREFIX."polls SET count$n=count$n+1, total=total+1 WHERE poll_id=$poll_id AND course_id=$_SESSION[course_id]";
\r
28 $result = mysql_query($sql, $db);
\r
32 if (!isset($include_all, $include_one)) {
\r
33 $include_one = ' checked="checked"';
\r
36 $sql = "SELECT * FROM ".TABLE_PREFIX."polls WHERE course_id=$_SESSION[course_id] ORDER BY question";
\r
37 $result = mysql_query($sql, $db);
\r
38 if (mysql_num_rows($result) == 0) {
\r
39 $msg->addInfo('NO_POLLS');
\r
41 require(AT_INCLUDE_PATH.'footer.inc.php');
\r
45 while ($row = mysql_fetch_assoc($result)) {
\r
46 echo '<form method="post" action="'.htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES).'">';
\r
47 echo '<table width="70%" border="0" cellspacing="0" cellpadding="0" summary="" class="dropdown" align="center">';
\r
49 echo '<td valign="top" class="dropdown-heading" nowrap="nowrap" align="left"><strong>' . AT_print($row['question'], 'polls.question') . '</strong>';
\r
50 echo '<input type="hidden" name="poll_id" value="'.$row['poll_id'].'" /></td></tr>';
\r
52 if (!authenticate(AT_PRIV_POLLS, AT_PRIV_RETURN)) {
\r
53 $sql = "SELECT * FROM ".TABLE_PREFIX."polls_members WHERE poll_id=$row[poll_id] AND member_id=$_SESSION[member_id]";
\r
54 $my_result = mysql_query($sql, $db);
\r
57 if (authenticate(AT_PRIV_POLLS, AT_PRIV_RETURN) || ($my_row = mysql_fetch_assoc($my_result))) {
\r
58 for ($i=1; $i<= AT_NUM_POLL_CHOICES; $i++) {
\r
59 if ($row['choice' . $i]) {
\r
60 if ($row['total']) {
\r
61 $width = round($row['count' . $i] / $row['total'] * 110);
\r
67 echo '<td valign="top" class="dropdown" nowrap="nowrap" align="left">';
\r
68 echo '<small>' . AT_print($row['choice' . $i], 'polls.choice') . '</small><br />';
\r
69 echo '<img src="'.$_base_path . 'images/blue.gif" height="5" width="'.$width.'" alt="" /> '.$row['count' . $i];
\r
74 for ($i=1; $i<= AT_NUM_POLL_CHOICES; $i++) {
\r
75 if ($row['choice' . $i]) {
\r
77 echo '<td valign="top" class="dropdown" nowrap="nowrap" align="left">';
\r
78 echo '<small><input type="radio" name="choice" value="'.$i.'" id="xc'.$i.$row['poll_id'].'" /><label for="xc'.$i.$row['poll_id'].'">' . AT_print($row['choice' . $i], 'polls.choice') . '</label></small></td></tr>';
\r
83 echo '<td valign="top" class="dropdown" nowrap="nowrap" align="center"><input type="submit" name="poll_submit" value="'._AT('submit').'" class="button" />';
\r
84 echo '<br /><small>'._AT('vote_to_see_results').'</small>';
\r
88 echo '</table></form><br />';
\r
91 require(AT_INCLUDE_PATH.'footer.inc.php');
\r