|
@@ -8,19 +8,20 @@
|
|
|
append-to-body
|
|
|
fullscreen
|
|
|
@opened="dialogOpened"
|
|
|
+ @close="dialogClose"
|
|
|
>
|
|
|
<div slot="title">
|
|
|
- <div>
|
|
|
- <h2>智能出题</h2>
|
|
|
- <span>课程代码:{{ formModel.courseCode }}</span>
|
|
|
- <span>课程名称:{{ formModel.courseName }}</span>
|
|
|
- </div>
|
|
|
+ <h2>
|
|
|
+ 智能出题 --<span
|
|
|
+ >{{ formModel.courseName }}({{ formModel.courseCode }})</span
|
|
|
+ >
|
|
|
+ </h2>
|
|
|
</div>
|
|
|
|
|
|
<div class="part-box">
|
|
|
<h2 class="part-box-title">生成试题</h2>
|
|
|
|
|
|
- <el-form :model="formModel" label-width="100px">
|
|
|
+ <el-form class="margin-top-20" :model="formModel" label-width="100px">
|
|
|
<el-form-item label="题型">
|
|
|
<el-button
|
|
|
v-for="item in BASE_QUESTION_TYPES"
|
|
@@ -33,7 +34,7 @@
|
|
|
>{{ item.name }}</el-button
|
|
|
>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="出题数量">
|
|
|
+ <el-form-item class="inline-top" label="出题数量">
|
|
|
<el-input-number
|
|
|
v-model="formModel.questionCount"
|
|
|
placeholder="出题数量"
|
|
@@ -45,7 +46,11 @@
|
|
|
:controls="false"
|
|
|
></el-input-number>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="IS_SELECTION_QUESTION" label="选项个数">
|
|
|
+ <el-form-item
|
|
|
+ v-if="IS_SELECTION_QUESTION"
|
|
|
+ class="inline-top"
|
|
|
+ label="选项个数"
|
|
|
+ >
|
|
|
<el-input-number
|
|
|
v-model="formModel.optionCount"
|
|
|
placeholder="选项个数"
|
|
@@ -57,9 +62,13 @@
|
|
|
:controls="false"
|
|
|
></el-input-number>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="IS_BOOLEAN_QUESTION" label="填空个数">
|
|
|
+ <el-form-item
|
|
|
+ v-if="IS_FILL_QUESTION"
|
|
|
+ class="inline-top"
|
|
|
+ label="填空个数"
|
|
|
+ >
|
|
|
<el-input-number
|
|
|
- v-model="formModel.fillCount"
|
|
|
+ v-model="formModel.blankCount"
|
|
|
placeholder="填空个数"
|
|
|
style="width: 150px"
|
|
|
:min="1"
|
|
@@ -71,27 +80,33 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="知识点">
|
|
|
<property-tree-select
|
|
|
- v-model="formModel.questionProperty"
|
|
|
+ ref="PropertyTreeSelect"
|
|
|
+ class="width-full"
|
|
|
+ v-model="formModel.propertyIdList"
|
|
|
:course-id="formModel.courseId"
|
|
|
- @change="propertyChange"
|
|
|
></property-tree-select>
|
|
|
<br />
|
|
|
<el-input
|
|
|
- v-model="formModel.supplement"
|
|
|
+ class="padding-top-6"
|
|
|
+ v-model="formModel.knowledgeNotes"
|
|
|
placeholder="请录入知识点补充说明"
|
|
|
type="textarea"
|
|
|
clearable
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
- <el-form-item>
|
|
|
- <el-button type="danger" @click="toProduct">生成试题</el-button>
|
|
|
+ <el-form-item style="margin: 0">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :loading="hasTaskRunning || loading"
|
|
|
+ @click="toProduct"
|
|
|
+ >生成试题</el-button
|
|
|
+ >
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
|
|
|
<div class="part-box">
|
|
|
- <div class="box-justify">
|
|
|
+ <div class="part-box-header">
|
|
|
<h2 class="part-box-title">检查试题</h2>
|
|
|
<div>
|
|
|
<el-button
|
|
@@ -129,12 +144,12 @@
|
|
|
></rich-text>
|
|
|
</div>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="课程" width="120">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span>{{ scope.row.course.name }}</span>
|
|
|
- </template>
|
|
|
+ <el-table-column label="题型" prop="questionType" width="100">
|
|
|
+ <span slot-scope="scope">
|
|
|
+ {{ scope.row.questionType | questionTypeFilter }}
|
|
|
+ </span>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="题型" prop="sourceDetailName" width="100">
|
|
|
+ <el-table-column label="生成时间" prop="creationTime" width="170">
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" width="180" fixed="right">
|
|
|
<template slot-scope="scope">
|
|
@@ -175,7 +190,6 @@
|
|
|
<!-- GptQuestionEditDialog -->
|
|
|
<gpt-question-edit-dialog
|
|
|
ref="GptQuestionEditDialog"
|
|
|
- :option-info="{ ...searchFormModel, propertyInfos }"
|
|
|
:question="curQuestion"
|
|
|
@modified="getList"
|
|
|
></gpt-question-edit-dialog>
|
|
@@ -191,26 +205,38 @@ import {
|
|
|
gptQuestionListApi,
|
|
|
saveGptQuestionApi,
|
|
|
deleteGptQuestionApi,
|
|
|
+ gptTaskDetailApi,
|
|
|
} from "../api";
|
|
|
+import timeMixin from "@/mixins/timeMixin";
|
|
|
|
|
|
const initFormModel = {
|
|
|
courseId: null,
|
|
|
courseCode: "",
|
|
|
courseName: "",
|
|
|
questionType: "SINGLE_ANSWER_QUESTION",
|
|
|
- questionCount: null,
|
|
|
- optionCount: null,
|
|
|
- fillCount: null,
|
|
|
- questionProperty: [],
|
|
|
- supplement: "",
|
|
|
+ questionCount: 1,
|
|
|
+ optionCount: 4,
|
|
|
+ blankCount: 1,
|
|
|
+ propertyIdList: [],
|
|
|
+ knowledgeNotes: "",
|
|
|
};
|
|
|
|
|
|
export default {
|
|
|
name: "GptQuestionDialog",
|
|
|
components: { PropertyTreeSelect, GptQuestionEditDialog },
|
|
|
+ mixins: [timeMixin],
|
|
|
+ props: {
|
|
|
+ course: {
|
|
|
+ type: Object,
|
|
|
+ default() {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- taskId: null,
|
|
|
+ curTaskId: null,
|
|
|
+ hasTaskRunning: false,
|
|
|
formModel: {
|
|
|
...initFormModel,
|
|
|
},
|
|
@@ -233,15 +259,64 @@ export default {
|
|
|
this.formModel.questionType
|
|
|
);
|
|
|
},
|
|
|
- IS_BOOLEAN_QUESTION() {
|
|
|
- return this.formModel.questionType === "BOOL_ANSWER_QUESTION";
|
|
|
- },
|
|
|
IS_FILL_QUESTION() {
|
|
|
return this.formModel.questionType === "FILL_BLANK_QUESTION";
|
|
|
},
|
|
|
},
|
|
|
+ beforeDestroy() {
|
|
|
+ this.clearSetTs();
|
|
|
+ },
|
|
|
methods: {
|
|
|
- dialogOpened() {},
|
|
|
+ dialogOpened() {
|
|
|
+ this.formModel = this.$objAssign(initFormModel, this.course);
|
|
|
+ this.checkTaskStatus(true);
|
|
|
+ },
|
|
|
+ dialogClose() {
|
|
|
+ this.resetData();
|
|
|
+ this.clearSetTs();
|
|
|
+ },
|
|
|
+ resetData() {
|
|
|
+ this.questionList = [];
|
|
|
+ this.selectedQuestionIds = [];
|
|
|
+ this.propertyInfos = [];
|
|
|
+ this.curQuestion = {};
|
|
|
+ this.searchFormModel = {};
|
|
|
+ this.formModel = { ...initFormModel };
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.modalIsShow = false;
|
|
|
+ },
|
|
|
+ open() {
|
|
|
+ this.modalIsShow = true;
|
|
|
+ },
|
|
|
+ async checkTaskStatus(isReview) {
|
|
|
+ this.clearSetTs();
|
|
|
+
|
|
|
+ const res = await gptTaskDetailApi({
|
|
|
+ courseId: this.course.courseId,
|
|
|
+ taskId: this.curTaskId,
|
|
|
+ }).catch(() => {});
|
|
|
+ if (!res || !res.data) return;
|
|
|
+
|
|
|
+ this.curTaskId = res.data.id;
|
|
|
+
|
|
|
+ if (res.data.status === "FAILED") {
|
|
|
+ this.hasTaskRunning = false;
|
|
|
+ if (!isReview) this.$message.error("出题失败,请重新尝试!");
|
|
|
+ this.toPage(1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.data.status === "FINISH") {
|
|
|
+ this.hasTaskRunning = false;
|
|
|
+ if (!isReview) this.$message.success("出题成功!");
|
|
|
+ this.toPage(1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.hasTaskRunning = res.data.status === "RUNNING";
|
|
|
+ this.addSetTime(() => {
|
|
|
+ this.checkTaskStatus();
|
|
|
+ }, 3 * 1000);
|
|
|
+ },
|
|
|
async toProduct() {
|
|
|
this.loading = true;
|
|
|
|
|
@@ -251,23 +326,23 @@ export default {
|
|
|
this.loading = false;
|
|
|
if (!res) return;
|
|
|
|
|
|
+ this.curTaskId = res.data;
|
|
|
this.searchFormModel = { ...this.formModel };
|
|
|
- this.taskId = res.data;
|
|
|
- this.toPage(1);
|
|
|
+
|
|
|
+ this.hasTaskRunning = true;
|
|
|
+ this.addSetTime(() => {
|
|
|
+ this.checkTaskStatus();
|
|
|
+ }, 3 * 1000);
|
|
|
},
|
|
|
toPage(page) {
|
|
|
this.currentPage = page;
|
|
|
this.getList();
|
|
|
},
|
|
|
async getList() {
|
|
|
- // this.selectedQuestionIds = [];
|
|
|
- // this.questionList = this.questions.slice(
|
|
|
- // (this.currentPage - 1) * this.pageSize,
|
|
|
- // this.currentPage * this.pageSize
|
|
|
- // );
|
|
|
+ this.selectedQuestionIds = [];
|
|
|
let data = {
|
|
|
- taskId: this.taskId,
|
|
|
- pageNumber: this.currentPage,
|
|
|
+ courseId: this.course.courseId,
|
|
|
+ curPage: this.currentPage,
|
|
|
pageSize: this.pageSize,
|
|
|
};
|
|
|
const res = await gptQuestionListApi(data).catch(() => {});
|
|
@@ -284,26 +359,25 @@ export default {
|
|
|
this.selectedQuestionIds = selections.map((item) => item.id);
|
|
|
},
|
|
|
switchQuestionType(questionType) {
|
|
|
- this.questionModel.questionType = questionType;
|
|
|
+ this.formModel.questionType = questionType;
|
|
|
this.$nextTick(() => {
|
|
|
this.questionTypeChange();
|
|
|
});
|
|
|
},
|
|
|
questionTypeChange() {
|
|
|
if (this.IS_FILL_QUESTION) {
|
|
|
- this.questionModel.optionCount = null;
|
|
|
+ this.formModel.optionCount = null;
|
|
|
} else if (this.IS_SELECTION_QUESTION) {
|
|
|
- this.questionModel.fillCount = null;
|
|
|
+ this.formModel.blankCount = null;
|
|
|
} else {
|
|
|
- this.questionModel.optionCount = null;
|
|
|
- this.questionModel.fillCount = null;
|
|
|
+ this.formModel.optionCount = null;
|
|
|
+ this.formModel.blankCount = null;
|
|
|
}
|
|
|
},
|
|
|
- propertyChange(propertyInfos) {
|
|
|
- this.propertyInfos = propertyInfos;
|
|
|
- },
|
|
|
toEditQuestion(row) {
|
|
|
- this.curQuestion = row;
|
|
|
+ const propertyInfos =
|
|
|
+ this.$refs.PropertyTreeSelect.getCheckedPropertyInfos(row.propertyIds);
|
|
|
+ this.curQuestion = { ...row, ...this.course, propertyInfos };
|
|
|
this.$refs.GptQuestionEditDialog.open();
|
|
|
},
|
|
|
async toDeleteQuestion(row) {
|
|
@@ -327,12 +401,6 @@ export default {
|
|
|
this.deleteQuestion(this.selectedQuestionIds);
|
|
|
},
|
|
|
async deleteQuestion(ids) {
|
|
|
- // this.questions = this.questions.filter((q) => !ids.includes(q.id));
|
|
|
- // this.total = this.questions.length;
|
|
|
- // const maxPage = Math.ceil(this.total / this.pageSize);
|
|
|
- // this.currentPage = Math.min(maxPage, this.currentPage);
|
|
|
- // this.toPage(this.currentPage);
|
|
|
-
|
|
|
this.loading = true;
|
|
|
const res = await deleteGptQuestionApi(ids.join()).catch(() => {});
|
|
|
this.loading = false;
|
|
@@ -348,7 +416,7 @@ export default {
|
|
|
if (this.loading) return;
|
|
|
|
|
|
if (!this.selectedQuestionIds.length) {
|
|
|
- this.$message.error("请选择需要删除的试题!");
|
|
|
+ this.$message.error("请选择需要保存的试题!");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -359,15 +427,16 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (this.loading) return;
|
|
|
this.loading = true;
|
|
|
- const datas = {
|
|
|
- questions: this.selectedQuestionIds,
|
|
|
- };
|
|
|
- const res = await saveGptQuestionApi(datas).catch(() => {});
|
|
|
+ const res = await saveGptQuestionApi(
|
|
|
+ this.selectedQuestionIds.join()
|
|
|
+ ).catch(() => {});
|
|
|
this.loading = false;
|
|
|
if (!res) return;
|
|
|
this.$message.success("保存成功!");
|
|
|
- this.deleteQuestion(this.selectedQuestionIds);
|
|
|
+ this.getList();
|
|
|
+ this.$emit("modified");
|
|
|
},
|
|
|
},
|
|
|
};
|