|
@@ -63,17 +63,39 @@ function keyup(e: KeyboardEvent) {
|
|
.includes(e.code)
|
|
.includes(e.code)
|
|
) {
|
|
) {
|
|
_hmt.push(["_trackEvent", "答题页面", "快捷键", "ABCDE"]);
|
|
_hmt.push(["_trackEvent", "答题页面", "快捷键", "ABCDE"]);
|
|
- logger({ cnl: ["server"], act: "选择题键盘作答" });
|
|
|
|
|
|
+ logger({ cnl: ["server"], lvl: "debug", act: "选择题键盘作答" });
|
|
const keyAns = newQuestionOptions.find((v) => v.name == e.code[3]);
|
|
const keyAns = newQuestionOptions.find((v) => v.name == e.code[3]);
|
|
- if (keyAns) examQuestion.studentAnswer = keyAns.oldIndex;
|
|
|
|
|
|
+ if (keyAns) {
|
|
|
|
+ answerQuestion(keyAns.oldIndex);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function answerQuestion(studentAnswer: string) {
|
|
function answerQuestion(studentAnswer: string) {
|
|
- if (studentAnswer !== examQuestion.studentAnswer) {
|
|
|
|
- store.updateExamQuestion({ order: examQuestion.order, studentAnswer });
|
|
|
|
|
|
+ if (examQuestion.questionType === "SINGLE_CHOICE") {
|
|
|
|
+ examQuestion.studentAnswer = studentAnswer;
|
|
|
|
+ } else {
|
|
|
|
+ // 多选题
|
|
|
|
+ const oldAns = examQuestion.studentAnswer;
|
|
|
|
+ if (oldAns) {
|
|
|
|
+ if (oldAns.includes(studentAnswer)) {
|
|
|
|
+ examQuestion.studentAnswer = oldAns.replace(studentAnswer, "");
|
|
|
|
+ } else {
|
|
|
|
+ examQuestion.studentAnswer = oldAns
|
|
|
|
+ .concat(studentAnswer)
|
|
|
|
+ .split("")
|
|
|
|
+ .sort()
|
|
|
|
+ .join("");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ examQuestion.studentAnswer = studentAnswer;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ store.updateExamQuestion({
|
|
|
|
+ order: examQuestion.order,
|
|
|
|
+ studentAnswer: examQuestion.studentAnswer,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
function toggleShowAnswer() {
|
|
function toggleShowAnswer() {
|
|
isShowAnswer = !isShowAnswer;
|
|
isShowAnswer = !isShowAnswer;
|
|
@@ -81,10 +103,7 @@ function toggleShowAnswer() {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <div
|
|
|
|
- v-if="examQuestion.questionType === 'SINGLE_CHOICE'"
|
|
|
|
- class="question-view"
|
|
|
|
- >
|
|
|
|
|
|
+ <div class="question-view">
|
|
<question-body :questionBody="examQuestion.body" />
|
|
<question-body :questionBody="examQuestion.body" />
|
|
<div class="ops">
|
|
<div class="ops">
|
|
<div class="stu-answer">{{ oldIndexToABCD }}</div>
|
|
<div class="stu-answer">{{ oldIndexToABCD }}</div>
|
|
@@ -98,25 +117,26 @@ function toggleShowAnswer() {
|
|
>
|
|
>
|
|
<div
|
|
<div
|
|
:class="
|
|
:class="
|
|
- examQuestion.studentAnswer === option.oldIndex && 'row-selected'
|
|
|
|
|
|
+ examQuestion.studentAnswer?.includes(option.oldIndex) &&
|
|
|
|
+ 'row-selected'
|
|
"
|
|
"
|
|
- style="display: flex"
|
|
|
|
|
|
+ class="tw-flex tw-items-start"
|
|
>
|
|
>
|
|
<div>
|
|
<div>
|
|
<input
|
|
<input
|
|
- type="radio"
|
|
|
|
|
|
+ :type="
|
|
|
|
+ examQuestion.questionType === 'SINGLE_CHOICE'
|
|
|
|
+ ? 'radio'
|
|
|
|
+ : 'checkbox'
|
|
|
|
+ "
|
|
name="question"
|
|
name="question"
|
|
:value="option.oldIndex"
|
|
:value="option.oldIndex"
|
|
- :checked="examQuestion.studentAnswer === option.oldIndex"
|
|
|
|
- style="margin-top: 3px; display: block"
|
|
|
|
|
|
+ :checked="examQuestion.studentAnswer?.includes(option.oldIndex)"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
<span style="padding: 0 10px">{{ optionName[index] }}: </span>
|
|
<span style="padding: 0 10px">{{ optionName[index] }}: </span>
|
|
<div v-if="option.value" class="question-options">
|
|
<div v-if="option.value" class="question-options">
|
|
- <question-body
|
|
|
|
- :questionBody="option.value.body"
|
|
|
|
- :examQuestion="examQuestion"
|
|
|
|
- />
|
|
|
|
|
|
+ <question-body :questionBody="option.value.body" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|