|
@@ -4,7 +4,14 @@ import {
|
|
|
getSingleStudentCardData,
|
|
|
getMarkArea,
|
|
|
} from '@/api/task';
|
|
|
-import { Task, Track, SpecialTag, Question, MarkArea } from '@/api/types/task';
|
|
|
+import {
|
|
|
+ Task,
|
|
|
+ Track,
|
|
|
+ SpecialTag,
|
|
|
+ Question,
|
|
|
+ MarkArea,
|
|
|
+ SplitConfig,
|
|
|
+} from '@/api/types/task';
|
|
|
import { TrackConfigType } from '@/store/modules/app/types';
|
|
|
import { PictureTypeEnum, PICTURE_TYPE } from '@/constants/enumerate';
|
|
|
import { calcSum, deepCopy, maxNum, strGbLen } from '@/utils/utils';
|
|
@@ -345,10 +352,9 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
|
|
|
const markDeailList = parseMarkDetailList(originImgs);
|
|
|
const objectiveAnswerTagList = parseObjectiveAnswerTags(originImgs);
|
|
|
- // 如果没有轨迹信息信息,有评卷区域信息,就在评卷区域左上角展示得分
|
|
|
- const commonMarkQuestionAreaList = !trackLists.length
|
|
|
- ? parseCommonMarkQuestionAreaScore(originImgs)
|
|
|
- : [];
|
|
|
+ // 在每个分组的第一个评卷区域左上角展示分组总分
|
|
|
+ const commonMarkQuestionAreaList =
|
|
|
+ parseCommonMarkQuestionAreaScore(originImgs);
|
|
|
|
|
|
for (let i = 0; i < originImgs.length; i++) {
|
|
|
const img = originImgs[i];
|
|
@@ -382,10 +388,8 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- if (!cardData.length) {
|
|
|
- const summarys = parseMode4Data(originImgs[0]);
|
|
|
- trackData[0].drawTrackList.push(...summarys);
|
|
|
- }
|
|
|
+ const summarys = parseSummaryData(originImgs[0]);
|
|
|
+ trackData[0].drawTrackList.push(...summarys);
|
|
|
}
|
|
|
|
|
|
async function drawTask(): Promise<ImageItem[]> {
|
|
@@ -1087,7 +1091,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
return markerName;
|
|
|
}
|
|
|
|
|
|
- function parseMode4Data(img: ImageItem): DrawTrackItem[] {
|
|
|
+ function parseSummaryData(img: ImageItem): DrawTrackItem[] {
|
|
|
const isDoubleMark = (rawTask.questionList || []).some((question) => {
|
|
|
let userIds = question.trackList.map((track) => track.userId);
|
|
|
if (
|
|
@@ -1143,16 +1147,29 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
if (!markAreaList.length) return [];
|
|
|
|
|
|
const dataList: DrawTrackItem[][] = [];
|
|
|
- const questionScore: Record<string, string> = {};
|
|
|
- (rawTask.questionList || []).forEach((q) => {
|
|
|
- questionScore[`${q.mainNumber}_${q.subNumber}`] = String(q.score || '');
|
|
|
+ const questionList = rawTask.questionList || [];
|
|
|
+ const groupQuestions = {} as Record<number, Question[]>;
|
|
|
+ questionList.forEach((question) => {
|
|
|
+ if (!groupQuestions[question.groupNumber]) {
|
|
|
+ groupQuestions[question.groupNumber] = [];
|
|
|
+ }
|
|
|
+ groupQuestions[question.groupNumber].push(question);
|
|
|
});
|
|
|
|
|
|
- markAreaList.forEach((markArea) => {
|
|
|
- const qStruct = `${markArea.mainNumber}_${markArea.subNumber}`;
|
|
|
- const area = markArea.splitConfig && markArea.splitConfig[0];
|
|
|
- if (!area) return;
|
|
|
+ Object.keys(groupQuestions).forEach((groupNumber) => {
|
|
|
+ const questions = groupQuestions[Number(groupNumber)];
|
|
|
+ const groupScore = calcSum(questions.map((q) => q.score || 0));
|
|
|
+ const qnos = questions.map((q) => `${q.mainNumber}-${q.subNumber}`);
|
|
|
+
|
|
|
+ const mArea = markAreaList.find(
|
|
|
+ (markArea) =>
|
|
|
+ qnos.includes(`${markArea.mainNumber}-${markArea.subNumber}`) &&
|
|
|
+ markArea.splitConfig &&
|
|
|
+ markArea.splitConfig.length
|
|
|
+ );
|
|
|
+ if (!mArea) return;
|
|
|
|
|
|
+ const area = (mArea.splitConfig as SplitConfig[])[0];
|
|
|
const imgIndex = area.i - 1;
|
|
|
const img = images[imgIndex];
|
|
|
area.x *= img.width;
|
|
@@ -1165,7 +1182,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
option: {
|
|
|
x: area.x,
|
|
|
y: area.y,
|
|
|
- text: questionScore[qStruct] || '',
|
|
|
+ text: String(groupScore),
|
|
|
color: 'red',
|
|
|
fontSize: trackInfoFontSize * 3,
|
|
|
},
|