|
@@ -3,11 +3,8 @@ package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordQuestionsRepo;
|
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamQuestionEntity;
|
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordQuestionsEntity;
|
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamRecordStatus;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamRecordStatus;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.MarkingType;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.MarkingType;
|
|
@@ -15,15 +12,11 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamStudentEffectiveScoreInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamStudentEffectiveScoreInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamStudentQuestionScoreInfo;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
-import org.springframework.jdbc.core.RowMapper;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.sql.ResultSet;
|
|
|
|
-import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -48,20 +41,6 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 考生作答成绩
|
|
|
|
- */
|
|
|
|
- private static final String EXAM_STUDENT_QUESTION_SCORE_SQL = "select " +
|
|
|
|
- "erd.id exam_record_data_id,co.`code` course_code,co.`name` course_name, ex.`name` exam_name" +
|
|
|
|
- ",erd.student_code,erd.base_paper_id " +
|
|
|
|
- "from ec_oe_exam_record_data erd " +
|
|
|
|
- "inner join ec_b_course co on erd.course_id=co.id " +
|
|
|
|
- "inner join ec_e_exam ex on erd.exam_id=ex.id " +
|
|
|
|
- "where 1=1 ";
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 构建查询 考试明细sql语句
|
|
* 构建查询 考试明细sql语句
|
|
*
|
|
*
|
|
@@ -209,36 +188,6 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<ExamStudentQuestionScoreInfo> getExamStudentQuestionScoreList(Long examId, String courseCode) {
|
|
|
|
- //最终返回的结果集
|
|
|
|
- List<ExamStudentQuestionScoreInfo> resultList = new ArrayList<ExamStudentQuestionScoreInfo>();
|
|
|
|
- //获取考试记录相关基本信息
|
|
|
|
- List<ExamStudentQuestionScoreInfo> partialExamStudentQuestionScoreList = getPartialExamStudentQuestionScoreList(examId, courseCode);
|
|
|
|
- List<Long> examRecordDataIdList = new ArrayList<Long>();
|
|
|
|
- if (partialExamStudentQuestionScoreList != null && !partialExamStudentQuestionScoreList.isEmpty()) {
|
|
|
|
- partialExamStudentQuestionScoreList.forEach(p -> examRecordDataIdList.add(p.getExamRecordDataId()));
|
|
|
|
- //批量查询考试记录数据
|
|
|
|
- List<ExamRecordQuestionsEntity> examRecordQuestionsList = examRecordQuestionsRepo.findByExamRecordDataIdIn(examRecordDataIdList);
|
|
|
|
- for (ExamStudentQuestionScoreInfo scoreInfo : partialExamStudentQuestionScoreList) {
|
|
|
|
- List<ExamRecordQuestionsEntity> filterExamRecordQuestionsList = examRecordQuestionsList.stream().filter(p -> p.getExamRecordDataId().equals(scoreInfo.getExamRecordDataId())).collect(Collectors.toList());
|
|
|
|
- if (examRecordQuestionsList != null && !examRecordQuestionsList.isEmpty()) {
|
|
|
|
- ExamRecordQuestionsEntity filterExamRecordQuestionsEntity = filterExamRecordQuestionsList.get(0);
|
|
|
|
- //当前考试记录中的所有考题成绩集合
|
|
|
|
- List<ExamQuestionEntity> examQuestionEntities = filterExamRecordQuestionsEntity.getExamQuestionEntities();
|
|
|
|
- if (examQuestionEntities != null && !examQuestionEntities.isEmpty()) {
|
|
|
|
- examQuestionEntities.forEach(qa -> {
|
|
|
|
- ExamStudentQuestionScoreInfo examStudentQuestionScoreInfo = buildExamStudentQuestionScore(scoreInfo, qa);
|
|
|
|
- resultList.add(examStudentQuestionScoreInfo);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return resultList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<ExamStudentEffectiveScoreInfo> getExamStudentEffectiveScoreList(String markingType, List<Long> examStudentIdList) {
|
|
public List<ExamStudentEffectiveScoreInfo> getExamStudentEffectiveScoreList(String markingType, List<Long> examStudentIdList) {
|
|
List<ExamStudentEffectiveScoreInfo> resultList = new ArrayList<>();
|
|
List<ExamStudentEffectiveScoreInfo> resultList = new ArrayList<>();
|
|
@@ -306,75 +255,4 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
return examScoreEntity;
|
|
return examScoreEntity;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 根据考试记录信息和考题信息构建完整 的考生考题作答记录
|
|
|
|
- *
|
|
|
|
- * @param scoreInfo
|
|
|
|
- * @param qa
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private ExamStudentQuestionScoreInfo buildExamStudentQuestionScore(ExamStudentQuestionScoreInfo scoreInfo,
|
|
|
|
- ExamQuestionEntity qa) {
|
|
|
|
- ExamStudentQuestionScoreInfo examStudentQuestionScoreInfo = new ExamStudentQuestionScoreInfo();
|
|
|
|
- examStudentQuestionScoreInfo.setExamRecordDataId(scoreInfo.getExamRecordDataId());
|
|
|
|
- examStudentQuestionScoreInfo.setCourseCode(scoreInfo.getCourseCode());
|
|
|
|
- examStudentQuestionScoreInfo.setCourseName(scoreInfo.getCourseName());
|
|
|
|
- examStudentQuestionScoreInfo.setExamName(scoreInfo.getExamName());
|
|
|
|
- examStudentQuestionScoreInfo.setStudentCode(scoreInfo.getStudentCode());
|
|
|
|
- examStudentQuestionScoreInfo.setBasePaperId(scoreInfo.getBasePaperId());
|
|
|
|
- examStudentQuestionScoreInfo.setMainNumber(qa.getMainNumber());
|
|
|
|
- examStudentQuestionScoreInfo.setOrder(qa.getOrder());
|
|
|
|
- examStudentQuestionScoreInfo.setStudentScore(qa.getStudentScore());
|
|
|
|
- examStudentQuestionScoreInfo.setStudentAnswer(qa.getStudentAnswer());
|
|
|
|
-
|
|
|
|
- // if (QuestionType.SINGLE_CHOICE == qa.getQuestionType() || QuestionType.MULTIPLE_CHOICE == qa.getQuestionType()) {
|
|
|
|
- // // 选择题 - 转换为新答案格式(兼容旧格式)
|
|
|
|
- // examStudentQuestionScoreInfo.setStudentAnswer(QuestionOptionHelper.parseNumbers(qa.getStudentAnswer()));
|
|
|
|
- // } else {
|
|
|
|
- // examStudentQuestionScoreInfo.setStudentAnswer(qa.getStudentAnswer());
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- return examStudentQuestionScoreInfo;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据考试id和课程代码获取学生考试成绩的部分信息
|
|
|
|
- *
|
|
|
|
- * @param examId 考试id
|
|
|
|
- * @param courseCode 课程代码
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private List<ExamStudentQuestionScoreInfo> getPartialExamStudentQuestionScoreList(Long examId, String courseCode) {
|
|
|
|
- //查询条件
|
|
|
|
- StringBuilder sqlBuilder = new StringBuilder();
|
|
|
|
- sqlBuilder.append(EXAM_STUDENT_QUESTION_SCORE_SQL);
|
|
|
|
- sqlBuilder.append(" and erd.exam_id=" + examId);
|
|
|
|
- sqlBuilder.append(" and co.`code`='" + courseCode + "'");
|
|
|
|
- List<ExamStudentQuestionScoreInfo> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamStudentQuestionScoreInfo>() {
|
|
|
|
- @Override
|
|
|
|
- public ExamStudentQuestionScoreInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
|
- return getExamStudentQuestionScoreInfoByResultSet(rs);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- return examRecordDataList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据结果集获取相应的实体对象
|
|
|
|
- *
|
|
|
|
- * @param rs
|
|
|
|
- * @return
|
|
|
|
- * @throws SQLException
|
|
|
|
- */
|
|
|
|
- private ExamStudentQuestionScoreInfo getExamStudentQuestionScoreInfoByResultSet(ResultSet rs) throws SQLException {
|
|
|
|
- ExamStudentQuestionScoreInfo info = new ExamStudentQuestionScoreInfo();
|
|
|
|
- info.setExamRecordDataId(rs.getLong("exam_record_data_id"));
|
|
|
|
- info.setCourseCode(rs.getString("course_code"));
|
|
|
|
- info.setCourseName(rs.getString("course_name"));
|
|
|
|
- info.setExamName(rs.getString("exam_name"));
|
|
|
|
- info.setStudentCode(rs.getString("student_code"));
|
|
|
|
- info.setBasePaperId(rs.getString("base_paper_id"));
|
|
|
|
- return info;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|