【新增】 学生分数试卷绑定新增临时ID,方式同一学生同一试卷数据冲突
This commit is contained in:
@@ -34,6 +34,10 @@ public class StuPaperScoreDO extends TenantBaseDO {
|
|||||||
* 试卷ID
|
* 试卷ID
|
||||||
*/
|
*/
|
||||||
private String paperId;
|
private String paperId;
|
||||||
|
/**
|
||||||
|
* 临时ID,每次做题都会变
|
||||||
|
*/
|
||||||
|
private String temporaryId;
|
||||||
/**
|
/**
|
||||||
* 试题ID
|
* 试题ID
|
||||||
*/
|
*/
|
||||||
|
@@ -16,7 +16,7 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface StuPaperScoreMapper extends BaseMapperX<StuPaperScoreDO> {
|
public interface StuPaperScoreMapper extends BaseMapperX<StuPaperScoreDO> {
|
||||||
|
|
||||||
List<StuPaperScoreDO> findByStuIdAndPaperId(@Param("stuId") Long stuId, @Param("paperId") String paperId);
|
List<StuPaperScoreDO> findByStuIdAndPaperId(@Param("stuId") Long stuId, @Param("paperId") String paperId, @Param("temporaryId") String temporaryId);
|
||||||
|
|
||||||
List<StuScoreVo> getStuScore(@Param("stuId") Long stuId, @Param("paperId") String paperId);
|
List<StuScoreVo> getStuScore(@Param("stuId") Long stuId, @Param("paperId") String paperId);
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface StuPaperScoreService {
|
public interface StuPaperScoreService {
|
||||||
|
|
||||||
List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId);
|
List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId);
|
||||||
|
|
||||||
void insertStuPaperScore(StuPaperScoreDO stuPaperScoreDO);
|
void insertStuPaperScore(StuPaperScoreDO stuPaperScoreDO);
|
||||||
|
|
||||||
|
@@ -27,8 +27,8 @@ public class StuPaperScoreServiceImpl implements StuPaperScoreService {
|
|||||||
private EducationPaperMapper educationPaperMapper;
|
private EducationPaperMapper educationPaperMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId) {
|
public List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId) {
|
||||||
return stuPaperScoreMapper.findByStuIdAndPaperId(stuId, paperId);
|
return stuPaperScoreMapper.findByStuIdAndPaperId(stuId, paperId, temporaryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
-->
|
-->
|
||||||
<select id="findByStuIdAndPaperId" resultType="pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO">
|
<select id="findByStuIdAndPaperId" resultType="pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO">
|
||||||
SELECT * FROM exam_stu_paper_score WHERE stu_id = #{stuId} AND paper_id = #{paperId} order by sort ASC
|
SELECT * FROM exam_stu_paper_score WHERE stu_id = #{stuId} AND paper_id = #{paperId} AND paper_id = #{temporaryId} order by sort ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,8 +23,6 @@ import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSessionMapper;
|
|||||||
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
|
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.IEducationPaperSessionService;
|
|
||||||
import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService;
|
|
||||||
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
|
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuInTheExam;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuInTheExam;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
||||||
@@ -79,7 +77,7 @@ public class AutoToolsController {
|
|||||||
StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
||||||
stuPaperScoreInfoVos.setStuInfoReqVo(stuScoreVo);
|
stuPaperScoreInfoVos.setStuInfoReqVo(stuScoreVo);
|
||||||
// 3、查询学生试卷得分信息
|
// 3、查询学生试卷得分信息
|
||||||
stuPaperScoreInfoVos.setStuPaperScoreDOList(stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId()));
|
stuPaperScoreInfoVos.setStuPaperScoreDOList(stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId()));
|
||||||
// 4、查询学生试卷内容信息
|
// 4、查询学生试卷内容信息
|
||||||
List<String> quIds = educationPaperQuMapper.selectPaperQuByPaperId(stuPaperReqVo.getPaperId());
|
List<String> quIds = educationPaperQuMapper.selectPaperQuByPaperId(stuPaperReqVo.getPaperId());
|
||||||
List<ExamQuestion> examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
|
List<ExamQuestion> examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
|
||||||
@@ -92,7 +90,7 @@ public class AutoToolsController {
|
|||||||
// 一条一条进行查询试题,防止顺序错乱
|
// 一条一条进行查询试题,防止顺序错乱
|
||||||
stuPaperScoreInfoVos.setExamQuestionList(examQuestionList);
|
stuPaperScoreInfoVos.setExamQuestionList(examQuestionList);
|
||||||
// 5、查询学生试卷分析
|
// 5、查询学生试卷分析
|
||||||
List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId());
|
||||||
String judgementStr = "<p>试卷分析</p>";
|
String judgementStr = "<p>试卷分析</p>";
|
||||||
for (StuPaperScoreDO scoreDO : scoreDOS) {
|
for (StuPaperScoreDO scoreDO : scoreDOS) {
|
||||||
judgementStr += "<p>---------------------------------------</p>";
|
judgementStr += "<p>---------------------------------------</p>";
|
||||||
@@ -111,66 +109,69 @@ public class AutoToolsController {
|
|||||||
public CommonResult<String> startExam(@RequestBody StuInTheExam stuInTheExam) {
|
public CommonResult<String> startExam(@RequestBody StuInTheExam stuInTheExam) {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
String token = SecurityFrameworkUtils.obtainAuthorization(request,
|
String token = null;
|
||||||
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
if (request != null) {
|
||||||
// 获取登录用户
|
token = SecurityFrameworkUtils.obtainAuthorization(request,
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||||
// 通过token获取用户redis信息,获取refreshToken
|
// 获取登录用户
|
||||||
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class);
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
int startTime = 0;
|
// 通过token获取用户redis信息,获取refreshToken
|
||||||
if (oAuth2AccessTokenDO != null) {
|
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class);
|
||||||
String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
|
int startTime = 0;
|
||||||
// 查找对应的task
|
if (oAuth2AccessTokenDO != null) {
|
||||||
EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(stuInTheExam.getTaskId());
|
String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
|
||||||
String isSession = educationPaperParam.getIsSession();
|
// 查找对应的task
|
||||||
if (isSession.equals("0")) {
|
EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(stuInTheExam.getTaskId());
|
||||||
// 设置了场次
|
String isSession = educationPaperParam.getIsSession();
|
||||||
// 剩余时间需要继续计算
|
if (isSession.equals("0")) {
|
||||||
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuInTheExam.getTaskId(), String.valueOf(loginUser.getId()));
|
// 设置了场次
|
||||||
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId());
|
// 剩余时间需要继续计算
|
||||||
//结束时间
|
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuInTheExam.getTaskId(), String.valueOf(loginUser.getId()));
|
||||||
Date endTime = educationPaperSession.getEndTime();
|
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId());
|
||||||
Date nowTime = new Date();
|
//结束时间
|
||||||
// 将 Date 转换为 Instant
|
Date endTime = educationPaperSession.getEndTime();
|
||||||
Instant endInstant = endTime.toInstant();
|
Date nowTime = new Date();
|
||||||
Instant nowInstant = nowTime.toInstant();
|
// 将 Date 转换为 Instant
|
||||||
// 计算秒数差
|
Instant endInstant = endTime.toInstant();
|
||||||
long diffInSeconds = Duration.between(nowInstant, endInstant).getSeconds();
|
Instant nowInstant = nowTime.toInstant();
|
||||||
startTime = (int) diffInSeconds;
|
// 计算秒数差
|
||||||
} else {
|
long diffInSeconds = Duration.between(nowInstant, endInstant).getSeconds();
|
||||||
// 没有设置场次
|
startTime = (int) diffInSeconds;
|
||||||
// 剩余时间直接读取数据
|
|
||||||
String isTime = educationPaperParam.getIsTime();
|
|
||||||
if (isTime.equals("0")) {
|
|
||||||
// 设置了时间
|
|
||||||
// 剩余时间直接读取数据
|
|
||||||
long seconds = educationPaperParam.getExamTime().toLocalTime().toSecondOfDay();
|
|
||||||
startTime = (int) seconds;
|
|
||||||
} else {
|
} else {
|
||||||
// 没有设置时间 默认1小时 = 3600秒
|
// 没有设置场次
|
||||||
startTime = 3600;
|
// 剩余时间直接读取数据
|
||||||
|
String isTime = educationPaperParam.getIsTime();
|
||||||
|
if (isTime.equals("0")) {
|
||||||
|
// 设置了时间
|
||||||
|
// 剩余时间直接读取数据
|
||||||
|
long seconds = educationPaperParam.getExamTime().toLocalTime().toSecondOfDay();
|
||||||
|
startTime = (int) seconds;
|
||||||
|
} else {
|
||||||
|
// 没有设置时间 默认1小时 = 3600秒
|
||||||
|
startTime = 3600;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// 判断是否存在对应的场次
|
||||||
|
// 定时上传文件时间
|
||||||
|
String time = educationPaperParam.getUploadTime();
|
||||||
|
// 将分钟继续转换成秒
|
||||||
|
stuInTheExam.setTimes(Integer.parseInt(time) * 60);
|
||||||
|
// 倒计时
|
||||||
|
AtomicInteger countdown = new AtomicInteger(startTime);
|
||||||
|
// 创建初始返回数据
|
||||||
|
StuTheExamInfo stuTheExamInfo = new StuTheExamInfo();
|
||||||
|
// 返回数据-剩余时间
|
||||||
|
stuTheExamInfo.setTime(formatLongDuration(countdown.get()));
|
||||||
|
// 返回数据-上传文件状态 0:上传;1:不上传
|
||||||
|
stuTheExamInfo.setUpload(1);
|
||||||
|
// 返回数据-上传文件状态 0:结束;1:不结束
|
||||||
|
stuTheExamInfo.setEndStatus(1);
|
||||||
|
// 返回数据-网络状态
|
||||||
|
stuTheExamInfo.setNetwork("强");
|
||||||
|
// 创建对应的线程池
|
||||||
|
taskManager.startTask(stuInTheExam, stuTheExamInfo, refreshToken, countdown, new AtomicInteger(0));
|
||||||
|
return CommonResult.success(refreshToken);
|
||||||
}
|
}
|
||||||
// 判断是否存在对应的场次
|
|
||||||
// 定时上传文件时间
|
|
||||||
String time = educationPaperParam.getUploadTime();
|
|
||||||
// 将分钟继续转换成秒
|
|
||||||
stuInTheExam.setTimes(Integer.parseInt(time) * 60);
|
|
||||||
// 倒计时
|
|
||||||
AtomicInteger countdown = new AtomicInteger(startTime);
|
|
||||||
// 创建初始返回数据
|
|
||||||
StuTheExamInfo stuTheExamInfo = new StuTheExamInfo();
|
|
||||||
// 返回数据-剩余时间
|
|
||||||
stuTheExamInfo.setTime(formatLongDuration(countdown.get()));
|
|
||||||
// 返回数据-上传文件状态 0:上传;1:不上传
|
|
||||||
stuTheExamInfo.setUpload(1);
|
|
||||||
// 返回数据-上传文件状态 0:结束;1:不结束
|
|
||||||
stuTheExamInfo.setEndStatus(1);
|
|
||||||
// 返回数据-网络状态
|
|
||||||
stuTheExamInfo.setNetwork("强");
|
|
||||||
// 创建对应的线程池
|
|
||||||
taskManager.startTask(stuInTheExam, stuTheExamInfo, refreshToken, countdown, new AtomicInteger(0));
|
|
||||||
return CommonResult.success(refreshToken);
|
|
||||||
}
|
}
|
||||||
return CommonResult.success("未登录");
|
return CommonResult.success("未登录");
|
||||||
}
|
}
|
||||||
@@ -182,14 +183,17 @@ public class AutoToolsController {
|
|||||||
@GetMapping("/stopExam")
|
@GetMapping("/stopExam")
|
||||||
public CommonResult<Boolean> stopExam() {
|
public CommonResult<Boolean> stopExam() {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
String token = SecurityFrameworkUtils.obtainAuthorization(request,
|
String token = null;
|
||||||
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
if (request != null) {
|
||||||
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class);
|
token = SecurityFrameworkUtils.obtainAuthorization(request,
|
||||||
if (oAuth2AccessTokenDO != null) {
|
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||||
// 删除对应的线程池
|
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class);
|
||||||
String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
|
if (oAuth2AccessTokenDO != null) {
|
||||||
taskManager.stopTask(refreshToken);
|
// 删除对应的线程池
|
||||||
return CommonResult.success(true);
|
String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
|
||||||
|
taskManager.stopTask(refreshToken);
|
||||||
|
return CommonResult.success(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CommonResult.success(false);
|
return CommonResult.success(false);
|
||||||
}
|
}
|
||||||
@@ -199,6 +203,6 @@ public class AutoToolsController {
|
|||||||
int minutes = (totalSeconds % 3600) / 60;
|
int minutes = (totalSeconds % 3600) / 60;
|
||||||
int seconds = totalSeconds % 60;
|
int seconds = totalSeconds % 60;
|
||||||
|
|
||||||
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,5 +13,6 @@ public class StuPaperReqVo {
|
|||||||
@Schema(description = "试卷号")
|
@Schema(description = "试卷号")
|
||||||
private String paperId;
|
private String paperId;
|
||||||
|
|
||||||
|
@Schema(description = "临时ID")
|
||||||
|
private String temporaryId;
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ public class TaskManager {
|
|||||||
int minutes = (totalSeconds % 3600) / 60;
|
int minutes = (totalSeconds % 3600) / 60;
|
||||||
int seconds = totalSeconds % 60;
|
int seconds = totalSeconds % 60;
|
||||||
|
|
||||||
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user