组卷与考试系统_题库添加选择题模块

action部分:

String questionkindId;
String questionCon;
String choicea;
String choiceb;
String choicec;
String choiced;
String result;

生成getter和setter方法,由于应用了ssh框架,因此只要在action中定义与JSP页面中name名称相同的属性,并生成setter和getter,并在JSP中定义

,即可自动获取JSP表单中的内容。


public String AddQuestion_wanxing(){
for(int i=0;iBoolean success=questionservice.AddQuestion_wanxing(questionkindId, questionCon, choiceas, choicebs, choicecs, choiceds, results, questionAnas, questionknows,errorRate,difficult,QuestionDetailIds);

if(success) return "success";


else return "failure";
}
return "failure";
}


service层:


public Boolean AddQuestion_wanxing(String questionkindId,
String questionCon, String[] choiceas, String[] choicebs,
String[] choicecs, String[] choiceds, String[] results,
String[] questionAnas, String[] questionknows, String errorRate,
String difficult, String[] questionDetailIds);


serviceimplement层:


public Boolean AddQuestion(String questionkindId, String questionCon,
String choicea, String choiceb, String choicec, String choiced,
String result, String questionAna, String questionknow,String errorRate,String difficult,String QuestionDetailId) {
try {
return questiondao.AddQuestion(questionkindId, questionCon, choicea, choiceb, choicec, choiced, result, questionAna, questionknow,errorRate,difficult,QuestionDetailId);

} catch (Exception e) {
// TODO: handle exception
return false;
}
}


dao层:

public Boolean AddQuestion_wanxing(String questionkindId,
String questionCon, String[] choiceas, String[] choicebs,
String[] choicecs, String[] choiceds, String[] results,
String[] questionAnas, String[] questionknows, String errorRate,
String difficult, String[] questionDetailIds);


daoimplement层:


public Boolean AddQuestion(String questionkindId, String questionCon,
String choicea, String choiceb, String choicec, String choiced,
String result, String questionAna, String questionknow,String errorRate,String difficult,String QuestionDetailId) {


// TODO Auto-generated method stub
try {
Question question=new Question();
question.setQuestionKind(Integer.parseInt(questionkindId));
question.setQuestionCon(questionCon);
question.setQuestionErrorRate(Float.valueOf(errorRate));
question.setQuestionDifficult(Integer.parseInt(difficult));

if((Integer.parseInt(questionkindId))==1){
question.setQuestionNumber(1);}
else if((Integer.parseInt(questionkindId))==2){
question.setQuestionNumber(20);
}
else if((Integer.parseInt(questionkindId))==3){
question.setQuestionNumber(5);
}

// QuestionDetail detail=(QuestionDetail) question.getQuestionDetails();

QuestionDetail detail = new QuestionDetail();
int detailid=Integer.parseInt(QuestionDetailId);
QuestionDetailId ID = new QuestionDetailId(question, detailid);
detail.setId(ID);
detail.setSelectA(choicea);
detail.setSelectB(choiceb);
detail.setSelectC(choicec);
detail.setSelectD(choiced);
detail.setSelectans(result);
detail.setSelectExplain(questionAna);
detail.setSelectKnowledge(questionknow);
question.getQuestionDetails().add(detail);

getHibernateTemplate().save(question);
return true;

} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return false;
}


}

JSP页面部分:


 
   
 
    
    组卷与考试管理系统-增加用户
    


   





 




新增题目


   
   
         
       
       
       
     
        
     
         
         
     
     
         
         
     
         
         
         
     
           
         
         
     
           
         
         
       
     
         
         
     
         
         
          
           
         
         
         
       
       
       
       
       
       
       
       
       
       
           
           
       
   
题目类型:选择题
题干部分
选项A
选项B
选项C
选项D
答案:
         
         
         
         
         
         
ABCD
 
     
问题解析
知识点
错误率
难度

   
   






bean.XML部分












struct.xml部分:




teacher/success.jsp
teacher/error.jsp


teacher/success.jsp
teacher/error.jsp


teacher/success.jsp
teacher/error.jsp



你可能感兴趣的:(Java,Web)