|
@@ -14,35 +14,21 @@
|
|
|
</div>
|
|
|
<div class="question-answer">
|
|
|
<h4 class="question-answer-title">答案</h4>
|
|
|
- <div class="question-answer-body">
|
|
|
- <div v-if="IS_SELECTION">
|
|
|
- {{ quesAnswer | selectionAnswerFilter }}
|
|
|
- </div>
|
|
|
- <div v-else-if="IS_BOOL_ANSWER_QUESTION">
|
|
|
- {{ quesAnswer ? "对" : "错" }}
|
|
|
- </div>
|
|
|
- <div v-else-if="IS_FILL_BLANK_QUESTION || IS_TEXT_ANSWER_QUESTION">
|
|
|
- <rich-text
|
|
|
- v-for="(cont, cindex) in textQuesAnswer"
|
|
|
- :key="cindex"
|
|
|
- :text-json="cont"
|
|
|
- ></rich-text>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <question-answer
|
|
|
+ class="question-answer-body"
|
|
|
+ :data="question"
|
|
|
+ ></question-answer>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { deepCopy } from "@/plugins/utils";
|
|
|
+import QuestionAnswer from "./QuestionAnswer.vue";
|
|
|
|
|
|
export default {
|
|
|
name: "QuestionBasePreview",
|
|
|
- filters: {
|
|
|
- selectionAnswerFilter(val) {
|
|
|
- return val.map((value) => String.fromCharCode(64 + value)).join("");
|
|
|
- },
|
|
|
- },
|
|
|
+ components: { QuestionAnswer },
|
|
|
props: {
|
|
|
question: {
|
|
|
type: Object,
|
|
@@ -63,23 +49,6 @@ export default {
|
|
|
quesOptions: [],
|
|
|
};
|
|
|
},
|
|
|
- computed: {
|
|
|
- IS_FILL_BLANK_QUESTION() {
|
|
|
- return this.question.questionType === "FILL_BLANK_QUESTION";
|
|
|
- },
|
|
|
- IS_SELECTION() {
|
|
|
- return (
|
|
|
- this.question.questionType === "SINGLE_ANSWER_QUESTION" ||
|
|
|
- this.question.questionType === "MULTIPLE_ANSWER_QUESTION"
|
|
|
- );
|
|
|
- },
|
|
|
- IS_TEXT_ANSWER_QUESTION() {
|
|
|
- return this.question.questionType === "TEXT_ANSWER_QUESTION";
|
|
|
- },
|
|
|
- IS_BOOL_ANSWER_QUESTION() {
|
|
|
- return this.question.questionType === "BOOL_ANSWER_QUESTION";
|
|
|
- },
|
|
|
- },
|
|
|
created() {
|
|
|
this.initData();
|
|
|
},
|
|
@@ -118,36 +87,6 @@ export default {
|
|
|
});
|
|
|
this.quesOptions = quesOptions;
|
|
|
}
|
|
|
-
|
|
|
- if (!this.question.quesAnswer) return;
|
|
|
- this.quesAnswer = JSON.parse(this.question.quesAnswer);
|
|
|
-
|
|
|
- if (this.IS_FILL_BLANK_QUESTION) {
|
|
|
- this.textQuesAnswer = this.quesAnswer.map((item) => {
|
|
|
- let nitem = deepCopy(item);
|
|
|
- if (!nitem.sections || !nitem.sections.length) {
|
|
|
- nitem.sections = [
|
|
|
- {
|
|
|
- blocks: [
|
|
|
- {
|
|
|
- type: "text",
|
|
|
- value: `(${item.index + 1})`,
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ];
|
|
|
- } else {
|
|
|
- nitem.sections[0].blocks.unshift({
|
|
|
- type: "text",
|
|
|
- value: `(${item.index + 1})`,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return nitem;
|
|
|
- });
|
|
|
- } else if (this.IS_TEXT_ANSWER_QUESTION) {
|
|
|
- this.textQuesAnswer = this.quesAnswer;
|
|
|
- }
|
|
|
},
|
|
|
},
|
|
|
};
|