📄 teacheraction.java
字号:
package action;
import java.util.ArrayList;
import java.util.Collection;
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 entity.Anlysis;
import entity.Course;
import entity.EExam;
import entity.Exam;
import entity.Me_Qu;
import entity.Middle;
import entity.Paper;
import entity.PaperAnlysis;
import entity.Question;
import entity.TCExam;
import entity.Teacher;
import entity.Theme;
import forms.CourseForm;
import forms.EExamForm;
import forms.MathUtil;
import forms.QuestionForm;
import forms.ThemeForm;
import biz.TeacherBIZ;
public class TeacherAction extends MappingDispatchAction {
int[] f = new int[9];
private TeacherBIZ teacherbiz;
public void setTeacherbiz(TeacherBIZ teacherbiz) {
this.teacherbiz = teacherbiz;
}
public ActionForward onlinepaper1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("*****onlinepaper***88");
System.out.println(teacherbiz);
Exam exam = new Exam();
HttpSession session = request.getSession(false);
CourseForm courseForm = (CourseForm) form;
String name = courseForm.getCname();
String style = courseForm.getEname();
Paper paper = teacherbiz.selectByNameP(style);
Course course = teacherbiz.selectByNameC(name);
System.out.println("*****onlinepaper***88" + name);
System.out.println("*****onlinepaper***88" + style);
Teacher teacher = (Teacher) session.getAttribute("Teacher");
exam.setCourseid(course.getId());
exam.setPaperid(paper.getId());
exam.setTeacherid(teacher.getId());
teacherbiz.insertExam(exam);
Exam e = teacherbiz.selectByCourseidTeacheridPaperid(course.getId(),
teacher.getId(), paper.getId());
System.out.println("*****e.getId()***88" + e.getId());
Collection<Theme> theme = teacherbiz.listTheme();
session.setAttribute("Course", course);
session.setAttribute("Paper", paper);
session.setAttribute("Theme", theme);
session.setAttribute("Exam", e);
return mapping.findForward("success");
}
public ActionForward onlinepaper(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("*****onlinepaper***88");
System.out.println(teacherbiz);
HttpSession session = request.getSession(false);
Collection<Theme> theme = teacherbiz.listTheme();
session.setAttribute("Theme", theme);
return mapping.findForward("success");
}
public ActionForward toaddTheme(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("********toaddTheme");
System.out.println(teacherbiz);
Theme t = new Theme();
String typestyle = request.getParameter("Name");
System.out.println("***********" + typestyle);
t.setTypestyle(typestyle);
teacherbiz.altertype(t);
return mapping.findForward("success");
}
public ActionForward choosePaper(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int f[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
System.out.println(f[1]);
System.out.println("********88");
System.out.println(teacherbiz);
HttpSession session = request.getSession(false);
Collection<Course> course = teacherbiz.listCourse();
System.out.println("********course" + course);
session.setAttribute("Course", course);
return mapping.findForward("success");
}
public ActionForward addTheme(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("***addTheme*****88");
System.out.println(teacherbiz);
return mapping.findForward("success");
}
public ActionForward deleteTheme(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("***addTheme*****88");
ThemeForm themeForm = (ThemeForm) form;
Long id = themeForm.getTypeid();
Theme t = teacherbiz.getThemeById(id);
teacherbiz.deletetheme(t);
return mapping.findForward("success");
}
public ActionForward thememes(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
System.out.println("***thememes*****88");
System.out.println(teacherbiz);
int id = Integer.parseInt(request.getParameter("id"));
Long id1 = Long.parseLong(request.getParameter("id"));
session.setAttribute("id", id);
session.setAttribute("id1", id1);
if (id == 2) {
System.out.println("***thememes*****88" + id);
return mapping.findForward("success1");
} else if (id == 3) {
System.out.println("***thememes*****88" + id);
return mapping.findForward("success2");
} else if (id == 4) {
System.out.println("***thememes*****88" + id);
return mapping.findForward("success3");
}
return mapping.findForward("success");
}
public ActionForward addthememes(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("***addthememes*****88");
TCExam tcexam = new TCExam();
HttpSession session = request.getSession(false);
Question question = new Question();
QuestionForm questionForm = (QuestionForm) form;
int i = (Integer) session.getAttribute("id");
System.out.println("FididiiddiididFF" + i);
f[i] = f[i] + 1;
System.out.println("FFFFFFFFFFFFFFFFFFFF" + f[i]);
String context = questionForm.getContext();
String an = questionForm.getAnswer();
int point = questionForm.getPoint();
System.out.println("***&&&&&&&&^^^^^^^" + session.getAttribute("id"));
if (session.getAttribute("id").equals(4)
|| session.getAttribute("id").equals(3)) {
System.out.println("***&&&&&&&&^^^^^^^"
+ session.getAttribute("id"));
String keya = questionForm.getKeya();
String keyb = questionForm.getKeyb();
String keyc = questionForm.getKeyc();
String keyd = questionForm.getKeyd();
String keye = questionForm.getKeye();
String keyf = questionForm.getKeyf();
String keyg = questionForm.getKeyg();
question.setKeya(keya);
question.setKeyb(keyb);
question.setKeyc(keyc);
question.setKeyd(keyd);
question.setKeye(keye);
question.setKeyf(keyf);
question.setKeyg(keyg);
}
question.setContext(context);
question.setPoint(point);
question.setAnswer(an);
question.setQuestionid(f[i]);
teacherbiz.insertthememesQuestion(question);
Exam exam = (Exam) session.getAttribute("Exam");
Question q = teacherbiz.selectBycontext(context,exam.getId());
System.out.println("***addthememes*****88");
Long themid = (Long) session.getAttribute("id1");
System.out.println(exam.getId());
System.out.println(exam.getId());
tcexam.setExamid(exam.getId());
tcexam.setQuestionid(q.getId());
tcexam.setThemeid(themid);
teacherbiz.insertTCExam(tcexam);
session.setAttribute("I", f[i]);
return mapping.findForward("success");
}
public ActionForward paperManage(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
Collection<EExam> eexam = new ArrayList();
Teacher teacher = (Teacher) session.getAttribute("Teacher");
Collection<Exam> exam = teacherbiz.selectByTeacherid(teacher.getId());
for (Exam e : exam) {
EExam eexam1 = new EExam();
System.out.println("System.outgetPaperid()" + e.getPaperid());
System.out.println("System.outTeacherid" + e.getTeacherid());
System.out.println("System.outCourseid" + e.getCourseid());
String paper_name = teacherbiz.selectPaperById(e.getPaperid())
.getName();
String course_name = teacherbiz.selectCourseById(e.getCourseid())
.getName();
System.out.println("System.outgetPaperid()" + paper_name);
System.out.println("System.outCourseid" + course_name);
eexam1.setId(e.getId());
eexam1.setCourse_name(course_name);
eexam1.setPaper_name(paper_name);
System.out.println("eexam1" + eexam1);
eexam.add(eexam1);
}
System.out.println("***addTheme*****88");
System.out.println(teacherbiz);
session.setAttribute("EExam", eexam);
for (EExam e : eexam) {
System.out.println("rrrrrrrrrrrrrrr" + e.getCourse_name());
}
return mapping.findForward("success");
}
public ActionForward deleteExam(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("***deleteExam*****88");
EExamForm eexamForm = (EExamForm) form;
Long id = eexamForm.getId();
System.out.println(id);
teacherbiz.deleteExamById(id);
return mapping.findForward("success");
}
public ActionForward paper(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("***deleteExam*****88");
HttpSession session = request.getSession(false);
Long id = Long.parseLong(request.getParameter("id"));
System.out.println("***getParameter*****88"
+ request.getParameter("id"));
Exam exam = teacherbiz.selectExamByid(id);
Paper paper = teacherbiz.selectPaperById(exam.getPaperid());
Course course = teacherbiz.selectCourseById(exam.getCourseid());
Collection<TCExam> tcexam = teacherbiz.selectTCExamByExamid(exam
.getId());
Collection<Me_Qu> mq1 = new ArrayList();
for (TCExam tce : tcexam) {
Me_Qu mq = new Me_Qu();
Question qu = teacherbiz.selectById(tce.getQuestionid());
mq.setQu(qu);
mq.setThemeid(tce.getThemeid());
mq1.add(mq);
}
for (Me_Qu me : mq1) {
System.out
.println("***deleteExam*****88" + me.getQu().getContext());
}
session.setAttribute("Me_Qu", mq1);
session.setAttribute("Exam", exam);
session.setAttribute("Paper", paper);
session.setAttribute("Course", course);
return mapping.findForward("success");
}
// paperAnlysis
public ActionForward paperAnlysis(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
Collection<EExam> eexam = new ArrayList();
Teacher teacher = (Teacher) session.getAttribute("Teacher");
Collection<Exam> exam = teacherbiz.selectByTeacherid(teacher.getId());
for (Exam e : exam) {
EExam eexam1 = new EExam();
String paper_name = teacherbiz.selectPaperById(e.getPaperid())
.getName();
String course_name = teacherbiz.selectCourseById(e.getCourseid())
.getName();
eexam1.setId(e.getId());
eexam1.setCourse_name(course_name);
eexam1.setPaper_name(paper_name);
System.out.println("eexam1" + eexam1);
eexam.add(eexam1);
}
System.out.println("***addTheme*****88");
System.out.println(teacherbiz);
session.setAttribute("EExam", eexam);
for (EExam e : eexam) {
System.out.println("rrrrrrrrrrrrrrr" + e.getCourse_name());
}
return mapping.findForward("success");
}
public ActionForward Anlysis(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
Collection<PaperAnlysis> paperanlysis = new ArrayList();
int[][] i = new int[9][9];
int[] a = new int[9];
int k = 0;
System.out.println("***Anlysis*****88" + i[0]);
Long id = Long.parseLong(request.getParameter("id"));
System.out.println("***Anlysis*****88" + id);
Exam exam = teacherbiz.selectExamByid(id);
Paper paper = teacherbiz.selectPaperById(exam.getPaperid());
Course course = teacherbiz.selectCourseById(exam.getCourseid());
session.setAttribute("Paper", paper);
session.setAttribute("Course", course);
Collection<Theme> theme = teacherbiz.listTheme();
Collection<Anlysis> anlysis = teacherbiz.selectAnlysisByExamid(id);
System.out.println("***Anlysis*****88" + anlysis);
long k1=1;
for (Theme the : theme) {
for (Anlysis an : anlysis) {
if (the.getTypeid().equals(an.getThemeid())) {
long Themeid = the.getTypeid();
int temp = (int) Themeid;
System.out.println("temp" + temp);
Question question = teacherbiz.selectById(an
.getQuestionid());
System.out.println("question.getQuestionid()"
+ question.getQuestionid());
i[temp][question.getQuestionid()] = i[temp][question
.getQuestionid()]
+ an.getRight();
a[temp] = question.getQuestionid();
}
if(the.getTypeid()>k1){ k1 = the.getTypeid();
k = (int) k1;}
}
}
System.out.println("kkkkkkkkkkkkkkkkk" + k);
System.out.println("aaaaaaaaaaaaaaaaaaaaa" + a[4]);
for (int h = 1; h <= k; h++) {
PaperAnlysis paperanlylsis1 = new PaperAnlysis();
long temp = h;
Long temp1 = temp;
Theme t = teacherbiz.getThemeById(temp1);
paperanlylsis1.setThemeid(temp1);
paperanlylsis1.setName(t.getTypestyle());
Collection<Middle> m = new ArrayList();
for (int j = 1; j <= a[h]; j++) {
Middle middle = new Middle();
middle.setNumber(j);
middle.setNumberofright(i[h][j]);
double w = MathUtil.round(i[h][j] /34.000*100, 3);
System.out.println("int l=(i[h][j]/34)*100;" + w);
middle.setLv(w);
m.add(middle);
System.out.println("temp1" + temp1);
System.out.println("jjjjjjjjjjjjjjj" + j);
System.out.println("setNumberofright" + i[h][j]);
}
paperanlylsis1.setMiddle(m);
paperanlysis.add(paperanlylsis1);
}
session.setAttribute("People", 34);
session.setAttribute("PaperAnlysis", paperanlysis);
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -