Around exam time, it's pretty common to want to take a poll to see what possible review session times work for students. Here's a script that was designed to handle this on the course webpage. It's general enough to work for any kind of online poll.
A typical deployment with integrated look and feel is shown in the image above.
In order to use it, you will need to modify your .htaccess
file, download the vote.php and vote.shtml files and set up a vote/voteconfig.txt
file. Votes are currently restricted to students registered in the course, and course staff, so you'll also need to vote/permissions.php
, as explained in the Restricting Permissions section below.
When students vote, the actual data is stored in a file vote/votedata.csv
(relative to vote.php
). To change the locations of where vote.php
looks for these files, modify the globals TIME_DATA_FILE
and VOTE_DATA_FILE
in vote.php
.
The default layout of files is shown below:
.htaccess
file. If this file does not exist, create it.
<FilesMatch "vote\.(shtml|php)"> AddHandler cgi-script .php PerlAuthenHandler Apache::AuthenURL Require valid-user SSLRequireSSL </FilesMatch>
Here is a sample .htaccess file.
vote.php
to something else, you will need to edit where the form posts to by modifying the global FORM_POST_FILE
in vote.php
. If you rename vote.shtml
, you'll have to modify the REDIRECT_AFTER_POST_FILE
global. You will also need to modify the .htaccess
file accordingly.
If you're just interested in a standalone copy that does not try to fit into the standard look and feel, download vote_standalone.php. You can rename this file to whatever you like without having to modify the code, but you will still need to ensure the .htaccess
file matches the filename.
Be sure to chmod a+x vote.php
!
vote/voteconfig.txt
, so if you have your vote.php|shtml
files in ~cs136/public_html/vote.php|shtml
, put this in ~cs136/public_html/vote/voteconfig.txt
(create the vote
subdirectory if necessary). This is the same location where the vote data will be stored. It is a good idea to chmod o-r vote
to disallow students from reading that directory.
The format of this text file is:
Title of page Option 1 Option 2 ... Option n
For example:
Midterm Review Session Times Wednesday, June 16, 4:30pm Wednesday, June 16, 6:30pm Thursday, June 17, 4:30pm Thursday, June 17, 6:30pm Friday, June 18, 4:30pm
Download a sample voteconfig.txt.
VOTE_RUNNING
at the top of vote.php
. A value of true
means users can continue to vote, while a value of false
means the vote is closed.
vote.php
is to have access to it restricted to students enrolled in the course, and the course staff. To change this, you'll need to modify these lines at the start of vote.php
:
require_once "vote/permissions.php"; $allowed = array("isc", "instructor", "tutor", "ta", "student"); ensure_permissions(USER_ID, $allowed);
This requires a coursestaff.term
file to exist in order to work. This file must be created manually under your course's home directory. For details on the format of this file, see ClassListPerlModule.
For documentation on the permissions.php
itself, see RestrictingWebAccessToCourse.
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
file_layout.png | r3 r2 r1 | manage | 10.4 K | 2010-06-20 - 13:30 | PeterBeshai | layout of directory structure |
![]() |
htaccess | r1 | manage | 0.2 K | 2010-06-10 - 20:45 | PeterBeshai | sample .htaccess file |
![]() |
vote.renametophp.txt | r4 r3 r2 r1 | manage | 5.5 K | 2010-06-20 - 13:27 | PeterBeshai | vote.php for integration with vote.shtml |
![]() |
vote.shtml | r2 r1 | manage | 0.5 K | 2010-06-15 - 12:30 | PeterBeshai | vote.shtml for integration with standard look and feel |
![]() |
vote_screenshot.gif | r1 | manage | 30.6 K | 2010-06-10 - 18:40 | PeterBeshai | integrated screenshot |
![]() |
vote_standalone.renametophp.txt | r3 r2 r1 | manage | 5.3 K | 2010-06-20 - 13:27 | PeterBeshai | vote.php that works on its own |
![]() |
voteconfig.txt | r1 | manage | 0.2 K | 2010-06-10 - 20:39 | PeterBeshai | sample voteconfig.txt to be put in vote/voteconfig.txt |