【新增】 1、交互接口,学生端定时与后台交互,获取交互时间存入缓存;2、更换PC答题,使用交互时间进行判断

This commit is contained in:
dlaren
2025-09-14 16:27:32 +08:00
parent 73b5d9c4c2
commit 196fef938f
10 changed files with 271 additions and 158 deletions

View File

@@ -135,7 +135,6 @@ public class EducationPaperPersonController {
} else { } else {
return CommonResult.error(DEMO03_PAPER_STUDENT_EXISTS); return CommonResult.error(DEMO03_PAPER_STUDENT_EXISTS);
} }
} }
/** /**

View File

@@ -81,4 +81,9 @@ public class MonitorDO extends BaseDO {
*/ */
private String startTime; private String startTime;
/**
* 交互时间
*/
private String interactiveTime;
} }

View File

@@ -21,8 +21,7 @@ import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
* @date 2025-04-15 * @date 2025-04-15
*/ */
@Mapper @Mapper
public interface EducationPaperMapper extends BaseMapperX<EducationPaper> public interface EducationPaperMapper extends BaseMapperX<EducationPaper> {
{
/** /**
* 查询试卷 * 查询试卷
* *
@@ -31,14 +30,19 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
*/ */
public EducationPaper selectEducationPaperByPaperId(String paperId); public EducationPaper selectEducationPaperByPaperId(String paperId);
/**
* 根据试卷编号查询试卷
* @param paperNum 试卷编号
* @return 试卷ID
*/
String selectPaperByPaperNum(String paperNum);
/** /**
* 查询试卷列表 * 查询试卷列表
* *
* @return 试卷集合 * @return 试卷集合
*/ */
// public List<EducationPaper> selectEducationPaperList(EducationPaper educationPaper); // public List<EducationPaper> selectEducationPaperList(EducationPaper educationPaper);
default PageResult<EducationPaper> selectEducationPaperList(PaperPageVo paperPageVo) { default PageResult<EducationPaper> selectEducationPaperList(PaperPageVo paperPageVo) {
return selectPage(paperPageVo, new LambdaQueryWrapperX<EducationPaper>() return selectPage(paperPageVo, new LambdaQueryWrapperX<EducationPaper>()
.likeIfPresent(EducationPaper::getTaskId, paperPageVo.getTaskId()) .likeIfPresent(EducationPaper::getTaskId, paperPageVo.getTaskId())
@@ -83,7 +87,6 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
public int deleteEducationPaperByPaperIds(@Param("paperIds") String[] paperIds); public int deleteEducationPaperByPaperIds(@Param("paperIds") String[] paperIds);
List<String> selectQuByPaperScheme(@Param("pointName") List<String> pointName List<String> selectQuByPaperScheme(@Param("pointName") List<String> pointName
, @Param("keywordList") List<String> keywordList , @Param("keywordList") List<String> keywordList
, @Param("educationPaperScheme") EducationPaperScheme educationPaperScheme , @Param("educationPaperScheme") EducationPaperScheme educationPaperScheme
@@ -91,8 +94,10 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
, @Param("tId") Long tId); , @Param("tId") Long tId);
String selectTaskIdByPaperId(String paperId); String selectTaskIdByPaperId(String paperId);
//查找方案下所有试卷id //查找方案下所有试卷id
List<String> selectPaperByTaskId(String taskId); List<String> selectPaperByTaskId(String taskId);
//根据试卷id批量设置试卷格式 //根据试卷id批量设置试卷格式
public int updateEducationByids(@Param("strings") List<String> strings); public int updateEducationByids(@Param("strings") List<String> strings);
@@ -104,15 +109,18 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
/** /**
* 根据试卷任务id查找试卷id集合 * 根据试卷任务id查找试卷id集合
*
* @param taskId * @param taskId
* @return * @return
*/ */
List<String> selectPaperByTaskIdAndRoll(@Param("taskId") String taskId); List<String> selectPaperByTaskIdAndRoll(@Param("taskId") String taskId);
//查找该方案所有的试卷 //查找该方案所有的试卷
List<EducationPaper> getPaperByTaskIdByType(String taskId); List<EducationPaper> getPaperByTaskIdByType(String taskId);
/** /**
* 查找选中方案下已分配的试卷 * 查找选中方案下已分配的试卷
*
* @param row * @param row
* @return * @return
*/ */
@@ -120,6 +128,7 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
/** /**
* 批量设置试卷抽卷方式(自选) * 批量设置试卷抽卷方式(自选)
*
* @param strings * @param strings
* @return * @return
*/ */
@@ -127,6 +136,7 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
/** /**
* 分局任务id查找任务下的 试卷 * 分局任务id查找任务下的 试卷
*
* @param taskId * @param taskId
* @return * @return
*/ */
@@ -134,12 +144,14 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
/** /**
* 批量插入试卷 * 批量插入试卷
*
* @param educationPapers * @param educationPapers
*/ */
void insertEducationPaperList(List<EducationPaper> educationPapers); void insertEducationPaperList(List<EducationPaper> educationPapers);
/** /**
* 改变试卷状态 * 改变试卷状态
*
* @param paperId * @param paperId
* @param status * @param status
* @return * @return
@@ -149,12 +161,14 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
/** /**
* 查找试卷个数 * 查找试卷个数
*
* @return * @return
*/ */
int selectCountPaperList(); int selectCountPaperList();
/** /**
* 查找试卷列表 * 查找试卷列表
*
* @param paperPageVo * @param paperPageVo
* @return * @return
*/ */
@@ -165,6 +179,7 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
.eq(EducationPaper::getStatus, 0) .eq(EducationPaper::getStatus, 0)
); );
} }
/** /**
* 根据方案获取试卷下拉 * 根据方案获取试卷下拉
*/ */

View File

@@ -194,7 +194,6 @@ public class MonitorServiceImpl implements MonitorService {
for (SpecialtyVo specialtyVo : taskInVo) { for (SpecialtyVo specialtyVo : taskInVo) {
String specialtyId = specialtyVo.getSpecialtyId(); String specialtyId = specialtyVo.getSpecialtyId();
if (!authSpecialtyIds.contains(specialtyId)) continue; if (!authSpecialtyIds.contains(specialtyId)) continue;
String specialtyName = specialtyVo.getSpecialtyName(); String specialtyName = specialtyVo.getSpecialtyName();
Integer currentCount = specialtyVo.getCounts(); Integer currentCount = specialtyVo.getCounts();
Integer authCount = authMap.getOrDefault(specialtyId, 0); Integer authCount = authMap.getOrDefault(specialtyId, 0);
@@ -238,13 +237,10 @@ public class MonitorServiceImpl implements MonitorService {
} }
} }
} }
if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) { if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) {
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId()); EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId());
String counts = educationPaper.getCounts(); String counts = educationPaper.getCounts();
int count = 0; int count = 0;
try { try {
count = Integer.parseInt(counts); count = Integer.parseInt(counts);
} catch (NumberFormatException | NullPointerException e) { } catch (NumberFormatException | NullPointerException e) {
@@ -255,14 +251,14 @@ public class MonitorServiceImpl implements MonitorService {
educationPaperMapper.updateById(educationPaper); educationPaperMapper.updateById(educationPaper);
info.setPaperNum(educationPaper.getNum()); info.setPaperNum(educationPaper.getNum());
} }
info.setExamStatus("1"); info.setExamStatus("1");
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatterNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
info.setStartTime(nowTime.format(formatter1)); info.setStartTime(nowTime.format(formatterNow));
// 考试考试的时候初始化交互时间为当前时间
info.setInteractiveTime(nowTime.format(formatterNow));
info.setTemporaryId(stuMonitorPaperVo.getTemporaryId()); info.setTemporaryId(stuMonitorPaperVo.getTemporaryId());
info.setIp(stuMonitorPaperVo.getIp()); info.setIp(stuMonitorPaperVo.getIp());
if (info.getRemainingTime() == null) { if (info.getRemainingTime() == null) {
stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info)); stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info));
monitorMapper.updateById(info); monitorMapper.updateById(info);
@@ -271,15 +267,12 @@ public class MonitorServiceImpl implements MonitorService {
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperVo.getTaskId()); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperVo.getTaskId());
//测评时长 //测评时长
Time examTime = educationPaperParam.getExamTime(); Time examTime = educationPaperParam.getExamTime();
//判断是否开启测评时长限制 //判断是否开启测评时长限制
//开启测评时长限制 开启场次 判断场次时间 ,,,,没开启测评时长限制 开启场次 -判断场次时间 //开启测评时长限制 开启场次 判断场次时间 ,,,,没开启测评时长限制 开启场次 -判断场次时间
if ("0".equals(educationPaperParam.getIsSession())) { if ("0".equals(educationPaperParam.getIsSession())) {
//获得场次开始时间, 结束时间 判断是否在 时间范围内 //获得场次开始时间, 结束时间 判断是否在 时间范围内
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuMonitorPaperVo.getTaskId(), stuMonitorPaperVo.getStuId()); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuMonitorPaperVo.getTaskId(), stuMonitorPaperVo.getStuId());
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId()); EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId());
if (educationPaperSession == null) { if (educationPaperSession == null) {
throw new MonitorSpecialtyException("未分配考场,请联系教师!"); throw new MonitorSpecialtyException("未分配考场,请联系教师!");
} }
@@ -291,17 +284,14 @@ public class MonitorServiceImpl implements MonitorService {
String allowEntry = educationPaperSession.getAllowEntry(); String allowEntry = educationPaperSession.getAllowEntry();
//开始考试后分钟,禁止入场 //开始考试后分钟,禁止入场
String endAllowEntry = educationPaperSession.getEndAllowEntry(); String endAllowEntry = educationPaperSession.getEndAllowEntry();
// 开始转换时间
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
LocalDateTime start = DateUtil.toLocalDateTime(startTime); LocalDateTime start = DateUtil.toLocalDateTime(startTime);
LocalDateTime end = DateUtil.toLocalDateTime(endTime); LocalDateTime end = DateUtil.toLocalDateTime(endTime);
// 考试开始前允许入场时间(分钟) // 考试开始前允许入场时间(分钟)
int allowEntryMin = Integer.parseInt(allowEntry); int allowEntryMin = Integer.parseInt(allowEntry);
// 考试开始后允许入场时间(分钟) // 考试开始后允许入场时间(分钟)
int endAllowEntryMin = Integer.parseInt(endAllowEntry); int endAllowEntryMin = Integer.parseInt(endAllowEntry);
// 入场允许范围: [start-allowEntryMin , end + endAllowEntryMin] // 入场允许范围: [start-allowEntryMin , end + endAllowEntryMin]
LocalDateTime entryStart = start.minusMinutes(allowEntryMin); LocalDateTime entryStart = start.minusMinutes(allowEntryMin);
LocalDateTime entryEnd = end.plusMinutes(endAllowEntryMin); LocalDateTime entryEnd = end.plusMinutes(endAllowEntryMin);
@@ -331,9 +321,7 @@ public class MonitorServiceImpl implements MonitorService {
info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay()); info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay());
stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info)); stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info));
monitorMapper.updateById(info); monitorMapper.updateById(info);
return (long) examTime.toLocalTime().toSecondOfDay(); return (long) examTime.toLocalTime().toSecondOfDay();
} }
return 0L; return 0L;
} }
@@ -350,9 +338,6 @@ public class MonitorServiceImpl implements MonitorService {
return false; return false;
} }
stringRedisTemplate.opsForValue().set(keychoice, JsonUtils.toJsonString(stuMonitorQuVo)); stringRedisTemplate.opsForValue().set(keychoice, JsonUtils.toJsonString(stuMonitorQuVo));
// 更新缓存
// redisTemplate.opsForValue().set(key, info);
// monitorMapper.updateById(info);
} }
return true; return true;
@@ -364,11 +349,9 @@ public class MonitorServiceImpl implements MonitorService {
String taskId = educationPaper.getTaskId(); String taskId = educationPaper.getTaskId();
String key = "userCache:" + taskId + ":" + stuMonitorPaperEndVo.getStuId(); String key = "userCache:" + taskId + ":" + stuMonitorPaperEndVo.getStuId();
// 获取学生分数 // 获取学生分数
StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(Long.valueOf(stuMonitorPaperEndVo.getStuId()), StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(Long.valueOf(stuMonitorPaperEndVo.getStuId()), stuMonitorPaperEndVo.getPaperId(), stuMonitorPaperEndVo.getTemporaryId());
stuMonitorPaperEndVo.getPaperId(),
stuMonitorPaperEndVo.getTemporaryId());
BigDecimal score = stuScoreVo.getScore(); BigDecimal score = stuScoreVo.getScore();
// 获取缓存
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class); MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
if (info != null) { if (info != null) {
long usedTime = info.getRemainingTime(); long usedTime = info.getRemainingTime();
@@ -382,15 +365,15 @@ public class MonitorServiceImpl implements MonitorService {
long remainingTime = duration.getSeconds() < 0 ? 0 : duration.getSeconds(); long remainingTime = duration.getSeconds() < 0 ? 0 : duration.getSeconds();
info.setRemainingTime(usedTime - remainingTime); info.setRemainingTime(usedTime - remainingTime);
} }
// 重置开始时间 // 重置开始时间&交互时间
if (info != null) { if (info != null) {
info.setStartTime(null); info.setStartTime(null);
info.setInteractiveTime(null);
} }
MonitorDO monitorDOs = null; MonitorDO monitorDOs = null;
if (info != null) { if (info != null) {
monitorDOs = getMonitor(info.getMonitorId()); monitorDOs = getMonitor(info.getMonitorId());
} }
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId);
if ("1".equals(educationPaperParam.getSaveGrades())) { if ("1".equals(educationPaperParam.getSaveGrades())) {

View File

@@ -222,9 +222,9 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
info.setPaperNum(""); info.setPaperNum("");
info.setTaskName(name); info.setTaskName(name);
info.setTaskType(educationPaperTask.getTaskType()); info.setTaskType(educationPaperTask.getTaskType());
info.setInteractiveTime(null);
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
monitorMapper.insert(info); monitorMapper.insert(info);
educationPaperPerson.setPersonId(studentId); educationPaperPerson.setPersonId(studentId);
educationPaperPerson.setSessionId(sessionId); educationPaperPerson.setSessionId(sessionId);
educationPaperPerson.setBatch(batch); educationPaperPerson.setBatch(batch);

View File

@@ -62,12 +62,10 @@ public class EducationPaperServiceImpl implements IEducationPaperService
private EducationPaperSchemeMapper educationPaperSchemeMapper; private EducationPaperSchemeMapper educationPaperSchemeMapper;
@Autowired @Autowired
private EducationPaperTaskMapper educationPaperTaskMapper; private EducationPaperTaskMapper educationPaperTaskMapper;
@Autowired @Autowired
private EducationPaperSessionMapper educationPaperSessionMapper; private EducationPaperSessionMapper educationPaperSessionMapper;
@Autowired @Autowired
private EducationPaperQuMapper educationPaperQuMapper; private EducationPaperQuMapper educationPaperQuMapper;
@Autowired @Autowired
private EducationPaperPersonMapper educationPaperPersonMapper; private EducationPaperPersonMapper educationPaperPersonMapper;
@@ -967,5 +965,10 @@ public class EducationPaperServiceImpl implements IEducationPaperService
} }
} }
@Override
public String selectPaperByPaperNum(String paperNum) {
return educationPaperMapper.selectPaperByPaperNum(paperNum);
}
} }

View File

@@ -130,5 +130,7 @@ public interface IEducationPaperService
void addPaperBypaper(PaperSubmitDTO dto); void addPaperBypaper(PaperSubmitDTO dto);
String selectPaperByPaperNum(String paperNum);
} }

View File

@@ -54,7 +54,20 @@
<sql id="selectEducationPaperVo"> <sql id="selectEducationPaperVo">
select paper_id, task_id, num,counts, paper_score,roll_up, is_ab, status ,create_time,update_time,creator,updater ,deleted from education_paper select paper_id,
task_id,
num,
counts,
paper_score,
roll_up,
is_ab,
status,
create_time,
update_time,
creator,
updater,
deleted
from education_paper
</sql> </sql>
@@ -62,6 +75,13 @@
<include refid="selectEducationPaperVo"/> <include refid="selectEducationPaperVo"/>
where paper_id = #{paperId} where paper_id = #{paperId}
</select> </select>
<select id="selectPaperByPaperNum" resultType="java.lang.String">
SELECT paper_id
FROM education_paper
WHERE num = #{paperNum}
</select>
<select id="selectQuByPaperScheme" resultType="java.lang.String"> <select id="selectQuByPaperScheme" resultType="java.lang.String">
SELECT qu_id SELECT qu_id
@@ -97,24 +117,42 @@
</select> </select>
<select id="selectTaskIdByPaperId" resultType="java.lang.String"> <select id="selectTaskIdByPaperId" resultType="java.lang.String">
select task_id from education_paper where paper_id=#{paperId} select task_id
from education_paper
where paper_id = #{paperId}
</select> </select>
<select id="selectPaperByTaskId" resultType="java.lang.String"> <select id="selectPaperByTaskId" resultType="java.lang.String">
select paper_id from education_paper where task_id=#{taskId} and deleted ='0' select paper_id
from education_paper
where task_id = #{taskId}
and deleted = '0'
</select> </select>
<select id="selectPaperRandomByTaskId" resultType="java.lang.String"> <select id="selectPaperRandomByTaskId" resultType="java.lang.String">
select paper_id from education_paper where task_id=#{taskId} and roll_up ='2' select paper_id
from education_paper
where task_id = #{taskId}
and roll_up = '2'
</select> </select>
<select id="selectPaperByTaskIdAndRoll" resultType="java.lang.String"> <select id="selectPaperByTaskIdAndRoll" resultType="java.lang.String">
select paper_id from education_paper where task_id=#{taskId} and deleted ='0' select paper_id
from education_paper
where task_id = #{taskId}
and deleted = '0'
</select> </select>
<select id="getPaperByTaskIdByType" resultMap="EducationPaperResult"> <select id="getPaperByTaskIdByType" resultMap="EducationPaperResult">
select * from education_paper where task_id=#{taskId} and status ='0' and deleted ='0' and roll_up IS NOT NULL select *
from education_paper
where task_id = #{taskId}
and status = '0'
and deleted = '0'
and roll_up IS NOT NULL
</select> </select>
<select id="getSelectPaperIdBySchemeIds" resultType="java.lang.String"> <select id="getSelectPaperIdBySchemeIds" resultType="java.lang.String">
select paper_id from education_paper_session where session_id =#{row} select paper_id
from education_paper_session
where session_id = #{row}
</select> </select>
<select id="selectPaperListByTaskId" resultMap="EducationPaperResult"> <select id="selectPaperListByTaskId" resultMap="EducationPaperResult">
@@ -122,13 +160,20 @@ select task_id from education_paper where paper_id=#{paperId}
where task_id =#{taskId} and deleted ='0' and status ='0' where task_id =#{taskId} and deleted ='0' and status ='0'
</select> </select>
<select id="selectCountPaperList" resultType="java.lang.Integer"> <select id="selectCountPaperList" resultType="java.lang.Integer">
select count(*) from education_paper select count(*)
from education_paper
</select> </select>
<select id="selectPaperIdAndNumByTaskId" resultMap="PaperIdAndNumResult"> <select id="selectPaperIdAndNumByTaskId" resultMap="PaperIdAndNumResult">
select paper_id ,num from education_paper where task_id=#{taskId} and deleted ='0' select paper_id, num
from education_paper
where task_id = #{taskId}
and deleted = '0'
</select> </select>
<select id="countPapersByTaskId" resultType="java.lang.Integer"> <select id="countPapersByTaskId" resultType="java.lang.Integer">
select count(*) from education_paper where task_id =#{taskId} and deleted ='0' select count(*)
from education_paper
where task_id = #{taskId}
and deleted = '0'
</select> </select>
<select id="selectTaskNumByids" resultType="java.lang.String"> <select id="selectTaskNumByids" resultType="java.lang.String">
select task_num from education_paper_task select task_num from education_paper_task
@@ -148,7 +193,8 @@ select task_id from education_paper where paper_id=#{paperId}
<select id="selctStuScoreByStuIdAndPaperId" resultType="java.lang.Double"> <select id="selctStuScoreByStuIdAndPaperId" resultType="java.lang.Double">
SELECT COALESCE(SUM(score), 0.0) SELECT COALESCE(SUM(score), 0.0)
FROM exam_stu_paper_score FROM exam_stu_paper_score
WHERE stu_id = #{stuId} AND paper_id = #{paperId} WHERE stu_id = #{stuId}
AND paper_id = #{paperId}
</select> </select>
@@ -191,7 +237,8 @@ select task_id from education_paper where paper_id=#{paperId}
INSERT INTO education_paper (paper_id, task_id,num ,counts,paper_score, roll_up, is_ab, status ) VALUES INSERT INTO education_paper (paper_id, task_id,num ,counts,paper_score, roll_up, is_ab, status ) VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
#{item.paperId}, #{item.taskId}, #{item.num},#{item.counts},#{item.paperScore}, #{item.rollUp}, #{item.isAb}, #{item.status} #{item.paperId}, #{item.taskId}, #{item.num},#{item.counts},#{item.paperScore}, #{item.rollUp},
#{item.isAb}, #{item.status}
) )
</foreach> </foreach>
</insert> </insert>
@@ -233,8 +280,10 @@ select task_id from education_paper where paper_id=#{paperId}
</update> </update>
<update id="updatePaperGuByRollup"> <update id="updatePaperGuByRollup">
UPDATE education_paper UPDATE education_paper
SET roll_up = null, is_ab = null SET roll_up = null,
where task_id=#{taskId} and roll_up ='1' is_ab = null
where task_id = #{taskId}
and roll_up = '1'
</update> </update>
<update id="updateEducationByidsThree"> <update id="updateEducationByidsThree">
UPDATE education_paper UPDATE education_paper
@@ -252,7 +301,9 @@ select task_id from education_paper where paper_id=#{paperId}
<delete id="deleteEducationPaperByPaperId" parameterType="String"> <delete id="deleteEducationPaperByPaperId" parameterType="String">
delete from education_paper where paper_id = #{paperId} delete
from education_paper
where paper_id = #{paperId}
</delete> </delete>
<delete id="deleteEducationPaperByPaperIds" parameterType="String"> <delete id="deleteEducationPaperByPaperIds" parameterType="String">
@@ -265,7 +316,4 @@ select task_id from education_paper where paper_id=#{paperId}
</delete> </delete>
</mapper> </mapper>

View File

@@ -28,20 +28,17 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo; import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo;
import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService; import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService;
import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService; import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService;
import pc.exam.pp.module.exam.service.paper.IEducationPaperService;
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService; import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService; import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService;
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.*; import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.*;
import pc.exam.pp.module.judgement.service.TaskManager; import pc.exam.pp.module.judgement.service.TaskManager;
import pc.exam.pp.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -76,6 +73,8 @@ public class AutoToolsController {
IEducationPaperQuService educationPaperQuService; IEducationPaperQuService educationPaperQuService;
@Resource @Resource
StuPaperFileService stuPaperFileService; StuPaperFileService stuPaperFileService;
@Resource
IEducationPaperService educationPaperService;
@GetMapping("/getStuScoreInfo") @GetMapping("/getStuScoreInfo")
@Operation(summary = "通过学生ID、试卷ID获取") @Operation(summary = "通过学生ID、试卷ID获取")
@@ -109,6 +108,34 @@ public class AutoToolsController {
return CommonResult.success(stuPaperScoreInfoVos); return CommonResult.success(stuPaperScoreInfoVos);
} }
/**
* 学生端进行交互
* @param taskId 方案ID
* @return 是否完成
*/
@GetMapping("/getStuSideStatus")
public CommonResult<Boolean> getStuSideStatus(@RequestParam("taskId") String taskId) {
// 获取登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (loginUser != null) {
// 获取ID
long userId = loginUser.getId();
// 通过方案ID获取学生考试状态
String key = "userCache:" + taskId + ":" + userId;
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
if (info != null) {
// 更新交互时间
LocalDateTime nowTime = LocalDateTime.now();
DateTimeFormatter formatterNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 考试考试的时候初始化交互时间为当前时间
info.setInteractiveTime(nowTime.format(formatterNow));
// 更新缓存
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
}
}
return CommonResult.success(true);
}
/** /**
* 开始考试 通过websocket进行传输时间 * 开始考试 通过websocket进行传输时间
* *
@@ -186,16 +213,33 @@ public class AutoToolsController {
// 学生端重新登录,判断是否上一次考试没有结束就退出了 // 学生端重新登录,判断是否上一次考试没有结束就退出了
@GetMapping("/reStartExamStatus") @GetMapping("/reStartExamStatus")
public CommonResult<String> reStartExamStatus() { public CommonResult<String> reStartExamStatus() {
HttpServletRequest request = ServletUtils.getRequest();
// 获取学生ID // 获取学生ID
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (loginUser != null) {
long userId = loginUser.getId(); long userId = loginUser.getId();
Set<String> userCaches = stringRedisTemplate.keys("userCache:*");
for (String userCache : userCaches) {
// 获取所有试卷的数据
Set<String> userCacheInfos = stringRedisTemplate.keys(userCache);
for (String userCacheInfo : userCacheInfos) {
MonitorDO monitorDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(userCacheInfo), MonitorDO.class);
if (monitorDO.getStuId().equals(String.valueOf(userId))) {
if (monitorDO.getExamStatus().equals("1")) {
// 说明考试没有结束
String key = taskManager.getTaskById(String.valueOf(userId)); String key = taskManager.getTaskById(String.valueOf(userId));
if (key == null) { if (key != null) {
return CommonResult.success(key);
} else {
// 通过试卷number查找试卷ID
String paperNum = monitorDO.getPaperNum();
String paperId = educationPaperService.selectPaperByPaperNum(paperNum);
key = loginUser.getId() + "_" + monitorDO.getTaskId() + "_" + paperId;
return CommonResult.success(key);
}
} else {
return CommonResult.success("0"); return CommonResult.success("0");
} }
return CommonResult.success(key); }
}
} }
return CommonResult.success("0"); return CommonResult.success("0");
} }
@@ -270,6 +314,7 @@ public class AutoToolsController {
} }
return CommonResult.error(1_0001_002,"没有找到对应的学生信息"); return CommonResult.error(1_0001_002,"没有找到对应的学生信息");
} }
/** /**
* 停止考试 * 停止考试
* *

View File

@@ -0,0 +1,13 @@
package pc.exam.pp.module.judgement.controller.admin.autoTools.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class StuSideReqVo {
@Schema(description = "试卷号")
private String taskId;
}