|
@@ -140,6 +140,19 @@ export default function useTrackTag() {
|
|
|
|
|
|
// 解析各试题答题区域
|
|
|
function parseQuestionAreas(questions: Question[]) {
|
|
|
+ if (!questions.length) return [];
|
|
|
+ let pictureConfigs = [];
|
|
|
+ if (markStore.currentTask.hasMarkAreas) {
|
|
|
+ pictureConfigs = parseMarkQuestionAreas(questions);
|
|
|
+ } else {
|
|
|
+ pictureConfigs = parseCardQuestionAreas(questions);
|
|
|
+ }
|
|
|
+
|
|
|
+ return shrinkQuestionArea(pictureConfigs);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过评卷区设置获取试题评卷区
|
|
|
+ function parseMarkQuestionAreas(questions: Question[]) {
|
|
|
if (!questions.length || !markStore.currentTask?.markAreas?.length)
|
|
|
return [];
|
|
|
|
|
@@ -169,7 +182,57 @@ export default function useTrackTag() {
|
|
|
const combinePictureConfigList: QuestionArea[] =
|
|
|
combinePictureConfig(pictureConfigs);
|
|
|
// console.log(combinePictureConfigList);
|
|
|
- return shrinkQuestionArea(combinePictureConfigList);
|
|
|
+ return combinePictureConfigList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通过题卡获取试题评卷区
|
|
|
+ function parseCardQuestionAreas(questions: QuestionItem[]) {
|
|
|
+ if (!questions.length || !markStore.currentTask.cardData?.length) return [];
|
|
|
+
|
|
|
+ const pictureConfigs: QuestionArea[] = [];
|
|
|
+ const structs = questions.map(
|
|
|
+ (item) => `${item.mainNumber}_${item.subNumber}`
|
|
|
+ );
|
|
|
+ markStore.currentTask.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;
|
|
|
}
|
|
|
|
|
|
// 缩小区域
|
|
@@ -590,44 +653,34 @@ export default function useTrackTag() {
|
|
|
}
|
|
|
|
|
|
// 模式4的解析
|
|
|
- function parseMode4Data(): TrackSummaryItem[] {
|
|
|
- // 只有单评才展示summary
|
|
|
- const isDoubleMark = (markStore.currentTask.questionList || []).some(
|
|
|
- (question) => {
|
|
|
- let userIds = question.markerTrackList.map((track) => track.userId);
|
|
|
- if (
|
|
|
- !userIds.length &&
|
|
|
- question.markerList &&
|
|
|
- question.markerList.length
|
|
|
- ) {
|
|
|
- userIds = question.markerList
|
|
|
- .filter((marker) => !marker.header)
|
|
|
- .map((marker) => marker.userId);
|
|
|
- }
|
|
|
- const uids = new Set(userIds);
|
|
|
- return uids.size === 2;
|
|
|
+ function getMode4MarkerName(q: Question): string {
|
|
|
+ let markerName = "";
|
|
|
+ if (q.headerTrackList && q.headerTrackList.length) {
|
|
|
+ const names = new Set(q.headerTrackList.map((item) => item.userName));
|
|
|
+ markerName = Array.from(names).join(",");
|
|
|
+ } else if (q.markerTrackList && q.markerTrackList.length) {
|
|
|
+ const names = new Set(q.markerTrackList.map((item) => item.userName));
|
|
|
+ markerName = Array.from(names).join(",");
|
|
|
+ } else if (q.markerList && q.markerList.length) {
|
|
|
+ let markers = q.markerList.filter((marker) => marker.header);
|
|
|
+ if (!markers.length) {
|
|
|
+ markers = q.markerList.filter((marker) => !marker.header);
|
|
|
}
|
|
|
- );
|
|
|
- if (isDoubleMark) return [];
|
|
|
+ if (markers.length) {
|
|
|
+ const names = new Set(markers.map((item) => item.userName));
|
|
|
+ markerName = Array.from(names).join(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return markerName;
|
|
|
+ }
|
|
|
|
|
|
+ function parseMode4Data(): TrackSummaryItem[] {
|
|
|
return (markStore.currentTask.questionList || []).map((q) => {
|
|
|
- let markerName = "";
|
|
|
- if (q.headerTrackList && q.headerTrackList.length) {
|
|
|
- markerName = q.headerTrackList[0].userName;
|
|
|
- } else if (q.markerTrackList && q.markerTrackList.length) {
|
|
|
- markerName = q.markerTrackList[0].userName;
|
|
|
- } else if (q.markerList && q.markerList.length) {
|
|
|
- let markers = q.markerList.filter((marker) => marker.header);
|
|
|
- if (!markers.length) {
|
|
|
- markers = q.markerList.filter((marker) => !marker.header);
|
|
|
- }
|
|
|
- if (markers.length) markerName = markers[0].userName;
|
|
|
- }
|
|
|
return {
|
|
|
mainNumber: q.mainNumber,
|
|
|
subNumber: q.subNumber,
|
|
|
score: q.score,
|
|
|
- markerName,
|
|
|
+ markerName: getMode4MarkerName(q),
|
|
|
};
|
|
|
});
|
|
|
}
|