Browse Source

教师阅卷

tags/正式版本
雍文秀 2 years ago
parent
commit
53684be60a

+ 5
- 2
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperCorrectTeacherController.java View File

19
 import javax.annotation.Resource;
19
 import javax.annotation.Resource;
20
 import java.util.List;
20
 import java.util.List;
21
 import java.util.Map;
21
 import java.util.Map;
22
+import java.util.concurrent.ExecutionException;
23
+import java.util.concurrent.Future;
22
 
24
 
23
 /**
25
 /**
24
  * @author ywx
26
  * @author ywx
133
      * @Date 2022/7/28 15:30
135
      * @Date 2022/7/28 15:30
134
      **/
136
      **/
135
     @PostMapping("/correct")
137
     @PostMapping("/correct")
136
-    public ResultVo correctQuestion(@RequestBody EPaperStudentQuestion vo) {
138
+    public ResultVo correctQuestion(@RequestBody EPaperStudentQuestion vo) throws ExecutionException, InterruptedException {
137
         Integer epsid = vo.getEpsid();
139
         Integer epsid = vo.getEpsid();
138
         Integer epsqid = vo.getEpsqid();
140
         Integer epsqid = vo.getEpsqid();
139
         Integer checkid = vo.getCheckid();
141
         Integer checkid = vo.getCheckid();
140
         N_Utils.validation(new Object[]{epsid, "试卷学生id", 1, epsqid, "试卷学生试题id", 1, checkid, "批阅人", 1});
142
         N_Utils.validation(new Object[]{epsid, "试卷学生id", 1, epsqid, "试卷学生试题id", 1, checkid, "批阅人", 1});
141
-        return correctTeacherService.correctQuestion(vo);
143
+        Future<ResultVo> future = correctTeacherService.correctQuestion(vo);
144
+        return future.get();
142
     }
145
     }
143
 }
146
 }

+ 13
- 7
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperCorrectTeacherService.java View File

8
 import com.xhkjedu.vo.ResultVo;
8
 import com.xhkjedu.vo.ResultVo;
9
 import lombok.extern.slf4j.Slf4j;
9
 import lombok.extern.slf4j.Slf4j;
10
 import org.springframework.scheduling.annotation.Async;
10
 import org.springframework.scheduling.annotation.Async;
11
+import org.springframework.scheduling.annotation.AsyncResult;
11
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
12
 
13
 
13
 import javax.annotation.Resource;
14
 import javax.annotation.Resource;
14
 import java.util.HashMap;
15
 import java.util.HashMap;
15
 import java.util.List;
16
 import java.util.List;
16
 import java.util.Map;
17
 import java.util.Map;
18
+import java.util.concurrent.Future;
17
 import java.util.concurrent.locks.Lock;
19
 import java.util.concurrent.locks.Lock;
18
 import java.util.concurrent.locks.ReentrantLock;
20
 import java.util.concurrent.locks.ReentrantLock;
19
 
21
 
77
 
79
 
78
     //批阅试题
80
     //批阅试题
79
     @Async("asyncPoolTaskExecutor")
81
     @Async("asyncPoolTaskExecutor")
80
-    public ResultVo correctQuestion(EPaperStudentQuestion psq) {
81
-        correctTeacherMapper.correctQuestion(psq);
82
-        Integer epsid = psq.getEpsid();
83
-        Integer num = correctTeacherMapper.getNotCorrect(epsid);//学生未批改试题数量
84
-        if (num == 0) {//批阅完成修改学生试卷批阅状态
85
-            correctTeacherMapper.updateCheckStuById(epsid, psq.getCheckid());
82
+    public Future<ResultVo> correctQuestion(EPaperStudentQuestion psq) {
83
+        try {
84
+            correctTeacherMapper.correctQuestion(psq);
85
+            Integer epsid = psq.getEpsid();
86
+            Integer num = correctTeacherMapper.getNotCorrect(epsid);//学生未批改试题数量
87
+            if (num == 0) {//批阅完成修改学生试卷批阅状态
88
+                correctTeacherMapper.updateCheckStuById(epsid, psq.getCheckid());
89
+            }
90
+            return new AsyncResult<>(new ResultVo(0, "批阅成功"));
91
+        } catch (Exception e) {
92
+            return new AsyncResult<>(new ResultVo(1, e.getMessage()));
86
         }
93
         }
87
-        return new ResultVo(0, "批阅成功");
88
     }
94
     }
89
 }
95
 }

+ 5
- 5
sexam/src/main/resources/mapper/paper/EPaperCorrectTeacherMapper.xml View File

59
     </select>
59
     </select>
60
     <!--试题批阅情况-->
60
     <!--试题批阅情况-->
61
     <select id="getCheckQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
61
     <select id="getCheckQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
62
-        select count(psq.epsqid)tjnum,count(case when psq.checked=1 then psq.epsqid else null end)pynum
63
-        ,count(case when psq.checked=1 and psq.checkid=#{teacherid} then psq.epsqid else null end)wpynum
62
+        select count(psq.epsqid)tjnum,count(case when psq.checked=2 then psq.epsqid else null end)pynum
63
+        ,count(case when psq.checked=2 and psq.checkid=#{teacherid} then psq.epsqid else null end)wpynum
64
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder} and psq.answered=1
64
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder} and psq.answered=1
65
     </select>
65
     </select>
66
     <!--修改试卷学生试题为批阅中-->
66
     <!--修改试卷学生试题为批阅中-->
70
     <!--获取上一份批阅试题-->
70
     <!--获取上一份批阅试题-->
71
     <select id="getPreQuestion" resultType="java.util.Map">
71
     <select id="getPreQuestion" resultType="java.util.Map">
72
         select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.epsid
72
         select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.epsid
73
-        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=1 and psq.checkid=#{teacherid}
73
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=2 and psq.checkid=#{teacherid}
74
         order by psq.checktime desc limit 1
74
         order by psq.checktime desc limit 1
75
     </select>
75
     </select>
76
     <!--阅卷记录-->
76
     <!--阅卷记录-->
77
     <select id="listRecord" resultType="java.util.Map">
77
     <select id="listRecord" resultType="java.util.Map">
78
         select psq.epsqid,psq.stuanswer,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.checktime
78
         select psq.epsqid,psq.stuanswer,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.checktime
79
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder}
79
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder}
80
-        and psq.checked=1 and psq.checkid=#{teacherid}
80
+        and psq.checked=2 and psq.checkid=#{teacherid}
81
         order by psq.checktime desc
81
         order by psq.checktime desc
82
     </select>
82
     </select>
83
     <!--批阅试题-->
83
     <!--批阅试题-->
84
     <update id="correctQuestion">
84
     <update id="correctQuestion">
85
         update e_paper_student_question
85
         update e_paper_student_question
86
-        set stuscore=#{psq.stuscore},checked=1
86
+        set stuscore=#{psq.stuscore},checked=2
87
         ,checkid=#{psq.checkid},checktime=unix_timestamp()
87
         ,checkid=#{psq.checkid},checktime=unix_timestamp()
88
         ,good=#{psq.good},bad=#{psq.bad}
88
         ,good=#{psq.good},bad=#{psq.bad}
89
         <if test="psq.stuanswer!=null and psq.stuanswer!=''">
89
         <if test="psq.stuanswer!=null and psq.stuanswer!=''">

Loading…
Cancel
Save