yks-element 1.0.317 → 1.0.320

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.
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <div class="single">
3
+ <div class="single-stem__label required__label">题干</div>
4
+ <yks-tinymce
5
+ key="itemContent"
6
+ :value="fromData.itemContent"
7
+ :toolbar="toolbar"
8
+ :plugins="plugins"
9
+ :charLimit="topicDataExtent.itemContentLength || 20000"
10
+
11
+ :fileParams="getFileTypes('stem', fromData.stemAttrs)"
12
+ :uploadFileToHwCloud="uploadFileToHwCloud"
13
+ :uploadFileFunction="uploadFileFunction"
14
+ menubar=""
15
+ height="200px"
16
+ @change="($event) => getTinymceEdit($event, 'stem')"
17
+ @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
18
+ />
19
+
20
+ <div
21
+ v-for="(item, index) in fromData.compoundList"
22
+ :key="`compoundList${index}`"
23
+ class="yks-ml10"
24
+ >
25
+ <div class="yks-flex single-single">
26
+ <span class="single-single__label required__label"
27
+ >{{ index + 1 }}) {{ topic[item.componentId] }}</span
28
+ >
29
+ <span class="yks-fs-12 yks-mr10">分值</span>
30
+ <span class="flex-1">
31
+ <el-input-number
32
+ v-model="item.score"
33
+ :min="0"
34
+ :step="0.5"
35
+ :max="100"
36
+ ></el-input-number>
37
+ <el-button
38
+ v-if="index > 0"
39
+ type="text"
40
+ class="yks-ml10"
41
+ @click="handleShiftItem('up', index)"
42
+ >上移题目</el-button
43
+ >
44
+ <el-button
45
+ v-if="
46
+ index + 1 !== fromData.compoundList.length &&
47
+ fromData.compoundList.length > 0
48
+ "
49
+ type="text"
50
+ class="yks-ml10"
51
+ @click="handleShiftItem('down', index)"
52
+ >下移题目</el-button
53
+ >
54
+ </span>
55
+ <el-button
56
+ v-if="fromData.compoundList.length > 1"
57
+ type="text"
58
+ class="yks-danger"
59
+ @click="handleDelte(index)"
60
+ >删除</el-button
61
+ >
62
+ </div>
63
+ <component
64
+ :is="getComponentId(item.componentId)"
65
+ v-model="item.itemContentList"
66
+ :topicDataExtent="topicDataExtent"
67
+ :uploadFileToHwCloud="uploadFileToHwCloud"
68
+ ></component>
69
+ </div>
70
+
71
+ <div class="yks-flex h-between compound-button">
72
+ <el-button type="primary" @click="handleAddItem('single')">添加单选题</el-button>
73
+ <el-button type="primary" @click="handleAddItem('judgment')">添加判断题</el-button>
74
+ <el-button type="primary" @click="handleAddItem('multiple')">添加多选题</el-button>
75
+ <el-button type="primary" @click="handleAddItem('short_answer')">添加简答题</el-button>
76
+ </div>
77
+ </div>
78
+ </template>
79
+ <script>
80
+ import YksTinymce from '../../Tinymce/index'
81
+ import TopicMixins from '../../assets/mixins/topic'
82
+ import { analysisItemType, stemItemType, itemDataLists } from './config'
83
+ import { Single, Multiple, Judgment, ShortAnswer } from '../index'
84
+
85
+ export default {
86
+ name: 'Compound',
87
+ components: { YksTinymce, Single, Multiple, Judgment, ShortAnswer },
88
+ mixins: [TopicMixins],
89
+ methods: {
90
+ handleDelte(index) {
91
+ this.fromData.compoundList.splice(index, 1)
92
+ this.$emit('change', this.fromData)
93
+ },
94
+
95
+ handleAddItem(value) {
96
+ const params = {
97
+ itemContentList: {
98
+ answer: '',
99
+ itemContent: '',
100
+ itemList: itemDataLists(),
101
+ stemAttrs: [],
102
+ answerAttrs: [],
103
+ descriptionAttrs: [],
104
+ description: ''
105
+ },
106
+ score: 0,
107
+ componentId: value
108
+ }
109
+
110
+ switch (value) {
111
+ case 'multiple':
112
+ params.itemContentList.answer = []
113
+ break
114
+ case 'judgment':
115
+ params.itemContentList.itemList = []
116
+ break
117
+ case 'short_answer':
118
+ params.itemContentList.itemList = []
119
+ break
120
+ }
121
+ this.fromData.compoundList.push(params)
122
+ this.$emit('change', this.fromData)
123
+ },
124
+
125
+ /**
126
+ * data 富文本数据
127
+ * field 对象名
128
+ * type 类型
129
+ */
130
+ getTinymceEdit(data, type) {
131
+ switch (type) {
132
+ case 'stem':
133
+ data.itemAttr.type = stemItemType[data.itemAttr.type]
134
+ this.fromData.itemContent = data.value
135
+ if (data.itemAttr.type && data.itemAttr.content) {
136
+ this.fromData.stemAttrs.push(data.itemAttr)
137
+ }
138
+ break
139
+ case 'analysis':
140
+ data.itemAttr.type = analysisItemType[data.itemAttr.type]
141
+ this.fromData.description = data.value
142
+ if (data.itemAttr.type && data.itemAttr.content) {
143
+ this.fromData.descriptionAttrs.push(data.itemAttr)
144
+ }
145
+ break
146
+ default:
147
+ break
148
+ }
149
+ this.$emit('change', this.fromData)
150
+ },
151
+
152
+ handleShiftItem(type, index) {
153
+ const { compoundList } = this.fromData
154
+ if (type === 'up') {
155
+ compoundList[index] = compoundList.splice(index - 1, 1, compoundList[index])[0]
156
+ } else {
157
+ compoundList[index] = compoundList.splice(index + 1, 1, compoundList[index])[0]
158
+ }
159
+ this.fromData.compoundList = compoundList
160
+ this.$emit('change', this.fromData)
161
+ },
162
+
163
+ getComponentId(value) {
164
+ if (value === 'short_answer') {
165
+ return 'shortAnswer'
166
+ }
167
+ return value
168
+ },
169
+
170
+ handleDelteAttrs(data, type, list, row = {}) {
171
+ const listAttrs = list
172
+ listAttrs.splice(data.index, 1)
173
+ switch (type) {
174
+ case 'stem':
175
+ this.fromData.stemAttrs = listAttrs
176
+ break
177
+ case 'option':
178
+ this.$set(row, 'optionAttrs', listAttrs)
179
+ break
180
+ case 'analysis':
181
+ this.fromData.descriptionAttrs = listAttrs
182
+ break
183
+ default:
184
+ break
185
+ }
186
+ this.$emit('change', this.fromData)
187
+ }
188
+ }
189
+ }
190
+ </script>
191
+
192
+ <style lang="scss" scoped>
193
+ .single-single {
194
+ margin: 30px 0;
195
+ .single-single__label {
196
+ font-weight: 700;
197
+ font-size: 18px;
198
+ margin-right: 20px;
199
+ }
200
+ }
201
+ .single-stem__label {
202
+ font-weight: 700;
203
+ font-size: 18px;
204
+ margin: 30px 0;
205
+ }
206
+ .radio-tinymce {
207
+ font-size: 14px;
208
+ margin-right: 20px;
209
+ }
210
+
211
+ .compound-button {
212
+ margin: 20px auto;
213
+ width: 60%;
214
+ }
215
+
216
+ ::v-deep {
217
+ .el-radio-group {
218
+ display: block;
219
+ }
220
+ }
221
+ </style>
@@ -0,0 +1,132 @@
1
+ /**
2
+ * uploadRecording 录音
3
+ * uploadVideo 视频
4
+ * uploadAudio 音频
5
+ * uploadFile 文件
6
+ */
7
+
8
+ export const toolbar = [
9
+ 'bold underline italic strikethrough | kityformula-editor subscript superscript charmap | link image | table | removeformat | uploadRecording uploadVideo uploadAudio uploadFile'
10
+ ]
11
+
12
+ /* 选项、填空等 */
13
+ export const toolbarSpare = ['kityformula-editor subscript superscript charmap']
14
+
15
+ /* 插件 */
16
+ export const plugins = ['kityformula-editor powerpaste lists image media table charmap imagetools']
17
+
18
+ /* 选项字符 */
19
+ export const letter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
20
+
21
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件):题干 / 标题 - 类型 */
22
+ export const stemItemType = {
23
+ recording: 'stem_voiceRecord',
24
+ video: 'stem_video',
25
+ audio: 'stem_audio',
26
+ file: 'stem_document'
27
+ }
28
+
29
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 标准答案 - 类型 */
30
+ export const shortItemType = {
31
+ recording: 'answer_voiceRecord',
32
+ video: 'answer_video',
33
+ audio: 'answer_audio',
34
+ file: 'answer_document'
35
+ }
36
+
37
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 选项 - 类型 */
38
+ export const optionItemType = {
39
+ recording: 'option_voiceRecord',
40
+ video: 'option_video',
41
+ audio: 'option_audio',
42
+ file: 'option_document'
43
+ }
44
+
45
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 答案解析 - 类型 */
46
+ export const analysisItemType = {
47
+ recording: 'description_voiceRecord',
48
+ video: 'description_video',
49
+ audio: 'description_audio',
50
+ file: 'description_document'
51
+ }
52
+
53
+ /**
54
+ * 获取题类型
55
+ * @param {string} type
56
+ * @return {Object}
57
+ */
58
+ export const getFileType = (type, data) => {
59
+ if (data) {
60
+ let params = {}
61
+ switch (type) {
62
+ case 'stem':
63
+ params = {
64
+ stem_voiceRecord: 'recording',
65
+ stem_video: 'video',
66
+ stem_audio: 'audio',
67
+ stem_document: 'file'
68
+ }
69
+ break
70
+ case 'answer':
71
+ params = {
72
+ answer_voiceRecord: 'recording',
73
+ answer_video: 'video',
74
+ answer_audio: 'audio',
75
+ answer_document: 'file'
76
+ }
77
+ break
78
+ case 'option':
79
+ params = {
80
+ option_voiceRecord: 'recording',
81
+ option_video: 'video',
82
+ option_audio: 'audio',
83
+ option_document: 'file'
84
+ }
85
+ break
86
+ case 'analysis':
87
+ params = {
88
+ description_voiceRecord: 'recording',
89
+ description_video: 'video',
90
+ description_audio: 'audio',
91
+ description_document: 'file'
92
+ }
93
+ break
94
+ }
95
+ const fileType = params[data.type]
96
+
97
+ return {
98
+ ...data,
99
+ fileType
100
+ }
101
+ }
102
+ return false
103
+ }
104
+
105
+ export const itemDataLists = () => {
106
+ return [
107
+ {
108
+ optionName: 'A',
109
+ content: '',
110
+ optionAttrs: [],
111
+ score: ''
112
+ },
113
+ {
114
+ optionName: 'B',
115
+ content: '',
116
+ optionAttrs: [],
117
+ score: ''
118
+ },
119
+ {
120
+ optionName: 'C',
121
+ content: '',
122
+ optionAttrs: [],
123
+ score: ''
124
+ },
125
+ {
126
+ optionName: 'D',
127
+ content: '',
128
+ optionAttrs: [],
129
+ score: ''
130
+ }
131
+ ]
132
+ }
@@ -0,0 +1,272 @@
1
+ <template>
2
+ <div class="single">
3
+ <div class="single-stem__label required__label">题干</div>
4
+ <yks-tinymce
5
+ ref="stemTinymceEdit"
6
+ key="itemContent"
7
+ :value="fromData.itemContent"
8
+ :toolbar="toolbar"
9
+ :plugins="plugins"
10
+ :charLimit="topicDataExtent.itemContentLength || 20000"
11
+
12
+ :fileParams="getFileTypes('stem', fromData.stemAttrs)"
13
+ :uploadFileToHwCloud="uploadFileToHwCloud"
14
+ :uploadFileFunction="uploadFileFunction"
15
+ menubar=""
16
+ height="200px"
17
+ @change="($event) => getTinymceEdit($event, 'stem')"
18
+ @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
19
+ />
20
+ <div class="yks-flex yks-mt10">
21
+ <el-button type="primary" class="yks-mr10" @click="handleFillInBlanks"
22
+ >插入填空符</el-button
23
+ >
24
+ <span class="yks-fs-12 info">请在题干中你需要的位置插入填空符,并在下方编辑对应答案</span>
25
+ </div>
26
+
27
+ <div class="yks-flex single-single">
28
+ <span class="single-single__label required__label">答案</span>
29
+ <span class="yks-fs-12 yks-info">考生需要在每个空内输入正确的答案</span>
30
+ </div>
31
+ <div
32
+ v-for="(item, index) in fromData.itemList"
33
+ :key="`itemList${index}`"
34
+ class="yks-flex yks-mb10 v-start"
35
+ >
36
+ <span class="yks-w_60 yks-mr10">填空{{ index + 1 }}</span>
37
+ <yks-tinymce
38
+ key="content"
39
+ :value="item.content"
40
+ :toolbar="toolbarSpare"
41
+ :plugins="plugins"
42
+ :charLimit="topicDataExtent.answerLength || 5000"
43
+
44
+ :fileParams="getFileTypes('option', item.optionAttrs)"
45
+ :uploadFileToHwCloud="uploadFileToHwCloud"
46
+ :uploadFileFunction="uploadFileFunction"
47
+ inline
48
+ height="60px"
49
+ menubar=""
50
+ class="flex-1 radio-tinymce"
51
+ @change="($event) => changeItem($event, item)"
52
+ @delte="($event) => handleDelteAttrs($event, 'option', item.optionAttrs, item)"
53
+ />
54
+ <el-input-number
55
+ v-model="item.score"
56
+ controls-position="right"
57
+ placeholder="分值"
58
+ class="yks-mr10"
59
+ size="large"
60
+ :min="0"
61
+ :step="0.5"
62
+ :max="100"
63
+ ></el-input-number>
64
+ <el-button type="text" class="yks-danger" @click="handleDelte(index)">删除</el-button>
65
+ </div>
66
+
67
+ <div class="fill__other">
68
+ <div class="text__warning">
69
+ 1、如果勾选考生端开启数学公式编辑器,在PC端考生答题页面,本题答题区域考生可以使用数据公式编辑器。
70
+ <br />
71
+ 2、如果勾选按答案自动判分,需要考生填写内容须跟答案完全相同,才能得分,录入答案时,请不要加多余的空格标点符号等干扰字符,考生考后系统自动出分。
72
+ <br />
73
+ 3、如果没有勾选按答案自动判分,考生答卷需等待管理员后台手工判分。
74
+ </div>
75
+ <div class="yks-mt10">
76
+ <el-checkbox v-model="fromData.mathematical"
77
+ >开启数学公式编辑器(只适用于PC端答题)</el-checkbox
78
+ >
79
+ <div class="yks-mt10">
80
+ <el-checkbox v-model="fromData.automaticScoring" true-label="1" false-label="0"
81
+ >按答案自动判分</el-checkbox
82
+ >
83
+ </div>
84
+ <div v-if="fromData.automaticScoring === '1'" class="yks-mt10">
85
+ <el-checkbox v-model="fromData.outOfOrder" true-label="1" false-label="0"
86
+ >允许考生答案与参考答案顺序不一致</el-checkbox
87
+ >
88
+ <el-checkbox v-model="fromData.neglect" true-label="1" false-label="0"
89
+ >忽略大小写</el-checkbox
90
+ >
91
+ </div>
92
+ </div>
93
+ </div>
94
+
95
+ <div class="single-stem__label">答案解析</div>
96
+ <yks-tinymce
97
+ key="description"
98
+ :value="fromData.description"
99
+ :toolbar="toolbar"
100
+ :plugins="plugins"
101
+ :charLimit="topicDataExtent.descriptionLength || 20000"
102
+
103
+ :fileParams="getFileTypes('analysis', fromData.descriptionAttrs)"
104
+ :uploadFileToHwCloud="uploadFileToHwCloud"
105
+ :uploadFileFunction="uploadFileFunction"
106
+ menubar=""
107
+ height="200px"
108
+ @change="($event) => getTinymceEdit($event, 'analysis')"
109
+ @delte="($event) => handleDelteAttrs($event, 'analysis', fromData.descriptionAttrs)"
110
+ />
111
+ </div>
112
+ </template>
113
+ <script>
114
+ import YksTinymce from '../../Tinymce/index'
115
+ import TopicMixins from '../../assets/mixins/topic'
116
+ import { stemItemType, optionItemType, analysisItemType } from './config'
117
+
118
+ export default {
119
+ name: 'FillInBlanks',
120
+ components: { YksTinymce },
121
+ mixins: [TopicMixins],
122
+ methods: {
123
+ /**
124
+ * data 富文本数据
125
+ * field 对象名
126
+ * type 类型
127
+ */
128
+ getTinymceEdit(data, type) {
129
+ switch (type) {
130
+ case 'stem':
131
+ data.itemAttr.type = stemItemType[data.itemAttr.type]
132
+ if (data.itemAttr.type && data.itemAttr.content) {
133
+ this.fromData.stemAttrs.push(data.itemAttr)
134
+ }
135
+ // eslint-disable-next-line no-case-declarations
136
+ const list = data.value.match(/<input ([^>|]+)>/g, '') || []
137
+ // eslint-disable-next-line no-case-declarations
138
+ const editor = this.$refs.stemTinymceEdit
139
+ if ((this.fromData.itemList || []).length !== list.length && !this.processing) {
140
+ const { itemContent } = this.fromData
141
+ this.$message.error('请从下方填空符删除!')
142
+ this.fromData.itemContent = itemContent.replace(
143
+ /<input ([^>|]+)\/>/g,
144
+ (all, value) => {
145
+ const attributes = value.replace('disabled="disabled"', '')
146
+ return `<input ${attributes} disabled="disabled" />`
147
+ }
148
+ )
149
+ this.$nextTick(() => {
150
+ editor.keepLastIndex()
151
+ })
152
+ } else {
153
+ this.fromData.itemContent = data.value
154
+ }
155
+ break
156
+ case 'analysis':
157
+ data.itemAttr.type = analysisItemType[data.itemAttr.type]
158
+ this.fromData.description = data.value
159
+ if (data.itemAttr.type && data.itemAttr.content) {
160
+ this.fromData.descriptionAttrs.push(data.itemAttr)
161
+ }
162
+ break
163
+ default:
164
+ break
165
+ }
166
+ this.$emit('change', this.fromData)
167
+ },
168
+
169
+ changeItem(data, row) {
170
+ data.itemAttr.type = optionItemType[data.itemAttr.type]
171
+ if (data.itemAttr.type && data.itemAttr.content) {
172
+ row.optionAttrs.push(data.itemAttr)
173
+ this.$set(row, 'optionAttrs', row.optionAttrs)
174
+ }
175
+ this.$set(row, 'content', data.value)
176
+ this.$emit('change', this.fromData)
177
+ },
178
+
179
+ handleDelte(index) {
180
+ const list = this.fromData.itemContent.match(/<input ([^>|]+)>/g, '') || []
181
+ const classId = this.fromData.itemList[index].classId
182
+ if (classId) {
183
+ const subIndex = list.findIndex((v) => v.search(classId) !== -1)
184
+ this.fromData.itemList.splice(index, 1)
185
+ const editor = this.$refs.stemTinymceEdit
186
+ editor.deleFillItem(subIndex)
187
+ } else {
188
+ this.fromData.itemList.splice(index, 1)
189
+ const editor = this.$refs.stemTinymceEdit
190
+ editor.deleFillItem(index)
191
+ }
192
+
193
+ this.$emit('change', this.fromData)
194
+ },
195
+
196
+ handleFillInBlanks() {
197
+ if (this.fromData.itemList.length >= 40) {
198
+ return
199
+ }
200
+ const value = Date.now()
201
+ this.processing = true
202
+ const editor = this.$refs.stemTinymceEdit
203
+ editor.handleFillInBlanks(this.fromData.itemList.length, value)
204
+ const { itemContent } = this.fromData
205
+ let index = 0
206
+ this.fromData.itemContent = itemContent.replace(/<input ([^>|]+)\/>/g, (all, value) => {
207
+ index += 1
208
+ return `<input value="${index}" ${value} />`
209
+ })
210
+ const list = this.fromData.itemContent.match(/<input ([^>|]+)>/g, '') || []
211
+ const subIndex = list.findIndex((v) => v.search(value) !== -1)
212
+ this.fromData.itemList.splice(subIndex, 0, {
213
+ optionName: '',
214
+ content: '',
215
+ score: '',
216
+ optionAttrs: [],
217
+ classId: value
218
+ })
219
+ this.$nextTick(() => {
220
+ editor.keepLastIndex()
221
+ this.$emit('change', this.fromData)
222
+ })
223
+ this.processing = false
224
+ },
225
+
226
+ handleDelteAttrs(data, type, list, row = {}) {
227
+ const listAttrs = list
228
+ listAttrs.splice(data.index, 1)
229
+ switch (type) {
230
+ case 'stem':
231
+ this.fromData.stemAttrs = listAttrs
232
+ break
233
+ case 'option':
234
+ this.$set(row, 'optionAttrs', listAttrs)
235
+ break
236
+ case 'analysis':
237
+ this.fromData.descriptionAttrs = listAttrs
238
+ break
239
+ default:
240
+ break
241
+ }
242
+ this.$emit('change', this.fromData)
243
+ }
244
+ }
245
+ }
246
+ </script>
247
+
248
+ <style lang="scss" scoped>
249
+ .single-single {
250
+ margin: 30px 0;
251
+ .single-single__label {
252
+ font-weight: 700;
253
+ font-size: 18px;
254
+ width: 100px;
255
+ }
256
+ }
257
+ .single-stem__label {
258
+ font-weight: 700;
259
+ font-size: 18px;
260
+ margin: 30px 0;
261
+ }
262
+ .radio-tinymce {
263
+ font-size: 14px;
264
+ margin-right: 20px;
265
+ }
266
+
267
+ ::v-deep {
268
+ .el-radio-group {
269
+ display: block;
270
+ }
271
+ }
272
+ </style>
File without changes