Browse Source

学习统计等调整

mingfu 1 month ago
parent
commit
d763d0e734

+ 24 - 7
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontStudentController.java

@@ -203,11 +203,14 @@ public class FrontStudentController extends BaseController {
                 curr.setStudentId(null);
                 curr.setBeginTime(null);
                 curr.setStats(null);
-                learnPlanService.updateLearnPlan(plan);
+                plan.setFirstTime(curr.getFirstTime());
+                learnPlanService.updateLearnPlan(curr);
             }
             if(curr.getStatus().equals(1)) {
                 return AjaxResult.success();
             }
+        } else {
+            plan.setFirstTime(today);
         }
         plan.setStudentId(SecurityUtils.getLoginUser().getUserId());
         plan.setBeginTime(today);
@@ -240,12 +243,24 @@ public class FrontStudentController extends BaseController {
         Date firstDate = null;
         for(LearnPlanStudy study : studyList) {
             JSONObject planStudy = toStudyStats(study);
-            doneDay++;
+            boolean videoCompleted;
+            if(null != study.getVideoCount()) {
+                videoCompleted = study.getVideoCount() >= study.getVideoPlan();
+            } else {
+                videoCompleted = study.getVideoPlan().equals(0);
+            }
             if(null != study.getVideoTime()) {
                 videoTimes += study.getVideoTime();
             }
+            boolean questionCompleted;
             if(null != study.getQuestionCount()) {
                 questionCnt += study.getQuestionCount();
+                questionCompleted = study.getQuestionCount() >= study.getQuestionPlan();
+            } else {
+                questionCompleted = study.getQuestionPlan().equals(0);
+            }
+            if(videoCompleted && questionCompleted) {
+                doneDay++;
             }
             if(null == firstDate) {
                 firstDate = study.getReportDate();
@@ -254,11 +269,11 @@ public class FrontStudentController extends BaseController {
         }
 
         Integer preDay = 0; // 同月的排队计划开始之前的 历史月不好计算,待定 TODO MF
-//        if(DateUtils.isSameDay(DateUtils.truncate(cond.getReportDate(), Calendar.MONTH), DateUtils.truncate(curr.getBeginTime(), Calendar.MONTH))) {
-//            Calendar cal = Calendar.getInstance();
-//            cal.setTime(curr.getBeginTime());
-//            preDay = cal.get(Calendar.DAY_OF_MONTH) - 1;
-//        }
+        if(DateUtils.isSameDay(DateUtils.truncate(cond.getReportDate(), Calendar.MONTH), DateUtils.truncate(curr.getFirstTime(), Calendar.MONTH))) {
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(curr.getFirstTime());
+            preDay = cal.get(Calendar.DAY_OF_MONTH) - 1;
+        }
         JSONObject stats = new JSONObject();
         stats.put("doneDay", doneDay);
         stats.put("undoneDay", LocalDateTimeUtil.of(cond.getReportDate()).getDayOfMonth() - doneDay - preDay);
@@ -270,6 +285,8 @@ public class FrontStudentController extends BaseController {
 
     private JSONObject toStudyStats(LearnPlanStudy todayStudy) {
         JSONObject study = new JSONObject();
+        study.put("questionPlan", todayStudy.getQuestionPlan());
+        study.put("videoPlan", todayStudy.getVideoPlan());
         study.put("questionCnt", todayStudy.getQuestionCount());
         study.put("videoTime", todayStudy.getVideoCount());
         study.put("videoTimes", todayStudy.getVideoTime());

+ 8 - 5
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -167,7 +167,7 @@ public class ExamService {
         if(answerSheet.getIsDone()) {
             // 关闭试卷
             LearnPaper up = new LearnPaper();
-            up.setId(answerSheet.getPaperId());
+            up.setId(exitExaminee.getPaperId());
             up.setStatus(PaperStatus.Valid.getVal());
             paperMapper.updateLearnPaper(up);
 
@@ -180,8 +180,8 @@ public class ExamService {
     private LearnAnswer buildAnswer(AnswerSheet answerSheet, Map<Long, PaperVO.QuestionAnswer> questionMap, PaperVO.QuestionAnswer question,
                              List<LearnAnswer> addList, List<LearnAnswer> updateList) {
         LearnAnswer answer = new LearnAnswer();
-        PaperVO.QuestionAnswer exist = questionMap.remove(question.getId());
-        if(null == exist || null == exist.getAnswerId()) {
+        PaperVO.QuestionAnswer stdWidhAnswer = questionMap.remove(question.getId());
+        if(null == stdWidhAnswer.getAnswerId()) {
             answer.setExamineeId(answerSheet.getExamineeId());
             answer.setStudentId(SecurityUtils.getUserId());
             answer.setQuestionId(question.getId());
@@ -189,11 +189,13 @@ public class ExamService {
             answer.setKnowledgeId(answerSheet.getKnowledgeId());
             addList.add(answer);
         } else {
-            answer.setAnswerId(exist.getAnswerId());
+            answer.setAnswerId(stdWidhAnswer.getAnswerId());
             updateList.add(answer);
         }
         answer.setAnswer(StringUtils.join(question.getAnswers(), ","));
-        answer.setState(question.calcState(answerSheet.getIsDone()));
+        answer.setMark(null != question.getIsMark() && question.getIsMark());
+        answer.setNotKnow(null != question.getIsNotKnow() && question.getIsNotKnow());
+        answer.setState(question.calcState(stdWidhAnswer, answerSheet.getIsDone()));
         return answer;
     }
 
@@ -346,6 +348,7 @@ public class ExamService {
         answerSheet.setPaperId(examinee.getPaperId());
         answerSheet.setName(paper.getPaperName());
         answerSheet.setBeginTime(examinee.getBeginTime());
+        answerSheet.setDuration(examinee.getDuration());
         if(StringUtils.isNotBlank(paper.getConditions())) {
             answerSheet.setConditions(JSONObject.parseObject(paper.getConditions(), AnswerSheet.PaperCond.class));
         }

+ 4 - 3
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -74,7 +74,7 @@ public class PaperService {
         List<PaperVO.QuestionSeq> paperQuestionList = Lists.newArrayList();
         for(LearnQuestions lqs : questions) {
             PaperVO.QuestionSeq qs = new PaperVO.QuestionSeq();
-            BeanUtils.copyProperties(lqs, qs, "options");
+            BeanUtils.copyProperties(lqs, qs, "options", "parse", "answer1", "answer2");
             QuestionType qt = QuestionType.of(lqs.getQtpye());
             qs.setTypeId(qt.getVal());
             qs.setType(qt.getTitle());
@@ -105,7 +105,7 @@ public class PaperService {
         LearnAnswer answer;
         for(LearnQuestions lqs : questions) {
             PaperVO.QuestionAnswer qs = new PaperVO.QuestionAnswer();
-            if(!withParse) {
+            if(withParse) {
                 BeanUtils.copyProperties(lqs, qs, "title", "options");
             } else {
                 BeanUtils.copyProperties(lqs, qs, "title", "options", "parse", "answer1", "answer2");
@@ -117,7 +117,8 @@ public class PaperService {
                 qs.setAnswerId(answer.getAnswerId());
                 qs.setAnswers(Arrays.asList(answer.getAnswer().split(",")));
                 qs.setState(answer.getState());
-                qs.setIsNotKnow(null != answer.getState() && answer.getState().equals(3L));
+                qs.setIsMark(answer.getMark());
+                qs.setIsNotKnow(answer.getNotKnow());
             }
             if(StringUtils.isNotBlank(lqs.getTitle0())) { // 大题
                 PaperVO.QuestionAnswer qg = gropuMap.get(lqs.getTitle0());

+ 20 - 0
ie-system/src/main/java/com/ruoyi/learn/domain/LearnAnswer.java

@@ -1,5 +1,6 @@
 package com.ruoyi.learn.domain;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -70,6 +71,9 @@ public class LearnAnswer extends BaseEntity
     @Excel(name = "得分率")
     private Long scoreRate;
 
+    private Boolean isMark;
+    private Boolean isNotKnow;
+
     public void setAnswerId(Long answerId) 
     {
         this.answerId = answerId;
@@ -210,6 +214,22 @@ public class LearnAnswer extends BaseEntity
         return scoreRate;
     }
 
+    public Boolean getMark() {
+        return isMark;
+    }
+
+    public void setMark(Boolean mark) {
+        isMark = mark;
+    }
+
+    public Boolean getNotKnow() {
+        return isNotKnow;
+    }
+
+    public void setNotKnow(Boolean notKnow) {
+        isNotKnow = notKnow;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 14 - 1
ie-system/src/main/java/com/ruoyi/learn/domain/LearnPlan.java

@@ -36,6 +36,11 @@ public class LearnPlan extends BaseEntity
     @Excel(name = "是否有效")
     private Integer status;
 
+    /** 开始时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date firstTime;
+
     /** 开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@@ -95,7 +100,15 @@ public class LearnPlan extends BaseEntity
         return status;
     }
 
-    public void setBeginTime(Date beginTime) 
+    public Date getFirstTime() {
+        return firstTime;
+    }
+
+    public void setFirstTime(Date firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public void setBeginTime(Date beginTime)
     {
         this.beginTime = beginTime;
     }

+ 3 - 3
ie-system/src/main/java/com/ruoyi/learn/domain/PaperVO.java

@@ -76,7 +76,7 @@ public class PaperVO {
 
         List<QuestionAnswer> subQuestions;
 
-        public Long calcState(boolean isDone) {
+        public Long calcState(QuestionAnswer std, boolean isDone) {
             if(null != isNotKnow && isNotKnow) {
                 return 3L;
             } if(isDone) {
@@ -85,12 +85,12 @@ public class PaperVO {
                     if(CollectionUtils.isEmpty(answers)) {
                         return 0L;
                     }
-                    return answers.get(0).equals(answer1) ? 1L : 2L;
+                    return answers.get(0).equals(std.getAnswer1()) ? 1L : 2L;
                 } else if(QuestionType.Multiple.equals(qt)) {
                     if(CollectionUtils.isEmpty(answers)) {
                         return 0L;
                     }
-                    List<String> stdAnswers = Arrays.asList(answer1.split(","));
+                    List<String> stdAnswers = Arrays.asList(std.getAnswer1().split(","));
                     return stdAnswers.size() == answers.size() && CollectionUtils.intersection(stdAnswers, answers).size() == answers.size() ? 1L : 2L;
                 }
             }

+ 7 - 1
ie-system/src/main/resources/mapper/learn/LearnAnswerMapper.xml

@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLearnAnswerVo">
-        select answer_id, examinee_id, student_id, question_id, seq, knowledge_id, answer, correct, duration, count, state, score_level, score, score_rate, create_time, update_time from learn_answer
+        select answer_id, examinee_id, student_id, question_id, seq, knowledge_id, answer, correct, duration, count, state, score_level, score, score_rate, isMark, isNotKnow, create_time, update_time from learn_answer
     </sql>
 
     <select id="selectLearnAnswerList" parameterType="LearnAnswer" resultMap="LearnAnswerResult">
@@ -64,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="duration != null">duration,</if>
             <if test="count != null">count,</if>
             <if test="state != null">state,</if>
+            <if test="isMark != null">isMark,</if>
+            <if test="isNotKnow != null">isNotKnow,</if>
             <if test="scoreLevel != null">score_level,</if>
             <if test="score != null">score,</if>
             <if test="scoreRate != null">score_rate,</if>
@@ -81,6 +83,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="duration != null">#{duration},</if>
             <if test="count != null">#{count},</if>
             <if test="state != null">#{state},</if>
+            <if test="isMark != null">#{isMark},</if>
+            <if test="isNotKnow != null">#{isNotKnow},</if>
             <if test="scoreLevel != null">#{scoreLevel},</if>
             <if test="score != null">#{score},</if>
             <if test="scoreRate != null">#{scoreRate},</if>
@@ -102,6 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="duration != null">duration = #{duration},</if>
             <if test="count != null">count = #{count},</if>
             <if test="state != null">state = #{state},</if>
+            <if test="isMark != null">isMark = #{isMark},</if>
+            <if test="isNotKnow != null">isNotKnow = #{isNotKnow},</if>
             <if test="scoreLevel != null">score_level = #{scoreLevel},</if>
             <if test="score != null">score = #{score},</if>
             <if test="scoreRate != null">score_rate = #{scoreRate},</if>

+ 6 - 1
ie-system/src/main/resources/mapper/learn/LearnPlanMapper.xml

@@ -10,13 +10,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="videoTime"    column="video_time"    />
         <result property="questionCnt"    column="question_cnt"    />
         <result property="status"    column="status"    />
+        <result property="firstTime"    column="first_time"    />
         <result property="beginTime"    column="begin_time"    />
         <result property="createTime"    column="create_time"    />
         <result property="stats"    column="stats"    />
     </resultMap>
 
     <sql id="selectLearnPlanVo">
-        select id, studentId, video_time, question_cnt, status, begin_time, create_time, stats from learn_plan
+        select id, studentId, video_time, question_cnt, status, first_time, begin_time, create_time, stats from learn_plan
     </sql>
 
     <select id="selectLearnPlanList" parameterType="LearnPlan" resultMap="LearnPlanResult">
@@ -26,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="videoTime != null "> and video_time = #{videoTime}</if>
             <if test="questionCnt != null "> and question_cnt = #{questionCnt}</if>
             <if test="status != null "> and status = #{status}</if>
+            <if test="firstTime != null "> and first_time = #{firstTime}</if>
             <if test="beginTime != null "> and begin_time = #{beginTime}</if>
             <if test="stats != null  and stats != ''"> and stats = #{stats}</if>
         </where>
@@ -43,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="videoTime != null">video_time,</if>
             <if test="questionCnt != null">question_cnt,</if>
             <if test="status != null">status,</if>
+            <if test="firstTime != null">first_time,</if>
             <if test="beginTime != null">begin_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="stats != null">stats,</if>
@@ -52,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="videoTime != null">#{videoTime},</if>
             <if test="questionCnt != null">#{questionCnt},</if>
             <if test="status != null">#{status},</if>
+            <if test="firstTime != null">#{firstTime},</if>
             <if test="beginTime != null">#{beginTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="stats != null">#{stats},</if>
@@ -65,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="videoTime != null">video_time = #{videoTime},</if>
             <if test="questionCnt != null">question_cnt = #{questionCnt},</if>
             <if test="status != null">status = #{status},</if>
+            <if test="firstTime != null">first_time = #{firstTime},</if>
             <if test="beginTime != null">begin_time = #{beginTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="stats != null">stats = #{stats},</if>

+ 1 - 1
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -269,7 +269,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <select id="selectQuestionByPaperId" parameterType="Long" resultMap="LearnQuestionsResult">
-        select q.`id`, pq.`seq`, pq.`score`, title, option_a, option_b, option_c, option_d, option_e, option_f, option_g, qtpye, diff, similarity, isSub, paperTypeTitle, title0
+        select q.`id`, pq.`seq`, pq.`score`, title, option_a, option_b, option_c, option_d, option_e, option_f, option_g, qtpye, diff, similarity, isSub, paperTypeTitle, title0, answer1, answer2,parse
           from learn_paper_question pq join `learn_questions` q on q.`id` = pq.`question_id`
           where pq.`paper_id` = #{paperId}
           order by pq.`seq`, q.`id`