|
|
|
@ -53,7 +53,6 @@ import java.util.function.Predicate;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.date.DateUnit.SECOND;
|
|
|
|
|
import static cn.hutool.core.util.ArrayUtil.isAllNotEmpty;
|
|
|
|
|
import static cn.hutool.core.util.ArrayUtil.join;
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
|
|
|
|
|
import static cn.jlw.util.CacheUserUtil.getStudent;
|
|
|
|
@ -63,8 +62,6 @@ import static com.ibeetl.jlw.enums.QuestionBusinessTypeEnum.FROM_OPEN_COURSE;
|
|
|
|
|
import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.*;
|
|
|
|
|
import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.CHAPTER_EXERCISE;
|
|
|
|
|
import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_FILE;
|
|
|
|
|
import static com.ibeetl.jlw.enums.ResourcesQuestionTypeEnum.isOneQuestion;
|
|
|
|
|
import static java.lang.Math.abs;
|
|
|
|
|
import static java.lang.Math.toIntExact;
|
|
|
|
|
import static java.math.BigDecimal.ZERO;
|
|
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
|
|
@ -516,7 +513,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
|
|
|
|
|
|
|
|
|
|
// 比对答案
|
|
|
|
|
if ( StrUtil.isAllNotBlank(questionAns.toString(), studentAns) && questionAns.toString().equalsIgnoreCase(studentAns)) {
|
|
|
|
|
studentScore.add(eachScore);
|
|
|
|
|
studentScore = studentScore.add(eachScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -524,7 +521,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
|
|
|
|
|
// 计算该题目学生的得分情况
|
|
|
|
|
questionLog.setStudentScore(studentScore);
|
|
|
|
|
// 是否是错题
|
|
|
|
|
questionLog.setIsErrorFavorite(NumberUtil.isLess(studentScore, questionLog.getQuestionScore()));
|
|
|
|
|
questionLog.setIsErrorFavorite(NumberUtil.equals(studentScore, ZERO));
|
|
|
|
|
}else {
|
|
|
|
|
answersText = join(answer.split(","), ",");
|
|
|
|
|
// 是否是正确答案
|
|
|
|
@ -555,7 +552,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
|
|
|
|
|
// 最后提交试卷答案时候,才会记录错题
|
|
|
|
|
if (addType.equals(FINALLY_SUBMIT)) {
|
|
|
|
|
// 计算学生分数,并标记错题
|
|
|
|
|
calculateScoreOnSubmit(updateList);
|
|
|
|
|
// calculateScoreOnSubmit(updateList);
|
|
|
|
|
updateBatchTemplate(updateList);
|
|
|
|
|
// 添加到题目日志汇总中
|
|
|
|
|
addQuestionLogSummary(student, questionSettingId, updateList);
|
|
|
|
@ -568,86 +565,86 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能描述: <br>
|
|
|
|
|
* 计算学生分数
|
|
|
|
|
* 会判断题目是否打完,并抛出异常
|
|
|
|
|
*
|
|
|
|
|
* @param logList
|
|
|
|
|
* @Author: lx
|
|
|
|
|
* @Date: 2022/12/4 20:16
|
|
|
|
|
*/
|
|
|
|
|
public void calculateScoreOnSubmit(@NotEmpty(message = "学生题目日志不能为空!") List<TeacherOpenCourseQuestionLog> logList) {
|
|
|
|
|
logList.forEach(questionLog -> {
|
|
|
|
|
// 题目原本设置的分数
|
|
|
|
|
final BigDecimal questionScore = questionLog.getQuestionScore();
|
|
|
|
|
// 题目类型
|
|
|
|
|
final Integer questionType = questionLog.getQuestionType();
|
|
|
|
|
// 学生提交的结果
|
|
|
|
|
final String studentAnswer = defaultIfNull(questionLog.getTeacherOpenCourseQuestionLogAnswer(), "");
|
|
|
|
|
// 题目的答案
|
|
|
|
|
final String questionAnswer = defaultIfNull(questionLog.getQuestionAnswer(), "");
|
|
|
|
|
// 判断答案和学生提交的结果,都不能为空
|
|
|
|
|
final boolean allNotEmpty = isAllNotEmpty(questionAnswer, studentAnswer);
|
|
|
|
|
// 题目类型,答案属于一道题
|
|
|
|
|
final boolean oneQuestion = isOneQuestion(questionType);
|
|
|
|
|
|
|
|
|
|
// 一条日志记录,属于一道题
|
|
|
|
|
if (oneQuestion) {
|
|
|
|
|
final boolean isTrue = allNotEmpty && studentAnswer.equalsIgnoreCase(questionAnswer);
|
|
|
|
|
final BigDecimal mySimpleScore = isTrue ? questionScore: ZERO;
|
|
|
|
|
// 计算学生最后的得分
|
|
|
|
|
questionLog.setStudentScore(mySimpleScore);
|
|
|
|
|
|
|
|
|
|
if (isTrue) {
|
|
|
|
|
questionLog.setSuccessCount(1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
questionLog.setErrorCount(1);
|
|
|
|
|
}
|
|
|
|
|
// 错题标记
|
|
|
|
|
questionLog.setIsErrorFavorite(!isTrue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 一条日志记录,属于多道题的逻辑处理
|
|
|
|
|
else {
|
|
|
|
|
// 分数,正确数量
|
|
|
|
|
BigDecimal score = ZERO; int successCount = 0;
|
|
|
|
|
// 学生提交的题目结果
|
|
|
|
|
final String[] studentAnswerArr = studentAnswer.split(",");
|
|
|
|
|
// 正确答案和学生答案对比
|
|
|
|
|
|
|
|
|
|
String[] successAnswerArr = questionAnswer.split(",");
|
|
|
|
|
final int studentAnswerLength = studentAnswerArr.length;
|
|
|
|
|
final int questionLength = successAnswerArr.length;
|
|
|
|
|
// 断言需要判断,题目答案的数量是否相等,不然会对不上答案,导致分数计算错误
|
|
|
|
|
// Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
|
|
|
|
|
|
|
|
|
|
// 一道题的分数
|
|
|
|
|
BigDecimal simpleQuestionScore = NumberUtil.mul(questionScore, questionLength);
|
|
|
|
|
// 循环比对这个题目,是否是复杂的题目:如选词填空或者分析题
|
|
|
|
|
for (int i = 0; i < questionLength; i++) {
|
|
|
|
|
String sqs = successAnswerArr[i];
|
|
|
|
|
boolean isTrue = allNotEmpty && sqs.equalsIgnoreCase(studentAnswerArr[i]);
|
|
|
|
|
BigDecimal oneScore = isTrue ? simpleQuestionScore : ZERO;
|
|
|
|
|
score = score.add(oneScore);
|
|
|
|
|
|
|
|
|
|
// 正确的数量计数
|
|
|
|
|
if (isTrue) {
|
|
|
|
|
successCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 全对的题目,才算做正确答案
|
|
|
|
|
final boolean isAllTrue = successCount == questionLength;
|
|
|
|
|
// 计算学生最后的得分
|
|
|
|
|
questionLog.setStudentScore(score);
|
|
|
|
|
questionLog.setSuccessCount(successCount);
|
|
|
|
|
questionLog.setErrorCount(abs(questionLength - successCount));
|
|
|
|
|
// 错题标记
|
|
|
|
|
questionLog.setIsErrorFavorite(!isAllTrue);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// /**
|
|
|
|
|
// * 功能描述: <br>
|
|
|
|
|
// * 计算学生分数
|
|
|
|
|
// * 会判断题目是否打完,并抛出异常
|
|
|
|
|
// *
|
|
|
|
|
// * @param logList
|
|
|
|
|
// * @Author: lx
|
|
|
|
|
// * @Date: 2022/12/4 20:16
|
|
|
|
|
// */
|
|
|
|
|
// public void calculateScoreOnSubmit(@NotEmpty(message = "学生题目日志不能为空!") List<TeacherOpenCourseQuestionLog> logList) {
|
|
|
|
|
// logList.forEach(questionLog -> {
|
|
|
|
|
// // 题目原本设置的分数
|
|
|
|
|
// final BigDecimal questionScore = questionLog.getQuestionScore();
|
|
|
|
|
// // 题目类型
|
|
|
|
|
// final Integer questionType = questionLog.getQuestionType();
|
|
|
|
|
// // 学生提交的结果
|
|
|
|
|
// final String studentAnswer = defaultIfNull(questionLog.getTeacherOpenCourseQuestionLogAnswer(), "");
|
|
|
|
|
// // 题目的答案
|
|
|
|
|
// final String questionAnswer = defaultIfNull(questionLog.getQuestionAnswer(), "");
|
|
|
|
|
// // 判断答案和学生提交的结果,都不能为空
|
|
|
|
|
// final boolean allNotEmpty = isAllNotEmpty(questionAnswer, studentAnswer);
|
|
|
|
|
// // 题目类型,答案属于一道题
|
|
|
|
|
// final boolean oneQuestion = isOneQuestion(questionType);
|
|
|
|
|
//
|
|
|
|
|
// // 一条日志记录,属于一道题
|
|
|
|
|
// if (oneQuestion) {
|
|
|
|
|
// final boolean isTrue = allNotEmpty && studentAnswer.equalsIgnoreCase(questionAnswer);
|
|
|
|
|
// final BigDecimal mySimpleScore = isTrue ? questionScore: ZERO;
|
|
|
|
|
// // 计算学生最后的得分
|
|
|
|
|
// questionLog.setStudentScore(mySimpleScore);
|
|
|
|
|
//
|
|
|
|
|
// if (isTrue) {
|
|
|
|
|
// questionLog.setSuccessCount(1);
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// questionLog.setErrorCount(1);
|
|
|
|
|
// }
|
|
|
|
|
// // 错题标记
|
|
|
|
|
// questionLog.setIsErrorFavorite(!isTrue);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 一条日志记录,属于多道题的逻辑处理
|
|
|
|
|
// else {
|
|
|
|
|
// // 分数,正确数量
|
|
|
|
|
// BigDecimal score = ZERO; int successCount = 0;
|
|
|
|
|
// // 学生提交的题目结果
|
|
|
|
|
// final String[] studentAnswerArr = studentAnswer.split(",");
|
|
|
|
|
// // 正确答案和学生答案对比
|
|
|
|
|
//
|
|
|
|
|
// String[] successAnswerArr = questionAnswer.split(",");
|
|
|
|
|
// final int studentAnswerLength = studentAnswerArr.length;
|
|
|
|
|
// final int questionLength = successAnswerArr.length;
|
|
|
|
|
// // 断言需要判断,题目答案的数量是否相等,不然会对不上答案,导致分数计算错误
|
|
|
|
|
//// Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
|
|
|
|
|
//
|
|
|
|
|
// // 一道题的分数
|
|
|
|
|
// BigDecimal simpleQuestionScore = NumberUtil.div(questionScore, questionLength);
|
|
|
|
|
// // 循环比对这个题目,是否是复杂的题目:如选词填空或者分析题
|
|
|
|
|
// for (int i = 0; i < questionLength; i++) {
|
|
|
|
|
// String sqs = successAnswerArr[i];
|
|
|
|
|
// boolean isTrue = allNotEmpty && sqs.equalsIgnoreCase(studentAnswerArr[i]);
|
|
|
|
|
// BigDecimal oneScore = isTrue ? simpleQuestionScore : ZERO;
|
|
|
|
|
// score = score.add(oneScore);
|
|
|
|
|
//
|
|
|
|
|
// // 正确的数量计数
|
|
|
|
|
// if (isTrue) {
|
|
|
|
|
// successCount++;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // 全对的题目,才算做正确答案
|
|
|
|
|
// final boolean isAllTrue = successCount == questionLength;
|
|
|
|
|
// // 计算学生最后的得分
|
|
|
|
|
// questionLog.setStudentScore(score);
|
|
|
|
|
// questionLog.setSuccessCount(successCount);
|
|
|
|
|
// questionLog.setErrorCount(abs(questionLength - successCount));
|
|
|
|
|
// // 错题标记
|
|
|
|
|
// questionLog.setIsErrorFavorite(!isAllTrue);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|