Michael Wang 4 年之前
父節點
當前提交
598fd725a8
共有 5 個文件被更改,包括 53 次插入9 次删除
  1. 1 0
      package.json
  2. 36 2
      src/api/markPage.ts
  3. 10 7
      src/components/mark/MarkBody.vue
  4. 1 0
      src/types/index.ts
  5. 5 0
      yarn.lock

+ 1 - 0
package.json

@@ -20,6 +20,7 @@
   },
   },
   "devDependencies": {
   "devDependencies": {
     "@types/lodash-es": "^4.17.4",
     "@types/lodash-es": "^4.17.4",
+    "@types/node": "^14.14.37",
     "@vitejs/plugin-vue": "^1.2.1",
     "@vitejs/plugin-vue": "^1.2.1",
     "@vue/compiler-sfc": "^3.0.11",
     "@vue/compiler-sfc": "^3.0.11",
     "autoprefixer": "^10.2.5",
     "autoprefixer": "^10.2.5",

+ 36 - 2
src/api/markPage.ts

@@ -1,6 +1,7 @@
 import { findCurrentTaskMarkResult } from "@/components/mark/store";
 import { findCurrentTaskMarkResult } from "@/components/mark/store";
 import { httpApp } from "@/plugins/axiosApp";
 import { httpApp } from "@/plugins/axiosApp";
 import { Setting, UISetting } from "@/types";
 import { Setting, UISetting } from "@/types";
+import { groupBy, sortBy } from "lodash";
 
 
 /** 清除评卷任务(之前锁住的任务之类的) */
 /** 清除评卷任务(之前锁住的任务之类的) */
 export async function clearMarkTask() {
 export async function clearMarkTask() {
@@ -65,11 +66,44 @@ export async function getHistoryTask({
 export async function saveTask() {
 export async function saveTask() {
   const markResult = findCurrentTaskMarkResult();
   const markResult = findCurrentTaskMarkResult();
   if (markResult) {
   if (markResult) {
-    markResult.scoreList = markResult.trackList.map((t) => t.score);
+    const scoreGroups = groupBy(
+      markResult.trackList,
+      (obj) =>
+        (obj.mainNumber + "").padStart(10, "0") +
+        obj.subNumber.padStart(10, "0")
+    );
+    const questionWithScore = Object.entries(scoreGroups);
+    const questionWithTotalScore = questionWithScore.map((v) => [
+      v[0],
+      v[1].reduce((acc, c) => (acc += c.score), 0),
+    ]);
+    const questionWithTotalScoreSorted = sortBy(
+      questionWithTotalScore,
+      (obj) => obj[0]
+    );
+    const scoreList = questionWithTotalScoreSorted.map((s) => s[1]);
+    console.log(
+      scoreGroups,
+      questionWithScore,
+      questionWithTotalScore,
+      questionWithTotalScoreSorted,
+      scoreList
+    );
+    markResult.scoreList = scoreList as number[];
+    // const sortScore = orderBy(markResult.trackList, ['mainNumber', 'subNumber', 'score']);
+    // markResult.scoreList = sortScore.reduce((acc, pre) => {
+    //   if(pre.mainNumber === cur.mainNumber && pre.subNumber === cur.subNumber) {
+    //     acc[acc.length-1] += cur.score
+    //   }
+    // }, [0])
+    const allScoreList = markResult.trackList.map((t) => t.score);
     markResult.markerScore =
     markResult.markerScore =
-      markResult.scoreList.reduce((acc, v) => (acc += v * 100)) / 100;
+      markResult.trackList
+        .map((t) => t.score)
+        .reduce((acc, v) => (acc += v * 100), 0) / 100;
     markResult.specialTagList = [];
     markResult.specialTagList = [];
     markResult.problem = false;
     markResult.problem = false;
+    markResult.spent = Date.now() - markResult.spent;
 
 
     httpApp.post("/mark/saveTask", markResult);
     httpApp.post("/mark/saveTask", markResult);
   }
   }

+ 10 - 7
src/components/mark/MarkBody.vue

@@ -281,19 +281,22 @@ export default defineComponent({
     });
     });
 
 
     const makeMark = (event: MouseEvent, item: SliceImage) => {
     const makeMark = (event: MouseEvent, item: SliceImage) => {
-      console.log(event);
-      console.log(item);
+      // console.log(event);
+      // console.log(item);
       const target = event.target as HTMLImageElement;
       const target = event.target as HTMLImageElement;
       const track = {} as Track;
       const track = {} as Track;
       // TODO: choose question first
       // TODO: choose question first
       track.mainNumber = 4;
       track.mainNumber = 4;
       track.subNumber = "1";
       track.subNumber = "1";
-      track.score = 9;
+      track.number = 0;
+      track.score = 2;
       track.offsetIndex = item.indexInSliceUrls;
       track.offsetIndex = item.indexInSliceUrls;
-      track.offsetX =
-        event.offsetX * (target.naturalWidth / target.width) + item.dx;
-      track.offsetY =
-        event.offsetY * (target.naturalHeight / target.height) + item.dy;
+      track.offsetX = Math.round(
+        event.offsetX * (target.naturalWidth / target.width) + item.dx
+      );
+      track.offsetY = Math.round(
+        event.offsetY * (target.naturalHeight / target.height) + item.dy
+      );
       track.positionX = (track.offsetX - item.dx) / maxSliceWidth;
       track.positionX = (track.offsetX - item.dx) / maxSliceWidth;
       track.positionY =
       track.positionY =
         (track.offsetY - item.dy + item.accumTopHeight) / theFinalHeight;
         (track.offsetY - item.dy + item.accumTopHeight) / theFinalHeight;

+ 1 - 0
src/types/index.ts

@@ -105,6 +105,7 @@ interface Question {
 export interface Track {
 export interface Track {
   mainNumber: number; // 大题号
   mainNumber: number; // 大题号
   subNumber: string; // 小题号,当前api中只有number // 特殊标记中没有
   subNumber: string; // 小题号,当前api中只有number // 特殊标记中没有
+  number: number; // 前端使用,暂时用不着,赋0
   offsetIndex: number; // 第几张图
   offsetIndex: number; // 第几张图
   offsetX: number; // 左上角为原点
   offsetX: number; // 左上角为原点
   offsetY: number;
   offsetY: number;

+ 5 - 0
yarn.lock

@@ -61,6 +61,11 @@
   resolved "https://registry.npm.taobao.org/@types/lodash/download/@types/lodash-4.14.168.tgz?cache=0&sync_timestamp=1613379246862&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Flodash%2Fdownload%2F%40types%2Flodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
   resolved "https://registry.npm.taobao.org/@types/lodash/download/@types/lodash-4.14.168.tgz?cache=0&sync_timestamp=1613379246862&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Flodash%2Fdownload%2F%40types%2Flodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
   integrity sha1-/iRjLnm3rePxMoka//hsql5c4Ag=
   integrity sha1-/iRjLnm3rePxMoka//hsql5c4Ag=
 
 
+"@types/node@^14.14.37":
+  version "14.14.37"
+  resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-14.14.37.tgz?cache=0&sync_timestamp=1616803552865&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
+  integrity sha1-o92NpOuEqZbDbjMd+Y2Cq9drUW4=
+
 "@vitejs/plugin-vue@^1.2.1":
 "@vitejs/plugin-vue@^1.2.1":
   version "1.2.1"
   version "1.2.1"
   resolved "https://registry.npm.taobao.org/@vitejs/plugin-vue/download/@vitejs/plugin-vue-1.2.1.tgz?cache=0&sync_timestamp=1617153040488&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vitejs%2Fplugin-vue%2Fdownload%2F%40vitejs%2Fplugin-vue-1.2.1.tgz#6de49436fc346f829a56676066428e3f011522ac"
   resolved "https://registry.npm.taobao.org/@vitejs/plugin-vue/download/@vitejs/plugin-vue-1.2.1.tgz?cache=0&sync_timestamp=1617153040488&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vitejs%2Fplugin-vue%2Fdownload%2F%40vitejs%2Fplugin-vue-1.2.1.tgz#6de49436fc346f829a56676066428e3f011522ac"