|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+<script setup lang="ts">
|
|
|
2
|
+import { computed, ref } from 'vue';
|
|
|
3
|
+
|
|
|
4
|
+// 试卷表单数据
|
|
|
5
|
+const examForm = ref({
|
|
|
6
|
+ examName: '',
|
|
|
7
|
+ examCategory: '',
|
|
|
8
|
+});
|
|
|
9
|
+
|
|
|
10
|
+// 当前选中的题目索引
|
|
|
11
|
+const currentQuestionIndex = ref(0);
|
|
|
12
|
+
|
|
|
13
|
+// 新题目标题
|
|
|
14
|
+const newQuestionTitle = ref('');
|
|
|
15
|
+
|
|
|
16
|
+// 试卷题目数据
|
|
|
17
|
+const examQuestions = ref([
|
|
|
18
|
+ {
|
|
|
19
|
+ title: '第一题 选择题',
|
|
|
20
|
+ fixedQuestions: [
|
|
|
21
|
+ { type: '填空题', count: 120, score: 0 },
|
|
|
22
|
+ { type: '简答题', count: 120, score: 0 },
|
|
|
23
|
+ { type: '单选题', count: 120, score: 0 },
|
|
|
24
|
+ { type: '多选题', count: 120, score: 0 },
|
|
|
25
|
+ ],
|
|
|
26
|
+ randomQuestions: [
|
|
|
27
|
+ { type: '填空题', count: 120, score: 0 },
|
|
|
28
|
+ { type: '简答题', count: 120, score: 0 },
|
|
|
29
|
+ { type: '单选题', count: 120, score: 0 },
|
|
|
30
|
+ { type: '多选题', count: 120, score: 0 },
|
|
|
31
|
+ ],
|
|
|
32
|
+ },
|
|
|
33
|
+ {
|
|
|
34
|
+ title: '第二题 填空题',
|
|
|
35
|
+ fixedQuestions: [],
|
|
|
36
|
+ randomQuestions: [],
|
|
|
37
|
+ },
|
|
|
38
|
+ {
|
|
|
39
|
+ title: '第三题 判断题',
|
|
|
40
|
+ fixedQuestions: [],
|
|
|
41
|
+ randomQuestions: [],
|
|
|
42
|
+ },
|
|
|
43
|
+]);
|
|
|
44
|
+
|
|
|
45
|
+// 计算总题数
|
|
|
46
|
+const totalQuestions = computed(() => examQuestions.value.length);
|
|
|
47
|
+
|
|
|
48
|
+// 计算小题总数
|
|
|
49
|
+const totalSubQuestions = computed(() => {
|
|
|
50
|
+ return examQuestions.value.reduce((total, question) => {
|
|
|
51
|
+ return (
|
|
|
52
|
+ total + question.fixedQuestions.length + question.randomQuestions.length
|
|
|
53
|
+ );
|
|
|
54
|
+ }, 0);
|
|
|
55
|
+});
|
|
|
56
|
+
|
|
|
57
|
+// 计算总分
|
|
|
58
|
+const totalScore = computed(() => {
|
|
|
59
|
+ let score = 0;
|
|
|
60
|
+ examQuestions.value.forEach((question) => {
|
|
|
61
|
+ question.fixedQuestions.forEach((item) => {
|
|
|
62
|
+ score += item.score;
|
|
|
63
|
+ });
|
|
|
64
|
+ question.randomQuestions.forEach((item) => {
|
|
|
65
|
+ score += item.score;
|
|
|
66
|
+ });
|
|
|
67
|
+ });
|
|
|
68
|
+ return score;
|
|
|
69
|
+});
|
|
|
70
|
+
|
|
|
71
|
+// 获取单个题目总分
|
|
|
72
|
+const getQuestionTotalScore = (index: number) => {
|
|
|
73
|
+ const question = examQuestions.value[index];
|
|
|
74
|
+ let score = 0;
|
|
|
75
|
+ question.fixedQuestions.forEach((item) => {
|
|
|
76
|
+ score += item.score;
|
|
|
77
|
+ });
|
|
|
78
|
+ question.randomQuestions.forEach((item) => {
|
|
|
79
|
+ score += item.score;
|
|
|
80
|
+ });
|
|
|
81
|
+ return score;
|
|
|
82
|
+};
|
|
|
83
|
+
|
|
|
84
|
+// 计算分数变化
|
|
|
85
|
+const calculateScore = () => {
|
|
|
86
|
+ // 分数计算逻辑已通过computed属性实现
|
|
|
87
|
+};
|
|
|
88
|
+
|
|
|
89
|
+// 添加大题
|
|
|
90
|
+const addBigQuestion = () => {
|
|
|
91
|
+ examQuestions.value.push({
|
|
|
92
|
+ title: `第${examQuestions.value.length + 1}题 新题目`,
|
|
|
93
|
+ fixedQuestions: [],
|
|
|
94
|
+ randomQuestions: [],
|
|
|
95
|
+ });
|
|
|
96
|
+ currentQuestionIndex.value = examQuestions.value.length - 1;
|
|
|
97
|
+};
|
|
|
98
|
+</script>
|
|
|
99
|
+
|
|
|
100
|
+<template>
|
|
|
101
|
+ <div class="exam-edit-container">
|
|
|
102
|
+ <!-- 顶部区域 -->
|
|
|
103
|
+ <div class="top-section">
|
|
|
104
|
+ <div class="left-section">
|
|
|
105
|
+ <div class="form-item">
|
|
|
106
|
+ <label class="label">试卷名称:</label>
|
|
|
107
|
+ <el-input
|
|
|
108
|
+ v-model="examForm.examName"
|
|
|
109
|
+ placeholder="请输入试卷名称"
|
|
|
110
|
+ :maxlength="30"
|
|
|
111
|
+ show-word-limit
|
|
|
112
|
+ class="input"
|
|
|
113
|
+ />
|
|
|
114
|
+ </div>
|
|
|
115
|
+ <div class="form-item">
|
|
|
116
|
+ <label class="label">试卷分类:</label>
|
|
|
117
|
+ <el-select
|
|
|
118
|
+ v-model="examForm.examCategory"
|
|
|
119
|
+ placeholder="请选择"
|
|
|
120
|
+ class="select"
|
|
|
121
|
+ >
|
|
|
122
|
+ <el-option label="选择题" value="1" />
|
|
|
123
|
+ <el-option label="填空题" value="2" />
|
|
|
124
|
+ <el-option label="简答题" value="3" />
|
|
|
125
|
+ <el-option label="判断题" value="4" />
|
|
|
126
|
+ </el-select>
|
|
|
127
|
+ </div>
|
|
|
128
|
+ </div>
|
|
|
129
|
+ <div class="right-section">
|
|
|
130
|
+ <div class="stats">
|
|
|
131
|
+ <span>{{ totalQuestions }}大题</span>
|
|
|
132
|
+ <span class="separator">|</span>
|
|
|
133
|
+ <span>{{ totalSubQuestions }}小题</span>
|
|
|
134
|
+ <span class="separator">|</span>
|
|
|
135
|
+ <span>总分:{{ totalScore }}</span>
|
|
|
136
|
+ </div>
|
|
|
137
|
+ <el-button type="primary" size="default" class="save-btn">
|
|
|
138
|
+ 保存
|
|
|
139
|
+ </el-button>
|
|
|
140
|
+ </div>
|
|
|
141
|
+ </div>
|
|
|
142
|
+
|
|
|
143
|
+ <!-- 主体区域 -->
|
|
|
144
|
+ <div class="main-section">
|
|
|
145
|
+ <!-- 左侧导航 -->
|
|
|
146
|
+ <div class="left-nav">
|
|
|
147
|
+ <div class="nav-title">大题导航</div>
|
|
|
148
|
+ <div
|
|
|
149
|
+ v-for="(question, index) in examQuestions"
|
|
|
150
|
+ :key="index"
|
|
|
151
|
+ class="nav-item"
|
|
|
152
|
+ :class="{ active: currentQuestionIndex === index }"
|
|
|
153
|
+ @click="currentQuestionIndex = index"
|
|
|
154
|
+ >
|
|
|
155
|
+ {{ question.title }}
|
|
|
156
|
+ </div>
|
|
|
157
|
+ <el-input
|
|
|
158
|
+ v-model="newQuestionTitle"
|
|
|
159
|
+ placeholder="大题名称"
|
|
|
160
|
+ class="new-question-input"
|
|
|
161
|
+ />
|
|
|
162
|
+ </div>
|
|
|
163
|
+
|
|
|
164
|
+ <!-- 右侧内容 -->
|
|
|
165
|
+ <div class="right-content">
|
|
|
166
|
+ <!-- 题目编辑区域 -->
|
|
|
167
|
+ <div
|
|
|
168
|
+ v-for="(question, index) in examQuestions"
|
|
|
169
|
+ :key="index"
|
|
|
170
|
+ class="question-block"
|
|
|
171
|
+ v-show="currentQuestionIndex === index"
|
|
|
172
|
+ >
|
|
|
173
|
+ <div class="question-header">
|
|
|
174
|
+ <span class="question-title">{{ question.title }}</span>
|
|
|
175
|
+ <el-button type="text" icon="EditPen" class="edit-btn">
|
|
|
176
|
+ 编辑
|
|
|
177
|
+ </el-button>
|
|
|
178
|
+ </div>
|
|
|
179
|
+
|
|
|
180
|
+ <!-- 固定试题 -->
|
|
|
181
|
+ <div class="question-type-section">
|
|
|
182
|
+ <div class="section-title">固定试题</div>
|
|
|
183
|
+ <el-table :data="question.fixedQuestions" style="width: 100%">
|
|
|
184
|
+ <el-table-column prop="type" label="试题类型" width="120" />
|
|
|
185
|
+ <el-table-column prop="count" label="试题数" width="100" />
|
|
|
186
|
+ <el-table-column prop="score" label="每道题分数" width="120">
|
|
|
187
|
+ <template #default="scope">
|
|
|
188
|
+ <el-input-number
|
|
|
189
|
+ v-model="scope.row.score"
|
|
|
190
|
+ :min="0"
|
|
|
191
|
+ :max="100"
|
|
|
192
|
+ size="small"
|
|
|
193
|
+ @change="calculateScore"
|
|
|
194
|
+ />
|
|
|
195
|
+ </template>
|
|
|
196
|
+ </el-table-column>
|
|
|
197
|
+ <el-table-column label="操作" width="120">
|
|
|
198
|
+ <template #default="scope">
|
|
|
199
|
+ <el-button type="text" size="small" class="preview-btn">
|
|
|
200
|
+ 预览
|
|
|
201
|
+ </el-button>
|
|
|
202
|
+ <el-button type="text" size="small" class="delete-btn">
|
|
|
203
|
+ 删除
|
|
|
204
|
+ </el-button>
|
|
|
205
|
+ </template>
|
|
|
206
|
+ </el-table-column>
|
|
|
207
|
+ </el-table>
|
|
|
208
|
+ <el-button type="text" icon="Plus" class="add-question-btn">
|
|
|
209
|
+ + 试题库中选题
|
|
|
210
|
+ </el-button>
|
|
|
211
|
+ </div>
|
|
|
212
|
+
|
|
|
213
|
+ <!-- 随机试题 -->
|
|
|
214
|
+ <div class="question-type-section">
|
|
|
215
|
+ <div class="section-title">随机试题</div>
|
|
|
216
|
+ <el-table :data="question.randomQuestions" style="width: 100%">
|
|
|
217
|
+ <el-table-column prop="type" label="试题类型" width="120" />
|
|
|
218
|
+ <el-table-column prop="count" label="试题数" width="100" />
|
|
|
219
|
+ <el-table-column prop="score" label="每道题分数" width="120">
|
|
|
220
|
+ <template #default="scope">
|
|
|
221
|
+ <el-input-number
|
|
|
222
|
+ v-model="scope.row.score"
|
|
|
223
|
+ :min="0"
|
|
|
224
|
+ :max="100"
|
|
|
225
|
+ size="small"
|
|
|
226
|
+ @change="calculateScore"
|
|
|
227
|
+ />
|
|
|
228
|
+ </template>
|
|
|
229
|
+ </el-table-column>
|
|
|
230
|
+ <el-table-column label="操作" width="120">
|
|
|
231
|
+ <template #default="scope">
|
|
|
232
|
+ <el-button type="text" size="small" class="preview-btn">
|
|
|
233
|
+ 预览
|
|
|
234
|
+ </el-button>
|
|
|
235
|
+ <el-button type="text" size="small" class="delete-btn">
|
|
|
236
|
+ 删除
|
|
|
237
|
+ </el-button>
|
|
|
238
|
+ </template>
|
|
|
239
|
+ </el-table-column>
|
|
|
240
|
+ </el-table>
|
|
|
241
|
+ <el-button type="text" icon="Plus" class="add-question-btn">
|
|
|
242
|
+ + 试题库中选题
|
|
|
243
|
+ </el-button>
|
|
|
244
|
+ </div>
|
|
|
245
|
+
|
|
|
246
|
+ <div class="question-footer">
|
|
|
247
|
+ <span class="question-score"
|
|
|
248
|
+ >合计:{{ getQuestionTotalScore(index) }}分</span
|
|
|
249
|
+ >
|
|
|
250
|
+ </div>
|
|
|
251
|
+ </div>
|
|
|
252
|
+
|
|
|
253
|
+ <!-- 添加大题按钮 -->
|
|
|
254
|
+ <el-button
|
|
|
255
|
+ type="dashed"
|
|
|
256
|
+ icon="Plus"
|
|
|
257
|
+ class="add-big-question-btn"
|
|
|
258
|
+ @click="addBigQuestion"
|
|
|
259
|
+ >
|
|
|
260
|
+ + 添加大题
|
|
|
261
|
+ </el-button>
|
|
|
262
|
+ </div>
|
|
|
263
|
+ </div>
|
|
|
264
|
+ </div>
|
|
|
265
|
+</template>
|
|
|
266
|
+
|
|
|
267
|
+<style scoped>
|
|
|
268
|
+.exam-edit-container {
|
|
|
269
|
+ padding: 20px;
|
|
|
270
|
+ background-color: #f5f7fa;
|
|
|
271
|
+ min-height: 100vh;
|
|
|
272
|
+}
|
|
|
273
|
+
|
|
|
274
|
+/* 顶部区域 */
|
|
|
275
|
+.top-section {
|
|
|
276
|
+ display: flex;
|
|
|
277
|
+ justify-content: space-between;
|
|
|
278
|
+ align-items: flex-start;
|
|
|
279
|
+ margin-bottom: 20px;
|
|
|
280
|
+ background-color: white;
|
|
|
281
|
+ padding: 20px;
|
|
|
282
|
+ border-radius: 8px;
|
|
|
283
|
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
284
|
+}
|
|
|
285
|
+
|
|
|
286
|
+.left-section {
|
|
|
287
|
+ display: flex;
|
|
|
288
|
+ flex-direction: column;
|
|
|
289
|
+ gap: 20px;
|
|
|
290
|
+ flex: 1;
|
|
|
291
|
+}
|
|
|
292
|
+
|
|
|
293
|
+.form-item {
|
|
|
294
|
+ display: flex;
|
|
|
295
|
+ align-items: center;
|
|
|
296
|
+ gap: 10px;
|
|
|
297
|
+}
|
|
|
298
|
+
|
|
|
299
|
+.label {
|
|
|
300
|
+ font-size: 14px;
|
|
|
301
|
+ color: #606266;
|
|
|
302
|
+ min-width: 80px;
|
|
|
303
|
+ text-align: right;
|
|
|
304
|
+}
|
|
|
305
|
+
|
|
|
306
|
+.input {
|
|
|
307
|
+ width: 300px;
|
|
|
308
|
+}
|
|
|
309
|
+
|
|
|
310
|
+.select {
|
|
|
311
|
+ width: 300px;
|
|
|
312
|
+}
|
|
|
313
|
+
|
|
|
314
|
+.right-section {
|
|
|
315
|
+ display: flex;
|
|
|
316
|
+ flex-direction: column;
|
|
|
317
|
+ align-items: flex-end;
|
|
|
318
|
+ gap: 15px;
|
|
|
319
|
+}
|
|
|
320
|
+
|
|
|
321
|
+.stats {
|
|
|
322
|
+ display: flex;
|
|
|
323
|
+ align-items: center;
|
|
|
324
|
+ gap: 15px;
|
|
|
325
|
+ font-size: 14px;
|
|
|
326
|
+ color: #303133;
|
|
|
327
|
+}
|
|
|
328
|
+
|
|
|
329
|
+.separator {
|
|
|
330
|
+ color: #dcdfe6;
|
|
|
331
|
+ font-size: 16px;
|
|
|
332
|
+}
|
|
|
333
|
+
|
|
|
334
|
+.save-btn {
|
|
|
335
|
+ width: 100px;
|
|
|
336
|
+}
|
|
|
337
|
+
|
|
|
338
|
+/* 主体区域 */
|
|
|
339
|
+.main-section {
|
|
|
340
|
+ display: flex;
|
|
|
341
|
+ gap: 20px;
|
|
|
342
|
+ background-color: white;
|
|
|
343
|
+ padding: 20px;
|
|
|
344
|
+ border-radius: 8px;
|
|
|
345
|
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
346
|
+}
|
|
|
347
|
+
|
|
|
348
|
+/* 左侧导航 */
|
|
|
349
|
+.left-nav {
|
|
|
350
|
+ width: 250px;
|
|
|
351
|
+ border-right: 1px solid #e6e8eb;
|
|
|
352
|
+ padding-right: 20px;
|
|
|
353
|
+}
|
|
|
354
|
+
|
|
|
355
|
+.nav-title {
|
|
|
356
|
+ font-size: 16px;
|
|
|
357
|
+ font-weight: bold;
|
|
|
358
|
+ margin-bottom: 15px;
|
|
|
359
|
+ color: #303133;
|
|
|
360
|
+}
|
|
|
361
|
+
|
|
|
362
|
+.nav-item {
|
|
|
363
|
+ padding: 10px 15px;
|
|
|
364
|
+ margin-bottom: 10px;
|
|
|
365
|
+ border-radius: 4px;
|
|
|
366
|
+ cursor: pointer;
|
|
|
367
|
+ transition: all 0.3s;
|
|
|
368
|
+ background-color: #f5f7fa;
|
|
|
369
|
+}
|
|
|
370
|
+
|
|
|
371
|
+.nav-item:hover {
|
|
|
372
|
+ background-color: #ecf5ff;
|
|
|
373
|
+ color: #409eff;
|
|
|
374
|
+}
|
|
|
375
|
+
|
|
|
376
|
+.nav-item.active {
|
|
|
377
|
+ background-color: #ecf5ff;
|
|
|
378
|
+ color: #409eff;
|
|
|
379
|
+ border-left: 3px solid #409eff;
|
|
|
380
|
+}
|
|
|
381
|
+
|
|
|
382
|
+.new-question-input {
|
|
|
383
|
+ margin-top: 10px;
|
|
|
384
|
+}
|
|
|
385
|
+
|
|
|
386
|
+/* 右侧内容 */
|
|
|
387
|
+.right-content {
|
|
|
388
|
+ flex: 1;
|
|
|
389
|
+ padding-left: 20px;
|
|
|
390
|
+}
|
|
|
391
|
+
|
|
|
392
|
+/* 题目块 */
|
|
|
393
|
+.question-block {
|
|
|
394
|
+ margin-bottom: 30px;
|
|
|
395
|
+ padding: 20px;
|
|
|
396
|
+ background-color: #fafafa;
|
|
|
397
|
+ border-radius: 8px;
|
|
|
398
|
+}
|
|
|
399
|
+
|
|
|
400
|
+.question-header {
|
|
|
401
|
+ display: flex;
|
|
|
402
|
+ justify-content: space-between;
|
|
|
403
|
+ align-items: center;
|
|
|
404
|
+ margin-bottom: 20px;
|
|
|
405
|
+}
|
|
|
406
|
+
|
|
|
407
|
+.question-title {
|
|
|
408
|
+ font-size: 18px;
|
|
|
409
|
+ font-weight: bold;
|
|
|
410
|
+ color: #303133;
|
|
|
411
|
+}
|
|
|
412
|
+
|
|
|
413
|
+.edit-btn {
|
|
|
414
|
+ color: #409eff;
|
|
|
415
|
+}
|
|
|
416
|
+
|
|
|
417
|
+/* 题目类型区块 */
|
|
|
418
|
+.question-type-section {
|
|
|
419
|
+ margin-bottom: 20px;
|
|
|
420
|
+ padding: 15px;
|
|
|
421
|
+ background-color: white;
|
|
|
422
|
+ border-radius: 6px;
|
|
|
423
|
+}
|
|
|
424
|
+
|
|
|
425
|
+.section-title {
|
|
|
426
|
+ font-size: 16px;
|
|
|
427
|
+ font-weight: bold;
|
|
|
428
|
+ margin-bottom: 15px;
|
|
|
429
|
+ color: #303133;
|
|
|
430
|
+}
|
|
|
431
|
+
|
|
|
432
|
+.add-question-btn {
|
|
|
433
|
+ color: #409eff;
|
|
|
434
|
+ margin-top: 10px;
|
|
|
435
|
+}
|
|
|
436
|
+
|
|
|
437
|
+.question-footer {
|
|
|
438
|
+ text-align: right;
|
|
|
439
|
+ margin-top: 15px;
|
|
|
440
|
+ font-size: 14px;
|
|
|
441
|
+ color: #606266;
|
|
|
442
|
+}
|
|
|
443
|
+
|
|
|
444
|
+.question-score {
|
|
|
445
|
+ font-weight: bold;
|
|
|
446
|
+ color: #303133;
|
|
|
447
|
+}
|
|
|
448
|
+
|
|
|
449
|
+/* 添加大题按钮 */
|
|
|
450
|
+.add-big-question-btn {
|
|
|
451
|
+ width: 100%;
|
|
|
452
|
+ margin-top: 20px;
|
|
|
453
|
+}
|
|
|
454
|
+
|
|
|
455
|
+/* 操作按钮样式 */
|
|
|
456
|
+.preview-btn {
|
|
|
457
|
+ color: #409eff;
|
|
|
458
|
+ margin-right: 10px;
|
|
|
459
|
+}
|
|
|
460
|
+
|
|
|
461
|
+.delete-btn {
|
|
|
462
|
+ color: #f56c6c;
|
|
|
463
|
+}
|
|
|
464
|
+
|
|
|
465
|
+/* 响应式设计 */
|
|
|
466
|
+@media (max-width: 1200px) {
|
|
|
467
|
+ .input,
|
|
|
468
|
+ .select {
|
|
|
469
|
+ width: 250px;
|
|
|
470
|
+ }
|
|
|
471
|
+}
|
|
|
472
|
+
|
|
|
473
|
+@media (max-width: 768px) {
|
|
|
474
|
+ .top-section {
|
|
|
475
|
+ flex-direction: column;
|
|
|
476
|
+ }
|
|
|
477
|
+
|
|
|
478
|
+ .right-section {
|
|
|
479
|
+ align-items: flex-start;
|
|
|
480
|
+ }
|
|
|
481
|
+
|
|
|
482
|
+ .main-section {
|
|
|
483
|
+ flex-direction: column;
|
|
|
484
|
+ }
|
|
|
485
|
+
|
|
|
486
|
+ .left-nav {
|
|
|
487
|
+ width: 100%;
|
|
|
488
|
+ border-right: none;
|
|
|
489
|
+ border-bottom: 1px solid #e6e8eb;
|
|
|
490
|
+ padding-right: 0;
|
|
|
491
|
+ padding-bottom: 20px;
|
|
|
492
|
+ margin-bottom: 20px;
|
|
|
493
|
+ }
|
|
|
494
|
+
|
|
|
495
|
+ .right-content {
|
|
|
496
|
+ padding-left: 0;
|
|
|
497
|
+ }
|
|
|
498
|
+}
|
|
|
499
|
+</style>
|