|
@@ -11,19 +11,26 @@ import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
import cn.com.qmth.stmms.biz.report.model.ReportSubjectQuestion;
|
|
import cn.com.qmth.stmms.biz.report.model.ReportSubjectQuestion;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectQuestionService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectQuestionService;
|
|
import cn.com.qmth.stmms.biz.report.utils.Module;
|
|
import cn.com.qmth.stmms.biz.report.utils.Module;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.QuestionCalculatorProvider;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportContext;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportContext;
|
|
import cn.com.qmth.stmms.biz.report.utils.unit.BaseCalculatorUnit;
|
|
import cn.com.qmth.stmms.biz.report.utils.unit.BaseCalculatorUnit;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
import cn.com.qmth.stmms.biz.utils.SpringContextHolder;
|
|
import cn.com.qmth.stmms.biz.utils.SpringContextHolder;
|
|
|
|
|
|
-public class SubjectQuestionModule implements Module {
|
|
|
|
|
|
+/**
|
|
|
|
+ * 按科目统计全样本小题指标
|
|
|
|
+ *
|
|
|
|
+ * @author luoshi
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+public class SubjectQuestionModule implements Module, QuestionCalculatorProvider {
|
|
|
|
|
|
- private Map<String, BaseCalculatorUnit> units;
|
|
|
|
|
|
+ protected Map<String, BaseCalculatorUnit> calculators;
|
|
|
|
|
|
- private ReportContext context;
|
|
|
|
|
|
+ protected ReportContext context;
|
|
|
|
|
|
public SubjectQuestionModule(ReportContext context) {
|
|
public SubjectQuestionModule(ReportContext context) {
|
|
- this.units = new HashMap<String, BaseCalculatorUnit>();
|
|
|
|
|
|
+ this.calculators = new HashMap<String, BaseCalculatorUnit>();
|
|
this.context = context;
|
|
this.context = context;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -31,13 +38,14 @@ public class SubjectQuestionModule implements Module {
|
|
if (student.isUpload() && !student.isAbsent() && !student.isBreach() && student.getSubject() != null) {
|
|
if (student.isUpload() && !student.isAbsent() && !student.isBreach() && student.getSubject() != null) {
|
|
double totalScore = student.getTotalScore();
|
|
double totalScore = student.getTotalScore();
|
|
// 遍历客观题
|
|
// 遍历客观题
|
|
- process(student.getScoreList(true), student.getObjectiveQuestionList(), totalScore);
|
|
|
|
|
|
+ process(student, student.getScoreList(true), student.getObjectiveQuestionList(), totalScore);
|
|
// 遍历主观题
|
|
// 遍历主观题
|
|
- process(student.getScoreList(false), student.getSubjectiveQuestionList(), totalScore);
|
|
|
|
|
|
+ process(student, student.getScoreList(false), student.getSubjectiveQuestionList(), totalScore);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void process(List<ScoreItem> scoreList, List<ExamQuestion> questionList, double totalScore) {
|
|
|
|
|
|
+ private void process(ExamStudent student, List<ScoreItem> scoreList, List<ExamQuestion> questionList,
|
|
|
|
+ double totalScore) {
|
|
if (scoreList == null || questionList == null) {
|
|
if (scoreList == null || questionList == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -49,11 +57,15 @@ public class SubjectQuestionModule implements Module {
|
|
}
|
|
}
|
|
ScoreItem item = scoreCount > i ? scoreList.get(i) : null;
|
|
ScoreItem item = scoreCount > i ? scoreList.get(i) : null;
|
|
double score = item != null ? item.getScore() : 0;
|
|
double score = item != null ? item.getScore() : 0;
|
|
- findUnit(getKey(question)).process(score, question.getTotalScore(), totalScore);
|
|
|
|
|
|
+ process(student, question, score, totalScore);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public String getKey(ExamQuestion question) {
|
|
|
|
|
|
+ protected void process(ExamStudent student, ExamQuestion question, double score, double totalScore) {
|
|
|
|
+ findCalculator(getKey(question)).process(score, question.getTotalScore(), totalScore);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected String getKey(ExamQuestion question, Object... parameter) {
|
|
return question.getSubjectCode() + "\t" + question.isObjective() + "\t"
|
|
return question.getSubjectCode() + "\t" + question.isObjective() + "\t"
|
|
+ StringUtils.trimToEmpty(question.getPaperType()) + "\t" + question.getMainNumber() + "\t"
|
|
+ StringUtils.trimToEmpty(question.getPaperType()) + "\t" + question.getMainNumber() + "\t"
|
|
+ question.getSubNumber();
|
|
+ question.getSubNumber();
|
|
@@ -61,7 +73,7 @@ public class SubjectQuestionModule implements Module {
|
|
|
|
|
|
public void save() {
|
|
public void save() {
|
|
ReportSubjectQuestionService service = SpringContextHolder.getBean(ReportSubjectQuestionService.class);
|
|
ReportSubjectQuestionService service = SpringContextHolder.getBean(ReportSubjectQuestionService.class);
|
|
- for (String key : this.units.keySet()) {
|
|
|
|
|
|
+ for (String key : this.calculators.keySet()) {
|
|
String s[] = key.split("\t");
|
|
String s[] = key.split("\t");
|
|
if (s.length > 4) {
|
|
if (s.length > 4) {
|
|
String subjectCode = s[0];
|
|
String subjectCode = s[0];
|
|
@@ -69,7 +81,7 @@ public class SubjectQuestionModule implements Module {
|
|
String paperType = StringUtils.trimToNull(s[2]);
|
|
String paperType = StringUtils.trimToNull(s[2]);
|
|
Integer mainNumber = Integer.parseInt(s[3]);
|
|
Integer mainNumber = Integer.parseInt(s[3]);
|
|
Integer subNumber = Integer.parseInt(s[4]);
|
|
Integer subNumber = Integer.parseInt(s[4]);
|
|
- BaseCalculatorUnit unit = units.get(key);
|
|
|
|
|
|
+ BaseCalculatorUnit unit = calculators.get(key);
|
|
ReportSubjectQuestion r = new ReportSubjectQuestion();
|
|
ReportSubjectQuestion r = new ReportSubjectQuestion();
|
|
r.setExamId(this.context.getExamId());
|
|
r.setExamId(this.context.getExamId());
|
|
r.setSubjectCode(subjectCode);
|
|
r.setSubjectCode(subjectCode);
|
|
@@ -96,13 +108,18 @@ public class SubjectQuestionModule implements Module {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private BaseCalculatorUnit findUnit(String key) {
|
|
|
|
- BaseCalculatorUnit unit = units.get(key);
|
|
|
|
|
|
+ protected BaseCalculatorUnit findCalculator(String key) {
|
|
|
|
+ BaseCalculatorUnit unit = calculators.get(key);
|
|
if (unit == null) {
|
|
if (unit == null) {
|
|
unit = new BaseCalculatorUnit();
|
|
unit = new BaseCalculatorUnit();
|
|
- units.put(key, unit);
|
|
|
|
|
|
+ calculators.put(key, unit);
|
|
}
|
|
}
|
|
return unit;
|
|
return unit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public BaseCalculatorUnit getCalculator(ExamQuestion question, Object... parameter) {
|
|
|
|
+ return calculators.get(getKey(question, parameter));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|