Browse Source

教师app作业报告

tags/正式版本
王宁 2 years ago
parent
commit
d37af6eb91

+ 13
- 6
sstudy/src/main/java/com/xhkjedu/sstudy/controller/paper/PaperTeaAppController.java View File

13
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
13
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
14
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
14
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
15
 import com.xhkjedu.sstudy.vo.paper.*;
15
 import com.xhkjedu.sstudy.vo.paper.*;
16
+import lombok.extern.slf4j.Slf4j;
16
 import org.springframework.web.bind.annotation.PostMapping;
17
 import org.springframework.web.bind.annotation.PostMapping;
17
 import org.springframework.web.bind.annotation.RequestBody;
18
 import org.springframework.web.bind.annotation.RequestBody;
18
 import org.springframework.web.bind.annotation.RequestMapping;
19
 import org.springframework.web.bind.annotation.RequestMapping;
28
  * @description 
29
  * @description 
29
  * @date 2020/10/12 15:08
30
  * @date 2020/10/12 15:08
30
  **/
31
  **/
32
+@Slf4j
31
 @RestController
33
 @RestController
32
 @RequestMapping("/paper_teacher")
34
 @RequestMapping("/paper_teacher")
33
 public class PaperTeaAppController {
35
 public class PaperTeaAppController {
84
         return new ResultVo(0,"获取已提交学生列表成功",list);
86
         return new ResultVo(0,"获取已提交学生列表成功",list);
85
     }
87
     }
86
 
88
 
87
-    //
89
+    //学生报告中-学生答题卡
88
     @PostMapping("/student_scantron")
90
     @PostMapping("/student_scantron")
89
     public ResultVo studentScantron(@RequestBody PStudentVo paper) {
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
     @PostMapping("/student_question")
104
     @PostMapping("/student_question")

+ 3
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/paper/PaperTeaAppMapper.java View File

3
 import com.xhkjedu.sstudy.base.TkMapper;
3
 import com.xhkjedu.sstudy.base.TkMapper;
4
 import com.xhkjedu.sstudy.model.paper.TPaper;
4
 import com.xhkjedu.sstudy.model.paper.TPaper;
5
 import com.xhkjedu.sstudy.model.question.TQuestionClass;
5
 import com.xhkjedu.sstudy.model.question.TQuestionClass;
6
+import com.xhkjedu.sstudy.vo.paper.*;
6
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
7
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
7
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
8
 import com.xhkjedu.sstudy.vo.paperstudent.PaperStudentQuestionVo;
8
-import com.xhkjedu.sstudy.vo.paper.*;
9
 import org.apache.ibatis.annotations.Param;
9
 import org.apache.ibatis.annotations.Param;
10
 
10
 
11
 import java.util.List;
11
 import java.util.List;
12
+import java.util.Map;
12
 
13
 
13
 /**
14
 /**
14
  * @author ywx
15
  * @author ywx
69
      * @Date 2020/10/14 16:05
70
      * @Date 2020/10/14 16:05
70
      * @return com.xhkjedu.vo.teacherapp.PStudentVo
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 View File

144
      * @Date 2020/10/14 16:04
144
      * @Date 2020/10/14 16:04
145
      * @return com.xhkjedu.vo.teacherapp.PStudentVo
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 View File

107
         order by ps.pschecked,ps.userscore ${paper.fieldorder},convert(u.username using gbk)
107
         order by ps.pschecked,ps.userscore ${paper.fieldorder},convert(u.username using gbk)
108
     </select>
108
     </select>
109
     <!--获取学生答题卡-->
109
     <!--获取学生答题卡-->
110
-    <resultMap id="scantronResult" type="com.xhkjedu.sstudy.vo.paper.PStudentVo">
110
+    <resultMap id="scantronResult" type="java.util.Map">
111
         <result property="papername" column="papername"></result>
111
         <result property="papername" column="papername"></result>
112
         <result property="papernum" column="papernum"></result>
112
         <result property="papernum" column="papernum"></result>
113
         <result property="scorerate" column="scorerate"></result>
113
         <result property="scorerate" column="scorerate"></result>
118
         <result property="rank" column="rank"></result>
118
         <result property="rank" column="rank"></result>
119
         <result property="paperscore" column="paperscore"></result>
119
         <result property="paperscore" column="paperscore"></result>
120
         <result property="userscore" column="userscore"></result>
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
             <result property="qorder" column="qorder"></result>
122
             <result property="qorder" column="qorder"></result>
123
             <result property="qn" column="qn"></result>
123
             <result property="qn" column="qn"></result>
124
             <result property="correctrate" column="correctrate"></result>
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
         </collection>
130
         </collection>
127
     </resultMap>
131
     </resultMap>
128
     <select id="getStudentScantron" resultMap="scantronResult">
132
     <select id="getStudentScantron" resultMap="scantronResult">
129
         select p.papername,ps.papernum,truncate(ps.userscore*100/ps.paperscore,2)scorerate,#{paper.papertype} papertype
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
         ,(select count(*)+1 from t_paper_student ps1
135
         ,(select count(*)+1 from t_paper_student ps1
132
         where ps1.paperid=ps.paperid and ps1.userscore>ps.userscore)rank,ps.paperscore,ps.userscore
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
         from t_paper_student ps left join t_paper p on ps.paperid = p.paperid
140
         from t_paper_student ps left join t_paper p on ps.paperid = p.paperid
134
         <if test="paper.papertype==1 or paper.papertype==3">
141
         <if test="paper.papertype==1 or paper.papertype==3">
135
             left join t_paper_student_question q on ps.psid=q.psid
142
             left join t_paper_student_question q on ps.psid=q.psid

Loading…
Cancel
Save