📄 gradesearchaction.java
字号:
package action;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;
import biz.CourseBIZ;
import biz.ExamBIZ;
import biz.PaperBIZ;
import biz.QuestionBIZ;
import biz.StudentBIZ;
import biz.TeacherBIZ;
import bizImpl.CourseBIZImpl;
import bizImpl.ExamBIZImpl;
import bizImpl.PaperBIZImpl;
import bizImpl.QuestionBIZImpl;
import bizImpl.StudentBIZImpl;
import bizImpl.TeacherBIZImpl;
import entity.Course;
import entity.Exam;
import entity.Paper;
import entity.Question;
import entity.Student;
import entity.Teacher;
import entity.Theme;
public class GradeSearchAction extends MappingDispatchAction{
private TeacherBIZ teacherBIZ = new TeacherBIZImpl();
private CourseBIZ courseBIZ = new CourseBIZImpl();
private StudentBIZ studentBIZ=new StudentBIZImpl();
private PaperBIZ paperBIZ = new PaperBIZImpl();
private ExamBIZ examBIZ=new ExamBIZImpl();
private QuestionBIZ questionBIZ=new QuestionBIZImpl();
public ActionForward getAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Collection<Teacher> teachers = teacherBIZ.getAllTeacher();
Collection<Course> courses = courseBIZ.getAllCourse();
List<Paper> exams = (List<Paper>) paperBIZ.getAllPaper();
HttpSession session = request.getSession();
session.setAttribute("teacher", teachers);
session.setAttribute("course", courses);
session.setAttribute("paperid", exams);
return mapping.findForward("listpaper");
}
public ActionForward search(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int totalCount=0;
Student student=(Student)request.getSession().getAttribute("student");
Long studentid=student.getId();
String tname=request.getParameter("tname");
String cname=request.getParameter("cname");
String pname=request.getParameter("ename");
Teacher teacher=teacherBIZ.selectTeacherByTName(tname);
Course course=courseBIZ.selectCourseByName(cname);
Paper paper=paperBIZ.selectPaperByName(pname);
Exam exam=examBIZ.selectExamByTeacherAndCourseAndPaper(teacher.getId(), course.getId(), paper.getId());
List<Theme> themes=exam.getThemes();
Boolean Flag=studentBIZ.selectByStudentid(studentid,exam.getId());
for(Theme theme:themes){
List<Question> questions=theme.getQuestion();
for(Question question:questions){
String sanswer=studentBIZ.selectSanswer(studentid, question.getId()).getSanswer();
int rightorwrong=0;
if(question.getAnswer().equals(sanswer)){
rightorwrong=1;
if(Flag==false){
if(rightorwrong==1){
questionBIZ.insertAnlysis(studentid, exam.getId(), theme.getId(), question.getId(), rightorwrong);
}
}
totalCount=totalCount+question.getPoint();
}
if(Flag==false && rightorwrong==0){
questionBIZ.insertAnlysis(studentid, exam.getId(), theme.getId(), question.getId(), 0);
}
}
};
request.getSession().setAttribute("totalCount", totalCount);
request.setAttribute("course", course);
request.setAttribute("paper",paper);
return mapping.findForward("grade");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -