【修改】试卷任务的使用次数学生和管理端分开

This commit is contained in:
huababa1
2025-09-18 12:08:28 +08:00
parent f287610f99
commit e716f414a8
7 changed files with 53 additions and 23 deletions

View File

@@ -90,4 +90,8 @@ public class MonitorDO extends BaseDO {
*/
private String interactiveTime;
/**
* 使用次数
*/
private String counts;
}

View File

@@ -72,4 +72,5 @@ public interface MonitorMapper extends BaseMapperX<MonitorDO> {
void deleteByTaskId(String taskId);
Integer selectCountByUserIdAndTaskId(@Param("stuId")Long stuId, @Param("taskId")String taskId);
}

View File

@@ -240,14 +240,20 @@ public class MonitorServiceImpl implements MonitorService {
if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) {
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId());
String counts = educationPaper.getCounts();
String countsStu = info.getCounts();
int count = 0;
int countStu = 0;
try {
count = Integer.parseInt(counts);
countStu = Integer.parseInt(countsStu);
} catch (NumberFormatException | NullPointerException e) {
count = 0; // 默认从 0 开始
countStu = 0;
}
count += 1;
countStu += 1;
educationPaper.setCounts(String.valueOf(count));
info.setCounts(String.valueOf(countStu));
educationPaperMapper.updateById(educationPaper);
info.setPaperNum(educationPaper.getNum());
}

View File

@@ -223,6 +223,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
info.setTaskName(name);
info.setTaskType(educationPaperTask.getTaskType());
info.setInteractiveTime(null);
info.setCounts("0");
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
monitorMapper.insert(info);
educationPaperPerson.setPersonId(studentId);

View File

@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
import cn.afterturn.easypoi.word.WordExportUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
@@ -27,6 +28,7 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.SchemeInfo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper;
import pc.exam.pp.module.exam.dal.dataobject.*;
import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.*;
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionFileMapper;
@@ -73,6 +75,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService
private ExamQuestionMapper examQuestionMapper;
@Autowired
private ExamQuestionFileMapper sysFileMapper;
@Resource
private MonitorMapper monitorMapper;
/**
* 查询试卷
*
@@ -339,10 +343,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService
EducationPaperStuDto educationPaperStuDto=new EducationPaperStuDto();
// EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(educationPaper.getTaskId());
// Integer counts= monitorMapper.selectCountByUserIdAndTaskId(loginUserId,educationPaper.getTaskId());
educationPaperStuDto.setPaperId(educationPaper.getPaperId());
educationPaperStuDto.setNum(educationPaper.getNum());
educationPaperStuDto.setTaskId(educationPaper.getTaskId());
educationPaperStuDto.setCounts(educationPaper.getCounts());
// educationPaperStuDto.setCounts(counts);
educationPaperStuDto.setRollUp(educationPaper.getRollUp());
educationPaperStuDto.setIsAb(educationPaper.getIsAb());
// educationPaperStuDto.setEducationPaperParam(educationPaperParam);

View File

@@ -629,21 +629,22 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
if ("0".equals(taskType)) {
for (EducationPaperTask paperTask : list) {
String taskId = paperTask.getTaskId();
int count = 0;
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
if (educationPapers != null && educationPapers.size() > 0) {
for (EducationPaper educationPaper : educationPapers) {
try {
count += Integer.parseInt(educationPaper.getCounts());
} catch (NumberFormatException e) {
// 可选:记录异常或忽略非法数字
System.err.println("无效的 counts 值: " + educationPaper.getCounts());
}
}
}
paperTask.setCount(String.valueOf(count));
// int count = 0;
// List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
// if (educationPapers != null && educationPapers.size() > 0) {
//// for (EducationPaper educationPaper : educationPapers) {
//// try {
//// count += Integer.parseInt(educationPaper.getCounts());
//// } catch (NumberFormatException e) {
//// // 可选:记录异常或忽略非法数字
//// System.err.println("无效的 counts 值: " + educationPaper.getCounts());
//// }
////
//// }
//
// }
Integer counts= monitorMapper.selectCountByUserIdAndTaskId(stuId,taskId);
paperTask.setCount(counts.toString());
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
//最高成绩
@@ -653,14 +654,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score);
} else {
paperTask.setScore("0.0");
paperTask.setScore("0");
}
} else {
String score = monitorMapper.selectByStuIdAndTaskIdNew(stuId, taskId);
if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score);
} else {
paperTask.setScore("0.0");
paperTask.setScore("0");
}
}

View File

@@ -28,28 +28,32 @@
select score
from exam_monitor
where stu_id = #{stuId}
and task_id = #{taskId}
and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
ORDER BY score DESC LIMIT 1
</select>
<select id="selectByStuIdAndTaskIdNew" resultType="java.lang.String">
select score
from exam_monitor
where stu_id = #{stuId}
and task_id = #{taskId}
and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
ORDER BY create_time DESC LIMIT 1
</select>
<select id="selectByStuIdAndTaskId" resultType="java.lang.String">
select task_id
from exam_monitor
where stu_id = #{stuId}
and exam_status !='2'
and exam_status !='2'
</select>
<select id="selectStuIdByTaskId" resultType="java.lang.String">
select stu_id
from exam_monitor
where task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
and deleted = '0'
and exam_status = '0'
</select>
<select id="selectTent" resultMap="TentSpecialyResult">
@@ -63,6 +67,14 @@
WHERE ets.tenant_id = #{loginTenantId}
</select>
<select id="selectCountByUserIdAndTaskId" resultType="java.lang.Integer">
select sum(counts)
from exam_monitor
where stu_id =#{stuId}
and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
</select>
</mapper>