|
@@ -79,7 +79,10 @@ export async function addWatermark(
|
|
// let y = 10;
|
|
// let y = 10;
|
|
//最大宽/高限制
|
|
//最大宽/高限制
|
|
const fontSize = store.config.watermark.fontSize || 30;
|
|
const fontSize = store.config.watermark.fontSize || 30;
|
|
- const maxX = imageWidth / 2 - x * 2;
|
|
|
|
|
|
+ // const maxX = imageWidth / 2 - x * 2;
|
|
|
|
+ let dynamicX = x;
|
|
|
|
+ const maxStartX = imageWidth - x - fontSize * 0.7 * 4;
|
|
|
|
+ const nextLineStartX = x + fontSize * 0.7 * 2;
|
|
const height = fontSize + 10;
|
|
const height = fontSize + 10;
|
|
//计算总分
|
|
//计算总分
|
|
const totalScore =
|
|
const totalScore =
|
|
@@ -110,36 +113,77 @@ export async function addWatermark(
|
|
student.objectiveScoreDetail &&
|
|
student.objectiveScoreDetail &&
|
|
student.objectiveScoreDetail.length > 0
|
|
student.objectiveScoreDetail.length > 0
|
|
) {
|
|
) {
|
|
- const lines = [];
|
|
|
|
- let array = [];
|
|
|
|
- //前置提示文字的字符数
|
|
|
|
- let count = 10;
|
|
|
|
- lines.push(array);
|
|
|
|
|
|
+ const title = "大题号 | 大题总分";
|
|
|
|
+ drawText(x, (y += height), title);
|
|
|
|
+ const map: any = {};
|
|
for (let i = 0; i < student.objectiveScoreDetail.length; i++) {
|
|
for (let i = 0; i < student.objectiveScoreDetail.length; i++) {
|
|
- const detail = student.objectiveScoreDetail[i];
|
|
|
|
- const content =
|
|
|
|
- detail.answer + ":" + (detail.score === -1 ? "未选做" : detail.score);
|
|
|
|
- //超长后另起一行显示客观题
|
|
|
|
- if ((count + content.length) * fontSize * 0.7 > maxX) {
|
|
|
|
- array = [];
|
|
|
|
- lines.push(array);
|
|
|
|
- count = 10;
|
|
|
|
|
|
+ const item = student.objectiveScoreDetail[i];
|
|
|
|
+ if (!map[item.mainNumber]) {
|
|
|
|
+ map[item.mainNumber] = [item];
|
|
|
|
+ } else {
|
|
|
|
+ map[item.mainNumber].push(item);
|
|
}
|
|
}
|
|
- array.push(content);
|
|
|
|
- count += content.length;
|
|
|
|
}
|
|
}
|
|
- //显示所有行的客观题明细
|
|
|
|
- for (let l = 0; l < lines.length; l++) {
|
|
|
|
- // FIXME: 要在小个版本修复
|
|
|
|
- // 事先判断,能否打印,情况较多,比如客观题多个答案
|
|
|
|
- // 事后报错,不让错误的数据保存
|
|
|
|
- // if (y + height + 15 > imageHeight) {
|
|
|
|
- // y = startY;
|
|
|
|
- // x += width;
|
|
|
|
- // }
|
|
|
|
- drawText(x, (y += height), "客观题识别结果 | " + lines[l].join(";"));
|
|
|
|
|
|
+ for (const mainNumber in map) {
|
|
|
|
+ const arr = map[mainNumber];
|
|
|
|
+ const mainTotalScore =
|
|
|
|
+ arr.reduce((num: number, item: any) => {
|
|
|
|
+ return num + item.score * 100;
|
|
|
|
+ }, 0) / 100;
|
|
|
|
+ drawText(x, (y += height), `${mainNumber} | ${mainTotalScore}`);
|
|
|
|
+ if (store.pageInputs["/image-download"].showSubScore) {
|
|
|
|
+ drawText((dynamicX += fontSize * 0.7 * 5), y, ":");
|
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
|
+ const v = arr[i];
|
|
|
|
+ const joinStr = i == arr.length - 1 ? "" : ",";
|
|
|
|
+ if (dynamicX > maxStartX) {
|
|
|
|
+ dynamicX = nextLineStartX;
|
|
|
|
+ y += height;
|
|
|
|
+ }
|
|
|
|
+ drawText(
|
|
|
|
+ (dynamicX += (v.score + joinStr).length * fontSize * 0.7),
|
|
|
|
+ y,
|
|
|
|
+ v.score + joinStr
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // if (
|
|
|
|
+ // student.objectiveScoreDetail &&
|
|
|
|
+ // student.objectiveScoreDetail.length > 0
|
|
|
|
+ // ) {
|
|
|
|
+ // const lines = [];
|
|
|
|
+ // let array = [];
|
|
|
|
+ // //前置提示文字的字符数
|
|
|
|
+ // let count = 10;
|
|
|
|
+ // lines.push(array);
|
|
|
|
+ // for (let i = 0; i < student.objectiveScoreDetail.length; i++) {
|
|
|
|
+ // const detail = student.objectiveScoreDetail[i];
|
|
|
|
+ // const content =
|
|
|
|
+ // detail.answer + ":" + (detail.score === -1 ? "未选做" : detail.score);
|
|
|
|
+ // //超长后另起一行显示客观题
|
|
|
|
+ // if ((count + content.length) * fontSize * 0.7 > maxX) {
|
|
|
|
+ // array = [];
|
|
|
|
+ // lines.push(array);
|
|
|
|
+ // count = 10;
|
|
|
|
+ // }
|
|
|
|
+ // array.push(content);
|
|
|
|
+ // count += content.length;
|
|
|
|
+ // }
|
|
|
|
+ // //显示所有行的客观题明细
|
|
|
|
+ // for (let l = 0; l < lines.length; l++) {
|
|
|
|
+ // // FIXME: 要在小个版本修复
|
|
|
|
+ // // 事先判断,能否打印,情况较多,比如客观题多个答案
|
|
|
|
+ // // 事后报错,不让错误的数据保存
|
|
|
|
+ // // if (y + height + 15 > imageHeight) {
|
|
|
|
+ // // y = startY;
|
|
|
|
+ // // x += width;
|
|
|
|
+ // // }
|
|
|
|
+ // drawText(x, (y += height), "客观题识别结果 | " + lines[l].join(";"));
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
//显示复核人
|
|
//显示复核人
|
|
if (student.inspector) {
|
|
if (student.inspector) {
|
|
drawText(x, (y += height), "复核人: " + student.inspector.loginName);
|
|
drawText(x, (y += height), "复核人: " + student.inspector.loginName);
|
|
@@ -237,10 +281,10 @@ export async function addWatermark(
|
|
group.titleString.join(",") +
|
|
group.titleString.join(",") +
|
|
")" +
|
|
")" +
|
|
" " +
|
|
" " +
|
|
- // group.score +
|
|
|
|
|
|
+ group.score +
|
|
(store.pageInputs["/image-download"].showSubScore
|
|
(store.pageInputs["/image-download"].showSubScore
|
|
- ? group.subScores.join(",")
|
|
|
|
- : group.score) +
|
|
|
|
|
|
+ ? ":" + group.subScores.join(",")
|
|
|
|
+ : "") +
|
|
" " +
|
|
" " +
|
|
group.markerString.join(",") +
|
|
group.markerString.join(",") +
|
|
" " +
|
|
" " +
|