提交 372cf9e7 authored 作者: jiashixiong's avatar jiashixiong

前台课后练习 模拟练习

上级 c8061e2b
......@@ -36,7 +36,7 @@
<artifactId>solr-solrj</artifactId>
<version>7.1.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.zrqx.resource.bg.controller.questionlibrary;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.resource.commons.form.bg.questionlibrary.*;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import com.zrqx.resource.commons.model.questionlibrary.QuestionLibrary;
import com.zrqx.resource.commons.vo.bg.questionlibrary.QuestionNumVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.resource.bg.service.questionlibrary.ExamPaperLibraryService;
import com.zrqx.resource.commons.form.bg.questionlibrary.BatchDeleteForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveExamPaperInfoForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveUpdateExamPaperForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.UpdateWordsQuestionRelationForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.security.auth.callback.Callback;
import java.util.List;
/**
* 试卷库
* @author JSX
......@@ -27,11 +29,17 @@ public class ExamPaperLibraryController {
@Autowired
private ExamPaperLibraryService service;
/**
* @param form name 试卷名称, DiyType 业务类型
* @return
* @author Jsx
* @date 2020/10/16 16:45
*/
@ApiOperation(value = "新增")
@PostMapping("/save")
public CallBack<Integer> save(@RequestBody SaveUpdateExamPaperForm form ,SaveExamPaperInfoForm form1){
return CallBack.success(service.save(form,form1));
public CallBack<Integer> save(@RequestBody SaveUpdateExamPaperForm form){
return CallBack.success(service.save(form));
}
@ApiOperation("修改")
......@@ -57,4 +65,42 @@ public class ExamPaperLibraryController {
public CallBack<Integer> connectQuestion(@RequestBody SaveExamPaperInfoForm form){
return CallBack.success(service.saveConnectQuestion(form));
}
/**
* @param exampaperId 试卷id
* @return [questionType 试题类型, num 试题数量]
* @author Jsx
* @date 2020/10/16 9:38
*/
@ApiOperation("获取试卷详情各个试题的数量")
@GetMapping("/get-exampaper-info-sum")
public CallBack<List<QuestionNumVo>> getExamPaperInfoSum(Integer exampaperId){
return CallBack.success(service.getExamPaperInfoSum(exampaperId));
}
/**
* @param pageParam
* @return
* @author Jsx
* @date 2020/10/16 15:21
*/
@ApiOperation("查询试卷分页数据")
@GetMapping("/page")
public CallBack<PageInfo<ExamPaperLibrary>> getPage(PageParam pageParam){
return CallBack.success(service.queryByPage(pageParam));
}
/**
*
* @param ,试卷id,资源类型IDresourcId 资源类型名称resourcName 资源类型resourceType
* @return
* @author Jsx
* @date 2020/10/20 8:49
*/
@ApiOperation("设置习题")
@PostMapping("/problem")
public CallBack<Integer> setProblem(@RequestBody SaveUpdateExamPaperForm form){
return CallBack.success(service.saveProblem(form));
}
}
......@@ -45,7 +45,7 @@ public class QuestionLibraryController {
@Autowired
private QuestionLibraryService service;
@ApiOperation("导入试题")
@PostMapping("/import")
public CallBack<Integer> importExcel(@RequestParam("file") MultipartFile file)throws Exception{
......@@ -58,25 +58,25 @@ public class QuestionLibraryController {
}
return CallBack.success(service.saveList(list));
}
@ApiOperation(value = "新增")
@PostMapping("/save")
public CallBack<Integer> saveQuestion(@RequestBody SaveUpdateQuestionForm form) {
return CallBack.success(service.save(form));
}
@ApiOperation(value = "修改")
@PostMapping("/update")
public CallBack<Integer> updateQuestion(@RequestBody SaveUpdateQuestionForm form) {
return CallBack.success(service.update(form));
}
@ApiOperation("批量删除")
@PostMapping("/batch-delete")
public CallBack<Integer> batchDelete(@RequestBody BatchDeleteForm form){
return CallBack.success(service.batchDelete(form));
}
@ApiOperation("分页查询")
@GetMapping("/page")
public CallBack<PageInfo<QuestionLibraryVo>> getPage(PageParam pageParam,QueryQuestionForm form){
......
......@@ -19,21 +19,24 @@ import io.swagger.annotations.ApiOperation;
* @author JSX
* @date 2020年9月30日上午10:29:45
*/
@RestController
@RequestMapping("/bg/statistics-analyse")
@Api(description = "统计分析")
public class StatisticsAnalyseController {
// @Autowired
// private StatisticsAnalyseService statisticsAnalyseService;
//
// @ApiOperation("获取课程分类统计信息")
// @GetMapping("/course-classify")
// public CallBack<Integer> getCourseClassify(){
//
//
// return null;
//
// }
@Autowired
//private StatisticsAnalyseService statisticsAnalyseService;
@ApiOperation("获取课程分类统计信息")
@GetMapping("/course-classify")
public CallBack<Integer> getCourseClassify(){
return null;
}
}
......@@ -25,4 +25,12 @@ public interface ExamPaperInfoManage extends BaseService<ExamPaperInfo, Integer>
*/
boolean delete(Integer id,String type);
/**
* 根据试卷id查询试题个数
* @param id 试卷id
* @return 试题个数
* @author Jsx
* @date 2020/10/16 15:33
*/
Integer getCount(Integer id);
}
......@@ -36,4 +36,11 @@ public class ExamPaperInfoManageImpl extends BaseServiceImpl<ExamPaperInfo,Integ
return mapper.delete(examPaperInfo) > 0;
}
@Override
public Integer getCount(Integer id) {
ExamPaperInfo record = new ExamPaperInfo();
record.setExampaperid(id);
return mapper.select(record).size();
}
}
package com.zrqx.resource.bg.manage.questionlibrary;
import com.zrqx.core.service.BaseService;
import com.zrqx.resource.commons.model.questionlibrary.ResourcLibraryExampaerDiyType;
/**
* 资源与试卷关联
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 10:29
*/
public interface ResourcLibraryExampaperDiyTypeManage extends BaseService<ResourcLibraryExampaerDiyType, Integer> {
}
package com.zrqx.resource.bg.manage.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.bg.mapper.questionlibrary.ResourcLibraryExampaperDiyTypeMapper;
import com.zrqx.resource.commons.model.questionlibrary.ResourcLibraryExampaerDiyType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 资源与试卷关联
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 10:32
*/
@Service
public class ResourcLibraryExampaperDiyTypeManageImpl extends BaseServiceImpl<ResourcLibraryExampaerDiyType,Integer> implements ResourcLibraryExampaperDiyTypeManage {
@Autowired
public ResourcLibraryExampaperDiyTypeMapper mapper;
@Override
public BaseMapper<ResourcLibraryExampaerDiyType> getMapper() {
return mapper;
}
}
......@@ -2,10 +2,23 @@ package com.zrqx.resource.bg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 试卷详细
*/
public interface ExamPaperInfoMapper extends BaseMapper<ExamPaperInfo> {
@Select("<script>"
+ " select questionid from res_exampaperinfo e "
+ " where 1=1 "
+ " <if test = 'examPaperId != null'> "
+ " and e.exampaperid = #{examPaperId} "
+ " </if> "
+ "</script>")
List<Integer> getIds(@Param("examPaperId")Integer examPaperId);
}
......@@ -21,17 +21,9 @@ public interface ExamPaperLibraryMapper extends BaseMapper<ExamPaperLibrary>{
+ " batchcode, begintime, endtime, restrictedhours , assemblytype, intype, introduction,effective, "
+ " creater, status , publishtime, sumscore, createTime, subcount, organizationid , questionnum, institutionid, years "
+ " from res_exampaper_library where 1=1 "
+ " <if test = '" + NOTBLANK + "(form.name)'> "
+ " AND name like concat(#{form.name},'%') "
+ " </if> "
+ " eq(examStatus,form.status) "
+ " eq(reserve2,form.reserve2) "
+ " order by createtime desc "
+ " </script>")
List<ExamPaperLibrary> queryByPage(@Param("form")QueryPageForm form);
List<ExamPaperLibrary> queryByPage();
@Select("<script>"
+ "select questionType,count(id) num from res_exampaperinfo where exampaperid=#{exampaperId} group by questiontype"
......
package com.zrqx.resource.bg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.model.questionlibrary.ResourcLibraryExampaerDiyType;
/**
* 资源与试卷关联
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 11:15
*/
public interface ResourcLibraryExampaperDiyTypeMapper extends BaseMapper<ResourcLibraryExampaerDiyType> {
}
......@@ -3,12 +3,12 @@ package com.zrqx.resource.bg.service.questionlibrary;
import java.util.List;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.resource.commons.form.bg.questionlibrary.*;
import com.zrqx.resource.commons.vo.bg.questionlibrary.QuestionNumVo;
import org.springframework.web.bind.annotation.RequestBody;
import com.zrqx.resource.commons.form.bg.questionlibrary.BatchDeleteForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveExamPaperInfoForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveUpdateExamPaperForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.UpdateWordsQuestionRelationForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import com.zrqx.core.service.BaseService;
......@@ -24,7 +24,7 @@ public interface ExamPaperLibraryService extends BaseService<ExamPaperLibrary, I
* @author JSX
* @date: 2020年9月28日 下午2:01:50
*/
Integer save(SaveUpdateExamPaperForm form,SaveExamPaperInfoForm form1);
Integer save(SaveUpdateExamPaperForm form);
/**
* 修改试卷
......@@ -53,12 +53,30 @@ public interface ExamPaperLibraryService extends BaseService<ExamPaperLibrary, I
*/
Integer saveConnectQuestion(SaveExamPaperInfoForm form);
// /**
// * 分页获取数据
// * @param pageParam
// * @return
// */
// PageInfo<ExamPaperLibrary> queryByPage(PageParam pageParam,QueryPageForm form);
/**
* 获取试卷关联的试题数量
* @param exampaperId 试卷id
* @return [questionType 试题类型, num 试题数量]
* @author JSX
* @date: 2020年9月28日 下午3:42:36
*/
List<QuestionNumVo> getExamPaperInfoSum(Integer exampaperId);
/**
* 分页获取数据
* @param pageParam
* @return
*/
PageInfo<ExamPaperLibrary> queryByPage(PageParam pageParam);
/**
* 设置课后习题
* @param ,试卷id,资源类型IDresourcId 资源类型名称resourcName 资源类型resourceType
* @return
* @author Jsx
* @date 2020/10/20 8:57
*/
Integer saveProblem(SaveUpdateExamPaperForm form);
//
// /**
// * 获取试卷关联的试题
......@@ -67,12 +85,7 @@ public interface ExamPaperLibraryService extends BaseService<ExamPaperLibrary, I
// */
// List<ExamPaperInfoVo> getExamPaperInfo(Integer id,String type);
//
// /**
// * 获取试卷关联的试题数量
// * @param exampaperId
// * @return
// */
// List<QuestionNumVo> getExamPaperInfoSum(Integer exampaperId);
//
// /**
// * 试卷关联页的试题弹窗列表
......
......@@ -10,7 +10,11 @@ import java.util.List;
import java.util.stream.Collectors;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.resource.bg.manage.questionlibrary.*;
import com.zrqx.resource.commons.form.bg.questionlibrary.*;
import com.zrqx.resource.commons.vo.bg.questionlibrary.QuestionNumVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -18,7 +22,6 @@ import org.springframework.stereotype.Service;
import com.zrqx.resource.commons.model.diytype.DiyType;
import com.zrqx.core.enums.third.ExamStatusEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.resource.commons.form.bg.questionlibrary.ExamPaperInfoForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.model.questionlibrary.QuestionLibrary;
import com.zrqx.resource.commons.model.questionlibrary.ResourcLibraryExampaerDiyType;
......@@ -27,10 +30,6 @@ import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.bg.mapper.questionlibrary.ExamPaperInfoMapper;
import com.zrqx.resource.bg.mapper.questionlibrary.ExamPaperLibraryMapper;
import com.zrqx.resource.commons.form.bg.questionlibrary.BatchDeleteForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveExamPaperInfoForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.SaveUpdateExamPaperForm;
import com.zrqx.resource.commons.form.bg.questionlibrary.UpdateWordsQuestionRelationForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibraryDiyType;
......@@ -45,9 +44,13 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
@Autowired
private ExamPaperLibraryDiyTypeManage manage;
@Autowired
private ResourcLibraryExampaperDiyTypeManage diyTypeManage;
@Autowired
private ExamPaperInfoManage infoManage;
@Autowired
private QuestionLibraryManage questionManage;
@Autowired
private ExamPaperInfoMapper examPaperInfoMapper;
@Override
public BaseMapper<ExamPaperLibrary> getMapper() {
......@@ -55,7 +58,7 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
}
@Override
public Integer save(SaveUpdateExamPaperForm form,SaveExamPaperInfoForm form1) {
public Integer save(SaveUpdateExamPaperForm form) {
ExamPaperLibrary ep = new ExamPaperLibrary();
ep.setName(form.getName()); //试卷名称
ep.setCreatename(form.getCreater()); //出卷人
......@@ -71,8 +74,11 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
ep.setReserve2(form.getReserve2()); //属性 工作分类
int i = mapper.insertUseGeneratedKeys(ep);
//如果保存成功,这进行组卷操作
if(i == 1 && form1 != null) {
form1.setId(ep.getId()); //获取保存成功的试卷id
if(i == 1 && form.getList() != null) {
form.setId(ep.getId()); //获取保存成功的试卷id
SaveExamPaperInfoForm form1 = new SaveExamPaperInfoForm();
form1.setId(ep.getId());
form1.setList(form.getList());
saveConnectQuestion(form1); //组卷
//循环遍历添加试卷与自定义分类表关系
if(form.getDiyType() != null) {
......@@ -90,9 +96,10 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
t.setName(form.getResourcName());
t.setResourceType(form.getResourceType());
t.setExampaperId(form.getId());
t.setCreateTime(new Date());
manage.insertSelective(t);
}
}
return 1;
}
......@@ -164,6 +171,7 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
throw new BusinessValidateException("未找到试卷");
}
List<ExamPaperInfoForm> list = form.getList();
int sumscore = 0;
if(list != null) {
for(ExamPaperInfoForm info : list) {
//获取最大排序号
......@@ -183,6 +191,9 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
}else {
epInfo.setScore(0);
}
if (info.getScore() != null){
sumscore = sumscore + info.getScore();
}
epInfo.setQuestionid(info.getQuestionId());
epInfo.setExampaperid(ep.getId());
epInfo.setComplexity(ql.getComplexity());
......@@ -190,6 +201,53 @@ public class ExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrar
infoManage.insert(epInfo);
}
}
ExamPaperLibrary paperLibrary = new ExamPaperLibrary();
paperLibrary.setSumscore(sumscore);
paperLibrary.setQuestionnum(list.size());
paperLibrary.setNum(list.size());
mapper.updateByPrimaryKeySelective(paperLibrary);
return 1;
}
@Override
public List<QuestionNumVo> getExamPaperInfoSum(Integer exampaperId) {
List<QuestionNumVo> list = mapper.getExamPaperInfoSum(exampaperId);
return list;
}
@Override
public PageInfo<ExamPaperLibrary> queryByPage(PageParam pageParam) {
startPage(pageParam);
List<ExamPaperLibrary> list = mapper.queryByPage();
list.forEach(this::fmtExamPaperLibrary);
return new PageInfo<ExamPaperLibrary>(list);
}
@Override
public Integer saveProblem(SaveUpdateExamPaperForm form) {
//添加课程与试卷表关系
if(form.getResourcId() != null) {
ResourcLibraryExampaerDiyType t = new ResourcLibraryExampaerDiyType();
t.setResourcId(form.getResourcId());
t.setName(form.getResourcName());
t.setResourceType(form.getResourceType());
t.setExampaperId(form.getId());
t.setCreateTime(new Date());
diyTypeManage.insertSelective(t);
}
return 1;
}
public void fmtExamPaperLibrary(ExamPaperLibrary examPaperLibrary){
//查询试卷中的试题个数
examPaperLibrary.setNum(infoManage.getCount(examPaperLibrary.getId()));
ExamPaperInfo epInfo = new ExamPaperInfo();
epInfo.setExampaperid(examPaperLibrary.getId());
List<ExamPaperInfo> voList = examPaperInfoMapper.select(epInfo);
for (ExamPaperInfo v : voList) {
QuestionLibrary questionLibrary = questionManage.selectByPrimaryKey(v.getQuestionid());
}
Integer scoreSum = voList.stream().collect(Collectors.summingInt(ExamPaperInfo::getScore));
examPaperLibrary.setSumscore(scoreSum);
}
}
package com.zrqx.resource.bg.service.statistics;
public class StatisticsAnalyseServiceImpl {
}
......@@ -6,6 +6,8 @@ import com.zrqx.resource.commons.model.videolibrary.VideoLibrary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 添加修改试卷表单
* @author ydm
......@@ -58,4 +60,7 @@ public class SaveUpdateExamPaperForm {
@ApiModelProperty("资源类型")
private Integer resourceType;
@ApiModelProperty("试卷详情(试题列表)")
private List<ExamPaperInfoForm> list;
}
package com.zrqx.resource.commons.form.fg.questionlibrary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 模拟练习
*
* @author Jsx
* @version 1.0
* @date 2020/10/26 15:36
*/
@Data
public class FgSelectExamPaperForm {
@ApiModelProperty(value = "资源名称")
private String name;
@ApiModelProperty(value = "资源类型")
private Integer resourceType;
@ApiModelProperty(value = "用户id")
private Integer memberId;
@ApiModelProperty(value = "分类ID")
private Integer typeId;
@ApiModelProperty(value = "分类名称")
private String typeName;
@ApiModelProperty(value = "分类code")
private String typeCode;
}
package com.zrqx.resource.commons.form.fg.questionlibrary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Jsx
* @version 1.0
* @date 2020/10/21 17:08
*/
@Data
public class FgSelectExamRecordForm {
@ApiModelProperty("试卷id")
private Integer exampaperid;
@ApiModelProperty("资源类型id")
private String resourcId;
@ApiModelProperty("用户id")
private String stuId;
@ApiModelProperty("自主练习 0否 1是")
private Integer auto;
}
package com.zrqx.resource.commons.form.fg.questionlibrary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 习题-提交结果
*
* @author Jsx
* @version 1.0
* @date 2020/10/21 9:59
*/
@Data
public class FgSubmitExamRecordForm {
@ApiModelProperty("答题结果")
private List<FgUpdateStudyRecordForm> list;
@ApiModelProperty("测试id")
private Integer recordId;
}
package com.zrqx.resource.commons.form.fg.questionlibrary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Jsx
* @version 1.0
* @date 2020/10/21 10:01
*/
@Data
public class FgUpdateStudyRecordForm {
@ApiModelProperty("考试记录详细id")
private Integer id;
@ApiModelProperty("排序后答案,统一大写字母,多个答案用英文逗号分隔")
private String answer;
}
......@@ -64,5 +64,11 @@ public class ExamRecord implements java.io.Serializable {
private String area;
@ApiModelProperty("县")
private String town;
@ApiModelProperty("资源类型id")
private String resourcid;
@ApiModelProperty("错误题数")
private Integer errornum;
@ApiModelProperty("自主练习 0否 1是")
private Integer auto;
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value="ResourcLibraryExampaerDiyType",description="资源类型与试卷关系表")
@Table(name = "res_resourc_library_exampaper_diy_type")
......@@ -29,5 +31,7 @@ public class ResourcLibraryExampaerDiyType {
@ApiModelProperty("试卷id")
private Integer exampaperId;
@ApiModelProperty("创建时间")
private Date createTime;
}
......@@ -19,7 +19,7 @@ public class FgMyLearningListVo {
private String img;
@ApiModelProperty(value = "课程名称")
private String name;
@ApiModelProperty("资源类型 ")
@ApiModelProperty("资源类型 ")
private Integer resourceType;
@ApiModelProperty("简介")
private String synopsis;
......
package com.zrqx.resource.commons.vo.fg.questionlibrary;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel
public class FgExamPaperInfoVo extends ExamPaperInfo {
//@ApiModelProperty("小题列表")
//public List<WordsQuestionRelation> children;
@ApiModelProperty("考生答案")
private String stuanswer;
@ApiModelProperty("是否答对0 错误1正确")
private Integer isRight;
}
package com.zrqx.resource.commons.vo.fg.questionlibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 模拟练习
*
* @author Jsx
* @version 1.0
* @date 2020/10/26 15:50
*/
@Data
@ApiModel(value = "FgSelectExamPaperVo",description = "查询模拟练习试卷")
public class FgSelectExamPaperVo {
@ApiModelProperty(value = "试卷id")
private Integer id;
@ApiModelProperty(value = "试卷名称")
private String name;
@ApiModelProperty(value = "练习时间")
private String time;
@ApiModelProperty(value = "得分")
private Integer realscore;
@ApiModelProperty(value = "总分")
private Integer sumscore;
}
......@@ -77,7 +77,7 @@ public class FgMemberCollectionController {
return CallBack.success(service.deleteMemberCollection(form));
}
@ApiOperation(value = "是否收藏",notes="1有收藏0没有收藏")
@ApiOperation(value = "是否关注",notes="1有关注0没有关注")
@GetMapping(value = "/check-is-collect")
public CallBack<Integer> checkIsCollect(GoodsForm form){
return CallBack.success(service.checkIsCollect(form));
......
package com.zrqx.resource.fg.controller.questionlibrary;
import com.zrqx.core.commons.model.resource.questionlibrary.ExamRecordInfo;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.resource.commons.form.bg.questionlibrary.QueryPageForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamPaperForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSubmitExamRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import com.zrqx.resource.commons.model.questionlibrary.ExamRecord;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgExamPaperInfoVo;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgSelectExamPaperVo;
import com.zrqx.resource.fg.service.questionlibray.FgExamPaperLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.security.auth.callback.Callback;
import java.util.List;
/**
* 前台习题
*
* @author Jsx
* @version 1.0
* @date 2020/10/19 16:24
*/
@RestController
@RequestMapping("/fg//question-library")
@Api(description = "前台-习题")
public class FgExamPaperLibraryController {
@Autowired
private FgExamPaperLibraryService service;
/**
* @param pageParam
* @param form 课程或者系列课id
* @return 课程或者系列课相关试卷列表
* @author Jsx
* @date 2020/10/19 16:30
*/
@ApiOperation("分页查询课程相关试卷列表")
@GetMapping("/page")
public CallBack<PageInfo<ExamPaperLibrary>> getPage(PageParam pageParam,@RequestBody FgSelectExamRecordForm form){
return CallBack.success(service.queryByPage(pageParam, form));
}
/**
* 1.依据该用户新增或者更新用户下的测试记录与测试记录详情
* 2.获取用户下该课程的试卷的试题列表
* @param , 试卷exampaperid 资源resourcId
* @return 试卷相关试题列表
* @author Jsx
* @date 2020/10/20 15:03
*/
@ApiOperation("获取试卷关联的试题")
@GetMapping("/get-exampaper-info")
public CallBack<List<ExamRecordInfo>> getExamPaperInfo(FgSelectExamRecordForm examRecordForm){
return CallBack.success(service.saveOrUpdateExamRecord(examRecordForm));
}
/**
* 获取该登录用户下res_examrecord表的答题测试记录
* @param recordid 考试记录id
* @return 答题记录
* @author Jsx
* @date 2020/10/23 9:22
*/
@ApiOperation("获取用户答题记录")
@GetMapping("/get")
public CallBack<List<ExamRecord>> getExamRecord(Integer recordid) {
return CallBack.success(service.getExamRecord(recordid));
}
/**
* 获取该用户答题后res_examrecordinfo表的练习提的记录详情
* @param recordid 考试记录id
* @return 返回试卷中各试题的详情
* @author Jsx
* @date 2020/10/25 17:04
*/
@ApiOperation("获取用户答题后的试题详情")
@GetMapping("/get-examrecorinfo")
public CallBack<List<ExamRecordInfo>> getExamRecordInfo(Integer recordid) {
return CallBack.success(service.getExamRecordInfo(recordid));
}
/**
* 1.保存练习提答案并更新试题库统计信息
* 2.根据保存的试题答案信息计算试题总分、正确题数等信息
* @param form [测试id 答案list]
* @return
* @author Jsx
* @date 2020/10/21 10:29
*/
@ApiOperation("提交结果")
@PostMapping("/submit-exampaper")
public CallBack<ExamRecord> submitExamPaper (@RequestBody FgSubmitExamRecordForm form){
service.updateExamRecordInfo(form);
ExamRecord examRecord = service.updateCheckExamRecord(form.getRecordId());
return CallBack.success(examRecord);
}
/**
* 根据条件查询模拟练习试卷库列表
* @param pageParam 分页查询条件 form 查询条件
* @return 模拟练习试卷库列表
* @author Jsx
* @date 2020/10/26 15:56
*/
@ApiOperation("获取模拟试卷列表")
@PostMapping("/get-exampaper")
public CallBack<List<FgSelectExamPaperVo>> getExamPaper(PageParam pageParam,@RequestBody FgSelectExamPaperForm form){
return CallBack.success(service.getExamPaper(pageParam,form));
}
/**
* 根据试卷id去判断用户是否有权限做题
* @param form 试卷id exampaperid
* @return 如果没有提示“暂无权限”,如果有返回试卷试题详情
* @author Jsx
* @date 2020/10/27 8:33
*/
@ApiOperation("获取模拟开始练习")
@PostMapping("/simulatePractice")
public CallBack<List<ExamRecordInfo>> simulatePractice(@RequestBody FgSelectExamRecordForm form){
return CallBack.success(service.simulatePractice(form));
}
/**
* 1.根据入参值分类code查询,用户的习题权限,如若没有提示“暂无权限” 如果有则则去组装相关试卷返回
* 2.选择全部会自动查询用户相关分类权限,选择单一分类则按单一分类试题组装试卷。
* @param form 分类code typeCode
* @return 如果没有提示“暂无权限”,如果有返回试卷试题详情
* @author Jsx
* @date 2020/10/27 13:57
*/
@ApiOperation("获取自主组题练习")
@PostMapping("/autoConnectQuestion")
public CallBack<List<ExamRecordInfo>> autoConnectQuestion (@RequestBody FgSelectExamPaperForm form){
return CallBack.success(service.autoConnectQuestion(form));
}
}
package com.zrqx.resource.fg.manage.questionlibrary;
import com.zrqx.core.service.BaseService;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
/**
* 试卷详情
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 15:59
*/
public interface FgExamPaperInfoManage extends BaseService<ExamPaperInfo, Integer> {
/**
* 根据试卷id查询试题个数
* @param . 试卷id
* @return 试题个数
* @author Jsx
* @date 2020/10/20 17:09
*/
Integer getCount(Integer id);
}
package com.zrqx.resource.fg.manage.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
import com.zrqx.resource.fg.mapper.questionlibrary.FgExamPaperInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 试卷详情
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 16:01
*/
@Service
public class FgExamPaperInfoManageImpl extends BaseServiceImpl<ExamPaperInfo,Integer> implements FgExamPaperInfoManage {
@Autowired
private FgExamPaperInfoMapper mapper;
@Override
public BaseMapper<ExamPaperInfo> getMapper() {
return mapper;
}
@Override
public Integer getCount(Integer id) {
ExamPaperInfo record = new ExamPaperInfo();
record.setExampaperid(id);
return mapper.select(record).size();
}
}
package com.zrqx.resource.fg.manage.questionlibrary;
import com.zrqx.core.service.BaseService;
import com.zrqx.resource.commons.model.questionlibrary.QuestionLibrary;
/**
* 试题库
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 16:24
*/
public interface FgQuestionLibraryManage extends BaseService<QuestionLibrary, Integer> {
}
package com.zrqx.resource.fg.manage.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.resource.commons.model.questionlibrary.QuestionLibrary;
import com.zrqx.resource.fg.mapper.questionlibrary.FgQuestionLibraryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 试题库
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 16:25
*/
@Service
public class FgQuestionLibraryManageImpl extends BaseServiceImpl<QuestionLibrary,Integer> implements FgQuestionLibraryManage {
@Autowired
private FgQuestionLibraryMapper mapper;
@Override
public BaseMapper<QuestionLibrary> getMapper() {
return mapper;
}
}
......@@ -40,7 +40,7 @@ public interface FgEbookDiyTypeMapper extends BaseMapper<EbookDiyType> {
@Select("<script>"
+ "select rdt.id, rdt.parentId, rdt.sort, rdt.showName, rdt.code "
+ "FROM res_Diy_Type rdt "
+ "left join res_ebook_diy_type redt on rdt.id = redt.diyTypeId "
+ "left join res_ebook_diy_type redt on rdt.id = redt.dtid "
+ "where redt.ebookId = #{oid}"
+ "</script>")
List<DiyType> selectDiyTypeList(String oid);
......
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.commons.model.resource.questionlibrary.ExamRecordInfo;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 试卷详情
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 16:06
*/
public interface FgExamPaperInfoMapper extends BaseMapper<ExamPaperInfo> {
@Select("<script>"
+ " select * "
+ " from res_exampaperinfo"
+ " where 1=1 "
+ " eq(exampaperid,exampaperid)"
+ "</script>")
List<ExamRecordInfo> getExamPaperInfo (@Param("exampaperid") String exampaperid);
}
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamPaperForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 试卷
*
* @author Jsx
* @version 1.0
* @date 2020/10/19 16:49
*/
public interface FgExamPaperLibraryMapper extends BaseMapper<ExamPaperLibrary> {
@Select("<script>"
+ " select rel.id,rel.name"
+ " FROM res_resourc_library_exampaper_diy_type rdiy "
+ " LEFT JOIN res_exampaper_library rel ON rel.id = rdiy.exampaperId"
+ " WHERE 1 = 1 "
+ " <if test = '" + NOTBLANK + "(form.resourcId)'> "
+ " AND rdiy.resourcId = #{form.resourcId}"
+ " </if> "
+ " <if test = '" + NOTBLANK + "(form.exampaperid)'> "
+ " AND rdiy.exampaperid = #{form.exampaperid}"
+ " </if> "
+ " ORDER BY rdiy.createTime DESC "
+ " </script>")
List<ExamPaperLibrary> queryByPage(@Param("form") FgSelectExamRecordForm form);
@Select("<script>"
+ " SELECT rel.id,rel.name,rel.questionnum,rel.sumscore"
+ " FROM res_exampaper_library_diy_type diy"
+ " LEFT JOIN res_exampaper_library rel ON diy.epid = rel.id"
+ " where 1=1"
+ " eq(diy.code,form.typeCode)"
+ " like(rel.name,fom.name)"
+ " </script>")
List<ExamPaperLibrary> selectExamPaper(@Param("form") FgSelectExamPaperForm form);
}
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.commons.model.resource.questionlibrary.ExamRecordInfo;
import com.zrqx.core.mapper.BaseMapper;
/**
* 考试记录详情
*
* @author Jsx
* @version 1.0
* @date 2020/10/21 11:45
*/
public interface FgExamRecordInfoMapper extends BaseMapper<ExamRecordInfo> {
}
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 考试记录
*
* @author Jsx
* @version 1.0
* @date 2020/10/21 13:38
*/
public interface FgExamRecordMapper extends BaseMapper<ExamRecord> {
@Select("<script>"
+ " select id, exampaperid, name, begintime, endtime, readtime, sumscore, realscore, questionnum, rightnum, "
+ " precisionpercent, stuId, batchCode, examcategory, createTime, province, city, area, town, resourcid"
+ " from res_examrecord res "
+ " where 1=1 "
+ "<if test = '"+NOTBLANK+"(form.stuId)' >"
+ " and res.stuId = #{form.stuId} "
+ "</if>"
+ "<if test = '"+NOTBLANK+"(form.resourcid)' >"
+ " and res.resourcid = #{form.resourcid} "
+ "</if>"
+ "<if test = '"+NOTBLANK+"(form.exampaperid)' >"
+ " and res.exampaperid = #{form.exampaperid} "
+ "</if>"
+ " eq(res.auto,form.auto)"
+ " order by createTime desc "
+ " </script>")
ExamRecord getUserPracticeRecord(@Param("form") ExamRecord form);
@Select("<script>"
+ " select * "
+ " from res_examrecord "
+ " where 1=1 "
+ " eq(stuId,form.stuId)"
+ " eq(resourcid,form.resourcid)"
+ " eq(exampaperid,form.exampaperid)"
+ " order by createTime desc "
+ " </script>")
List<ExamRecord> getUserRecord(@Param("form") FgSelectExamRecordForm form);
@Select("<script>"
+ " select *"
+ " from (select * from res_examrecord where stuId = #{stuId} ORDER BY createTime DESC) des GROUP BY exampaperid"
+ " </script>")
List<ExamRecord> getSelectExamRecord(String stuId);
}
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.model.questionlibrary.QuestionLibrary;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 试题库
*
* @author Jsx
* @version 1.0
* @date 2020/10/20 16:27
*/
public interface FgQuestionLibraryMapper extends BaseMapper<QuestionLibrary> {
@Select("<script>"
+ " SELECT a.*"
+ " From res_question_library_diy_type diy"
+ " LEFT JOIN res_question_library a ON a.id = diy.qlid"
+ " WHERE 1=1"
+ " IN(diy.code,list)"
+ " order by createTime desc "
+ "</script>")
List<QuestionLibrary> getSelectQuestion(@Param("list")List<String> list);
}
package com.zrqx.resource.fg.mapper.questionlibrary;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.ResourcLibraryExampaerDiyType;
import com.zrqx.resource.commons.vo.fg.courselibrary.FgMyLearningListVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 资源与试卷关联
*
* @author Jsx
* @version 1.0
* @date 2020/10/27 10:16
*/
public interface FgResourcLibraryExampaperDiyTypeMapper extends BaseMapper<ResourcLibraryExampaerDiyType> {
@Select("<script>"
+ " select * "
+ " from (SELECT * from res_resourc_library_exampaper_diy_type where 1=1 IN(resourcId,list1)) DE"
+ " where 1=1 "
+ " eq(exampaperId,form.exampaperid)"
+ " ORDER BY createTime DESC "
+ "</script>")
List<ResourcLibraryExampaerDiyType> getResourcLibrary(@Param("list1") List<String> list1, @Param("form") FgSelectExamRecordForm form);
}
......@@ -2,6 +2,8 @@ package com.zrqx.resource.fg.mapper.videolibrary;
import java.util.List;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamPaperForm;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.mapper.BaseMapper;
......@@ -19,4 +21,14 @@ public interface FgVideoLibraryDiyTypeMapper extends BaseMapper<VideoLibraryDiyT
@Select("select code from res_video_library_diy_type where vlid = #{oid}")
List<String> selectDiyCodesById(String oid);
@Select("<script>"
+ " SELECT code"
+ " FROM (SELECT a.* FROM (SELECT * FROM res_video_library_diy_type"
+ " UNION SELECT * FROM res_course_library_diy_type) a "
+ " LEFT JOIN res_diy_type diy ON a.dtid = diy.id"
+ " WHERE 1=1 IN(a.vlid,list) GROUP BY a. CODE) e"
+ " WHERE 1=1 eq(CODE,form.typeCode)"
+ " </script>")
List<String> getDiyType(@Param("list") List<String> list,@Param("form") FgSelectExamPaperForm form);
}
package com.zrqx.resource.fg.service.questionlibray;
import com.zrqx.core.commons.model.resource.questionlibrary.ExamRecordInfo;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamPaperForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSubmitExamRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.ExamPaperLibrary;
import com.zrqx.resource.commons.model.questionlibrary.ExamRecord;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgExamPaperInfoVo;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgSelectExamPaperVo;
import java.util.List;
/**
* 习题
*
* @author Jsx
* @version 1.0
* @date 2020/10/19 16:36
*/
public interface FgExamPaperLibraryService extends BaseService<ExamPaperLibrary, Integer> {
/**
* 分页查询课程相关试卷列表
* @param pageParam
* @param form 课程或者系列课id
* @return 课程或者系列课相关试卷列表
* @author Jsx
* @date 2020/10/19 16:30
*/
PageInfo<ExamPaperLibrary> queryByPage(PageParam pageParam, FgSelectExamRecordForm form);
/**
* 获取试卷关联的试题
* @param examRecordForm 试卷id
* @return 试卷相关试题列表
* @author Jsx
* @date 2020/10/20 15:01
*/
List<ExamRecordInfo> saveOrUpdateExamRecord(FgSelectExamRecordForm examRecordForm);
/**
* 获取该登录用户下res_examrecord表的答题测试记录
* @param
* @return
* @author Jsx
* @date 2020/10/23 9:31
*/
List<ExamRecord> getExamRecord(Integer recordid);
/**
* 获取该用户答题后的练习提的记录详情
* @param recordid 考试记录id
* @return 返回试卷中各试题的详情
* @author Jsx
* @date 2020/10/25 17:04
*/
List<ExamRecordInfo> getExamRecordInfo(Integer recordid);
/**
* 提交考试结果
* @param form [测试id 答案list]
* @return
* @author Jsx
* @date 2020/10/21 10:03
*/
Integer updateExamRecordInfo(FgSubmitExamRecordForm form);
/**
* 计算练习结果
* @param recordId 测试记录id
* @return
* @author Jsx
* @date 2020/10/23 16:34
*/
ExamRecord updateCheckExamRecord(Integer recordId);
/**
* 根据条件查询模拟练习试卷库列表
* @param pageParam 分页查询条件 form 查询条件
* @return 模拟练习试卷库列表
* @author Jsx
* @date 2020/10/26 15:56
*/
List<FgSelectExamPaperVo> getExamPaper (PageParam pageParam, FgSelectExamPaperForm form );
/**
* 根据试卷id去判断用户是否有权限做题
* @param form 试卷id exampaperid
* @return 如果没有提示“暂无权限”,如果有返回试卷试题详情
* @author Jsx
* @date 2020/10/27 8:33
*/
List<ExamRecordInfo> simulatePractice(FgSelectExamRecordForm form);
/**
* 1.根据入参值分类code查询,用户的习题权限,如若没有提示“暂无权限” 如果有则则去组装相关试卷返回
* 2.选择全部会自动查询用户相关分类权限,选择单一分类则按单一分类试题组装试卷。
* @param form 分类code typeCode
* @return 如果没有提示“暂无权限”,如果有返回试卷试题详情
* @author Jsx
* @date 2020/10/27 13:57
*/
List<ExamRecordInfo> autoConnectQuestion(FgSelectExamPaperForm form);
}
package com.zrqx.resource.fg.service.questionlibray;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zrqx.core.commons.form.LoginMemberInfo;
import com.zrqx.core.commons.model.resource.questionlibrary.ExamRecordInfo;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.questionlibrary.ExamUtils;
import com.zrqx.resource.commons.form.fg.courselibrary.FgMyLearningForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamPaperForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSelectExamRecordForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgSubmitExamRecordForm;
import com.zrqx.resource.commons.form.fg.questionlibrary.FgUpdateStudyRecordForm;
import com.zrqx.resource.commons.model.questionlibrary.*;
import com.zrqx.resource.commons.model.videolibrary.VideoLibraryDiyType;
import com.zrqx.resource.commons.redis.FgRedisManage;
import com.zrqx.resource.commons.vo.fg.courselibrary.FgMyLearningListVo;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgExamPaperInfoVo;
import com.zrqx.resource.commons.vo.fg.questionlibrary.FgSelectExamPaperVo;
import com.zrqx.resource.fg.manage.questionlibrary.FgExamPaperInfoManage;
import com.zrqx.resource.fg.mapper.courselibrary.FgCourseLibraryMapper;
import com.zrqx.resource.fg.mapper.questionlibrary.*;
import com.zrqx.resource.fg.mapper.videolibrary.FgVideoLibraryDiyTypeMapper;
import com.zrqx.resource.fg.service.courselibrary.FgCourseLibraryService;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 习题
*
* @author Jsx
* @version 1.0
* @date 2020/10/19 16:36
*/
@Service
public class FgExamPaperLibraryServiceImpl extends BaseServiceImpl<ExamPaperLibrary, Integer> implements FgExamPaperLibraryService {
@Autowired
private FgExamPaperLibraryMapper mapper;
@Autowired
private FgExamPaperInfoManage infoManage;
@Autowired
private FgExamPaperInfoMapper examPaperInfoMapper;
@Autowired
private FgExamRecordInfoMapper fgExamRecordInfoMapper;
@Autowired
private FgQuestionLibraryMapper fgQuestionLibraryMapper;
@Autowired
private FgExamRecordMapper fgExamRecordMapper;
@Autowired
private FgRedisManage redis;
@Autowired
private FgCourseLibraryMapper courseLibraryMapper;
@Autowired
private FgResourcLibraryExampaperDiyTypeMapper diyTypeMapper;
@Autowired
private FgVideoLibraryDiyTypeMapper videoLibraryDiyTypeMapper;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public BaseMapper<ExamPaperLibrary> getMapper() {
return null;
}
@Override
public PageInfo<ExamPaperLibrary> queryByPage(PageParam pageParam, FgSelectExamRecordForm form) {
startPage(pageParam);
List<ExamPaperLibrary> list = mapper.queryByPage(form);
list.forEach(this::fmtExamPaperLibrary);
return new PageInfo<ExamPaperLibrary>(list);
}
public void fmtExamPaperLibrary(ExamPaperLibrary examPaperLibrary) {
examPaperLibrary.setNum(infoManage.getCount(examPaperLibrary.getId()));//查询试卷中试题个数
ExamPaperInfo epInfo = new ExamPaperInfo();
epInfo.setExampaperid(examPaperLibrary.getId());
List<ExamPaperInfo> voList = examPaperInfoMapper.select(epInfo);
Integer scoreSum = voList.stream().collect(Collectors.summingInt(ExamPaperInfo::getScore));
examPaperLibrary.setSumscore(scoreSum);
}
public List<FgExamPaperInfoVo> ExamPaperInfo(Integer exampaperid,String resourcId) {
ExamPaperInfo record = new ExamPaperInfo();
record.setExampaperid(exampaperid);
List<ExamPaperInfo> list = infoManage.select(record);
List<FgExamPaperInfoVo> list2 = new ArrayList<FgExamPaperInfoVo>();
list.forEach(v -> {
QuestionLibrary re = fgQuestionLibraryMapper.selectByPrimaryKey(v.getQuestionid());
FgExamPaperInfoVo vo = new FgExamPaperInfoVo();
if (re != null) {
BeanUtils.copyProperties(re, vo);
vo.setId(v.getId());
vo.setQuestionid(re.getId());
vo.setSort(v.getSort());
vo.setScore(v.getScore());
list2.add(vo);
}
});
return list2.stream().sorted(Comparator.comparing(FgExamPaperInfoVo::getSort))
.collect(Collectors.toList());
}
/**
* 保存或者更新练习记录信息
* @param exampaperid
* @param resourcId
*/
@Override
public List<ExamRecordInfo> saveOrUpdateExamRecord(FgSelectExamRecordForm examRecordForm){
ExamRecord form = new ExamRecord();
form.setStuId(redis.getMember().getId()+""); //用户id
form.setExampaperid(examRecordForm.getExampaperid()); //试卷id
form.setResourcid(examRecordForm.getResourcId()); //资源类型id
//录获取该用户的课程下的试卷的练习记录
form = fgExamRecordMapper.getUserPracticeRecord(form);
PageParam pageParam = new PageParam();
FgSelectExamRecordForm form1 = new FgSelectExamRecordForm();
form1.setExampaperid(examRecordForm.getExampaperid());
form1.setResourcId(examRecordForm.getResourcId());
//获取试卷信息[试卷名称,试卷总分,总题数]
PageInfo<ExamPaperLibrary> info = queryByPage(pageParam,form1);
ExamPaperLibrary paperLibrary = info.getList().get(0);
//判断练习记录表中有没有该用户下的资源的试卷记录,如果有更新最新的试卷信息及试卷详情信息,否则直接插入
ExamRecord examRecord = new ExamRecord();
List<ExamRecordInfo> result = null;
if (form != null) {
examRecord.setId(form.getId());
examRecord.setExampaperid(form.getExampaperid());
examRecord.setName(paperLibrary.getName());
examRecord.setBegintime(sdf.format(new Date()));
examRecord.setSumscore(paperLibrary.getSumscore());
examRecord.setRealscore(0);
examRecord.setQuestionnum(paperLibrary.getQuestionnum());
fgExamRecordMapper.updateByPrimaryKeySelective(examRecord);
//保存练习记录详情信息
result = saveOrUpdateExamRecordInfo(form);
}
if (form == null) {
examRecord.setExampaperid(paperLibrary.getId());
examRecord.setName(paperLibrary.getName());
examRecord.setBegintime(sdf.format(new Date()));
examRecord.setSumscore(paperLibrary.getSumscore());
examRecord.setQuestionnum(paperLibrary.getNum());
examRecord.setStuId(redis.getMember().getId()+"");
examRecord.setResourcid(examRecordForm.getResourcId());
if (examRecordForm.getResourcId() ==null){
examRecord.setAuto(examRecordForm.getAuto());
}
fgExamRecordMapper.insert(examRecord);
//保存练习记录详情信息
result = saveOrUpdateExamRecordInfo(examRecord);
}
return result;
}
public List<ExamRecordInfo> saveOrUpdateExamRecordInfo (ExamRecord examRecord) {
List<ExamRecordInfo> result = new ArrayList<ExamRecordInfo>();
ExamRecordInfo examRecordInfo = new ExamRecordInfo();
examRecordInfo.setRecordid(examRecord.getId());
//删除练习记录下的关联的练习详情记录
fgExamRecordInfoMapper.delete(examRecordInfo);
result = examPaperInfoMapper.getExamPaperInfo(examRecord.getExampaperid()+"");
for (ExamRecordInfo e : result) {
e.setRecordid(examRecord.getId());
e.setExampaperinfoid(examRecord.getExampaperid()+"");
e.setReview(examRecord.getStuId());
}
fgExamRecordInfoMapper.insertList(result);
return result;
}
@Override
public Integer updateExamRecordInfo(FgSubmitExamRecordForm form) {
List<FgUpdateStudyRecordForm> list = form.getList();
ExamRecordInfo record = new ExamRecordInfo();
record.setRecordid(form.getRecordId());
//获取练习试题列表
List<ExamRecordInfo> infoList = fgExamRecordInfoMapper.select(record);
Map<Integer, ExamRecordInfo> infoMap = infoList.stream()
.collect(Collectors.toMap(ExamRecordInfo::getId, a -> a));
for (FgUpdateStudyRecordForm f : list) {
ExamRecordInfo eri = infoMap.get(f.getId());
if (StringUtils.isNotBlank(f.getAnswer())){
eri.setStuanswer(f.getAnswer().replace(",", ",")); //用户答案
}
eri.setIsRight(ExamUtils.compareAnswer(eri)); //对错
fgExamRecordInfoMapper.updateByPrimaryKeySelective(eri);
//修改试题的统计信息
this.updateQuestionLibrary(eri);
}
ExamRecord er = fgExamRecordMapper.selectByPrimaryKey(form.getRecordId());
er.setEndtime(sdf.format(new Date()));
try {
er.setReadtime(ExamUtils.minusMinutes(er.getBegintime(), er.getEndtime()));
} catch (Exception e) {
// TODO: handle exception
}
fgExamRecordMapper.updateByPrimaryKeySelective(er);
return list.size();
}
/**
* 修改试题的统计信息
* @param eri
*/
private void updateQuestionLibrary(ExamRecordInfo eri) {
QuestionLibrary ql = fgQuestionLibraryMapper.selectByPrimaryKey(eri.getQuestionId());
ql.setNumberofuse((ql.getNumberofuse().intValue())+1); //试题使用次数
if(eri.getIsRight() == 1){
ql.setNumberofright(ql.getNumberofright()+1); //试题正确次数
}
//错误率
ql.setWrongPercent(ExamUtils.countRightPercent((ql.getNumberofuse()-ql.getNumberofright()), ql.getNumberofuse()));
fgQuestionLibraryMapper.updateByPrimaryKeySelective(ql);
}
@Override
public List<ExamRecord> getExamRecord(Integer recordid) {
ExamRecord record = new ExamRecord();
record.setId(recordid);
List<ExamRecord> list = fgExamRecordMapper.select(record);
return list;
}
@Override
public List<ExamRecordInfo> getExamRecordInfo(Integer recordid) {
ExamRecordInfo info = new ExamRecordInfo();
info.setRecordid(recordid);
List<ExamRecordInfo> list = fgExamRecordInfoMapper.select(info);
return list;
}
@Override
public ExamRecord updateCheckExamRecord(Integer recordId) {
ExamRecord record = new ExamRecord();
record = fgExamRecordMapper.selectByPrimaryKey(recordId);
ExamRecordInfo recordInfo = new ExamRecordInfo();
recordInfo.setRecordid(record.getId());
List<ExamRecordInfo> infoList = fgExamRecordInfoMapper.select(recordInfo);
int rightAnswer = 0;
int errorAnswer = 0;
int realscore = 0;
//判断试题对错,isRight==1时是正确,==0为错误,客观题不参与计算。
for (ExamRecordInfo info : infoList) {
if (info.getIsRight() != null) {
if (1 == info.getIsRight().intValue()) {
rightAnswer++;
realscore = realscore + info.getScore();
}else if (0 == info.getIsRight().intValue()) {
errorAnswer++;
}
}
}
record.setRightnum(rightAnswer);
record.setErrornum(errorAnswer);
record.setPrecisionpercent(ExamUtils.countRightPercentStr(rightAnswer,record.getQuestionnum()));
record.setRealscore(realscore);
fgExamRecordMapper.updateByPrimaryKeySelective(record);
return record;
}
@Override
public List<FgSelectExamPaperVo> getExamPaper(PageParam pageParam, FgSelectExamPaperForm form) {
startPage(pageParam);
List<FgSelectExamPaperVo> list = new ArrayList<>();
FgSelectExamPaperVo vo = new FgSelectExamPaperVo();
//查询试卷库所有试卷
List<ExamPaperLibrary> examPaper = mapper.selectExamPaper(form);
//查询用户下所有试卷的答题记录
List<ExamRecord> recordList = fgExamRecordMapper.getSelectExamRecord(redis.getMember().getId() + "");
Map<Integer, ExamRecord> infoMap = recordList.stream()
.collect(Collectors.toMap(ExamRecord::getExampaperid, a -> a));
for (ExamPaperLibrary paper : examPaper) {
ExamRecord examRecord = infoMap.get(paper.getId());
if(examRecord != null) {
vo.setRealscore(examRecord.getRealscore());
vo.setTime(examRecord.getBegintime());
}
vo.setId(paper.getId());
vo.setName(paper.getName());
vo.setSumscore(paper.getSumscore());
list.add(vo);
}
return list;
}
@Override
public List<ExamRecordInfo> simulatePractice(FgSelectExamRecordForm form){
//判断该用户是否有相应的权限
FgMyLearningForm form1 = new FgMyLearningForm();
form1.setMemberId(redis.getMember().getId());
form1.setResourceType(AllResourceTypeEnum.COURSE.getCode());
List<FgMyLearningListVo> list = courseLibraryMapper.getMyLearningList(form1); //获取我的学习资源
List<String> list1 = list.stream().map(FgMyLearningListVo::getId).collect(Collectors.toList());
List<ResourcLibraryExampaerDiyType> diyTypes = diyTypeMapper.getResourcLibrary(list1,form);
if (diyTypes == null) {
throw new BusinessValidateException("暂无权限");
}
ResourcLibraryExampaerDiyType diyType = diyTypes.get(0);
FgSelectExamRecordForm examRecordForm = new FgSelectExamRecordForm();
examRecordForm.setExampaperid(diyType.getExampaperId());
examRecordForm.setResourcId(diyType.getResourcId());
List<ExamRecordInfo> examRecordInfo = saveOrUpdateExamRecord(examRecordForm);
return examRecordInfo;
}
@Override
public List<ExamRecordInfo> autoConnectQuestion(FgSelectExamPaperForm form){
FgMyLearningForm form1 = new FgMyLearningForm();
form1.setMemberId(redis.getMember().getId());
form1.setResourceType(AllResourceTypeEnum.COURSE.getCode());
List<FgMyLearningListVo> list = courseLibraryMapper.getMyLearningList(form1); //获取我的学习资源
List<String> list1 = list.stream().map(FgMyLearningListVo::getId).collect(Collectors.toList());
List<String> diyType = videoLibraryDiyTypeMapper.getDiyType(list1, form);
if (diyType == null) {
throw new BusinessValidateException("暂无权限");
}
List<ExamRecordInfo> result = autoSaveExamRecord(diyType, form1.getMemberId());
return result;
}
public List<ExamRecordInfo> autoSaveExamRecord (List<String> diyType,Integer memberId){
ExamRecord form = new ExamRecord();
form.setStuId(redis.getMember().getId()+""); //用户id
form.setAuto(1);
//获取该用户的课程下的试卷的练习记录
form = fgExamRecordMapper.getUserPracticeRecord(form);
ExamRecord examRecord = new ExamRecord();
List<ExamRecordInfo> result = null;
if (form != null){
examRecord.setId(form.getId());
examRecord.setBegintime(sdf.format(new Date()));
examRecord.setQuestionnum(10);
examRecord.setCreateTime(new Date());
fgExamRecordMapper.updateByPrimaryKeySelective(examRecord);
result = autoSaveExamRecordInfo(examRecord.getId(),diyType ,memberId);
}
if (form == null) {
examRecord.setName("自主练习");
examRecord.setBegintime(sdf.format(new Date()));
examRecord.setQuestionnum(10);
examRecord.setStuId(redis.getMember().getId()+"");
examRecord.setAuto(1);
fgExamRecordMapper.insert(examRecord);
result = autoSaveExamRecordInfo(examRecord.getId(), diyType, memberId);
}
return result;
}
public List<ExamRecordInfo> autoSaveExamRecordInfo(Integer recordId, List<String> diyType, Integer memberId){
ExamRecordInfo examRecordInfo = new ExamRecordInfo();
examRecordInfo.setRecordid(recordId);
//删除练习记录下的关联的练习详情记录
fgExamRecordInfoMapper.delete(examRecordInfo);
List<ExamRecordInfo> result = new ArrayList<ExamRecordInfo>();
//获取所有可用的试题
List<QuestionLibrary> question = fgQuestionLibraryMapper.getSelectQuestion(diyType);
Map<Integer, List<QuestionLibrary>> listMap = question.stream().collect(Collectors.groupingBy(QuestionLibrary::getQuestionType));
// 如果测试详情总数大于等于10 或者 试题库map中的已经没有试题则跳出循环
int Questionnum = 0; //试题总数
int sumscore = 0; //试题总分
// 试卷中已经选择的试题id
List<Integer> isHaveQuestionIdList = new ArrayList<Integer>();
while (result.size() < 10 && listMap.keySet().size() > 0) {
int questionType = ExamUtils.getRandomNum(listMap.keySet());
List<QuestionLibrary> libraries = listMap.get(questionType);
if (libraries == null || libraries.size() ==0) {
listMap.remove(questionType);
continue;
}
int questionNumber = ExamUtils.getRandomNum(libraries);
QuestionLibrary ql = libraries.get(questionNumber);
if (isHaveQuestionIdList.contains(ql.getId())) {
libraries.remove(ql);
listMap.put(questionType,libraries);
continue;
}
ExamRecordInfo info = JSON.toJavaObject((JSONObject) JSON.toJSON(ql), ExamRecordInfo.class);
info.setRecordid(recordId);
info.setQuestionId(ql.getId());
info.setIsRight(0);
info.setReview(memberId+"");
result.add(info);
isHaveQuestionIdList.add(ql.getId());
libraries.remove(ql);
listMap.put(questionType,libraries);
Questionnum++;
sumscore = sumscore + ql.getScore().intValue();
}
fgExamRecordInfoMapper.insertList(result);
ExamRecord examRecord = new ExamRecord();
examRecord.setId(recordId);
examRecord.setQuestionnum(Questionnum);
examRecord.setSumscore(sumscore);
fgExamRecordMapper.updateByPrimaryKeySelective(examRecord);
return result;
}
}
......@@ -10,9 +10,11 @@ import javax.persistence.Table;
import java.util.Date;
/**
* 考试记录详细 ExamRecordInfo entity. @author MyEclipse Persistence Tools
* 考试记录详情
* @author Jsx
* @date 2020/10/21 11:05
* @version 1.0
*/
@Data
@ApiModel(value = "ExamRecordInfo", description = "考试记录详细")
@Table(name = "res_examrecordinfo")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论