|
@@ -133,6 +133,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
let answerMap = {} as AnswerMap;
|
|
|
let cardData = [] as CardDataItem[];
|
|
|
let markAreas = [] as MarkArea[];
|
|
|
+ let hasMarkArea = true;
|
|
|
let recogDatas: string[] = [];
|
|
|
let rawTask = {} as Task;
|
|
|
let trackData = [] as TrackItemType[];
|
|
@@ -265,6 +266,10 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
};
|
|
|
});
|
|
|
|
|
|
+ hasMarkArea = res.subjectiveQuestions.some((item) => {
|
|
|
+ return item.picList?.length;
|
|
|
+ });
|
|
|
+
|
|
|
// 获取客观题选项信息
|
|
|
res.objectiveQuestions.forEach((item) => {
|
|
|
answerMap[`${item.mainNumber}_${item.subNumber}`] = {
|
|
@@ -389,6 +394,11 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
drawTrackList,
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ if (!hasMarkArea && !cardData.length) {
|
|
|
+ const summarys = parseSummaryData(originImgs[0]);
|
|
|
+ trackData[0].drawTrackList.push(...summarys);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async function drawTask(): Promise<ImageItem[]> {
|
|
@@ -886,8 +896,21 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
return questions;
|
|
|
}
|
|
|
|
|
|
- // 获取题型的评卷区
|
|
|
+ // 解析各试题答题区域
|
|
|
function parseQuestionAreas(questions: QuestionItem[]) {
|
|
|
+ if (!questions.length) return [];
|
|
|
+ let pictureConfigs = [];
|
|
|
+ if (hasMarkArea) {
|
|
|
+ pictureConfigs = parseMarkQuestionAreas(questions);
|
|
|
+ } else {
|
|
|
+ pictureConfigs = parseCardQuestionAreas(questions);
|
|
|
+ }
|
|
|
+
|
|
|
+ return shrinkQuestionArea(pictureConfigs);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取题型的评卷区
|
|
|
+ function parseMarkQuestionAreas(questions: QuestionItem[]) {
|
|
|
if (!questions.length || !markAreas?.length) return [];
|
|
|
|
|
|
const pictureConfigs: QuestionArea[] = [];
|
|
@@ -914,7 +937,57 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
// 合并相邻区域
|
|
|
const combinePictureConfigList = combinePictureConfig(pictureConfigs);
|
|
|
// console.log(combinePictureConfigList);
|
|
|
- return shrinkQuestionArea(combinePictureConfigList);
|
|
|
+ return combinePictureConfigList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过题卡获取试题评卷区
|
|
|
+ function parseCardQuestionAreas(questions: QuestionItem[]) {
|
|
|
+ if (!questions.length || !cardData?.length) return [];
|
|
|
+
|
|
|
+ const pictureConfigs: QuestionArea[] = [];
|
|
|
+ const structs = questions.map(
|
|
|
+ (item) => `${item.mainNumber}_${item.subNumber}`
|
|
|
+ );
|
|
|
+ cardData.forEach((page, pindex) => {
|
|
|
+ page.exchange.answer_area.forEach((area) => {
|
|
|
+ const [x, y, w, h] = area.area;
|
|
|
+ const qStruct = `${area.main_number}_${area.sub_number}`;
|
|
|
+
|
|
|
+ const pConfig: QuestionArea = {
|
|
|
+ i: pindex + 1,
|
|
|
+ x,
|
|
|
+ y,
|
|
|
+ w,
|
|
|
+ h,
|
|
|
+ qStruct,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (typeof area.sub_number === 'number') {
|
|
|
+ if (!structs.includes(qStruct)) return;
|
|
|
+ pictureConfigs.push(pConfig);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 复合区域处理,比如填空题,多个小题合并为一个区域
|
|
|
+ if (typeof area.sub_number === 'string') {
|
|
|
+ const areaStructs = area.sub_number
|
|
|
+ .split(',')
|
|
|
+ .map((subNumber) => `${area.main_number}_${subNumber}`);
|
|
|
+ if (
|
|
|
+ structs.some((struct) => areaStructs.includes(struct)) &&
|
|
|
+ !pictureConfigs.find((item) => item.qStruct === qStruct)
|
|
|
+ ) {
|
|
|
+ pictureConfigs.push(pConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // console.log(pictureConfigs);
|
|
|
+
|
|
|
+ // 合并相邻区域
|
|
|
+ const combinePictureConfigList: QuestionArea[] =
|
|
|
+ combinePictureConfig(pictureConfigs);
|
|
|
+ // console.log(combinePictureConfigList);
|
|
|
+ return combinePictureConfigList;
|
|
|
}
|
|
|
|
|
|
// 缩小区域
|
|
@@ -939,56 +1012,6 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
return shrinkPictureConfigList;
|
|
|
}
|
|
|
|
|
|
- // 通过题卡获取试题评卷区
|
|
|
- // function parseCardQuestionAreas(questions: QuestionItem[]) {
|
|
|
- // if (!questions.length || !cardData?.length) return [];
|
|
|
-
|
|
|
- // const pictureConfigs: QuestionArea[] = [];
|
|
|
- // const structs = questions.map(
|
|
|
- // (item) => `${item.mainNumber}_${item.subNumber}`
|
|
|
- // );
|
|
|
- // cardData.forEach((page, pindex) => {
|
|
|
- // page.exchange.answer_area.forEach((area) => {
|
|
|
- // const [x, y, w, h] = area.area;
|
|
|
- // const qStruct = `${area.main_number}_${area.sub_number}`;
|
|
|
-
|
|
|
- // const pConfig: QuestionArea = {
|
|
|
- // i: pindex + 1,
|
|
|
- // x,
|
|
|
- // y,
|
|
|
- // w,
|
|
|
- // h,
|
|
|
- // qStruct,
|
|
|
- // };
|
|
|
-
|
|
|
- // if (typeof area.sub_number === 'number') {
|
|
|
- // if (!structs.includes(qStruct)) return;
|
|
|
- // pictureConfigs.push(pConfig);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // // 复合区域处理,比如填空题,多个小题合并为一个区域
|
|
|
- // if (typeof area.sub_number === 'string') {
|
|
|
- // const areaStructs = area.sub_number
|
|
|
- // .split(',')
|
|
|
- // .map((subNumber) => `${area.main_number}_${subNumber}`);
|
|
|
- // if (
|
|
|
- // structs.some((struct) => areaStructs.includes(struct)) &&
|
|
|
- // !pictureConfigs.find((item) => item.qStruct === qStruct)
|
|
|
- // ) {
|
|
|
- // pictureConfigs.push(pConfig);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // });
|
|
|
- // // console.log(pictureConfigs);
|
|
|
-
|
|
|
- // // 合并相邻区域
|
|
|
- // const combinePictureConfigList: QuestionArea[] =
|
|
|
- // combinePictureConfig(pictureConfigs);
|
|
|
- // // console.log(combinePictureConfigList);
|
|
|
- // return combinePictureConfigList;
|
|
|
- // }
|
|
|
-
|
|
|
function combinePictureConfig(pictureConfigs: QuestionArea[]) {
|
|
|
pictureConfigs.sort((a, b) => {
|
|
|
return a.i - b.i || a.x - b.x || a.y - b.y;
|
|
@@ -1155,7 +1178,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
}
|
|
|
// objective answer tag ----- end->
|
|
|
|
|
|
- /* 首页汇总信息
|
|
|
+ // 首页汇总信息
|
|
|
// 获取汇总记录中评卷员信息
|
|
|
function getSummaryMarkerName(q: Question): string {
|
|
|
let markerName = '';
|
|
@@ -1224,7 +1247,6 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
|
|
|
return dataList;
|
|
|
}
|
|
|
- */
|
|
|
|
|
|
return {
|
|
|
runTask,
|