@zykjcommon/questions 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.production +2 -1
- package/.env.test +2 -1
- package/dist/zykjcommon-questions.common.js +14850 -2485
- package/dist/zykjcommon-questions.css +1 -1
- package/dist/zykjcommon-questions.umd.js +14851 -2494
- package/dist/zykjcommon-questions.umd.min.js +24 -1
- package/package.json +2 -2
- package/src/App.vue +2 -0
- package/src/assets/js/fun.js +23 -2
- package/src/assets/js/http.js +1 -1
- package/src/assets/scss/questions/index.scss +85 -22
- package/src/components/common/IframeComponent.vue +60 -76
- package/src/components/common/Loading.vue +9 -20
- package/src/components/common/TextAreaEditor.vue +72 -87
- package/src/components/exam/QuestionCard.vue +3 -3
- package/src/components/questions/QuestionReader.js +4 -4
- package/src/components/questions/Question_BriefAnswer.vue +146 -0
- package/src/components/questions/Question_FillBlank.vue +151 -0
- package/src/components/questions/Question_MultipleChoice.vue +179 -0
- package/src/components/questions/Question_Programming.vue +285 -0
- package/src/components/questions/Question_Reading.vue +173 -0
- package/src/components/questions/Question_SingleChoice.vue +7 -21
- package/src/components/questions/buildEntry.js +130 -5
- package/src/components/questions/const.js +15 -0
- package/src/components/questions/developmentEntry.js +130 -5
- package/src/components/questions/entry.js +2 -19
- package/src/components/questions/store.js +44 -0
- package/src/main.ts +17 -13
- package/src/views/exam/Analysis.vue +620 -7
- package/src/views/exam/Exam.vue +612 -11
- package/vue.config.js +8 -4
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="zykjcommon-question">
|
|
3
|
+
<div class="question-type" v-if="!isSub">{{questionInfo.questionIndex}}、{{questionInfo.hint ? questionInfo.hint : questionInfo.question_type_str}}<span v-if="questionInfo.score!=='null'"><!--({{questionInfo.score}}分)--></span>
|
|
4
|
+
<span class="score fr" v-if="mode==='analysis'">得分:{{questionInfo.answerMap ? questionInfo.answerMap.user_score : '-'}}分</span>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="question-box">
|
|
7
|
+
<!-- <div class="question-stem">{{questionInfo.hint}}</div>-->
|
|
8
|
+
<div class="editor-content" v-html="questionInfo.htmlContent"></div>
|
|
9
|
+
<button class="bcdt-btn"
|
|
10
|
+
v-if="(mode==='exam' && !oss_temp_url) || mode==='review'"
|
|
11
|
+
@click="startCode('1')">进入{{codeTypeMap[questionInfo.code_type]}}答题</button>
|
|
12
|
+
|
|
13
|
+
<div class="question-analysis" v-if="mode==='exam' && oss_temp_url">
|
|
14
|
+
<div class="triangle-top"></div>
|
|
15
|
+
<div class="question-analysis-item">
|
|
16
|
+
<span class="txt">【你的答案】:</span>
|
|
17
|
+
<div class="img-box" @click="startCode('2')">
|
|
18
|
+
<img :src="codeTypeImgMap[questionInfo.code_type]">
|
|
19
|
+
<div class="mask-text-box">
|
|
20
|
+
<div class="mask"></div>
|
|
21
|
+
<div class="mask-text">去修改</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div class="question-analysis" v-if="mode==='analysis'">
|
|
28
|
+
<div class="triangle-top"></div>
|
|
29
|
+
<div class="question-analysis-item">
|
|
30
|
+
<span class="txt">【你的答案】:</span>
|
|
31
|
+
<div class="img-box" @click="startCode('3')">
|
|
32
|
+
<img :src="codeTypeImgMap[questionInfo.code_type]">
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="question-analysis-item">
|
|
36
|
+
<span class="txt">【正确答案】:</span>
|
|
37
|
+
<div class="img-box" @click="startCode('4')">
|
|
38
|
+
<img :src="codeTypeImgMap[questionInfo.code_type]">
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="question-analysis-item" v-if="questionInfo.analysis">
|
|
42
|
+
<span class="txt">【本题解析】:</span>
|
|
43
|
+
<div class="txt-box">
|
|
44
|
+
<span class="analysis-txt" v-html="questionInfo.analysisHtmlContent"></span>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<!--
|
|
50
|
+
兼容性写法,两个都写
|
|
51
|
+
vue2支持.sync
|
|
52
|
+
vue3支持v-model:
|
|
53
|
+
:visible.sync="visible"
|
|
54
|
+
v-model:visible="visible"
|
|
55
|
+
-->
|
|
56
|
+
<MediaLooker :visible.sync="visible"
|
|
57
|
+
v-model:visible="visible"
|
|
58
|
+
v-if="visible"
|
|
59
|
+
:mediaCount="curMediaCount"
|
|
60
|
+
:mediaLookerList="mediaLookerList"></MediaLooker>
|
|
61
|
+
<IframeComponent :iframeUrl="iframeUrl"
|
|
62
|
+
@uploadCodingFileSuccess="uploadCodingFileSuccess"
|
|
63
|
+
@close="closeIframe"
|
|
64
|
+
@closeAndSave="closeAndSave"
|
|
65
|
+
@saveCodeOnly="saveCodeOnly"
|
|
66
|
+
@iframeLoaded="iframeLoaded"
|
|
67
|
+
@getQuestionInfo="getQuestionInfo"
|
|
68
|
+
v-if="showFrame"></IframeComponent>
|
|
69
|
+
<Loading :loading="loading"></Loading>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
<script>
|
|
73
|
+
|
|
74
|
+
import {commonData,doMediaLookerSome} from './mixin'
|
|
75
|
+
import MediaLooker from '../common/MediaLooker.vue'
|
|
76
|
+
import IframeComponent from "../common/IframeComponent.vue";
|
|
77
|
+
import Loading from "../common/Loading.vue";
|
|
78
|
+
import {mapActions, mapState} from "vuex";
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'Question_Programming',
|
|
82
|
+
props: {
|
|
83
|
+
urlQuery:{
|
|
84
|
+
type: String,
|
|
85
|
+
default: ''
|
|
86
|
+
},
|
|
87
|
+
isSub:{
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
90
|
+
},
|
|
91
|
+
questionInfo: {
|
|
92
|
+
type: Object,
|
|
93
|
+
default: {}
|
|
94
|
+
},
|
|
95
|
+
bus: {
|
|
96
|
+
type: Object,
|
|
97
|
+
default: {}
|
|
98
|
+
},
|
|
99
|
+
mode: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: 'exam'
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
mounted() {
|
|
105
|
+
doMediaLookerSome(this)
|
|
106
|
+
this.$watch('oss_temp_url',(nv)=>{
|
|
107
|
+
if(nv){
|
|
108
|
+
let answered = this.isAnswered()
|
|
109
|
+
this.$emit('getIsAnswered',answered)
|
|
110
|
+
this.mode === 'exam' && this.bus.$emit('questionCardChange',{
|
|
111
|
+
questionIndex:this.questionInfo.questionIndex - 1,
|
|
112
|
+
answered
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
},{
|
|
116
|
+
immediate:true
|
|
117
|
+
})
|
|
118
|
+
},
|
|
119
|
+
data() {
|
|
120
|
+
return {
|
|
121
|
+
iframe:null,
|
|
122
|
+
showFrame:false,
|
|
123
|
+
analyCorrectAnswer:'',
|
|
124
|
+
iframeUrl:'',
|
|
125
|
+
code_file_oss_temp_path:'',
|
|
126
|
+
oss_temp_url:'',
|
|
127
|
+
scratch_answer_json:'',
|
|
128
|
+
loading:false,
|
|
129
|
+
enterCode:false,
|
|
130
|
+
codeTypeMap:{
|
|
131
|
+
1:'Scratch',
|
|
132
|
+
2:'Python',
|
|
133
|
+
3:'PyGame',
|
|
134
|
+
4:'C++'
|
|
135
|
+
},
|
|
136
|
+
codeTypeImgMap:{
|
|
137
|
+
1:require('../../assets/img/sb3-bg.png'),
|
|
138
|
+
2:require('../../assets/img/py-bg.png'),
|
|
139
|
+
3:require('../../assets/img/pygame-bg.png'),
|
|
140
|
+
4:require('../../assets/img/cpp-bg.png')
|
|
141
|
+
},
|
|
142
|
+
answerMap:{},
|
|
143
|
+
...JSON.parse(commonData)
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
watch: {
|
|
147
|
+
questionInfo:{
|
|
148
|
+
handler(nv,ov){
|
|
149
|
+
if(nv){
|
|
150
|
+
this.answerMap = nv.answerMap
|
|
151
|
+
//回显答案
|
|
152
|
+
let answerMap = nv.answerMap
|
|
153
|
+
if(answerMap){
|
|
154
|
+
this.code_file_oss_temp_path = answerMap.code_file_oss_temp_path
|
|
155
|
+
this.oss_temp_url = answerMap.oss_temp_url
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
immediate:true
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
computed:{
|
|
163
|
+
...mapState('zykjcommonQuestions',['pythonCodeWebPath','scratchCodeWebPath','cplusCodeWebPath'])
|
|
164
|
+
},
|
|
165
|
+
methods: {
|
|
166
|
+
...mapActions('zykjcommonQuestions',['getEditorUrlActions']),
|
|
167
|
+
getAnswer(){
|
|
168
|
+
return {
|
|
169
|
+
code_file_oss_temp_path:this.code_file_oss_temp_path,
|
|
170
|
+
oss_temp_url:this.oss_temp_url,
|
|
171
|
+
scratch_answer_json:this.scratch_answer_json
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
isAnswered(){
|
|
175
|
+
let answered = this.oss_temp_url !== ''
|
|
176
|
+
return answered
|
|
177
|
+
},
|
|
178
|
+
isCorrect(){
|
|
179
|
+
let correct = this.questionInfo.answerMap.is_correct === '1' ? true : false
|
|
180
|
+
return correct
|
|
181
|
+
},
|
|
182
|
+
getCodeWebPath(cb){
|
|
183
|
+
if(this.pythonCodeWebPath || this.scratchCodeWebPath || this.cplusCodeWebPath){
|
|
184
|
+
cb && cb()
|
|
185
|
+
}else{
|
|
186
|
+
this.loading = true
|
|
187
|
+
this.getEditorUrlActions().then(()=>{
|
|
188
|
+
this.loading = false
|
|
189
|
+
cb && cb()
|
|
190
|
+
},()=>{
|
|
191
|
+
this.loading = false
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
startCode(type){
|
|
196
|
+
//mapper_type 1.开始做题 2.修改 3.结果页你的答案 4.结果页正确答案
|
|
197
|
+
// code_type:1-sb3 2-python 3-pyGame 4-C++
|
|
198
|
+
let self = this
|
|
199
|
+
if(this.loading){
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
this.getCodeWebPath(function(){
|
|
203
|
+
let mapper = {
|
|
204
|
+
'1':self.questionInfo.template_file_full_url,
|
|
205
|
+
'2':self.oss_temp_url,
|
|
206
|
+
'3':self.oss_temp_url,
|
|
207
|
+
'4':self.questionInfo.reference_file_full_url
|
|
208
|
+
}
|
|
209
|
+
let url = ''
|
|
210
|
+
let code_type = self.questionInfo.code_type
|
|
211
|
+
let fileUrl = mapper[type]
|
|
212
|
+
let baseQueryStr = self.urlQuery + `&codeUrl=${fileUrl}`
|
|
213
|
+
switch (code_type){
|
|
214
|
+
case 1:
|
|
215
|
+
url = `${self.scratchCodeWebPath}/?${baseQueryStr}`
|
|
216
|
+
break
|
|
217
|
+
case 2:
|
|
218
|
+
url = `${self.pythonCodeWebPath}/?${baseQueryStr}`
|
|
219
|
+
break
|
|
220
|
+
case 3:
|
|
221
|
+
url = `${self.pythonCodeWebPath}/?${baseQueryStr}&pygame=true`
|
|
222
|
+
break
|
|
223
|
+
case 4:
|
|
224
|
+
url = `${self.cplusCodeWebPath}/?${baseQueryStr}`
|
|
225
|
+
break
|
|
226
|
+
}
|
|
227
|
+
// console.log(url,'url');
|
|
228
|
+
self.iframeUrl = url
|
|
229
|
+
})
|
|
230
|
+
this.showFrame = true
|
|
231
|
+
},
|
|
232
|
+
getQuestionInfo(){
|
|
233
|
+
let self = this
|
|
234
|
+
let obj = {type:'getQuestionInfo',data:self.questionInfo.htmlContent}
|
|
235
|
+
this.iframe && this.iframe.contentWindow.postMessage(JSON.stringify(obj),'*')
|
|
236
|
+
},
|
|
237
|
+
submitCodeQuestionByTimeover(){
|
|
238
|
+
let obj = {type:'submitCodeQuestionByTimeover'}
|
|
239
|
+
this.iframe && this.iframe.contentWindow.postMessage(JSON.stringify(obj),'*')
|
|
240
|
+
},
|
|
241
|
+
iframeLoaded(node){
|
|
242
|
+
this.iframe = node
|
|
243
|
+
//用于浮动倒计时样式
|
|
244
|
+
this.enterCode = true
|
|
245
|
+
this.bus.$emit('enterCode',true)
|
|
246
|
+
},
|
|
247
|
+
//只关闭iframe不保存(考试已经结束)
|
|
248
|
+
closeIframe(){
|
|
249
|
+
this.enterCode = false
|
|
250
|
+
this.bus.$emit('enterCode',false)
|
|
251
|
+
this.showFrame = false
|
|
252
|
+
},
|
|
253
|
+
//关闭iframe并且保存(考试中)
|
|
254
|
+
closeAndSave(res){
|
|
255
|
+
this.saveCodeOnly(res)
|
|
256
|
+
this.closeIframe()
|
|
257
|
+
this.$emit('closeAndSave')
|
|
258
|
+
},
|
|
259
|
+
saveCodeOnly(res){
|
|
260
|
+
let self = this
|
|
261
|
+
this.code_file_oss_temp_path = res.codeFileOssTempPath
|
|
262
|
+
this.oss_temp_url = res.ossTempUrl
|
|
263
|
+
this.scratch_answer_json = res.scratch_answer_json
|
|
264
|
+
this.bus.$emit('submitQuestion',{saveType:1,submitRequestAutoQuit:false,needSubmitRequest:false})
|
|
265
|
+
let answered = this.isAnswered()
|
|
266
|
+
this.mode === 'exam' && this.bus.$emit('questionCardChange',{
|
|
267
|
+
questionIndex:self.questionInfo.questionIndex - 1,
|
|
268
|
+
answered
|
|
269
|
+
})
|
|
270
|
+
this.$emit('saveCodeOnly')
|
|
271
|
+
},
|
|
272
|
+
uploadCodingFileSuccess(res){
|
|
273
|
+
this.code_file_oss_temp_path = res.codeFileOssTempPath
|
|
274
|
+
this.oss_temp_url = res.ossTempUrl
|
|
275
|
+
this.scratch_answer_json = res.scratch_answer_json
|
|
276
|
+
this.bus.$emit('uploadCodingFileSuccess')
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
components:{
|
|
280
|
+
IframeComponent,
|
|
281
|
+
MediaLooker,
|
|
282
|
+
Loading
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
</script>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="zykjcommon-question">
|
|
3
|
+
<div class="question-type">{{questionInfo.questionIndex}}、{{questionInfo.hint ? questionInfo.hint : questionInfo.question_type_str}}<span v-if="questionInfo.score!=='null'"><!--({{questionInfo.score}}分)--></span>
|
|
4
|
+
<span class="score fr" v-if="mode==='analysis'">得分:{{questionInfo.answerMap ? questionInfo.answerMap.user_score : '-'}}分</span>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="question-box">
|
|
7
|
+
<!-- <div class="question-stem">{{questionInfo.hint}}</div>-->
|
|
8
|
+
<div class="editor-content editor-content-bor" v-html="questionInfo.htmlContent"></div>
|
|
9
|
+
<div class="question-tabs">
|
|
10
|
+
<div class="question-tab-item"
|
|
11
|
+
:class="{'cur':curTab===index}"
|
|
12
|
+
@click="clickTab(index)"
|
|
13
|
+
:key="index"
|
|
14
|
+
v-for="(item,index) in tabsArr">
|
|
15
|
+
{{index+1}}
|
|
16
|
+
<div class="tab-mark" v-if="item.answered"></div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div v-for="(item,index) in questionInfo.sub_questions"
|
|
20
|
+
v-show="curTab === index"
|
|
21
|
+
class="reading-question-item"
|
|
22
|
+
:id="'question'+ (questionInfo.questionIndex - 1) + '-' + index">
|
|
23
|
+
<component :is="item.questionComponent"
|
|
24
|
+
@optionChange="optionChange"
|
|
25
|
+
:mode="mode"
|
|
26
|
+
:bus="bus"
|
|
27
|
+
:isSub="true"
|
|
28
|
+
:questionInfo="item"
|
|
29
|
+
:orderIndex="index"
|
|
30
|
+
:key="'question'+ (questionInfo.questionIndex - 1) + '-' + index"
|
|
31
|
+
:ref="'question'+ (questionInfo.questionIndex - 1) + '-' + index"/>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
<!--
|
|
35
|
+
兼容性写法,两个都写
|
|
36
|
+
vue2支持.sync
|
|
37
|
+
vue3支持v-model:
|
|
38
|
+
:visible.sync="visible"
|
|
39
|
+
v-model:visible="visible"
|
|
40
|
+
-->
|
|
41
|
+
<MediaLooker :visible.sync="visible"
|
|
42
|
+
v-model:visible="visible"
|
|
43
|
+
v-if="visible"
|
|
44
|
+
:mediaCount="curMediaCount"
|
|
45
|
+
:mediaLookerList="mediaLookerList"></MediaLooker>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
<script>
|
|
49
|
+
|
|
50
|
+
import {commonData,doMediaLookerSome} from './mixin'
|
|
51
|
+
import MediaLooker from '../common/MediaLooker.vue'
|
|
52
|
+
export default {
|
|
53
|
+
name: 'Question_Reading',
|
|
54
|
+
props: {
|
|
55
|
+
questionInfo: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: {}
|
|
58
|
+
},
|
|
59
|
+
bus: {
|
|
60
|
+
type: Object,
|
|
61
|
+
default: {}
|
|
62
|
+
},
|
|
63
|
+
mode: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: 'exam'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
created() {
|
|
69
|
+
let self = this
|
|
70
|
+
this.bus.$on('optionChange',()=>{
|
|
71
|
+
let answered = this.isAnswered()
|
|
72
|
+
this.$emit('getIsAnswered',answered)
|
|
73
|
+
this.mode === 'exam' && this.bus.$emit('questionCardChange',{
|
|
74
|
+
questionIndex:self.questionInfo.questionIndex - 1,
|
|
75
|
+
answered
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
mounted() {
|
|
80
|
+
let self = this
|
|
81
|
+
doMediaLookerSome(this)
|
|
82
|
+
},
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
curTab:0,
|
|
86
|
+
radio:0,
|
|
87
|
+
analyCorrectAnswer:'',
|
|
88
|
+
exam_options_data:[],
|
|
89
|
+
answerMap:{},
|
|
90
|
+
tabsArr:[],
|
|
91
|
+
...JSON.parse(commonData)
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
watch: {
|
|
95
|
+
questionInfo:{
|
|
96
|
+
handler(nv,ov){
|
|
97
|
+
if(nv){
|
|
98
|
+
this.exam_options_data = nv.exam_options_data
|
|
99
|
+
this.answerMap = nv.answerMap
|
|
100
|
+
|
|
101
|
+
let sub_questions = nv.sub_questions
|
|
102
|
+
if(sub_questions && sub_questions.length){
|
|
103
|
+
sub_questions.forEach((item,index)=>{
|
|
104
|
+
let temp = {
|
|
105
|
+
answered:false,
|
|
106
|
+
questionComponent:item.questionComponent,
|
|
107
|
+
refName:`question${nv.questionIndex - 1}-${index}`
|
|
108
|
+
}
|
|
109
|
+
this.tabsArr.push(temp)
|
|
110
|
+
})
|
|
111
|
+
console.log(this.tabsArr,333);
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
immediate:true,
|
|
118
|
+
deep:true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
computed:{
|
|
122
|
+
},
|
|
123
|
+
methods: {
|
|
124
|
+
getAnswer(){
|
|
125
|
+
let result = []
|
|
126
|
+
let refs = this.$refs
|
|
127
|
+
Object.keys(refs).forEach((key)=>{
|
|
128
|
+
let item = refs[key][0]
|
|
129
|
+
result.push({
|
|
130
|
+
answer:item.getAnswer(),
|
|
131
|
+
question_id:item.questionInfo.question_id
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
return result
|
|
135
|
+
},
|
|
136
|
+
isAnswered(){
|
|
137
|
+
let refs = this.$refs
|
|
138
|
+
let arr = []
|
|
139
|
+
Object.keys(refs).forEach((key)=>{
|
|
140
|
+
let item = refs[key][0]
|
|
141
|
+
arr.push(item.isAnswered())
|
|
142
|
+
})
|
|
143
|
+
let answerd = arr.every((item)=>{
|
|
144
|
+
return item === true
|
|
145
|
+
})
|
|
146
|
+
return answerd
|
|
147
|
+
},
|
|
148
|
+
isCorrect(){
|
|
149
|
+
let refs = this.$refs
|
|
150
|
+
let arr = []
|
|
151
|
+
Object.keys(refs).forEach((key)=>{
|
|
152
|
+
let item = refs[key][0]
|
|
153
|
+
arr.push(item.isCorrect())
|
|
154
|
+
})
|
|
155
|
+
let correct = arr.every((item)=>{
|
|
156
|
+
return item === true
|
|
157
|
+
})
|
|
158
|
+
return correct
|
|
159
|
+
},
|
|
160
|
+
clickTab(index){
|
|
161
|
+
this.curTab = index
|
|
162
|
+
},
|
|
163
|
+
optionChange(obj){
|
|
164
|
+
let index = obj.orderIndex
|
|
165
|
+
console.log(obj,'obj');
|
|
166
|
+
this.tabsArr[index].answered = obj.isAnswered
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
components:{
|
|
170
|
+
MediaLooker
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
</script>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</template>
|
|
76
76
|
<script>
|
|
77
77
|
|
|
78
|
-
import {commonData,doMediaLookerSome} from './mixin
|
|
78
|
+
import {commonData,doMediaLookerSome} from './mixin'
|
|
79
79
|
import MediaLooker from '../common/MediaLooker.vue'
|
|
80
80
|
import fun from "../../assets/js/fun";
|
|
81
81
|
|
|
@@ -117,7 +117,7 @@ export default {
|
|
|
117
117
|
})
|
|
118
118
|
}else{
|
|
119
119
|
this.mode === 'exam' && this.bus.$emit('optionChange')
|
|
120
|
-
this.mode === 'exam' && this
|
|
120
|
+
this.mode === 'exam' && this.$emit('optionChange', {orderIndex:this.orderIndex,isAnswered:self.isAnswered()})
|
|
121
121
|
}
|
|
122
122
|
},{
|
|
123
123
|
immediate:true
|
|
@@ -152,36 +152,22 @@ export default {
|
|
|
152
152
|
let judge = nv.answerMap.judge
|
|
153
153
|
if(judge!==undefined && judge!==null && judge!==''){
|
|
154
154
|
this.radio = judge ? 1 : 2
|
|
155
|
+
// analysis的时候在这里标记tab已读,因为改变的时候限定了exam了
|
|
156
|
+
this.$emit('optionChange', {orderIndex:this.orderIndex,isAnswered:this.isAnswered()})
|
|
155
157
|
}
|
|
156
158
|
}else{
|
|
157
159
|
let single_index = nv.answerMap.single_index
|
|
158
160
|
if(single_index!==undefined && single_index!==null && single_index!==''){
|
|
159
161
|
this.radio = single_index
|
|
162
|
+
// analysis的时候在这里标记tab已读,因为改变的时候限定了exam了
|
|
163
|
+
this.$emit('optionChange', {orderIndex:this.orderIndex,isAnswered:this.isAnswered()})
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
},
|
|
165
169
|
immediate:true
|
|
166
|
-
}
|
|
167
|
-
/*radio:{
|
|
168
|
-
handler(nv,ov){
|
|
169
|
-
debugger
|
|
170
|
-
let self = this
|
|
171
|
-
let isSub = this.isSub
|
|
172
|
-
if(!isSub){
|
|
173
|
-
let answered = this.isAnswered()
|
|
174
|
-
this.mode === 'exam' && bus.$emit('questionCardChange',{
|
|
175
|
-
questionIndex:this.questionInfo.questionIndex - 1,
|
|
176
|
-
answered
|
|
177
|
-
})
|
|
178
|
-
}else{
|
|
179
|
-
this.mode === 'exam' && bus.$emit('optionChange')
|
|
180
|
-
this.mode === 'exam' && this.emit('optionChange', {orderIndex:this.orderIndex,isAnswered:self.isAnswered()})
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
immediate:true
|
|
184
|
-
}*/
|
|
170
|
+
}
|
|
185
171
|
},
|
|
186
172
|
computed:{
|
|
187
173
|
},
|
|
@@ -4,10 +4,135 @@
|
|
|
4
4
|
//此文件作为打包入口,打包后的dist文件给vue3用
|
|
5
5
|
import '../../assets/scss/questions/index.scss';
|
|
6
6
|
import Question_SingleChoice from './Question_SingleChoice.vue'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import Question_MultipleChoice from './Question_MultipleChoice.vue'
|
|
8
|
+
import Question_Reading from './Question_Reading.vue'
|
|
9
|
+
import Question_BriefAnswer from './Question_BriefAnswer.vue'
|
|
10
|
+
import Question_FillBlank from './Question_FillBlank.vue'
|
|
11
|
+
import Question_Programming from './Question_Programming.vue'
|
|
12
|
+
import {questionMapper} from "./const";
|
|
13
|
+
import fun from "../../assets/js/fun";
|
|
14
|
+
import storeOptions from './store'
|
|
15
|
+
export default function(store){
|
|
16
|
+
//动态注册store
|
|
17
|
+
store.registerModule('zykjcommonQuestions',storeOptions)
|
|
18
|
+
return {
|
|
19
|
+
install(Vue){
|
|
20
|
+
let version = fun.getVueVersion()
|
|
21
|
+
Vue.mixin({
|
|
22
|
+
methods: {
|
|
23
|
+
//公共解析questionItem方法
|
|
24
|
+
parseQuestionListItem(mode,question_list,answer_map,parentIndex = undefined){
|
|
25
|
+
function parseContent(arr,contentWidth){
|
|
26
|
+
arr.forEach((item)=>{
|
|
27
|
+
if(item['<>'] === 'img'){
|
|
28
|
+
if(item.hasOwnProperty('width')){
|
|
29
|
+
let width = Number(item.width)
|
|
30
|
+
if(width > contentWidth){
|
|
31
|
+
item.width = Math.floor(contentWidth)
|
|
32
|
+
item.height && delete item.height
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if(item.html && item.html.length){
|
|
37
|
+
parseContent(item.html,contentWidth)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
question_list.forEach((item,index)=>{
|
|
42
|
+
item.questionComponent = questionMapper[item.question_type]
|
|
43
|
+
// item.questionIndex = index + 1
|
|
44
|
+
if(parentIndex === undefined){
|
|
45
|
+
item.questionIndex = index + 1
|
|
46
|
+
}else{
|
|
47
|
+
item.questionIndex = (parentIndex + 1) + '-' + (index + 1)
|
|
48
|
+
item.questionIndex2 = index + 1
|
|
49
|
+
}
|
|
50
|
+
if(answer_map && answer_map.hasOwnProperty(item.question_id)){
|
|
51
|
+
item.answerMap = answer_map[item.question_id]
|
|
52
|
+
if(mode === 'analysis'){
|
|
53
|
+
//analysis页面特殊处理
|
|
54
|
+
if(item.answerMap.user_coding_file){
|
|
55
|
+
item.answerMap.oss_temp_url = item.answerMap.user_coding_file
|
|
56
|
+
}
|
|
57
|
+
//analysis页面特殊处理score字段为 answerMap.question_max_score
|
|
58
|
+
item.score = item.answerMap.question_max_score
|
|
59
|
+
//预览接口学生答案以user_开头,为适配考试的学生答案,做处理
|
|
60
|
+
let answerMapKeys = Object.keys(item.answerMap)
|
|
61
|
+
let reg = /^user_/ig
|
|
62
|
+
answerMapKeys.forEach((answerMapKeysItem)=>{
|
|
63
|
+
if(reg.test(answerMapKeysItem)){
|
|
64
|
+
let newProp = answerMapKeysItem.replace(reg,'')
|
|
65
|
+
item.answerMap[newProp] = item.answerMap[answerMapKeysItem]
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}else{
|
|
70
|
+
item.answerMap = null
|
|
71
|
+
}
|
|
72
|
+
let question_type = item.question_type
|
|
73
|
+
if(question_type == 3){
|
|
74
|
+
//判断题手动构造选项数组
|
|
75
|
+
item.exam_options_data = [
|
|
76
|
+
{
|
|
77
|
+
index:1,data:{
|
|
78
|
+
name:'正确'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
index:2,data:{
|
|
83
|
+
name:'错误'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}else{
|
|
88
|
+
if(item.exam_options_data && item.exam_options_data.length){
|
|
89
|
+
item.exam_options_data.forEach((subItem,subIndex)=>{
|
|
90
|
+
subItem.enIndex = fun.indexToEnIndex(subIndex+1)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//转化content富文本
|
|
95
|
+
try{
|
|
96
|
+
|
|
97
|
+
let contentArr = JSON.parse(item.content)
|
|
98
|
+
let contentWidth = jQuery('.question-list').width() - 30
|
|
99
|
+
//图片宽度超出框架的时候把宽度设置成框架大小
|
|
100
|
+
parseContent(contentArr,contentWidth)
|
|
101
|
+
item.htmlContent = $.json2html({}, contentArr);
|
|
102
|
+
}catch(e){
|
|
103
|
+
item.htmlContent = item.content
|
|
104
|
+
}
|
|
105
|
+
//转化analysis富文本
|
|
106
|
+
try{
|
|
107
|
+
if(item.analysis){
|
|
108
|
+
item.analysisHtmlContent = $.json2html({}, JSON.parse(item.analysis));
|
|
109
|
+
}else{
|
|
110
|
+
item.analysisHtmlContent = ''
|
|
111
|
+
}
|
|
112
|
+
}catch(e){
|
|
113
|
+
item.analysisHtmlContent = item.analysis
|
|
114
|
+
}
|
|
115
|
+
//如果是阅读题要递归解析
|
|
116
|
+
if(item.sub_questions && item.sub_questions.length){
|
|
117
|
+
this.parseQuestionListItem(mode,item.sub_questions,answer_map,index)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
Vue.component('Question_SingleChoice',Question_SingleChoice)
|
|
124
|
+
Vue.component('Question_MultipleChoice',Question_MultipleChoice)
|
|
125
|
+
Vue.component('Question_Reading',Question_Reading)
|
|
126
|
+
Vue.component('Question_BriefAnswer',Question_BriefAnswer)
|
|
127
|
+
Vue.component('Question_FillBlank',Question_FillBlank)
|
|
128
|
+
Vue.component('Question_Programming',Question_Programming)
|
|
129
|
+
},
|
|
130
|
+
Question_SingleChoice,
|
|
131
|
+
Question_MultipleChoice,
|
|
132
|
+
Question_Reading,
|
|
133
|
+
Question_BriefAnswer,
|
|
134
|
+
Question_FillBlank,
|
|
135
|
+
Question_Programming
|
|
136
|
+
}
|
|
12
137
|
}
|
|
13
138
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Created by Allen Liu on 2022/4/22.
|
|
5
|
+
*/
|
|
6
|
+
//全局用常量
|
|
7
|
+
export let questionMapper = {
|
|
8
|
+
'1':'Question_SingleChoice',//单选
|
|
9
|
+
'2':'Question_MultipleChoice',//多选
|
|
10
|
+
'3':'Question_SingleChoice',//判断
|
|
11
|
+
'7':'Question_BriefAnswer',//简答
|
|
12
|
+
'16':'Question_Programming',//编程
|
|
13
|
+
'11':'Question_Reading',//阅读
|
|
14
|
+
'4':'Question_FillBlank'//填空
|
|
15
|
+
}
|