Răsfoiți Sursa

给分面板逻辑支持小数点后3位

刘洋 2 ani în urmă
părinte
comite
486bbf5bab
3 a modificat fișierele cu 42 adăugiri și 12 ștergeri
  1. 33 4
      src/features/mark/MarkBoardTrack.vue
  2. 5 5
      src/features/mark/MarkBody.vue
  3. 4 3
      src/store/store.ts

+ 33 - 4
src/features/mark/MarkBoardTrack.vue

@@ -379,12 +379,40 @@ const questionScore = $computed(
     store.currentTask.markResult.scoreList[store.currentQuestion.__index]
 );
 
+// const questionScoreSteps = $computed(() => {
+//   const question = store.currentQuestion;
+//   if (!question) return [];
+
+//   const remainScore =
+//     Math.round(question.maxScore * 100 - (questionScore || 0) * 100) / 100;
+
+//   const steps = [];
+//   if (question.intervalScore <= 0) {
+//     console.warn(`question.intervalScore got: ${question.intervalScore}`);
+//   }
+//   for (
+//     let i = 0;
+//     i <= remainScore && question.intervalScore > 0;
+//     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;
+// });
+
 const questionScoreSteps = $computed(() => {
   const question = store.currentQuestion;
   if (!question) return [];
 
   const remainScore =
-    Math.round(question.maxScore * 100 - (questionScore || 0) * 100) / 100;
+    Math.round(question.maxScore * 1000 - (questionScore || 0) * 1000) / 1000;
 
   const steps = [];
   if (question.intervalScore <= 0) {
@@ -393,12 +421,13 @@ const questionScoreSteps = $computed(() => {
   for (
     let i = 0;
     i <= remainScore && question.intervalScore > 0;
-    i = Math.round(i * 100 + question.intervalScore * 100) / 100
+    i = Math.round(i * 1000 + question.intervalScore * 1000) / 1000
   ) {
     steps.push(i);
   }
   if (
-    Math.round(remainScore * 100) % Math.round(question.intervalScore * 100) !==
+    Math.round(remainScore * 1000) %
+      Math.round(question.intervalScore * 1000) !==
     0
   ) {
     steps.push(remainScore);
@@ -530,7 +559,7 @@ function clearLatestMarkOfCurrentQuetion() {
       ? null
       : ts
           .map((t) => t.score)
-          .reduce((acc, v) => (acc += Math.round(v * 100)), 0) / 100;
+          .reduce((acc, v) => (acc += Math.round(v * 1000)), 0) / 1000;
 }
 
 function clearAllMarksOfCurrentQuetion() {

+ 5 - 5
src/features/mark/MarkBody.vue

@@ -101,10 +101,10 @@ const makeScoreTrack = (
     store.currentTask.markResult.scoreList[store.currentQuestion.__index];
   const ifKeepScore =
     Math.round(
-      store.currentQuestion.maxScore * 100 -
-        (questionScore || 0) * 100 -
-        store.currentScore * 2 * 100
-    ) / 100;
+      store.currentQuestion.maxScore * 1000 -
+        (questionScore || 0) * 1000 -
+        store.currentScore * 2 * 1000
+    ) / 1000;
   if (ifKeepScore < 0 && store.currentScore > 0) {
     store.currentScore = undefined;
   }
@@ -126,7 +126,7 @@ const makeScoreTrack = (
     markResult.trackList
       .filter((t) => t.mainNumber === mainNumber && t.subNumber === subNumber)
       .map((t) => t.score)
-      .reduce((acc, v) => (acc += Math.round(v * 100)), 0) / 100;
+      .reduce((acc, v) => (acc += Math.round(v * 1000)), 0) / 1000;
   item.trackList.push(track);
 };
 

+ 4 - 3
src/store/store.ts

@@ -73,7 +73,7 @@ const useMarkStore = defineStore("mark", {
     },
     /** 当前任务。确保不为空,需在上文已经检查过 store.currentTask 不为空 */
     currentTaskEnsured(): Task {
-      return store.currentTask!;
+      return store.currentTask;
     },
     /** 是否是评卷端的轨迹模式 */
     isTrackMode(): boolean {
@@ -210,11 +210,12 @@ export const initMarkStore = () => {
       if (!store.currentTask) return;
       const scoreList = store.currentTask.markResult.scoreList.filter(
         (v) => v !== null
-      ) as number[];
+      );
       const result =
         scoreList.length === 0
           ? null
-          : scoreList.reduce((acc, v) => (acc += Math.round(v * 100)), 0) / 100;
+          : scoreList.reduce((acc, v) => (acc += Math.round(v * 1000)), 0) /
+            1000;
       store.currentTask.markResult.markerScore = result;
     },
     { deep: true }