新增理论考试新功能 修复考试部分bug 新增python运行接口

newBigdata
yz 11 months ago
parent e56506444f
commit a5ccb5b057

@ -88,6 +88,7 @@
<artifactId>spring-security-jwt</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
@ -183,6 +184,12 @@
<artifactId>easyexcel</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
<build>

@ -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";

@ -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<SysCaseQuestion> getCaseInfo(@RequestParam String chapterId) {
SysCaseQuestionExample example = new SysCaseQuestionExample();
example.createCriteria().andChapterIdEqualTo(chapterId);
List<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
return new ResultEntity<>(HttpStatus.OK, "获取案例题基础信息查询成功", sysCaseQuestions.get(0));
}
//获取案例题步骤基础信息
//判断是否需要回显、如果学生实训表中 实验实训步骤sort存在、则返回学生答案
@GetMapping("getCaseStepInfo")
@ApiOperation("获取案例题步骤基础信息")
@AnonymousAccess
public ResultEntity<List<SysCaseQuestionStep>> getCaseStepInfo(@RequestParam String caseId) {
SysCaseQuestionStepExample example = new SysCaseQuestionStepExample();
example.createCriteria().andCaseIdEqualTo(caseId);
List<SysCaseQuestionStep> 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在线运行
}

@ -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, "<string>", 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, "<string>", CompileMode.exec);
interpreter.exec(pyCode);
System.out.println("2");
} catch (Exception e) {
System.out.println(e.getMessage()); }
}
}

@ -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<List<SysObjectiveQuestion>> startTheoryTest(@RequestParam String userId) {
List<SysObjectiveQuestion> 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<Date> 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<List<SysObjectiveQuestion>> selectErrors(@RequestParam String userId){
List<SysObjectiveQuestion> 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<PageInfo<StuTheoryExam>> getTheoryTestList(@RequestParam String userId,
@RequestParam Integer index,
@RequestParam Integer size){
@ -93,6 +112,7 @@ public class TheoryTestController {
//考试记录详情查询
@GetMapping("getTheoryTestDetail")
@ApiOperation("获取理论考试数据详情")
@AnonymousAccess
public ResultEntity<List<StuTheoryExamDetailDto>> 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<StuTheoryRecord> getTheoryRecord(String userId){
StuTheoryRecord stuTheoryRecord = recordMapper.selectByPrimaryKey(userId);
return new ResultEntity<>(HttpStatus.OK, "获取理论考试记录数据成功",stuTheoryRecord);

@ -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<List<SysCourse>> selectAllCourse(@RequestParam String schoolId){
List<SysCourse> list=caseService.selectAllCourseName(schoolId);
return new ResultEntity<>(HttpStatus.OK, "案例题库选择课程名展示成功",list);
}
//案例题库选择章节名展示
@GetMapping("selectChapterByCourseId")
@ApiOperation("案例题库选择章节名展示")
@AnonymousAccess
public ResultEntity<List<SysCourseChapter>> selectChapterByCourseId(@ApiParam("课程id")@RequestParam String courseId){
List<SysCourseChapter> list=caseService.selectChapterByCourseId(courseId);
return new ResultEntity<>(HttpStatus.OK, "案例题库选择章节名展示成功",list);
}
//案例题库内容展示
@GetMapping("selectAllCaseByChapterId")
@ApiOperation("案例题库选择案例题内容展示")
@AnonymousAccess
public ResultEntity<List<SysCaseQuestion>> selectAllCaseByChapterId(@RequestParam String chapterId){
List<SysCaseQuestion> list=caseService.selectAllCaseByChapterId(chapterId);
return new ResultEntity<>(HttpStatus.OK, "案例题库选择案例题内容展示成功",list);
}
}

@ -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<String> objectiveIdList,
@RequestParam String schoolId) {
Boolean flag = teaObjectiveService.batchDeleteObjective(objectiveIdList,schoolId);
@ -60,6 +63,7 @@ public class TeaObjectiveController {
//客观题列表查看
@GetMapping("/selectObjectiveList")
@ApiOperation("客观题列表查看")
@AnonymousAccess
public ResultEntity<PageInfo<SysObjectiveQuestion>> 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<SysObjectiveQuestion> 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) {

@ -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<Map<String,String>> 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};")

@ -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<String> selectAllCourseNameBySchoolId(String schoolId);
@Select(" SELECT course_id FROM sys_course WHERE school_id in (#{builtInSchoolId},#{schoolId}) order by sequence")
List<String> selectAllCourseNameBySchoolIdS(String schoolId, String builtInSchoolId);
}

@ -38,8 +38,13 @@ public interface SysObjectiveQuestionMapper {
List<SysObjectiveQuestion> selectRandomObjective(@Param("chapterId")String chapterId);
List<SysObjectiveQuestion> selectRandomObjective100();
@Select("SELECT count(type) FROM sys_objective_question WHERE school_id in (999999999,#{schoolId}) group BY type")
List<Integer> getIndexTheoryTest(@Param("schoolId")String schoolId);
List<SysObjectiveQuestion> selectRandomObjectiveSingle();
List<SysObjectiveQuestion> selectRandomObjectiveMany();
List<SysObjectiveQuestion> selectRandomObjectiveJudge();
}

@ -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<StuTheoryExam> getTheoryTestList(String userId, Integer index, Integer size);
List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size);
Date getStartTime(String userId);
}

@ -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<SysObjectiveQuestion> GenerateTest(String userId) {
List<SysObjectiveQuestion> objectiveQuestionList = objectiveQuestionMapper.selectRandomObjective100();
List<SysObjectiveQuestion> objectiveQuestionList1 = objectiveQuestionMapper.selectRandomObjectiveSingle();
List<SysObjectiveQuestion> objectiveQuestionList2 = objectiveQuestionMapper.selectRandomObjectiveMany();
List<SysObjectiveQuestion> objectiveQuestionList3 = objectiveQuestionMapper.selectRandomObjectiveJudge();
List<SysObjectiveQuestion> objectiveQuestionList=new ArrayList<>();
objectiveQuestionList.addAll(objectiveQuestionList1);
objectiveQuestionList.addAll(objectiveQuestionList2);
objectiveQuestionList.addAll(objectiveQuestionList3);
List<String> singleIdList = new ArrayList<>();
List<String> manyIdList = new ArrayList<>();
List<String> 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<StuTheoryExamWithBLOBs> 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();
}
}
}
}

@ -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<SysCourse> selectAllCourseName(String schoolId);
List<SysCourseChapter> selectChapterByCourseId(String courseId);
List<SysCaseQuestion> selectAllCaseByChapterId(String chapterId);
}

@ -14,4 +14,6 @@ public interface ITeaCaseStepService {
Boolean deleteCaseStep(String caseStepId, String schoolId);
SysCaseQuestionStep selectCaseStepDetails(String caseStepId);
Boolean commitCase(SysCaseQuestionStep caseQuestionStep);
}

@ -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<SysCourse> selectAllCourseName(String schoolId) {
ArrayList<SysCourse> returnList = new ArrayList<>();
if(Constant.BUILT_IN_SCHOOL_ID.equals(schoolId)){
List<String> list=caseQuestionMapper.selectAllCourseNameBySchoolId(schoolId);
for (int i = 0; i < list.size(); i++) {
SysCourse sysCourse = courseMapper.selectByPrimaryKey(list.get(i));
returnList.add(sysCourse);
}
}else {
List<String> 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<SysCourseChapter> selectChapterByCourseId(String courseId) {
SysCourseChapterExample example = new SysCourseChapterExample();
example.createCriteria().andCourseIdEqualTo(courseId);
List<SysCourseChapter> chapterList = courseChapterMapper.selectByExample(example);
example.setOrderByClause("sequence DESC");
return chapterList;
}
@Override
public List<SysCaseQuestion> selectAllCaseByChapterId(String chapterId) {
SysCaseQuestionExample example = new SysCaseQuestionExample();
example.createCriteria().andChapterIdEqualTo(chapterId);
List<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
return sysCaseQuestions;
}
}

@ -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;
}
}

@ -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<Row> 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<SysCourse> courseList = courseService.selectAllBySchoolId(schoolId);
List<SysCourse> builtInList = courseService.selectAllBuiltIn();
courseList.addAll(builtInList);
Map<String, String> 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<SysObjectiveQuestion> selectRandomObjective(String chapterId) {
List<SysObjectiveQuestion> list=objectiveQuestionMapper.selectRandomObjective(chapterId);
List<SysObjectiveQuestion> list = objectiveQuestionMapper.selectRandomObjective(chapterId);
return list;
}

@ -410,35 +410,43 @@
</select>
<select id="selectRandomObjective100" resultMap="BaseResultMap">
<choose>
<when test="type = 'single' and inputType = '1'">
SELECT
*
FROM
sys_objective_question
WHERE
rownum &lt;= 35
</when>
<when test="type = 'many' and inputType = '1'">
SELECT
*
FROM
sys_objective_question
WHERE
rownum &lt;= 5
</when>
<when test="type = 'judge' and inputType = '1'">
SELECT
*
FROM
sys_objective_question
WHERE
rownum &lt;= 10
</when>
</choose>
<select id="selectRandomObjectiveSingle" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
sys_objective_question
WHERE
type = 0 AND input_type = 1
ORDER BY
RAND()
LIMIT
35
</select>
<select id="selectRandomObjectiveMany" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
sys_objective_question
WHERE
type = 1 AND input_type = 1
ORDER BY
RAND()
LIMIT
5
</select>
<select id="selectRandomObjectiveJudge" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
sys_objective_question
WHERE
type = 2 AND input_type = 1
ORDER BY
RAND()
LIMIT
10
</select>

Loading…
Cancel
Save