-須知
1.Controller層要負(fù)責(zé)業(yè)務(wù)流程的控制:
2.Service要負(fù)責(zé)業(yè)務(wù)模塊的業(yè)務(wù)邏輯應(yīng)用設(shè)計(jì):
3.Dao層定義了與數(shù)據(jù)庫交互的接口:
考試系統(tǒng)實(shí)現(xiàn)
考試中心模塊實(shí)現(xiàn)
該模塊主要對(duì)考生試卷進(jìn)行分配悔耘,考生點(diǎn)擊考試中心進(jìn)入考試項(xiàng)目選擇界面帮寻,緊接著需要進(jìn)一步明確考試科目,最終選擇相應(yīng)的考試模式進(jìn)行答題∠希考生必須按步驟進(jìn)行减细,當(dāng)且僅當(dāng)前一操作已經(jīng)執(zhí)行才可以進(jìn)入下一步尤辱。
1.考試項(xiàng)目選擇模塊實(shí)現(xiàn)
1.1.界面設(shè)計(jì)
1.3.選擇考試項(xiàng)目的核心代碼如下所示:
1.3.1.前端請(qǐng)求代碼:
1.3.2.Controller層:
//《ExamController.java相關(guān)源碼》
@RequestMapping(value="index",method= RequestMethod.GET)
public ModelAndView index(){
return new ModelAndView("exam/index");
}
//1.選擇考試專業(yè)項(xiàng)目 列表
@RequestMapping(value="chooseCourse")
public ModelAndView chooseCourse(ModelMap map, Integer pageNo, String findContent){
//分頁炭庙,專業(yè)項(xiàng)目列表
map.put("findContent", findContent);
Pagination<QCourseMapper> page = courseService.findByPage(map,pageNo,pageSize);
map.put("page", page);
return new ModelAndView("exam/choose_course");
}
1.3.3.Service層:
//《CourseService.java相關(guān)源碼》
public interface CourseService {
//查詢考試所有的專業(yè)項(xiàng)目 分頁
Pagination<QCourseMapper> findByPage(Map<String, Object> resultMap, Integer pageNo, Integer pageSize);
//考試項(xiàng)目信息
QCourse findById(Integer id);
//考試科目信息
QCourse findCourseTypeById(Integer parent_id,Integer type);
}
1.3.4.Dao層
//《QCourseMapper.java相關(guān)源碼》
//考試科目信息 QCourse findCourseTypeById(@Param("parent_id") Integer parent_id,@Param("type") Integer type);
//獲取所有的 _table
List<QCourse> findAll_Table();```
2.考試科目選擇模塊實(shí)現(xiàn)
2.1.界面設(shè)計(jì)
2.2.考試科目選擇的核心代碼如下所示:
2.2.1.前端請(qǐng)求代碼:
2.2.2.Controller層:
//《CourseService.java相關(guān)源碼》
//根據(jù)考試專業(yè)項(xiàng)目的id查詢出q_course_category所有的考試科目列表
@RequestMapping(value="get_course_list")
public ModelAndView getCourseList(ModelMap map,String findContent, Integer course_id){
if(course_id == null){
return new ModelAndView("exam/get_course_list");
}
//考試項(xiàng)目type
QCourse course = courseService.findById(course_id);
map.put("type",course.getType());
map.put("findContent", findContent);
map.put("course_id",course_id);
Pagination<QCourseMapper> page = courseService.findByPage(map,pageNo,pageSize);
map.put("page", page);
return new ModelAndView("exam/get_course_list");
}
2.2.3.Service層
// 《CourseService.java相關(guān)源碼》
public interface CourseService {
//考試項(xiàng)目信息
QCourse findById(Integer id);
}
2.2.4.Dao層
public interface QCourseMapper {
QCourse selectByPrimaryKey(Integer id);
}
3.考試模式模塊實(shí)現(xiàn)
3.1.界面設(shè)計(jì)
3.2.選擇考試項(xiàng)目的核心代碼如下所示:
3.2.1.前端請(qǐng)求代碼:
3.2.2.Controller層:
//《ExamController.java相關(guān)源碼》
//考試的模式選擇 type=${remarks}考試項(xiàng)目 &courseType=${it.value}考試科目
@RequestMapping(value="get_model_list")
public ModelAndView getModelList(ModelMap map,Integer type,Integer courseType){
Map<String,String> modelList = new LinkedHashMap<>();
modelList.put(String.valueOf(Const.ExamModelEnum.MODEL_1.getCode()),Const.ExamModelEnum.MODEL_1.getValue()); modelList.put(String.valueOf(Const.ExamModelEnum.MODEL_2.getCode()),Const.ExamModelEnum.MODEL_2.getValue()); modelList.put(String.valueOf(Const.ExamModelEnum.MODEL_3.getCode()),Const.ExamModelEnum.MODEL_3.getValue()); modelList.put(String.valueOf(Const.ExamModelEnum.MODEL_4.getCode()),Const.ExamModelEnum.MODEL_4.getValue()); modelList.put(String.valueOf(Const.ExamModelEnum.MODEL_5.getCode()),Const.ExamModelEnum.MODEL_5.getValue());
map.put("modelList",modelList);
map.put("type",type);
map.put("courseType",courseType);
return new ModelAndView("exam/get_model_list");
}
答題系統(tǒng)模塊實(shí)現(xiàn)
該模塊針對(duì)考生所選的考試類型進(jìn)行自動(dòng)分配相應(yīng)的卷子。試題類型有單選題泵肄,多選題捆交,判斷題,大題腐巢,考生需要在固定的時(shí)間里完成該試卷品追,答題完畢后需點(diǎn)擊交卷,否則時(shí)間截止時(shí)將會(huì)強(qiáng)制提交試卷無法作答系忙。
1.考試答題系統(tǒng)模塊實(shí)現(xiàn)
1.1.界面設(shè)計(jì)
1.3.考試答題系統(tǒng)項(xiàng)目的核心代碼如下所示:
1.3.1.前端請(qǐng)求代碼:
1.3.2.Controller層:
//開始考試 隨機(jī)生成新考卷
@RequestMapping(value="start_exam")
public ModelAndView StartExam(ModelMap map,Integer type,Integer courseType,Integer mode){
//考試項(xiàng)目
QCourse CourseProject = courseService.findById(type);
String CourseProjectName = CourseProject.getName();
map.put("CourseProjectName",CourseProjectName);
map.put("type",type);
//考試科目
QCourse Course = courseService.findCourseTypeById(CourseProject.getId(),courseType);
String CourseName = Course.getName();
map.put("CourseName",CourseName);
map.put("courseType",courseType);
//考試模式
Class<Const.ExamModelEnum> clasz = Const.ExamModelEnum.class;
String modeName =(String) EnumUtil.getEnumValueByCode(mode, clasz);
map.put("modeName",modeName);
map.put("mode",mode);
//隨機(jī)值 = 用來索引這個(gè)考卷的id
Random random = new Random();
int srandom = random.nextInt(1000000)%(9000000-1000000+1) + 1000000;
map.put("srandom",srandom);
//考試時(shí)間
int exam_time = 3600;
map.put("exam_time",exam_time);
//創(chuàng)建新的考卷
Map<String,List<QQuestion>> questions = examService.CreateExamPaper(srandom,type,courseType,mode,exam_time);
map.put("questions",questions);
return new ModelAndView("exam/exam");
}