<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="js" uri="net.sourceforge.jsurveyor.jsurveyorlib" %>
<%@ page import="net.sourceforge.jsurveyor.*" %>
<%@ page import="java.util.ArrayList" %>
<js:noCache />
<js:login access="admin" />
<%
int questionnaireID = Integer.parseInt(request.getParameter("QuestionnaireID"));
Questionnaire editQ = DataAccess.retrieveQuestionnaire(questionnaireID);
if(!editQ.getState()) {
	int questionPageID = Integer.parseInt(request.getParameter("QuestionPageID"));
	QuestionPage QPage = DataAccess.retrieveQuestionPage(questionPageID);
	String questionRef = request.getParameter("Question");
	if(questionRef.substring(0,1).equals("F")) {
		QuestionFreeText tempQ = (QuestionFreeText)DataAccess.retrieveQuestion(Integer.parseInt(questionRef.substring(1)));
		QPage.removeQuestion(tempQ);
		DataAccess.storeQuestionPage(QPage);
		DataAccess.deleteQuestion(tempQ.getQuestionID());
	}
	if(questionRef.substring(0,1).equals("M")) {
		QuestionMultipleChoice tempQ = (QuestionMultipleChoice)DataAccess.retrieveQuestion(Integer.parseInt(questionRef.substring(1)));
		QPage.removeQuestion(tempQ);
		DataAccess.storeQuestionPage(QPage);
		DataAccess.deleteQuestion(tempQ.getQuestionID());
	}
}
response.sendRedirect("admin_questionnaire.jsp?QuestionnaireID=" + questionnaireID);

%>