浏览代码

试题的答题次数,对,错数

lizhen_gitee 9 月之前
父节点
当前提交
e7840b9e07
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 6 1
      addons/exam/library/ExamService.php
  2. 12 0
      public/assets/js/backend/exam/question.js

+ 6 - 1
addons/exam/library/ExamService.php

@@ -17,7 +17,7 @@ use addons\exam\model\RoomGradeModel;
 use addons\exam\model\RoomModel;
 use addons\exam\model\RoomSignupModel;
 use app\admin\model\exam\MaterialQuestionModel;
-
+use think\Db;
 /**
  * 考试相关服务
  */
@@ -271,6 +271,11 @@ class ExamService
                     $user_questions[$key]['answer_score'] = $answer_score;
                     break;
             }
+
+            //记录总答题次数,答对数,答错数
+            Db::name('exam_question')->where('id',$question['id'])->setInc('total_count');
+            $field = $user_questions[$key]['is_right'] ? 'right_count' : 'error_count';
+            Db::name('exam_question')->where('id',$question['id'])->setInc($field);
         }
 
         // 递增参与人次

+ 12 - 0
public/assets/js/backend/exam/question.js

@@ -118,6 +118,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function (
                             formatter: Table.api.formatter.status,
                             operate: false
                         },
+                        {
+                            field: 'total_count',
+                            title: '总答题次数',
+                        },
+                        {
+                            field: 'right_count',
+                            title: '答对数',
+                        },
+                        {
+                            field: 'error_count',
+                            title: '答错数',
+                        },
                         /*{
                             field: 'createtime',
                             title: __('Createtime'),