|
@@ -31,6 +31,7 @@ import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
|
31
|
31
|
import com.xhkjedu.smarking.vo.report.reportsubject.SectionScoreVo;
|
32
|
32
|
import com.xhkjedu.utils.N_Utils;
|
33
|
33
|
import org.springframework.stereotype.Service;
|
|
34
|
+import org.springframework.transaction.annotation.Transactional;
|
34
|
35
|
|
35
|
36
|
import javax.annotation.Resource;
|
36
|
37
|
import java.util.*;
|
|
@@ -70,6 +71,7 @@ public class ReportGenerateQuestionService {
|
70
|
71
|
@Resource
|
71
|
72
|
private ReportGeneratePointService reportGeneratePointService;
|
72
|
73
|
|
|
74
|
+ @Transactional(rollbackFor = Exception.class)
|
73
|
75
|
public void generateQuestion(Integer examid, Integer exammode) {
|
74
|
76
|
// 查询所有学生试题
|
75
|
77
|
List<MsPaperStudentQuestion> stuQuestions = msPaperStudentQuestionMapper.listAllStuQuesByExamid(examid);
|
|
@@ -79,6 +81,8 @@ public class ReportGenerateQuestionService {
|
79
|
81
|
// 获取考试参数
|
80
|
82
|
List<MsrReportparam> params = msrReportparamMapper.listReportparamByRpbelong(examid, "quesummary", null);
|
81
|
83
|
|
|
84
|
+ msrClassQuestionMapper.deleteReportByExamid(examid);//清除数据
|
|
85
|
+
|
82
|
86
|
// 根据科目进行区分
|
83
|
87
|
for (MsPaper subject : subjects) {
|
84
|
88
|
String subjectid = subject.getSubjectid();
|
|
@@ -94,6 +98,8 @@ public class ReportGenerateQuestionService {
|
94
|
98
|
// 获取学生科目得分及排名
|
95
|
99
|
List<MsrStudent> subjectStuPapers = stuPapers.stream().filter(p -> p.getSubjectid().equals(subjectid)).collect(Collectors.toList());
|
96
|
100
|
|
|
101
|
+ // 处理学生客观题、主观题得分
|
|
102
|
+ handleStudentObjSub(subjectStuQuestions, subjectStuPapers, questions);
|
97
|
103
|
// 处理小题
|
98
|
104
|
handleQuestion(subjectStuQuestions, subjectClassStudents, questions, subjectParams, subjectStuPapers, examid, subjectid,subject.getPscore());
|
99
|
105
|
//处理题型
|
|
@@ -101,8 +107,36 @@ public class ReportGenerateQuestionService {
|
101
|
107
|
//客观题、主观题
|
102
|
108
|
handleObjSub(subjectStuQuestions, subjectClassStudents, questions, subjectStuPapers, examid, subjectid,subject.getPscore());
|
103
|
109
|
//知识点相关分析
|
104
|
|
- reportGeneratePointService.generatePoint(subjectStuQuestions,questions,classStudents,stuPapers,examid,subjectid,subject.getMpid(),subject.getPscore());
|
|
110
|
+ reportGeneratePointService.generatePoint(subjectStuQuestions,questions,classStudents,subjectStuPapers,examid,subjectid,subject.getMpid(),subject.getPscore());
|
|
111
|
+ }
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ //学生客观题、主观题得分
|
|
115
|
+ private void handleStudentObjSub(List<MsPaperStudentQuestion> subjectStuQuestions, List<MsrStudent> stus, List<MsPaperQtypeQuestion> questions){
|
|
116
|
+ //获取试卷中所有主观题、客观题
|
|
117
|
+ List<Integer> objMptqids = questions.stream().filter(q -> q.getQtype()==1).map(MsPaperQtypeQuestion::getMptqid).distinct().collect(Collectors.toList());
|
|
118
|
+ List<Integer> subMptqids = questions.stream().filter(q -> q.getQtype()==2).map(MsPaperQtypeQuestion::getMptqid).distinct().collect(Collectors.toList());
|
|
119
|
+ //学生试题按学生分组
|
|
120
|
+ Map<Integer,List<MsPaperStudentQuestion>> stuQuestionMap = subjectStuQuestions.stream().collect(Collectors.groupingBy(MsPaperStudentQuestion::getStudentid));
|
|
121
|
+
|
|
122
|
+ for(MsrStudent stu:stus){
|
|
123
|
+ Integer studentid = stu.getStudentid();
|
|
124
|
+ if(stuQuestionMap.containsKey(studentid)){
|
|
125
|
+ List<MsPaperStudentQuestion> stuQuestions = stuQuestionMap.get(studentid);
|
|
126
|
+ List<MsPaperStudentQuestion> objStuQues = stuQuestions.stream().filter(q -> objMptqids.contains(q.getMptqid())).collect(Collectors.toList());
|
|
127
|
+ List<MsPaperStudentQuestion> subStuQues = stuQuestions.stream().filter(q -> subMptqids.contains(q.getMptqid())).collect(Collectors.toList());
|
|
128
|
+ //学生客观题得分
|
|
129
|
+ double objScore = objStuQues.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
|
130
|
+ //学生主观题得分
|
|
131
|
+ double subScore = subStuQues.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
|
132
|
+ stu.setObjscore(N_Utils.formatDouble(objScore,1));
|
|
133
|
+ stu.setSubscore(N_Utils.formatDouble(subScore,1));
|
|
134
|
+ }else{
|
|
135
|
+ stu.setObjscore(0.0);
|
|
136
|
+ stu.setSubscore(0.0);
|
|
137
|
+ }
|
105
|
138
|
}
|
|
139
|
+ msrStudentMapper.updateBatchObjSubScore(stus);
|
106
|
140
|
}
|
107
|
141
|
|
108
|
142
|
// 单个试题分析
|
|
@@ -139,6 +173,7 @@ public class ReportGenerateQuestionService {
|
139
|
173
|
schoolQ.setSchoolavgscore(avgScore);
|
140
|
174
|
schoolQ.setSchoolavgrate(avgScoreRate);
|
141
|
175
|
schoolQ.setMptqid(question.getMptqid());
|
|
176
|
+ schoolQ.setZqda(question.getQanswer());
|
142
|
177
|
schoolQ.setQn(question.getMptqn() + "." + question.getQn());
|
143
|
178
|
// 全校班级试题情况
|
144
|
179
|
MsrClassQuestion schoolQue = questionClass(stuQuestions, question, params, schoolQ);
|
|
@@ -238,7 +273,7 @@ public class ReportGenerateQuestionService {
|
238
|
273
|
|
239
|
274
|
classQ.setScorerate(stuScoreRate);
|
240
|
275
|
classQ.setScoreratec(MarkingUtil.sub(MarkingUtil.calculateRate(maxScore, qScore), MarkingUtil.calculateRate(minScore, qScore)));// 得分率差=最高得分率-最低得分率
|
241
|
|
- classQ.setNd(MarkingUtil.div(stuScoreRate, qScore));// 难度
|
|
276
|
+ classQ.setNd(MarkingUtil.div(avgScore, qScore));// 难度
|
242
|
277
|
String[] ndStr = questionNdAndQfd(params, 1, classQ.getNd());
|
243
|
278
|
classQ.setNdms(ndStr[0]);// 难度描述
|
244
|
279
|
classQ.setNdfw(ndStr[1]);// 难度范围
|
|
@@ -248,19 +283,32 @@ public class ReportGenerateQuestionService {
|
248
|
283
|
classQ.setQfdfw(qfdStr[1]);// 区分度范围
|
249
|
284
|
classQ.setBzc(MarkingUtil.bzc(stuScores));// 标准差
|
250
|
285
|
classQ.setCyxs(MarkingUtil.div(classQ.getBzc(), avgScore));// 差异系数
|
251
|
|
- classQ.setJbzs(MarkingUtil.jbzs(stuScores, stuScoreRate));// 鉴别指数
|
|
286
|
+ classQ.setJbzs(MarkingUtil.jbzs(stuScores, question.getQscore()));// 鉴别指数
|
|
287
|
+ classQ.setZqda(schoolQ.getZqda());
|
252
|
288
|
// 获取所有满分学生
|
253
|
289
|
List<MsPaperStudentQuestion> fullStuQuestions = stuQuestions.stream().filter(q -> q.getStuscore().equals(q.getQscore())).collect(Collectors.toList());
|
254
|
|
- String mfids = fullStuQuestions.stream().map(p -> p.getStudentid().toString()).collect(Collectors.joining(","));// 满分学生id
|
255
|
|
- classQ.setMfnum(fullStuQuestions.size());
|
256
|
|
- classQ.setMfrate(MarkingUtil.calculateRate(classQ.getMfnum(), stunum));////正确率、满分人数占比
|
257
|
|
- classQ.setMfids(mfids);
|
|
290
|
+ if(!fullStuQuestions.isEmpty()){
|
|
291
|
+ String mfids = fullStuQuestions.stream().map(p -> p.getStudentid().toString()).collect(Collectors.joining(","));// 满分学生id
|
|
292
|
+ classQ.setMfnum(fullStuQuestions.size());
|
|
293
|
+ classQ.setMfrate(MarkingUtil.calculateRate(classQ.getMfnum(), stunum));////正确率、满分人数占比
|
|
294
|
+ classQ.setMfids(mfids);
|
|
295
|
+ }else{
|
|
296
|
+ classQ.setMfnum(0);
|
|
297
|
+ classQ.setMfrate(0.0);////正确率、满分人数占比
|
|
298
|
+ }
|
|
299
|
+ classQ.setZqrate(classQ.getMfrate());
|
|
300
|
+
|
258
|
301
|
// 获取零分学生
|
259
|
302
|
List<MsPaperStudentQuestion> lfStuQuestions = stuQuestions.stream().filter(q -> q.getStuscore() == 0).collect(Collectors.toList());
|
260
|
|
- String lfids = lfStuQuestions.stream().map(p -> p.getStudentid().toString()).collect(Collectors.joining(","));// 零分学生id
|
261
|
|
- classQ.setLfnum(lfStuQuestions.size());
|
262
|
|
- classQ.setLfrate(MarkingUtil.calculateRate(lfStuQuestions.size(), stunum));////零分人数占比
|
263
|
|
- classQ.setLfids(lfids);
|
|
303
|
+ if (!lfStuQuestions.isEmpty()) {
|
|
304
|
+ String lfids = lfStuQuestions.stream().map(p -> p.getStudentid().toString()).collect(Collectors.joining(","));// 零分学生id
|
|
305
|
+ classQ.setLfnum(lfStuQuestions.size());
|
|
306
|
+ classQ.setLfrate(MarkingUtil.calculateRate(lfStuQuestions.size(), stunum));////零分人数占比
|
|
307
|
+ classQ.setLfids(lfids);
|
|
308
|
+ } else {
|
|
309
|
+ classQ.setLfnum(0);
|
|
310
|
+ classQ.setLfrate(0.0);////零分人数占比
|
|
311
|
+ }
|
264
|
312
|
return classQ;
|
265
|
313
|
}
|
266
|
314
|
|
|
@@ -397,12 +445,18 @@ public class ReportGenerateQuestionService {
|
397
|
445
|
}else{
|
398
|
446
|
sectionStuQuestions = groupStuQuestions.stream().filter(q -> q.getStuscore() >= sectionScore.getMinvalue() && q.getStuscore() < sectionScore.getMaxvalue()).collect(Collectors.toList());
|
399
|
447
|
}
|
400
|
|
- double sectionStuSumScore = sectionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
401
|
|
- double sectionStuAvgScore = MarkingUtil.div(sectionStuSumScore, sectionStuQuestions.size());
|
402
|
|
- sqrg.setStunum(sectionStuQuestions.size());
|
403
|
|
- sqrg.setStuids(sectionStuQuestions.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
|
404
|
|
- sqrg.setScorerate(MarkingUtil.calculateRate(sectionStuSumScore, sectionStuQuestions.size() * fullScore));
|
405
|
|
- sqrg.setAvgrate(MarkingUtil.calculateRate(sectionStuAvgScore, fullScore));
|
|
448
|
+ if(!sectionStuQuestions.isEmpty()){
|
|
449
|
+ double sectionStuSumScore = sectionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
|
450
|
+ double sectionStuAvgScore = MarkingUtil.div(sectionStuSumScore, sectionStuQuestions.size());
|
|
451
|
+ sqrg.setStunum(sectionStuQuestions.size());
|
|
452
|
+ sqrg.setStuids(sectionStuQuestions.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
453
|
+ sqrg.setScorerate(MarkingUtil.calculateRate(sectionStuSumScore, sectionStuQuestions.size() * fullScore));
|
|
454
|
+ sqrg.setAvgrate(MarkingUtil.calculateRate(sectionStuAvgScore, fullScore));
|
|
455
|
+ }else{
|
|
456
|
+ sqrg.setStunum(0);
|
|
457
|
+ sqrg.setScorerate(0.0);
|
|
458
|
+ sqrg.setAvgrate(0.0);
|
|
459
|
+ }
|
406
|
460
|
}else{
|
407
|
461
|
sqrg.setStunum(0);
|
408
|
462
|
sqrg.setScorerate(0.0);
|
|
@@ -419,10 +473,10 @@ public class ReportGenerateQuestionService {
|
419
|
473
|
}
|
420
|
474
|
List<String> newOptions = options.stream().map(s -> s != null && !s.isEmpty() ? s : "未作答").sorted().collect(Collectors.toList());
|
421
|
475
|
for(String optionStr : newOptions){
|
422
|
|
-
|
423
|
476
|
MsrSubjectQuestionRankgroup optionObj = new MsrSubjectQuestionRankgroup();
|
424
|
477
|
optionObj.setExamid(examid);
|
425
|
478
|
optionObj.setSubjectid(subjectid);
|
|
479
|
+ optionObj.setMptqid(mptqid);
|
426
|
480
|
optionObj.setQntype(1);
|
427
|
481
|
optionObj.setRgroup(rankGroup.getGroupname());
|
428
|
482
|
optionObj.setRgtype(1);
|
|
@@ -436,13 +490,20 @@ public class ReportGenerateQuestionService {
|
436
|
490
|
optionStuQuestions = groupStuQuestions.stream().filter(q -> optionStr.equals(q.getStuanswer())).collect(Collectors.toList());
|
437
|
491
|
}
|
438
|
492
|
|
439
|
|
- double optionStuSumScore = optionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
440
|
|
- double optionStuAvgScore = MarkingUtil.div(optionStuSumScore, optionStuQuestions.size());
|
|
493
|
+ if(!optionStuQuestions.isEmpty()){
|
|
494
|
+ double optionStuSumScore = optionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
|
495
|
+ double optionStuAvgScore = MarkingUtil.div(optionStuSumScore, optionStuQuestions.size());
|
|
496
|
+
|
|
497
|
+ optionObj.setStunum(optionStuQuestions.size());
|
|
498
|
+ optionObj.setStuids(optionStuQuestions.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
499
|
+ optionObj.setScorerate(MarkingUtil.calculateRate(optionStuSumScore, optionStuQuestions.size() * fullScore));
|
|
500
|
+ optionObj.setAvgrate(MarkingUtil.calculateRate(optionStuAvgScore, fullScore));
|
|
501
|
+ }else{
|
|
502
|
+ optionObj.setStunum(0);
|
|
503
|
+ optionObj.setScorerate(0.0);
|
|
504
|
+ optionObj.setAvgrate(0.0);
|
|
505
|
+ }
|
441
|
506
|
|
442
|
|
- optionObj.setStunum(optionStuQuestions.size());
|
443
|
|
- optionObj.setStuids(optionStuQuestions.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
|
444
|
|
- optionObj.setScorerate(MarkingUtil.calculateRate(optionStuSumScore, optionStuQuestions.size() * fullScore));
|
445
|
|
- optionObj.setAvgrate(MarkingUtil.calculateRate(optionStuAvgScore, fullScore));
|
446
|
507
|
}else{
|
447
|
508
|
optionObj.setStunum(0);
|
448
|
509
|
optionObj.setScorerate(0.0);
|
|
@@ -491,22 +552,36 @@ public class ReportGenerateQuestionService {
|
491
|
552
|
String[] userids = section.getFdids().split(",");
|
492
|
553
|
List<String> useridList = Arrays.asList(userids);
|
493
|
554
|
List<MsPaperStudentQuestion> sectionStuQuestions = stuQuestions.stream().filter(q -> useridList.contains(q.getStudentid().toString())).collect(Collectors.toList());
|
|
555
|
+
|
|
556
|
+ MsrSubjectQuestionSection sqs = new MsrSubjectQuestionSection();
|
|
557
|
+ sqs.setExamid(section.getExamid());
|
|
558
|
+ sqs.setSubjectid(section.getSubjectid());
|
|
559
|
+ sqs.setMptqid(mptqid);
|
|
560
|
+ sqs.setFdfw(section.getFdfw());
|
|
561
|
+ sqs.setFdnum(section.getFdnum());
|
|
562
|
+ sqs.setFdids(section.getFdids());
|
494
|
563
|
// 获取总分
|
495
|
|
- double sumScore = sectionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
496
|
|
- int stuNum = sectionStuQuestions.size();
|
497
|
|
- // 获取平均分
|
498
|
|
- double avgScore = MarkingUtil.div(sumScore, stuNum);
|
499
|
|
- // 获取平均得分率
|
500
|
|
- double avgScoreRate = MarkingUtil.calculateRate(avgScore, fullScore);
|
501
|
|
- section.setAvgscore(avgScore);
|
502
|
|
- section.setAvgrate(avgScoreRate);
|
|
564
|
+ if(!sectionStuQuestions.isEmpty()){
|
|
565
|
+ int stuNum = sectionStuQuestions.size();
|
|
566
|
+ // 获取总分
|
|
567
|
+ double sumScore = sectionStuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();
|
|
568
|
+ // 获取平均分
|
|
569
|
+ double avgScore = MarkingUtil.div(sumScore, stuNum);
|
|
570
|
+ // 获取平均得分率
|
|
571
|
+ double avgScoreRate = MarkingUtil.calculateRate(avgScore, fullScore);
|
|
572
|
+ sqs.setAvgscore(avgScore);
|
|
573
|
+ sqs.setAvgrate(avgScoreRate);
|
|
574
|
+ }else{
|
|
575
|
+ sqs.setAvgscore(0.0);
|
|
576
|
+ sqs.setAvgrate(0.0);
|
|
577
|
+ }
|
|
578
|
+
|
503
|
579
|
if(qtype == 1){
|
504
|
|
- section.setQntype(qtype);//类型1小题2客观题3主观题
|
|
580
|
+ sqs.setQntype(qtype);//类型1小题2客观题3主观题
|
505
|
581
|
}else{
|
506
|
|
- section.setQntype(qtype+1);
|
|
582
|
+ sqs.setQntype(qtype+1);
|
507
|
583
|
}
|
508
|
|
- section.setMptqid(mptqid);
|
509
|
|
- rtnList.add(section);
|
|
584
|
+ rtnList.add(sqs);
|
510
|
585
|
}
|
511
|
586
|
return rtnList;
|
512
|
587
|
}
|
|
@@ -592,9 +667,9 @@ public class ReportGenerateQuestionService {
|
592
|
667
|
classQtype.setAvgscore(avgScore);
|
593
|
668
|
classQtype.setBzc(MarkingUtil.bzc(stuScores));
|
594
|
669
|
classQtype.setNd(MarkingUtil.div(avgScore, schoolQtype.getFullscore()));
|
595
|
|
- classQtype.setNdms(questionNdAndQfd(params, 1, schoolQtype.getNd())[0]);
|
|
670
|
+ classQtype.setNdms(questionNdAndQfd(params, 1, classQtype.getNd())[0]);
|
596
|
671
|
classQtype.setQfd(MarkingUtil.qfd(stuScores));
|
597
|
|
- classQtype.setQfdms(questionNdAndQfd(params, 2, schoolQtype.getQfd())[0]);
|
|
672
|
+ classQtype.setQfdms(questionNdAndQfd(params, 2, classQtype.getQfd())[0]);
|
598
|
673
|
classQtype.setMfnum(mfnum);
|
599
|
674
|
classQtype.setMfrate(MarkingUtil.calculateRate(mfnum, stuNum));
|
600
|
675
|
if(mfnum > 0){
|
|
@@ -644,8 +719,7 @@ public class ReportGenerateQuestionService {
|
644
|
719
|
List<MsrSubjectQuestionSection> sectionQuestions = subjectSectionQuestion(stuQuestions, subjectSectionQuestions,entry.getKey(), fullScore,null);
|
645
|
720
|
saveSectionQuestions.addAll(sectionQuestions);
|
646
|
721
|
|
647
|
|
-
|
648
|
|
- Integer qobjsubtype;//为了区分表中存放值
|
|
722
|
+ int qobjsubtype;//为了区分表中存放值
|
649
|
723
|
if(entry.getKey() == 1){
|
650
|
724
|
qobjsubtype = 11;
|
651
|
725
|
}else{
|
|
@@ -700,12 +774,12 @@ public class ReportGenerateQuestionService {
|
700
|
774
|
|
701
|
775
|
Double stuSumScore = stuQuestions.stream().mapToDouble(MsPaperStudentQuestion::getStuscore).sum();// 学生总分
|
702
|
776
|
Double avgScore = MarkingUtil.div(stuSumScore, stuNum);// 平均分
|
703
|
|
- Double stuScoreRate = MarkingUtil.div(stuSumScore, schoolObjsub.getFullscore() * stuNum);// 学生得分率
|
704
|
777
|
|
705
|
778
|
MsrClassQobjsub objSub = new MsrClassQobjsub();
|
706
|
779
|
objSub.setExamid(schoolObjsub.getExamid());
|
707
|
780
|
objSub.setSubjectid(schoolObjsub.getSubjectid());
|
708
|
781
|
objSub.setClassid(schoolObjsub.getClassid());
|
|
782
|
+ objSub.setStunum(stuNum);
|
709
|
783
|
objSub.setQtype(schoolObjsub.getQtype());
|
710
|
784
|
objSub.setFullscore(schoolObjsub.getFullscore());
|
711
|
785
|
objSub.setMaxscore(stuScores.stream().max(Double::compareTo).orElse(0.0));
|
|
@@ -716,7 +790,7 @@ public class ReportGenerateQuestionService {
|
716
|
790
|
objSub.setQfd(MarkingUtil.qfd(stuScores));
|
717
|
791
|
objSub.setBzc(MarkingUtil.bzc(stuScores));
|
718
|
792
|
objSub.setCyxs(MarkingUtil.div(objSub.getBzc(), avgScore));
|
719
|
|
- objSub.setJbzs(MarkingUtil.jbzs(stuScores, stuScoreRate));
|
|
793
|
+ objSub.setJbzs(MarkingUtil.jbzs(stuScores, schoolObjsub.getFullscore()));
|
720
|
794
|
objSub.setMfnum(mfnum);
|
721
|
795
|
objSub.setMfrate(MarkingUtil.calculateRate(mfnum, stuNum));
|
722
|
796
|
if(mfnum > 0){
|