|
|
@@ -1,22 +1,27 @@
|
|
|
package com.ruoyi.web.controller.front;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult2;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.dz.domain.DzSubject;
|
|
|
import com.ruoyi.dz.service.IDzControlService;
|
|
|
+import com.ruoyi.dz.service.IDzSubjectService;
|
|
|
import com.ruoyi.enums.PaperType;
|
|
|
import com.ruoyi.learn.domain.AnswerSheet;
|
|
|
import com.ruoyi.mxjb.domain.MxjbContants;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import com.ruoyi.web.domain.PaperDto;
|
|
|
-import com.ruoyi.web.service.CacheService;
|
|
|
-import com.ruoyi.web.service.ExamService;
|
|
|
-import com.ruoyi.web.service.PaperService;
|
|
|
-import com.ruoyi.web.service.SyTestMajorService;
|
|
|
+import com.ruoyi.web.service.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/front/exam")
|
|
|
@@ -25,11 +30,33 @@ public class FrontExamController {
|
|
|
private final ExamService examService;
|
|
|
private final SyTestMajorService syTestMajorService;
|
|
|
private final CacheService cacheService;
|
|
|
+ private final IDzSubjectService dzSubjectService;
|
|
|
+ private final StudentService studentService;
|
|
|
+ private final ISysUserService sysUserService;
|
|
|
|
|
|
- public FrontExamController(ExamService examService, SyTestMajorService syTestMajorService, CacheService cacheService) {
|
|
|
+ public FrontExamController(ExamService examService, SyTestMajorService syTestMajorService, CacheService cacheService, IDzSubjectService dzSubjectService, IDzSubjectService dzSubjectService1, StudentService studentService, ISysUserService sysUserService) {
|
|
|
this.examService = examService;
|
|
|
this.syTestMajorService = syTestMajorService;
|
|
|
this.cacheService = cacheService;
|
|
|
+ this.dzSubjectService = dzSubjectService1;
|
|
|
+ this.studentService = studentService;
|
|
|
+ this.sysUserService = sysUserService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/subjects")
|
|
|
+ @ApiOperation("科目列表")
|
|
|
+ public AjaxResult subjects()
|
|
|
+ {
|
|
|
+ SysUser sysUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ List<DzSubject> list = dzSubjectService.selectDzSubjectBySubjectIds(new Long[] {1L, 2L, 3L, 11L});
|
|
|
+ JSONObject evalCounts = JSONObject.parseObject(sysUserService.selectUserById(sysUser.getUserId()).getEvalCounts());
|
|
|
+ return AjaxResult.success(list.stream().map(t -> {
|
|
|
+ JSONObject o = new JSONObject();
|
|
|
+ o.put("subjectId", t.getSubjectId());
|
|
|
+ o.put("subject", t.getSubjectName());
|
|
|
+ o.put("examTime", evalCounts.getIntValue(t.getSubjectId().toString()));
|
|
|
+ return o;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
// 试卷: 真题卷,批次测试卷,自组卷, 生成考试记录
|
|
|
@@ -40,7 +67,9 @@ public class FrontExamController {
|
|
|
public AjaxResult openExaminee(@ApiParam("0默认1价值2职业3知识") @RequestParam(required = false) Integer testType,
|
|
|
@ApiParam("定向") @RequestParam(defaultValue = "false") boolean directed,
|
|
|
@ApiParam("考卷类型PaperType") @RequestParam(required = false) PaperType paperType,
|
|
|
- @ApiParam("考卷类型关联ID") @RequestParam Long relateId) {
|
|
|
+ @ApiParam("考卷类型关联ID") @RequestParam(required = false) Long relateId,
|
|
|
+ @ApiParam("考卷类型关联ID") @RequestParam(required = false) Long subjectId,
|
|
|
+ @RequestBody JSONObject body) {
|
|
|
if(null != testType && testType > 0) {
|
|
|
PaperDto paperDto = syTestMajorService.loadPaperByTestMajorTypeId(testType);
|
|
|
Map<String, String> stateMap = cacheService.selectDictDataMapByType(MxjbContants.StateTypeExaminee);
|
|
|
@@ -48,7 +77,12 @@ public class FrontExamController {
|
|
|
paperDto.calculateAllow();
|
|
|
return AjaxResult.success(paperDto);
|
|
|
}
|
|
|
- return AjaxResult.success(examService.openExaminee(directed, paperType, relateId));
|
|
|
+ if(null == subjectId && null == paperType) {
|
|
|
+ subjectId = body.getLongValue("subjectId");
|
|
|
+ paperType = PaperType.valueOf(body.getString("paperType"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success(examService.openExaminee(directed, paperType, relateId, subjectId));
|
|
|
}
|
|
|
|
|
|
@ApiOperation("04 开始考试")
|
|
|
@@ -60,8 +94,11 @@ public class FrontExamController {
|
|
|
|
|
|
@ApiOperation("04 取答卷")
|
|
|
@GetMapping(value = "loadExaminee")
|
|
|
- public AjaxResult loadExaminee(@ApiParam("答卷ID") Long examineeId) {
|
|
|
+ public AjaxResult loadExaminee(@ApiParam("答卷ID") @RequestParam(required = false) Long examineeId, @RequestBody JSONObject body) {
|
|
|
// 检查状态,以决定是否返回答案
|
|
|
+ if(null == examineeId) {
|
|
|
+ examineeId = body.getLongValue("examineeId");
|
|
|
+ }
|
|
|
return AjaxResult.success(examService.loadExaminee(examineeId, false));
|
|
|
}
|
|
|
|