|
|
@@ -1,50 +1,138 @@
|
|
|
<template>
|
|
|
<div class="do-recommend-question">
|
|
|
- <back-title>系统推荐</back-title>
|
|
|
- <template v-for="(question, index) in questions">
|
|
|
- <do-quiz-question-card @choice="handleChoice" :key="question.id" :question-prop="question"
|
|
|
- :marked-prop="interactiveMap ? interactiveMap[question.id].marked : false"
|
|
|
- :rate-prop="interactiveMap ? interactiveMap[question.id].rate : 0"
|
|
|
- :index="index"></do-quiz-question-card>
|
|
|
+ <back-title>系统推荐习题</back-title>
|
|
|
+ <div class="vertical-center mb-16" v-if="knowledgeTree">
|
|
|
+ <treeselect
|
|
|
+ v-model="selectedKnowledgeIdList"
|
|
|
+ :multiple="true"
|
|
|
+ :options="knowledgeTree ? knowledgeTree : null"
|
|
|
+ placeholder="选择相关知识点"
|
|
|
+ />
|
|
|
+ <c-button icon="search" theme="green" :left="12">搜索</c-button>
|
|
|
+ </div>
|
|
|
+ <div v-else class="mt-24">知识点加载中...</div>
|
|
|
+ <div class="no-content-warning" v-if="questions === null">
|
|
|
+ 推荐习题加载中...
|
|
|
+ </div>
|
|
|
+ <template v-else>
|
|
|
+ <template v-for="(question, index) in questions">
|
|
|
+ <do-quiz-question-card @choice="handleChoice" :key="question.id" :question-prop="question"
|
|
|
+ :marked-prop="interactiveMap ? interactiveMap[question.id].marked : false"
|
|
|
+ :rate-prop="interactiveMap ? interactiveMap[question.id].rate : 0"
|
|
|
+ :index="index"></do-quiz-question-card>
|
|
|
+ <div :key="'detail-' + question.id">
|
|
|
+ <p class="mb-8" v-if="question.knowledgeId.length">知识点:{{question.knowledgeId.map(_ =>
|
|
|
+ knowledgeNaming[_]).join(',')}}</p>
|
|
|
+ <p class="mb-8" v-if="question.keyPoints">关键字:{{question.keyPoints}}</p>
|
|
|
+ <p class="mb-8" v-if="question.tag">标签:{{question.tag.join(',')}}</p>
|
|
|
+ </div>
|
|
|
+ <show-transition :key="'transition-' + question.id">
|
|
|
+ <div v-if="submitted" class="answer">
|
|
|
+ <p class="mb-8">
|
|
|
+ 答案:{{question.answer}}
|
|
|
+ </p>
|
|
|
+ <p>
|
|
|
+ 解析:{{question.analysis}}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </show-transition>
|
|
|
+ </template>
|
|
|
+ <c-button class="mt-16" :icon="submitted ? 'arrow_forward' : 'check'" theme="green" standout
|
|
|
+ @click="handleSubmit">{{submitted ? '下一题' : '提交答案'}}
|
|
|
+ </c-button>
|
|
|
</template>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import BackTitle from '@/components/Basic/BackTitle'
|
|
|
+import Treeselect from '@riophae/vue-treeselect'
|
|
|
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
|
|
import DoQuizQuestionCard from '@/views/quiz/components/DoQuizQuestionCard'
|
|
|
-import { getInteractiveList, getRecommendationQuestions } from '@/server/question'
|
|
|
+import { getInteractiveList, getRecommendationQuestions, submitAnswerRecord } from '@/server/question'
|
|
|
+import { getKnowledgeNodes } from '@/server/knowledge'
|
|
|
+import { constructTree } from '@/utils/construct-tree'
|
|
|
+import CButton from '@/components/Basic/CButton'
|
|
|
+import ShowTransition from '@/animations/ShowTransition'
|
|
|
|
|
|
export default {
|
|
|
- components: { DoQuizQuestionCard, BackTitle },
|
|
|
+ components: { ShowTransition, CButton, Treeselect, DoQuizQuestionCard, BackTitle },
|
|
|
data () {
|
|
|
return {
|
|
|
- questions: [],
|
|
|
- interactiveMap: null
|
|
|
+ questions: null,
|
|
|
+ knowledgeTree: null,
|
|
|
+ knowledgeNaming: null,
|
|
|
+ interactiveMap: null,
|
|
|
+ selectedKnowledgeIdList: [],
|
|
|
+ submitted: false,
|
|
|
+ startAt: new Date(),
|
|
|
+ endAt: new Date()
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- getRecommendationQuestions({})
|
|
|
+ getKnowledgeNodes()
|
|
|
.then(res => {
|
|
|
- this.questions = res
|
|
|
- getInteractiveList({ questionIdJoinByComma: this.questions.map(_ => _.id).join(',') })
|
|
|
- .then(res => {
|
|
|
- console.log(res)
|
|
|
- if (res) {
|
|
|
- const tempMap = {}
|
|
|
- res.forEach(item => {
|
|
|
- tempMap[item.questionId] = { marked: item.collection, rate: item.rate }
|
|
|
- })
|
|
|
- this.interactiveMap = tempMap
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ this.knowledgeNaming = {}
|
|
|
+ res.forEach(item => {
|
|
|
+ this.knowledgeNaming[item.abbreviation] = item.name
|
|
|
+ })
|
|
|
+ this.knowledgeTree = constructTree(res)
|
|
|
})
|
|
|
.catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ this.getQuestions()
|
|
|
},
|
|
|
methods: {
|
|
|
+ getQuestions () {
|
|
|
+ getRecommendationQuestions({ questionNum: 1 })
|
|
|
+ .then(res => {
|
|
|
+ this.questions = res.map(question => ({
|
|
|
+ ...question,
|
|
|
+ studentAnswer: { answer: '' }
|
|
|
+ }))
|
|
|
+ getInteractiveList({ questionIdJoinByComma: this.questions.map(_ => _.id).join(',') })
|
|
|
+ .then(res => {
|
|
|
+ if (res) {
|
|
|
+ const tempMap = {}
|
|
|
+ res.forEach(item => {
|
|
|
+ tempMap[item.questionId] = { marked: item.collection, rate: item.rate }
|
|
|
+ })
|
|
|
+ this.interactiveMap = tempMap
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ })
|
|
|
+ .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ },
|
|
|
handleChoice () {
|
|
|
-
|
|
|
+ this.endAt = new Date()
|
|
|
+ },
|
|
|
+ handleSubmit () {
|
|
|
+ // ! 目前是每次只有一道题
|
|
|
+ // 如果需要多道题的话这里的开始结束时间做法
|
|
|
+ // 应该需要参考学生做题界面的处理
|
|
|
+ // records 也应该做相应的更改
|
|
|
+ if (this.submitted) {
|
|
|
+ // 点击展示下一题
|
|
|
+ this.getQuestions()
|
|
|
+ this.startAt = new Date()
|
|
|
+ this.submitted = false
|
|
|
+ } else {
|
|
|
+ // 点击上传答案,并显示解析
|
|
|
+ submitAnswerRecord({
|
|
|
+ records: {
|
|
|
+ [this.questions[0].id]: {
|
|
|
+ answer: this.questions[0].studentAnswer.answer,
|
|
|
+ startAt: this.startAt,
|
|
|
+ endAt: this.endAt
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(_ => {
|
|
|
+ this.$setSuccessMessage('提交成功')
|
|
|
+ this.submitted = true
|
|
|
+ })
|
|
|
+ .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -56,4 +144,14 @@ export default {
|
|
|
max-width: 800px;
|
|
|
margin: 0 auto;
|
|
|
}
|
|
|
+
|
|
|
+.do-quiz-question-card {
|
|
|
+ border: none;
|
|
|
+ margin: 0 -16px;
|
|
|
+}
|
|
|
+
|
|
|
+.answer {
|
|
|
+ padding: 12px;
|
|
|
+ border: 1px solid #aabaca;
|
|
|
+}
|
|
|
</style>
|