
本系统主要实现的功能有: 学生以及老师的注册登录,在线考试,错题查询,学生管理,问题管理,错题管理,错题查询,分数查询,试卷管 理,人工组卷。自动组卷,教师,班级,统计等等管理功能。
二、项目运行环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: VUE+Springboot+ SpringMVC + MyBatis + ThymeLeaf + Javascript + JQuery + Ajax + maven等等
课程信息控制器:
@RestController
@RequestMapping(value = "/v1/subjects")
public class SubjectController {
private static Logger logger = LoggerFactory.getLogger(SubjectController.class);
@Autowired
SubjectService subjectService;
@ApiOperation(value = "获取科目列表", notes = "")
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public PageInfo getSubjectList(@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List subjects = subjectService.getSubjectList();
PageInfo pageInfo = new PageInfo(subjects);
return pageInfo;
}
@ApiOperation(value = "根据名字获取科目信息", notes = "根据科目名称获取科目详细信息")
@ApiImplicitParam(name = "name", value = "科目名称", required = true, dataType = "String", paramType = "path")
@RequestMapping(value = "/{name}/name", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public List getSubjectByName(@PathVariable String name) {
return subjectService.getSubjectFuzzy(name);
}
@ApiOperation(value = "获取课程信息", notes = "根据课程id获取课程详细信息")
@ApiImplicitParam(name = "idOrName", value = "课程ID或名称", required = true, dataType = "String", paramType = "path")
@RequestMapping(value = "/search/{idOrName}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public List getSubjectForSearch(@PathVariable String idOrName) {
List subjects = new ArrayList();
Subject subject = subjectService.getSubjectByName(idOrName);
if (subject == null) {
try {
subject = subjectService.getSubjectById(idOrName);
} catch (Exception e) {
}
}
if (subject != null) {
subjects.add(subject);
}
return subjects;
}
@ApiOperation(value = "创建课程", notes = "创建课程")
@ApiImplicitParam(name = "subject", value = "课程实体Subject", required = true, dataType = "Subject")
@RequestMapping(value = "", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public ResponseEntity> postSubject(@RequestBody Subject subject) {
if(subjectService.getSubjectByName(subject.getName()) != null) {
return new ResponseEntity
题目信息控制器:
@RestController
@RequestMapping(value = "/v1/questions")
public class QuestionController {
private static Logger logger = LoggerFactory.getLogger(QuestionController.class);
@Autowired
QuestionService questionService;
@Autowired
PaperAnswerPaperService paperAnswerPaperService;
@ApiOperation(value = "获取题目分页列表", notes = "")
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public PageInfo getQuestionListByPage(@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List questions = questionService.getQuestionList();
PageInfo pageInfo = new PageInfo(questions);
return pageInfo;
}
@ApiOperation(value = "获取试卷题目分页列表", notes = "")
@RequestMapping(value = "/papers/{paperId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public PageInfo getQuestionListByPaper(@PathVariable String paperId,
@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List questions = questionService.getQuestionListByPaper(paperId);
PageInfo pageInfo = new PageInfo(questions);
return pageInfo;
}
@ApiOperation(value = "获取试卷题目数量", notes = "")
@RequestMapping(value = "/papers/{paperId}/count", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public ResponseEntity> getQuestionCountByPaper(@PathVariable String paperId) {
Integer count = questionService.countByPaperId(paperId);
return new ResponseEntity
考试控制层,负责试卷提交等:
@RestController
@RequestMapping("/v1/exam")
public class ExamController {
@Autowired
ExamService examService;
@Autowired
AnswerPaperService answerPaperService;
@Autowired
AnswerQuestionService answerQuestionService;
@Autowired
AnswerPaperQuestionService answerPaperQuestionService;
@Autowired
QuestionService questionService;
@Autowired
PaperService paperService;
@Autowired
WrongQuestionService wrongQuestionService;
@Autowired
PaperAnswerPaperService paperAnswerPaperService;
@ApiOperation(value = "根据试卷id和题目编号获取题目信息", notes = "根据题目id获取题目详细信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "paperId", value = "试卷ID", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "number", value = "题目编号", required = true, dataType = "String", paramType = "path")
})
@RequestMapping(value = "/questions/{number}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public Question getQuestionByPaperIdAndQuestionId(@RequestParam String paperId,
@RequestParam String username,
@RequestParam(required = false) String answerPaperId,
@PathVariable Integer number) {
Question question = null;
AnswerQuestion answerQuestion = null;
if(answerPaperId == null) {
Paper paper = paperService.getPaperById(paperId);
if(paper != null) {
AnswerPaper answerPaper = answerPaperService.findByAnswerUserAndPaperName(username, paper.getName());
if(answerPaper != null) {
answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(answerPaper.getId(), number);
}
}
}else {
answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(answerPaperId, number);
}
if(answerQuestion == null) {
question = questionService.getQuestionByPaperIdAndQuestionNumber(paperId, number);
if(question != null) {
//答案不返回
question.setAnswer("");
}
} else {
question = new Question();
question.setId(answerQuestion.getId());
question.setNumber(answerQuestion.getNumber());
question.setTitle(answerQuestion.getTitle());
question.setScore(answerQuestion.getScore());
question.setType(answerQuestion.getType());
question.setOptionA(answerQuestion.getOptionA());
question.setOptionB(answerQuestion.getOptionB());
question.setOptionC(answerQuestion.getOptionC());
question.setOptionD(answerQuestion.getOptionD());
question.setAnswer(answerQuestion.getAnswer());
}
return question;
}
@RequestMapping(value = "/submit/{type}/{username}", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public ResponseEntity> submit(@RequestBody Paper paper, @PathVariable String type,
@PathVariable String username,
@RequestParam(required = false) String answerPaperId) {
if(type.equals("official")) {
AnswerPaper answerPaper = new AnswerPaper();
if(answerPaperId != null) {
answerPaper.setId(answerPaperId);
}else {
return new ResponseEntity
答卷控制层,用于获取已经提交的答卷:
@RestController
@RequestMapping("/v1/answer-papers")
public class AnswerPaperController {
@Autowired
AnswerPaperService answerPaperService;
@Autowired
AnswerQuestionService answerQuestionService;
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public AnswerPaper getAnswerPaper(@PathVariable String id) {
return answerPaperService.getAnswerPaperById(id);
}
@RequestMapping(value = "/name/{name}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public List getAnswerPaperByName(@PathVariable String name) {
return answerPaperService.getAnswerPaperFuzzy(name);
}
@RequestMapping(value = "/papers/{paperId}/questions/{number}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public AnswerQuestion getQuestionByPaperIdAndQuestionId(@PathVariable String paperId, @PathVariable Integer number) {
AnswerQuestion answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(paperId, number);
return answerQuestion;
}
@RequestMapping(value = "/users/{username}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public PageInfo getListByUser(@PathVariable("username") String username,
@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List answerPapers = answerPaperService.getAnswerPaperListByAnswerUser(username);
PageInfo pageInfo = new PageInfo(answerPapers);
return pageInfo;
}
@RequestMapping(value = "/users/{username}/type/{type}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public PageInfo getListByUserAndType(@PathVariable("username") String username,
@PathVariable("type") String type,
@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List answerPapers = answerPaperService.getAnswerPaperListByAnswerUserAndType(username, type);
PageInfo pageInfo = new PageInfo(answerPapers);
return pageInfo;
}
@RequestMapping("/check")
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public DtoTask countUnCheckAnswerPaper() {
DtoTask dtoTask = new DtoTask();
Integer checked = answerPaperService.countCheck("true");
Integer unChecked = answerPaperService.countCheck("false");
dtoTask.setChecked(checked);
dtoTask.setUnChecked(unChecked);
return dtoTask;
}
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public PageInfo getListByUser(@RequestParam(required = false) Integer pageIndex,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) Integer limit,
@RequestParam(required = false) Integer offset) {
if(pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize);
}
List answerPapers = answerPaperService.getAnswerPaperList();
PageInfo pageInfo = new PageInfo(answerPapers);
return pageInfo;
}
@RequestMapping(value = "", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public ResponseEntity> putPaper(@RequestBody AnswerPaper answerPaper) {
answerPaperService.updatePaper(answerPaper);
return new ResponseEntity(HttpStatus.OK);
}
@RequestMapping(value = "/{id}/calculate", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")
public ResponseEntity> CalculationScore(@PathVariable String id) {
List questions = answerQuestionService.findByAnswerPaperId(id);
if(questions != null && questions.size() > 0) {
int score = 0;
try {
for(AnswerQuestion question : questions) {
score += Integer.parseInt(question.getMarkScore());
}
} catch (Exception e) {
// TODO: 2017/4/1
}
AnswerPaper answerPaper = new AnswerPaper();
answerPaper.setId(id);
answerPaper.setScore(Integer.toString(score));
answerPaper.setChecked("true");
answerPaperService.updatePaper(answerPaper);
} else {
// TODO: 2017/4/1
}
return new ResponseEntity(HttpStatus.OK);
}
@RequestMapping(value = "/analysis/paper")
@PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")
public List analysisPaper() {
return answerPaperService.analysisPaper();
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)