Browse Source

修改:答案顺序

吴朋磊 5 hours ago
parent
commit
54faeb0caa
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/views/teachingHomework/homeworkTask/answer.vue

+ 6 - 2
src/views/teachingHomework/homeworkTask/answer.vue

@@ -577,16 +577,20 @@ export default {
       const isJudge = !!question.isJudge;
       const isJudge = !!question.isJudge;
       const isChoice = question.type === 'single' && !isJudge;
       const isChoice = question.type === 'single' && !isJudge;
       const judgeValue = this.answers[question.id];
       const judgeValue = this.answers[question.id];
+      const choiceOrder = (question.options || []).map(opt => opt.key);
+      const choiceAnswer = (this.answers[question.id] || []).slice().sort((a, b) => {
+        return choiceOrder.indexOf(a) - choiceOrder.indexOf(b);
+      }).join('');
       const payload = {
       const payload = {
         homeWorkId: this.homework && this.homework.homeWorkId,
         homeWorkId: this.homework && this.homework.homeWorkId,
         homeWorkStuId: this.homework && this.homework.homeWorkStuId,
         homeWorkStuId: this.homework && this.homework.homeWorkStuId,
         homeWorkStuQuesId: question.homeWorkStuQuesId,
         homeWorkStuQuesId: question.homeWorkStuQuesId,
         questionId: question.questionId,
         questionId: question.questionId,
         commitFlag,
         commitFlag,
-        // 判断题传 T / F;选择题多选直接拼接,如 AB;拍照题提交图片地址
+        // 判断题传 T / F;选择题按选项顺序拼接,如先选 D 再选 C 仍传 CD
         writeAnswer: isJudge
         writeAnswer: isJudge
           ? (judgeValue === 'T' || judgeValue === 'F' ? judgeValue : '')
           ? (judgeValue === 'T' || judgeValue === 'F' ? judgeValue : '')
-          : (isChoice ? (this.answers[question.id] || []).join('') : ''),
+          : (isChoice ? choiceAnswer : ''),
         writeUrls: isJudge || isChoice ? [] : (this.answers[question.id] || []),
         writeUrls: isJudge || isChoice ? [] : (this.answers[question.id] || []),
       };
       };
       this.saving = true;
       this.saving = true;