Commit 4ff3e0e4 authored by wujipeng's avatar wujipeng
Browse files

考试中心-我的成绩-汇总

parent 18dbe93d
......@@ -76,6 +76,10 @@ public class TheoreticalPaperStudentDetailEntity {
@ApiModelProperty("结果")
private Boolean result;
@ApiModelProperty("是否部分对")
@TableField("is_partially_right")
private Boolean isPartiallyRight;
@ApiModelProperty("实际选择")
@TableField("actual_choice")
private String actualChoice;
......
......@@ -47,4 +47,22 @@ public class ExamStudentVO extends ExamStudentEntity {
private Integer finishNum;
private String lev;
@ApiModelProperty(value = "成绩标签")
private String scoreLabel;
@ApiModelProperty(value = "班级人数")
private Integer classNum;
@ApiModelProperty(value = "答对数量")
private Integer rightNum;
@ApiModelProperty(value = "答错数量")
private Integer wrongNum;
@ApiModelProperty(value = "部分对数量")
private Integer partiallyRightNum;
@ApiModelProperty(value = "正确率")
private String correctRate;
}
......@@ -119,4 +119,10 @@ public class ExamController extends BaseController {
public Result<ExamStudentVO> gradesDetail(@PathVariable(name = "id") String id) {
return Result.data(examService.gradesDetail(id));
}
@ApiOperation(value = "考试中心-我的成绩-汇总")
@GetMapping("/grades/summary/{id}")
public Result<ExamStudentVO> gradesSummary(@PathVariable(name = "id") String id) {
return Result.data(examService.gradesSummary(id));
}
}
......@@ -32,4 +32,6 @@ public interface ExamMapper extends BaseMapper<ExamEntity> {
TheoreticalPaperStudentDetailVO same(@Param("examId") Integer examId, @Param("studentId") String studentId, @Param("type") String type);
ExamStudentVO gradesSummary(@Param("id") String id);
}
......@@ -46,4 +46,7 @@ public interface ExamService extends IService<ExamEntity> {
TheoreticalPaperStudentDetailVO gradesQuestionDetail(String id);
ExamStudentVO gradesDetail(String id);
ExamStudentVO gradesSummary(String id);
}
......@@ -16,6 +16,7 @@ import com.platform.business.service.*;
import com.platform.model.resp.Result;
import com.platform.utils.DozerUtils;
import com.platform.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -357,4 +358,76 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, ExamEntity> impleme
public ExamStudentVO gradesDetail(String id) {
return baseMapper.gradesDetail(id);
}
@Override
public ExamStudentVO gradesSummary(String id) {
//考试名称,考试类型,考试时间,班级名称,本次成绩,班级排名
ExamStudentVO result = baseMapper.gradesSummary(id);
//成绩标签
Double score = result.getScore();
if (score != null) {
if (score >= 90) {
result.setScoreLabel("优秀");
} else if (score >= 80) {
result.setScoreLabel("良好");
} else if (score >= 60) {
result.setScoreLabel("及格");
} else {
result.setScoreLabel("不合格");
}
}
//班级均分
List<ExamStudentEntity> examStudentList = examStudentService.list(new LambdaQueryWrapper<ExamStudentEntity>()
.eq(ExamStudentEntity::getExamId, result.getExamId()));
double totalScore = 0;
for (ExamStudentEntity examStudentEntity : examStudentList) {
if (examStudentEntity.getScore() != null) {
totalScore += examStudentEntity.getScore();
}
}
result.setAvgScore(totalScore / examStudentList.size());
//和班级均分比较
if (result.getAvgScore() != null && score != null) {
if (result.getScore() > result.getAvgScore()) {
result.setScoreLabel("高于均分" + (result.getScore() - result.getAvgScore()));
} else if (result.getScore().equals(result.getAvgScore())) {
result.setScoreLabel("等于均分");
} else {
result.setScoreLabel("低于均分" + (result.getAvgScore() - result.getScore()));
}
}
//班级人数
result.setClassNum(examStudentList.size());
int rightNum = 0;
int wrongNum = 0;
int partiallyRightNum = 0;
int totalNum = 0;
List<TheoreticalPaperStudentDetailEntity> list = theoreticalPaperStudentDetailService
.list(new LambdaQueryWrapper<TheoreticalPaperStudentDetailEntity>()
.eq(TheoreticalPaperStudentDetailEntity::getExamId, result.getExamId())
.eq(TheoreticalPaperStudentDetailEntity::getStudentId, result.getStudentId()));
for (TheoreticalPaperStudentDetailEntity theoreticalPaperStudentDetail : list) {
if(!"主观题".equals(theoreticalPaperStudentDetail.getType())){
if (theoreticalPaperStudentDetail.getIsPartiallyRight()) {
partiallyRightNum++;
} else {
if(theoreticalPaperStudentDetail.getResult()){
rightNum++;
} else {
wrongNum++;
}
}
totalNum++;
}
}
//答对题数
result.setRightNum(rightNum);
//部分对题数
result.setPartiallyRightNum(partiallyRightNum);
//答错题数
result.setWrongNum(wrongNum);
//正确率
result.setCorrectRate(String.format("%.2f%%", (double) rightNum / totalNum * 100));
return result;
}
}
......@@ -196,4 +196,31 @@
and type = #{type}
and result = true
</select>
<select id="gradesSummary" resultType="com.platform.business.model.vo.ExamStudentVO">
SELECT
e.name AS exam_name,
e.type AS exam_type,
e.exam_time,
c.name AS class_name,
es.score,
es.exam_id,
rank_table.score_rank AS rank,
es.student_id AS studentId
FROM
exam_student es
LEFT JOIN
exam e
ON
es.exam_id = e.id
LEFT JOIN
class c
ON
es.class_id = c.id
LEFT JOIN (SELECT exam_id,
student_id,
DENSE_RANK() OVER (PARTITION BY exam_id ORDER BY score DESC NULLS LAST) AS score_rank
FROM exam_student) rank_table
ON es.exam_id = rank_table.exam_id AND es.student_id = rank_table.student_id
WHERE es.student_id = #{id}
</select>
</mapper>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment