- 计划
1.1需求描述:
现在市场上有很多的面向小学生的题卡,但是这习题卡不但价格昂贵,而且每次做题的内容基本都是固定。针对这些问题,开发出了这款网页在线答题系统,每次的题目都有所不同,可以跟快更好提高小学生的计算能力。
1.2估计开发时间
一天两宿。
1.3填写项目数据
产生随机的算式以及结果,保存在数据库中;
在程序运行过程中,需要用户填写产生题目的数量,产生题目后,系统会自动的给出评判结果。
1.4填写时间记录日志
学生:孙丙海 日期:2017.12.06
教师:王建民
课程:psp
日期 |
开始时间 |
结束时间 |
中断时间 |
净时间 |
活动 |
备注 |
C |
U |
12/3 |
18:00 |
21:00 |
|
3小时 |
调试程序 |
完成底层代码 |
|
|
12/4 |
15:00 |
17:00 |
|
2小时 |
调试程序 |
编写jsp |
|
|
12/5 |
11:00 |
12:00 |
|
1小时 |
调试程序 |
设计程序中的倒计时功能 |
|
|
- 开发
2.1设计程序
首先实现用代码生成随机的加减乘除的算式以及结果,并存入到数据库中,在运行web端的程序,弹出输入做的提的数目,并将该数量提交到另外一个答题界面中,并显示题目,让使用者输入计算的结果,并实现在线答题,控制答题的时间,超出时间自动跳转,并告诉使用者对错情况,并统计使用者作对以及做错的数量,并在后面输出相应的笑脸或哭脸。
代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="0.jsp" method="post" >
<table align="center" border="1" width="400" >
<tr>
<td>用户名称 :</td>
<td><input type="text" name="username" size=46/></td>
</tr>
<tr>
<td>用户密码 :</td>
<td><input type="password" name="password" size=47 /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="用户登录" /></td>
</tr>
</table>
</form>
</body>
</html>
<%@page import="java.util.Date"%> <%@page import="java.text.SimpleDateFormat"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body color="pink"> <br><br> <% SimpleDateFormat simpleDateFormat=new SimpleDateFormat("HH:mm:ss"); Date currenTime=new Date(); String time=simpleDateFormat.format(currenTime).toString(); out.print("当前时间:"+time); %> <form action="1.jsp" method="get"> <table align="center" border="1" width="600"> <tr> <td> 生成题目数量 </td> <td > <input type="text" name="num" /> </td> <td colspan="2"> <input type="submit" value="提交" /> </td> </tr> <tr> <td>题号</td><br> <td>题目</td><br> <td>计算结果</td><br> <td>答案</td><br> </tr> </table> </form> </body> </html>
<%@page import="dao.OperationDaoImpl"%> <%@page import="dao.IOperationDao"%> <%@page import="java.util.ArrayList" %> <%@page import="java.util.List" %> <%@page import="java.util.*" %> <%@page import="dao.Operation "%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <SCRIPT LANGUAGE="JavaScript"> var maxtime = 30 //半个小时,按秒计算,自己调整! function CountDown(){ if(maxtime>=0){ seconds = Math.floor(maxtime%30); msg = "距离结束还有"+seconds+"秒"; document.all["timer"].innerHTML=msg; if(maxtime == 5) alert('注意,还有5秒!'); --maxtime; } else{ clearInterval(timer); alert("时间到,结束!"); window.location.href="2.jsp"; } } timer = setInterval("CountDown()",1000); </SCRIPT> </head> <% %> <body> <div id="timer" style="color:ffff00" align="center"></div> <% int a=Integer.parseInt(request.getParameter("num")); OperationDaoImpl operationDaoImpl=new OperationDaoImpl(); List<Operation> list=new ArrayList<Operation>(); Operation operation=new Operation(); String id=""; String result=""; Random random=new Random(); for(int i=0;i<a/2;i++) { int b=random.nextInt(98)+1; id=id+" "+b; operation=operationDaoImpl.loadMultiply(b).get(i); result=result+" "+operation.getStoreResult(); list.add(operation); } for(int j=a/2;j<a;j++) { int c=random.nextInt(98)+1; id=id+" "+c; operation=operationDaoImpl.loadAdd(c).get(j); result=result+" "+operation.getStoreResult(); list.add(operation); } session.setAttribute("id", id); session.setAttribute("result", result); %> <form action="2.jsp" method="get" color="red"> <table align="center" border="1" width="600"> <tr> <td colspan="2" width="70%" align="center"> 生成题目数量 </td> <td colspan="2" > <input type="text" name="num1" size=35/> </td> </tr> <tr> <td width="20%">题号</td><br> <td >题目</td><br> <td>计算结果</td><br> <td hidden> <input type="hidden",name="solution",value="答案"/> </td><br> </tr> <% int i=1; for(Operation operation1:list){ %> <tr> <td><%=i %></td> <td><%=operation1.getStoreOperation()%></td> <td> <input style="text" name="result" /></td> <% %> </tr> <% i++;} %> <tr> <td colspan="4" align="center"> <input type="submit" ,value="提交试卷" /> </td> </tr> </table> </form> </body> </html>
<%@page import="dao.OperationDaoImpl"%> <%@page import="dao.IOperationDao"%> <%@page import=" java.util.ArrayList" %> <%@page import=" java.util.List" %> <%@page import=" java.util.*" %> <%@page import="dao.Operation "%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% String arr[]=request.getParameterValues("result"); Operation operation = new Operation(); OperationDaoImpl operationDaoImpl = new OperationDaoImpl(); List<Operation> list = new ArrayList<Operation>(); String id = (String) session.getAttribute("id"); String Result = (String) session.getAttribute("result"); String Id[] = id.toString().trim().split(" "); String result[] = Result.toString().trim().split(" "); for (int i = 0; i < Id.length / 2; i++) { operation = operationDaoImpl.loadMultiply(Id.length).get(i); list.add(operation); } for (int i = Id.length / 2; i < Id.length; i++) { operation = operationDaoImpl.loadAdd(Id.length).get(i); list.add(operation); } for (int j = 0; j < result.length; j++) { System.out.println(result[j]); } %> <form> <table align="center" border="1" width="600"> <tr> <td colspan="2" width="70%" align="center"> 生成题目数量 </td> <td colspan="2" > <input type="text" name="num" size=35/> </td> </tr> <tr> <td width="20%">题号</td><br> <td >题目</td><br> <td>计算结果</td><br> <td>答案</td><br> </tr> <tr> <% int i=0; for(Operation operation1:list){ %> <tr> <td><%=i+1 %></td> <td><%=operation1.getStoreOperation() %></td> <td> <% if(result[i].equals(list.get(i).getStoreResult())) { %> <font style="color: blue;"> <% out.print(arr[i]);%> </font> <% } else { %> <font style="color: red;"> <% out.print(arr[i]);%> </font> <% } %> </td> <td><%=operation1.getStoreResult()%></td> </tr> <% i++; } session.invalidate(); %> </table> </form> </body> </html>
2.3编译程序,修复并记录所发现的bug,并填写缺陷记录日志
学生:孙丙海
日期:2017.12.3
老师:王建民
程序号:1
日期 |
编号 |
类型 |
引入阶段 |
排除阶段 |
修复时间 |
修复缺陷 |
12/3 |
1 |
20 |
编码 |
编译 |
3h |
|
在另一个界面中无法获取用户的输入结果 |
||||||
日期 |
编号 |
类型 |
引入阶段 |
排除阶段 |
修复时间 |
修复缺陷 |
12/3 |
2 |
20 |
编码 |
编译 |
15min |
|
在java文件中定义的底层代码修改后,需要重启服务器。 |
- 总结
本程序大约在花了三天的时间完成,在开发过程中,遇到的bug有session中的值不能获取到,与队友的配合不够默契,关键是前期的讨论没有做充分导致后期再把代码合在一起的时候总是接不上,与预期的想法不一致,但是后来还是按时完成了项目开发所需要的要求。