|
@@ -10,14 +10,27 @@
|
|
|
<div class="container">
|
|
|
<div class="articel" v-html="sanitizeHTML(data.article)"></div>
|
|
|
<div class="question-list">
|
|
|
- <component
|
|
|
- :is="previewComponents[item.type]"
|
|
|
- v-for="(item, i) in childPreviewData"
|
|
|
- :key="i"
|
|
|
- class="preview"
|
|
|
- :data="item"
|
|
|
- @change="changeAnswer(i, item.type, $event)"
|
|
|
- />
|
|
|
+ <div v-if="isAnswer">
|
|
|
+ <component
|
|
|
+ :is="previewComponents[item.type]"
|
|
|
+ v-for="(item, i) in question_list"
|
|
|
+ :key="i"
|
|
|
+ class="preview"
|
|
|
+ :data="item"
|
|
|
+ :answer="answer.question_list[i]"
|
|
|
+ @change="changeAnswer(i, item.type, $event)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <component
|
|
|
+ :is="previewComponents[item.type]"
|
|
|
+ v-for="(item, i) in childPreviewData"
|
|
|
+ :key="i"
|
|
|
+ class="preview"
|
|
|
+ :data="item"
|
|
|
+ @change="changeAnswer(i, item.type, $event)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -31,6 +44,8 @@ import MatchingPreview from '@/views/exercise_questions/preview/MatchingPreview.
|
|
|
import FillPreview from '../preview/FillPreview.vue';
|
|
|
import ShortAnswerPreview from './ShortAnswerPreview.vue';
|
|
|
|
|
|
+import { GetQuestionInfo } from '@/api/exercise';
|
|
|
+
|
|
|
export default {
|
|
|
name: 'ReadPreview',
|
|
|
mixins: [PreviewMixin],
|
|
@@ -49,8 +64,27 @@ export default {
|
|
|
fill: FillPreview,
|
|
|
short_answer: ShortAnswerPreview,
|
|
|
},
|
|
|
+ question_list: [],
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ // 是否答题
|
|
|
+ isAnswer() {
|
|
|
+ return this.childPreviewData.length === 0 && this.childPreviewData.length !== this.data.question_list;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ isAnswer: {
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ this.data.question_list.forEach(({ id }, i) => {
|
|
|
+ this.getQuestionInfo(id, i);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
created() {
|
|
|
this.$set(
|
|
|
this.answer,
|
|
@@ -65,6 +99,14 @@ export default {
|
|
|
this.data.question_list[i].answer_list = answer_list;
|
|
|
this.data.question_list[i].type = type;
|
|
|
},
|
|
|
+ getQuestionInfo(question_id, i) {
|
|
|
+ GetQuestionInfo({ question_id })
|
|
|
+ .then(({ question }) => {
|
|
|
+ if (!question.content) return;
|
|
|
+ this.$set(this.question_list, i, JSON.parse(question.content));
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|