|
@@ -68,7 +68,7 @@ import { getStudentAnswerJSON } from "@/api/jsonMark";
|
|
|
import { store } from "@/store/store";
|
|
|
import { onUpdated, watch } from "vue";
|
|
|
import { renderRichText } from "@/utils/renderJSON";
|
|
|
-import type { RichTextJSON } from "@/types";
|
|
|
+import type { RichTextJSON, QuestionForRender } from "@/types";
|
|
|
import "viewerjs/dist/viewer.css";
|
|
|
import Viewer from "viewerjs";
|
|
|
import { useRoute } from "vue-router";
|
|
@@ -78,18 +78,6 @@ const isSeePaper = route.name === "StudentTrack";
|
|
|
const showScore = (question: QuestionForRender) =>
|
|
|
route.name !== "Mark" && question.totalScore;
|
|
|
|
|
|
-interface QuestionForRender {
|
|
|
- unionOrder: string;
|
|
|
- parentBody: RichTextJSON | null;
|
|
|
- body: RichTextJSON;
|
|
|
- studentAnswer: Array<RichTextJSON> | null;
|
|
|
- standardAnswer: Array<RichTextJSON> | null;
|
|
|
- score: number | null;
|
|
|
- totalScore: number;
|
|
|
- objective: boolean | null;
|
|
|
- options: Array<{ number: number; body: RichTextJSON }>;
|
|
|
-}
|
|
|
-
|
|
|
let questions: QuestionForRender[] = $ref([]);
|
|
|
async function updateStudentAnswerJSON() {
|
|
|
return getStudentAnswerJSON(store.currentTask?.jsonUrl as string);
|
|
@@ -124,8 +112,6 @@ watch(
|
|
|
// 查看原卷显示全部题目
|
|
|
if (isSeePaper) {
|
|
|
for (const questionBody of store.setting.subject.questions || []) {
|
|
|
- const questionForRender = {} as QuestionForRender;
|
|
|
-
|
|
|
const [mainNumber, subNumber] = questionBody.unionOrder.split("-");
|
|
|
const stuAns = stuAnswers.find(
|
|
|
(v) =>
|
|
@@ -144,22 +130,20 @@ watch(
|
|
|
(v) =>
|
|
|
[v.mainNumber, v.subNumber].join("-") === questionBody.unionOrder
|
|
|
);
|
|
|
-
|
|
|
- questionForRender.unionOrder = questionBody.unionOrder;
|
|
|
- questionForRender.parentBody = questionBody.parentBody;
|
|
|
- questionForRender.body = questionBody.body;
|
|
|
- questionForRender.options = questionBody.options;
|
|
|
- questionForRender.objective = questionBody.objective;
|
|
|
- questionForRender.standardAnswer = questionBody.answer;
|
|
|
- questionForRender.studentAnswer = stuAns.answer;
|
|
|
- questionForRender.score = taskQuestion?.score ?? null;
|
|
|
- questionForRender.totalScore = taskQuestion?.maxScore || 0;
|
|
|
- questions.push(questionForRender);
|
|
|
+ questions.push({
|
|
|
+ unionOrder: questionBody.unionOrder,
|
|
|
+ parentBody: questionBody.parentBody,
|
|
|
+ body: questionBody.body,
|
|
|
+ options: questionBody.options,
|
|
|
+ objective: questionBody.objective,
|
|
|
+ standardAnswer: questionBody.answer,
|
|
|
+ studentAnswer: stuAns.answer,
|
|
|
+ score: taskQuestion?.score ?? null,
|
|
|
+ totalScore: taskQuestion?.maxScore || 0,
|
|
|
+ });
|
|
|
}
|
|
|
} else {
|
|
|
for (const taskQuestion of store.currentTask?.questionList || []) {
|
|
|
- const questionForRender = {} as QuestionForRender;
|
|
|
-
|
|
|
const { mainNumber, subNumber } = taskQuestion;
|
|
|
const questionBody = store.setting.subject.questions.find(
|
|
|
(ques) => ques.unionOrder === `${mainNumber}-${subNumber}`
|
|
@@ -180,14 +164,17 @@ watch(
|
|
|
answer: [],
|
|
|
};
|
|
|
|
|
|
- questionForRender.unionOrder = questionBody.unionOrder;
|
|
|
- questionForRender.parentBody = questionBody.parentBody;
|
|
|
- questionForRender.body = questionBody.body;
|
|
|
- questionForRender.standardAnswer = questionBody.answer;
|
|
|
- questionForRender.studentAnswer = stuAns.answer;
|
|
|
- questionForRender.score = taskQuestion.score;
|
|
|
- questionForRender.totalScore = taskQuestion.maxScore;
|
|
|
- questions.push(questionForRender);
|
|
|
+ questions.push({
|
|
|
+ unionOrder: questionBody.unionOrder,
|
|
|
+ parentBody: questionBody.parentBody,
|
|
|
+ body: questionBody.body,
|
|
|
+ options: questionBody.options,
|
|
|
+ objective: questionBody.objective,
|
|
|
+ standardAnswer: questionBody.answer,
|
|
|
+ studentAnswer: stuAns.answer,
|
|
|
+ score: taskQuestion.score,
|
|
|
+ totalScore: taskQuestion.maxScore,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -195,7 +182,7 @@ watch(
|
|
|
);
|
|
|
|
|
|
const indexToABCD = (index: number) => "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[index - 1];
|
|
|
-const renderObjective = (ans: any) => {
|
|
|
+const renderObjective = (ans: QuestionForRender["studentAnswer"]) => {
|
|
|
if (typeof ans === "boolean") {
|
|
|
return ans ? "A" : "B";
|
|
|
} else if (Array.isArray(ans) && typeof ans[0] === "boolean") {
|
|
@@ -213,7 +200,7 @@ let viewer: Viewer = null as unknown as Viewer;
|
|
|
onUpdated(() => {
|
|
|
viewer && viewer.destroy();
|
|
|
viewer = new Viewer(
|
|
|
- document.querySelector(".rich-text-question-container") as HTMLElement,
|
|
|
+ document.querySelector<HTMLElement>(".rich-text-question-container")!,
|
|
|
// document.querySelector("#app") as HTMLElement,
|
|
|
{
|
|
|
// inline: true,
|