|
@@ -28,7 +28,7 @@
|
|
|
@setUp="setUp"
|
|
|
@setPreview="setPreview"
|
|
|
@deleteQuestion="deleteQuestion"
|
|
|
- @addQuestionToExercise="addQuestionToExercise"
|
|
|
+ @createNewQuestion="createNewQuestion"
|
|
|
/>
|
|
|
|
|
|
<div class="preview">
|
|
@@ -36,7 +36,7 @@
|
|
|
<span class="quick-preview">快捷预览:</span>
|
|
|
<div class="preview-right">
|
|
|
<template v-if="preview">
|
|
|
- <span class="preview-button plain" @click="getPreviewData">
|
|
|
+ <span class="preview-button plain" @click="refreshPreviewData">
|
|
|
<SvgIcon icon-class="loop" size="14" /><span>刷新</span>
|
|
|
</span>
|
|
|
<span class="preview-button"><SvgIcon icon-class="eye" /><span>完整预览</span></span>
|
|
@@ -120,17 +120,16 @@ export default {
|
|
|
},
|
|
|
/**
|
|
|
* 添加题目到练习
|
|
|
- * @param {string} type
|
|
|
- * @param {string} additional_type
|
|
|
+ * @param {string} type 题目类型
|
|
|
+ * @param {string} additional_type 附加类型
|
|
|
+ * @param {string} content 题目内容
|
|
|
*/
|
|
|
- addQuestionToExercise(type, additional_type) {
|
|
|
+ addQuestionToExercise(type, additional_type, content = '') {
|
|
|
AddQuestionToExercise({
|
|
|
exercise_id: this.id,
|
|
|
type,
|
|
|
additional_type,
|
|
|
- content: '',
|
|
|
- file_id_list: [],
|
|
|
- answer: '{}',
|
|
|
+ content,
|
|
|
})
|
|
|
.then(() => {
|
|
|
this.getExerciseQuestionIndexList();
|
|
@@ -139,6 +138,11 @@ export default {
|
|
|
this.$message.error('添加失败');
|
|
|
});
|
|
|
},
|
|
|
+ // 创建新题
|
|
|
+ createNewQuestion() {
|
|
|
+ let { type, additional_type } = this.index_list[this.curIndex];
|
|
|
+ this.addQuestionToExercise(type, additional_type);
|
|
|
+ },
|
|
|
/**
|
|
|
* 获取练习题目索引列表
|
|
|
*/
|
|
@@ -167,20 +171,31 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
/**
|
|
|
* 复制练习
|
|
|
* @param {Number} index 练习索引
|
|
|
*/
|
|
|
copy(index) {
|
|
|
- // TODO
|
|
|
+ this.$confirm('是否复制当前题目', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ GetQuestionInfo({ question_id: this.index_list[index].id }).then(
|
|
|
+ ({ question: { type, additional_type, content } }) => {
|
|
|
+ this.addQuestionToExercise(type, additional_type, content);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
/**
|
|
|
* 选择练习
|
|
|
* @param {Number} index 练习索引
|
|
|
+ * @param {Object} data 练习数据
|
|
|
*/
|
|
|
selectExerciseItem(index, data) {
|
|
|
if (index < 0 || index > this.index_list.length - 1) return;
|
|
@@ -191,13 +206,14 @@ export default {
|
|
|
setUp() {
|
|
|
this.isSetUp = !this.isSetUp;
|
|
|
},
|
|
|
- getPreviewData() {
|
|
|
+ // 刷新预览数据
|
|
|
+ refreshPreviewData() {
|
|
|
this.previewData = this.$refs.createMain.$refs.exercise?.[0].data || {};
|
|
|
},
|
|
|
// 预览
|
|
|
setPreview() {
|
|
|
this.preview = !this.preview;
|
|
|
- this.getPreviewData();
|
|
|
+ this.refreshPreviewData();
|
|
|
},
|
|
|
// 删除练习
|
|
|
deleteQuestion() {
|