实现学生签到和考试功能增强

dev
zhangyue 2026-01-29 15:40:37 +08:00
parent 8b65050d71
commit 2bda8de692
32 changed files with 390 additions and 61 deletions

View File

@ -0,0 +1,51 @@
package com.zcloud.edu.app.study;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.edu.api.study.StudentExamRecordServiceI;
import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO;
import com.zcloud.edu.dto.clientobject.study.StudentSignCO;
import com.zcloud.edu.dto.study.StudentExamRecordAddCmd;
import com.zcloud.edu.dto.study.StudentExamRecordPageQry;
import com.zcloud.edu.dto.study.StudentExamRecordUpdateCmd;
import com.zcloud.edu.dto.study.StudentSignPageQry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
/**
* web-adapter
*
* @Author zhangyue
* @Date 2026-01-13 14:18:16
*/
@Api(tags = "考试信息")
@RequestMapping("/${application.gateway}/app/studentExamRecord")
@RestController
@AllArgsConstructor
public class AppStudentExamRecordController {
private final StudentExamRecordServiceI studentExamRecordService;
@ApiOperation("提交试卷")
@PostMapping("/submit")
public SingleResponse<StudentExamRecordCO> submit(@Validated @RequestBody StudentExamRecordAddCmd cmd) {
SSOUser ssoUser = AuthContext.getCurrentUser();
return studentExamRecordService.add(cmd);
}
@ApiOperation("分页")
@PostMapping("/list")
public PageResponse<StudentExamRecordCO> page(@RequestBody StudentExamRecordPageQry qry) {
return studentExamRecordService.listPage(qry);
}
}

View File

@ -74,8 +74,8 @@ public class AppStudentSignController {
return SingleResponse.buildSuccess();
}
@ApiOperation("修改")
@PutMapping("/edit")
@ApiOperation("上传签到签字")
@PostMapping("/uploadSignUrl")
public SingleResponse edit(@Validated @RequestBody StudentSignUpdateCmd studentSignUpdateCmd) {
studentSignService.edit(studentSignUpdateCmd);
return SingleResponse.buildSuccess();

View File

@ -10,6 +10,7 @@ import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.edu.api.study.StudentServiceI;
import com.zcloud.edu.dto.clientobject.study.StudentCO;
import com.zcloud.edu.dto.study.StudentAddCmd;
import com.zcloud.edu.dto.study.StudentCountQry;
import com.zcloud.edu.dto.study.StudentPageQry;
import com.zcloud.edu.dto.study.StudentUpdateCmd;
import io.swagger.annotations.Api;
@ -65,6 +66,12 @@ public class StudentController {
return SingleResponse.of(studentService.countStudent(classId));
}
@ApiOperation("班级内学员数")
@PostMapping("/countStudentByCorpId")
public MultiResponse<StudentCO> countStudentByCorpId(@RequestBody StudentCountQry qry) {
return studentService.countStudentByCorpId(qry);
}
@ApiOperation("删除")
@PostMapping("/{id}")
public Response remove(@PathVariable("id") Long id) {

View File

@ -1,6 +1,7 @@
package com.zcloud.edu.command.query.study;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.edu.command.convertor.study.StudentCoConvertor;
@ -12,6 +13,7 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO;
import com.zcloud.edu.dto.clientobject.study.StudentSignCO;
import com.zcloud.edu.dto.data.archives.ClassArchivesDTO;
import com.zcloud.edu.dto.data.archives.PersonArchivesDTO;
import com.zcloud.edu.dto.study.StudentCountQry;
import com.zcloud.edu.dto.study.StudentPageQry;
import com.zcloud.edu.persistence.dataobject.study.*;
import com.zcloud.edu.persistence.repository.study.*;
@ -204,5 +206,16 @@ public class StudentQueryExe {
classArchivesDTO.setFailStudentList(failStudentList);
return SingleResponse.of(classArchivesDTO);
}
public MultiResponse<StudentCO> executeCountStudentByCorpId(StudentCountQry qry){
Map<String, Object> params = PageQueryHelper.toHashMap(qry);
List<StudentDO> studentDOList = studentRepository.countStudentByCorpId(params);
List<StudentCO> studentCOList = BeanUtil.copyToList(studentDOList, StudentCO.class);
return MultiResponse.of(studentCOList);
}
}

View File

@ -1,14 +1,33 @@
package com.zcloud.edu.command.study;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.alibaba.cola.exception.BizException;
import com.zcloud.edu.domain.gateway.study.StudentExamRecordGateway;
import com.zcloud.edu.domain.model.study.ClassExamPaperE;
import com.zcloud.edu.domain.model.study.StudentExamRecordE;
import com.zcloud.edu.domain.model.study.StudentExamRecordItemE;
import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO;
import com.zcloud.edu.dto.study.StudentExamRecordAddCmd;
import com.zcloud.edu.dto.study.StudentExamRecordItemAddCmd;
import com.zcloud.edu.persistence.dataobject.study.ClassDO;
import com.zcloud.edu.persistence.dataobject.study.ClassExamPaperDO;
import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO;
import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordItemDO;
import com.zcloud.edu.persistence.repository.study.ClassExamPaperRepository;
import com.zcloud.edu.persistence.repository.study.ClassRepository;
import com.zcloud.edu.persistence.repository.study.StudentExamRecordItemRepository;
import com.zcloud.edu.persistence.repository.study.StudentExamRecordRepository;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
/**
* web-app
@ -20,21 +39,41 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor
public class StudentExamRecordAddExe {
private final StudentExamRecordGateway studentExamRecordGateway;
private final ClassExamPaperRepository classExamPaperRepository;
private final StudentExamRecordItemRepository studentExamRecordItemRepository;
private final StudentExamRecordRepository studentExamRecordRepository;
private final ClassRepository classRepository;
@Transactional(rollbackFor = Exception.class)
public boolean execute(StudentExamRecordAddCmd cmd) {
public SingleResponse<StudentExamRecordCO> execute(StudentExamRecordAddCmd cmd) {
ClassDO classDO = classRepository.getByClassId(cmd.getClassId());
Integer count = studentExamRecordRepository.countByStudentId(cmd.getStudentId());
if (count >= classDO.getNumberofexams()) {
throw new BizException("您已经没有考试次数");
}
StudentExamRecordE studentExamRecordE = new StudentExamRecordE();
ClassExamPaperDO classExamPaper = classExamPaperRepository.findByClassId(cmd.getClassId());
List<StudentExamRecordItemAddCmd> questionList = cmd.getQuestionList();
List<StudentExamRecordItemE> queList = BeanUtil.copyToList(questionList, StudentExamRecordItemE.class);
BeanUtils.copyProperties(cmd, studentExamRecordE);
studentExamRecordE.submit(classExamPaper.getPassScore(), queList);
boolean res = false;
try {
res = studentExamRecordGateway.add(studentExamRecordE);
studentExamRecordItemRepository.saveBatch(BeanUtil.copyToList(queList, StudentExamRecordItemDO.class));
} catch (Exception e) {
throw new RuntimeException(e);
}
if (!res) {
throw new BizException("保存失败");
}
return true;
StudentExamRecordCO studentExamRecordCO = new StudentExamRecordCO();
BeanUtils.copyProperties(studentExamRecordE, studentExamRecordCO);
studentExamRecordCO.setSurplusExamNum(classDO.getNumberofexams() - count - 1);
return SingleResponse.of(studentExamRecordCO);
}
}

View File

@ -4,11 +4,16 @@ import com.alibaba.cola.exception.BizException;
import com.zcloud.edu.domain.gateway.study.StudentSignGateway;
import com.zcloud.edu.domain.model.study.StudentSignE;
import com.zcloud.edu.dto.study.StudentSignUpdateCmd;
import com.zcloud.edu.persistence.dataobject.study.StudentDO;
import com.zcloud.edu.persistence.repository.study.StudentRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
/**
* web-app
@ -20,12 +25,22 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor
public class StudentSignUpdateExe {
private final StudentSignGateway studentSignGateway;
private final StudentRepository studentRepository;
@Transactional(rollbackFor = Exception.class)
public void execute(StudentSignUpdateCmd studentSignUpdateCmd) {
StudentSignE studentSignE = new StudentSignE();
BeanUtils.copyProperties(studentSignUpdateCmd, studentSignE);
boolean res = studentSignGateway.update(studentSignE);
Map<String, Object> params = new HashMap<>();
if (studentSignUpdateCmd.getType() == 1){
params.put("signFlag",1);
} else if (studentSignUpdateCmd.getType() == 2){
params.put("examSignFlag",1);
}
params.put("studentId", studentSignUpdateCmd.getStudentId());
studentRepository.updateStudent(params);
if (!res) {
throw new BizException("修改失败");
}

View File

@ -1,6 +1,7 @@
package com.zcloud.edu.service.study;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.edu.api.study.StudentExamRecordServiceI;
import com.zcloud.edu.command.query.study.StudentExamRecordQueryExe;
@ -14,6 +15,8 @@ import com.zcloud.edu.dto.study.StudentExamRecordUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* web-app
*
@ -35,10 +38,8 @@ public class StudentExamRecordServiceImpl implements StudentExamRecordServiceI {
}
@Override
public SingleResponse add(StudentExamRecordAddCmd cmd) {
studentExamRecordAddExe.execute(cmd);
return SingleResponse.buildSuccess();
public SingleResponse<StudentExamRecordCO> add(StudentExamRecordAddCmd cmd) {
return studentExamRecordAddExe.execute(cmd);
}
@Override

View File

@ -1,5 +1,6 @@
package com.zcloud.edu.service.study;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.edu.api.study.StudentServiceI;
@ -12,10 +13,12 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO;
import com.zcloud.edu.dto.data.archives.ClassArchivesDTO;
import com.zcloud.edu.dto.data.archives.PersonArchivesDTO;
import com.zcloud.edu.dto.study.StudentAddCmd;
import com.zcloud.edu.dto.study.StudentCountQry;
import com.zcloud.edu.dto.study.StudentPageQry;
import com.zcloud.edu.dto.study.StudentUpdateCmd;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -89,5 +92,10 @@ public class StudentServiceImpl implements StudentServiceI {
public SingleResponse<ClassArchivesDTO> getClassExamResult(ClassArchivesQry qry) {
return studentQueryExe.executeGetClassExamResult(qry);
}
@Override
public MultiResponse<StudentCO> countStudentByCorpId(StudentCountQry qry) {
return studentQueryExe.executeCountStudentByCorpId(qry);
}
}

View File

@ -1,5 +1,6 @@
package com.zcloud.edu.api.study;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.edu.dto.archives.ClassArchivesQry;
@ -7,8 +8,10 @@ import com.zcloud.edu.dto.clientobject.study.StudentCO;
import com.zcloud.edu.dto.data.archives.ClassArchivesDTO;
import com.zcloud.edu.dto.data.archives.PersonArchivesDTO;
import com.zcloud.edu.dto.study.StudentAddCmd;
import com.zcloud.edu.dto.study.StudentCountQry;
import com.zcloud.edu.dto.study.StudentPageQry;
import com.zcloud.edu.dto.study.StudentUpdateCmd;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -40,5 +43,7 @@ public interface StudentServiceI {
Long countStudent(String classId);
SingleResponse<ClassArchivesDTO> getClassExamResult(ClassArchivesQry qry);
MultiResponse<StudentCO> countStudentByCorpId(StudentCountQry qry);
}

View File

@ -175,6 +175,10 @@ public class StudentCO extends ClientObject {
private Integer numberofexams;
// 学员统计数量
@ApiModelProperty(value = "学员统计数量")
@TableField(exist = false)
private Integer studentCount;

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@ -56,7 +57,7 @@ public class StudentExamRecordCO extends ClientObject {
private Integer examQuestionWrong;
//考试得分
@ApiModelProperty(value = "考试得分")
private Object examScore;
private BigDecimal examScore;
//考试结果 0 -不通过 1-通过
@ApiModelProperty(value = "考试结果 0 -不通过 1-通过")
private Integer result;
@ -67,6 +68,9 @@ public class StudentExamRecordCO extends ClientObject {
@ApiModelProperty(value = "试题集合")
private List<StudentExamRecordItemCO> examRecordItemList;
@ApiModelProperty(value = "剩余考试次数")
private Integer surplusExamNum;
//环境
@ApiModelProperty(value = "环境")
private String env;

View File

@ -28,15 +28,19 @@ public class StudentExamRecordItemCO extends ClientObject {
//学员id
@ApiModelProperty(value = "学员id")
private String studentId;
//班级id
@ApiModelProperty(value = "班级id")
private String classId;
//习题ID
@ApiModelProperty(value = "习题ID")
private String questionId;
//学员答案
@ApiModelProperty(value = "学员答案")
@ApiModelProperty(value = "正确答案")
private String answer;
//正确答案
@ApiModelProperty(value = "正确答案")
private String answerRight;
@ApiModelProperty(value = "学员答案")
private String choiceAnswer;
//删除标识true false
@ApiModelProperty(value = "删除标识true false")
private String deleteEnum;

View File

@ -0,0 +1,36 @@
package com.zcloud.edu.dto.study;
import com.alibaba.cola.dto.PageQuery;
import lombok.Data;
import java.util.List;
/**
* web-client
*
* @Author zhangyue
* @Date 2026-01-13 14:18:15
*/
@Data
public class StudentCountQry {
/**
* ,
* - `like`: SQLLIKE
* - `eq`: SQL=
* - `gt`:
* - `lt`:
* - `ge`:
* - `le`:
* - `ne`: SQL!=
*/
private String eqStudentId;
private String eqClassId;
private String likeProjectNames;
private String likeName;
private String likeInterestedIds;
private List<Long> corpinfoIds;
}

View File

@ -9,6 +9,8 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
/**
* web-client
@ -22,60 +24,50 @@ import javax.validation.constraints.NotNull;
@AllArgsConstructor
public class StudentExamRecordAddCmd extends Command {
@ApiModelProperty(value = "业务id", name = "studentExamRecordId", required = true)
@NotEmpty(message = "业务id不能为空")
private String studentExamRecordId;
@ApiModelProperty(value = "用户id", name = "userId", required = true)
@NotNull(message = "用户id不能为空")
private Long userId;
@ApiModelProperty(value = "学员id", name = "studentId", required = true)
@NotEmpty(message = "学员id不能为空")
private String studentId;
@ApiModelProperty(value = "班级id", name = "classId", required = true)
@NotEmpty(message = "班级id不能为空")
private String classId;
@ApiModelProperty(value = "企业id", name = "corpinfoId", required = true)
@NotNull(message = "企业id不能为空")
private Long corpinfoId;
@ApiModelProperty(value = "班级-试卷 表ID", name = "classExamPaperId", required = true)
@NotEmpty(message = "班级-试卷 表ID不能为空")
private String classExamPaperId;
@ApiModelProperty(value = "试卷id", name = "examPaperId", required = true)
@NotEmpty(message = "试卷id不能为空")
private String examPaperId;
@ApiModelProperty(value = "考试时间", name = "examTimeBegin", required = true)
@NotEmpty(message = "考试时间不能为空")
private String examTimeBegin;
@ApiModelProperty(value = "考试交卷时间", name = "examTimeEnd", required = true)
@NotEmpty(message = "考试交卷时间不能为空")
private String examTimeEnd;
@ApiModelProperty(value = "考试总题数", name = "examQuestionNum", required = true)
@NotNull(message = "考试总题数不能为空")
private Integer examQuestionNum;
@ApiModelProperty(value = "考试对题数", name = "examQuestionRight", required = true)
@NotNull(message = "考试对题数不能为空")
private Integer examQuestionRight;
@ApiModelProperty(value = "考试错题数", name = "examQuestionWrong", required = true)
@NotNull(message = "考试错题数不能为空")
private Integer examQuestionWrong;
@ApiModelProperty(value = "考试得分", name = "examScore", required = true)
@NotEmpty(message = "考试得分不能为空")
private Object examScore;
private BigDecimal examScore;
@ApiModelProperty(value = "考试结果 0 -不通过 1-通过", name = "result", required = true)
@NotNull(message = "考试结果 0 -不通过 1-通过不能为空")
private Integer result;
@ApiModelProperty(value = "选项", name = "questionList", required = true)
@NotNull(message = "选项不能为空")
private List<StudentExamRecordItemAddCmd> questionList;
}

View File

@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
/**
* web-client
@ -21,28 +22,24 @@ import javax.validation.constraints.NotEmpty;
@AllArgsConstructor
public class StudentExamRecordItemAddCmd extends Command {
@ApiModelProperty(value = "业务id", name = "studentExamRecordItemId", required = true)
@NotEmpty(message = "业务id不能为空")
private String studentExamRecordItemId;
@ApiModelProperty(value = "考试记录id", name = "studentExamRecordId", required = true)
@NotEmpty(message = "考试记录id不能为空")
private String studentExamRecordId;
@ApiModelProperty(value = "学员id", name = "studentId", required = true)
@NotEmpty(message = "学员id不能为空")
private String studentId;
@ApiModelProperty(value = "习题ID", name = "questionId", required = true)
@NotEmpty(message = "习题ID不能为空")
private String questionId;
@ApiModelProperty(value = "学员答案", name = "answer", required = true)
@NotEmpty(message = "学员答案不能为空")
@ApiModelProperty(value = "正确答案", name = "answer", required = true)
private String answer;
@ApiModelProperty(value = "正确答案", name = "answerRight", required = true)
@NotEmpty(message = "正确答案不能为空")
private String answerRight;
@ApiModelProperty(value = "学员答案", name = "choiceAnswer", required = true)
private String choiceAnswer;
@ApiModelProperty(value = "分值", name = "score", required = true)
private BigDecimal score;
}

View File

@ -36,11 +36,11 @@ public class StudentExamRecordItemUpdateCmd extends Command {
@ApiModelProperty(value = "习题ID", name = "questionId", required = true)
@NotEmpty(message = "习题ID不能为空")
private String questionId;
@ApiModelProperty(value = "学员答案", name = "answer", required = true)
@NotEmpty(message = "学员答案不能为空")
private String answer;
@ApiModelProperty(value = "正确答案", name = "answerRight", required = true)
@ApiModelProperty(value = "正确答案", name = "answer", required = true)
@NotEmpty(message = "正确答案不能为空")
private String answerRight;
private String answer;
@ApiModelProperty(value = "学员答案", name = "choiceAnswer", required = true)
@NotEmpty(message = "学员答案不能为空")
private String choiceAnswer;
}

View File

@ -24,5 +24,6 @@ public class StudentExamRecordPageQry extends PageQuery {
* - `ne`: SQL!=
*/
private String likeStudentExamRecordId;
private String likeStudentId;
}

View File

@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* web-client
@ -62,7 +63,7 @@ public class StudentExamRecordUpdateCmd extends Command {
private Integer examQuestionWrong;
@ApiModelProperty(value = "考试得分", name = "examScore", required = true)
@NotEmpty(message = "考试得分不能为空")
private Object examScore;
private BigDecimal examScore;
@ApiModelProperty(value = "考试结果 0 -不通过 1-通过", name = "result", required = true)
@NotNull(message = "考试结果 0 -不通过 1-通过不能为空")
private Integer result;

View File

@ -21,29 +21,25 @@ import javax.validation.constraints.NotNull;
@NoArgsConstructor
@AllArgsConstructor
public class StudentSignUpdateCmd extends Command {
@ApiModelProperty(value = "${column.comment}", name = "id", required = true)
@NotNull(message = "${column.comment}不能为空")
@ApiModelProperty(value = "id", name = "id", required = true)
@NotNull(message = "id不能为空")
private Long id;
@ApiModelProperty(value = "学员id", name = "studentId", required = true)
@NotEmpty(message = "学员id不能为空")
private String studentId;
@ApiModelProperty(value = "业务id", name = "studentSignId", required = true)
@NotEmpty(message = "业务id不能为空")
private String studentSignId;
@ApiModelProperty(value = "班级id", name = "classId", required = true)
@NotEmpty(message = "班级id不能为空")
private String classId;
@ApiModelProperty(value = "用户id", name = "userId", required = true)
@NotNull(message = "用户id不能为空")
private Long userId;
@ApiModelProperty(value = "企业id", name = "corpinfoId", required = true)
@NotNull(message = "企业id不能为空")
private Long corpinfoId;
@ApiModelProperty(value = "签到人脸路径", name = "faceUrl", required = true)
@NotEmpty(message = "签到人脸路径不能为空")
private String faceUrl;
@ApiModelProperty(value = "签字路径", name = "signUrl", required = true)
private String signUrl;
@ApiModelProperty(value = "签到类型 1-打卡签到 2-人脸签到", name = "type", required = true)
@NotNull(message = "签到类型 1-打卡签到 2-人脸签到不能为空")
private Integer type;
}

View File

@ -1,9 +1,14 @@
package com.zcloud.edu.domain.model.study;
import com.jjb.saas.framework.domain.model.BaseE;
import com.zcloud.gbscommon.utils.Tools;
import lombok.Data;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/**
* web-domain
@ -39,7 +44,7 @@ public class StudentExamRecordE extends BaseE {
//考试错题数
private Integer examQuestionWrong;
//考试得分
private Object examScore;
private BigDecimal examScore;
//考试结果 0 -不通过 1-通过
private Integer result;
//环境
@ -66,5 +71,38 @@ public class StudentExamRecordE extends BaseE {
private Long createId;
//修改人id
private Long updateId;
// 构造函数
public void submit(BigDecimal passScore, List<StudentExamRecordItemE> queList){
examScore = BigDecimal.ZERO;
examQuestionRight = 0;
examQuestionWrong = 0;
examQuestionNum = 0;
this.setStudentExamRecordId(Tools.get32UUID());
this.setExamQuestionNum(queList.size());
for (StudentExamRecordItemE que : queList) {
que.setStudentExamRecordId(this.getStudentExamRecordId());
que.setStudentExamRecordItemId(Tools.get32UUID());
que.setStudentId(this.getStudentId());
que.setClassId(this.getClassId());
if (!ObjectUtils.isEmpty(que.getChoiceAnswer())){
String choiceAnswer = que.getChoiceAnswer().chars()
.sorted()
.mapToObj(c -> String.valueOf((char) c))
.collect(Collectors.joining());
if (choiceAnswer.equals(que.getAnswer())){
examScore = examScore.add(que.getScore());
examQuestionRight++;
}
}
}
this.setExamQuestionWrong(examQuestionNum - examQuestionRight);
if (examScore.compareTo(passScore) >= 0){
result = 1;
} else {
result = 0;
}
}
}

View File

@ -3,6 +3,7 @@ package com.zcloud.edu.domain.model.study;
import com.jjb.saas.framework.domain.model.BaseE;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
@ -20,12 +21,16 @@ public class StudentExamRecordItemE extends BaseE {
private String studentExamRecordId;
//学员id
private String studentId;
//班级id
private String classId;
//习题ID
private String questionId;
//学员答案
//
private String answer;
//正确答案
private String answerRight;
// 分数
private BigDecimal score;
// 学员选择答案
private String choiceAnswer;
//删除标识true false
private String deleteEnum;
//备注

View File

@ -101,6 +101,12 @@ public class StudentDO extends BaseDO {
@TableField(exist = false)
private Integer classCount;
// 学员统计数量
@ApiModelProperty(value = "学员统计数量")
@TableField(exist = false)
private Integer studentCount;
@ApiModelProperty(value = "完成班级数")
@TableField(exist = false)
private Integer completeClassCount;

View File

@ -8,6 +8,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* web-infrastructure
*
@ -57,7 +59,7 @@ public class StudentExamRecordDO extends BaseDO {
private Integer examQuestionWrong;
//考试得分
@ApiModelProperty(value = "考试得分")
private Object examScore;
private BigDecimal examScore;
//考试结果 0 -不通过 1-通过
@ApiModelProperty(value = "考试结果 0 -不通过 1-通过")
private Integer result;
@ -70,5 +72,22 @@ public class StudentExamRecordDO extends BaseDO {
private String signUrl;
//试卷名称
@ApiModelProperty(value = "试卷名称")
@TableField(exist = false)
private String examName;
//试卷总分数
@ApiModelProperty(value = "试卷总分数")
@TableField(exist = false)
private BigDecimal paperExamScore;
//合格分数
@ApiModelProperty(value = "合格分数")
@TableField(exist = false)
private BigDecimal passScore;
//考试时长(分钟)
@ApiModelProperty(value = "考试时长(分钟)")
@TableField(exist = false)
private Integer examTime;
}

View File

@ -37,11 +37,11 @@ public class StudentExamRecordItemDO extends BaseDO {
@ApiModelProperty(value = "习题ID")
private String questionId;
//学员答案
@ApiModelProperty(value = "学员答案")
@ApiModelProperty(value = "正确答案")
private String answer;
//正确答案
@ApiModelProperty(value = "正确答案")
private String answerRight;
@ApiModelProperty(value = "学员答案")
private String choiceAnswer;
@ApiModelProperty(value = "试题类型1单选题、2多选题、3判断题")

View File

@ -1,6 +1,9 @@
package com.zcloud.edu.persistence.mapper.study;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zcloud.edu.persistence.dataobject.study.ClassDO;
import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -15,5 +18,9 @@ import org.apache.ibatis.annotations.Param;
public interface StudentExamRecordMapper extends BaseMapper<StudentExamRecordDO> {
StudentExamRecordDO getInfoByStudentId(@Param("studentId") String studentId);
Integer countByStudentId(@Param("studentId") String studentId);
IPage<StudentExamRecordDO> listPage(IPage<StudentExamRecordDO> page, @Param("ew") QueryWrapper<StudentExamRecordDO> queryWrapper, String menuPerms);
}

View File

@ -29,6 +29,10 @@ public interface StudentMapper extends BaseMapper<StudentDO> {
List<StudentDO> listAll(@Param("params") Map<String, Object> params);
void updateStudent(@Param("params") Map<String, Object> params);
List<StudentDO> countStudentByCorpId(@Param("params") Map<String, Object> params);
}

View File

@ -68,5 +68,10 @@ public class StudentExamRecordRepositoryImpl extends BaseRepositoryImpl<StudentE
public StudentExamRecordDO getInfoByStudentId(String studentId) {
return studentExamRecordMapper.getInfoByStudentId(studentId);
}
@Override
public Integer countByStudentId(String studentId) {
return studentExamRecordMapper.countByStudentId(studentId);
}
}

View File

@ -102,5 +102,15 @@ public class StudentRepositoryImpl extends BaseRepositoryImpl<StudentMapper, Stu
return studentMapper.listAll(params);
}
@Override
public void updateStudent(Map<String, Object> params) {
studentMapper.updateStudent(params);
}
@Override
public List<StudentDO> countStudentByCorpId(Map<String, Object> params) {
return studentMapper.countStudentByCorpId(params);
}
}

View File

@ -23,5 +23,7 @@ public interface StudentExamRecordRepository extends BaseRepository<StudentExamR
List<StudentExamRecordDO> listAllByStudentId(String studentId);
StudentExamRecordDO getInfoByStudentId(String studentId);
Integer countByStudentId(String studentId);
}

View File

@ -31,12 +31,14 @@ public interface StudentRepository extends BaseRepository<StudentDO> {
StudentDO findFaceUrlByPhone(String phone);
List<StudentDO> countStuClass(Map<String, Object> params);
List<StudentDO> countStuClass(Map<String, Object> params);
StudentDO findInfoByStudentId(String studentId);
List<StudentDO> listAll(Map<String, Object> params);
void updateStudent(Map<String, Object> params);
List<StudentDO> countStudentByCorpId(Map<String, Object> params);
}

View File

@ -33,5 +33,30 @@
er.result desc, er.exam_score desc, er.create_time desc
limit 1
</select>
<select id="countByStudentId" resultType="java.lang.Integer">
SELECT
count(1)
FROM
student_exam_record
<where>
delete_enum = 'FALSE'
and student_id = #{studentId}
</where>
</select>
<select id="listPage" resultType="com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO">
SELECT
er.*,
ep.exam_name,
ep.paper_exam_score,
ep.pass_score,
ep.exam_time
from
student_exam_record er
left join class_exam_paper ep on er.class_exam_paper_id = ep.class_exam_paper_id
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -103,5 +103,37 @@
</where>
</select>
<update id="updateStudent">
update
student
<set>
<if test="params.signFlag != null and params.signFlag != ''">
,sign_flag = #{params.signFlag}
</if>
<if test="params.examSignFlag != null and params.examSignFlag != ''">
,exam_sign_flag = #{params.examSignFlag}
</if>
</set>
where
student_id = #{params.studentId}
</update>
<select id="countStudentByCorpId" resultType="com.zcloud.edu.persistence.dataobject.study.StudentDO">
select
count(*) student_count,
s.class_corpinfo_id
from
student s
left join class c on c.class_id = s.class_id
<where>
s.delete_enum = 'FALSE'
and c.delete_enum = 'FALSE'
and c.state != 1
</where>
group by
s.class_corpinfo_id
</select>
</mapper>