Java implements online examination system (teacher function)

Online Exam System Teacher Login Page
write picture description here

//跳转到登录页面
@RequestMapping(value="/login", method = RequestMethod.GET)
	public String userLogin(){
		
		return "/adminUser/login";
	}
	
	//实现登录功能
@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String adminLogin(String id, String password,Model model, HttpServletRequest request){
		//在service实现的登录功能校验
		Teacher teacher = teacherService.login(id, password);
		if (teacher != null){
			HttpSession session = request.getSession();
			session.setAttribute("teacherInfo", teacher);
			return "redirect:/index";
		}
		model.addAttribute("message", "用户名或密码错误!");
		return "/adminUser/login";
	}
	
	//跳转到修改密码页面
	@RequestMapping(value="/updatePassword", method=RequestMethod.GET)
	public String userUpdatePasswordView(){
		
		return "/adminUser/updatePassword";
	}
	
	//实现密码修改功能
	@RequestMapping(value="/updatePassword", method=RequestMethod.POST)
	@ResponseBody
	public AjaxResult userUpdatePassword(String id, String password, String newpassword, String renewpassword){
		
		if (newpassword != null){
			if (newpassword.equals(renewpassword)){
			//在service实现了修改密码功能
				boolean flag = teacherService.updatePassword(id, password, newpassword);
				if (flag){
					return AjaxResult.successInstance("修改密码成功");
				}else{
					return AjaxResult.errorInstance("原密码错误");
				}
			}else{
				return AjaxResult.errorInstance("您两次输入的密码不一致");
			}
		}
		
		return AjaxResult.errorInstance("您两次输入的密码不一致");
	}
	
//退出系统功能代码
@RequestMapping("/logout")
	public String userLogout(HttpServletRequest request){
		
		HttpSession session = request.getSession();
		session.setAttribute("teacherInfo", null);
		return "redirect:/adminUser/login";
	}
//实现登录拦截器
@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		//在handle执行之前处理
		//判断用户是否登录
		//1.获取Session
		HttpSession session = request.getSession();
		Teacher teacher = (Teacher) session.getAttribute("teacherInfo");
		
		if (teacher == null){
			response.sendRedirect("/adminUser/login");
			return false;
		}
		
		return true;
	}

After the teacher logs in to the system, he can conduct examination management (the teacher's marking is a flow marking, and all teachers who teach this course will mark the paper, but the teacher does not know which student's paper in which class he is marking)
write picture description here
The system uses a semi-automatic marking method for marking examination papers ( Multiple-choice questions and fill-in-the-blank questions are graded by computer in the background. It is too difficult to use computer to grade subjective questions, so we change to the teacher to grade the paper manually; in order to facilitate the teacher to grade the paper, the correct answer will be displayed below the answer of the test)
write picture description here
write picture description here

You can see which student's test paper is the completed test paper, and you can also view the marked test paper, which is convenient for checking the student's test paper.
write picture description here

As a teacher, you can add test question modules (such as multiple-choice questions, fill-in-the-blank questions, etc., what types of questions are there, and it is easy to select certain test questions to publish when publishing the test)
write picture description here

There is the function of adding test questions, of course, there is also the function of adding test questions (here, the teacher can only view all the test questions of the courses he teaches, and the test questions of the courses that are not taught are not authorized to view) The
write picture description here
function of adding test questions (if it is a multiple-choice question, there are There are four option boxes for ABCD, if it is non-multiple choice, there is no, here we have a linkage function)
write picture description here
write picture description here
When adding test questions, we also control the authority of the subjects, the teacher can only add the test questions of the subjects taught by himself Test questions related to subjects (and here we have done a secondary linkage of the form, select a subject, and the following test question chapters will also become the chapters corresponding to the subject)
write picture description here

//跳转到添加页面
@RequestMapping(value="/add", method=RequestMethod.GET)
	public String addTextView(HttpServletRequest request,Model model){
		
		HttpSession session = request.getSession();
		Teacher teacher = (Teacher) session.getAttribute("teacherInfo");
		List<Subject> textList = subjectService.showList(teacher.getId());
		Subject subject = textList.get(0);
		List<Chapter> chapterList = chapterService.getChapter(subject.getId());
		List<Textmodel> textModelList = textModelService.showList();
		model.addAttribute("textList", textList);
		model.addAttribute("textModelList", textModelList);
		model.addAttribute("chapterList", chapterList);
		return "/text/add";
	}
	//添加试题
	@RequestMapping(value="/add", method=RequestMethod.POST)
	@ResponseBody
	public AjaxResult addText(Text text){
		
		Integer chapterid = text.getChapterid();
		Chapter chapter = chapterService.selectOne(chapterid);
		text.setChaptername(chapter.getName()+"   "+chapter.getTitle());
		
		Integer subjectid = text.getSubjectid();
		Subject subject = subjectService.selectOne(subjectid);
		text.setSubjectname(subject.getName());
		
		Integer texId = text.getTexId();
		Textmodel textmodel = textModelService.selectOne(texId);
		text.setModelname(textmodel.getTexttype());
		
		textService.insert(text);
		return AjaxResult.successInstance("添加成功");
	}
//添加试题模块前端JQuery
<script type="text/javascript">
		$(function(){
			//科目的下拉框change事件
			$("#subjectid").change(function(){
				var subjectid = $("#subjectid").val();
				$.ajax({
					type:"POST",
					url:"<%=path%>/text/showChapter",
					data:{
						id:subjectid
					},
					dataType:"json",
					success:function(data){
						$("#chapterid").empty();
						$.each(data,function(index,item){
							$("#chapterid").append("<option value='"+item.id+"'>"+item.name+"&nbsp;&nbsp;&nbsp;"+item.title+"</option>");
						})
					}
				})
			}
					
			)
			
		})
	</script>
	
	<!-- 当是选择题时出现选择题ABCD框,否则不显示 -->
	<script type="text/javascript">
		//初始情况
		$(function(){
			var model = $("#texId option:selected").text();
			if (model != "选择题"){
				$("#type1,#type2,#type3,#type4").hide();
			}
			
			//当试题模块内容改变
			$("#texId").change(function(){
				var model = $("#texId option:selected").text();
				if (model != "选择题"){
					$("#type1,#type2,#type3,#type4").hide();
				}else{
					$("#type1,#type2,#type3,#type4").show();
				}
			})
			
		})
	</script>

The query result function is the same as the administrator's query function, so it will not be repeated here (because there are many codes, so just select some codes and paste them)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324223066&siteId=291194637