|
@@ -0,0 +1,159 @@
|
|
|
+<template>
|
|
|
+ <div
|
|
|
+ v-if="store.currentTask"
|
|
|
+ :style="{ display: store.markBoardCollapse ? 'none' : 'block' }"
|
|
|
+ style="max-width: 250px; min-width: 250px; border: 1px solid grey"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <h1 class="text-3xl text-center">总分:{{ markResultScore }}</h1>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="text-2xl text-center" @click="submit">提交</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div
|
|
|
+ v-if="store.currentTask && store.currentTask.questionList"
|
|
|
+ class="flex gap-1 flex-wrap"
|
|
|
+ >
|
|
|
+ <template
|
|
|
+ v-for="(question, index) in store.currentTask?.questionList"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ @click="chooseQuestion(question)"
|
|
|
+ class="question"
|
|
|
+ :class="isCurrentQuestion(question) && 'current-question'"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ {{ question.title }} {{ question.mainNumber }}-{{
|
|
|
+ question.subNumber
|
|
|
+ }}
|
|
|
+ </div>
|
|
|
+ <div class="text-center">
|
|
|
+ {{ question.score || 0 }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="flex gap-1 flex-wrap mt-5">
|
|
|
+ <div
|
|
|
+ v-for="(s, i) in questionScoreSteps"
|
|
|
+ :key="i"
|
|
|
+ @click="chooseScore(s)"
|
|
|
+ class="single-score"
|
|
|
+ :class="isCurrentScore(s) && 'current-score'"
|
|
|
+ >
|
|
|
+ {{ s }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts">
|
|
|
+import { Question } from "@/types";
|
|
|
+import { computed, defineComponent, watch } from "vue";
|
|
|
+import { findCurrentTaskMarkResult, store } from "./store";
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: "MarkBoard",
|
|
|
+ emits: ["submit"],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const markResult = findCurrentTaskMarkResult();
|
|
|
+
|
|
|
+ const markResultScore = computed(() => {
|
|
|
+ return markResult
|
|
|
+ ? markResult.trackList
|
|
|
+ .map((t) => t.score)
|
|
|
+ .reduce((acc, v) => (acc += v * 100), 0) / 100
|
|
|
+ : 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ const questionScoreSteps = computed(() => {
|
|
|
+ const question = store.currentQuestion;
|
|
|
+ if (!question) return [];
|
|
|
+
|
|
|
+ const steps = [];
|
|
|
+ for (
|
|
|
+ let i = 0;
|
|
|
+ i <= question.maxScore - question.score;
|
|
|
+ i += question.intervalScore
|
|
|
+ ) {
|
|
|
+ steps.push(i);
|
|
|
+ }
|
|
|
+ if ((question.maxScore - question.score) % question.intervalScore !== 0) {
|
|
|
+ steps.push(question.maxScore - question.score);
|
|
|
+ }
|
|
|
+
|
|
|
+ return steps;
|
|
|
+ });
|
|
|
+
|
|
|
+ function isCurrentQuestion(question: Question) {
|
|
|
+ return (
|
|
|
+ store.currentQuestion?.mainNumber === question.mainNumber &&
|
|
|
+ store.currentQuestion?.subNumber === question.subNumber
|
|
|
+ );
|
|
|
+ }
|
|
|
+ watch(
|
|
|
+ () => store.currentTask,
|
|
|
+ () => {
|
|
|
+ store.currentQuestion = undefined;
|
|
|
+ store.currentScore = undefined;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ watch(
|
|
|
+ () => store.currentQuestion,
|
|
|
+ () => {
|
|
|
+ store.currentScore = undefined;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ function chooseQuestion(question: Question) {
|
|
|
+ store.currentQuestion = question;
|
|
|
+ }
|
|
|
+ function isCurrentScore(score: number) {
|
|
|
+ return store.currentScore === score;
|
|
|
+ }
|
|
|
+ function chooseScore(score: number) {
|
|
|
+ store.currentScore = score;
|
|
|
+ }
|
|
|
+
|
|
|
+ function submit() {
|
|
|
+ emit("submit");
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ store,
|
|
|
+ markResult,
|
|
|
+ markResultScore,
|
|
|
+ isCurrentQuestion,
|
|
|
+ chooseQuestion,
|
|
|
+ isCurrentScore,
|
|
|
+ chooseScore,
|
|
|
+ questionScoreSteps,
|
|
|
+ submit,
|
|
|
+ };
|
|
|
+ },
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.question {
|
|
|
+ min-width: 80px;
|
|
|
+ border: 1px solid grey;
|
|
|
+}
|
|
|
+.current-question {
|
|
|
+ border: 1px solid yellowgreen;
|
|
|
+}
|
|
|
+.single-score {
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ display: grid;
|
|
|
+ place-content: center;
|
|
|
+
|
|
|
+ border: 1px solid black;
|
|
|
+ border-radius: 5px;
|
|
|
+}
|
|
|
+.current-score {
|
|
|
+ border: 1px solid yellowgreen;
|
|
|
+}
|
|
|
+</style>
|