|
|
|
@ -39,6 +39,13 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
|
|
|
|
|
|
|
|
|
|
/** ========================================================================= */
|
|
|
|
|
|
|
|
|
|
// 题目总数量
|
|
|
|
|
|
|
|
|
|
@FetchSql("select count(1) from resources_question_snapshot t " +
|
|
|
|
|
"where t.question_status = 1 " +
|
|
|
|
|
"and t.resources_question_snapshot_from_id = #resourcesQuestionSnapshotFromId# "
|
|
|
|
|
)
|
|
|
|
|
private int questionTotalCount;
|
|
|
|
|
|
|
|
|
|
// 答对数量
|
|
|
|
|
|
|
|
|
@ -101,16 +108,21 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
|
|
|
|
|
tryCalcCorrectRate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setQuestionTotalCount(int questionTotalCount) {
|
|
|
|
|
this.questionTotalCount = questionTotalCount;
|
|
|
|
|
tryCalcCorrectRate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 尝试计算正确率
|
|
|
|
|
*/
|
|
|
|
|
private void tryCalcCorrectRate() {
|
|
|
|
|
int temp = this.getCorrectCount() + this.getWrongCount();
|
|
|
|
|
if (this.getCorrectCount() > 0 && this.getWrongCount() > 0) {
|
|
|
|
|
int sumTotalCount = getCorrectCount() + getWrongCount();
|
|
|
|
|
if (getQuestionTotalCount() == sumTotalCount) {
|
|
|
|
|
// 计算正确率, 取小数点后2位数
|
|
|
|
|
// 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100
|
|
|
|
|
this.setCorrectRate(NumberUtil
|
|
|
|
|
.round(NumberUtil.div(this.getCorrectCount(), temp) * 100, 0)
|
|
|
|
|
.round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 0)
|
|
|
|
|
.intValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|