Blame view

src/views/examinationPaper/edit.vue 28.8 KB
4c4f7640   梁保满   路由表,路由前端文件
1
  <template>
65f592b6   梁保满   答题卡列表页
2
3
4
5
6
7
    <div>
      <back-box>
        <template slot="title">
          <span>修改答案</span>
        </template>
      </back-box>
13b58a42   梁保满   备题组卷部分前端页面基本完成
8
      <div class="content">
4ad1ef07   阿宝   类型添加验证
9
        <p class="tips" v-if="paperModifyLog.modifiedTime">
f26ecfa4   阿宝   测试bug
10
          <i class="fa fa-bell-o"></i>
4ad1ef07   阿宝   类型添加验证
11
12
13
          {{
            `${paperModifyLog.modifiedTime} ${paperModifyLog.realName}`
          }}老师修改了答案
13b58a42   梁保满   备题组卷部分前端页面基本完成
14
15
16
17
18
        </p>
        <div class="answer-title">
          <p class="name">{{ form.title }}</p>
          <p class="totals">卷面总分:{{ allScore }}分</p>
        </div>
3de13776   梁保满   背题组卷修改答案
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
        <template v-if="questionList[0]?.subQuestions">
          <div v-for="(question, index) in questionList" :key="index">
            <p class="question-title">
              <span>{{ setBigNum(index) }}、</span>
              <el-input
                class="ipt"
                v-model.trim="question.questionTitle"
                maxlength="30"
                placeholder="填写大题名称"
              ></el-input>
              <span>共 {{ setScore(question) }} 分</span>
            </p>
            <ul class="questions-ul">
              <li class="sub-questions">
                <div class="qs-num">题号</div>
                <div class="qs-type">题型</div>
                <div class="qs-score">分数</div>
                <div class="qs-partScore">漏选得分</div>
                <div class="qs-options qs-options2">选项设置</div>
              </li>
              <li
                v-for="(subQuestions, indexs) in question.subQuestions"
                :key="indexs"
              >
                <p
                  class="set-ans-btn"
                  v-if="
                    subQuestions.qusType &&
                    subQuestions.subNum &&
                    subQuestions.subNum > 4
                  "
                >
                  <el-button type="primary" @click="setFormAns(indexs, index)"
                    >批量设置答案</el-button
                  >
                </p>
                <div v-else class="sub-questions">
                  <div class="qs-num">{{ subQuestions.questionIndex }}</div>
                  <div class="qs-type">
                    {{ setSubPro(subQuestions.questionType) }}
                  </div>
                  <div class="qs-score">
bbc51d4b   梁保满   组卷添加修改分数,打开新开页面跳转...
61
62
63
64
65
66
67
68
69
70
                    <el-input-number
                      class="number-ipt"
                      size="medium"
                      :min="1"
                      :max="200"
                      :precision="2"
                      :step="1"
                      v-model="subQuestions.score"
                      label="单题分值"
                    ></el-input-number>
3de13776   梁保满   背题组卷修改答案
71
72
73
                  </div>
                  <div class="qs-partScore">
                    <p v-if="subQuestions.questionType != 3">--</p>
f5729396   梁保满   批量设置答案
74
75
76
77
78
79
80
81
82
83
84
                    <el-input-number
                      class="number-ipt"
                      v-else
                      size="medium"
                      :min="0"
                      :precision="2"
                      :max="subQuestions.score"
                      :step="0.5"
                      v-model="subQuestions.partScore"
                      label="漏选得分"
                    ></el-input-number>
3de13776   梁保满   背题组卷修改答案
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
                  </div>
                  <div class="qs-options qs-options2">
                    <p v-if="subQuestions.questionType == 5">--</p>
                    <p v-if="subQuestions.questionType == 4" class="answer-box">
                      <span
                        class="answer-s"
                        :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
                        @click="subQuestions.correctAnswer = 1"
                        >✓</span
                      >
                      <span
                        class="answer-s"
                        :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
                        @click="subQuestions.correctAnswer = 2"
                        >✗</span
                      >
                    </p>
                    <p v-if="subQuestions.questionType == 3" class="answer-box">
                      <template
                        v-for="option in subQuestions.answerOptions.split(',')"
                      >
                        <span
                          v-if="option"
                          class="answer-s"
                          :class="
                            subQuestions.correctAnswer.includes(option)
                              ? 'active'
                              : ''
                          "
                          :key="option"
                          @click="changAnswer(subQuestions, option)"
                          >{{ option }}</span
                        >
                      </template>
                    </p>
                    <p v-if="subQuestions.questionType == 2" class="answer-box">
                      <template
                        v-for="option in subQuestions.answerOptions.split(',')"
                      >
                        <span
                          class="answer-s"
                          v-if="option"
                          :class="
                            subQuestions.correctAnswer == option ? 'active' : ''
                          "
                          :key="option"
                          @click="subQuestions.correctAnswer = option"
                          >{{ option }}</span
                        >
                      </template>
                    </p>
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </template>
        <ul class="questions-ul" v-else>
          <li class="sub-questions">
            <div class="qs-num">题号</div>
            <div class="qs-type">题型</div>
            <div class="qs-score">分数</div>
            <div class="qs-partScore">漏选得分</div>
            <div class="qs-options qs-options2">选项设置</div>
          </li>
          <li v-for="(subQuestions, indexs) in questionList" :key="indexs">
            <p
              class="set-ans-btn"
              v-if="
                subQuestions.qusType &&
                subQuestions.subNum &&
                subQuestions.subNum > 4
              "
13b58a42   梁保满   备题组卷部分前端页面基本完成
158
            >
3de13776   梁保满   背题组卷修改答案
159
160
161
162
163
              <el-button type="primary" @click="setFormAns(indexs, index)"
                >批量设置答案</el-button
              >
            </p>
            <div v-else class="sub-questions">
13b58a42   梁保满   备题组卷部分前端页面基本完成
164
165
166
167
168
              <div class="qs-num">{{ subQuestions.questionIndex }}</div>
              <div class="qs-type">
                {{ setSubPro(subQuestions.questionType) }}
              </div>
              <div class="qs-score">
3de13776   梁保满   背题组卷修改答案
169
                {{ subQuestions.score }}
13b58a42   梁保满   备题组卷部分前端页面基本完成
170
              </div>
ca39cc52   阿宝   飞书问题处理
171
              <div class="qs-partScore">
3de13776   梁保满   背题组卷修改答案
172
                <p v-if="subQuestions.questionType != 3">--</p>
f5729396   梁保满   批量设置答案
173
174
175
176
177
178
179
180
181
182
183
                <el-input-number
                  class="number-ipt"
                  v-else
                  size="medium"
                  :min="0"
                  :precision="2"
                  :max="subQuestions.score"
                  :step="0.5"
                  v-model="subQuestions.partScore"
                  label="漏选得分"
                ></el-input-number>
3de13776   梁保满   背题组卷修改答案
184
              </div>
13b58a42   梁保满   备题组卷部分前端页面基本完成
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
              <div class="qs-options qs-options2">
                <p v-if="subQuestions.questionType == 5">--</p>
                <p v-if="subQuestions.questionType == 4" class="answer-box">
                  <span
                    class="answer-s"
                    :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
                    @click="subQuestions.correctAnswer = 1"
                    >✓</span
                  >
                  <span
                    class="answer-s"
                    :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
                    @click="subQuestions.correctAnswer = 2"
                    >✗</span
                  >
                </p>
                <p v-if="subQuestions.questionType == 3" class="answer-box">
aed43d3a   阿宝   即时测修改答案
202
                  <template
5424ef82   梁保满   接口调整
203
                    v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
204
                  >
aed43d3a   阿宝   即时测修改答案
205
206
207
208
209
210
211
212
213
214
215
216
217
                    <span
                      v-if="option"
                      class="answer-s"
                      :class="
                        subQuestions.correctAnswer.includes(option)
                          ? 'active'
                          : ''
                      "
                      :key="option"
                      @click="changAnswer(subQuestions, option)"
                      >{{ option }}</span
                    >
                  </template>
13b58a42   梁保满   备题组卷部分前端页面基本完成
218
219
                </p>
                <p v-if="subQuestions.questionType == 2" class="answer-box">
aed43d3a   阿宝   即时测修改答案
220
                  <template
5424ef82   梁保满   接口调整
221
                    v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
222
                  >
aed43d3a   阿宝   即时测修改答案
223
224
225
226
227
228
229
230
231
232
233
                    <span
                      class="answer-s"
                      v-if="option"
                      :class="
                        subQuestions.correctAnswer == option ? 'active' : ''
                      "
                      :key="option"
                      @click="subQuestions.correctAnswer = option"
                      >{{ option }}</span
                    >
                  </template>
13b58a42   梁保满   备题组卷部分前端页面基本完成
234
235
                </p>
              </div>
3de13776   梁保满   背题组卷修改答案
236
237
238
            </div>
          </li>
        </ul>
13b58a42   梁保满   备题组卷部分前端页面基本完成
239
240
241
242
        <div class="btn-box">
          <el-button type="danger" plain round @click="linkBack">取消</el-button>
          <el-button type="primary" round @click="save">保存</el-button>
        </div>
3de13776   梁保满   背题组卷修改答案
243
244
245
246
247
248
249
        <el-dialog
          title="批量设置答案"
          :close-on-click-modal="false"
          :visible.sync="diaSetAns"
          width="400"
          :modal-append-to-body="false"
        >
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
250
          <div class="qs-options set-questions">
3de13776   梁保满   背题组卷修改答案
251
252
253
254
255
256
            <p class="dia-tips">
              请点击选项按钮设置答案,多选题题目之间用“,”隔开,若添加5道题:“AC,AD,BD,AC,CD”
            </p>
            <p>{{ setSubPro(formAns.qusType) }}:</p>
            <p class="ipt">
              <el-input
f5729396   梁保满   批量设置答案
257
                ref="formAnsIpt"
3de13776   梁保满   背题组卷修改答案
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
                v-if="formAns.qusType == 2 || formAns.qusType == 3"
                v-model="formAns.answerList"
                @keydown.native="keydownAnswer($event, formAns.qusType)"
                @input="setAllAnswer($event, formAns.qusType)"
              ></el-input>
              <el-input
                v-if="formAns.qusType == 4"
                v-model="formAns.answerList"
                readonly=""
              ></el-input>
            </p>
            <p class="answer-box">
              <template v-if="formAns.qusType == 4">
                <span
                  class="answer-s active"
                  @click="
                    formAns.answerList.length < formAns.subNum
                      ? (formAns.answerList += '✓')
                      : ''
                  "
                  >✓</span
                >
                <span
                  class="answer-s active"
                  @click="
                    formAns.answerList.length < formAns.subNum
                      ? (formAns.answerList += '✗')
                      : ''
                  "
                  >✗</span
                >
              </template>
              <template v-if="formAns.qusType == 3">
                <span
                  class="answer-s active"
                  v-for="option in formAns.answerOptions.split(',')"
                  :key="option"
                  @click="setMultiple(formAns, option)"
                  >{{ option }}</span
                >
                <span
                  class="answer-s active"
                  @click="
                    formAns.answerList.split(',').length < formAns.subNum
                      ? (formAns.answerList += ',')
                      : ''
                  "
                  >,</span
                >
              </template>
              <template v-if="formAns.qusType == 2" class="answer-box">
                <span
                  class="answer-s active"
                  v-for="option in formAns.answerOptions.split(',')"
                  :key="option"
                  @click="
                    formAns.answerList.length < formAns.subNum
                      ? (formAns.answerList += option)
                      : ''
                  "
                  >{{ option }}</span
                >
              </template>
              <span
                class="answer-s delButton"
                @click="formAns.answerList = formAns.answerList.slice(0, -1)"
                >x</span
              >
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
326
              <span class="answer-s ac" @click="formAns.answerList = ''">ac</span>
3de13776   梁保满   背题组卷修改答案
327
328
329
330
331
332
333
            </p>
          </div>
          <div class="dialog-footer" slot="footer">
            <el-button @click="saveFormAns">确 定</el-button>
            <el-button @click="diaSetAns = false">取 消</el-button>
          </div>
        </el-dialog>
13b58a42   梁保满   备题组卷部分前端页面基本完成
334
      </div>
65f592b6   梁保满   答题卡列表页
335
    </div>
4c4f7640   梁保满   路由表,路由前端文件
336
337
338
  </template>
  
  <script>
3de13776   梁保满   背题组卷修改答案
339
  import { deepClone, checkAnswer } from "utils";
13b58a42   梁保满   备题组卷部分前端页面基本完成
340
341
342
  export default {
    data() {
      return {
6fffbd55   阿宝   组卷接口调整
343
        questionList: [],
13b58a42   梁保满   备题组卷部分前端页面基本完成
344
345
346
347
348
349
350
351
        form: {
          //答题卡详情
          title: "",
          tag: "",
          subjectId: "",
          examsDuration: 90,
          gradeName: "",
          share: 1,
13b58a42   梁保满   备题组卷部分前端页面基本完成
352
353
          questionList: [],
        },
4ad1ef07   阿宝   类型添加验证
354
355
356
357
        paperModifyLog: {
          realName: "",
          modifiedTime: "",
        },
3de13776   梁保满   背题组卷修改答案
358
359
360
361
362
363
364
365
366
        diaSetAns: false,
        formAns: {
          listIndex: 0, //大题位置
          endIndex: 0, //相同题目最后一位题目的questionIndex
          qusType: "", //题目类型
          subNum: 0, //数量
          answerOptions: [], //答案选项
          answerList: "", //答案列表-字符串
        },
13b58a42   梁保满   备题组卷部分前端页面基本完成
367
368
369
370
371
      };
    },
    computed: {
      allScore: function () {
        let score = 0;
3de13776   梁保满   背题组卷修改答案
372
        this.questionList.map((item) => {
13b58a42   梁保满   备题组卷部分前端页面基本完成
373
          score += item.subQuestions.reduce((a, b) => {
3de13776   梁保满   背题组卷修改答案
374
            return a + (Number(b.score) || 0);
13b58a42   梁保满   备题组卷部分前端页面基本完成
375
376
377
378
379
380
          }, 0);
        }, 0);
        return Number(score).toFixed(2);
      },
    },
    created() {
6fffbd55   阿宝   组卷接口调整
381
      this._QueryDetail();
13b58a42   梁保满   备题组卷部分前端页面基本完成
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
    },
    methods: {
      linkBack() {
        this.$router.push({
          path: "/examinationPaper",
        });
      },
      setSubPro(type) {
        let tit;
        switch (type) {
          case 2:
            tit = "单选题";
            break;
          case 3:
            tit = "多选题";
            break;
          case 4:
            tit = "判断题";
            break;
          case 5:
            tit = "主观题";
            break;
        }
        return tit;
      },
      setBigNum(num) {
        let txt = "";
        let bigNum = [
          "一",
          "二",
          "三",
          "四",
          "五",
          "六",
          "七",
          "八",
          "九",
          "十",
          "十一",
          "十二",
          "十三",
          "十四",
          "十五",
          "十六",
          "十七",
          "十八",
          "十九",
          "二十",
        ];
        txt = bigNum[num];
  
        return txt;
      },
      setScore(question) {
        let score = question.subQuestions.reduce((a, b) => {
3de13776   梁保满   背题组卷修改答案
437
          return a + (b.score || 0);
13b58a42   梁保满   备题组卷部分前端页面基本完成
438
        }, 0);
f26ecfa4   阿宝   测试bug
439
        return Number(score).toFixed(2);
13b58a42   梁保满   备题组卷部分前端页面基本完成
440
441
442
443
444
445
446
447
448
449
450
451
      },
      changAnswer(sub, option) {
        //设置多选答案
        let str = new RegExp(option, "g");
        if (sub.correctAnswer?.includes(option)) {
          sub.correctAnswer = sub.correctAnswer.replace(str, "");
        } else {
          let arrs = (sub.correctAnswer && sub.correctAnswer.split("")) || [];
          arrs.push(option);
          sub.correctAnswer = arrs.sort().join("");
        }
      },
3de13776   梁保满   背题组卷修改答案
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
      keydownAnswer(event, type) {
        let answerA = "ABCDEFG";
        let answer_a = "abcdefg";
        answerA = answerA.substring(0, this.formAns.subNum);
        answer_a = answer_a.substring(0, this.formAns.subNum);
        answerA += answer_a;
        answerA = type == 2 ? answerA : answerA + ",";
        if (
          event.key == "Meta" ||
          event.key == "CapsLock" ||
          event.key == "Shift" ||
          event.key == "Enter" ||
          event.key == "Alt" ||
          event.key == "Backspace" ||
          event.key == "Delete" ||
          event.key == "ArrowUp" ||
          event.key == "ArrowDown" ||
          event.key == "ArrowLeft" ||
          event.key == "v" ||
          event.key == "V" ||
          event.key == "ArrowRight"
        )
          return;
        if (!answerA.includes(event.key)) {
          event.returnValue = "";
        }
      },
      setAllAnswer(event, type) {
        let str = this.formAns.answerList;
        let str2 = checkAnswer(
          str,
          type,
          this.formAns.answerOptions.split(",").length,
          this.formAns.subNum
        );
        this.formAns.answerList = str2;
      },
      setAnswer(type, ans) {
        let txt = "";
        if (type == 2) {
          txt = ans;
        } else if (type == 3) {
          txt = ans + ",";
        } else if (type == 4) {
          txt = ans == 1 ? "✓" : ans == 2 ? "✗" : "";
        }
        return txt;
      },
f5729396   梁保满   批量设置答案
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
      insertTxtAndSetcursor(answerList, str) {
        let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签
        let startPos = element.selectionStart; // 获取光标开始的位置
        if (startPos === undefined) {
          // 如果没有光标位置 不操作
          return answerList;
        } else {
          return {
            text:
              answerList.substring(0, startPos) +
              str +
              answerList.substring(startPos), // 将文本插入
            startPos: startPos + str.length,
          };
        }
      },
3de13776   梁保满   背题组卷修改答案
516
517
      setMultiple(obj, answer) {
        //多选答案设置
f5729396   梁保满   批量设置答案
518
519
        let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer);
        obj.answerList = resault.text;
3de13776   梁保满   背题组卷修改答案
520
521
522
523
524
525
526
527
        let str = obj.answerList;
        let str2 = checkAnswer(
          str,
          3,
          obj.answerOptions.split(",").length,
          obj.answerList.length
        );
        obj.answerList = str2;
f5729396   梁保满   批量设置答案
528
529
        this.$refs.formAnsIpt.$el.children[0].focus();
        this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos;
3de13776   梁保满   背题组卷修改答案
530
531
532
533
534
535
      },
      setFormAns(indexs, index) {
        //初始化要修改的答案
        if (this.questionList[0].subQuestions) {
          this.formAns = { ...this.questionList[index].subQuestions[indexs] };
          this.formAns.listIndex = index;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
536
          let answerList = "";
f5729396   梁保满   批量设置答案
537
          let startIndex = this.formAns.endIndex - this.formAns.subNum;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
538
          this.questionList[index].subQuestions.map((item, subIdx) => {
f5729396   梁保满   批量设置答案
539
540
541
542
543
544
545
546
547
548
549
            if (subIdx >= startIndex) {
              answerList += this.setAnswer(item.questionType, item.correctAnswer);
              if (subIdx != indexs) {
                if (!!item.qusType) {
                  answerList = "";
                }
              } else {
                if (item.qusType == 3) {
                  answerList = answerList.slice(0, -1);
                }
                this.formAns.answerList = answerList;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
550
              }
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
551
552
            }
          });
3de13776   梁保满   背题组卷修改答案
553
554
        } else {
          this.formAns = { ...this.questionList[indexs] };
f5729396   梁保满   批量设置答案
555
          let startIndex = this.formAns.endIndex - this.formAns.subNum;
3de13776   梁保满   背题组卷修改答案
556
          this.formAns.listIndex = indexs;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
557
558
          let answerList = "";
          this.questionList[index].map((item, subIdx) => {
f5729396   梁保满   批量设置答案
559
560
561
562
563
564
565
566
567
568
569
            if (subIdx >= startIndex) {
              answerList += this.setAnswer(item.questionType, item.correctAnswer);
              if (subIdx != indexs) {
                if (!!item.qusType) {
                  answerList = "";
                }
              } else {
                if (item.qusType == 3) {
                  answerList = answerList.slice(0, -1);
                }
                this.formAns.answerList = answerList;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
570
              }
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
571
572
            }
          });
3de13776   梁保满   背题组卷修改答案
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
        }
        this.diaSetAns = true;
      },
      saveFormAns() {
        //批量修改答案
        let EndIndex;
        let subNum = this.formAns.subNum - 1;
        if (this.questionList[this.formAns.listIndex].subQuestions) {
          this.questionList[this.formAns.listIndex].subQuestions.some(
            (item, index) => {
              if (this.formAns.endIndex == item.questionIndex) {
                EndIndex = index;
                return;
              }
            }
          );
        } else {
          this.questionList.some((item, index) => {
            if (this.formAns.endIndex == item.questionIndex) {
              EndIndex = index;
              return;
            }
          });
        }
  
        for (let i = 0; i <= subNum; i++) {
          let correctAnswer = "";
          if (this.formAns.qusType == 2) {
f5729396   梁保满   批量设置答案
601
            correctAnswer = this.formAns.answerList[subNum - i] || "";
3de13776   梁保满   背题组卷修改答案
602
          } else if (this.formAns.qusType == 3) {
f5729396   梁保满   批量设置答案
603
            correctAnswer = this.formAns.answerList.split(",")[subNum - i] || "";
3de13776   梁保满   背题组卷修改答案
604
          } else if (this.formAns.qusType == 4) {
f5729396   梁保满   批量设置答案
605
606
607
608
609
610
            correctAnswer =
              this.formAns.answerList[subNum - i] == "✓"
                ? 1
                : this.formAns.answerList[subNum - i] == "✗"
                ? 2
                : "";
3de13776   梁保满   背题组卷修改答案
611
612
613
614
615
616
617
618
619
620
621
          }
          if (this.questionList[0].subQuestions) {
            this.questionList[this.formAns.listIndex].subQuestions[
              EndIndex - i
            ].correctAnswer = correctAnswer;
          } else {
            this.questionList[EndIndex - i].correctAnswer = correctAnswer;
          }
        }
        this.diaSetAns = false;
      },
6fffbd55   阿宝   组卷接口调整
622
      async save() {
3de13776   梁保满   背题组卷修改答案
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
        for (let i = 0; i < this.questionList.length; i++) {
          if (this.questionList[0].subQuestions) {
            for (let j = 0; j < this.questionList[i].subQuestions.length; j++) {
              if (this.questionList[i].subQuestions[j].qusType) {
                this.questionList[i].subQuestions.splice(j, 1);
              }
            }
          } else {
            if (this.questionList[i].qusType) {
              this.questionList.splice(i, 1);
              i--;
            }
          }
        }
        let questionList = this.questionList.map((item) => {
6fffbd55   阿宝   组卷接口调整
638
          item.score = null;
8f573b82   阿宝   组卷接口联调
639
640
          // item.questionId = "";
          // item.questionIndex = "";
6fffbd55   阿宝   组卷接口调整
641
642
643
644
645
646
647
          return item;
        });
        //更新答题卡
        const { data, status, info } = await this.$request.modifyPaper({
          paperId: this.form.id,
          questionList: questionList,
        });
ee6e7628   梁保满   备题组卷借口数据对接调整
648
        if (status == 0) {
13b58a42   梁保满   备题组卷部分前端页面基本完成
649
          this.$router.push({
6fffbd55   阿宝   组卷接口调整
650
651
            path: "/examinationPaper",
          });
ee6e7628   梁保满   备题组卷借口数据对接调整
652
        } else {
6fffbd55   阿宝   组卷接口调整
653
          this.$message.error(info);
ee6e7628   梁保满   备题组卷借口数据对接调整
654
655
656
657
        }
      },
      async _QueryDetail() {
        //查询年级列表
6fffbd55   阿宝   组卷接口调整
658
659
        const { data, status, info } = await this.$request.fetchPaperDetail({
          paperId: this.$route.query.paperId,
ee6e7628   梁保满   备题组卷借口数据对接调整
660
661
        });
        if (status == 0) {
6fffbd55   阿宝   组卷接口调整
662
          this.form = deepClone(data);
3de13776   梁保满   背题组卷修改答案
663
          this.questionList = deepClone(this.form.questionList);
4ad1ef07   阿宝   类型添加验证
664
665
666
667
          this.paperModifyLog = {
            ...this.paperModifyLog,
            ...this.form.paperModifyLog,
          };
3de13776   梁保满   背题组卷修改答案
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
          if (!!this.questionList[0]?.subQuestions) {
            this.questionList?.map((item) => {
              let types = [{}];
              let addndex = 0;
              item.subQuestions.map((sub, index) => {
                if (!!sub.questionType && sub.questionType != 5) {
                  if (sub.questionType == types[addndex].qusType) {
                    //同类型批量答案+1
                    types[addndex].subNum += 1;
                    if (
                      types[addndex].answerOptions.length <
                      sub.answerOptions.length
                    ) {
                      types[addndex].answerOptions = sub.answerOptions;
                    }
                    types[addndex].answerList += this.setAnswer(
                      sub.questionType,
                      sub.correctAnswer
                    );
                    if (index == item.subQuestions.length - 1) {
                      //循环最后类型数量大于等于5,保存批量答案
                      if (types[addndex].subNum && types[addndex].subNum >= 5) {
                        types[addndex].endIndex = sub.questionIndex;
                        types[addndex].index = index;
                      }
                    }
                  } else {
                    if (types[addndex].subNum && types[addndex].subNum >= 5) {
                      //不同类型时如果原有类型数量大于等于5,保存批量答案
                      types[addndex].endIndex =
                        item.subQuestions[index - 1].questionIndex;
                      types[addndex].index = index - 1;
                      addndex += 1;
                      types[addndex] = {};
                    }
                    //不同类型初始化批量答案
                    types[addndex].qusType = sub.questionType;
                    types[addndex].subNum = 1;
                    types[addndex].answerOptions = sub.answerOptions;
                    types[addndex].answerList = this.setAnswer(
                      sub.questionType,
                      sub.correctAnswer
                    );
                  }
                }
              });
              for (let i = 0; i < types.length; i++) {
                if (types[i].qusType == 3) {
                  types[i].answerList = types[i].answerList.slice(0, -1);
                }
                if (types[i].subNum >= 5) {
                  item.subQuestions.splice(
                    types[i].index + i + 1,
                    0,
                    deepClone(types[i])
                  );
                }
              }
            });
          } else {
            let types = [{}];
            let addndex = 0;
            this.questionList?.map((sub, index) => {
              if (!!sub.questionType && sub.questionType != 5) {
                if (sub.questionType == types[addndex].qusType) {
                  //同类型批量答案+1
                  types[addndex].subNum += 1;
                  if (
                    types[addndex].answerOptions.length < sub.answerOptions.length
                  ) {
                    types[addndex].answerOptions = sub.answerOptions;
                  }
                  types[addndex].answerList += this.setAnswer(
                    sub.questionType,
                    sub.correctAnswer
                  );
                  if (index == this.questionList.length - 1) {
                    //循环最后类型数量大于等于5,保存批量答案
                    if (types[addndex].subNum && types[addndex].subNum >= 5) {
                      types[addndex].endIndex = sub.questionIndex;
                      types[addndex].index = index;
                    }
                  }
                } else {
                  if (types[addndex].subNum && types[addndex].subNum >= 5) {
                    //不同类型时如果原有类型数量大于等于5,保存批量答案
                    types[addndex].endIndex =
                      this.questionList[index - 1].questionIndex;
                    types[addndex].index = index - 1;
                    addndex += 1;
                    types[addndex] = {};
                  }
                  //不同类型初始化批量答案
                  types[addndex].qusType = sub.questionType;
                  types[addndex].subNum = 1;
                  types[addndex].answerOptions = sub.answerOptions;
                  types[addndex].answerList = this.setAnswer(
                    sub.questionType,
                    sub.correctAnswer
                  );
                }
              }
            });
            for (let i = 0; i < types.length; i++) {
              if (types[i].qusType == 3) {
                types[i].answerList = types[i].answerList.slice(0, -1);
              }
              if (types[i].subNum >= 5) {
                item.subQuestions.splice(
                  types[i].index + i + 1,
                  0,
                  deepClone(types[i])
                );
              }
            }
          }
f5729396   梁保满   批量设置答案
784
          console.log(this.questionList);
ee6e7628   梁保满   备题组卷借口数据对接调整
785
        } else {
6fffbd55   阿宝   组卷接口调整
786
          this.$message.error(info);
ee6e7628   梁保满   备题组卷借口数据对接调整
787
788
        }
      },
13b58a42   梁保满   备题组卷部分前端页面基本完成
789
790
    },
  };
4c4f7640   梁保满   路由表,路由前端文件
791
792
  </script>
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
  <style lang="scss" scoped>
  .content {
    width: 100%;
    box-sizing: border-box;
    padding: 0 50px;
    .ml-20 {
      margin-left: 20px;
    }
    .btn-box {
      text-align: right;
      margin-left: 140px;
    }
    .tips {
      height: 48px;
      line-height: 48px;
      padding: 0 16px;
      border: 1px solid #fac7cc;
      background-color: #ffebec;
      font-size: 14px;
      color: #fd9795;
      margin: 10px 0 20px 0;
      .fa-bell-o {
        font-size: 18px;
        margin-right: 5px;
      }
    }
  }
  .answer-title {
    text-align: center;
    font-size: 20px;
    color: #333;
    font-weight: 700;
b769660c   梁保满   备课组题细节调整,随堂问列表页面开发完成
825
    padding-bottom: 20px;
13b58a42   梁保满   备题组卷部分前端页面基本完成
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
    .totals {
      font-size: 16px;
      color: #888;
      font-weight: normal;
    }
  }
  .question-title {
    line-height: 40px;
    .ipt {
      width: 300px;
      margin: 0 16px 0 10px;
      :deep(.el-input__inner) {
        border-radius: 20px;
        border-color: #667ffd;
        background: rgba($color: #667ffd, $alpha: 0.05);
      }
    }
    .delete {
      margin-right: 8px;
    }
    .title-txt {
      margin-right: 20px;
      font-size: 16px;
      font-weight: 700;
    }
  }
3de13776   梁保满   背题组卷修改答案
852
853
854
855
856
857
858
  .set-ans-btn {
    width: 100%;
    padding: 10px 0 10px 630px;
    box-sizing: border-box;
    border-bottom: 1px solid #e2e2e2;
    border-right: 1px solid #e2e2e2;
  }
13b58a42   梁保满   备题组卷部分前端页面基本完成
859
860
861
  .el-input-number {
    width: 140px;
  }
b769660c   梁保满   备课组题细节调整,随堂问列表页面开发完成
862
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
  .questions-ul {
    border-left: 1px solid #e2e2e2;
    border-top: 1px solid #e2e2e2;
    margin: 12px 0;
  }
  .sub-questions {
    width: 100%;
    display: flex;
    border-bottom: 1px solid #e2e2e2;
    & > div {
      min-height: 40px;
      padding: 5px;
      flex-shrink: 0;
      border-right: 1px solid #e2e2e2;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .qs-num {
      width: 80px;
    }
    .qs-type {
      width: 160px;
    }
    .qs-score,
    .qs-partScore {
      width: 160px;
    }
    .qs-options {
      flex: 1;
    }
    .qs-set {
      width: 80px;
    }
    .qs-options2 {
      text-align: left;
      justify-content: flex-start;
      padding-left: 20px;
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
901
902
903
    }
    .answer-s {
      cursor: pointer;
13b58a42   梁保满   备题组卷部分前端页面基本完成
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
    }
    :deep(.el-select) {
      .el-input__inner {
        border-radius: 20px;
        border-color: #667ffd;
        width: 150px;
        height: 32px;
        line-height: 32px;
        background: rgba($color: #667ffd, $alpha: 0.05);
      }
      .el-input__icon {
        line-height: 32px;
      }
    }
  }
11a4e518   梁保满   背题组卷修改答案设置,即使测随堂问...
919
920
921
922
923
924
925
926
927
928
929
  .set-questions {
    .answer-box {
      .answer-s {
        cursor: pointer;
        user-select: none;
        &:first-of-type {
          margin-left: 0;
        }
      }
    }
  }
4c4f7640   梁保满   路由表,路由前端文件
930
  </style>