Merge remote-tracking branch 'origin/beetlsql3-dev' into beetlsql3-dev

beetlsql3-dev
姚丹ab 2 years ago
commit 8d91e16fee

@ -139,5 +139,23 @@ public interface GeneralQuestionLogDao extends BaseMapper<GeneralQuestionLog> {
.andEq(GeneralQuestionLog::getGeneralQuestionSettingId, questionSettingId)
.select();
}
/**
*
* @param studentId
* @param questionSettingId
* @return
*/
List<TeacherOpenCourseQuestionLog> getNotSubmitQuestionLogs(Long studentId, Long questionSettingId);
/**
*
* @param studentId
* @param questionSettingId
* @return
*/
long getNotSubmitQuestionLogsCount(Long studentId, Long questionSettingId);
}

@ -143,4 +143,21 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper<TeacherOpenC
.andEq(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionSettingId, questionSettingId)
.select();
}
/**
*
* @param studentId
* @param questionSettingId
* @return
*/
List<TeacherOpenCourseQuestionLog> getNotSubmitQuestionLogs(Long studentId, Long questionSettingId);
/**
*
* @param studentId
* @param questionSettingId
* @return
*/
long getNotSubmitQuestionLogsCount(Long studentId, Long questionSettingId);
}

@ -1,6 +1,7 @@
package com.ibeetl.jlw.entity.dto;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum;
import lombok.Data;
@ -61,7 +62,10 @@ public class QuestionLogAddDTO {
* @return
*/
public static String answerDistinctSort(@NotEmpty(message = "题目答案不能为空!") String answersText) {
return join(new TreeSet<>(Arrays.asList(answersText.split(","))).toArray(), ",");
if (!JSONUtil.isTypeJSON(answersText)) {
return join(new TreeSet<>(Arrays.asList(answersText.split(","))).toArray(), ",");
}
return answersText;
}
/**

@ -4,10 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.*;
import cn.hutool.json.JSONUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -582,6 +580,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
/**
*
*
*
*
* @param questionLogAddDTO
* @param questionSetting
@ -612,8 +611,14 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList());
Assert.notEmpty(logList, "未查询到题目信息!");
// 题目日志IDs汇总
String logsIds = logList.stream().map(item -> item.getGeneralQuestionLogId().toString()).collect(joining(","));
// 当前时间, 存储要更新的题目日志集合
Date now = new Date(); List<GeneralQuestionLog> updateList = new ArrayList<>();
// 代表填空题和分析题的类型
List<Integer> questionType = Arrays.asList(4, 5);
// 处理答案和分数
logList.forEach(questionLog -> {
// 验证最新的提交时间,防止网络延迟
@ -623,16 +628,54 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
// 验证提交类型
validateQuestionLogAddTypeThrow(questionLog.getQuestionLogAddType(), questionLogAddDTO.getQuestionLogAddType());
// 学生提交的答案
String answersText = join(questionLogMap.get(questionLog.getGeneralResourcesQuestionSnapshotId().toString()).split(","), ",");
// 是否是正确答案
Boolean isCorrectAnswer = questionLog.getQuestionAnswer().equalsIgnoreCase(answersText);
String answer = questionLogMap.get(questionLog.getGeneralQuestionLogId().toString());
// 默认0分
questionLog.setStudentScore(BigDecimal.valueOf(0));
// 学生提交的答案处理
String answersText = null;
if (questionType.contains(questionLog.getQuestionType())) {
answersText = answer;
// 学生答案和正确答案集合
cn.hutool.json.JSONObject studentAnswerArr = JSONUtil.parseObj(answersText);
cn.hutool.json.JSONObject questionAnswerArr = JSONUtil.parseObj(questionLog.getQuestionAnswer());
// 每题分数
BigDecimal eachScore = NumberUtil.div(questionLog.getQuestionScore(), questionAnswerArr.size(), 1);
BigDecimal studentScore = new BigDecimal("0");
for (Map.Entry<String, Object> map : questionAnswerArr.entrySet()) {
Object questionAns = map.getValue();
String k = map.getKey();
String studentAns = studentAnswerArr.getStr(k, "");
// 比对答案
if (studentAns.equalsIgnoreCase(questionAns.toString()) && StrUtil.isAllNotBlank(questionAns.toString(), studentAns)) {
studentScore.add(eachScore);
}
}
// 填空题和分析题计算分数
// 计算该题目学生的得分情况
questionLog.setStudentScore(studentScore);
// 是否是错题
questionLog.setIsErrorFavorite(NumberUtil.isLess(studentScore, questionLog.getQuestionScore()));
}else {
answersText = join(answer.split(","), ",");
// 是否是正确答案
Boolean isCorrectAnswer = questionLog.getQuestionAnswer().equalsIgnoreCase(answersText);
// 学生得分
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : ZERO);
questionLog.setIsErrorFavorite(!isCorrectAnswer);
}
// 完成时间
long finishSecondTime = DateUtil.between(questionLog.getGeneralQuestionLogAddTime(), now, SECOND);
// 填充属性
// 计算该题目学生的得分情况
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : BigDecimal.valueOf(0));
questionLog.setIsErrorFavorite(isCorrectAnswer);
questionLog.setGeneralQuestionLogUpdateTime(now);
questionLog.setGeneralQuestionLogFinishTime(finishSecondTime);
questionLog.setGeneralQuestionLogAnswer(answersText);
@ -653,7 +696,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
// 学生做的题目的答案与日志关联
updateBatchTemplate(updateList);
// 添加到题目日志汇总中
addQuestionLogSummary(updateList, student,
addQuestionLogSummary(logsIds, updateList, student,
questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType());
}
}
@ -738,16 +781,17 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
* : <br>
*
*
* @param logList questionSettingId
* @param student
* @param questionSettingName
* @param fromType
* @param snapshotFromTypeEnum
* @param logsIds IDs
* @param logList questionSettingId
* @param student
* @param questionSettingName
* @param fromType
* @param snapshotFromTypeEnum
* @Author: lx
* @Date: 2022/12/4 20:16
*/
public void addQuestionLogSummary(
@NotEmpty(message = "学生题目日志不能为空!") List<GeneralQuestionLog> logList,
String logsIds, @NotEmpty(message = "学生题目日志不能为空!") List<GeneralQuestionLog> logList,
@NotNull Student student, @NotBlank String questionSettingName, @NotNull QuestionBusinessTypeEnum fromType,
@NotNull ResourcesQuestionSnapshotFromTypeEnum snapshotFromTypeEnum) {
// 构建实体
@ -790,7 +834,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
questionLogSummary.setQuestionSettingTotalScore(questionTotalScore);
questionLogSummary.setQuestionLogSummaryStudentTotalScore(myTotalScore);
questionLogSummary.setPersonId(student.getStudentId());
questionLogSummary.setQuestionLogIds(join(idsSet.toArray(), ","));
questionLogSummary.setQuestionLogIds(logsIds);
questionLogSummary.setQuestionLogSummaryQuestionTotalCount(questionTotalCount);
questionLogSummary.setQuestionLogSummaryStudentDoCount(sumDoCount);
questionLogSummary.setQuestionLogSummarySuccessCount(sumSuccessCount);
@ -850,7 +894,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
// 不是强制发题,则不覆盖现有的题目日志,则继续做题
// 验证题目日志,是否已经存在试卷
if(!isReSend) {
long logCount = generalQuestionLogDao.getCountByQuestionLogAddType(questionSettingId, studentId, PRE_SUBMIT.name(), null);
long logCount = generalQuestionLogDao.getNotSubmitQuestionLogsCount(studentId, questionSettingId);
// 如果题目日志里存在预先布置的题目,则直接返回
if (logCount > 0) {
@ -884,6 +928,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
});
insertBatch(generalQuestionLogs);
}
/**

@ -487,11 +487,11 @@ public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuesti
Integer generalQuestionSettingSettingDoCount = setting.getGeneralQuestionSettingDoCount();
Assert.isTrue(generalQuestionSettingSettingDoCount > 0, "作答次数设置有误,请联系管理员!");
// 数据库查询该学生已经做过的次数, 这个试卷如果已经交卷的话,就提示用户
GeneralQuestionLog generalQuestionLog = new GeneralQuestionLog();
generalQuestionLog.setStudentId(studentId);
generalQuestionLog.setQuestionLogAddType(FINALLY_SUBMIT);
generalQuestionLog.setGeneralQuestionSettingId(generalQuestionSettingId);
long doCount = generalQuestionLogDao.templateCount(generalQuestionLog);
QuestionLogSummary entity = new QuestionLogSummary();
entity.setPersonId(studentId);
entity.setQuestionSettingType(fromTypeEnum);
entity.setQuestionSettingId(generalQuestionSettingId);
long doCount = questionLogSummaryDao.templateCount(entity);
// 断言判断最大作答次数
Assert.isTrue(doCount < generalQuestionSettingSettingDoCount, "已超过最大作答次数!");
}

@ -5,10 +5,8 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.*;
import cn.hutool.json.JSONUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -412,6 +410,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
/**
*
*
*
*
* @param questionLogAddDTO
* @param student
@ -442,9 +441,13 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 只是未提交的数据
logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList());
Assert.notEmpty(logList, "未查询到题目信息!");
// 题目日志IDs汇总
String logsIds = logList.stream().map(item -> item.getTeacherOpenCourseQuestionLogId().toString()).collect(joining(","));
// 当前时间, 存储要更新的题目日志集合
Date now = new Date(); List<TeacherOpenCourseQuestionLog> updateList = new ArrayList<>();
// 代表填空题和分析题的类型
List<Integer> questionType = Arrays.asList(4, 5);
// 处理答案和分数
logList.forEach(questionLog -> {
// 验证最新的提交时间,防止网络延迟
@ -454,7 +457,50 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 验证提交类型
validateQuestionLogAddTypeThrow(questionLog.getQuestionLogAddType(), questionLogAddDTO.getQuestionLogAddType());
// 学生提交的答案
String answersText = join(questionLogMap.get(questionLog.getResourcesQuestionSnapshotId().toString()).split(","), ",");
String answer = questionLogMap.get(questionLog.getResourcesQuestionSnapshotId().toString());
// 默认0分
questionLog.setStudentScore(BigDecimal.valueOf(0));
// 学生提交的答案处理
String answersText = null;
if (questionType.contains(questionLog.getQuestionType())) {
answersText = answer;
// 学生答案和正确答案集合
cn.hutool.json.JSONObject studentAnswerArr = JSONUtil.parseObj(answersText);
cn.hutool.json.JSONObject questionAnswerArr = JSONUtil.parseObj(questionLog.getQuestionAnswer());
// 每题分数
BigDecimal eachScore = NumberUtil.div(questionLog.getQuestionScore(), questionAnswerArr.size(), 1);
BigDecimal studentScore = new BigDecimal("0");
for (Map.Entry<String, Object> map : questionAnswerArr.entrySet()) {
Object questionAns = map.getValue();
String k = map.getKey();
String studentAns = studentAnswerArr.getStr(k, "");
// 比对答案
if (studentAns.equalsIgnoreCase(questionAns.toString()) && StrUtil.isAllNotBlank(questionAns.toString(), studentAns)) {
studentScore.add(eachScore);
}
}
// 填空题和分析题计算分数
// 计算该题目学生的得分情况
questionLog.setStudentScore(studentScore);
// 是否是错题
questionLog.setIsErrorFavorite(NumberUtil.isLess(studentScore, questionLog.getQuestionScore()));
}else {
answersText = join(answer.split(","), ",");
// 是否是正确答案
Boolean isCorrectAnswer = questionLog.getQuestionAnswer().equalsIgnoreCase(answersText);
// 学生得分
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : ZERO);
questionLog.setIsErrorFavorite(!isCorrectAnswer);
}
// 完成时间,从生成试卷时候,开始计算
long finishSecondTime = DateUtil.between(questionLog.getTeacherOpenCourseQuestionLogAddTime(), now, SECOND);
@ -478,7 +524,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
calculateScoreOnSubmit(updateList);
updateBatchTemplate(updateList);
// 添加到题目日志汇总中
addQuestionLogSummary(updateList, student,
addQuestionLogSummary(logsIds, updateList, student,
questionSetting.getTeacherOpenCourseQuestionSettingName(), questionSetting.getTeacherOpenCourseQuestionSettingType());
// 批量插入错题集错题库方法内部自带分数判断。内部方法更新log中的错题标记。
teacherOpenCourseQuestionLogWrongService.insertBatchByQuestionLogList(updateList);
@ -567,15 +613,16 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
* : <br>
*
*
* @param logList questionSettingId
* @param student
* @param questionSettingName
* @param snapshotFromTypeEnum
* @param logsIds IDs
* @param logList questionSettingId
* @param student
* @param questionSettingName
* @param snapshotFromTypeEnum
* @Author: lx
* @Date: 2022/12/4 20:16
*/
public void addQuestionLogSummary(
@NotEmpty(message = "学生题目日志不能为空!") List<TeacherOpenCourseQuestionLog> logList,
String logsIds, @NotEmpty(message = "学生题目日志不能为空!") List<TeacherOpenCourseQuestionLog> logList,
@NotNull Student student, @NotBlank String questionSettingName, @NotNull ResourcesQuestionSnapshotFromTypeEnum snapshotFromTypeEnum) {
// 构建实体
final QuestionLogSummary questionLogSummary = new QuestionLogSummary();
@ -618,7 +665,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
questionLogSummary.setQuestionSettingTotalScore(questionTotalScore);
questionLogSummary.setQuestionLogSummaryStudentTotalScore(myTotalScore);
questionLogSummary.setPersonId(student.getStudentId());
questionLogSummary.setQuestionLogIds(join(idsSet.toArray(), ","));
questionLogSummary.setQuestionLogIds(logsIds);
questionLogSummary.setQuestionLogSummaryQuestionTotalCount(questionTotalCount);
questionLogSummary.setQuestionLogSummaryStudentDoCount(sumDoCount);
questionLogSummary.setQuestionLogSummarySuccessCount(sumSuccessCount);
@ -681,7 +728,8 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 不是强制发题,则不覆盖现有的题目日志,则继续做题
// 验证题目日志,是否已经存在试卷
if(!isReSend) {
long logCount = teacherOpenCourseQuestionLogDao.getCountByQuestionLogAddType(questionSettingId, studentId, judgeAddType.name(), null);
long logCount = teacherOpenCourseQuestionLogDao.getNotSubmitQuestionLogsCount(studentId, questionSettingId);
// 如果题目日志里存在预先布置的题目,则直接返回
if (logCount > 0) {

@ -752,11 +752,11 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
Integer teacherOpenCourseQuestionSettingSettingDoCount = setting.getTeacherOpenCourseQuestionSettingDoCount();
Assert.isTrue(teacherOpenCourseQuestionSettingSettingDoCount > 0, "作答次数设置有误,请联系管理员!");
// 数据库查询该学生已经做过的次数, 这个试卷如果已经交卷的话,就提示用户
TeacherOpenCourseQuestionLog teacherOpenCourseQuestionLog = new TeacherOpenCourseQuestionLog();
teacherOpenCourseQuestionLog.setStudentId(studentId);
teacherOpenCourseQuestionLog.setQuestionLogAddType(FINALLY_SUBMIT);
teacherOpenCourseQuestionLog.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSettingId);
long doCount = teacherOpenCourseQuestionLogDao.templateCount(teacherOpenCourseQuestionLog);
QuestionLogSummary entity = new QuestionLogSummary();
entity.setPersonId(studentId);
entity.setQuestionSettingType(fromTypeEnum);
entity.setQuestionSettingId(teacherOpenCourseQuestionSettingId);
long doCount = questionLogSummaryDao.templateCount(entity);
// 断言判断最大作答次数
Assert.isTrue(doCount < teacherOpenCourseQuestionSettingSettingDoCount, "已超过最大作答次数!");
}

@ -1256,3 +1256,48 @@ verifyLogAddTypeIsReSend
AND ta.student_id = #studentId#
AND ta.question_log_add_type = #questionLogAddType#
LIMIT 1
getNotSubmitQuestionLogs
===
* 查询未提交的试卷
SELECT
*
FROM
general_question_log t
WHERE
NOT EXISTS (
SELECT
1
FROM
question_log_summary ta
WHERE
ta.person_id = #studentId#
AND ta.question_setting_id = #questionSettingId#
AND FIND_IN_SET( t.general_question_log_id, ta.question_log_ids )
)
AND t.student_id = #studentId#
AND t.general_question_setting_id = #questionSettingId#
getNotSubmitQuestionLogsCount
===
* 查询未提交试卷的题目数量
SELECT
count(1)
FROM
general_question_log t
WHERE
NOT EXISTS (
SELECT
1
FROM
question_log_summary ta
WHERE
ta.person_id = #studentId#
AND ta.question_setting_id = #questionSettingId#
AND FIND_IN_SET( t.general_question_log_id, ta.question_log_ids )
)
AND t.student_id = #studentId#
AND t.general_question_setting_id = #questionSettingId#

@ -471,7 +471,7 @@ selectStudentAnswerFragment
from general_question_log b
where 1 = 1 and b.student_id = #studentId#
and b.general_question_log_status = 1
and find_in_set(b.question_log_add_type, 'LOCK,FINALLY_SUBMIT')
and b.question_log_add_type != 'FINALLY_SUBMIT'
and b.general_question_setting_id = t.general_question_setting_id
and b.general_resources_question_snapshot_id = t.general_resources_question_snapshot_id
order by general_question_log_add_time desc limit 1

@ -486,7 +486,7 @@ selectStudentAnswerFragment
from teacher_open_course_question_log b
where 1 = 1 and b.student_id = #studentId#
and b.teacher_open_course_question_log_status = 1
@// and find_in_set(b.question_log_add_type, 'LOCK,FINALLY_SUBMIT')
and b.question_log_add_type != 'FINALLY_SUBMIT'
and b.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
and b.resources_question_snapshot_id = t.resources_question_snapshot_id
order by teacher_open_course_question_log_add_time desc limit 1

@ -936,3 +936,48 @@ verifyLogAddTypeIsReSend
AND ta.student_id = #studentId#
AND ta.question_log_add_type = #questionLogAddType#
LIMIT 1
getNotSubmitQuestionLogs
===
* 查询未提交的试卷
SELECT
*
FROM
teacher_open_course_question_log t
WHERE
NOT EXISTS (
SELECT
1
FROM
question_log_summary ta
WHERE
ta.person_id = #studentId#
AND ta.question_setting_id = #questionSettingId#
AND FIND_IN_SET( t.teacher_open_course_question_log_id, ta.question_log_ids )
)
AND t.student_id = #studentId#
AND t.teacher_open_course_question_setting_id = #questionSettingId#
getNotSubmitQuestionLogsCount
===
* 查询未提交试卷的题目数量
SELECT
count(1)
FROM
teacher_open_course_question_log t
WHERE
NOT EXISTS (
SELECT
1
FROM
question_log_summary ta
WHERE
ta.person_id = #studentId#
AND ta.question_setting_id = #questionSettingId#
AND FIND_IN_SET( t.teacher_open_course_question_log_id, ta.question_log_ids )
)
AND t.student_id = #studentId#
AND t.teacher_open_course_question_setting_id = #questionSettingId#
Loading…
Cancel
Save