|
|
@@ -1,69 +1,27 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <back-title>测试详情</back-title>
|
|
|
- <form @submit.prevent="handleSubmit">
|
|
|
- <label>
|
|
|
- 测试名称:
|
|
|
- <input v-model="quiz.name" required placeholder="请输入测试名称" />
|
|
|
- </label>
|
|
|
- <label>
|
|
|
- 测试进行时课件的状态(测试时间):
|
|
|
- <select v-model="quiz.quizTime" required >
|
|
|
- <option value="">请选择测试时间</option>
|
|
|
- <option :key="index" v-for="(item, index) in SlideStateTranslation" :value="index">{{ item }}</option>
|
|
|
- </select>
|
|
|
- </label>
|
|
|
- <div class="mb-16" :key="question.id" v-for="(question, index) in selectedQuestions">
|
|
|
- <div>{{ index + 1 }}.</div>
|
|
|
- <a @click="moveIndexQuestionUp(index)">向上移动</a>
|
|
|
- <a @click="moveIndexQuestionUp(index + 1)">向下移动</a>
|
|
|
- <question-detail-factory :question="question" />
|
|
|
- </div>
|
|
|
- <question-table v-model="selectedQuestions" selectable />
|
|
|
- <button>创建</button>
|
|
|
- </form>
|
|
|
+ <back-title>创建测试</back-title>
|
|
|
+ <quiz-editor @submit="handleSubmit" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { naming as QuestionKindNaming } from '@/server/enums/question-kind'
|
|
|
-import { QuizStateNaming } from '@/server/enums/quiz-state'
|
|
|
-import SlideStateTranslation from '@/server/enums/slide-state-translation'
|
|
|
import BackTitle from '@/components/Basic/BackTitle'
|
|
|
-import QuestionTable from '@/views/quiz/components/QuestionTable'
|
|
|
-import QuestionDetailFactory from '@/views/quiz/components/QuestionDetailFactory'
|
|
|
import { createQuiz } from '@/server/quiz'
|
|
|
+import QuizEditor from '@/views/quiz/components/QuizEditor'
|
|
|
|
|
|
export default {
|
|
|
name: 'CreateQuiz',
|
|
|
- components: { QuestionDetailFactory, QuestionTable, BackTitle },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- quiz: { name: '', quizTime: '', slideId: this.$route.params.slideId },
|
|
|
- selectedQuestions: [],
|
|
|
-
|
|
|
- QuestionKindNaming,
|
|
|
- QuizStateNaming,
|
|
|
- SlideStateTranslation
|
|
|
- }
|
|
|
- },
|
|
|
+ components: { QuizEditor, BackTitle },
|
|
|
methods: {
|
|
|
- handleSubmit() {
|
|
|
- createQuiz({ ...this.quiz, questions: this.selectedQuestions.map(item => item.id) })
|
|
|
+ handleSubmit(quizData) {
|
|
|
+ const { slideId } = this.$route.params
|
|
|
+ createQuiz({ ...quizData, slideId })
|
|
|
.then(() => this.$setSuccessMessage('创建成功'))
|
|
|
.then(() => this.$router.go(-1))
|
|
|
.catch(err =>
|
|
|
this.$setErrorMessage(err.response.data.msg)
|
|
|
)
|
|
|
- },
|
|
|
- moveIndexQuestionUp(index) {
|
|
|
- if (index < this.selectedQuestions.length && index >= 1) {
|
|
|
- const nextQuestions = [...this.selectedQuestions]
|
|
|
- const before = nextQuestions[index - 1]
|
|
|
- nextQuestions[index - 1] = nextQuestions[index]
|
|
|
- nextQuestions[index] = before
|
|
|
- this.selectedQuestions = nextQuestions
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|