mingfu 1 месяц назад
Родитель
Сommit
373a597e46

+ 16 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontTeacherController.java

@@ -2,12 +2,16 @@ package com.ruoyi.web.controller.front;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
+import com.ruoyi.common.core.content.VistorContextHolder;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.AjaxResult2;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.ExamType;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.domain.DzTeacher;
 import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
@@ -157,4 +161,16 @@ public class FrontTeacherController extends BaseController {
     {
         return AjaxResult.success(learnStatService.getRecordVideo(recordId));
     }
+
+    @GetMapping("/subjects")
+    @ApiOperation("科目列表")
+    public AjaxResult2<List<DzSubject>> subjects()
+    {
+        SysUser vistor = VistorContextHolder.getContext();
+        DzSubject sCond = new DzSubject();
+        sCond.setExamTypes(vistor.getExamType().name());
+        sCond.setLocations(vistor.getLocation());
+        List<DzSubject> list = dzSubjectService.selectDzSubjectList(sCond);
+        return AjaxResult2.success(list);
+    }
 }

+ 47 - 19
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -229,7 +229,7 @@ public class ExamService {
             upExaminee.setScoreRate(score * 100 / totalScore);
             upExaminee.setWrongCount(wrongCount);
             learnExamineeMapper.updateLearnExaminee(upExaminee);
-            if(PaperType.Simulated.getVal().equals(exitExaminee.getPaperType())) {
+            if(PaperType.Simulated.getVal().equals(exitExaminee.getPaperType()) || PaperType.Test.getVal().equals(exitExaminee.getPaperType())) {
                 List<JSONObject> paperStatList = learnExamineeMapper.selectExamRankingStats(upExaminee.getScore(), Lists.newArrayList(exitExaminee.getPaperId()));
                 JSONObject o = paperStatList.get(0);
                 Integer totalCount = o.getInteger("totalCount");
@@ -361,6 +361,31 @@ public class ExamService {
         return answer;
     }
 
+    private AnswerSheet openExamineeForTest(PaperType paperType, Long paperId, LearnTestStudent ts) {
+        LearnPaper paper = paperMapper.selectLearnPaperById(paperId);
+
+        LearnExaminee learnExaminee = new LearnExaminee();
+        learnExaminee.setStudentId(ts.getStudentId());
+        learnExaminee.setPaperId(paperId);
+        learnExaminee.setPaperType(paperType.getVal());
+        learnExaminee.setState(ExamineeStatus.Exam.getVal());
+        List<LearnExaminee> examineeList = examineeMapper.selectLearnExamineeList(learnExaminee);
+        if (CollectionUtils.isNotEmpty(examineeList)) {
+            learnExaminee = examineeList.get(0);
+        } else {
+            if(StringUtils.isNotBlank(ts.getDirectKey())) { // 全量,只分科目
+                LearnStudent ls = learnStudentMapper.selectLearnStudentByStudentId(ts.getStudentId());
+                AMarjorPlan plan = marjorPlanService.selectAMarjorPlanById(ls.getMajorPlanId());
+                learnExaminee.setPaperInfo(buildPaperInfo(ls, plan));
+            }
+            learnExaminee.setState(ExamineeStatus.Exam.getVal());
+            learnExaminee.setBeginTime(new Date());
+            learnExaminee.setDuration(0L);
+            examineeMapper.insertLearnExaminee(learnExaminee);
+        }
+        return buildAnswerSheet(paper, learnExaminee);
+    }
+
     private AnswerSheet openExaminee(PaperType paperType, Long paperId, Long studentId) {
         LearnPaper paper = paperMapper.selectLearnPaperById(paperId);
 
@@ -385,7 +410,7 @@ public class ExamService {
         if(null != ts.getExamineeId()) {
             return loadExaminee(ts.getExamineeId(), true);
         }
-        AnswerSheet answerSheet = openExaminee(PaperType.Test, ts.getPaperId(), ts.getStudentId());
+        AnswerSheet answerSheet = openExamineeForTest(PaperType.Test, ts.getPaperId(), ts);
 
         LearnTestStudent uts = new LearnTestStudent();
         uts.setId(ts.getId());
@@ -412,17 +437,7 @@ public class ExamService {
         for(LearnExaminee e : examineeList) {
             if(ExamineeStatus.Sign.getVal().equals(e.getState())) {
                 LearnPaper learnPaper = paperMapper.selectLearnPaperById(e.getPaperId());
-                AnswerSheet answerSheet = buildAnswerSheet(learnPaper, e);
-                if(null != e.getPaperInfo()) {
-                    JSONObject info = JSONObject.parseObject(e.getPaperInfo());
-                    answerSheet.setCollegeId(info.getLong("universityId"));
-                    answerSheet.setCollegeName(info.getString("universityName"));
-                    answerSheet.setMajorId(info.getLong("planId"));
-                    answerSheet.setMajorName(info.getString("majorName"));
-                    answerSheet.setSubjectId(learnPaper.getSubjectId());
-                    answerSheet.setSubjectName(dzSubjectService.selectDzSubjectBySubjectId(learnPaper.getSubjectId()).getSubjectName());
-                }
-                return answerSheet;
+                return buildAnswerSheet(learnPaper, e);
             }
             existPaperIdSet.add(e.getPaperId());
         }
@@ -443,12 +458,7 @@ public class ExamService {
         upUser.setEvalCounts(evalCountObj.toJSONString());
         sysUserService.updateUserProfile(upUser);
 
-        JSONObject info = new JSONObject();
-        info.put("universityId", ls.getUniversityId());
-        info.put("universityName", plan.getUniversityName());
-        info.put("planId", ls.getMajorPlanId());
-        info.put("majorName", plan.getMajorName());
-        examinee.setPaperInfo(info.toJSONString());
+        examinee.setPaperInfo(buildPaperInfo(ls, plan));
         examineeMapper.insertLearnExaminee(examinee);
         AnswerSheet answerSheet = buildAnswerSheet(paper, examinee);
 
@@ -462,6 +472,14 @@ public class ExamService {
 
     }
 
+    private String buildPaperInfo(LearnStudent ls, AMarjorPlan plan) {
+        JSONObject info = new JSONObject();
+        info.put("universityId", ls.getUniversityId());
+        info.put("universityName", plan.getUniversityName());
+        info.put("planId", ls.getMajorPlanId());
+        info.put("majorName", plan.getMajorName());
+        return info.toJSONString();
+    }
 
     private AnswerSheet openExamineeForCourse(Long knowledgeId, Long studentId, Boolean directed) {
         LearnKnowledgeCourse kc = learnKnowledgeCourseMapper.selectLearnKnowledgeCourseById(knowledgeId);
@@ -650,6 +668,16 @@ public class ExamService {
         answerSheet.setState(examinee.getState());
         answerSheet.setAllowAnswer(true);
         answerSheet.setAllowScore(false);
+
+        if(null != examinee.getPaperInfo()) {
+            JSONObject info = JSONObject.parseObject(examinee.getPaperInfo());
+            answerSheet.setCollegeId(info.getLong("universityId"));
+            answerSheet.setCollegeName(info.getString("universityName"));
+            answerSheet.setMajorId(info.getLong("planId"));
+            answerSheet.setMajorName(info.getString("majorName"));
+            answerSheet.setSubjectId(paper.getSubjectId());
+            answerSheet.setSubjectName(dzSubjectService.selectDzSubjectBySubjectId(paper.getSubjectId()).getSubjectName());
+        }
         return answerSheet;
     }
 }

+ 1 - 1
ie-system/src/main/resources/mapper/learn/LearnTestStudentMapper.xml

@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         , ts.create_time publishTime, u.`nick_name` publishUser,  p.`direct_key` directKey, us.`name` universityName, sr.`name` schoolName, sc.`name` campusName, mp.`majorName`, ts.`class_id` classId
         FROM `learn_test_student` ts
         JOIN `learn_paper` p ON ts.`paper_id` = p.`id`
-        LEFT JOIN `learn_examinee` e ON ts.`examinee_id` = e.`examinee_id` AND ts.`student_id` = 34
+        LEFT JOIN `learn_examinee` e ON ts.`examinee_id` = e.`examinee_id` AND ts.`student_id` = #{studentId}
         LEFT JOIN sys_user u ON ts.`creator_id` = u.`user_id`
         LEFT JOIN `dz_school` sr ON ts.`school_id` = sr.`id`
         LEFT JOIN `dz_school` sc ON ts.`campus_id` = sc.`id`