作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
在线考试系统是利用Java web技术开发设计的。数据库是基于Mysql设计的。学生可以在线考试,系统实现自动阅卷,管理员可以管理学生信息,试卷信息,题目信息等;本系统分前台和后台两部分,前台实现功能有:学生登录,在线考试,成绩查询,修改密码等;后台实现功能有:管理员登录,考生信息管理,考生成绩查询,试卷管理,题目管理等;
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
1. 后端:spring+spring mvc+hibernate
2. 前端:JSP+Javascript+Bootstrap
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
2. 将项目中hibernate.cfg.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,考生登录页面输入http://localhost:8080/ 登录
考生账号密码:JS20140701094708/123456
管理员登录页面地址:http://localhost:8080/login2.jsp
管理员账号密码:admin/123456

- /**
- * 考试Action类
- * @author Administrator
- *
- */
- public class ExamAction extends ActionSupport implements ServletRequestAware{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private ExamDao examDao=new ExamDao();
- private QuestionDao questionDao=new QuestionDao();
-
- private HttpServletRequest request;
-
- private String mainPage;
-
- private Exam exam;
- private Exam s_exam;
-
- private List<Exam> examList;
-
- private String page;
- private int total;
- private String pageCode;
-
- public String getMainPage() {
- return mainPage;
- }
-
- public void setMainPage(String mainPage) {
- this.mainPage = mainPage;
- }
-
- public Exam getExam() {
- return exam;
- }
-
- public void setExam(Exam exam) {
- this.exam = exam;
- }
-
- public List<Exam> getExamList() {
- return examList;
- }
-
- public void setExamList(List<Exam> examList) {
- this.examList = examList;
- }
-
- public Exam getS_exam() {
- return s_exam;
- }
-
- public void setS_exam(Exam s_exam) {
- this.s_exam = s_exam;
- }
-
- public String getPage() {
- return page;
- }
-
- public void setPage(String page) {
- this.page = page;
- }
-
- public int getTotal() {
- return total;
- }
-
- public void setTotal(int total) {
- this.total = total;
- }
-
- public String getPageCode() {
- return pageCode;
- }
-
- public void setPageCode(String pageCode) {
- this.pageCode = pageCode;
- }
-
- /**
- * 计算/添加考试成绩
- * @return
- * @throws Exception
- */
- public String add()throws Exception{
- Map<String, String[]> keyMap = new HashMap<String, String[]>();
- keyMap = request.getParameterMap();
- Iterator<Entry<String,String[]>> it2 = keyMap.entrySet().iterator();
- int totalScore=0;
- int singleScore=0;
- int moreScore=0;
- while (it2.hasNext()) {
- Entry<String, String[]> entry = it2.next();
- String keyStr=entry.getKey();
- String values[]=entry.getValue();
- String key;
- String value="";
- if(keyStr.equals("exam.student.id")||keyStr.equals("exam.paper.id")){
- continue;
- }
- if(keyStr.split("-")[1].equals("r")){ // 单选
- key=keyStr.split("-")[2];
- value=values[0];
- singleScore+=this.calScore(key, value, "1");
- }else{ // 多选
- key=keyStr.split("-")[2];
- for(String s:values){
- value+=s+",";
- }
- value=value.substring(0,value.length()-1);
- moreScore+=this.calScore(key, value, "2");
- }
- }
- totalScore=singleScore+moreScore;
- exam.setSingleScore(singleScore);
- exam.setMoreScore(moreScore);
- exam.setScore(totalScore);
- //exam.setExamDate(new Date());
- examDao.saveExam(exam);
- mainPage="exam/examResult.jsp";
- return SUCCESS;
- }
-
- /**
- * 试卷Action类
- * @author Administrator
- *
- */
- public class PaperAction extends ActionSupport{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private PaperDao paperDao=new PaperDao();
- private QuestionDao questionDao=new QuestionDao();
-
- private String mainPage;
- private String paperId;
-
- private List<Paper> paperList=new ArrayList<Paper>();
- private List<Question> squestionList=new ArrayList<Question>();
- private List<Question> mquestionList=new ArrayList<Question>();
-
- private String title; // 标题
-
-
- private Paper paper;
-
- public List<Paper> getPaperList() {
- return paperList;
- }
-
- public void setPaperList(List<Paper> paperList) {
- this.paperList = paperList;
- }
-
-
-
- public List<Question> getSquestionList() {
- return squestionList;
- }
-
- public void setSquestionList(List<Question> squestionList) {
- this.squestionList = squestionList;
- }
-
- public List<Question> getMquestionList() {
- return mquestionList;
- }
-
- public void setMquestionList(List<Question> mquestionList) {
- this.mquestionList = mquestionList;
- }
-
- public void setPaper(Paper paper) {
- this.paper = paper;
- }
-
-
- public Paper getPaper() {
- return paper;
- }
-
-
-
- public String getPaperId() {
- return paperId;
- }
-
- public void setPaperId(String paperId) {
- this.paperId = paperId;
- }
-
- public String getMainPage() {
- return mainPage;
- }
-
- public void setMainPage(String mainPage) {
- this.mainPage = mainPage;
- }
-
-
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * 获取所有试卷
- * @return
- * @throws Exception
- */
- public String list()throws Exception{
- paperList=paperDao.getPapers();
- mainPage="exam/selectPaper.jsp";
- return SUCCESS;
- }
-
- /**
- * 获取所有试卷(管理)
- * @return
- * @throws Exception
- */
- public String paperList()throws Exception{
- paperList=paperDao.getPapers();
- mainPage="paper/paperList.jsp";
- return SUCCESS;
- }
-
- /**
- * 通过id获取试卷实体
- * @return
- * @throws Exception
- */
- public String getPaperById()throws Exception{
- paper=paperDao.getPaper(paperId);
- mainPage="paper/paperSave.jsp";
- return SUCCESS;
- }
-
- /**
- * 保存预操作
- * @return
- * @throws Exception
- */
- public String preSave()throws Exception{
- if(StringUtil.isNotEmpty(paperId)){
- paper=paperDao.getPaper(paperId);
- title="修改试卷";
- }else{
- title="添加试卷";
- }
- mainPage="paper/paperSave.jsp";
- return SUCCESS;
- }
-
- /**
- * 保存试卷
- * @return
- * @throws Exception
- */
- public String savePaper()throws Exception{
- if(StringUtil.isNotEmpty(paperId)){
- paper.setId(Integer.parseInt(paperId));
- }else{
- paper.setJoinDate(new Date());
- }
- paperDao.savePaper(paper);
- return "save";
- }
如果也想学习本系统,下面领取。回复:106ssh