diff --git a/pom.xml b/pom.xml index 6e96ac4..b4a3ad8 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,7 @@ spring-security-jwt 1.1.1.RELEASE + com.nimbusds nimbus-jose-jwt @@ -183,6 +184,12 @@ easyexcel 3.2.1 + + + org.python + jython-standalone + 2.7.2 + diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java index dd8412f..35f1320 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java +++ b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java @@ -21,9 +21,13 @@ public class Constant { public static final String INPUT_TYPE_TEACHER= "0"; public static final String INPUT_TYPE_BUILT_IN= "1"; - public static final String OBJECTIVE_TYPE_SINGLE= "single"; - public static final String OBJECTIVE_TYPE_Many= "many"; - public static final String OBJECTIVE_TYPE_JUDGE= "judge"; + public static final String OBJECTIVE_TYPE_SINGLE= "0"; + public static final String OBJECTIVE_TYPE_Many= "1"; + public static final String OBJECTIVE_TYPE_JUDGE= "2"; + + public static final String OBJECTIVE_TYPE_SINGLE_OTHER= "0.0"; + public static final String OBJECTIVE_TYPE_Many_OTHER= "1.0"; + public static final String OBJECTIVE_TYPE_JUDGE_OTHER= "2.0"; private String aaa="aaa"; diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java index 488166c..94b4441 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java @@ -1,13 +1,74 @@ package com.sztzjy.financial_bigdata.controller.stu; +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; +import com.sztzjy.financial_bigdata.entity.SysCaseQuestion; +import com.sztzjy.financial_bigdata.entity.SysCaseQuestionExample; +import com.sztzjy.financial_bigdata.entity.SysCaseQuestionStep; +import com.sztzjy.financial_bigdata.entity.SysCaseQuestionStepExample; +import com.sztzjy.financial_bigdata.mapper.SysCaseQuestionMapper; +import com.sztzjy.financial_bigdata.mapper.SysCaseQuestionStepMapper; +import com.sztzjy.financial_bigdata.service.tea.ITeaCaseStepService; +import com.sztzjy.financial_bigdata.util.ResultEntity; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import java.util.List; //实训演练-实训案例-实验实训 @RestController @Api(tags = "实训演练-实训案例-实验实训") @RequestMapping("api/stu/exercise/experimentalTrainingController") public class ExerciseExperimentalTraining { + @Autowired + SysCaseQuestionMapper caseQuestionMapper; + @Autowired + SysCaseQuestionStepMapper caseQuestionStepMapper; + @Autowired + ITeaCaseStepService stepService; + + //获取案例题基础信息 + @GetMapping("getCaseInfo") + @ApiOperation("获取案例题基础信息") + @AnonymousAccess + public ResultEntity getCaseInfo(@RequestParam String chapterId) { + SysCaseQuestionExample example = new SysCaseQuestionExample(); + example.createCriteria().andChapterIdEqualTo(chapterId); + List sysCaseQuestions = caseQuestionMapper.selectByExample(example); + return new ResultEntity<>(HttpStatus.OK, "获取案例题基础信息查询成功", sysCaseQuestions.get(0)); + } + + //获取案例题步骤基础信息 + //判断是否需要回显、如果学生实训表中 实验实训步骤sort存在、则返回学生答案 + @GetMapping("getCaseStepInfo") + @ApiOperation("获取案例题步骤基础信息") + @AnonymousAccess + public ResultEntity> getCaseStepInfo(@RequestParam String caseId) { + SysCaseQuestionStepExample example = new SysCaseQuestionStepExample(); + example.createCriteria().andCaseIdEqualTo(caseId); + List stepList = caseQuestionStepMapper.selectByExample(example); + for (int i = 0; i < stepList.size(); i++) { + stepList.get(0).setAnswer(""); + stepList.get(0).setAnswerOriginal(""); + } + return new ResultEntity<>(HttpStatus.OK, "获取案例题基础信息查询成功", stepList); + } + + //提交案例题 + @PostMapping("commitCase") + @ApiOperation("提交案例题") + @AnonymousAccess + public ResultEntity getCaseStepInfo(@ApiParam("将学生答案传递到answer中") @RequestParam SysCaseQuestionStep caseQuestionStep) { + + //执行记录操作 + Boolean flag = stepService.commitCase(caseQuestionStep); + return new ResultEntity<>(HttpStatus.OK, "回答正确、该步骤提交成功"); + + } + + //python在线运行 } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/PythonController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/PythonController.java new file mode 100644 index 0000000..5b03195 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/PythonController.java @@ -0,0 +1,49 @@ +package com.sztzjy.financial_bigdata.controller.stu;// 后端代码 + +import com.sztzjy.financial_bigdata.util.ResultEntity; +import org.python.core.CompileMode; +import org.python.core.Py; +import org.python.core.PyCode; +import org.python.util.PythonInterpreter; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +@RestController +@RequestMapping("/api/python") +public class PythonController { + + @PostMapping("/validate") + public ResultEntity validatePythonCode(@RequestBody String code) { + // 对 Python 代码进行检验 + PythonInterpreter interpreter = new PythonInterpreter(); + try { + InputStream stream = new ByteArrayInputStream(code.getBytes()); + PyCode pyCode = Py.compile(stream, "", CompileMode.exec); + interpreter.exec(pyCode); + return new ResultEntity<>(HttpStatus.OK, "语法正确"); + } catch (Exception e) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "语法有误",e.getMessage()); + } + } + + public static void main(String[] args) { + String code="if True:\n" + + " print (\"True\")\n" + + "else:\n" + + " print (\"False\")\n"; + PythonInterpreter interpreter = new PythonInterpreter(); + try { + InputStream stream = new ByteArrayInputStream(code.getBytes()); + PyCode pyCode = Py.compile(stream, "", CompileMode.exec); + interpreter.exec(pyCode); + + System.out.println("2"); + } catch (Exception e) { + System.out.println(e.getMessage()); } + } + + +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java index fe2e203..1025d20 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java @@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import java.util.Date; import java.util.List; @RestController @@ -36,11 +37,23 @@ public class TheoryTestController { @AnonymousAccess public ResultEntity> startTheoryTest(@RequestParam String userId) { List list=theoryTestService.startTheoryTest(userId); + for (int i = 0; i < list.size(); i++) { + list.get(i).setSchoolId(String.valueOf(i+1)); + } return new ResultEntity<>(HttpStatus.OK, "开始考试、客观题列表查询成功",list); } + //获取理论考试开始时间 + @GetMapping("getStartTime") + @ApiOperation("获取理论考试开始时间") + @AnonymousAccess + public ResultEntity getStartTime(@RequestParam String userId){ + Date date=theoryTestService.getStartTime(userId); + return new ResultEntity<>(HttpStatus.OK, "获取理论考试开始时间成功",date); + } + //结束考试 - @GetMapping("endTheoryTest") + @PostMapping("endTheoryTest") @ApiOperation("结束考试 学生自动点击交卷、前端检查时间到了也发送请求") @AnonymousAccess public ResultEntity endTheoryTest(@RequestBody StuTheoryTestDto theoryTestDto) { @@ -58,8 +71,12 @@ public class TheoryTestController { //错题集展示 @GetMapping("selectErrors") @ApiOperation("错题集展示") + @AnonymousAccess public ResultEntity> selectErrors(@RequestParam String userId){ List list=theoryTestService.selectErrors(userId); + for (int i = 0; i < list.size(); i++) { + list.get(i).setSchoolId(String.valueOf(i+1)); + } if(list==null){ return new ResultEntity<>(HttpStatus.OK, "没有错题",null); } @@ -69,9 +86,10 @@ public class TheoryTestController { //移除错题集 @GetMapping("removeError") @ApiOperation("移除错题集") + @AnonymousAccess public ResultEntity removeError(@RequestParam String userId, @ApiParam("客观题id")@RequestParam String objectiveQuestionId, - @ApiParam("题目类型 single、many、judge")@RequestParam String type){ + @ApiParam("题目类型 0、1、2")@RequestParam String type){ Boolean flag=theoryTestService.removeError(userId,objectiveQuestionId,type); if(flag){ return new ResultEntity<>(HttpStatus.OK, "移除错题集成功"); @@ -83,6 +101,7 @@ public class TheoryTestController { //考试记录查询 @GetMapping("getTheoryTestList") @ApiOperation("获取理论考试数据集") + @AnonymousAccess public ResultEntity> getTheoryTestList(@RequestParam String userId, @RequestParam Integer index, @RequestParam Integer size){ @@ -93,6 +112,7 @@ public class TheoryTestController { //考试记录详情查询 @GetMapping("getTheoryTestDetail") @ApiOperation("获取理论考试数据详情") + @AnonymousAccess public ResultEntity> getTheoryTestDetail(@ApiParam("理论考试id")@RequestParam String theoryExamId, @RequestParam Integer index, @RequestParam Integer size){ @@ -100,9 +120,10 @@ public class TheoryTestController { return new ResultEntity<>(HttpStatus.OK, "获取理论考试数据详情成功",detailDtoList); } - //答题次数、平均正确率、排名(理论考试记录) + //答题次数、平均正确率、排名(理论考试记录) ************ @GetMapping("getTheoryRecord") @ApiOperation("获取理论考试记录数据") + @AnonymousAccess public ResultEntity getTheoryRecord(String userId){ StuTheoryRecord stuTheoryRecord = recordMapper.selectByPrimaryKey(userId); return new ResultEntity<>(HttpStatus.OK, "获取理论考试记录数据成功",stuTheoryRecord); diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java index c5a9480..6fe9fb2 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaCaseController.java @@ -1,8 +1,11 @@ package com.sztzjy.financial_bigdata.controller.tea; import com.github.pagehelper.PageInfo; +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.config.Constant; import com.sztzjy.financial_bigdata.entity.SysCaseQuestion; +import com.sztzjy.financial_bigdata.entity.SysCourse; +import com.sztzjy.financial_bigdata.entity.SysCourseChapter; import com.sztzjy.financial_bigdata.service.tea.ITeaCaseService; import com.sztzjy.financial_bigdata.util.ResultEntity; import io.swagger.annotations.Api; @@ -106,4 +109,32 @@ public class TeaCaseController { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例题更新失败"); } } + + + //案例题库选择课程名展示 + @GetMapping("selectAllCourse") + @ApiOperation("案例题库选择课程名展示") + @AnonymousAccess + public ResultEntity> selectAllCourse(@RequestParam String schoolId){ + List list=caseService.selectAllCourseName(schoolId); + return new ResultEntity<>(HttpStatus.OK, "案例题库选择课程名展示成功",list); + } + + //案例题库选择章节名展示 + @GetMapping("selectChapterByCourseId") + @ApiOperation("案例题库选择章节名展示") + @AnonymousAccess + public ResultEntity> selectChapterByCourseId(@ApiParam("课程id")@RequestParam String courseId){ + List list=caseService.selectChapterByCourseId(courseId); + return new ResultEntity<>(HttpStatus.OK, "案例题库选择章节名展示成功",list); + } + + //案例题库内容展示 + @GetMapping("selectAllCaseByChapterId") + @ApiOperation("案例题库选择案例题内容展示") + @AnonymousAccess + public ResultEntity> selectAllCaseByChapterId(@RequestParam String chapterId){ + List list=caseService.selectAllCaseByChapterId(chapterId); + return new ResultEntity<>(HttpStatus.OK, "案例题库选择案例题内容展示成功",list); + } } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java index b4446c9..df0cb5a 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaObjectiveController.java @@ -1,6 +1,7 @@ package com.sztzjy.financial_bigdata.controller.tea; import com.github.pagehelper.PageInfo; +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion; import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService; import com.sztzjy.financial_bigdata.util.ResultEntity; @@ -35,6 +36,7 @@ public class TeaObjectiveController { //客观题新增 @PostMapping("insertObjective") @ApiOperation("客观题新增") + @AnonymousAccess public ResultEntity insertObjective(@RequestBody SysObjectiveQuestion objectiveQuestion) { Boolean flag = teaObjectiveService.insertObjective(objectiveQuestion); if (flag) { @@ -47,6 +49,7 @@ public class TeaObjectiveController { //客观题删除 @GetMapping("/batchDeleteObjective") @ApiOperation("客观题批量删除") + @AnonymousAccess public ResultEntity batchDeleteObjective(@ApiParam("客观题IDList") @RequestParam List objectiveIdList, @RequestParam String schoolId) { Boolean flag = teaObjectiveService.batchDeleteObjective(objectiveIdList,schoolId); @@ -60,6 +63,7 @@ public class TeaObjectiveController { //客观题列表查看 @GetMapping("/selectObjectiveList") @ApiOperation("客观题列表查看") + @AnonymousAccess public ResultEntity> selectObjectiveList(@RequestParam String schoolId, @ApiParam("课程ID") @RequestParam String courseId, @ApiParam("题目类型 single单选 many多选 judge判断")@RequestParam(required = false)String type, @@ -73,6 +77,7 @@ public class TeaObjectiveController { //客观题单个详情查看 @GetMapping("/selectObjectiveDetails") @ApiOperation("客观题单个详情查看") + @AnonymousAccess public ResultEntity selectObjectiveDetails(@ApiParam("客观题ID") @RequestParam String objectiveId){ SysObjectiveQuestion objectiveQuestion=teaObjectiveService.selectObjectiveDetails(objectiveId); return new ResultEntity<>(HttpStatus.OK, "客观题删除成功",objectiveQuestion); @@ -81,6 +86,7 @@ public class TeaObjectiveController { //客观题导入模板下载 @GetMapping("downloadResource") @ApiOperation("客观题导入模板下载") + @AnonymousAccess public void downloadResource(HttpServletResponse response) { fileUtil.download(response, "客观题导入模板.xlsx", filePath); } @@ -88,6 +94,7 @@ public class TeaObjectiveController { //客观题批量导入 @ApiOperation(value = "以导入excel方式") @PostMapping(value = "/insertObjectiveByExcel") + @AnonymousAccess public ResultEntity insertObjectiveByExcel(@RequestParam MultipartFile file, @RequestParam String schoolId) { if (file == null) { diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java index d246ea3..23ae202 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java @@ -32,7 +32,7 @@ public interface StuClassMapper { int updateByPrimaryKey(StuClass record); - @Select("SELECT DISTINCT s.class_name, s.class_id FROM stu_class s, stu_users u WHERE #{schoolId}= u.school_id;") + @Select("SELECT DISTINCT s.class_name, s.class_id FROM stu_class s, stu_userinfo u WHERE #{schoolId}= u.school_id;") List> selectAllClassNameBySchoolId(@Param("schoolId")String schoolId); @Select("SELECT s.class_name FROM stu_class s, stu_userinfo u WHERE s.class_id = u.class_id and s.class_id = #{classId};") diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCaseQuestionMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCaseQuestionMapper.java index 4d5dd82..cb609be 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCaseQuestionMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCaseQuestionMapper.java @@ -6,6 +6,8 @@ import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + @Mapper public interface SysCaseQuestionMapper { long countByExample(SysCaseQuestionExample example); @@ -29,4 +31,10 @@ public interface SysCaseQuestionMapper { int updateByPrimaryKeySelective(SysCaseQuestion record); int updateByPrimaryKey(SysCaseQuestion record); + + @Select(" SELECT course_id FROM sys_course WHERE school_id = #{schoolId} order by sequence") + List selectAllCourseNameBySchoolId(String schoolId); + + @Select(" SELECT course_id FROM sys_course WHERE school_id in (#{builtInSchoolId},#{schoolId}) order by sequence") + List selectAllCourseNameBySchoolIdS(String schoolId, String builtInSchoolId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysObjectiveQuestionMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysObjectiveQuestionMapper.java index e875535..e5b69b7 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysObjectiveQuestionMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysObjectiveQuestionMapper.java @@ -38,8 +38,13 @@ public interface SysObjectiveQuestionMapper { List selectRandomObjective(@Param("chapterId")String chapterId); - List selectRandomObjective100(); @Select("SELECT count(type) FROM sys_objective_question WHERE school_id in (999999999,#{schoolId}) group BY type") List getIndexTheoryTest(@Param("schoolId")String schoolId); + + List selectRandomObjectiveSingle(); + + List selectRandomObjectiveMany(); + + List selectRandomObjectiveJudge(); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java index 8287245..0ee7218 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java @@ -6,6 +6,7 @@ import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion; import com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryExamDetailDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryTestDto; +import java.util.Date; import java.util.List; public interface ITheoryTestService { @@ -20,4 +21,6 @@ public interface ITheoryTestService { PageInfo getTheoryTestList(String userId, Integer index, Integer size); List getTheoryTestDetail(String theoryExamId, Integer index, Integer size); + + Date getStartTime(String userId); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java index a2a7a16..671e891 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java @@ -87,6 +87,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService { stuTheoryRecord.setName(stuUser.getName()); stuTheoryRecord.setStudentId(stuUser.getStudentId()); stuTheoryRecord.setExamCount(0); + theoryRecordMapper.insert(stuTheoryRecord); } } @@ -127,7 +128,13 @@ public class TheoryTestServiceImpl implements ITheoryTestService { //随机生成100分题目 public List GenerateTest(String userId) { - List objectiveQuestionList = objectiveQuestionMapper.selectRandomObjective100(); + List objectiveQuestionList1 = objectiveQuestionMapper.selectRandomObjectiveSingle(); + List objectiveQuestionList2 = objectiveQuestionMapper.selectRandomObjectiveMany(); + List objectiveQuestionList3 = objectiveQuestionMapper.selectRandomObjectiveJudge(); + List objectiveQuestionList=new ArrayList<>(); + objectiveQuestionList.addAll(objectiveQuestionList1); + objectiveQuestionList.addAll(objectiveQuestionList2); + objectiveQuestionList.addAll(objectiveQuestionList3); List singleIdList = new ArrayList<>(); List manyIdList = new ArrayList<>(); List judgeIdList = new ArrayList<>(); @@ -171,9 +178,12 @@ public class TheoryTestServiceImpl implements ITheoryTestService { list.addAll(theoryTestDto.getSingleErrorIds()); list.addAll(theoryTestDto.getMultipleErrorIds()); list.addAll(theoryTestDto.getJudgeErrorIds()); + stuTheoryExam.setSingleStuAnswer(String.valueOf(theoryTestDto.getSingleStuAnswer())); + stuTheoryExam.setMultipleStuAnswer(String.valueOf(theoryTestDto.getMultipleStuAnswer())); + stuTheoryExam.setJudgeStuAnswer(String.valueOf(theoryTestDto.getJudgeStuAnswer())); stuTheoryExam.setErrorIds(list.toString()); stuTheoryExam.setAnswered(true); - int i = theoryExamMapper.updateByPrimaryKey(stuTheoryExam); + int i = theoryExamMapper.updateByPrimaryKeyWithBLOBs(stuTheoryExam); //更新错题集 StuErrorExample errorExample = new StuErrorExample(); @@ -368,5 +378,25 @@ public class TheoryTestServiceImpl implements ITheoryTestService { return detailDtos; } + @Override + public Date getStartTime(String userId) { + StuTheoryExamExample example = new StuTheoryExamExample(); + example.createCriteria().andUserIdEqualTo(userId); + example.setOrderByClause("exam_time DESC"); + List stuTheoryExams = theoryExamMapper.selectByExampleWithBLOBs(example); + if (stuTheoryExams.isEmpty()) { //之前没有进行考试 + return null; + } else { //根据考试时间排序 查询最近的一条 + StuTheoryExamWithBLOBs stuTheoryExam = stuTheoryExams.get(0); + Date currentTime = new Date(); + Date twoHoursAgo = new Date(currentTime.getTime() - (2 * 60 * 60 * 1000)); // 当前时间减去两个小时 + if (stuTheoryExam.getExamTime().before(twoHoursAgo)) { //已超出两个小时 从新生成新试卷 + return null; + } else { //在两个小时内 返回最近的一条试卷 + return stuTheoryExam.getExamTime(); + } + } + } + } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseService.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseService.java index 864b9c1..9bdf5ef 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseService.java @@ -2,6 +2,8 @@ package com.sztzjy.financial_bigdata.service.tea; import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.entity.SysCaseQuestion; +import com.sztzjy.financial_bigdata.entity.SysCourse; +import com.sztzjy.financial_bigdata.entity.SysCourseChapter; import java.util.List; @@ -17,4 +19,10 @@ public interface ITeaCaseService { Boolean unmountStatusCase(String caseId, Boolean unmountStatus); Boolean updateCase(SysCaseQuestion caseQuestion); + + List selectAllCourseName(String schoolId); + + List selectChapterByCourseId(String courseId); + + List selectAllCaseByChapterId(String chapterId); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java index 6476d4e..6775b9b 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaCaseStepService.java @@ -14,4 +14,6 @@ public interface ITeaCaseStepService { Boolean deleteCaseStep(String caseStepId, String schoolId); SysCaseQuestionStep selectCaseStepDetails(String caseStepId); + + Boolean commitCase(SysCaseQuestionStep caseQuestionStep); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseServiceImpl.java index d60cca8..710c963 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseServiceImpl.java @@ -3,10 +3,10 @@ package com.sztzjy.financial_bigdata.service.tea.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.config.Constant; -import com.sztzjy.financial_bigdata.entity.SysCaseQuestion; -import com.sztzjy.financial_bigdata.entity.SysCaseQuestionExample; -import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion; +import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.mapper.SysCaseQuestionMapper; +import com.sztzjy.financial_bigdata.mapper.SysCourseChapterMapper; +import com.sztzjy.financial_bigdata.mapper.SysCourseMapper; import com.sztzjy.financial_bigdata.service.tea.ITeaCaseService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +20,10 @@ import java.util.UUID; public class TeaCaseServiceImpl implements ITeaCaseService { @Autowired SysCaseQuestionMapper caseQuestionMapper; + @Autowired + SysCourseMapper courseMapper; + @Autowired + SysCourseChapterMapper courseChapterMapper; @Override public Boolean insertCase(SysCaseQuestion caseQuestion) { caseQuestion.setCaseId(String.valueOf(UUID.randomUUID())); @@ -95,5 +99,41 @@ public class TeaCaseServiceImpl implements ITeaCaseService { return i==1; } + @Override + public List selectAllCourseName(String schoolId) { + ArrayList returnList = new ArrayList<>(); + if(Constant.BUILT_IN_SCHOOL_ID.equals(schoolId)){ + List list=caseQuestionMapper.selectAllCourseNameBySchoolId(schoolId); + for (int i = 0; i < list.size(); i++) { + SysCourse sysCourse = courseMapper.selectByPrimaryKey(list.get(i)); + returnList.add(sysCourse); + } + }else { + List list=caseQuestionMapper.selectAllCourseNameBySchoolIdS(schoolId,Constant.BUILT_IN_SCHOOL_ID); + for (int i = 0; i < list.size(); i++) { + SysCourse sysCourse = courseMapper.selectByPrimaryKey(list.get(i)); + returnList.add(sysCourse); + } + } + return returnList; + } + + @Override + public List selectChapterByCourseId(String courseId) { + SysCourseChapterExample example = new SysCourseChapterExample(); + example.createCriteria().andCourseIdEqualTo(courseId); + List chapterList = courseChapterMapper.selectByExample(example); + example.setOrderByClause("sequence DESC"); + return chapterList; + } + + @Override + public List selectAllCaseByChapterId(String chapterId) { + SysCaseQuestionExample example = new SysCaseQuestionExample(); + example.createCriteria().andChapterIdEqualTo(chapterId); + List sysCaseQuestions = caseQuestionMapper.selectByExample(example); + return sysCaseQuestions; + } + } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java index 4ba76a7..e5afcd3 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java @@ -76,4 +76,19 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { SysCaseQuestionStep sysCaseQuestionStep = caseQuestionStepMapper.selectByPrimaryKey(caseStepId); return sysCaseQuestionStep; } + + //************ + @Override + public Boolean commitCase(SysCaseQuestionStep caseQuestionStep) { +// SysCaseQuestionStep dbCaseQuestionStep = selectCaseStepDetails(caseQuestionStep.getCaseStepId()); +// if(dbCaseQuestionStep.getAnswer().equals(caseQuestionStep.getAnswer())){ +// //答案正确 将答案存储到学生实训表中,并设置得分,更新实验实训得分 如果所有步骤的案例题分数都已存在、修改实验实训完成状态并修改进度 +// Integer sort = caseQuestionStep.getSort(); +// caseQuestionStep.getAnswer() +// }else { +// +// } + return null; + + } } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaObjectiveServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaObjectiveServiceImpl.java index 1dc607a..1d15d3c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaObjectiveServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaObjectiveServiceImpl.java @@ -11,11 +11,9 @@ import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper; import com.sztzjy.financial_bigdata.service.common.ICourseChapterService; import com.sztzjy.financial_bigdata.service.common.ICourseService; import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService; +import io.swagger.models.auth.In; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -71,11 +69,11 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { SysObjectiveQuestionExample.Criteria criteria2 = example.createCriteria(); criteria.andSchoolIdEqualTo(schoolId).andCourseIdEqualTo(courseId); criteria2.andSchoolIdEqualTo(Constant.BUILT_IN_SCHOOL_ID).andCourseIdEqualTo(courseId); - if(type!=null){ + if (type != null) { criteria.andTypeEqualTo(type); criteria2.andTypeEqualTo(type); } - if(content!=null){ + if (content != null) { criteria.andContentLike(content); criteria2.andContentLike(content); } @@ -86,7 +84,6 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { } - @Override public SysObjectiveQuestion selectObjectiveDetails(String objectiveId) { SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(objectiveId); @@ -112,17 +109,28 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { // 迭代每一行 Iterator iterator = sheet.iterator(); + iterator.next(); while (iterator.hasNext()) { Row currentRow = iterator.next(); String courseName = currentRow.getCell(0).getStringCellValue(); //课程名称 String chapterName = currentRow.getCell(1).getStringCellValue(); //章节名称 - String type = currentRow.getCell(2).getStringCellValue(); //题目类型 - String score = currentRow.getCell(3).getStringCellValue(); //分数 + String type = String.valueOf(currentRow.getCell(2).getNumericCellValue()); //题目类型 + String score = String.valueOf(currentRow.getCell(3).getNumericCellValue()); //分数 String content = currentRow.getCell(4).getStringCellValue(); //题目内容 - String question_a = currentRow.getCell(5).getStringCellValue(); - String question_b = currentRow.getCell(6).getStringCellValue(); - String question_c = currentRow.getCell(7).getStringCellValue(); - String question_d = currentRow.getCell(8).getStringCellValue(); + String question_a = ""; + String question_b = ""; + String question_c = ""; + String question_d = ""; + if (type.equals("2.0") || type.equals("2")) { + question_a = "正确"; + question_b = "错误"; + } else { + question_a = currentRow.getCell(5).getStringCellValue(); + question_b = currentRow.getCell(6).getStringCellValue(); + question_c = currentRow.getCell(7).getStringCellValue(); + question_d = currentRow.getCell(8).getStringCellValue(); + } + String answer = currentRow.getCell(9).getStringCellValue(); String analyze = currentRow.getCell(10).getStringCellValue(); @@ -134,6 +142,13 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { obj.setChapterId(chapterMap.get(chapterName)); obj.setChapterName(chapterName); obj.setInputType(Constant.INPUT_TYPE_BUILT_IN); + if(type.equals("0.0")){ + type="0"; + }else if(type.equals("1.0")){ + type="1"; + }else { + type="2"; + } obj.setType(type); obj.setScore(new BigDecimal(score)); obj.setContent(content); @@ -146,13 +161,13 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { obj.setSchoolId(schoolId); objectiveQuestionList.add(obj); } - }else { //老师批量新增题目 + } else { //老师批量新增题目 List courseList = courseService.selectAllBySchoolId(schoolId); List builtInList = courseService.selectAllBuiltIn(); courseList.addAll(builtInList); Map courseMap = new HashMap<>(); for (int i = 0; i < courseList.size(); i++) { - courseMap.put(courseList.get(i).getCourseName(),courseList.get(i).getCourseId()); + courseMap.put(courseList.get(i).getCourseName(), courseList.get(i).getCourseId()); } Workbook workbook = WorkbookFactory.create(file.getInputStream()); @@ -163,13 +178,23 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { while (iterator.hasNext()) { Row currentRow = iterator.next(); String courseName = currentRow.getCell(0).getStringCellValue(); //课程名称 - String type = currentRow.getCell(1).getStringCellValue(); //题目类型 - String score = currentRow.getCell(2).getStringCellValue(); //分数 + String type = String.valueOf(currentRow.getCell(1).getNumericCellValue()); //题目类型 + String score = String.valueOf(currentRow.getCell(2).getNumericCellValue()); //分数 String content = currentRow.getCell(3).getStringCellValue(); //题目内容 - String question_a = currentRow.getCell(4).getStringCellValue(); - String question_b = currentRow.getCell(5).getStringCellValue(); - String question_c = currentRow.getCell(6).getStringCellValue(); - String question_d = currentRow.getCell(7).getStringCellValue(); + String question_a = ""; + String question_b = ""; + String question_c = ""; + String question_d = ""; + if (type.equals("2.0") || type.equals("2")) { + question_a = "正确"; + question_b = "错误"; + } else { + question_a = currentRow.getCell(4).getStringCellValue(); + question_b = currentRow.getCell(5).getStringCellValue(); + question_c = currentRow.getCell(6).getStringCellValue(); + question_d = currentRow.getCell(7).getStringCellValue(); + } + String answer = currentRow.getCell(8).getStringCellValue(); String analyze = currentRow.getCell(9).getStringCellValue(); @@ -179,7 +204,14 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { obj.setCourseId(courseMap.get(courseName)); obj.setCourseName(courseName); obj.setInputType(Constant.INPUT_TYPE_TEACHER); - obj.setType(type); + if(type.equals("0.0")){ + type="0"; + }else if(type.equals("1.0")){ + type="1"; + }else { + type="2"; + } + obj.setType(String.valueOf(type)); obj.setScore(new BigDecimal(score)); obj.setContent(content); obj.setQuestionA(question_a); @@ -231,7 +263,7 @@ public class TeaObjectiveServiceImpl implements ITeaObjectiveService { @Override public List selectRandomObjective(String chapterId) { - List list=objectiveQuestionMapper.selectRandomObjective(chapterId); + List list = objectiveQuestionMapper.selectRandomObjective(chapterId); return list; } diff --git a/src/main/resources/mapper/SysObjectiveQuestionMapper.xml b/src/main/resources/mapper/SysObjectiveQuestionMapper.xml index 88dbf1a..c359327 100644 --- a/src/main/resources/mapper/SysObjectiveQuestionMapper.xml +++ b/src/main/resources/mapper/SysObjectiveQuestionMapper.xml @@ -410,35 +410,43 @@ - + SELECT + + FROM + sys_objective_question + WHERE + type = 0 AND input_type = 1 + ORDER BY + RAND() + LIMIT + 35 + + + + +