闫增涛
2024-05-14 3b9668925cee7a1fd371a5c36e9c149c6ea6346c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
import {activeBook} from '@/assets/js/config'
import MG from '@/assets/js/middleGround/WebMiddleGroundApi'
 const getQuestionList = (rootCmsItemId,questionList) => {
  let cardList = [
    
  ];
  let query = {
    path: '*',
    cmsPath: rootCmsItemId,
    cmsType: '*',
    productId: activeBook.bookId,
    queryType: '*',
    itemIds: questionList.map((item) => item + ''),
    itemFields: {
      Embedded_QuestionBank_Stem: [],
      Embedded_QuestionBank_AnalysisCon: [],
      Embedded_QuestionBank_Answer: [],
      Embedded_QuestionBank_Option: [],
      Embedded_QuestionBank_QuestionType: [],
      Embedded_QuestionBank_StemStyle: [],
      Embedded_QuestionBank_OptionStyle: [],
      Embedded_QuestionBank_KnowledgePoint: [],
      Embedded_QuestionBank_Difficulty: []
    }
  }
  MG.store.getProductDetail(query).then((res) => {
    console.log('题目列表',res);
    // res.datas.cmsDatas[0].datas.forEach((item, index) => {
    //   let oldObj = "";
    //   if (oldList)
    //     oldObj = oldList.find((oldItem) => oldItem.id == item.id);
    //   let questionObj = {
    //     // num: index, // 题号
    //     id: item.id,
    //     type: pathitem.name,
    //     stem:
    //       item.Embedded_QuestionBank_QuestionType == "completion"
    //         ? JSON.parse(item.Embedded_QuestionBank_Stem)
    //             .stemTxt.replaceAll("<vacancy>", ",input,")
    //             .split(",")
    //         : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
    //     answer: item.Embedded_QuestionBank_Answer, // 答案
    //     option: item.Embedded_QuestionBank_Option
    //       ? JSON.parse(item.Embedded_QuestionBank_Option)
    //       : "", // 选择题选项
    //     analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
    //     questionType: item.Embedded_QuestionBank_QuestionType, // 题型
    //     optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型
    //     stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型
    //     difficulty: item.Embedded_QuestionBank_Difficulty
    //       ? 4 - item.Embedded_QuestionBank_Difficulty
    //       : 0, // 难度等级
    //     userAnswer: oldObj
    //       ? oldObj.userAnswer
    //       : item.Embedded_QuestionBank_QuestionType == "completion" ||
    //         item.Embedded_QuestionBank_QuestionType == "multipleChoice"
    //       ? []
    //       : "",
    //     isUserAnswer: oldObj
    //       ? this.isHaveAnswer(oldObj.userAnswer)
    //       : false,
    //     isRight: oldObj ? oldObj.isRight : null,
    //     isComplete: oldObj ? oldObj.isComplete : false,
    //     isCollect: false,
    //     isUnfold: "", // 控制解析的折叠面板是否展开
    //   };
    //   // 多选和填空答案肯为数组,要转换JSON格式
    //   if (
    //     questionObj.questionType == "completion" ||
    //     questionObj.questionType == "multipleChoice"
    //   ) {
    //     try {
    //       questionObj.answer = JSON.parse(questionObj.answer).toString();
    //     } catch (error) {
    //       questionObj.answer = item.Embedded_QuestionBank_Answer;
    //     }
    //   }
    //   // 填空题改造
    //   if (questionObj.questionType == "completion") {
    //     let index = 0;
    //     for (let i = 0; i < questionObj.stem.length; i++) {
    //       const item = questionObj.stem[i];
    //       if (item == "input") {
    //         questionObj.stem[i] = {
    //           num: index,
    //           data: "input",
    //         };
    //         if (!oldObj) questionObj.userAnswer[index] = "";
    //         index++;
    //       }
    //     }
    //   }
    //   // 题干富文本处理
    //   if (questionObj.stemStyle == "RichText") {
    //     // questionObj.option.txt = ''
    //     questionObj.stem.stemTxt = questionObj.stem.stemTxt
    //       .replace(
    //         /\<img/gi,
    //         '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
    //       )
    //       .replace(/\<p/gi, '<p class="stem-rich-p"')
    //       .replace("../file", app.config.requestCtx + "/file");
    //   }
    //   // 选项富文本处理
    //   if (
    //     questionObj.optionStyle == "RichText" &&
    //     (questionObj.questionType == "singleChoice" ||
    //       questionObj.questionType == "judge" ||
    //       questionObj.questionType == "multipleChoice")
    //   ) {
    //     questionObj.option.forEach((item) => {
    //       if (item.txt)
    //         item.txt = item.txt
    //           .replace(/\<img/gi, '<img class="option-rich-img"')
    //           .replace(/\<p/gi, '<p class="stem-rich-p"')
    //           .replace("../file", app.config.requestCtx + "/file");
    //     });
    //   }
    //   // 解析富文本处理
    //   if (
    //     questionObj.analysisCon &&
    //     typeof questionObj.analysisCon == "string"
    //   ) {
    //     questionObj.analysisCon = questionObj.analysisCon.replace(
    //       /\<img/gi,
    //       '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
    //     );
    //   }
    //   if (
    //     questionObj.stemStyle == "Image" ||
    //     questionObj.stemStyle == "TxtAndImage"
    //   ) {
    //     questionObj.stem.stemImage = getPublicImage(
    //       questionObj.stem.stemImage,
    //       150
    //     );
    //   }
    //   if (
    //     questionObj.optionStyle == "Image" ||
    //     questionObj.optionStyle == "TxtAndImage"
    //   ) {
    //     questionObj.option.forEach((optionItem) => {
    //       if (optionItem.img)
    //         optionItem.img = getPublicImage(optionItem.img, 150);
    //     });
    //   }
    //   return cardList
    // });
  })
}
 
export default getQuestionList