<%@ page language = "java" import = "r2q2.util.streams.*,r2q2.router.ws.*,java.net.*,java.lang.reflect.*,javax.activation.*,javax.xml.soap.*,java.util.*,java.io.*,java.net.*"%><%-- Copyright (c) 2008, University of Southampton All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Southampton nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --%><% String basePath = System.getProperty("R2Q2_HOME"); if (basePath==null) { basePath = System.getenv("R2Q2_HOME"); if (basePath == null) { basePath = System.getProperty("catalina.home"); basePath += "/webapps/r2q2/"; } } Properties p = new Properties(); p.load(new FileInputStream(basePath+"/r2q2.properties")); String router = (String)p.get("r2q2.router.ws.location"); RouterServiceLocator loc = new RouterServiceLocator(); RouterSoapBindingStub stub = new RouterSoapBindingStub( new URL(router), loc); String guid = (String)session.getAttribute("guid"); boolean back = false; HashMap[] resp = new HashMap[2]; if(request.getParameter("submit").equals("SUBMIT ANSWER")){ HashMap responseVars = new HashMap(); Enumeration e = request.getParameterNames(); while(e.hasMoreElements()){ String name = (String)e.nextElement(); if(!name.equals("submit")){ String[] valuesArray = request.getParameterValues(name); if(valuesArray[0].indexOf(",")>-1) { String[] tmpValuesArray = valuesArray; valuesArray = tmpValuesArray[0].split(","); } Vector valuesVector = new Vector(); for(int i=0; i", ""); html = html.replaceAll("", ""); html += "\t
\n\t
\n\t\t

Outcome Variables

"; //starting xml html += "\n\n"; HashMap outcome = resp[1]; Iterator iter = outcome.keySet().iterator(); String tmp = null; double overallScore = 0; while(iter.hasNext()){ String next = iter.next(); HashMap temp = (HashMap) outcome.get(next); if(next.startsWith("SCORE") && !back) { tmp = ""+(Vector)temp.get(next); tmp = tmp.substring(1, tmp.length()-1); overallScore += Double.parseDouble(tmp); } else { if(next.startsWith("completion")) { tmp = "unknown"; } else { tmp = "0.0"; } } html += "\n" + next + "" + tmp + ""; } //overallScore html += "\nOVERALL_SCORE"+overallScore+""; html += "\n\n"; html += "\t
\n"; html += "\t
\n\t
\n\t\t

Response Variables

"; if(!back){ HashMap res = resp[0]; Iterator iter2 = res.keySet().iterator(); while(iter2.hasNext()){ String next = iter2.next(); HashMap temp = (HashMap) res.get(next); html+= "
For responseDeclaration: "+next; html+= "
Candidate Response: "+(Vector)temp.get("candidateValues"); html+= "
Correct Response: "+(Vector)temp.get("correctResponse"); html+= "
Correct: "+(Boolean)temp.get("r2q2_correct"); } } html += "\n\t
\n\t\n"; //serve xml if possible (not for fragments) if ( html.startsWith("") && //must start with xml preamble if not fragment ((request.getHeader("accept") != null && request.getHeader("accept").contains("application/xhtml+xml")) || (request.getHeader("user-agent") != null && request.getHeader("user-agent").contains("MathPlayer")))) { //browsers with mathplayer can accept xml response.setContentType("application/xhtml+xml"); } out.println(html); %>