📄 aexamineetest.java
字号:
/*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/).
*/
package ch07.action;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import ch07.*;
import ch07.object.unit.*;
import ch07.logic.*;
import ch07.global.*;
import ch07.database.*;
/**
* 针对答题页面的Servlet
* @author ShenYK
* @version 1.0
*/
public class AExamineeTest
{
//题目向前跳转
public void doPrev( Hashtable inputData,
Hashtable outputData,
HttpSession mySession )
throws Exception
{
//首先获得当前题目的答案
String sIndex = (String)inputData.get("qIndex");
String sAnswer = (String)inputData.get("choice");
if ( sAnswer == null || sAnswer.equals("") )
{
sAnswer = "0";
}
//题目答案应该放在session中在完成的时候再提交
Hashtable hAnswers = (Hashtable)mySession.getAttribute("answers");
if ( hAnswers == null )
{
hAnswers = new Hashtable();
mySession.setAttribute("answers", hAnswers );
}
hAnswers.put( sIndex, sAnswer );
//决定下标,然后跳转页面
int iNext = (new Integer(sIndex)).intValue() - 1;
outputData.put( "questionIndex", new Integer(iNext) );
outputData.put( "pageId", CommonConst.VIEWID_EXAMINEE_TEST );
return;
}
//题目向后跳转
public void doNext( Hashtable inputData,
Hashtable outputData,
HttpSession mySession )
throws Exception
{
//首先获得当前题目的答案
String sIndex = (String)inputData.get("qIndex");
String sAnswer = (String)inputData.get("choice");
if ( sAnswer == null || sAnswer.equals("") )
{
sAnswer = "0";
}
//题目答案应该放在session中在完成的时候再提交
Hashtable hAnswers = (Hashtable)mySession.getAttribute("answers");
if ( hAnswers == null )
{
hAnswers = new Hashtable();
mySession.setAttribute("answers", hAnswers );
}
hAnswers.put( sIndex, sAnswer );
//决定下标,然后跳转页面
int iNext = (new Integer(sIndex)).intValue() + 1;
outputData.put( "questionIndex", new Integer(iNext) );
outputData.put( "pageId", CommonConst.VIEWID_EXAMINEE_TEST );
return;
}
//完成
public void doEnd( Hashtable inputData,
Hashtable outputData,
HttpSession mySession )
throws Exception
{
//首先获得当前题目的答案
String sIndex = (String)inputData.get("qIndex");
String sAnswer = (String)inputData.get("choice");
if ( sAnswer == null || sAnswer.equals("") )
{
sAnswer = "0";
}
//题目答案应该放在session中在完成的时候再提交
Hashtable hAnswers = (Hashtable)mySession.getAttribute("answers");
if ( hAnswers == null )
{
hAnswers = new Hashtable();
mySession.setAttribute("answers", hAnswers );
}
hAnswers.put( sIndex, sAnswer );
//获得当前的用户
String sUsername = ((User)mySession.getAttribute("loginUser")).getUsername();
//获得当前的分类
String sCategoryId = (String)mySession.getAttribute("examineeCategory");
//获得所有题目
Vector allQuestions = (Vector)mySession.getAttribute("examineeQuestions");
//调用对应的logic类
LQuestion lQuestion = (LQuestion)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_QUESTION);
int[] iResult = lQuestion.calculateResult( sUsername, sCategoryId, allQuestions, hAnswers );
//计算完成以后,将相关session变量清除
mySession.removeAttribute("answers");
mySession.removeAttribute("examineeQuestions");
mySession.removeAttribute("examineeCategory");
//迁移到答题结果页面
outputData.put( "pageId", CommonConst.VIEWID_EXAMINEE_RESULT );
outputData.put( "iResult", new Integer(iResult[0]) );
outputData.put( "iOrder", new Integer(iResult[1]) );
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -