本文为JavaWeb项目课程设计,通过利用MVC模式,前端JSP+CSS界面展示,控制器用Servlet完成页面跳转,JavaBean完成数据库类、用户类、教师类等封装,开发出的一款教师监考管理系统。
2.2.1管理员
管理员为本系统的主要操纵者,可以完成几乎所有的功能,其总结功能需求如下:
- 需要输入正确的账号密码登录整个系统;
- 能够查看当前待排考试信息;
- 能够查看当前考场状态信息;
- 能够查看当前已分配监考教师及地点考场信息;
5. 能够实现为每个考场分配合理的考场;
6. 能够对每种信息进行单项增加或用excel导入MySql批量式增加;
- 能够对每种信息进行删除、修改、查询的操作;
- 能够按照班级考试人数为考试科目合理分配监考教师;
- 能够单独分配或批量一键分配;
- 能够一键处理或手动处理教师请求调换信息;
- 能够对监考教师请求信息和监考信息完成后发送邮件提醒;
- 具有良好的可视化前端界面和温馨提示;
- 能够显示当前已有任务的教师总监考次数;
2.2.2 教师
教师同样作为本系统的使用者,能够完成与自身相关的功能,具体功能需求总结如下:
- 需要输入正确的账号密码登录整个系统;
- 能够完成密码等个人信息的修改;
- 能够查看个人当前需监考的考试信息;
- 能够查看当前所有时间状态等;
- 对有异议的考试可发送申请调换请求;
- 友好界面显示,提醒当前待监考场数;
- 收取邮件提醒监考任务等;
数据流图:
相关界面展示:
管理员端:
教师端:
部分Servlet代码:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
String url = request.getServletPath();
if(url.equals("/a.Main"))
{
/*String a = request.getParameter("username");
System.out.print(a);*/
String us = request.getParameter("username"); //从这开始,是为了登录所用的,并且判断是哪类人登录的,跳转到不同页面
String pw = request.getParameter("password");
String rad = request.getParameter("power");
if(us==null || pw==null || rad==null)
{
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('孩子看看信息输入了吗');window.location.href='login.jsp';</script>");
}
else if(us!=null && pw!=null){
if(rad.equals("admin"))
{
Admin admin = new Admin();
admin.setPassword(pw);
admin.setUsername(us);
//System.out.print(admin.getUsername());
//System.out.print(admin.getPassword());
int r = admin.getPasswd();
if(r==1) {
// int time = 3600;
// Cookie c=new Cookie("user",us+"-"+pw);
// c.setMaxAge(time);
// response.addCookie(c);
System.out.print("管理员,登录成功");
request.getSession().setAttribute("name", us);
request.getRequestDispatcher ("admin_1.jsp").forward (request, response);
}else if(r != 1) {
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('孩子看看密码输对了吗');window.location.href='login.jsp';</script>");
}
}
else if(rad.equals("teacher"))
{
Teacher teacher = new Teacher();
teacher.setTid(us);
teacher.setTpassword(pw);
int r = teacher.tgetPasswd();
if(r == 1) {
System.out.print("老师,登录成功");
request.getSession().setAttribute("tname", us);
request.getRequestDispatcher ("tea_1.jsp").forward (request, response);
}else if(r != 1) {
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('孩子看看密码输对了吗');window.location.href='login.jsp';</script>");
}
}
}
}
if(url.equals("/b.Main")) //考试信息查询跳到这里来
{
//Admin admin = new Admin();
//request.setAttribute("kaoshis", admin.getAllkaoshi());
Test test = new Test();
request.getSession().setAttribute("kaoshis", test.getAllkaoshi());
request.getRequestDispatcher("admin_test.jsp").forward(request,response);
}
if(url.equals("/c.Main")) //考试信息删除跳到这里来
{
Test test = new Test();
String x1 = request.getParameter("x1");
int c = Integer.parseInt(x1);
System.out.print(c);
test.setTest_id(c);
test.changeexamhouse(); //删除当前考试的话,需要把考场恢复成kong,表明以后可以用,加入有looktea的话,把looktea的老师弄成kong
int a = test.delkaoshi();
if(a==1)
{
request.getSession().setAttribute("kaoshis", test.getAllkaoshi());
request.getRequestDispatcher("admin_test.jsp").forward(request,response);
}else {
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('好像删除失败了呢');window.location.href='admin_test.jsp';</script>");
}
}
if(url.equals("/d.Main")) //考试信息修改跳到这里来
{
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
Test test = new Test();
Teacher teacher = new Teacher();
String x =(String)request.getSession().getAttribute("oldlooktea");
String y =(String)request.getSession().getAttribute("oldlooktime");
String z =(String)request.getSession().getAttribute("oldposit");
teacher.dealold(x,y,1);
teacher.dealold(z,y,3);
String x1 = request.getParameter("id");
String x2 = request.getParameter("l_s_card");
String x3 = request.getParameter("s_subject");
String x4 = request.getParameter("k_time");
String x5 = request.getParameter("c_name");
String x6 = request.getParameter("tea");
String x7 = request.getParameter("s_position");
String x8 = request.getParameter("count");
String x9 = request.getParameter("looktea");
teacher.dealold(x9,y,2);
teacher.dealold(x7,y,4);
int c = Integer.parseInt(x1);
test.setTest_id(c);
test.setTest_leibie(x2);
test.setTest_subject(x3);
test.setTest_time(x4);
test.setTest_class(x5);
test.setTest_teacher(x6);
test.setTest_position(x7);
test.setTest_count(x8);
test.setLooktea(x9);
int a = test.updatekaoshi();
if(a==1)
{
request.getSession().setAttribute("kaoshis", test.getAllkaoshi());
request.getRequestDispatcher("admin_test.jsp").forward(request,response);
}else {
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('好像修改失败了呢');window.location.href='admin_test.jsp';</script>");
}
}