提交试卷,报错修复

beetlsql3-dev
Mlxa0324 2 years ago
parent fc5bfe0a08
commit aa22cd59ac

@ -54,6 +54,10 @@ public enum ResourcesQuestionTypeEnum {
* @Date: 2022/12/4 22:33
*/
public static boolean isOneQuestion(Integer code) {
return isOneQuestion(EnumUtil.likeValueOf(ResourcesQuestionTypeEnum.class, code));
return isOneQuestion(like(code));
}
private static ResourcesQuestionTypeEnum like(Integer code) {
return EnumUtil.likeValueOf(ResourcesQuestionTypeEnum.class, code);
}
}

@ -643,13 +643,15 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
// 只添加可以更新的数据
updateList.add(questionLog);
});
// 计算学生分数,并标记错题
calculateScoreOnSubmit(updateList);
// 学生做的题目的答案与日志关联
updateBatchTemplate(updateList);
// 最后提交试卷答案时候,才会记录错题
if (addType.equals(FINALLY_SUBMIT)) {
// 计算学生分数,并标记错题
calculateScoreOnSubmit(updateList);
// 学生做的题目的答案与日志关联
updateBatchTemplate(updateList);
// 添加到题目日志汇总中
addQuestionLogSummary(updateList, student,
questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType());
@ -704,7 +706,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
final int studentAnswerLength = studentAnswerArr.length;
final int questionLength = successAnswerArr.length;
// 断言需要判断,题目答案的数量是否相等,不然会对不上答案,导致分数计算错误
Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
// Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
// 一道题的分数
BigDecimal simpleQuestionScore = NumberUtil.mul(questionScore, questionLength);

@ -525,8 +525,11 @@ public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuesti
if (TRUE_CONST.equals(setting.getGeneralQuestionSettingOptionNoOrder())) {
// 单题选项排序处理
resourcesQuestionSnapshots.forEach(value -> {
shuffleQuestion(value, "questionStem","questionOption",
"questionAnswer", "questionType");
// 1单选 2多选进行打乱其他的不变
if (value.getQuestionType() <= 2) {
shuffleQuestion(value, "questionStem","questionOption",
"questionAnswer", "questionType");
}
});
}

@ -469,13 +469,14 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 只添加可以更新的数据
updateList.add(questionLog);
});
// 计算学生分数,并标记错题
calculateScoreOnSubmit(updateList);
// 学生做的题目的答案与日志关联
updateBatchTemplate(updateList);
// 最后提交试卷答案时候,才会记录错题
if (addType.equals(FINALLY_SUBMIT)) {
// 计算学生分数,并标记错题
calculateScoreOnSubmit(updateList);
updateBatchTemplate(updateList);
// 添加到题目日志汇总中
addQuestionLogSummary(updateList, student,
questionSetting.getTeacherOpenCourseQuestionSettingName(), questionSetting.getTeacherOpenCourseQuestionSettingType());
@ -497,6 +498,8 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
logList.forEach(questionLog -> {
// 题目原本设置的分数
final BigDecimal questionScore = questionLog.getQuestionScore();
// 题目类型
Integer questionType = questionLog.getQuestionType();
// 学生提交的结果
final String studentAnswer = defaultIfNull(questionLog.getTeacherOpenCourseQuestionLogAnswer(), "");
// 题目的答案
@ -504,7 +507,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 判断答案和学生提交的结果,都不能为空
final boolean allNotEmpty = isAllNotEmpty(questionAnswer, studentAnswer);
// 题目类型,答案属于一道题
final boolean oneQuestion = isOneQuestion(questionLog.getQuestionType());
final boolean oneQuestion = isOneQuestion(questionType);
// 一条日志记录,属于一道题
if (oneQuestion) {
@ -532,7 +535,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
final int studentAnswerLength = studentAnswerArr.length;
final int questionLength = successAnswerArr.length;
// 断言需要判断,题目答案的数量是否相等,不然会对不上答案,导致分数计算错误
Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
// Assert.isTrue(studentAnswerLength == questionLength, "题干:" + questionLog.getQuestionStem()+ ",有选项未提交!");
// 一道题的分数
BigDecimal simpleQuestionScore = NumberUtil.mul(questionScore, questionLength);
@ -695,8 +698,6 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
logicDeleteBySettingIds(questionSettingId.toString());
}
// 断言
Assert.notBlank(resourcesQuestionSnapshots.get(0).getQuestionAnswer(), "题目快照选项不能为空!");
List<TeacherOpenCourseQuestionLog> teacherOpenCourseQuestionLogs = BeanUtil.copyToList(resourcesQuestionSnapshots, TeacherOpenCourseQuestionLog.class);
// 设计个单表,后面进行修改操作

@ -792,8 +792,11 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
if (TRUE_CONST.equals(setting.getTeacherOpenCourseQuestionSettingOptionNoOrder())) {
// 单题选项排序处理
resourcesQuestionSnapshots.forEach(value -> {
shuffleQuestion(value, "questionStem","questionOption",
"questionAnswer", "questionType");
// 1单选 2多选进行打乱其他的不变
if (value.getQuestionType() <= 2) {
shuffleQuestion(value, "questionStem","questionOption",
"questionAnswer", "questionType");
}
});
}

Loading…
Cancel
Save