From 1c27a881d1adf5be0d5263fbde6602e2c0634ccf Mon Sep 17 00:00:00 2001 From: yangdj <18302547071@163> Date: Wed, 22 Mar 2023 00:47:46 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=80=83=E8=AF=81=E8=BE=85=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/GeneralQuestionSettingController.java | 2 +- .../jlw/courseInfo/examInfoList.html | 36 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java b/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java index 2f582096..1389a793 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java @@ -279,7 +279,7 @@ public class GeneralQuestionSettingController{ @PostMapping(MODEL + "/edit.json") @Function("generalQuestionSetting.edit") - public JsonResult update(@Validated(ValidateConfig.UPDATE.class) GeneralQuestionSettingQuery generalQuestionSettingQuery, BindingResult result) { + public JsonResult update(@Validated(ValidateConfig.UPDATE.class) @RequestBody GeneralQuestionSettingQuery generalQuestionSettingQuery, BindingResult result) { if(result.hasErrors()){ return JsonResult.failMessage(result); }else { diff --git a/web/src/main/resources/templates/jlw/courseInfo/examInfoList.html b/web/src/main/resources/templates/jlw/courseInfo/examInfoList.html index df3eded3..69486508 100644 --- a/web/src/main/resources/templates/jlw/courseInfo/examInfoList.html +++ b/web/src/main/resources/templates/jlw/courseInfo/examInfoList.html @@ -146,7 +146,7 @@ data: [], initValue:[xmSeInitValue], on: function(data){ - getQuestionTypeGroupInfo(Common.concatBatchId(data.arr,'id')); + getQuestionTypeGroupInfo(Common.concatBatchId(data.arr,'id'),{}); } }); @@ -306,7 +306,7 @@ //添加考试信息 function addGeneral(data){ - getQuestionTypeGroupInfo($.isEmpty(data.generalQuestionSettingId)?xmSeInitValue:data.sourceCourseInfoIds); + getQuestionTypeGroupInfo($.isEmpty(data.generalQuestionSettingId)?xmSeInitValue:data.sourceCourseInfoIds,data); if (courseInfoList.length <= 0){ var ret = Common.getAjax("/jlw/courseInfo/getValues.json",{"courseLabelType":"考证课程类","courseInfoStatus":1,courseInfoType:1}); if (ret.code == 0){ @@ -324,7 +324,7 @@ }else{ demo1.update({ data: courseInfoList, - initValue: [data.sourceCourseInfoIds] + initValue: $.isEmpty(data.sourceCourseInfoIds)?[]:data.sourceCourseInfoIds.split(",") }); } layer.open({ @@ -407,7 +407,12 @@ param.generalQuestionSettingEndShowTrueFalse = generalQuestionSettingEndShowTrueFalse; param.generalQuestionSettingName = generalQuestionSettingName; 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, { offset: ['50%'], icon: ret.code == 0 ? 1 : 2, @@ -426,12 +431,31 @@ } //根据课程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:"考证课程类"}); 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 ,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; $("input[name='tnum'],input[name='tfnum']").unbind(); $("input[name='tnum'],input[name='tfnum']").change(function (){ From fa35158e01271a7a2574baf5d4c865dc7a5b7c3b Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Wed, 22 Mar 2023 10:45:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=80=83=E8=AF=81=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/GeneralQuestionLogService.java | 3 ++ .../GeneralQuestionSettingService.java | 54 +++++++++++++++++++ .../web/GeneralQuestionSettingController.java | 5 ++ .../query/GeneralQuestionSettingQuery.java | 9 ++++ 4 files changed, 71 insertions(+) diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java index 6238d815..d962faac 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java @@ -635,6 +635,9 @@ public class GeneralQuestionLogService extends CoreBaseService 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 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 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)); + } + }); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java b/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java index 1389a793..93100509 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/GeneralQuestionSettingController.java @@ -80,6 +80,11 @@ public class GeneralQuestionSettingController{ PageQuery page = condition.getPageQuery(); generalQuestionSettingService.queryByConditionQuery(page); generalQuestionSettingService.fullQuestionSettingOptions(page.getList()); + + if (!condition.getNotSelectOther()) { + // 设置分数和完成时间 + generalQuestionSettingService.setMyQuestionLogScoreInfo(page.getList(), getStudent()); + } return JsonResult.success(page); } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/GeneralQuestionSettingQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/GeneralQuestionSettingQuery.java index e58a4bad..3756b8a2 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/GeneralQuestionSettingQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/GeneralQuestionSettingQuery.java @@ -101,6 +101,7 @@ public class GeneralQuestionSettingQuery extends PageParam { private String generalQuestionSettingJsonStr;//json格式 private String _given;//指定更新的特定字段,多个逗号隔开 + private boolean notSelectOther; public GeneralQuestionSetting pojo(){ GeneralQuestionSetting pojo = new GeneralQuestionSetting(); @@ -176,4 +177,12 @@ public class GeneralQuestionSettingQuery extends PageParam { setDefault(this); return this; } + + public boolean getNotSelectOther() { + return notSelectOther; + } + + public void setNotSelectOther(boolean notSelectOther) { + this.notSelectOther = notSelectOther; + } } From a9c0907f0b45e1f9508967cb34e3c0d30292fad5 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Wed, 22 Mar 2023 10:57:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=80=83=E8=AF=81=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jlw/service/GeneralQuestionLogService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java index d962faac..7dd9b3fd 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java @@ -1,6 +1,7 @@ package com.ibeetl.jlw.service; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; @@ -814,10 +815,23 @@ public class GeneralQuestionLogService extends CoreBaseService logList = getValuesBySettingIds(questionSettingId.toString()); - GeneralQuestionSetting questionSetting = generalQuestionSettingService.getInfo(questionSettingId); setErrorSuccessCountField(updateList, logList); + // 这里是库里查询到多条记录,但只更新改过值的数据 + updateList.forEach(item -> { + // 直接替换表里查询到的数据 + int index = CollUtil.indexOf(logList, questionLog -> questionLog.getGeneralQuestionLogId().equals(item.getGeneralQuestionLogId())); + Optional 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) { String logIds = logList.stream().map(GeneralQuestionLog::getGeneralQuestionLogId).map(Objects::toString).collect(joining(",")); addQuestionLogSummary(logIds, logList, student, questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType()); From 704e13c6ee165bfc441edc8e68e59b514d6176dd Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Wed, 22 Mar 2023 13:52:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=80=83=E8=AF=81=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ibeetl/jlw/service/GeneralQuestionLogService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java index 7dd9b3fd..ca9f1576 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java @@ -613,7 +613,7 @@ public class GeneralQuestionLogService extends CoreBaseService logList = generalQuestionLogDao.getValuesByQuery(questionLogQuery); - final List tempList = Arrays.asList(PRE_SUBMIT, null); + final List tempList = Arrays.asList(PRE_SUBMIT, LOCK, null); // 只是未提交的数据 logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList()); Assert.notEmpty(logList, "未查询到题目信息!");