【修改】试题导入由名称改为id
This commit is contained in:
@@ -188,7 +188,7 @@ public class ExamQuestionController
|
||||
public CommonResult<QueImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<QuemportExcelVO> list = ExcelUtils.read(file, QuemportExcelVO.class);
|
||||
System.out.println(list);
|
||||
// System.out.println(list);
|
||||
return success(examQuestionService.importUserList(list, updateSupport));
|
||||
}
|
||||
|
||||
@@ -197,10 +197,9 @@ public class ExamQuestionController
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<QuemportExcelVO> list = Arrays.asList(
|
||||
QuemportExcelVO.builder().chapteridDictText("章节一").specialtyName("计算机专业").courseName("计算机基础")
|
||||
QuemportExcelVO.builder().specialtyName("计算机专业").courseName("计算机基础")
|
||||
.subjectName("选择题").quLevel("0、简单 1、一般 2、困难").analysis("解析").content("试题内容")
|
||||
.pointNames("知识点").keywords("").a("内容").b("内容").c("内容").d("内容").answer("A").build()
|
||||
);
|
||||
.chapteridDictText("第一章").pointNames("知识点").keywords("").a("内容").b("内容").c("内容").d("内容").answer("A").build());
|
||||
// 输出
|
||||
ExcelUtils.write(response, "试题导入模板.xls", "试题列表", QuemportExcelVO.class, list);
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@ public class TenantDto {
|
||||
@Min(value = 1, message = "每页条数最小值为 1")
|
||||
@Max(value = 100, message = "每页条数最大值为 100")
|
||||
private Integer pageSize = PAGE_SIZE;
|
||||
private Integer offset;
|
||||
|
||||
public Integer getOffset() {
|
||||
return (this.pageNo - 1) * this.pageSize;
|
||||
}
|
||||
|
@@ -102,46 +102,108 @@ public interface ExamQuestionMapper extends BaseMapperX<ExamQuestion>
|
||||
*/
|
||||
public int deleteExamQuestionByQuIds(@Param("ids") String[] ids);
|
||||
|
||||
/**
|
||||
* 批量查找试题
|
||||
* @param quIds
|
||||
* @return
|
||||
*/
|
||||
List<ExamQuestion> selectExamQuestionListByQuIds(List<String> quIds);
|
||||
|
||||
/**
|
||||
* 批量审核试题
|
||||
* @param quIds
|
||||
*/
|
||||
void setQuestionAuditByids(@Param("quIds")List<String> quIds);
|
||||
|
||||
/**
|
||||
* 查找学校集合(带分页)
|
||||
* @return
|
||||
*/
|
||||
List<TenantVo> getSchoolName(TenantDto tenantDto);
|
||||
|
||||
|
||||
long getSchoolNameTotal(TenantDto tenantDto);
|
||||
|
||||
int auditQueByIds(@Param("quIds")List<String> quIds,@Param("updater") String loginUserNickname);
|
||||
|
||||
/**
|
||||
* 批量审核试题
|
||||
* @param quIds
|
||||
*/
|
||||
int noAuditQue(@Param("quIds")List<String> quIds);
|
||||
|
||||
|
||||
/**
|
||||
* 根据试题id和租户id查找 试题
|
||||
* @param quId
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
ExamQuestion selectExamQuestionByQuIdAndTenantId(@Param("quId") String quId, @Param("source")Long source);
|
||||
|
||||
/**
|
||||
* 查找所有的mqtt通道
|
||||
* @return
|
||||
*/
|
||||
List<String> seleAllQueueName();
|
||||
|
||||
|
||||
/**
|
||||
* 更改试题审核的审核人和审核时间
|
||||
* @param loginUserNickname
|
||||
* @param quIds
|
||||
*/
|
||||
void updateExamQuestionByIds(@Param("updater") String loginUserNickname, @Param("quIds") List<String> quIds);
|
||||
|
||||
/**
|
||||
* 根据id查找试题
|
||||
* @param quId
|
||||
* @return
|
||||
*/
|
||||
ExamQuestion selectExamQuestionCountByQuId(String quId);
|
||||
|
||||
/**
|
||||
* 查找学校集合
|
||||
* @return
|
||||
*/
|
||||
List<TenantVo> getSchoolNameNaPage();
|
||||
|
||||
long selectTenantId();
|
||||
|
||||
|
||||
/**
|
||||
* 根据专业、课程、题型、试题内容查找 相同的试题
|
||||
* @param specialtyName 专业
|
||||
* @param courseName 课程
|
||||
* @param subjectName 题型
|
||||
* @param content 试题内容
|
||||
* @return
|
||||
*/
|
||||
ExamQuestion selectByTypes(@Param("specialtyName")String specialtyName
|
||||
,@Param("courseName") String courseName
|
||||
,@Param("subjectName") String subjectName
|
||||
,@Param("content") String content);
|
||||
|
||||
/**
|
||||
* 根据id查询学校名称
|
||||
* @param loginTenantId
|
||||
* @return
|
||||
*/
|
||||
String selectSchoolnameBytId(Long loginTenantId);
|
||||
|
||||
/**
|
||||
* 批量插入或更新试题
|
||||
* @param examQuestions
|
||||
*/
|
||||
void insertOrUpdateList(List<ExamQuestion> examQuestions);
|
||||
|
||||
|
||||
/**
|
||||
* 更改试题状态
|
||||
* @param quId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
boolean changeStatus(@Param("quId") String quId
|
||||
,@Param("status") String status);
|
||||
|
||||
/**
|
||||
* 查找试题表的试题数量
|
||||
* @return
|
||||
*/
|
||||
int selectCountQu();
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
|
||||
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
|
||||
|
||||
import java.util.List;
|
||||
@@ -108,4 +109,9 @@ public interface ExamSpecialtyMapper extends BaseMapperX<ExamSpecialty>
|
||||
ExamSpecialty selectBySpecCourseSub(@Param("specialtyName") String specialtyName
|
||||
,@Param("courseName") String courseName
|
||||
,@Param("subjectName") String subjectName);
|
||||
|
||||
ExamKnowledgePoints selectByPointsSub(@Param("specialtyName") String specialtyName
|
||||
, @Param("chapteridDictText")String chapteridDictText
|
||||
, @Param("pointNames") String pointNames);
|
||||
|
||||
}
|
||||
|
@@ -219,6 +219,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
|
||||
public int updateExamQuestion(ExamQuestion examQuestion)
|
||||
{
|
||||
|
||||
@@ -229,9 +230,9 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
List<String> excludedSubjects = Arrays.asList("程序设计", "网络题", "文件处理");
|
||||
//这三种题型的考点,在考点设置就已经做好,不需要在题目层更新
|
||||
if (!excludedSubjects.contains(examQuestion.getSubjectName())) {
|
||||
//先删除试题的答案
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
|
||||
if (answerList!=null&&answerList.size()>0){
|
||||
//先删除试题的答案
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
answerList.replaceAll(answer -> {
|
||||
answer.setAnswerId(IdUtils.simpleUUID());
|
||||
@@ -243,10 +244,10 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//先删除试题的文件
|
||||
sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
|
||||
if (fileUploads!=null&&fileUploads.size()>0){
|
||||
//先删除试题的答案
|
||||
sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
|
||||
|
||||
//赋值
|
||||
fileUploads.replaceAll(fileUpload -> {
|
||||
// 设置文件名(如果文件名为空)
|
||||
@@ -284,9 +285,9 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
questionScore.setQuId(examQuestion.getQuId());
|
||||
examQuestionScoreMapper.insertExamQuestionScore(questionScore);
|
||||
}
|
||||
//先删除试题的判分
|
||||
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
||||
//先删除试题的判分
|
||||
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||
@@ -543,6 +544,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
|
||||
@Override
|
||||
public PageResult<TenantVo> getSchoolName(TenantDto tenantDto) {
|
||||
tenantDto.setOffset(tenantDto.getOffset());
|
||||
List<TenantVo> schoolName = examQuestionMapper.getSchoolName(tenantDto);
|
||||
long total = examQuestionMapper.getSchoolNameTotal(tenantDto);
|
||||
PageResult<TenantVo> pageResult=new PageResult<>();
|
||||
@@ -760,6 +762,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
try {
|
||||
//校验 是否有 专业课程题型
|
||||
validateQueForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getCourseName(),importUser.getSubjectName());
|
||||
//检验是否有章节 知识点
|
||||
validatePointsForCreateOrUpdate(importUser.getSpecialtyName(),importUser.getChapteridDictText(),importUser.getPointNames(),importUser);
|
||||
//校验 选项
|
||||
validateChoice(importUser.getA(),importUser.getB(),importUser.getC(),importUser.getD(),importUser.getAnswer());
|
||||
|
||||
@@ -988,6 +992,21 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
}
|
||||
|
||||
|
||||
private void validatePointsForCreateOrUpdate(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) {
|
||||
validateSpecPointsSub(specialtyName,chapteridDictText,pointNames,quemportExcelVO);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateSpecPointsSub(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) {
|
||||
|
||||
ExamKnowledgePoints examKnowledgePoints= examSpecialtyMapper.selectByPointsSub(specialtyName,chapteridDictText,pointNames);
|
||||
if (examKnowledgePoints==null){
|
||||
throw exception(QESESTION_TYPE_POINTS_ERROR);
|
||||
}else {
|
||||
quemportExcelVO.setPointNames(String.valueOf(examKnowledgePoints.getSpId()));
|
||||
quemportExcelVO.setChapteridDictText(String.valueOf(examKnowledgePoints.getParentId()));
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateSpecCourseSub(String specialtyName, String courseName, String subjectName) {
|
||||
|
@@ -16,6 +16,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="roles" column="roles" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="ExamKnowledgePoints" id="KnowledgePointsResult">
|
||||
<result property="spId" column="sp_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="spName" column="sp_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="status" column="status" />
|
||||
<result property="treeNum" column="tree_num" />
|
||||
</resultMap>
|
||||
<sql id="selectExamSpecialtyVo">
|
||||
select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, roles,tenant_id from exam_specialty
|
||||
</sql>
|
||||
@@ -111,8 +120,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND q3.sp_name = #{subjectName}
|
||||
AND q1.deleted = '0'
|
||||
AND q2.deleted = '0'
|
||||
AND q3.deleted = '0';
|
||||
AND q3.deleted = '0'
|
||||
LIMIT 1;
|
||||
</select>
|
||||
<select id="selectByPointsSub" resultMap="KnowledgePointsResult">
|
||||
SELECT
|
||||
q3.*
|
||||
FROM exam_knowledge_points q1
|
||||
JOIN exam_knowledge_points q2 ON q2.parent_id = q1.sp_id
|
||||
JOIN exam_knowledge_points q3 ON q3.parent_id = q2.sp_id
|
||||
WHERE q1.sp_name = #{specialtyName}
|
||||
AND q2.sp_name = #{chapteridDictText}
|
||||
AND q3.sp_name = #{pointNames}
|
||||
AND q1.deleted = '0'
|
||||
AND q2.deleted = '0'
|
||||
AND q3.deleted = '0'
|
||||
LIMIT 1;
|
||||
</select>
|
||||
|
||||
|
||||
<update id="deleteExamSpecialtyBySpId" parameterType="Long">
|
||||
update exam_specialty
|
||||
|
Reference in New Issue
Block a user