Merge remote-tracking branch 'origin/beetlsql3-dev' into beetlsql3-dev

beetlsql3-dev
Mlxa0324 2 years ago
commit 09a65c7b02

@ -1,6 +1,7 @@
package com.ibeetl.jlw.service; package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
@ -612,7 +613,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
.build(); .build();
List<GeneralQuestionLog> logList = generalQuestionLogDao.getValuesByQuery(questionLogQuery); List<GeneralQuestionLog> logList = generalQuestionLogDao.getValuesByQuery(questionLogQuery);
final List<QuestionLogAddTypeEnum> tempList = Arrays.asList(PRE_SUBMIT, null); final List<QuestionLogAddTypeEnum> tempList = Arrays.asList(PRE_SUBMIT, LOCK, null);
// 只是未提交的数据 // 只是未提交的数据
logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList()); logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList());
Assert.notEmpty(logList, "未查询到题目信息!"); Assert.notEmpty(logList, "未查询到题目信息!");
@ -635,6 +636,9 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
validateQuestionLogAddTypeThrow(questionLog.getQuestionLogAddType(), questionLogAddDTO.getQuestionLogAddType()); validateQuestionLogAddTypeThrow(questionLog.getQuestionLogAddType(), questionLogAddDTO.getQuestionLogAddType());
// 学生提交的答案 // 学生提交的答案
String answer = questionLogMap.get(questionLog.getGeneralQuestionLogId().toString()); String answer = questionLogMap.get(questionLog.getGeneralQuestionLogId().toString());
String answerBySnapshot = questionLogMap.get(questionLog.getGeneralResourcesQuestionSnapshotId().toString());
answer = defaultIfNull(answer, answerBySnapshot);
// 默认0分 // 默认0分
questionLog.setStudentScore(BigDecimal.valueOf(0)); questionLog.setStudentScore(BigDecimal.valueOf(0));
@ -811,10 +815,23 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
} }
List<GeneralQuestionLog> logList = getValuesBySettingIds(questionSettingId.toString()); List<GeneralQuestionLog> logList = getValuesBySettingIds(questionSettingId.toString());
GeneralQuestionSetting questionSetting = generalQuestionSettingService.getInfo(questionSettingId);
setErrorSuccessCountField(updateList, logList); setErrorSuccessCountField(updateList, logList);
// 这里是库里查询到多条记录,但只更新改过值的数据
updateList.forEach(item -> {
// 直接替换表里查询到的数据
int index = CollUtil.indexOf(logList, questionLog -> questionLog.getGeneralQuestionLogId().equals(item.getGeneralQuestionLogId()));
Optional<GeneralQuestionLog> optional = logList.stream()
.filter(o -> o.getGeneralQuestionLogId().equals(item.getGeneralQuestionLogId())).findFirst();
optional.ifPresent(c -> {
logList.set(index, c);
});
});
GeneralQuestionSetting questionSetting = generalQuestionSettingService.getInfo(questionSettingId);
if (CollectionUtil.isNotEmpty(logList) && questionSetting != null) { if (CollectionUtil.isNotEmpty(logList) && questionSetting != null) {
String logIds = logList.stream().map(GeneralQuestionLog::getGeneralQuestionLogId).map(Objects::toString).collect(joining(",")); String logIds = logList.stream().map(GeneralQuestionLog::getGeneralQuestionLogId).map(Objects::toString).collect(joining(","));
addQuestionLogSummary(logIds, logList, student, questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType()); addQuestionLogSummary(logIds, logList, student, questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType());

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.jlw.util.EnumUtil; import cn.jlw.util.EnumUtil;
@ -40,6 +41,7 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.*; import java.io.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import static cn.hutool.core.util.ObjectUtil.defaultIfNull; import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
@ -768,4 +770,56 @@ public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuesti
questionSetting.setQuestionSettingOptions(questionSettingDTOList); questionSetting.setQuestionSettingOptions(questionSettingDTOList);
} }
} }
/**
*
* @param list
* @param student
*/
public void setMyQuestionLogScoreInfo(List<GeneralQuestionSetting> list, Student student) {
Optional.ofNullable(list).orElse(Collections.emptyList()).forEach(item -> {
Long questionSettingId = item.getGeneralQuestionSettingId();
if (ObjectUtil.isNotEmpty(student)) {
Long studentId = student.getStudentId();
QuestionLogSummaryQuery logSummaryQuery = new QuestionLogSummaryQuery();
logSummaryQuery.setPersonId(studentId);
logSummaryQuery.setQuestionLogSummaryStatus(1);
logSummaryQuery.setQuestionSettingId(questionSettingId);
List<QuestionLogSummary> myLogSummaryList = questionLogSummaryDao.getValuesByQueryNotWithPermission(logSummaryQuery);
// 我的得分,完成时间
if (ObjectUtil.isNotEmpty(myLogSummaryList)) {
QuestionLogSummary myScoreInfo = myLogSummaryList.get(0);
item.set("finishTime", myScoreInfo.getFinishTime());
item.set("finishSecondTime", myScoreInfo.getFinishSecondTime());
item.set("myScore", myScoreInfo.getQuestionLogSummaryStudentTotalScore());
item.set("mySuccessRate", myScoreInfo.getQuestionLogSummarySuccessRate());
item.set("mySuccessCount", myScoreInfo.getQuestionLogSummarySuccessCount());
item.set("myErrorCount", myScoreInfo.getQuestionLogSummaryErrorCount());
}
}
QuestionLogSummaryQuery logSummaryQuery2 = new QuestionLogSummaryQuery();
logSummaryQuery2.setQuestionLogSummaryStatus(1);
logSummaryQuery2.setQuestionSettingId(questionSettingId);
List<QuestionLogSummary> logSummaryList2 = questionLogSummaryDao.getValuesByQueryNotWithPermission(logSummaryQuery2);
// 平均及格率,平均得分等等
if (ObjectUtil.isNotEmpty(logSummaryList2)) {
BigDecimal studentTotalScore = logSummaryList2.stream().map(QuestionLogSummary::getQuestionLogSummaryStudentTotalScore).reduce(BigDecimal::add).get();
int passTotalCount = logSummaryList2.stream().map(QuestionLogSummary::getQuestionLogSummaryIsPass).reduce(Integer::sum).get();
int totalSuccessCount = logSummaryList2.stream().map(QuestionLogSummary::getQuestionLogSummarySuccessCount).reduce(Integer::sum).get();
int totalErrorCount = logSummaryList2.stream().map(QuestionLogSummary::getQuestionLogSummaryErrorCount).reduce(Integer::sum).get();
BigDecimal totalSuccessRate = logSummaryList2.stream().map(QuestionLogSummary::getQuestionLogSummarySuccessRate).reduce(BigDecimal::add).get();
int logSummarySize = logSummaryList2.size();
item.set("avgScore", NumberUtil.div(studentTotalScore, logSummarySize, 1));
item.set("avgPassRate", NumberUtil.div(passTotalCount, logSummarySize, 1));
item.set("avgSuccessCount", NumberUtil.div(totalSuccessCount, logSummarySize, 1));
item.set("avgErrorCount", NumberUtil.div(totalErrorCount, logSummarySize, 1));
item.set("avgSuccessRate", NumberUtil.div(totalSuccessRate, logSummarySize, 1));
}
});
}
} }

@ -80,6 +80,11 @@ public class GeneralQuestionSettingController{
PageQuery page = condition.getPageQuery(); PageQuery page = condition.getPageQuery();
generalQuestionSettingService.queryByConditionQuery(page); generalQuestionSettingService.queryByConditionQuery(page);
generalQuestionSettingService.fullQuestionSettingOptions(page.getList()); generalQuestionSettingService.fullQuestionSettingOptions(page.getList());
if (!condition.getNotSelectOther()) {
// 设置分数和完成时间
generalQuestionSettingService.setMyQuestionLogScoreInfo(page.getList(), getStudent());
}
return JsonResult.success(page); return JsonResult.success(page);
} }
} }
@ -279,7 +284,7 @@ public class GeneralQuestionSettingController{
@PostMapping(MODEL + "/edit.json") @PostMapping(MODEL + "/edit.json")
@Function("generalQuestionSetting.edit") @Function("generalQuestionSetting.edit")
public JsonResult<String> update(@Validated(ValidateConfig.UPDATE.class) GeneralQuestionSettingQuery generalQuestionSettingQuery, BindingResult result) { public JsonResult<String> update(@Validated(ValidateConfig.UPDATE.class) @RequestBody GeneralQuestionSettingQuery generalQuestionSettingQuery, BindingResult result) {
if(result.hasErrors()){ if(result.hasErrors()){
return JsonResult.failMessage(result); return JsonResult.failMessage(result);
}else { }else {

@ -101,6 +101,7 @@ public class GeneralQuestionSettingQuery extends PageParam {
private String generalQuestionSettingJsonStr;//json格式 private String generalQuestionSettingJsonStr;//json格式
private String _given;//指定更新的特定字段,多个逗号隔开 private String _given;//指定更新的特定字段,多个逗号隔开
private boolean notSelectOther;
public GeneralQuestionSetting pojo(){ public GeneralQuestionSetting pojo(){
GeneralQuestionSetting pojo = new GeneralQuestionSetting(); GeneralQuestionSetting pojo = new GeneralQuestionSetting();
@ -176,4 +177,12 @@ public class GeneralQuestionSettingQuery extends PageParam {
setDefault(this); setDefault(this);
return this; return this;
} }
public boolean getNotSelectOther() {
return notSelectOther;
}
public void setNotSelectOther(boolean notSelectOther) {
this.notSelectOther = notSelectOther;
}
} }

@ -146,7 +146,7 @@
data: [], data: [],
initValue:[xmSeInitValue], initValue:[xmSeInitValue],
on: function(data){ on: function(data){
getQuestionTypeGroupInfo(Common.concatBatchId(data.arr,'id')); getQuestionTypeGroupInfo(Common.concatBatchId(data.arr,'id'),{});
} }
}); });
@ -306,7 +306,7 @@
//添加考试信息 //添加考试信息
function addGeneral(data){ function addGeneral(data){
getQuestionTypeGroupInfo($.isEmpty(data.generalQuestionSettingId)?xmSeInitValue:data.sourceCourseInfoIds); getQuestionTypeGroupInfo($.isEmpty(data.generalQuestionSettingId)?xmSeInitValue:data.sourceCourseInfoIds,data);
if (courseInfoList.length <= 0){ if (courseInfoList.length <= 0){
var ret = Common.getAjax("/jlw/courseInfo/getValues.json",{"courseLabelType":"考证课程类","courseInfoStatus":1,courseInfoType:1}); var ret = Common.getAjax("/jlw/courseInfo/getValues.json",{"courseLabelType":"考证课程类","courseInfoStatus":1,courseInfoType:1});
if (ret.code == 0){ if (ret.code == 0){
@ -324,7 +324,7 @@
}else{ }else{
demo1.update({ demo1.update({
data: courseInfoList, data: courseInfoList,
initValue: [data.sourceCourseInfoIds] initValue: $.isEmpty(data.sourceCourseInfoIds)?[]:data.sourceCourseInfoIds.split(",")
}); });
} }
layer.open({ layer.open({
@ -407,7 +407,12 @@
param.generalQuestionSettingEndShowTrueFalse = generalQuestionSettingEndShowTrueFalse; param.generalQuestionSettingEndShowTrueFalse = generalQuestionSettingEndShowTrueFalse;
param.generalQuestionSettingName = generalQuestionSettingName; param.generalQuestionSettingName = generalQuestionSettingName;
param.generalQuestionSettingDoCount = generalQuestionSettingDoCount; param.generalQuestionSettingDoCount = generalQuestionSettingDoCount;
var ret = Common.postJSON("/api/generalQuestionSetting/addQuestionByType.do",JSON.stringify(param)); param.generalQuestionSettingId = data.generalQuestionSettingId;
var url = "/api/generalQuestionSetting/addQuestionByType.do";
if (!$.isEmpty(param.generalQuestionSettingId)){
url = "/jlw/generalQuestionSetting/edit.json";
}
var ret = Common.postJSON(url,JSON.stringify(param));
layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, { layer.msg(ret.code == 0 ? "保存成功!" : ret.msg, {
offset: ['50%'], offset: ['50%'],
icon: ret.code == 0 ? 1 : 2, icon: ret.code == 0 ? 1 : 2,
@ -426,12 +431,31 @@
} }
//根据课程ID获取相应的题目数量及类型 //根据课程ID获取相应的题目数量及类型
function getQuestionTypeGroupInfo(ids){ function getQuestionTypeGroupInfo(ids,item){
var map = {};
if (!$.isEmpty(item.questionSettingOptions)){
item.questionSettingOptions.forEach(function (it,i){
map[it.questionType] = it;
})
}
var ret = Common.postAjax("/api/resourcesQuestion/questionTypeGroupInfo.do",{courseInfoIdPlural:ids,courseLabelTypePlural:"考证课程类"}); var ret = Common.postAjax("/api/resourcesQuestion/questionTypeGroupInfo.do",{courseInfoIdPlural:ids,courseLabelTypePlural:"考证课程类"});
if(ret.code == 0){ if(ret.code == 0){
var ctNum = "",hjNum = "";
if (!$.isEmpty(ret.data)){
ctNum = 0,hjNum = 0;
ret.data.forEach(function (it,i){
if (!$.isEmpty(map[it.questionType])){
ctNum = ctNum + map[it.questionType].selectCount;
hjNum = hjNum + map[it.questionType].singleTypeTotalScore;
it.selectCount = map[it.questionType].selectCount;
it.singleScore = map[it.questionType].singleScore;
it.singleTypeTotalScore = map[it.questionType].singleTypeTotalScore;
}
});
}
var getTpl = question_demo.innerHTML var getTpl = question_demo.innerHTML
,view = document.getElementById('question_view'); ,view = document.getElementById('question_view');
laytpl(getTpl).render({list:ret.data}, function(html){ laytpl(getTpl).render({list:ret.data,ctNum:ctNum,hjNum:hjNum}, function(html){
view.innerHTML = html; view.innerHTML = html;
$("input[name='tnum'],input[name='tfnum']").unbind(); $("input[name='tnum'],input[name='tfnum']").unbind();
$("input[name='tnum'],input[name='tfnum']").change(function (){ $("input[name='tnum'],input[name='tfnum']").change(function (){

Loading…
Cancel
Save