diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/ExamDOController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/ExamDOController.java index 67ceee3..2551445 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/ExamDOController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/ExamDOController.java @@ -40,6 +40,18 @@ public class ExamDOController { @Autowired private IQuestionbankService iQuestionbankService; + @ApiOperation("试卷中增加题目") + @GetMapping("addQuestionByExamPaper") + public R addQuestionByExamPaper(Long id,Long pid){ + return R.ok(iExamCreateService.addPaperCreate(id,pid)); + } + + @ApiOperation("删除试卷中的试题") + @DeleteMapping("deleteQuestionByExamPaper") + public R deleteQuestionByExamPaper(Long id,Long pid){ + return R.ok(iExamCreateService.deletePaperCreate(id,pid)); + } + @ApiOperation("添加题目") @PostMapping("addQuestion") public R addQuestion(@RequestBody QuestionbankVo2 questionbankVo2){ @@ -64,6 +76,12 @@ public class ExamDOController { return R.ok(iExamDOService.selectExamDoList(pagenum,pagesize,subject,questiontype,difficulty)); } + @ApiOperation("题库列表(不分页)") + @GetMapping("selectListNotPage") + public R> selectListNotPage(){ + return R.ok(iExamDOService.selectListNotPage()); + } + @ApiOperation("预览") @GetMapping("preview") public R preview(Long id){ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/student/StudentExamPaperController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/student/StudentExamPaperController.java index a27d8ad..a6a167f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/student/StudentExamPaperController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/student/StudentExamPaperController.java @@ -63,7 +63,7 @@ public class StudentExamPaperController { @ApiOperation("试卷查询") @GetMapping("examPaperByTypeAndSubject") - public R> examPaperByTypeAndSubject(int pagenum,int pagesize,String type,String subject){ + public R> examPaperByTypeAndSubject(String type,String subject){ SysUser sysUser = SecurityUtils.getLoginUser().getUser(); Long id = sysUser.getUserId(); StudentClass studentClass = iStudentClassService.selectById(id); @@ -76,9 +76,6 @@ public class StudentExamPaperController { List list1 = new ArrayList<>(); for(ClassExamPaper classExamPaper : list ){ ExamPaper examPaper = iExamPaperService.selectById(classExamPaper.getId()); - if(examPaper.getExamPaperStatus()==0L){ - continue; - } if(type!=null&&!examPaper.getType().equals(type)){ continue; } @@ -103,10 +100,7 @@ public class StudentExamPaperController { examPaperDO1.setTotalscore(total); list1.add(examPaperDO1); } - Page page = new Page<>(pagenum,pagesize); - IPage iPage = new Page<>(page.getCurrent(),page.getSize(),page.getTotal()); - iPage.setRecords(list1); - return R.ok(iPage); + return R.ok(list1); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherAnswerSheetController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherAnswerSheetController.java index 112482e..a68ee89 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherAnswerSheetController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherAnswerSheetController.java @@ -101,6 +101,7 @@ public class TeacherAnswerSheetController { List list1 = iStudentClassService.getStudentClassByClassExamPaperList(list) .stream() .map(StudentClass::getStudentid) + .distinct() .collect(Collectors.toList()); return R.ok(iMarkedtestService.selectByStudentList(sysUser.getUserId(),list1)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherExamPaperController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherExamPaperController.java index 6bfd9ab..d8b475b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherExamPaperController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/test/teacher/TeacherExamPaperController.java @@ -10,6 +10,7 @@ import com.ruoyi.test.domain.ClassExamPaper; import com.ruoyi.test.domain.DO.*; import com.ruoyi.test.domain.ExamPaper; import com.ruoyi.test.domain.TeacherManageClass; +import com.ruoyi.test.domain.Vo.ExamPaperVo; import com.ruoyi.test.domain.Vo.QuestionbankVo1; import com.ruoyi.test.seriver.*; import io.swagger.annotations.Api; @@ -46,6 +47,18 @@ public class TeacherExamPaperController { @Autowired private IQuestionbankService iQuestionbankService; + @ApiOperation("创建试卷") + @PostMapping("newExamPaper") + public R addExamPaper(@RequestBody ExamPaper examPaper){ + System.out.println("============"+examPaper); + SysUser sysUser = SecurityUtils.getLoginUser().getUser(); + Long id = sysUser.getUserId(); + examPaper.setGlId(id); + examPaper.setStatus(0); + examPaper.setExamPaperStatus(0); + return R.ok(iExamPaperService.newExamPaper(examPaper)); + } + @ApiOperation("试卷题目获取") @GetMapping("getExamPaperQuestions") public R> getExamPaperQuestions(Long id){ diff --git a/ruoyi-test/src/main/java/com/ruoyi/test/mapper/ExamPaperMapper.java b/ruoyi-test/src/main/java/com/ruoyi/test/mapper/ExamPaperMapper.java index 312ea6d..09d60bc 100644 --- a/ruoyi-test/src/main/java/com/ruoyi/test/mapper/ExamPaperMapper.java +++ b/ruoyi-test/src/main/java/com/ruoyi/test/mapper/ExamPaperMapper.java @@ -3,6 +3,7 @@ package com.ruoyi.test.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.test.domain.DO.PaperCreateDO; import com.ruoyi.test.domain.ExamPaper; +import com.ruoyi.test.domain.Vo.ExamPaperVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -12,4 +13,6 @@ public interface ExamPaperMapper extends BaseMapper { int addPaperExam(@Param("paperCreateDO") PaperCreateDO paperCreateDO); int updateExamPaper(@Param("testid")Long testid); + + int newExamPaper(@Param("examPaper")ExamPaper examPaper); } diff --git a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamDOService.java b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamDOService.java index bb01602..0987368 100644 --- a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamDOService.java +++ b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamDOService.java @@ -28,4 +28,6 @@ public interface IExamDOService { int addfrQuestions(Questionbank questionbank); + List selectListNotPage(); + } diff --git a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamPaperService.java b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamPaperService.java index cac5333..b5225c0 100644 --- a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamPaperService.java +++ b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/IExamPaperService.java @@ -7,6 +7,7 @@ import com.ruoyi.test.domain.TeacherManageClass; import com.ruoyi.test.domain.TeacherSubject; import com.ruoyi.test.domain.Vo.ExamPaperVo; import com.ruoyi.test.domain.Vo.QuestionbankVo1; +import io.swagger.models.auth.In; //import com.ruoyi.test.domain.Vo.ExamCreateVo; import java.util.List; @@ -48,4 +49,5 @@ public interface IExamPaperService { List getExamPaperQuestions(Long id); + Integer newExamPaper(ExamPaper examPaper); } diff --git a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamDOServiceImpl.java b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamDOServiceImpl.java index f1f8208..c3805c5 100644 --- a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamDOServiceImpl.java +++ b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamDOServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.stereotype.Service; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -135,4 +136,23 @@ public class ExamDOServiceImpl extends ServiceImpl impleme return questionbankMapper.addExamCreate(questionbank); } + @Override + public List selectListNotPage() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + List list = questionbankMapper.selectList(queryWrapper); + List list1 = new ArrayList<>(); + for (Questionbank questionbank : list) { + QuestionbankVo2 questionbankVo2 = new QuestionbankVo2(); + BeanUtils.copyProperties(questionbank, questionbankVo2); + + Gson gson = new Gson(); + // 将 JSON 字符串转换为 List> + List> listMap = gson.fromJson(questionbank.getChance(), List.class); + questionbankVo2.setChance(listMap); + + list1.add(questionbankVo2); + } + return list1; + } + } diff --git a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamPaperServiceImpl.java b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamPaperServiceImpl.java index 8d0d86c..cbb884b 100644 --- a/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamPaperServiceImpl.java +++ b/ruoyi-test/src/main/java/com/ruoyi/test/seriver/Impl/ExamPaperServiceImpl.java @@ -223,6 +223,11 @@ public class ExamPaperServiceImpl extends ServiceImpl totalExamPaper(List list, List list2) { // List list1 = new ArrayList<>(); diff --git a/ruoyi-test/src/main/resources/mapper/ExamPaperMapper.xml b/ruoyi-test/src/main/resources/mapper/ExamPaperMapper.xml index 190f255..e1cb4d1 100644 --- a/ruoyi-test/src/main/resources/mapper/ExamPaperMapper.xml +++ b/ruoyi-test/src/main/resources/mapper/ExamPaperMapper.xml @@ -30,4 +30,28 @@ SET status = 1 WHERE id = #{testid} + + + insert into exam_paper( + gl_id, + grade, + subject, + name, + type, + time, + status, + exam_paper_status, + createtime + )values ( + #{examPaper.glId}, + #{examPaper.grade}, + #{examPaper.subject}, + #{examPaper.name}, + #{examPaper.type}, + #{examPaper.time}, + #{examPaper.status}, + #{examPaper.examPaperStatus}, + Now() + ) + diff --git a/ruoyi-test/src/main/resources/mapper/MarkedtestMapper.xml b/ruoyi-test/src/main/resources/mapper/MarkedtestMapper.xml index 4036082..9ba76cb 100644 --- a/ruoyi-test/src/main/resources/mapper/MarkedtestMapper.xml +++ b/ruoyi-test/src/main/resources/mapper/MarkedtestMapper.xml @@ -24,7 +24,7 @@ #{markedtest.tquestions}, #{markedtest.totalquestions}, #{markedtest.time}, - #{markedtest.finishtime} + #{markedtest.finishtime}, #{markedtest.status} ) diff --git a/vue2/vue/src/views/Student/Exam.vue b/vue2/vue/src/views/Student/Exam.vue index 02a66b7..294aa81 100644 --- a/vue2/vue/src/views/Student/Exam.vue +++ b/vue2/vue/src/views/Student/Exam.vue @@ -82,7 +82,7 @@ export default { components: {Aside, Header}, data() { return { - paperTypes: ["固定试卷","随机试卷"], // 试卷类型 + paperTypes: ["固定试卷","班级试卷"], // 试卷类型 subjects: ["语文", "数学"], // 学科 selectedType: "班级试卷", // 默认选中的试卷类型 selectedSubject: "语文", // 默认选中的学科 @@ -168,7 +168,7 @@ export default { return false; } }, - async fetchPapers(page = 1, size = 10) { + async fetchPapers() { const token = this.$store.state.tokens[this.userId]; if (!token) { alert("用户未登录,请重新登录!"); @@ -177,17 +177,10 @@ export default { } try { this.loading = true; - - // 确保 page 和 size 参数是有效的 - const pageNumber = page || 1; // 使用默认值 1 - const pageSize = size || 10; // 使用默认值 10 - const response = await axios.get( `http://localhost:8080/student/examPaper/examPaperByTypeAndSubject`, { params: { - pagenum: pageNumber, - pagesize: pageSize, // 确保传递 pagesize type: this.selectedType, // 类型 subject: this.selectedSubject, // 学科 }, @@ -197,13 +190,13 @@ export default { }, } ); - console.log("responser",response); + console.log("responser",response.data); if (response.data.code === 200) { - const { records } = response.data.data; + const data = response.data.data; const updatedRecords = await Promise.all( - records.map(async (record) => { + data.map(async (record) => { const hasTaken = await this.checkExamStatus(record.id); return { id: record.id, @@ -216,6 +209,7 @@ export default { }; }) ); + console.log("updatedRecords",updatedRecords); this.papers = updatedRecords; console.log("更新后的试卷数据:", updatedRecords); } else { diff --git a/vue2/vue/src/views/Student/ExamPaper.vue b/vue2/vue/src/views/Student/ExamPaper.vue index 5dfc202..6950c34 100644 --- a/vue2/vue/src/views/Student/ExamPaper.vue +++ b/vue2/vue/src/views/Student/ExamPaper.vue @@ -227,7 +227,7 @@ export default { // 检查是否有未作答的题目 const unanswered = this.questions.filter( - (q) => !this.answers[q.id] || (typeof this.answers[q.id] === 'string' && this.answers[q.id].trim() === "") + (q) => !this.answers[q.id] || (Array.isArray(this.answers[q.id]) && this.answers[q.id].length === 0) ); if (unanswered.length > 0) { @@ -237,6 +237,13 @@ export default { } } + if(this.remainingTime > 0){ + const confirmSubmit = confirm(`还有 ${Math.round(this.remainingTime / 60) } 分钟,是否仍然提交试卷?`); + if (!confirmSubmit) { + return; // 用户选择不提交,退出提交操作 + } + } + const answerList = Object.keys(this.answers).map((questionId) => ({ id: Number(questionId), answer: Array.isArray(this.answers[questionId]) diff --git a/vue2/vue/src/views/Teacher/Correct.vue b/vue2/vue/src/views/Teacher/Correct.vue index a1163dc..6af137e 100644 --- a/vue2/vue/src/views/Teacher/Correct.vue +++ b/vue2/vue/src/views/Teacher/Correct.vue @@ -161,7 +161,8 @@ export default { 'Content-Type': 'application/json', } }); - if (response.data.code == 200) { + console.log('response', response); + if (response.data.code === 200) { this.examPapers = response.data.data; this.filteredExamPapers = [...this.examPapers]; // Initially, show all exam papers console.log('examPapers', this.filteredExamPapers); diff --git a/vue2/vue/src/views/Teacher/TeacherExam.vue b/vue2/vue/src/views/Teacher/TeacherExam.vue index fe67c1b..6349161 100644 --- a/vue2/vue/src/views/Teacher/TeacherExam.vue +++ b/vue2/vue/src/views/Teacher/TeacherExam.vue @@ -1,33 +1,26 @@ +