Pārlūkot izejas kodu

教师app作业报告

tags/正式版本
王宁 pirms 2 gadiem
vecāks
revīzija
d37af6eb91

+ 13
- 6
sstudy/src/main/java/com/xhkjedu/sstudy/controller/paper/PaperTeaAppController.java Parādīt failu

@@ -13,6 +13,7 @@ import com.xhkjedu.vo.ResultVo;
13 13
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
14 14
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
15 15
 import com.xhkjedu.sstudy.vo.paper.*;
16
+import lombok.extern.slf4j.Slf4j;
16 17
 import org.springframework.web.bind.annotation.PostMapping;
17 18
 import org.springframework.web.bind.annotation.RequestBody;
18 19
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -28,6 +29,7 @@ import java.util.Map;
28 29
  * @description 
29 30
  * @date 2020/10/12 15:08
30 31
  **/
32
+@Slf4j
31 33
 @RestController
32 34
 @RequestMapping("/paper_teacher")
33 35
 public class PaperTeaAppController {
@@ -84,14 +86,19 @@ public class PaperTeaAppController {
84 86
         return new ResultVo(0,"获取已提交学生列表成功",list);
85 87
     }
86 88
 
87
-    //
89
+    //学生报告中-学生答题卡
88 90
     @PostMapping("/student_scantron")
89 91
     public ResultVo studentScantron(@RequestBody PStudentVo paper) {
90
-        Integer psid = paper.getPsid();
91
-        Integer papertype = paper.getPapertype();
92
-        N_Utils.validation(new Object[]{psid,"作业学生id",1,papertype,"作业类型",1});
93
-        PStudentVo scantron = paperTeaAppService.getStudentScantron(paper);
94
-        return new ResultVo(0,"获取学生答题卡成功",scantron);
92
+        try {
93
+            Integer psid = paper.getPsid();
94
+            Integer papertype = paper.getPapertype();
95
+            N_Utils.validation(new Object[]{psid,"作业学生id",1,papertype,"作业类型",1});
96
+            Map map = paperTeaAppService.getStudentScantron(paper);
97
+            return new ResultVo(0,"获取学生答题卡成功",map);
98
+        }catch (Exception e){
99
+            log.error("获取学生答题卡出错:"+e.getMessage());
100
+            return new ResultVo(1,"获取学生答题卡失败");
101
+        }
95 102
     }
96 103
 
97 104
     @PostMapping("/student_question")

+ 3
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/paper/PaperTeaAppMapper.java Parādīt failu

@@ -3,12 +3,13 @@ package com.xhkjedu.sstudy.mapper.paper;
3 3
 import com.xhkjedu.sstudy.base.TkMapper;
4 4
 import com.xhkjedu.sstudy.model.paper.TPaper;
5 5
 import com.xhkjedu.sstudy.model.question.TQuestionClass;
6
+import com.xhkjedu.sstudy.vo.paper.*;
6 7
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
7 8
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
8
-import com.xhkjedu.sstudy.vo.paper.*;
9 9
 import org.apache.ibatis.annotations.Param;
10 10
 
11 11
 import java.util.List;
12
+import java.util.Map;
12 13
 
13 14
 /**
14 15
  * @author ywx
@@ -69,7 +70,7 @@ public interface PaperTeaAppMapper extends TkMapper<TPaper> {
69 70
      * @Date 2020/10/14 16:05
70 71
      * @return com.xhkjedu.vo.teacherapp.PStudentVo
71 72
      **/
72
-    PStudentVo getStudentScantron(@Param("paper") PStudentVo paper);
73
+    Map getStudentScantron(@Param("paper") PStudentVo paper);
73 74
 
74 75
     /**
75 76
      * 学生答题卡单题详情

+ 34
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/service/paper/PaperTeaAppService.java Parādīt failu

@@ -144,8 +144,40 @@ public class PaperTeaAppService {
144 144
      * @Date 2020/10/14 16:04
145 145
      * @return com.xhkjedu.vo.teacherapp.PStudentVo
146 146
      **/
147
-    public PStudentVo getStudentScantron(PStudentVo paper) {
148
-        return paperTeaAppMapper.getStudentScantron(paper);
147
+    public Map getStudentScantron(PStudentVo paper){
148
+        Map map = paperTeaAppMapper.getStudentScantron(paper);
149
+        Integer papertype = Integer.parseInt(map.get("papertype").toString());
150
+        if(papertype == 1){
151
+            List<Map> questions = (List<Map>) map.get("questions");
152
+            List<String> qids = new ArrayList<>();
153
+            List<Map> rtnques = new ArrayList<>();
154
+            for(Map q : questions){
155
+                Integer qlevel = Integer.parseInt(q.get("qlevel").toString());
156
+                if(qlevel == 1){
157
+                    q.remove("questionpid");
158
+                    q.remove("ctype");
159
+                    q.remove("qscore");
160
+                    q.remove("stuscore");
161
+                    rtnques.add(q);
162
+                }else{
163
+                    String questionpid = q.get("questionpid").toString();
164
+                    if(!qids.contains(questionpid)){
165
+                        qids.add(questionpid);
166
+                        List<Map> sonqmap = questions.stream().filter(s -> qlevel.equals(Integer.parseInt(s.get("qlevel").toString())) && questionpid.equals(s.get("questionpid").toString())).collect(Collectors.toList());
167
+                        Double stuscore = sonqmap.stream().mapToDouble(s -> Double.parseDouble(s.get("stuscore").toString())).sum();
168
+                        Double qscore = sonqmap.stream().mapToDouble(s -> Double.parseDouble(s.get("qscore").toString())).sum();
169
+                        Double correctrate = N_Utils.getDoubleDivideAndMulitiply(stuscore,qscore);
170
+                        Map mqmap = new TreeMap();
171
+                        mqmap.put("qorder",sonqmap.get(0).get("qorder"));
172
+                        mqmap.put("correctrate",correctrate);
173
+                        mqmap.put("questionid",questionpid);
174
+                        rtnques.add(mqmap);
175
+                    }
176
+                }
177
+            }
178
+            map.put("questions",rtnques);
179
+        }
180
+        return map;
149 181
     }
150 182
 
151 183
     /**

+ 11
- 4
sstudy/src/main/resources/mapper/paper/PaperTeaAppMapper.xml Parādīt failu

@@ -107,7 +107,7 @@
107 107
         order by ps.pschecked,ps.userscore ${paper.fieldorder},convert(u.username using gbk)
108 108
     </select>
109 109
     <!--获取学生答题卡-->
110
-    <resultMap id="scantronResult" type="com.xhkjedu.sstudy.vo.paper.PStudentVo">
110
+    <resultMap id="scantronResult" type="java.util.Map">
111 111
         <result property="papername" column="papername"></result>
112 112
         <result property="papernum" column="papernum"></result>
113 113
         <result property="scorerate" column="scorerate"></result>
@@ -118,18 +118,25 @@
118 118
         <result property="rank" column="rank"></result>
119 119
         <result property="paperscore" column="paperscore"></result>
120 120
         <result property="userscore" column="userscore"></result>
121
-        <collection property="questions" ofType="com.xhkjedu.sstudy.vo.paper.PaperTeacherReportVo">
121
+        <collection property="questions" ofType="java.util.Map" javaType="java.util.List">
122 122
             <result property="qorder" column="qorder"></result>
123 123
             <result property="qn" column="qn"></result>
124 124
             <result property="correctrate" column="correctrate"></result>
125
-            <result property="ctype" column="ctype"></result>
125
+            <result property="stuscore" column="stuscore"></result>
126
+            <result property="qscore" column="qscore"></result>
127
+            <result property="qlevel" column="qlevel"></result>
128
+            <result property="questionid" column="questionid"></result>
129
+            <result property="questionpid" column="questionpid"></result>
126 130
         </collection>
127 131
     </resultMap>
128 132
     <select id="getStudentScantron" resultMap="scantronResult">
129 133
         select p.papername,ps.papernum,truncate(ps.userscore*100/ps.paperscore,2)scorerate,#{paper.papertype} papertype
130
-        ,ps.psid,ps.stoptime,ps.costtime,q.qorder,q.qn,truncate(q.stuscore*100/q.qscore,2)correctrate,tq.ctype
134
+        ,ps.psid,ps.stoptime,ps.costtime,q.qorder,q.qn,truncate(q.stuscore*100/q.qscore,2)correctrate,q.stuscore,q.qscore
131 135
         ,(select count(*)+1 from t_paper_student ps1
132 136
         where ps1.paperid=ps.paperid and ps1.userscore>ps.userscore)rank,ps.paperscore,ps.userscore
137
+        <if test="paper.papertype==1 or paper.papertype==3">
138
+            ,tq.qlevel,tq.questionid,tq.questionpid
139
+        </if>
133 140
         from t_paper_student ps left join t_paper p on ps.paperid = p.paperid
134 141
         <if test="paper.papertype==1 or paper.papertype==3">
135 142
             left join t_paper_student_question q on ps.psid=q.psid

Notiek ielāde…
Atcelt
Saglabāt