123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- <template>
- <div
- v-if="markStore.currentTask"
- :key="markStore.currentTask?.secretNumber || 0"
- class="mark-board-track is-key-board"
- :class="[
- markStore.isTrackMode && markStore.isScoreBoardCollapsed
- ? 'hide'
- : 'show',
- ]"
- >
- <div class="board-mode">
- <a-select
- v-model:value="normalMode"
- style="width: 120px"
- @change="normalModeChange"
- >
- <a-select-option value="keyboard">键盘给分</a-select-option>
- <a-select-option value="mouse">鼠标给分</a-select-option>
- </a-select>
- </div>
- <div class="board-header">
- <div class="board-header-left">
- <div class="board-header-info">
- <img src="@/assets/icons/icon-star.svg" />
- <span>总分</span>
- </div>
- <div class="board-header-score">
- <transition-group name="score-number-animation" tag="span">
- <span :key="markStore.currentTask.markResult?.markerScore || 0">{{
- markStore.currentTask.markResult?.markerScore
- }}</span>
- </transition-group>
- </div>
- </div>
- <qm-button
- v-if="props.isCheckAnswer && !hasModifyScore"
- class="board-header-submit"
- size="medium"
- type="primary"
- @click="checkSubmit"
- >
- 复核
- </qm-button>
- <qm-button
- v-else
- class="board-header-submit"
- size="medium"
- type="primary"
- @click="submit"
- >
- 提交
- </qm-button>
- </div>
- <div
- v-if="markStore.currentTaskEnsured.questionList"
- class="board-questions"
- :style="{
- flexGrow: 2,
- }"
- >
- <template
- v-for="(question, index) in markStore.currentTaskEnsured.questionList"
- :key="index"
- >
- <div class="board-question-full-box">
- <div
- :id="'bq-' + question.mainNumber + '-' + question.subNumber"
- :class="[
- 'board-question',
- {
- 'is-current': isCurrentQuestion(question),
- 'is-disabled': isDisabledQuestion(question),
- },
- ]"
- @click="
- () => {
- chooseQuestion(question);
- scrollToQuestion(question);
- }
- "
- >
- <div class="question-info">
- <div class="question-title" :title="question.title">
- {{ question.title }}
- </div>
- <div class="question-no">
- 间隔{{ question.intervalScore }}分,给分区间{{
- question.minScore
- }}~{{ question.maxScore }}
- </div>
- <div class="question-no">
- {{ question.mainNumber }}-{{ question.subNumber }}
- </div>
- </div>
- <div
- :class="[
- 'question-score',
- {
- 'is-problem': question.problem || isArbitrated(question),
- },
- ]"
- >
- <transition-group name="score-number-animation" tag="span">
- <span v-if="question.problem"> 问题卷 </span>
- <span v-else-if="isArbitrated(question)">{{
- getArbitratedStatusName(question)
- }}</span>
- <span v-else-if="!question.selfMark">已评</span>
- <span
- v-else
- :key="`${question.mainNumber}_${question.subNumber}_${index}`"
- >
- {{
- isCurrentQuestion(question)
- ? scoreStr
- : markStore.currentTask?.markResult?.scoreList[index]
- }}
- </span>
- </transition-group>
- </div>
- </div>
- </div>
- </template>
- </div>
- <div
- v-if="!isCheckAnswer && markStore.currentQuestion?.selfMark"
- class="board-footer"
- >
- <qm-button
- v-if="markStore.currentQuestion?.problem"
- class="board-clear"
- @click="cancelProblemQuestion"
- >
- 取消问题卷
- </qm-button>
- <qm-button v-else class="board-clear" @click="toMarkProblemQuestion">
- 标记问题卷
- </qm-button>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import type { Question } from "@/types";
- import { isNumber } from "lodash-es";
- import { ref, onMounted, onUnmounted, watch } from "vue";
- import { useMarkStore } from "@/store";
- import useAutoChooseFirstQuestion from "../composables/useAutoChooseFirstQuestion";
- import useQuestion from "../composables/useQuestion";
- import useMakeTrack from "../composables/useMakeTrack";
- import { message } from "ant-design-vue";
- const emit = defineEmits([
- "submit",
- "allZeroSubmit",
- "unselectiveSubmit",
- "checkSubmit",
- ]);
- const props = defineProps<{ isCheckAnswer?: boolean }>();
- const {
- isDisabledQuestion,
- isArbitrated,
- getArbitratedStatusName,
- cancelProblemQuestion,
- toMarkProblemQuestion,
- } = useQuestion();
- const { chooseQuestion } = useAutoChooseFirstQuestion();
- const { makeCommonTrack } = useMakeTrack();
- const hasModifyScore = ref(false);
- const markStore = useMarkStore();
- let scoreStr = $ref("");
- watch(
- () => [markStore.currentQuestion, markStore.setting.uiSetting["normal.mode"]],
- () => {
- if (markStore.currentQuestion) {
- const { __index } = markStore.currentQuestion;
- const scoreR = markStore.currentTask?.markResult?.scoreList[__index];
- scoreStr =
- scoreR || scoreR === 0 ? scoreR : markStore.currentQuestion.score;
- if (isNumber(scoreStr)) {
- scoreStr = "" + scoreStr;
- } else {
- scoreStr = "";
- }
- } else {
- scoreStr = "";
- }
- },
- { immediate: true }
- );
- const normalMode = ref(
- markStore.setting.uiSetting["normal.mode"] || "keyboard"
- );
- function normalModeChange(value: string) {
- markStore.setting.uiSetting["normal.mode"] = value;
- }
- const questionScoreSteps = $computed(() => {
- const question = markStore.currentQuestion;
- if (!question) return [];
- const remainScore = Math.round(question.maxScore * 100) / 100;
- const steps = [];
- for (
- let i = 0;
- i <= remainScore;
- i = Math.round(i * 100 + question.intervalScore * 100) / 100
- ) {
- steps.push(i);
- }
- if (
- Math.round(remainScore * 100) % Math.round(question.intervalScore * 100) !==
- 0
- ) {
- steps.push(remainScore);
- }
- return steps;
- });
- function isCurrentQuestion(question: Question) {
- return (
- markStore.currentQuestion?.mainNumber === question.mainNumber &&
- markStore.currentQuestion?.subNumber === question.subNumber
- );
- }
- const questionScore = $computed(
- () =>
- markStore.currentTask &&
- markStore.currentQuestion &&
- markStore.currentTask.markResult.scoreList[
- markStore.currentQuestion.__index
- ]
- );
- function numberKeyListener(event: KeyboardEvent) {
- if (
- isDisabledQuestion(markStore.currentQuestion) ||
- markStore.currentQuestion?.problem
- )
- return;
-
- hasModifyScore.value = true;
-
-
- if (!markStore.currentQuestion || !markStore.currentTask) return;
- if (markStore.globalMask) return;
- function indexOfCurrentQuestion() {
- return markStore.currentTaskEnsured.questionList.findIndex(
- (q) =>
- q.mainNumber === markStore.currentQuestion?.mainNumber &&
- q.subNumber === markStore.currentQuestion.subNumber
- );
- }
-
- if (event.key === "Enter") {
- const allScoreMarked = markStore.currentTask.markResult.scoreList.every(
- (s) => isNumber(s)
- );
-
- if (allScoreMarked && scoreStr === "" + questionScore) {
- submit();
- return;
- }
- if (scoreStr.length === 0) {
- void message.error({ content: "请输入分数", duration: 5 });
- console.log("请输入分数");
- return;
- }
-
-
-
- if (
- !(
- scoreStr === "0" ||
- /^0\.[1-9]\d*$/.test(scoreStr) ||
- /^[1-9]\d*$/.test(scoreStr) ||
- /^[1-9]\d*\.\d*[1-9]$/.test(scoreStr)
- )
- ) {
- void message.error({ content: "分数格式不正确", duration: 5 });
- console.log("分数格式不正确");
- return;
- }
- const score = parseFloat(scoreStr);
-
- if (!isNumber(score)) {
- void message.error({ content: "非数字输入", duration: 5 });
- console.log("非数字输入");
- return;
- }
- if (!questionScoreSteps.includes(score)) {
- void message.error({ content: "输入的分数不在有效间隔内", duration: 5 });
- return;
- }
- makeCommonTrack(markStore.currentQuestion, score);
-
- const idx = indexOfCurrentQuestion();
- if (idx + 1 < markStore.currentTask.questionList.length) {
- chooseQuestion(markStore.currentTask.questionList[idx + 1]);
- }
- return;
- }
- if (event.key === "ArrowUp") {
- const idx = indexOfCurrentQuestion();
- if (idx > 0) {
- chooseQuestion(markStore.currentTask.questionList[idx - 1]);
- }
- event.preventDefault();
- return;
- }
- if (event.key === "ArrowDown") {
- const idx = indexOfCurrentQuestion();
- if (idx < markStore.currentTask.questionList.length - 1) {
- chooseQuestion(markStore.currentTask.questionList[idx + 1]);
- }
- event.preventDefault();
- return;
- }
-
- if (event.key === "Backspace") {
- if (scoreStr.length > 0) {
- scoreStr = scoreStr.slice(0, -1);
- } else {
- return;
- }
- }
- if (event.key === "Escape") {
- scoreStr = "";
- }
-
- if (".0123456789".includes(event.key)) {
- scoreStr += event.key;
- }
- }
- onMounted(() => {
- document.addEventListener("keydown", numberKeyListener);
- });
- onUnmounted(() => {
- document.removeEventListener("keydown", numberKeyListener);
- });
- function submit() {
- emit("submit");
- }
- function checkSubmit() {
- emit("checkSubmit");
- }
- const buttonHeightForSelective = $computed(() =>
- markStore.setting.selective && markStore.setting.enableAllZero
- ? "36px"
- : "76px"
- );
- </script>
- <style scoped>
- .mark-board-track-container {
- max-width: 290px;
- min-width: 290px;
- padding: 20px;
- max-height: calc(100vh - 56px - 0px);
- overflow: auto;
- z-index: 1001;
- transition: margin-right 0.5s;
- color: var(--app-small-header-text-color);
- }
- .mark-board-track-container.show {
- margin-right: 0;
- }
- .mark-board-track-container.hide {
- margin-right: -290px;
- }
- .top-container {
- background-color: var(--app-container-bg-color);
- }
- .total-score {
- color: var(--app-main-text-color);
- font-size: 32px;
- }
- .question {
- min-width: 80px;
- padding: 10px;
- background-color: var(--app-container-bg-color);
- }
- .current-question {
- color: white;
- background-color: var(--app-score-color);
- }
- .current-score {
- background-color: var(--app-score-color);
- color: white;
- }
- .all-zero-unselective-button {
- height: v-bind(buttonHeightForSelective);
- border-radius: 10px;
- padding: 7px;
- background-color: #4db9ff;
- border: none;
- }
- </style>
|