%
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see .
*
*/
%>
<%@page import="javax.servlet.http.Cookie"%>
<%
String poll = request.getParameter( "poll" );
boolean validVote = false;
String error = null;
// grab cookies and look for the bbbpollstaken cookie
String cookieValue = null;
Cookie [] cookies = request.getCookies();
if (cookies != null) {
for (int i=0; i < cookies.length; i++) {
if (cookies[i].getName().equals("bbbpollstaken")) {
cookieValue = cookies[i].getValue();
}
}
}
String vote = null;
String [] votes = null;
if (connection.getTitle() != null) {
if (connection.getMultiple().equals("false")) {
vote = request.getParameter( "answers" );
} else {
votes = request.getParameterValues( "answers" );
}
}
if (poll == null) {
error = "Error: No poll entered.";
} else if (poll.equals("youshallnotpass")) {
error = "Error: Requested resource not found.";
} else if (connection.cleanWebKey(poll)) {
error = "Error: Improper formatting.";
} else if (connection.sessionVoted(poll) || (cookieValue != null && connection.cookieCheck(cookieValue, poll))) { // already voted
error = "Error: Already voted.";
} else if (!connection.retrievePoll(poll)) { // tries to find poll
error = "Error: Poll not found.";
} else if (connection.getMultiple().equals("false") && vote != null) { // radio buttons used
// check to see if they pressed they selected an answer
validVote = true;
connection.recordRadioVote(vote);
} else if (connection.getMultiple().equals("true") && votes != null) { // checkboxes used
validVote = true;
connection.recordCheckVote(votes);
} else {
String [] answers = connection.getAnswers();
session.setAttribute("webkey", poll); %>
<%= connection.getTitle()%>
<%= connection.getQuestion()%>
<%
}
// check if an error was recorded
if (error != null) {
%>
Error
<%= error%>
<%
} else if (validVote) {
%>
<%= connection.getTitle()%>
Thank you for voting!
<%
// write to the cookie
if (cookieValue == null) {
cookieValue = "," + (String) session.getAttribute("webkey") + ",";
} else {
cookieValue += session.getAttribute("webkey") + ",";
}
Cookie bbbpollstaken = new Cookie("bbbpollstaken", cookieValue);
bbbpollstaken.setMaxAge(60*60*8); // expire after 4h
response.addCookie( bbbpollstaken );
}
%>