excer.js
6.8 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import {observable, computed, action} from 'mobx';
// export const items = [{
// id: 1,
// titleId: 'Q1',
// title: "以下那个神秘时间不是罗伯特.兰登破解的?(8积分)",
// optionArr: [
// {
// id: 1, value: "A. 1", is_correct: true,
// },
// {
// id: 2, value: "B. 2", is_correct: false,
// },
// ],
// reason: "罗伯特兰登,丹布朗小说《天使与魔鬼》·《达芬奇密码》·《失落的秘符》与《地狱》新作的主要人物"
// }, {
// id: 2,
// titleId: 'Q2',
// title: "以下那个神秘时间不是罗伯特.兰登破解的?(8积分)2",
// optionArr: [
// {
// id: 1, value: "A. 1", is_correct: true,
// },
// {
// id: 2, value: "B. 2", is_correct: false,
// },
// {
// id: 3, value: "C. 3", is_correct: false,
// },
// {
// id: 4, value: "D. 4", is_correct: false
// }
// ],
// reason: "罗伯特兰登,丹布朗小说《天使与魔鬼》·《达芬奇密码》·《失落的秘符》与《地狱》新作的主要人物"
// }, {
// id: 3,
// titleId: 'Q2',
// title: "以下那个神秘时间不是罗伯特.兰登破解的?(8积分)3",
// optionArr: [
// {
// id: 1, value: "A. 1", is_correct: true,
// },
// {
// id: 2, value: "B. 2", is_correct: false,
// },
// {
// id: 3, value: "C. 3", is_correct: false,
// },
// {
// id: 4, value: "D. 4", is_correct: false
// }
// ],
// reason: "罗伯特兰登,丹布朗小说《天使与魔鬼》·《达芬奇密码》·《失落的秘符》与《地狱》新作的主要人物"
// }]
export const items = {
"class": "com.xiniunet.site.testing.response.TestingQuestionFindResponse",
"errors": [],
"firstErrorMessage": "",
"result": [{
"class": "com.xiniunet.site.testing.domain.TestingQuestion",
"id": "873081455239368704",
"objectId": "873078041528897536",
"objectType": "COURSE_LESSON",
"point": 5,
"questionOptions": [{
"class": "com.xiniunet.site.testing.domain.TestingQuestionOption",
"id": "873081455243563008",
"isAnswer": false,
"label": "a",
"value":"我是选项",
"questionId": "873081455239368704",
"rowVersion": "0",
"tenantId": "512824102474878976"
}, {
"class": "com.xiniunet.site.testing.domain.TestingQuestionOption",
"id": "873081455260340224",
"isAnswer": false,
"label": "b",
"value":"我是选项",
"questionId": "873081455239368704",
"rowVersion": "0",
"tenantId": "512824102474878976"
}, {
"class": "com.xiniunet.site.testing.domain.TestingQuestionOption",
"id": "873081455268728832",
"isAnswer": false,
"label": "c",
"value":"我是选项",
"questionId": "873081455239368704",
"rowVersion": "0",
"tenantId": "512824102474878976"
}, {
"class": "com.xiniunet.site.testing.domain.TestingQuestionOption",
"id": "873081455277117440",
"isAnswer": true,
"label": "d",
"value":"我是选项",
"questionId": "873081455239368704",
"rowVersion": "0",
"tenantId": "512824102474878976"
}],
"rowVersion": "0",
"tenantId": "512824102474878976",
"title": "作文1",
"type": "MULTIPLE_CHOICE"
}],
"totalCount": "1"
}
export const subList = observable.box([]);//存的是Sub数组
class Sub {
id; //第几项
titleId;//没什么卵用
title; //问题的标题
@observable
optionArr = [];//选项数组
reason; //讲解
@observable
selectId;//这就是 那个 确定 的 答案
//是否是选对,用于确认做对的数量
value_correct;
//这个 是 当时 改的 答案 可以 修改
@observable
sub_select;
questionId;//习题Id
point;//赠送积分
from(obj, index) {
this.id = index + 1;
this.titleId = "Q"+(index+1);
this.title = obj.title;
this.reason = " ";
this.questionId = obj.id;
this.point = obj.point;
for (let i = 0; i < obj.questionOptions.length; i++) {
this.optionArr.push(new optionItem().from(obj.questionOptions[i], i))
}
this.selectId = 0;
this.value_correct = false;
this.sub_select = 0;
return this;
}
@computed
get isCorrect() {
let flag = false;
this.optionArr.map((v, i) => {
if (this.selectId === v.id && v.is_correct === true) {
flag = true;
}
})
return flag;
}
@action
setValue = (x) => {
this.sub_select = x;
this.optionArr.map((v, i) => {
if (v.id === x) {
v.setSelect(true);
} else {
v.setSelect(false);
}
})
}
//设置 最后 的答案 在 下一题 这个 按钮 这边
@action
setSub = () => {
this.selectId = this.sub_select;
this.value_correct = this.isCorrect;
}
@action
setLoading = () => {
this.selectId = this.sub_select;
this.value_correct = this.isCorrect;
}
}
class optionItem {
id;//第几个选项
value;//选项的值
is_correct;//是否是正确答案
@observable
select;//是否选中
optionId;//选项Id
from(obj, index) {
if(obj.label == null || obj.label == undefined){
obj.label = "";
}
if(obj.value == null || obj.value == undefined){
obj.value = "";
}
this.id = index + 1;
this.value = obj.label + ". " + obj.value;
this.is_correct = obj.isAnswer;
this.select = false;
this.optionId = obj.id;
return this;
}
@action
setSelect = (x)=> {
this.select = x;
}
}
//传入questions
export async function loadData(questions, onUpdated) {
subList.replace(questions.map((v, i) => {
return new Sub().from(v, i);
}))
onUpdated();
}
export function getDataById(id = 1) {
const item = subList.find((v, i) => v.id == id);
return item;
}
export function getCorrect() {
let num = 0;
subList.slice(0).map((v, i) => {
if (v.value_correct) {
num++;
}
})
return num;
}
export function getScore(){
let score = 0;
subList.slice(0).map((v, i) => {
if (v.value_correct) {
score = score + v.point;
}
})
return score;
}