uni-answer-sheet 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +9 -7
- package/dist/browser.js +43 -43
- package/dist/chunks/{index-ChLOq9ID.js → index-kGCb-s_b.js} +824 -824
- package/dist/chunks/{runtime-QFMZtUfH.js → runtime-C9TDF-ed.js} +4453 -4443
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
var Ut = Object.defineProperty;
|
|
2
|
+
var Ft = (t, e, o) => e in t ? Ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var wt = (t, e, o) => Ft(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const Kt = ["pagination", "content-identity", "choice-fill", "answer-regions", "html-codec", "status"];
|
|
5
|
+
function vt(t) {
|
|
6
6
|
const e = t.filter((n) => n?.kind === "answer-sheet-editor");
|
|
7
7
|
if (e.length !== 1) throw new Error("请显式注册一个富文本插件:plugins: [createEditorPlugin()]");
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
8
|
+
const o = e[0];
|
|
9
|
+
if (o.apiVersion !== 1 || o.documentVersion !== 1 || Kt.some((n) => !o.capabilities?.includes(n)) || typeof o.prepare != "function" || typeof o.create != "function" || typeof o.validateDocument != "function" || typeof o.html?.parse != "function" || typeof o.html?.serialize != "function") throw new Error("富文本插件协议不兼容,需要支持制卡协议 v1 的 uni-editor/plugin");
|
|
10
|
+
return o;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const e = [],
|
|
12
|
+
function xt(t) {
|
|
13
|
+
const e = [], o = (n) => {
|
|
14
14
|
if (n.type === "choiceGroup") {
|
|
15
15
|
typeof n.attrs?.id == "string" && e.push({
|
|
16
16
|
id: n.attrs.id,
|
|
17
17
|
label: n.attrs.label || String(e.length + 1),
|
|
18
|
-
options: (n.content || []).map((
|
|
18
|
+
options: (n.content || []).map((r, s) => ({ id: r.attrs?.id, label: String.fromCharCode(65 + s) })).filter((r) => typeof r.id == "string")
|
|
19
19
|
});
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
n.content?.forEach(
|
|
22
|
+
n.content?.forEach(o);
|
|
23
23
|
};
|
|
24
|
-
return
|
|
24
|
+
return o(t.content), e;
|
|
25
25
|
}
|
|
26
|
-
class
|
|
27
|
-
constructor(e,
|
|
28
|
-
super(
|
|
26
|
+
class mt extends Error {
|
|
27
|
+
constructor(e, o) {
|
|
28
|
+
super(o), this.path = e;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const B = (t, e) => {
|
|
32
|
-
throw new
|
|
32
|
+
throw new mt(t, e);
|
|
33
33
|
}, ot = {
|
|
34
34
|
语文: "CHINESE",
|
|
35
35
|
数学: "MATHS",
|
|
@@ -46,164 +46,164 @@ const B = (t, e) => {
|
|
|
46
46
|
信息科技: "IT",
|
|
47
47
|
信息技术: "IT",
|
|
48
48
|
日语: "JAPANESE"
|
|
49
|
-
},
|
|
49
|
+
}, zt = {
|
|
50
50
|
P: ["语文", "数学", "英语", "科学", "道德与法治"],
|
|
51
51
|
J: ["语文", "数学", "英语", "物理", "化学", "生物", "地理", "历史", "道德与法治", "信息科技"],
|
|
52
52
|
S: ["语文", "数学", "英语", "物理", "化学", "生物", "政治", "历史", "地理", "信息技术", "日语"]
|
|
53
|
-
},
|
|
54
|
-
const
|
|
55
|
-
return { label: t, value: `${
|
|
56
|
-
}), z = (t, e) => typeof t == "string" && t.trim() ? t.trim() : B(e, "字典编码和名称必须是非空字符串"), tt = (t, e) => t && typeof t == "object" && !Array.isArray(t) ? t : B(e, "字典必须是对象"),
|
|
57
|
-
function
|
|
58
|
-
const e = tt(t, "dictionaries"),
|
|
53
|
+
}, Wt = ["一年级", "二年级", "三年级", "四年级", "五年级", "六年级", "初一", "初二", "初三", "高一", "高二", "高三"], Vt = Wt.map((t, e) => {
|
|
54
|
+
const o = e < 6 ? "P" : e < 9 ? "J" : "S";
|
|
55
|
+
return { label: t, value: `${o}0${e < 6 ? e + 1 : (e - 6) % 3 + 1}`, classify: o };
|
|
56
|
+
}), z = (t, e) => typeof t == "string" && t.trim() ? t.trim() : B(e, "字典编码和名称必须是非空字符串"), tt = (t, e) => t && typeof t == "object" && !Array.isArray(t) ? t : B(e, "字典必须是对象"), $t = (t) => t.classify || (/^[PJS]/.test(t.value) ? t.value[0] : void 0);
|
|
57
|
+
function Lt(t = {}) {
|
|
58
|
+
const e = tt(t, "dictionaries"), o = (l, u) => {
|
|
59
59
|
if (!Array.isArray(l)) return B(u, "字典选项必须是数组");
|
|
60
60
|
const g = /* @__PURE__ */ new Set();
|
|
61
61
|
return l.map((A, C) => {
|
|
62
|
-
const
|
|
63
|
-
return g.has(
|
|
62
|
+
const M = tt(A, `${u}.${C}`), $ = z(M.value, `${u}.${C}.value`), b = z(M.label, `${u}.${C}.label`);
|
|
63
|
+
return g.has($) && B(`${u}.${C}.value`, "字典编码重复"), g.add($), { ...M, value: $, label: b };
|
|
64
64
|
});
|
|
65
|
-
}, n =
|
|
65
|
+
}, n = o(e.grades === void 0 ? Vt : e.grades, "dictionaries.grades").map((l, u) => (l.classify !== void 0 && !["P", "J", "S"].includes(String(l.classify)) && B(`dictionaries.grades.${u}.classify`, "学段为 P、J 或 S"), { value: l.value, label: l.label, classify: l.classify })), r = e.gradeCourseMap === void 0 ? void 0 : tt(e.gradeCourseMap, "dictionaries.gradeCourseMap"), s = e.courseCodeToSubjectCode === void 0 ? {} : tt(e.courseCodeToSubjectCode, "dictionaries.courseCodeToSubjectCode");
|
|
66
66
|
for (const [l, u] of Object.entries(s)) z(u, `dictionaries.courseCodeToSubjectCode.${l}`);
|
|
67
67
|
const c = /* @__PURE__ */ new Map(), i = Object.fromEntries(n.map((l) => {
|
|
68
|
-
const u =
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const O = z(
|
|
72
|
-
return c.has(
|
|
68
|
+
const u = $t(l), g = (u ? zt[u] : []).map((M) => ({ value: ot[M], label: M, subjectCode: ot[M] })), A = `dictionaries.gradeCourseMap.${l.value}`, C = o(r ? r[l.value] ?? [] : g, A).map((M, $) => {
|
|
69
|
+
const b = s[M.value];
|
|
70
|
+
M.subjectCode !== void 0 && b !== void 0 && M.subjectCode !== b && B(`${A}.${$}.subjectCode`, "课程对应的学科编码冲突");
|
|
71
|
+
const O = z(M.subjectCode ?? b ?? (Object.values(ot).includes(M.value) ? M.value : void 0), `${A}.${$}.subjectCode`);
|
|
72
|
+
return c.has(M.value) && c.get(M.value) !== O && B(`${A}.${$}.subjectCode`, "同一课程不能对应不同学科"), c.set(M.value, O), M.custom !== void 0 && typeof M.custom != "boolean" && B(`${A}.${$}.custom`, "custom 必须是布尔值"), { value: M.value, label: M.label, subjectCode: O, ...M.custom === void 0 ? {} : { custom: M.custom } };
|
|
73
73
|
});
|
|
74
74
|
return [l.value, C];
|
|
75
|
-
})), a = n.filter((l) => i[l.value].length), y = e.defaultGradeCode === void 0 ? void 0 : z(e.defaultGradeCode, "dictionaries.defaultGradeCode"),
|
|
76
|
-
return { grades: a, gradeCourseMap: i, defaultGradeCode:
|
|
75
|
+
})), a = n.filter((l) => i[l.value].length), y = e.defaultGradeCode === void 0 ? void 0 : z(e.defaultGradeCode, "dictionaries.defaultGradeCode"), T = a.find((l) => l.value === y)?.value || a[0]?.value || "", m = e.defaultCourseCode === void 0 ? void 0 : z(e.defaultCourseCode, "dictionaries.defaultCourseCode"), f = i[T] || [], h = f.find((l) => l.value === m)?.value || f[0]?.value || "";
|
|
76
|
+
return { grades: a, gradeCourseMap: i, defaultGradeCode: T, defaultCourseCode: h };
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function dt(t, e, o) {
|
|
79
79
|
const n = t.grades.find((s) => s.value === e);
|
|
80
80
|
if (!n) return B("initialization.gradeCode", "年级不在可用字典中");
|
|
81
|
-
const
|
|
82
|
-
return
|
|
81
|
+
const r = t.gradeCourseMap[e]?.find((s) => s.value === o);
|
|
82
|
+
return r ? { grade: n.label, subject: r.label, gradeCode: e, courseCode: o, subjectCode: r.subjectCode, phaseCode: $t(n) } : B("initialization.courseCode", "当前年级没有此课程");
|
|
83
83
|
}
|
|
84
84
|
function Be(t, e = {}) {
|
|
85
|
-
const n = t.grades.find((c) => c.value === e.gradeCode || !e.gradeCode && c.label === e.grade)?.value || t.defaultGradeCode,
|
|
86
|
-
return n && s ?
|
|
85
|
+
const n = t.grades.find((c) => c.value === e.gradeCode || !e.gradeCode && c.label === e.grade)?.value || t.defaultGradeCode, r = t.gradeCourseMap[n] || [], s = r.find((c) => c.value === e.courseCode || !e.courseCode && c.label === e.subject)?.value || (n === t.defaultGradeCode ? t.defaultCourseCode : r[0]?.value) || "";
|
|
86
|
+
return n && s ? dt(t, n, s) : { grade: "", subject: "", gradeCode: "", courseCode: "" };
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function _t(t) {
|
|
89
89
|
return t?.subjectCode || ot[t?.subject || ""];
|
|
90
90
|
}
|
|
91
|
-
const W = { questions: 200, options: 12, score: 15 }, je = (t) => t.multiple ? t.indefinite ? "indefinite" : "multiple" : "single", v = (t) => Number.isFinite(t) && Number.isInteger(t * 2),
|
|
92
|
-
function
|
|
93
|
-
const e = typeof t.score == "number" && v(t.score) && t.score >= 0.5 && t.score <= W.score ? t.score : null,
|
|
91
|
+
const W = { questions: 200, options: 12, score: 15 }, je = (t) => t.multiple ? t.indefinite ? "indefinite" : "multiple" : "single", v = (t) => Number.isFinite(t) && Number.isInteger(t * 2), ht = (t) => !!(_t(t) === "MATHS" && (t?.phaseCode ? t.phaseCode === "S" : t?.gradeCode ? t.gradeCode.startsWith("S") : /^高[一二三]/.test(t?.grade || "")));
|
|
92
|
+
function Qt(t) {
|
|
93
|
+
const e = typeof t.score == "number" && v(t.score) && t.score >= 0.5 && t.score <= W.score ? t.score : null, o = [...new Set(t.correctIds)].filter((n) => t.options.some((r) => r.id === n));
|
|
94
94
|
return {
|
|
95
95
|
...t,
|
|
96
96
|
indefinite: !!(t.multiple && t.indefinite),
|
|
97
97
|
score: e,
|
|
98
98
|
scoreType: t.multiple && t.scoreType === "ITEM_SCORE" ? "ITEM_SCORE" : "LESS_SCORE",
|
|
99
99
|
lessScore: t.multiple && e !== null && v(t.lessScore ?? 0) ? Math.max(0, Math.min(e, t.lessScore ?? 0)) : 0,
|
|
100
|
-
correctIds: t.multiple ?
|
|
100
|
+
correctIds: t.multiple ? o : o.slice(0, 1)
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function Tt(t, e, o) {
|
|
104
104
|
let n = { ...t };
|
|
105
105
|
if (e.kind !== void 0) {
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
const r = e.kind !== "single";
|
|
107
|
+
r && !t.multiple && (n.scoreType = ht(o) ? "ITEM_SCORE" : "LESS_SCORE", typeof n.score != "number" && ht(o) && (n.score = 6)), n.multiple = r, n.indefinite = e.kind === "indefinite";
|
|
108
108
|
}
|
|
109
109
|
if (e.optionCount !== void 0) {
|
|
110
|
-
const
|
|
111
|
-
n.options = Array.from({ length:
|
|
110
|
+
const r = Math.max(2, Math.min(W.options, Math.round(e.optionCount)));
|
|
111
|
+
n.options = Array.from({ length: r }, (s, c) => t.options[c] || { id: crypto.randomUUID(), label: String.fromCharCode(65 + c) });
|
|
112
112
|
}
|
|
113
|
-
return e.score !== void 0 && (n.score = e.score), e.scoreType !== void 0 && (n.scoreType = e.scoreType), e.lessScore !== void 0 && (n.lessScore = e.lessScore),
|
|
113
|
+
return e.score !== void 0 && (n.score = e.score), e.scoreType !== void 0 && (n.scoreType = e.scoreType), e.lessScore !== void 0 && (n.lessScore = e.lessScore), Qt(n);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Dt(t) {
|
|
116
116
|
return typeof t.score == "number" && (!v(t.score) || t.score < 0.5 || t.score > W.score) ? "每题分值须为 0.5–15 分,按 0.5 分递增" : t.multiple && t.scoreType === "LESS_SCORE" && typeof t.score == "number" && (!v(t.lessScore ?? 0) || (t.lessScore ?? 0) < 0 || (t.lessScore ?? 0) > t.score) ? "少选得分须为 0.5 的倍数,且不能超过本题分值" : t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !v(t.score / t.correctIds.length) ? "答案个数与分值不匹配,每个正确选项的得分须为 0.5 的倍数" : null;
|
|
117
117
|
}
|
|
118
118
|
function Ge(t) {
|
|
119
|
-
return t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !
|
|
119
|
+
return t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !Dt(t) ? t.score / t.correctIds.length : null;
|
|
120
120
|
}
|
|
121
121
|
function Ue(t) {
|
|
122
|
-
const e = t.map((
|
|
123
|
-
let
|
|
124
|
-
const n = new Set(t.map((
|
|
125
|
-
for (; n.has(
|
|
126
|
-
return
|
|
122
|
+
const e = t.map((r) => Number(r.label)).filter((r) => Number.isSafeInteger(r) && r > 0 && r < 1e5);
|
|
123
|
+
let o = String(Math.max(0, ...e) + 1);
|
|
124
|
+
const n = new Set(t.map((r) => r.label));
|
|
125
|
+
for (; n.has(o); ) o = String(Number(o) + 1);
|
|
126
|
+
return o;
|
|
127
127
|
}
|
|
128
128
|
function Fe(t, e) {
|
|
129
|
-
const
|
|
129
|
+
const o = new Map(t.options.map((n) => [n.id, crypto.randomUUID()]));
|
|
130
130
|
return {
|
|
131
131
|
...t,
|
|
132
132
|
id: crypto.randomUUID(),
|
|
133
133
|
label: e,
|
|
134
134
|
breakBefore: !1,
|
|
135
135
|
contentTarget: null,
|
|
136
|
-
options: t.options.map((n) => ({ ...n, id:
|
|
137
|
-
correctIds: t.correctIds.map((n) =>
|
|
136
|
+
options: t.options.map((n) => ({ ...n, id: o.get(n.id) })),
|
|
137
|
+
correctIds: t.correctIds.map((n) => o.get(n)).filter(Boolean)
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
return
|
|
140
|
+
function Jt(t, e, o) {
|
|
141
|
+
return o.trim() ? t.some((n) => n.id !== e && n.label.trim() === o.trim()) ? "题组内题号不能重复" : null : "题号不能为空";
|
|
142
142
|
}
|
|
143
|
-
function Ke(t, e,
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
143
|
+
function Ke(t, e, o, n) {
|
|
144
|
+
const r = t.questions.filter((a) => e.includes(a.id));
|
|
145
|
+
if (!r.length) return { error: "请选择要修改的题目" };
|
|
146
146
|
let s;
|
|
147
|
-
if (
|
|
148
|
-
if (!Object.keys(
|
|
149
|
-
const { optionCount: a, score: y, lessScore:
|
|
147
|
+
if (o.type === "settings") {
|
|
148
|
+
if (!Object.keys(o.patch).length) return { error: "请设置需要修改的属性" };
|
|
149
|
+
const { optionCount: a, score: y, lessScore: T } = o.patch;
|
|
150
150
|
if (a !== void 0 && (!Number.isInteger(a) || a < 2 || a > W.options)) return { error: "选项个数须为 2–12 的整数" };
|
|
151
151
|
if (typeof y == "number" && (!v(y) || y < 0.5 || y > W.score)) return { error: "每题分值须为 0.5–15 分,按 0.5 分递增" };
|
|
152
|
-
if (
|
|
153
|
-
if (s =
|
|
154
|
-
} else if (
|
|
155
|
-
if (!Number.isInteger(
|
|
156
|
-
s =
|
|
157
|
-
} else if (
|
|
158
|
-
const a =
|
|
152
|
+
if (T !== void 0 && (!v(T) || T < 0)) return { error: "少选得分须为非负的 0.5 倍数" };
|
|
153
|
+
if (s = r.map((m) => Tt(m, o.patch, n)), T !== void 0 && s.some((m) => m.multiple && m.scoreType !== "ITEM_SCORE" && T > (m.score ?? 0))) return { error: "少选得分不能超过所选题目的分值" };
|
|
154
|
+
} else if (o.type === "numbering") {
|
|
155
|
+
if (!Number.isInteger(o.start) || o.start < 1 || o.start + r.length - 1 > 1e3) return { error: "连续题号须在 1–1000 内" };
|
|
156
|
+
s = r.map((a, y) => ({ ...a, label: String(o.start + y) }));
|
|
157
|
+
} else if (o.type === "average") {
|
|
158
|
+
const a = o.total / r.length;
|
|
159
159
|
if (!v(a) || a < 0.5 || a > W.score) return { error: "总分无法平均分配,每题须为 0.5–15 分且为 0.5 的倍数" };
|
|
160
|
-
s =
|
|
160
|
+
s = r.map((y) => Tt(y, { score: a }));
|
|
161
161
|
} else {
|
|
162
|
-
const a =
|
|
163
|
-
if (a.length !==
|
|
162
|
+
const a = o.text.toUpperCase().trim().split(/[\s,,;;]+/).filter(Boolean);
|
|
163
|
+
if (a.length !== r.length) return { error: `需要 ${r.length} 组答案,当前为 ${a.length} 组` };
|
|
164
164
|
s = [];
|
|
165
|
-
for (let y = 0; y <
|
|
166
|
-
const
|
|
167
|
-
if (m !== "-" && (!/^[A-T]+$/.test(m) || new Set(m).size !== m.length || [...m].some((
|
|
168
|
-
const f = m === "-" ? [] : [...m].map((
|
|
169
|
-
if (!
|
|
170
|
-
s.push({ ...
|
|
165
|
+
for (let y = 0; y < r.length; y++) {
|
|
166
|
+
const T = r[y], m = a[y];
|
|
167
|
+
if (m !== "-" && (!/^[A-T]+$/.test(m) || new Set(m).size !== m.length || [...m].some((h) => !T.options.some((l) => l.label === h)))) return { error: `第 ${T.label} 题包含无效或重复选项` };
|
|
168
|
+
const f = m === "-" ? [] : [...m].map((h) => T.options.find((l) => l.label === h).id);
|
|
169
|
+
if (!T.multiple && f.length > 1) return { error: `第 ${T.label} 题为单选,只能设置一个答案` };
|
|
170
|
+
s.push({ ...T, correctIds: f });
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
const c = new Map(s.map((a) => [a.id, a])), i = t.questions.map((a) => c.get(a.id) || a);
|
|
174
174
|
for (const a of s) {
|
|
175
|
-
const y =
|
|
175
|
+
const y = Jt(i, a.id, a.label) || Dt(a);
|
|
176
176
|
if (y) return { error: `第 ${a.label} 题:${y}` };
|
|
177
177
|
}
|
|
178
178
|
return { value: { ...t, questions: i } };
|
|
179
179
|
}
|
|
180
|
-
const
|
|
181
|
-
function ve(t, e,
|
|
182
|
-
const n =
|
|
180
|
+
const Xt = { layout: "natural", columns: 2, indent: !1, rowGap: 0, columnGap: 32, marker: "letter" }, St = (t) => `question:${t}`, Yt = (t) => t.presentation === "stem" ? "stem" : ["option", "distributed"].includes(t.presentation) ? "option" : "concentrated";
|
|
181
|
+
function ve(t, e, o) {
|
|
182
|
+
const n = xt(e), r = /* @__PURE__ */ new Map(), s = (i, a) => {
|
|
183
183
|
const y = i.attrs?.contentId || a;
|
|
184
|
-
i.type === "choiceGroup" && y &&
|
|
184
|
+
i.type === "choiceGroup" && y && r.set(i.attrs.id, y), i.content?.forEach((T) => s(T, y));
|
|
185
185
|
};
|
|
186
186
|
s(e.content);
|
|
187
187
|
const c = new Set(t.questions.map((i) => i.contentTarget?.groupId));
|
|
188
|
-
return { ...t, presentation:
|
|
189
|
-
const y = n.find((
|
|
190
|
-
return
|
|
188
|
+
return { ...t, presentation: o, questions: t.questions.map((i, a) => {
|
|
189
|
+
const y = n.find((T) => r.get(T.id) === i.id) || (r.size ? void 0 : n[a]);
|
|
190
|
+
return o === "concentrated" || i.contentTarget !== void 0 || !y || c.has(y.id) ? i : (c.add(y.id), { ...i, contentTarget: { groupId: y.id, optionIds: y.options.map((T) => T.id) } });
|
|
191
191
|
}) };
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
const n =
|
|
195
|
-
const l = f.attrs?.contentId ||
|
|
193
|
+
function Zt(t, e, o) {
|
|
194
|
+
const n = Yt(t), r = new Map(xt(e).map((f) => [f.id, f])), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = (f, h) => {
|
|
195
|
+
const l = f.attrs?.contentId || h;
|
|
196
196
|
f.type === "choiceGroup" && l && (c.set(l, [...c.get(l) || [], f.attrs.id]), i.set(f.attrs.id, l)), f.type === "choiceStemAnchor" && typeof f.attrs?.groupId == "string" && s.add(f.attrs.groupId), f.content?.forEach((u) => a(u, l));
|
|
197
197
|
};
|
|
198
198
|
a(e.content);
|
|
199
|
-
const y = [],
|
|
200
|
-
if (!
|
|
201
|
-
if (n === "stem" && s.has(
|
|
202
|
-
return y.push({ groupId:
|
|
203
|
-
const
|
|
204
|
-
if (!u || !g ||
|
|
199
|
+
const y = [], T = /* @__PURE__ */ new Set(), m = t.questions.filter((f) => {
|
|
200
|
+
if (!o || n === "concentrated") return !0;
|
|
201
|
+
if (n === "stem" && s.has(St(f.id)))
|
|
202
|
+
return y.push({ groupId: St(f.id), questionId: f.id, options: f.options.map((C) => ({ ...C, contentOptionId: C.id })) }), !1;
|
|
203
|
+
const h = c.get(f.id), l = h?.length === 1 ? r.get(h[0]) : void 0, u = l ? { groupId: l.id, optionIds: l.options.map((C) => C.id) } : f.contentTarget, g = u && r.get(u.groupId);
|
|
204
|
+
if (!u || !g || T.has(g.id) || n === "stem" && !s.has(g.id) || i.has(g.id) && i.get(g.id) !== f.id) return !0;
|
|
205
205
|
const A = u.optionIds.slice(0, f.options.length);
|
|
206
|
-
return A.length !== f.options.length || new Set(A).size !== A.length || A.some((C) => !g.options.some((
|
|
206
|
+
return A.length !== f.options.length || new Set(A).size !== A.length || A.some((C) => !g.options.some((M) => M.id === C)) ? !0 : (T.add(g.id), y.push({ groupId: g.id, questionId: f.id, options: f.options.map((C, M) => ({ ...C, contentOptionId: A[M] })) }), !1);
|
|
207
207
|
});
|
|
208
208
|
return { position: n === "concentrated" ? void 0 : n, bindings: y, concentrated: { ...t, questions: m } };
|
|
209
209
|
}
|
|
@@ -218,10 +218,10 @@ function at(t, e = 4) {
|
|
|
218
218
|
lessScore: 0,
|
|
219
219
|
correctIds: [],
|
|
220
220
|
breakBefore: !1,
|
|
221
|
-
options: Array.from({ length: e }, (
|
|
221
|
+
options: Array.from({ length: e }, (o, n) => ({ id: crypto.randomUUID(), label: String.fromCharCode(65 + n) }))
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function qt(t = 8) {
|
|
225
225
|
return {
|
|
226
226
|
source: "manual",
|
|
227
227
|
presentation: "concentrated",
|
|
@@ -230,27 +230,27 @@ function te(t = 8) {
|
|
|
230
230
|
marker: "box",
|
|
231
231
|
rowGap: 0,
|
|
232
232
|
columnGap: 0,
|
|
233
|
-
questions: Array.from({ length: t }, (e,
|
|
233
|
+
questions: Array.from({ length: t }, (e, o) => at(o))
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
function ze(t) {
|
|
237
237
|
return new Set(t.questions.map((e) => e.options.length)).size > 1 ? "column" : t.direction;
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function te(t) {
|
|
240
240
|
const e = [];
|
|
241
|
-
for (const
|
|
241
|
+
for (const o of t.questions) {
|
|
242
242
|
const n = e.at(-1);
|
|
243
|
-
(!n || n.length >= t.rowsPerColumn ||
|
|
243
|
+
(!n || n.length >= t.rowsPerColumn || o.breakBefore || n[0].options.length !== o.options.length) && e.push([]), e[e.length - 1].push(o);
|
|
244
244
|
}
|
|
245
245
|
return e;
|
|
246
246
|
}
|
|
247
247
|
function We(t) {
|
|
248
248
|
const e = [];
|
|
249
|
-
for (const
|
|
250
|
-
(!e.length ||
|
|
249
|
+
for (const o of te(t))
|
|
250
|
+
(!e.length || o[0].breakBefore) && e.push([]), e[e.length - 1].push(o);
|
|
251
251
|
return e;
|
|
252
252
|
}
|
|
253
|
-
const
|
|
253
|
+
const ee = {
|
|
254
254
|
judge: "判断题",
|
|
255
255
|
fill: "填空题",
|
|
256
256
|
answer: "解答题",
|
|
@@ -269,23 +269,23 @@ const ne = {
|
|
|
269
269
|
composite: "材料/复合题",
|
|
270
270
|
optional: "选做题组",
|
|
271
271
|
practice: "实践评价"
|
|
272
|
-
}, Ve = { choice: "选择", judge: "判断", fill: "填空", answer: "简答", calculation: "计算/证明", correction: "改错", drawing: "作图", table: "表格", writing: "作文", english: "外语写作" }, Qe = ["reading", "cloze", "completion", "composite", "optional"], j = () => ({ version: 1, content: { type: "doc", content: [{ type: "paragraph" }] } }), Je = { symbols: ["√", "×"], letters: ["T", "F"], words: ["正确", "错误"] },
|
|
273
|
-
function
|
|
272
|
+
}, Ve = { choice: "选择", judge: "判断", fill: "填空", answer: "简答", calculation: "计算/证明", correction: "改错", drawing: "作图", table: "表格", writing: "作文", english: "外语写作" }, Qe = ["reading", "cloze", "completion", "composite", "optional"], j = () => ({ version: 1, content: { type: "doc", content: [{ type: "paragraph" }] } }), Je = { symbols: ["√", "×"], letters: ["T", "F"], words: ["正确", "错误"] }, ne = (t) => ["writing", "english"].includes(t) ? 70 : ["answer", "calculation", "drawing", "table", "correction"].includes(t) ? 60 : 15, Xe = (t) => t === "judge" ? 200 : t === "fill" ? 50 : ["reading", "cloze", "completion"].includes(t) ? 20 : t === "matching" ? 9 : 100;
|
|
273
|
+
function oe(t = 0) {
|
|
274
274
|
return { id: crypto.randomUUID(), label: String(t + 1), width: 50, style: "line", characters: 6, score: null, answers: [], prefix: "", suffix: "", breakAfter: !1 };
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
276
|
+
function re(t, e = "1") {
|
|
277
|
+
const o = crypto.randomUUID();
|
|
278
278
|
return {
|
|
279
|
-
id:
|
|
279
|
+
id: o,
|
|
280
280
|
label: e,
|
|
281
281
|
kind: t,
|
|
282
282
|
document: j(),
|
|
283
283
|
reference: j(),
|
|
284
284
|
explanation: j(),
|
|
285
285
|
score: null,
|
|
286
|
-
choice: { ...at(0, t === "judge" ? 2 : 4), id:
|
|
286
|
+
choice: { ...at(0, t === "judge" ? 2 : 4), id: o, label: e },
|
|
287
287
|
presentation: "concentrated",
|
|
288
|
-
blanks: [
|
|
288
|
+
blanks: [oe()],
|
|
289
289
|
steps: [],
|
|
290
290
|
needsReason: !1,
|
|
291
291
|
judgment: null,
|
|
@@ -293,12 +293,12 @@ function ie(t, e = "1") {
|
|
|
293
293
|
area: { style: t === "writing" ? "characters" : t === "english" ? "lines" : t === "drawing" ? "grid" : "blank", rows: t === "writing" ? 20 : 6, columns: 20, rowHeight: t === "writing" ? 40 : 28, wordMark: 100, title: !1, backgroundUrl: "" }
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function ie(t) {
|
|
297
297
|
return ["reading", "cloze", "chunk"].includes(t) ? "choice" : ["matching", "completion"].includes(t) ? "fill" : ["ordering", "composite", "optional", "practice"].includes(t) ? "answer" : t;
|
|
298
298
|
}
|
|
299
299
|
function Ye(t) {
|
|
300
300
|
return {
|
|
301
|
-
items: [ie(
|
|
301
|
+
items: [re(ie(t))],
|
|
302
302
|
judgeLabels: "symbols",
|
|
303
303
|
fillNewLine: !0,
|
|
304
304
|
pool: [],
|
|
@@ -322,63 +322,63 @@ function Ye(t) {
|
|
|
322
322
|
function Ze(t) {
|
|
323
323
|
return String(Math.max(0, ...t.map((e) => /^\d+$/.test(e.label) ? Number(e.label) : 0)) + 1);
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
const e = structuredClone(t),
|
|
325
|
+
function kt(t) {
|
|
326
|
+
const e = structuredClone(t), o = /* @__PURE__ */ new Map(), n = (s) => {
|
|
327
327
|
!s || typeof s != "object" || Object.entries(s).forEach(([c, i]) => {
|
|
328
|
-
["id", "answerId"].includes(c) && typeof i == "string" ?
|
|
328
|
+
["id", "answerId"].includes(c) && typeof i == "string" ? o.set(i, crypto.randomUUID()) : n(i);
|
|
329
329
|
});
|
|
330
330
|
};
|
|
331
331
|
n(e);
|
|
332
|
-
const
|
|
333
|
-
return
|
|
332
|
+
const r = (s) => typeof s == "string" ? o.get(s) || s : Array.isArray(s) ? s.map(r) : s && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([c, i]) => [o.get(c) || c, r(i)])) : s;
|
|
333
|
+
return r(e);
|
|
334
334
|
}
|
|
335
335
|
function qe(t, e) {
|
|
336
|
-
const
|
|
337
|
-
return { ...
|
|
336
|
+
const o = kt(t);
|
|
337
|
+
return { ...o, label: e, choice: { ...o.choice, label: e } };
|
|
338
338
|
}
|
|
339
|
-
function tn(t, e,
|
|
340
|
-
const n = t.findIndex((c) => c.id === e),
|
|
341
|
-
if (n < 0 ||
|
|
339
|
+
function tn(t, e, o) {
|
|
340
|
+
const n = t.findIndex((c) => c.id === e), r = n + o;
|
|
341
|
+
if (n < 0 || r < 0 || r >= t.length) return t;
|
|
342
342
|
const s = [...t];
|
|
343
|
-
return s.splice(
|
|
343
|
+
return s.splice(r, 0, ...s.splice(n, 1)), s;
|
|
344
344
|
}
|
|
345
345
|
function en(t, e) {
|
|
346
|
-
return { ...t, pool: t.pool.filter((
|
|
346
|
+
return { ...t, pool: t.pool.filter((o) => o.id !== e), sequence: t.sequence.filter((o) => o !== e), assignments: Object.fromEntries(Object.entries(t.assignments).filter(([o]) => o !== e)), items: t.items.map((o) => ({ ...o, targets: o.targets.filter((n) => n !== e) })) };
|
|
347
347
|
}
|
|
348
|
-
function nn(t, e,
|
|
349
|
-
const n = [...new Set(
|
|
350
|
-
return { ...t, items: t.items.map((s) => s.id === e ? { ...s, targets:
|
|
348
|
+
function nn(t, e, o) {
|
|
349
|
+
const n = [...new Set(o)].filter((s) => t.pool.some((c) => c.id === s)), r = t.relation === "one" ? n.slice(-1) : n;
|
|
350
|
+
return { ...t, items: t.items.map((s) => s.id === e ? { ...s, targets: r } : t.reuseOptions ? s : { ...s, targets: s.targets.filter((c) => !r.includes(c)) }) };
|
|
351
351
|
}
|
|
352
352
|
function on(t, e) {
|
|
353
|
-
let
|
|
354
|
-
for (;
|
|
353
|
+
let o = 0;
|
|
354
|
+
for (; o < e.length && o < t.chunkText.length && e[o] === t.chunkText[o]; ) o++;
|
|
355
355
|
let n = 0;
|
|
356
|
-
for (; n < e.length -
|
|
357
|
-
const
|
|
356
|
+
for (; n < e.length - o && n < t.chunkText.length - o && e[e.length - 1 - n] === t.chunkText[t.chunkText.length - 1 - n]; ) n++;
|
|
357
|
+
const r = t.chunkText.length - n, s = /* @__PURE__ */ new Set(), c = t.chunkPoints.filter((i) => i.offset <= o || i.offset >= r).map((i) => ({ ...i, offset: i.offset <= o ? i.offset : i.offset + e.length - t.chunkText.length })).filter((i) => i.offset <= 0 || i.offset >= e.length || s.has(i.offset) ? !1 : (s.add(i.offset), !0));
|
|
358
358
|
return { ...t, chunkText: e, chunkPoints: c, chunkCorrect: t.chunkCorrect.filter((i) => c.some((a) => a.id === i)) };
|
|
359
359
|
}
|
|
360
360
|
function rn(t, e) {
|
|
361
|
-
const
|
|
362
|
-
(n.some((
|
|
363
|
-
for (const
|
|
364
|
-
|
|
365
|
-
const c = (
|
|
366
|
-
c.length &&
|
|
361
|
+
const o = [], n = t.items.map((r) => r.label.trim());
|
|
362
|
+
(n.some((r) => !r) || new Set(n).size !== n.length) && o.push("题号不能为空或重复");
|
|
363
|
+
for (const r of t.items) {
|
|
364
|
+
r.score !== null && (!Number.isFinite(r.score) || r.score < 0.5 || r.score > ne(r.kind) || !Number.isInteger(r.score * 2)) && o.push(`${r.label} 题分值超出范围或不是 0.5 的倍数`);
|
|
365
|
+
const c = (r.kind === "fill" ? r.blanks : r.steps).map((i) => i.score);
|
|
366
|
+
c.length && r.score !== null && c.every((i) => i !== null) && c.reduce((i, a) => i + (a || 0), 0) !== r.score && o.push(`${r.label} 题分项分值之和与题分不一致`);
|
|
367
367
|
}
|
|
368
368
|
if (["matching", "ordering"].includes(e)) {
|
|
369
|
-
const
|
|
370
|
-
(
|
|
369
|
+
const r = t.pool.map((s) => s.label.trim());
|
|
370
|
+
(r.some((s) => !s) || new Set(r).size !== r.length) && o.push("共享选项编号不能为空或重复");
|
|
371
371
|
}
|
|
372
|
-
return e === "optional" && t.chooseCount > t.items.length &&
|
|
372
|
+
return e === "optional" && t.chooseCount > t.items.length && o.push("选做数量不能超过题目数量"), e === "chunk" && t.chunkCorrect.length > t.chunkMax && o.push("正确断点数不能超过最多选择数"), o;
|
|
373
373
|
}
|
|
374
374
|
function sn(t = 3, e = 3) {
|
|
375
375
|
return { version: 1, content: { type: "doc", content: [{ type: "table", content: Array.from({ length: t }, () => ({ type: "tableRow", content: Array.from({ length: e }, () => ({ type: "tableCell", content: [{ type: "paragraph" }] })) })) }] } };
|
|
376
376
|
}
|
|
377
377
|
function J(t) {
|
|
378
|
-
const e = (
|
|
378
|
+
const e = (o) => !!(o.text || o.type && !["doc", "paragraph", "choiceStemAnchor"].includes(o.type) || o.content?.some(e));
|
|
379
379
|
return !e(t.content);
|
|
380
380
|
}
|
|
381
|
-
const cn = { choice: "选择题", area: "空白区域", ...
|
|
381
|
+
const cn = { choice: "选择题", area: "空白区域", ...ee };
|
|
382
382
|
function an(t) {
|
|
383
383
|
return {
|
|
384
384
|
id: crypto.randomUUID(),
|
|
@@ -389,10 +389,10 @@ function an(t) {
|
|
|
389
389
|
document: { version: 1, content: { type: "doc", content: t === "forbiden" ? ["请勿在此区域作答", "或者做任何标记"].map((e) => ({ type: "paragraph", attrs: { textAlign: "center", lineSpacing: 0 }, content: [{ type: "text", text: e }] })) : [{ type: "paragraph" }] } }
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
function
|
|
393
|
-
return { version: 1, title: "", questionCard: !1, preset: "a3-two", margin: 15, gap: 10, blocks: [] };
|
|
392
|
+
function se() {
|
|
393
|
+
return { version: 1, title: "", questionCard: !1, duplex: !1, preset: "a3-two", margin: 15, gap: 10, blocks: [] };
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function ce(t = "") {
|
|
396
396
|
return {
|
|
397
397
|
// 22px title + the configured 9mm line spacing + 10px bottom inset.
|
|
398
398
|
id: crypto.randomUUID(),
|
|
@@ -404,104 +404,104 @@ function ae(t = "") {
|
|
|
404
404
|
}] } }
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function ae(t) {
|
|
408
408
|
return {
|
|
409
|
-
...
|
|
409
|
+
...se(),
|
|
410
410
|
title: t.name,
|
|
411
411
|
creation: t,
|
|
412
|
-
paperTitle:
|
|
412
|
+
paperTitle: ce(t.name),
|
|
413
413
|
header: { focusText: !0, writeKaohao: !1, missExam: !1, mifeng: !1, kaohao: "school", weishu: 8 }
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
function Q(t, e = 96) {
|
|
417
417
|
return t * e / 25.4;
|
|
418
418
|
}
|
|
419
|
-
const
|
|
419
|
+
const le = {
|
|
420
420
|
a4: { label: "A4 单栏", width: 210, height: 297, columns: 1 },
|
|
421
421
|
"a3-two": { label: "A3 双栏", width: 420, height: 297, columns: 2 },
|
|
422
422
|
"a3-three": { label: "A3 三栏", width: 420, height: 297, columns: 3 }
|
|
423
|
-
}, et = 44, it = 16,
|
|
424
|
-
function
|
|
425
|
-
const
|
|
426
|
-
return { ...
|
|
427
|
-
}
|
|
428
|
-
function ln(t, e,
|
|
429
|
-
const n =
|
|
430
|
-
let
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
},
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
const
|
|
437
|
-
return
|
|
423
|
+
}, et = 44, it = 16, ue = (t) => t.duplex === !0 ? 2 : 1;
|
|
424
|
+
function Ct(t, e) {
|
|
425
|
+
const o = le[t.preset], n = Q(o.width), r = Q(o.height), s = Q(t.margin), c = Q(t.gap), i = t.usage !== "homework" && t.header?.mifeng ? Q(t.header.kaohao === "code" ? 26 : 14) : 0, a = n - s * 2 - i, y = (a - c * (o.columns - 1)) / o.columns, T = Math.max(s, t.header ? t.recognition?.examQrCode ? 64 : 39 : 0), m = Math.max(s, t.header ? 56 : 0), f = r - T - m, h = f - it, l = t.header ? y : a, u = e && e.id === t.paperTitle?.id && Math.abs(e.width - l) < 1 ? e : void 0, g = t.paperTitle ? Math.min(f, u?.height ?? t.paperTitle.height + (t.header ? 260 : it)) : 0, A = (b, O = 0) => !!t.paperTitle && (t.header ? b % 2 === 0 && O === 0 : b === 0), C = (b, O = 0) => A(b, O) ? g : 0;
|
|
426
|
+
return { ...o, width: n, height: r, margin: s, topInset: T, bottomInset: m, gap: c, sealWidth: i, contentWidth: a, contentHeight: f, columnWidth: y, columnX: (b, O) => s + (b % 2 === 0 ? i : 0) + O * (y + c), titleWidth: l, titleMaxHeight: h, hasHeader: A, headerHeight: C, capacity: (b, O = 0) => f - C(b, O) };
|
|
427
|
+
}
|
|
428
|
+
function ln(t, e, o) {
|
|
429
|
+
const n = Ct(t, o), r = ue(t);
|
|
430
|
+
let s = 0, c = 0, i = 0;
|
|
431
|
+
const a = () => {
|
|
432
|
+
c++, c === n.columns && (c = 0, s++), i = 0;
|
|
433
|
+
}, y = t.blocks.map((m) => {
|
|
434
|
+
const f = e[m.id], h = f && Math.abs(f.width - n.columnWidth) < 1 ? f.height : 100 + m.answerHeight, l = f && Math.abs(f.width - n.columnWidth) < 1 ? [...new Set([...f.breaks || [], h].filter((b) => Number.isFinite(b) && b > 0 && b <= h))].sort((b, O) => b - O) : [], u = m.reference?.type === "CCOMPOSITION", g = (b) => u && b > 0 ? Math.max(0, 6 - Math.max(0, (f?.compositionStart || 0) - b)) : 0;
|
|
435
|
+
if (l.length > 1 && l.every((b, O) => {
|
|
436
|
+
const p = l[O - 1] || 0;
|
|
437
|
+
return b - p + g(p) <= n.capacity(1) + 0.5;
|
|
438
438
|
})) {
|
|
439
|
-
const
|
|
440
|
-
let
|
|
441
|
-
for (;
|
|
442
|
-
const
|
|
443
|
-
if (
|
|
444
|
-
|
|
439
|
+
const b = [];
|
|
440
|
+
let O = 0;
|
|
441
|
+
for (; O < h - 0.5; ) {
|
|
442
|
+
const E = n.capacity(s, c) - i, d = O, I = g(O), w = (L) => f?.markingFrames?.some((_) => _.from >= d - 0.5 && _.from < L - 0.5 && _.to > L + 0.5) ? 22 : 0, S = l.filter((L) => L > d + 0.5 && L + w(L) <= d + E - I + 0.5).at(-1);
|
|
443
|
+
if (S === void 0) {
|
|
444
|
+
a();
|
|
445
445
|
continue;
|
|
446
446
|
}
|
|
447
|
-
const
|
|
448
|
-
|
|
447
|
+
const N = u && S < h - 0.5 ? Math.max(w(S), E - I - (S - O)) : w(S);
|
|
448
|
+
b.push({ page: s, column: c, x: n.columnX(s, c), y: s * (n.height + et) + n.topInset + n.headerHeight(s, c) + i, from: O, to: S, ...I ? { topPadding: I } : {}, ...N ? { bottomPadding: N } : {} }), i += S - O + I, O = S, O < h - 0.5 && a();
|
|
449
449
|
}
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
return { id:
|
|
450
|
+
i += it;
|
|
451
|
+
const p = b[0];
|
|
452
|
+
return { id: m.id, ...p, height: h, available: n.capacity(p.page, p.column), overflowing: !1, fragments: b };
|
|
453
453
|
}
|
|
454
|
-
for (;
|
|
455
|
-
const
|
|
456
|
-
id:
|
|
457
|
-
page:
|
|
458
|
-
column:
|
|
459
|
-
x: n.columnX(
|
|
460
|
-
y:
|
|
461
|
-
height:
|
|
462
|
-
available:
|
|
463
|
-
overflowing:
|
|
464
|
-
fragments: [{ page:
|
|
454
|
+
for (; i + h > n.capacity(s, c) + 0.5 && (i > 0 || n.headerHeight(s, c) > 0); ) a();
|
|
455
|
+
const C = n.capacity(s, c), M = h > C + 0.5, $ = {
|
|
456
|
+
id: m.id,
|
|
457
|
+
page: s,
|
|
458
|
+
column: c,
|
|
459
|
+
x: n.columnX(s, c),
|
|
460
|
+
y: s * (n.height + et) + n.topInset + n.headerHeight(s, c) + i,
|
|
461
|
+
height: h,
|
|
462
|
+
available: C,
|
|
463
|
+
overflowing: M,
|
|
464
|
+
fragments: [{ page: s, column: c, x: n.columnX(s, c), y: s * (n.height + et) + n.topInset + n.headerHeight(s, c) + i, from: 0, to: Math.min(h, C) }]
|
|
465
465
|
};
|
|
466
|
-
return
|
|
467
|
-
}),
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
})),
|
|
472
|
-
const
|
|
473
|
-
if (!
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
466
|
+
return i += Math.min(h, C) + it, $;
|
|
467
|
+
}), T = /* @__PURE__ */ new Map();
|
|
468
|
+
y.forEach((m, f) => m.fragments.forEach((h) => {
|
|
469
|
+
const l = `${h.page}/${h.column}`, u = T.get(l) || [];
|
|
470
|
+
u.push({ fragment: h, placement: m, blockIndex: f }), T.set(l, u);
|
|
471
|
+
})), T.forEach((m) => {
|
|
472
|
+
const f = m.filter((g) => ["answer", "writing", "english", "composite", "area"].includes(t.blocks[g.blockIndex].kind)).at(-1);
|
|
473
|
+
if (!f || t.blocks[f.blockIndex].reference?.type !== "CCOMPOSITION" && t.blocks[f.blockIndex].kind !== "area") return;
|
|
474
|
+
const h = m.at(-1).fragment, u = h.page * (n.height + et) + n.height - n.bottomInset - h.y - (h.to - h.from) - (h.topPadding || 0) - (h.bottomPadding || 0);
|
|
475
|
+
u <= 0 || u > 30 || (f.fragment.bottomPadding = (f.fragment.bottomPadding || 0) + u, m.slice(m.indexOf(f) + 1).forEach(({ fragment: g, placement: A }) => {
|
|
476
|
+
g.y += u, A.fragments[0] === g && (A.y = g.y);
|
|
477
477
|
}));
|
|
478
478
|
});
|
|
479
|
-
for (const
|
|
480
|
-
(
|
|
481
|
-
return { geometry: n, placements:
|
|
479
|
+
for (const m of y)
|
|
480
|
+
(m.overflowing || m.fragments.some((f) => f.page >= r)) && (m.overflowFrom = m.fragments.filter((f) => f.page < r).at(-1)?.to || 0);
|
|
481
|
+
return { geometry: n, placements: y, pageCount: Math.min(r, s + 1), requiredPageCount: s + 1 };
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function pt(t, e) {
|
|
484
484
|
return { version: 1, content: { type: "doc", content: [{ type: "paragraph", content: [
|
|
485
485
|
{ type: "text", text: `${t}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] },
|
|
486
486
|
...e ? [{ type: "text", text: `(${e}分)`, marks: [{ type: "documentLabel", attrs: { kind: "score" } }] }] : []
|
|
487
487
|
] }] } };
|
|
488
488
|
}
|
|
489
|
-
function st(t, e,
|
|
490
|
-
const n = (
|
|
491
|
-
if (!
|
|
489
|
+
function st(t, e, o) {
|
|
490
|
+
const n = (r) => {
|
|
491
|
+
if (!r.content) return r;
|
|
492
492
|
let s;
|
|
493
|
-
const c =
|
|
494
|
-
const y = a.type === "text" && a.marks?.find((f) => f.type === "documentLabel")?.attrs?.kind,
|
|
495
|
-
if (s = y,
|
|
493
|
+
const c = r.content.flatMap((a) => {
|
|
494
|
+
const y = a.type === "text" && a.marks?.find((f) => f.type === "documentLabel")?.attrs?.kind, T = y && y === s;
|
|
495
|
+
if (s = y, T) return [];
|
|
496
496
|
if (!y) return [n(a)];
|
|
497
|
-
const m = y === "number" ? `${e}.` :
|
|
497
|
+
const m = y === "number" ? `${e}.` : o ? `(${o}分)` : "";
|
|
498
498
|
return m ? [{ ...a, text: m }] : [];
|
|
499
499
|
}), i = c.findIndex((a) => a.marks?.some((y) => y.type === "documentLabel" && y.attrs?.kind === "number"));
|
|
500
|
-
return
|
|
500
|
+
return o && i >= 0 && !c.some((a) => a.marks?.some((y) => y.type === "documentLabel" && y.attrs?.kind === "score")) && c.splice(i + 1, 0, { type: "text", text: `(${o}分)`, marks: [{ type: "documentLabel", attrs: { kind: "score" } }] }), { ...r, content: c };
|
|
501
501
|
};
|
|
502
502
|
return { ...t, content: n(t.content) };
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const It = {
|
|
505
505
|
SCHOICE: "单选题",
|
|
506
506
|
MCHOICE: "多选题",
|
|
507
507
|
JUDGE: "判断题",
|
|
@@ -515,83 +515,83 @@ const yt = {
|
|
|
515
515
|
ECOMPOSITION: "英语作文",
|
|
516
516
|
CCOMPOSITION: "语文作文",
|
|
517
517
|
CHUNK_CHOICE: "断句题"
|
|
518
|
-
},
|
|
518
|
+
}, At = ["SCHOICE", "MCHOICE", "JUDGE", "FILLBLANK", "SHORTANSWER", "MIXED"];
|
|
519
519
|
function un(t, e = !1) {
|
|
520
|
-
const
|
|
521
|
-
return e ? ["CHINESE", "JAPANESE"].includes(
|
|
520
|
+
const o = _t(t), n = e ? At.filter((r) => r !== "MIXED") : At;
|
|
521
|
+
return e ? ["CHINESE", "JAPANESE"].includes(o || "") ? [...n, "CHUNK_CHOICE"] : n : o === "CHINESE" ? [...n, "CCOMPOSITION", "CHUNK_CHOICE"] : o === "ENGLISH" ? [...n, "CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION", "ECOMPOSITION"] : o === "JAPANESE" ? Object.keys(It) : ["POLITICAL", "HISTORY"].includes(o || "") ? [...n, "CCOMPOSITION"] : n;
|
|
522
522
|
}
|
|
523
523
|
const fe = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t), de = (t) => ["SCHOICE", "MCHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING", "JUDGE"].includes(t), Z = (t) => ({ version: 1, content: { type: "doc", content: t.length ? t : [{ type: "paragraph" }] } });
|
|
524
|
-
function
|
|
524
|
+
function Pt(t, e, o = !1) {
|
|
525
525
|
return {
|
|
526
526
|
content: j(),
|
|
527
|
-
numbered: !
|
|
527
|
+
numbered: !o,
|
|
528
528
|
groupId: `options:${e.id}`,
|
|
529
|
-
layout: { ...
|
|
530
|
-
itemsContent: !
|
|
529
|
+
layout: { ...Xt, columns: t === "CLOZE" ? 4 : 2, ...t === "READTHENANSWER" ? { layout: "fixed", columnGap: 0 } : {} },
|
|
530
|
+
itemsContent: !o && de(t) ? e.options.map((n) => ({ id: n.id, key: n.label, content: j() })) : []
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
533
|
const ct = (t) => {
|
|
534
534
|
if (t.type === "choiceStemAnchor" || t.type === "text" && t.marks?.some((n) => n.type === "documentLabel" && n.attrs?.kind === "number")) return null;
|
|
535
|
-
const { contentId: e, ...
|
|
536
|
-
return { ...t, ...t.attrs ? { attrs:
|
|
535
|
+
const { contentId: e, ...o } = t.attrs || {};
|
|
536
|
+
return { ...t, ...t.attrs ? { attrs: o } : {}, ...t.content ? { content: t.content.map(ct).filter((n) => n !== null) } : {} };
|
|
537
537
|
};
|
|
538
|
-
function
|
|
539
|
-
const
|
|
538
|
+
function Ot(t, e, o) {
|
|
539
|
+
const r = (t.content.content.content || [{ type: "paragraph" }]).map((s) => ({ ...s, attrs: { ...s.attrs, contentId: e } }));
|
|
540
540
|
if (t.numbered) {
|
|
541
|
-
const s = { type: "text", text: `${
|
|
542
|
-
["paragraph", "heading"].includes(
|
|
541
|
+
const s = { type: "text", text: `${o}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] };
|
|
542
|
+
["paragraph", "heading"].includes(r[0]?.type || "") || r.unshift({ type: "paragraph", attrs: { contentId: e }, content: [] }), r[0] = { ...r[0], content: [s, ...r[0].content || []] };
|
|
543
543
|
}
|
|
544
|
-
return t.itemsContent.length &&
|
|
544
|
+
return t.itemsContent.length && r.push({ type: "choiceGroup", attrs: { id: t.groupId, contentId: e, ...t.layout }, content: t.itemsContent.map((s) => ({
|
|
545
545
|
type: "choiceOption",
|
|
546
546
|
attrs: { id: s.id, label: s.key, sourceKey: s.key, marker: "letter" },
|
|
547
547
|
content: s.content.content.content || [{ type: "paragraph" }]
|
|
548
|
-
})) }),
|
|
548
|
+
})) }), r;
|
|
549
549
|
}
|
|
550
550
|
function he(t, e) {
|
|
551
|
-
const
|
|
551
|
+
const o = e.filter((i) => i.type === "choiceGroup"), n = o.find((i) => i.attrs?.id === t.groupId) || (o.length === 1 ? o[0] : void 0), r = e.filter((i) => i !== n);
|
|
552
552
|
let s = !1;
|
|
553
553
|
const c = (i) => {
|
|
554
554
|
i.marks?.some((a) => a.type === "documentLabel" && a.attrs?.kind === "number") && (s = !0), i.content?.forEach(c);
|
|
555
555
|
};
|
|
556
|
-
return
|
|
556
|
+
return r.forEach(c), {
|
|
557
557
|
...t,
|
|
558
558
|
numbered: s,
|
|
559
|
-
content: Z(
|
|
559
|
+
content: Z(r.map(ct).filter((i) => i !== null)),
|
|
560
560
|
groupId: n?.attrs?.id || t.groupId,
|
|
561
561
|
layout: n ? Object.fromEntries(Object.entries(t.layout).map(([i, a]) => [i, n.attrs?.[i] ?? a])) : t.layout,
|
|
562
562
|
itemsContent: (n?.content || []).map((i, a) => ({ id: i.attrs?.id || t.itemsContent[a]?.id || crypto.randomUUID(), key: i.attrs?.label || String.fromCharCode(65 + a), content: Z((i.content || []).map(ct).filter((y) => y !== null)) }))
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
|
-
function pe(t, e,
|
|
566
|
-
const
|
|
565
|
+
function pe(t, e, o, n) {
|
|
566
|
+
const r = /* @__PURE__ */ new Map();
|
|
567
567
|
e.content.content?.forEach((i) => {
|
|
568
|
-
i.attrs?.contentId &&
|
|
568
|
+
i.attrs?.contentId && r.set(i.attrs.contentId, [...r.get(i.attrs.contentId) || [], i]);
|
|
569
569
|
});
|
|
570
|
-
const s = new Set(n?.content.content?.map((i) => i.attrs?.contentId).filter(Boolean)), c = (i, a) => a && (
|
|
570
|
+
const s = new Set(n?.content.content?.map((i) => i.attrs?.contentId).filter(Boolean)), c = (i, a) => a && (r.has(i) || s.has(i)) ? he(a, r.get(i) || []) : a;
|
|
571
571
|
return {
|
|
572
572
|
...t,
|
|
573
|
-
...
|
|
573
|
+
...r.has(o) ? { material: Z(r.get(o).map((i) => ct(i))) } : {},
|
|
574
574
|
questions: t.questions.map((i) => ({ ...i, text: c(i.id, i.text), parts: i.parts.map((a) => ({ ...a, text: c(a.id, a.text) })) }))
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
577
|
function ge(t) {
|
|
578
|
-
const e = t.reference,
|
|
579
|
-
e.type === "MIXED" &&
|
|
580
|
-
|
|
581
|
-
s.text &&
|
|
578
|
+
const e = t.reference, o = [];
|
|
579
|
+
e.type === "MIXED" && o.push(...(e.material || j()).content.content.map((r) => ({ ...r, attrs: { ...r.attrs, contentId: t.id } }))), e.questions.forEach((r) => {
|
|
580
|
+
r.text && o.push(...Ot(r.text, r.id, r.label)), fe(r.type) && r.parts.forEach((s) => {
|
|
581
|
+
s.text && o.push(...Ot(s.text, s.id, s.label));
|
|
582
582
|
});
|
|
583
583
|
});
|
|
584
|
-
const n = (t.document.content.content || []).filter((
|
|
585
|
-
return J(Z(n)) ||
|
|
584
|
+
const n = (t.document.content.content || []).filter((r) => !r.attrs?.contentId);
|
|
585
|
+
return J(Z(n)) || o.push(...n), Z(o);
|
|
586
586
|
}
|
|
587
587
|
function me(t, e) {
|
|
588
|
-
const
|
|
588
|
+
const o = (n, r, s) => !n || !s || r.options.map((c) => c.id).join() === s.options.map((c) => c.id).join() ? n : { ...n, itemsContent: r.options.map((c) => ({ ...n.itemsContent.find((i) => i.id === c.id), id: c.id, key: c.label, content: n.itemsContent.find((i) => i.id === c.id)?.content || j() })) };
|
|
589
589
|
return { ...t, questions: t.questions.map((n) => {
|
|
590
|
-
const
|
|
591
|
-
return { ...n, text:
|
|
590
|
+
const r = e.questions.find((s) => s.id === n.id);
|
|
591
|
+
return { ...n, text: o(n.text, n.choice, r?.choice), parts: n.parts.map((s) => ({ ...s, text: o(s.text, s.choice, r?.parts.find((c) => c.id === s.id)?.choice) })) };
|
|
592
592
|
}) };
|
|
593
593
|
}
|
|
594
|
-
function fn(t, e,
|
|
594
|
+
function fn(t, e, o) {
|
|
595
595
|
if (t.reference?.textVersion !== 1) return t;
|
|
596
596
|
let n = t.reference;
|
|
597
597
|
if (!e && !J(t.document) && !t.document.content.content?.some((s) => s.attrs?.contentId)) return { ...t, reference: { ...n, textVersion: void 0 } };
|
|
@@ -599,8 +599,8 @@ function fn(t, e, r) {
|
|
|
599
599
|
if (t.document !== e?.document && (!J(t.document) || e) && (n = pe(n, t.document, t.id, e?.document), e && t.reference === e.reference))
|
|
600
600
|
return { ...t, reference: n };
|
|
601
601
|
e?.reference && t.reference !== e.reference && (n = me(n, e.reference));
|
|
602
|
-
const
|
|
603
|
-
return
|
|
602
|
+
const r = { ...t, reference: n };
|
|
603
|
+
return o || !J(t.document) ? { ...r, document: ge(r) } : r;
|
|
604
604
|
}
|
|
605
605
|
const lt = {
|
|
606
606
|
SCHOICE: { count: 200, options: [2, 12], parts: 1, score: 15 },
|
|
@@ -615,15 +615,15 @@ const lt = {
|
|
|
615
615
|
TEXT_COMPLETION: { count: 20, options: [0, 0], parts: 20, score: 15 },
|
|
616
616
|
CCOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 },
|
|
617
617
|
ECOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 }
|
|
618
|
-
}, Y = (t) => ["SCHOICE", "MCHOICE", "JUDGE", "CHUNK_CHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING"].includes(t), R = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t), dn = (t) => t === "FILLBLANK" || t === "TEXT_COMPLETION",
|
|
618
|
+
}, Y = (t) => ["SCHOICE", "MCHOICE", "JUDGE", "CHUNK_CHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING"].includes(t), R = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t), dn = (t) => t === "FILLBLANK" || t === "TEXT_COMPLETION", Rt = (t) => t === "CCOMPOSITION" || t === "ECOMPOSITION", Ce = { SCHOICE: "choice", MCHOICE: "choice", JUDGE: "judge", FILLBLANK: "fill", SHORTANSWER: "answer", MIXED: "composite", CLOZE: "cloze", READTHENANSWER: "reading", INFO_MATCHING: "matching", TEXT_COMPLETION: "completion", ECOMPOSITION: "english", CCOMPOSITION: "writing", CHUNK_CHOICE: "chunk" };
|
|
619
619
|
function Ie(t) {
|
|
620
|
-
return { type: t, textVersion: 1, questions: [], layout:
|
|
620
|
+
return { type: t, textVersion: 1, questions: [], layout: qt(0), fillNewLine: !1, optional: !1, choose: 1, optionalHeight: 200, scoreType: "LESS_SCORE" };
|
|
621
621
|
}
|
|
622
622
|
function hn(t) {
|
|
623
|
-
return { id: crypto.randomUUID(), kind: Ce[t], title:
|
|
623
|
+
return { id: crypto.randomUUID(), kind: Ce[t], title: It[t], answerHeight: 0, document: j(), reference: Ie(t) };
|
|
624
624
|
}
|
|
625
|
-
function pn(t, e = 1,
|
|
626
|
-
const n = t === "MCHOICE" &&
|
|
625
|
+
function pn(t, e = 1, o) {
|
|
626
|
+
const n = t === "MCHOICE" && ht(o);
|
|
627
627
|
return {
|
|
628
628
|
type: t,
|
|
629
629
|
start: e,
|
|
@@ -639,35 +639,35 @@ function pn(t, e = 1, r) {
|
|
|
639
639
|
singleScore: 1
|
|
640
640
|
};
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
const n = Array.from({ length:
|
|
644
|
-
return { ...t, options: n, multiple: e === "MCHOICE" || e === "CHUNK_CHOICE", indefinite: !1, correctIds: t.correctIds.filter((
|
|
642
|
+
function Ht(t, e, o) {
|
|
643
|
+
const n = Array.from({ length: o }, (r, s) => ({ ...t.options[s] || { id: crypto.randomUUID() }, label: e === "JUDGE" ? ["T", "F"][s] : String.fromCharCode(65 + s) }));
|
|
644
|
+
return { ...t, options: n, multiple: e === "MCHOICE" || e === "CHUNK_CHOICE", indefinite: !1, correctIds: t.correctIds.filter((r) => n.some((s) => s.id === r)).slice(0, e === "MCHOICE" || e === "CHUNK_CHOICE" ? o : 1) };
|
|
645
645
|
}
|
|
646
|
-
function ye(t, e,
|
|
647
|
-
const
|
|
646
|
+
function ye(t, e, o, n = 4) {
|
|
647
|
+
const r = crypto.randomUUID(), s = { ...Ht(at(0), o, n), id: r, label: t, score: e };
|
|
648
648
|
return {
|
|
649
|
-
id:
|
|
649
|
+
id: r,
|
|
650
650
|
label: t,
|
|
651
651
|
score: e,
|
|
652
652
|
width: 25,
|
|
653
653
|
breakAfter: !1,
|
|
654
654
|
height: 100,
|
|
655
|
-
document:
|
|
655
|
+
document: o === "SHORTANSWER" ? pt(t, e) : j(),
|
|
656
656
|
choice: s,
|
|
657
|
-
...R(
|
|
657
|
+
...R(o) && o !== "TEXT_COMPLETION" ? { text: Pt(o, s) } : {}
|
|
658
658
|
};
|
|
659
659
|
}
|
|
660
660
|
function be(t, e) {
|
|
661
|
-
const
|
|
661
|
+
const o = crypto.randomUUID(), { type: n, score: r } = t, s = String(e), c = t.partCount || 1, i = Array.from({ length: R(n) || ["FILLBLANK", "SHORTANSWER"].includes(n) ? c : 0 }, (y, T) => ye(R(n) ? String(e + T) : c === 1 ? s : `${s}.${T + 1}`, r, n, t.optionCount || 4)), a = { ...Ht(at(0), n, t.optionCount || 4), id: o, label: s, score: r, scoreType: t.scoreType, lessScore: t.lessScore };
|
|
662
662
|
return {
|
|
663
|
-
id:
|
|
663
|
+
id: o,
|
|
664
664
|
type: n,
|
|
665
665
|
label: s,
|
|
666
|
-
score: i.length ?
|
|
666
|
+
score: i.length ? Bt(i) : r,
|
|
667
667
|
choice: a,
|
|
668
|
-
text:
|
|
668
|
+
text: Pt(n, a, R(n)),
|
|
669
669
|
parts: i,
|
|
670
|
-
document: n === "ECOMPOSITION" ? { version: 1, content: { type: "doc", content: [...
|
|
670
|
+
document: n === "ECOMPOSITION" ? { version: 1, content: { type: "doc", content: [...pt(s, r).content.content, ...Ee(t.lines, t.paperWidth || 600).content.content] } } : n === "CCOMPOSITION" ? pt(s, r) : j(),
|
|
671
671
|
height: n === "ECOMPOSITION" ? 50 * t.lines + 40 : 100,
|
|
672
672
|
contentHeight: 38,
|
|
673
673
|
characters: t.characters,
|
|
@@ -677,26 +677,26 @@ function be(t, e) {
|
|
|
677
677
|
singleScore: t.singleScore
|
|
678
678
|
};
|
|
679
679
|
}
|
|
680
|
-
const
|
|
681
|
-
function
|
|
682
|
-
return t.questions.flatMap((e) => R(e.type) ? e.parts.map((
|
|
680
|
+
const Bt = (t) => t.some((e) => e.score === null) ? null : t.reduce((e, o) => e + (o.score || 0), 0);
|
|
681
|
+
function yt(t) {
|
|
682
|
+
return t.questions.flatMap((e) => R(e.type) ? e.parts.map((o) => o.label) : [e.label]);
|
|
683
683
|
}
|
|
684
684
|
function gn(t) {
|
|
685
|
-
return Math.max(0, ...
|
|
685
|
+
return Math.max(0, ...yt(t).map(Number).filter(Number.isFinite)) + 1;
|
|
686
686
|
}
|
|
687
|
-
function mn(t, e,
|
|
688
|
-
const
|
|
689
|
-
if (!Number.isInteger(e.start) || e.start < 1 || e.end > 1e3 || !Number.isInteger(s) || s < 1 || s >
|
|
687
|
+
function mn(t, e, o = !1, n = !1) {
|
|
688
|
+
const r = lt[e.type], s = Rt(e.type) ? 1 : e.end - e.start + 1;
|
|
689
|
+
if (!Number.isInteger(e.start) || e.start < 1 || e.end > 1e3 || !Number.isInteger(s) || s < 1 || s > r.count) return `题号须为 1–1000,单次题数为 1–${r.count}`;
|
|
690
690
|
if (t.type === "CCOMPOSITION" && t.questions.length) return "语文作文每组只能有一道题";
|
|
691
691
|
if (t.optional) return "选做题组不能追加题目";
|
|
692
|
-
const c =
|
|
692
|
+
const c = yt(t);
|
|
693
693
|
if (Array.from({ length: s }, (i, a) => String(e.start + a)).some((i) => c.includes(i))) return "同一分组内,题号不能重复";
|
|
694
|
-
if (Y(e.type) && (e.optionCount === null || !Number.isInteger(e.optionCount) || e.optionCount <
|
|
695
|
-
if ((R(e.type) || ["FILLBLANK", "SHORTANSWER"].includes(e.type)) && (!e.partCount || !Number.isInteger(e.partCount) || e.partCount < 1 || e.partCount >
|
|
694
|
+
if (Y(e.type) && (e.optionCount === null || !Number.isInteger(e.optionCount) || e.optionCount < r.options[0] || e.optionCount > r.options[1])) return `选项个数须为 ${r.options[0]}–${r.options[1]}`;
|
|
695
|
+
if ((R(e.type) || ["FILLBLANK", "SHORTANSWER"].includes(e.type)) && (!e.partCount || !Number.isInteger(e.partCount) || e.partCount < 1 || e.partCount > r.parts)) return `子题/空数须为 1–${r.parts}`;
|
|
696
696
|
if (R(e.type) && s % e.partCount !== 0) return "题目数量无法按子题数量均分,请重新设置";
|
|
697
697
|
if (e.type === "INFO_MATCHING" && e.partCount > e.optionCount) return "选项个数需大于等于子题数量";
|
|
698
|
-
if (e.type === "SHORTANSWER" && (
|
|
699
|
-
if (e.score !== null && (!Number.isFinite(e.score) || e.score < (n ? 0 : 0.5) || e.score >
|
|
698
|
+
if (e.type === "SHORTANSWER" && (o || t.optional) && e.partCount !== 1) return "网阅或选做题不支持小题";
|
|
699
|
+
if (e.score !== null && (!Number.isFinite(e.score) || e.score < (n ? 0 : 0.5) || e.score > r.score || !Number.isInteger(e.score * 2))) return `分值须为 ${n ? 0 : 0.5}–${r.score} 分,按 0.5 分递增`;
|
|
700
700
|
if (e.type === "MCHOICE" && (e.lessScore < 0 || !Number.isInteger(e.lessScore * 2) || e.lessScore > (e.score || 0))) return "少选得分不能超过本题分值";
|
|
701
701
|
if (e.type === "CHUNK_CHOICE") {
|
|
702
702
|
if (!e.rightAnswers || !Number.isInteger(e.rightAnswers) || e.rightAnswers >= e.optionCount) return "正确答案个数需小于选项个数";
|
|
@@ -704,25 +704,25 @@ function mn(t, e, r = !1, n = !1) {
|
|
|
704
704
|
}
|
|
705
705
|
return e.type === "CCOMPOSITION" && (!Number.isInteger(e.characters) || e.characters < 1 || e.characters > 1200) ? "作文格数须为 1–1200" : e.type === "ECOMPOSITION" && (!Number.isInteger(e.lines) || e.lines < 1 || e.lines > 100) ? "作文行数须为 1–100" : e.score === null ? "请输入分值" : null;
|
|
706
706
|
}
|
|
707
|
-
function Cn(t, e,
|
|
708
|
-
const n = R(e.type) ? e.partCount : 1,
|
|
709
|
-
for (let i = e.start; i <= (
|
|
710
|
-
const s = [...t.questions], c = s.findIndex((i) => i.id ===
|
|
711
|
-
return s.splice(c < 0 ? s.length : c + 1, 0, ...
|
|
707
|
+
function Cn(t, e, o) {
|
|
708
|
+
const n = R(e.type) ? e.partCount : 1, r = [];
|
|
709
|
+
for (let i = e.start; i <= (Rt(e.type) ? e.start : e.end); i += n) r.push(be(e, i));
|
|
710
|
+
const s = [...t.questions], c = s.findIndex((i) => i.id === o || i.parts.some((a) => a.id === o));
|
|
711
|
+
return s.splice(c < 0 ? s.length : c + 1, 0, ...r), { ...t, questions: s };
|
|
712
712
|
}
|
|
713
713
|
function In(t) {
|
|
714
714
|
return t.questions.flatMap((e) => [e, ...e.parts]);
|
|
715
715
|
}
|
|
716
716
|
function yn(t) {
|
|
717
|
-
return t.questions.filter((e) => Y(e.type)).flatMap((e) => R(e.type) ? e.parts.map((
|
|
717
|
+
return t.questions.filter((e) => Y(e.type)).flatMap((e) => R(e.type) ? e.parts.map((o) => ({ ...o.choice, label: o.label, score: o.score })) : [{ ...e.choice, label: e.label, score: e.score }]);
|
|
718
718
|
}
|
|
719
719
|
function bn(t, e) {
|
|
720
|
-
const
|
|
721
|
-
return
|
|
722
|
-
n.label = R(
|
|
723
|
-
}),
|
|
724
|
-
n.text && (n.text.groupId = `options:${n.id}`), n.referenceData && (n.referenceData = { ...n.referenceData, questionId: n.id, questionPid:
|
|
725
|
-
}),
|
|
720
|
+
const o = kt(t);
|
|
721
|
+
return o.referenceData && (o.referenceData = { ...o.referenceData, questionId: o.id }), o.text && (o.text.groupId = `options:${o.id}`), o.label = String(e), o.choice.label = o.label, o.choice.contentTarget = null, o.choice.breakBefore = !1, o.parts.forEach((n, r) => {
|
|
722
|
+
n.label = R(o.type) ? String(e + r) : o.parts.length === 1 ? o.label : `${e}.${r + 1}`, n.choice.label = n.label, n.choice.contentTarget = null, n.choice.breakBefore = !1;
|
|
723
|
+
}), o.parts.forEach((n) => {
|
|
724
|
+
n.text && (n.text.groupId = `options:${n.id}`), n.referenceData && (n.referenceData = { ...n.referenceData, questionId: n.id, questionPid: o.id });
|
|
725
|
+
}), o.document = st(o.document, o.label, o.score), o.parts = o.parts.map((n) => ({ ...n, document: st(n.document, n.label, n.score) })), o;
|
|
726
726
|
}
|
|
727
727
|
function En(t) {
|
|
728
728
|
return Math.max(1, Math.floor((t - 6) / 31));
|
|
@@ -730,14 +730,14 @@ function En(t) {
|
|
|
730
730
|
function Ee(t, e) {
|
|
731
731
|
return { version: 1, content: { type: "doc", content: Array.from({ length: t }, () => ({ type: "paragraph", attrs: { fixedLineHeight: 1152 / 25.4 }, content: [{ type: "text", text: " ".repeat(Math.max(1, Math.floor((e - 24) / 3))), marks: [{ type: "underline" }, { type: "textStyle", attrs: { fontFamily: "Times New Roman, serif", fontSize: "12px" } }] }] })) } };
|
|
732
732
|
}
|
|
733
|
-
function wn(t, e,
|
|
734
|
-
const n = t.questions.reduce((s, c) => s + (c.parts.length || 1), 0),
|
|
735
|
-
return !n || !Number.isFinite(
|
|
733
|
+
function wn(t, e, o = !1) {
|
|
734
|
+
const n = t.questions.reduce((s, c) => s + (c.parts.length || 1), 0), r = e / n;
|
|
735
|
+
return !n || !Number.isFinite(r) || r < (o ? 0 : 0.5) || !Number.isInteger(r * 2) || t.questions.some((s) => r > lt[s.type].score || r !== 0 && s.type === "CHUNK_CHOICE" && (s.rightAnswers || 0) * (s.singleScore || 0) > r) ? null : { ...t, questions: t.questions.map((s) => ({ ...s, score: r * (s.parts.length || 1), document: st(s.document, s.label, r * (s.parts.length || 1)), choice: { ...s.choice, score: r, lessScore: Math.min(s.choice.lessScore || 0, r) }, parts: s.parts.map((c) => ({ ...c, score: r, document: st(c.document, c.label, r), choice: { ...c.choice, score: r } })) })) };
|
|
736
736
|
}
|
|
737
737
|
function Tn(t, e) {
|
|
738
|
-
return [...t <= 17 ? Array.from({ length: 18 }, (
|
|
738
|
+
return [...t <= 17 ? Array.from({ length: 18 }, (o, n) => 17 - n <= t ? String(17 - n) : "") : [...Array.from({ length: 7 }, (o, n) => 7 - n <= Math.floor(t / 10) ? `${7 - n}0` : ""), "", ...Array.from({ length: 10 }, (o, n) => String(9 - n))], e ? "0.5" : ""];
|
|
739
739
|
}
|
|
740
|
-
const we = ["000", "100", "110", "111", "101", "010", "011", "001"], Sn = (t) => we[t - 1],
|
|
740
|
+
const we = ["000", "100", "110", "111", "101", "010", "011", "001"], Sn = (t) => we[t - 1], jt = {
|
|
741
741
|
CHINESE: [1],
|
|
742
742
|
MATHS: [2],
|
|
743
743
|
ENGLISH: [3],
|
|
@@ -774,244 +774,244 @@ const we = ["000", "100", "110", "111", "101", "010", "011", "001"], Sn = (t) =>
|
|
|
774
774
|
历史: "HISTORY"
|
|
775
775
|
};
|
|
776
776
|
function Se(t) {
|
|
777
|
-
return t?.subjectCode || (t?.courseCode &&
|
|
777
|
+
return t?.subjectCode || (t?.courseCode && jt[t.courseCode] ? t.courseCode : Te[t?.subject || ""]);
|
|
778
778
|
}
|
|
779
779
|
const nt = (t) => Math.round(t * 1e3) / 1e3, An = (t) => ({ x: nt(t.x), y: nt(t.y), width: nt(t.width), height: nt(t.height) });
|
|
780
780
|
function On(t, e) {
|
|
781
|
-
const
|
|
782
|
-
return
|
|
781
|
+
const o = Math.max(t.x, e.x), n = Math.max(t.y, e.y), r = Math.min(t.x + t.width, e.x + e.width) - o, s = Math.min(t.y + t.height, e.y + e.height) - n;
|
|
782
|
+
return r > 0.01 && s > 0.01 ? { x: o, y: n, width: r, height: s } : void 0;
|
|
783
783
|
}
|
|
784
784
|
const V = function(t, e) {
|
|
785
|
-
let
|
|
785
|
+
let r = t;
|
|
786
786
|
const s = X[e];
|
|
787
787
|
let c = null, i = 0, a = null;
|
|
788
|
-
const y = [],
|
|
789
|
-
i =
|
|
790
|
-
const
|
|
788
|
+
const y = [], T = {}, m = function(p, E) {
|
|
789
|
+
i = r * 4 + 17, c = (function(d) {
|
|
790
|
+
const I = new Array(d);
|
|
791
791
|
for (let w = 0; w < d; w += 1) {
|
|
792
|
-
|
|
792
|
+
I[w] = new Array(d);
|
|
793
793
|
for (let S = 0; S < d; S += 1)
|
|
794
|
-
|
|
794
|
+
I[w][S] = null;
|
|
795
795
|
}
|
|
796
|
-
return
|
|
797
|
-
})(i), f(0, 0), f(i - 7, 0), f(0, i - 7), u(), l(), A(
|
|
798
|
-
}, f = function(
|
|
796
|
+
return I;
|
|
797
|
+
})(i), f(0, 0), f(i - 7, 0), f(0, i - 7), u(), l(), A(p, E), r >= 7 && g(p), a == null && (a = $(r, s, y)), C(a, E);
|
|
798
|
+
}, f = function(p, E) {
|
|
799
799
|
for (let d = -1; d <= 7; d += 1)
|
|
800
|
-
if (!(
|
|
801
|
-
for (let
|
|
802
|
-
|
|
803
|
-
},
|
|
804
|
-
let
|
|
800
|
+
if (!(p + d <= -1 || i <= p + d))
|
|
801
|
+
for (let I = -1; I <= 7; I += 1)
|
|
802
|
+
E + I <= -1 || i <= E + I || (0 <= d && d <= 6 && (I == 0 || I == 6) || 0 <= I && I <= 6 && (d == 0 || d == 6) || 2 <= d && d <= 4 && 2 <= I && I <= 4 ? c[p + d][E + I] = !0 : c[p + d][E + I] = !1);
|
|
803
|
+
}, h = function() {
|
|
804
|
+
let p = 0, E = 0;
|
|
805
805
|
for (let d = 0; d < 8; d += 1) {
|
|
806
806
|
m(!0, d);
|
|
807
|
-
const
|
|
808
|
-
(d == 0 ||
|
|
807
|
+
const I = F.getLostPoint(T);
|
|
808
|
+
(d == 0 || p > I) && (p = I, E = d);
|
|
809
809
|
}
|
|
810
|
-
return
|
|
810
|
+
return E;
|
|
811
811
|
}, l = function() {
|
|
812
|
-
for (let
|
|
813
|
-
c[
|
|
814
|
-
for (let
|
|
815
|
-
c[6][
|
|
812
|
+
for (let p = 8; p < i - 8; p += 1)
|
|
813
|
+
c[p][6] == null && (c[p][6] = p % 2 == 0);
|
|
814
|
+
for (let p = 8; p < i - 8; p += 1)
|
|
815
|
+
c[6][p] == null && (c[6][p] = p % 2 == 0);
|
|
816
816
|
}, u = function() {
|
|
817
|
-
const
|
|
818
|
-
for (let
|
|
819
|
-
for (let d = 0; d <
|
|
820
|
-
const
|
|
821
|
-
if (c[
|
|
817
|
+
const p = F.getPatternPosition(r);
|
|
818
|
+
for (let E = 0; E < p.length; E += 1)
|
|
819
|
+
for (let d = 0; d < p.length; d += 1) {
|
|
820
|
+
const I = p[E], w = p[d];
|
|
821
|
+
if (c[I][w] == null)
|
|
822
822
|
for (let S = -2; S <= 2; S += 1)
|
|
823
823
|
for (let N = -2; N <= 2; N += 1)
|
|
824
|
-
S == -2 || S == 2 || N == -2 || N == 2 || S == 0 && N == 0 ? c[
|
|
824
|
+
S == -2 || S == 2 || N == -2 || N == 2 || S == 0 && N == 0 ? c[I + S][w + N] = !0 : c[I + S][w + N] = !1;
|
|
825
825
|
}
|
|
826
|
-
}, g = function(
|
|
827
|
-
const
|
|
826
|
+
}, g = function(p) {
|
|
827
|
+
const E = F.getBCHTypeNumber(r);
|
|
828
828
|
for (let d = 0; d < 18; d += 1) {
|
|
829
|
-
const
|
|
830
|
-
c[Math.floor(d / 3)][d % 3 + i - 8 - 3] =
|
|
829
|
+
const I = !p && (E >> d & 1) == 1;
|
|
830
|
+
c[Math.floor(d / 3)][d % 3 + i - 8 - 3] = I;
|
|
831
831
|
}
|
|
832
832
|
for (let d = 0; d < 18; d += 1) {
|
|
833
|
-
const
|
|
834
|
-
c[d % 3 + i - 8 - 3][Math.floor(d / 3)] =
|
|
833
|
+
const I = !p && (E >> d & 1) == 1;
|
|
834
|
+
c[d % 3 + i - 8 - 3][Math.floor(d / 3)] = I;
|
|
835
835
|
}
|
|
836
|
-
}, A = function(
|
|
837
|
-
const d = s << 3 |
|
|
836
|
+
}, A = function(p, E) {
|
|
837
|
+
const d = s << 3 | E, I = F.getBCHTypeInfo(d);
|
|
838
838
|
for (let w = 0; w < 15; w += 1) {
|
|
839
|
-
const S = !
|
|
839
|
+
const S = !p && (I >> w & 1) == 1;
|
|
840
840
|
w < 6 ? c[w][8] = S : w < 8 ? c[w + 1][8] = S : c[i - 15 + w][8] = S;
|
|
841
841
|
}
|
|
842
842
|
for (let w = 0; w < 15; w += 1) {
|
|
843
|
-
const S = !
|
|
843
|
+
const S = !p && (I >> w & 1) == 1;
|
|
844
844
|
w < 8 ? c[8][i - w - 1] = S : w < 9 ? c[8][15 - w - 1 + 1] = S : c[8][15 - w - 1] = S;
|
|
845
845
|
}
|
|
846
|
-
c[i - 8][8] = !
|
|
847
|
-
}, C = function(
|
|
848
|
-
let d = -1,
|
|
849
|
-
const N = F.getMaskFunction(
|
|
846
|
+
c[i - 8][8] = !p;
|
|
847
|
+
}, C = function(p, E) {
|
|
848
|
+
let d = -1, I = i - 1, w = 7, S = 0;
|
|
849
|
+
const N = F.getMaskFunction(E);
|
|
850
850
|
for (let L = i - 1; L > 0; L -= 2)
|
|
851
851
|
for (L == 6 && (L -= 1); ; ) {
|
|
852
852
|
for (let _ = 0; _ < 2; _ += 1)
|
|
853
|
-
if (c[
|
|
853
|
+
if (c[I][L - _] == null) {
|
|
854
854
|
let k = !1;
|
|
855
|
-
S <
|
|
855
|
+
S < p.length && (k = (p[S] >>> w & 1) == 1), N(I, L - _) && (k = !k), c[I][L - _] = k, w -= 1, w == -1 && (S += 1, w = 7);
|
|
856
856
|
}
|
|
857
|
-
if (
|
|
858
|
-
|
|
857
|
+
if (I += d, I < 0 || i <= I) {
|
|
858
|
+
I -= d, d = -d;
|
|
859
859
|
break;
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
},
|
|
863
|
-
let d = 0,
|
|
864
|
-
const S = new Array(
|
|
865
|
-
for (let
|
|
866
|
-
const D =
|
|
867
|
-
|
|
868
|
-
for (let G = 0; G < S[
|
|
869
|
-
S[
|
|
862
|
+
}, M = function(p, E) {
|
|
863
|
+
let d = 0, I = 0, w = 0;
|
|
864
|
+
const S = new Array(E.length), N = new Array(E.length);
|
|
865
|
+
for (let x = 0; x < E.length; x += 1) {
|
|
866
|
+
const D = E[x].dataCount, H = E[x].totalCount - D;
|
|
867
|
+
I = Math.max(I, D), w = Math.max(w, H), S[x] = new Array(D);
|
|
868
|
+
for (let G = 0; G < S[x].length; G += 1)
|
|
869
|
+
S[x][G] = 255 & p.getBuffer()[G + d];
|
|
870
870
|
d += D;
|
|
871
|
-
const ft = F.getErrorCorrectPolynomial(H),
|
|
872
|
-
N[
|
|
873
|
-
for (let G = 0; G < N[
|
|
874
|
-
const
|
|
875
|
-
N[
|
|
871
|
+
const ft = F.getErrorCorrectPolynomial(H), bt = q(S[x], ft.getLength() - 1).mod(ft);
|
|
872
|
+
N[x] = new Array(ft.getLength() - 1);
|
|
873
|
+
for (let G = 0; G < N[x].length; G += 1) {
|
|
874
|
+
const Et = G + bt.getLength() - N[x].length;
|
|
875
|
+
N[x][G] = Et >= 0 ? bt.getAt(Et) : 0;
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
878
|
let L = 0;
|
|
879
|
-
for (let
|
|
880
|
-
L +=
|
|
879
|
+
for (let x = 0; x < E.length; x += 1)
|
|
880
|
+
L += E[x].totalCount;
|
|
881
881
|
const _ = new Array(L);
|
|
882
882
|
let k = 0;
|
|
883
|
-
for (let
|
|
884
|
-
for (let D = 0; D <
|
|
885
|
-
|
|
886
|
-
for (let
|
|
887
|
-
for (let D = 0; D <
|
|
888
|
-
|
|
883
|
+
for (let x = 0; x < I; x += 1)
|
|
884
|
+
for (let D = 0; D < E.length; D += 1)
|
|
885
|
+
x < S[D].length && (_[k] = S[D][x], k += 1);
|
|
886
|
+
for (let x = 0; x < w; x += 1)
|
|
887
|
+
for (let D = 0; D < E.length; D += 1)
|
|
888
|
+
x < N[D].length && (_[k] = N[D][x], k += 1);
|
|
889
889
|
return _;
|
|
890
|
-
},
|
|
891
|
-
const
|
|
890
|
+
}, $ = function(p, E, d) {
|
|
891
|
+
const I = Nt.getRSBlocks(p, E), w = Mt();
|
|
892
892
|
for (let N = 0; N < d.length; N += 1) {
|
|
893
893
|
const L = d[N];
|
|
894
|
-
w.put(L.getMode(), 4), w.put(L.getLength(), F.getLengthInBits(L.getMode(),
|
|
894
|
+
w.put(L.getMode(), 4), w.put(L.getLength(), F.getLengthInBits(L.getMode(), p)), L.write(w);
|
|
895
895
|
}
|
|
896
896
|
let S = 0;
|
|
897
|
-
for (let N = 0; N <
|
|
898
|
-
S +=
|
|
897
|
+
for (let N = 0; N < I.length; N += 1)
|
|
898
|
+
S += I[N].dataCount;
|
|
899
899
|
if (w.getLengthInBits() > S * 8)
|
|
900
900
|
throw "code length overflow. (" + w.getLengthInBits() + ">" + S * 8 + ")";
|
|
901
901
|
for (w.getLengthInBits() + 4 <= S * 8 && w.put(0, 4); w.getLengthInBits() % 8 != 0; )
|
|
902
902
|
w.putBit(!1);
|
|
903
903
|
for (; !(w.getLengthInBits() >= S * 8 || (w.put(236, 8), w.getLengthInBits() >= S * 8)); )
|
|
904
904
|
w.put(17, 8);
|
|
905
|
-
return
|
|
905
|
+
return M(w, I);
|
|
906
906
|
};
|
|
907
|
-
|
|
908
|
-
|
|
907
|
+
T.addData = function(p, E) {
|
|
908
|
+
E = E || "Byte";
|
|
909
909
|
let d = null;
|
|
910
|
-
switch (
|
|
910
|
+
switch (E) {
|
|
911
911
|
case "Numeric":
|
|
912
|
-
d = Ae(
|
|
912
|
+
d = Ae(p);
|
|
913
913
|
break;
|
|
914
914
|
case "Alphanumeric":
|
|
915
|
-
d = Oe(
|
|
915
|
+
d = Oe(p);
|
|
916
916
|
break;
|
|
917
917
|
case "Byte":
|
|
918
|
-
d = Ne(
|
|
918
|
+
d = Ne(p);
|
|
919
919
|
break;
|
|
920
920
|
case "Kanji":
|
|
921
|
-
d = Me(
|
|
921
|
+
d = Me(p);
|
|
922
922
|
break;
|
|
923
923
|
default:
|
|
924
|
-
throw "mode:" +
|
|
924
|
+
throw "mode:" + E;
|
|
925
925
|
}
|
|
926
926
|
y.push(d), a = null;
|
|
927
|
-
},
|
|
928
|
-
if (
|
|
929
|
-
throw
|
|
930
|
-
return c[
|
|
931
|
-
},
|
|
927
|
+
}, T.isDark = function(p, E) {
|
|
928
|
+
if (p < 0 || i <= p || E < 0 || i <= E)
|
|
929
|
+
throw p + "," + E;
|
|
930
|
+
return c[p][E];
|
|
931
|
+
}, T.getModuleCount = function() {
|
|
932
932
|
return i;
|
|
933
|
-
},
|
|
934
|
-
if (
|
|
935
|
-
let
|
|
936
|
-
for (;
|
|
937
|
-
const
|
|
933
|
+
}, T.make = function() {
|
|
934
|
+
if (r < 1) {
|
|
935
|
+
let p = 1;
|
|
936
|
+
for (; p < 40; p++) {
|
|
937
|
+
const E = Nt.getRSBlocks(p, s), d = Mt();
|
|
938
938
|
for (let w = 0; w < y.length; w++) {
|
|
939
939
|
const S = y[w];
|
|
940
|
-
d.put(S.getMode(), 4), d.put(S.getLength(), F.getLengthInBits(S.getMode(),
|
|
940
|
+
d.put(S.getMode(), 4), d.put(S.getLength(), F.getLengthInBits(S.getMode(), p)), S.write(d);
|
|
941
941
|
}
|
|
942
|
-
let
|
|
943
|
-
for (let w = 0; w <
|
|
944
|
-
|
|
945
|
-
if (d.getLengthInBits() <=
|
|
942
|
+
let I = 0;
|
|
943
|
+
for (let w = 0; w < E.length; w++)
|
|
944
|
+
I += E[w].dataCount;
|
|
945
|
+
if (d.getLengthInBits() <= I * 8)
|
|
946
946
|
break;
|
|
947
947
|
}
|
|
948
|
-
|
|
948
|
+
r = p;
|
|
949
949
|
}
|
|
950
|
-
m(!1,
|
|
951
|
-
},
|
|
952
|
-
|
|
950
|
+
m(!1, h());
|
|
951
|
+
}, T.createTableTag = function(p, E) {
|
|
952
|
+
p = p || 2, E = typeof E > "u" ? p * 4 : E;
|
|
953
953
|
let d = "";
|
|
954
|
-
d += '<table style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: " +
|
|
955
|
-
for (let
|
|
954
|
+
d += '<table style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: " + E + "px;", d += '">', d += "<tbody>";
|
|
955
|
+
for (let I = 0; I < T.getModuleCount(); I += 1) {
|
|
956
956
|
d += "<tr>";
|
|
957
|
-
for (let w = 0; w <
|
|
958
|
-
d += '<td style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: 0px;", d += " width: " +
|
|
957
|
+
for (let w = 0; w < T.getModuleCount(); w += 1)
|
|
958
|
+
d += '<td style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: 0px;", d += " width: " + p + "px;", d += " height: " + p + "px;", d += " background-color: ", d += T.isDark(I, w) ? "#000000" : "#ffffff", d += ";", d += '"/>';
|
|
959
959
|
d += "</tr>";
|
|
960
960
|
}
|
|
961
961
|
return d += "</tbody>", d += "</table>", d;
|
|
962
|
-
},
|
|
962
|
+
}, T.createSvgTag = function(p, E, d, I) {
|
|
963
963
|
let w = {};
|
|
964
|
-
typeof arguments[0] == "object" && (w = arguments[0],
|
|
965
|
-
const S =
|
|
966
|
-
let N, L, _, k,
|
|
967
|
-
for (D = "l" +
|
|
968
|
-
for (k = _ *
|
|
969
|
-
|
|
970
|
-
return
|
|
971
|
-
},
|
|
972
|
-
|
|
973
|
-
const d =
|
|
964
|
+
typeof arguments[0] == "object" && (w = arguments[0], p = w.cellSize, E = w.margin, d = w.alt, I = w.title), p = p || 2, E = typeof E > "u" ? p * 4 : E, d = typeof d == "string" ? { text: d } : d || {}, d.text = d.text || null, d.id = d.text ? d.id || "qrcode-description" : null, I = typeof I == "string" ? { text: I } : I || {}, I.text = I.text || null, I.id = I.text ? I.id || "qrcode-title" : null;
|
|
965
|
+
const S = T.getModuleCount() * p + E * 2;
|
|
966
|
+
let N, L, _, k, x = "", D;
|
|
967
|
+
for (D = "l" + p + ",0 0," + p + " -" + p + ",0 0,-" + p + "z ", x += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', x += w.scalable ? "" : ' width="' + S + 'px" height="' + S + 'px"', x += ' viewBox="0 0 ' + S + " " + S + '" ', x += ' preserveAspectRatio="xMinYMin meet"', x += I.text || d.text ? ' role="img" aria-labelledby="' + b([I.id, d.id].join(" ").trim()) + '"' : "", x += ">", x += I.text ? '<title id="' + b(I.id) + '">' + b(I.text) + "</title>" : "", x += d.text ? '<description id="' + b(d.id) + '">' + b(d.text) + "</description>" : "", x += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', x += '<path d="', _ = 0; _ < T.getModuleCount(); _ += 1)
|
|
968
|
+
for (k = _ * p + E, N = 0; N < T.getModuleCount(); N += 1)
|
|
969
|
+
T.isDark(_, N) && (L = N * p + E, x += "M" + L + "," + k + D);
|
|
970
|
+
return x += '" stroke="transparent" fill="black"/>', x += "</svg>", x;
|
|
971
|
+
}, T.createDataURL = function(p, E) {
|
|
972
|
+
p = p || 2, E = typeof E > "u" ? p * 4 : E;
|
|
973
|
+
const d = T.getModuleCount() * p + E * 2, I = E, w = d - E;
|
|
974
974
|
return _e(d, d, function(S, N) {
|
|
975
|
-
if (
|
|
976
|
-
const L = Math.floor((S -
|
|
977
|
-
return
|
|
975
|
+
if (I <= S && S < w && I <= N && N < w) {
|
|
976
|
+
const L = Math.floor((S - I) / p), _ = Math.floor((N - I) / p);
|
|
977
|
+
return T.isDark(_, L) ? 0 : 1;
|
|
978
978
|
} else
|
|
979
979
|
return 1;
|
|
980
980
|
});
|
|
981
|
-
},
|
|
982
|
-
|
|
983
|
-
const
|
|
981
|
+
}, T.createImgTag = function(p, E, d) {
|
|
982
|
+
p = p || 2, E = typeof E > "u" ? p * 4 : E;
|
|
983
|
+
const I = T.getModuleCount() * p + E * 2;
|
|
984
984
|
let w = "";
|
|
985
|
-
return w += "<img", w += ' src="', w +=
|
|
985
|
+
return w += "<img", w += ' src="', w += T.createDataURL(p, E), w += '"', w += ' width="', w += I, w += '"', w += ' height="', w += I, w += '"', d && (w += ' alt="', w += b(d), w += '"'), w += "/>", w;
|
|
986
986
|
};
|
|
987
|
-
const
|
|
988
|
-
let
|
|
989
|
-
for (let d = 0; d <
|
|
990
|
-
const
|
|
991
|
-
switch (
|
|
987
|
+
const b = function(p) {
|
|
988
|
+
let E = "";
|
|
989
|
+
for (let d = 0; d < p.length; d += 1) {
|
|
990
|
+
const I = p.charAt(d);
|
|
991
|
+
switch (I) {
|
|
992
992
|
case "<":
|
|
993
|
-
|
|
993
|
+
E += "<";
|
|
994
994
|
break;
|
|
995
995
|
case ">":
|
|
996
|
-
|
|
996
|
+
E += ">";
|
|
997
997
|
break;
|
|
998
998
|
case "&":
|
|
999
|
-
|
|
999
|
+
E += "&";
|
|
1000
1000
|
break;
|
|
1001
1001
|
case '"':
|
|
1002
|
-
|
|
1002
|
+
E += """;
|
|
1003
1003
|
break;
|
|
1004
1004
|
default:
|
|
1005
|
-
|
|
1005
|
+
E += I;
|
|
1006
1006
|
break;
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
return
|
|
1010
|
-
}, O = function(
|
|
1011
|
-
|
|
1012
|
-
const d =
|
|
1009
|
+
return E;
|
|
1010
|
+
}, O = function(p) {
|
|
1011
|
+
p = typeof p > "u" ? 2 : p;
|
|
1012
|
+
const d = T.getModuleCount() * 1 + p * 2, I = p, w = d - p;
|
|
1013
1013
|
let S, N, L, _, k;
|
|
1014
|
-
const
|
|
1014
|
+
const x = {
|
|
1015
1015
|
"██": "█",
|
|
1016
1016
|
"█ ": "▀",
|
|
1017
1017
|
" █": "▄",
|
|
@@ -1024,72 +1024,72 @@ const V = function(t, e) {
|
|
|
1024
1024
|
};
|
|
1025
1025
|
let H = "";
|
|
1026
1026
|
for (S = 0; S < d; S += 2) {
|
|
1027
|
-
for (L = Math.floor((S -
|
|
1028
|
-
k = "█",
|
|
1027
|
+
for (L = Math.floor((S - I) / 1), _ = Math.floor((S + 1 - I) / 1), N = 0; N < d; N += 1)
|
|
1028
|
+
k = "█", I <= N && N < w && I <= S && S < w && T.isDark(L, Math.floor((N - I) / 1)) && (k = " "), I <= N && N < w && I <= S + 1 && S + 1 < w && T.isDark(_, Math.floor((N - I) / 1)) ? k += " " : k += "█", H += p < 1 && S + 1 >= w ? D[k] : x[k];
|
|
1029
1029
|
H += `
|
|
1030
1030
|
`;
|
|
1031
1031
|
}
|
|
1032
|
-
return d % 2 &&
|
|
1032
|
+
return d % 2 && p > 0 ? H.substring(0, H.length - d - 1) + Array(d + 1).join("▀") : H.substring(0, H.length - 1);
|
|
1033
1033
|
};
|
|
1034
|
-
return
|
|
1035
|
-
if (
|
|
1036
|
-
return O(
|
|
1037
|
-
|
|
1038
|
-
const d =
|
|
1034
|
+
return T.createASCII = function(p, E) {
|
|
1035
|
+
if (p = p || 1, p < 2)
|
|
1036
|
+
return O(E);
|
|
1037
|
+
p -= 1, E = typeof E > "u" ? p * 2 : E;
|
|
1038
|
+
const d = T.getModuleCount() * p + E * 2, I = E, w = d - E;
|
|
1039
1039
|
let S, N, L, _;
|
|
1040
|
-
const k = Array(
|
|
1040
|
+
const k = Array(p + 1).join("██"), x = Array(p + 1).join(" ");
|
|
1041
1041
|
let D = "", H = "";
|
|
1042
1042
|
for (S = 0; S < d; S += 1) {
|
|
1043
|
-
for (L = Math.floor((S -
|
|
1044
|
-
_ = 1,
|
|
1045
|
-
for (L = 0; L <
|
|
1043
|
+
for (L = Math.floor((S - I) / p), H = "", N = 0; N < d; N += 1)
|
|
1044
|
+
_ = 1, I <= N && N < w && I <= S && S < w && T.isDark(L, Math.floor((N - I) / p)) && (_ = 0), H += _ ? k : x;
|
|
1045
|
+
for (L = 0; L < p; L += 1)
|
|
1046
1046
|
D += H + `
|
|
1047
1047
|
`;
|
|
1048
1048
|
}
|
|
1049
1049
|
return D.substring(0, D.length - 1);
|
|
1050
|
-
},
|
|
1051
|
-
|
|
1052
|
-
const d =
|
|
1053
|
-
for (let
|
|
1050
|
+
}, T.renderTo2dContext = function(p, E) {
|
|
1051
|
+
E = E || 2;
|
|
1052
|
+
const d = T.getModuleCount();
|
|
1053
|
+
for (let I = 0; I < d; I++)
|
|
1054
1054
|
for (let w = 0; w < d; w++)
|
|
1055
|
-
|
|
1056
|
-
},
|
|
1055
|
+
p.fillStyle = T.isDark(I, w) ? "black" : "white", p.fillRect(w * E, I * E, E, E);
|
|
1056
|
+
}, T;
|
|
1057
1057
|
};
|
|
1058
1058
|
V.stringToBytes = function(t) {
|
|
1059
1059
|
const e = [];
|
|
1060
|
-
for (let
|
|
1061
|
-
const n = t.charCodeAt(
|
|
1060
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
1061
|
+
const n = t.charCodeAt(o);
|
|
1062
1062
|
e.push(n & 255);
|
|
1063
1063
|
}
|
|
1064
1064
|
return e;
|
|
1065
1065
|
};
|
|
1066
1066
|
V.createStringToBytes = function(t, e) {
|
|
1067
|
-
const
|
|
1068
|
-
const
|
|
1069
|
-
const a =
|
|
1067
|
+
const o = (function() {
|
|
1068
|
+
const r = $e(t), s = function() {
|
|
1069
|
+
const a = r.read();
|
|
1070
1070
|
if (a == -1) throw "eof";
|
|
1071
1071
|
return a;
|
|
1072
1072
|
};
|
|
1073
1073
|
let c = 0;
|
|
1074
1074
|
const i = {};
|
|
1075
1075
|
for (; ; ) {
|
|
1076
|
-
const a =
|
|
1076
|
+
const a = r.read();
|
|
1077
1077
|
if (a == -1) break;
|
|
1078
|
-
const y = s(),
|
|
1079
|
-
i[f] =
|
|
1078
|
+
const y = s(), T = s(), m = s(), f = String.fromCharCode(a << 8 | y), h = T << 8 | m;
|
|
1079
|
+
i[f] = h, c += 1;
|
|
1080
1080
|
}
|
|
1081
1081
|
if (c != e)
|
|
1082
1082
|
throw c + " != " + e;
|
|
1083
1083
|
return i;
|
|
1084
1084
|
})(), n = 63;
|
|
1085
|
-
return function(
|
|
1085
|
+
return function(r) {
|
|
1086
1086
|
const s = [];
|
|
1087
|
-
for (let c = 0; c <
|
|
1088
|
-
const i =
|
|
1087
|
+
for (let c = 0; c < r.length; c += 1) {
|
|
1088
|
+
const i = r.charCodeAt(c);
|
|
1089
1089
|
if (i < 128)
|
|
1090
1090
|
s.push(i);
|
|
1091
1091
|
else {
|
|
1092
|
-
const a = r
|
|
1092
|
+
const a = o[r.charAt(c)];
|
|
1093
1093
|
typeof a == "number" ? (a & 255) == a ? s.push(a) : (s.push(a >>> 8), s.push(a & 255)) : s.push(n);
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
@@ -1157,25 +1157,25 @@ const P = {
|
|
|
1157
1157
|
[6, 32, 58, 84, 110, 136, 162],
|
|
1158
1158
|
[6, 26, 54, 82, 110, 138, 166],
|
|
1159
1159
|
[6, 30, 58, 86, 114, 142, 170]
|
|
1160
|
-
], e = 1335,
|
|
1160
|
+
], e = 1335, o = 7973, n = 21522, r = {}, s = function(c) {
|
|
1161
1161
|
let i = 0;
|
|
1162
1162
|
for (; c != 0; )
|
|
1163
1163
|
i += 1, c >>>= 1;
|
|
1164
1164
|
return i;
|
|
1165
1165
|
};
|
|
1166
|
-
return
|
|
1166
|
+
return r.getBCHTypeInfo = function(c) {
|
|
1167
1167
|
let i = c << 10;
|
|
1168
1168
|
for (; s(i) - s(e) >= 0; )
|
|
1169
1169
|
i ^= e << s(i) - s(e);
|
|
1170
1170
|
return (c << 10 | i) ^ n;
|
|
1171
|
-
},
|
|
1171
|
+
}, r.getBCHTypeNumber = function(c) {
|
|
1172
1172
|
let i = c << 12;
|
|
1173
|
-
for (; s(i) - s(
|
|
1174
|
-
i ^=
|
|
1173
|
+
for (; s(i) - s(o) >= 0; )
|
|
1174
|
+
i ^= o << s(i) - s(o);
|
|
1175
1175
|
return c << 12 | i;
|
|
1176
|
-
},
|
|
1176
|
+
}, r.getPatternPosition = function(c) {
|
|
1177
1177
|
return t[c - 1];
|
|
1178
|
-
},
|
|
1178
|
+
}, r.getMaskFunction = function(c) {
|
|
1179
1179
|
switch (c) {
|
|
1180
1180
|
case U.PATTERN000:
|
|
1181
1181
|
return function(i, a) {
|
|
@@ -1212,12 +1212,12 @@ const P = {
|
|
|
1212
1212
|
default:
|
|
1213
1213
|
throw "bad maskPattern:" + c;
|
|
1214
1214
|
}
|
|
1215
|
-
},
|
|
1215
|
+
}, r.getErrorCorrectPolynomial = function(c) {
|
|
1216
1216
|
let i = q([1], 0);
|
|
1217
1217
|
for (let a = 0; a < c; a += 1)
|
|
1218
1218
|
i = i.multiply(q([1, K.gexp(a)], 0));
|
|
1219
1219
|
return i;
|
|
1220
|
-
},
|
|
1220
|
+
}, r.getLengthInBits = function(c, i) {
|
|
1221
1221
|
if (1 <= i && i < 10)
|
|
1222
1222
|
switch (c) {
|
|
1223
1223
|
case P.MODE_NUMBER:
|
|
@@ -1259,23 +1259,23 @@ const P = {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
else
|
|
1261
1261
|
throw "type:" + i;
|
|
1262
|
-
},
|
|
1262
|
+
}, r.getLostPoint = function(c) {
|
|
1263
1263
|
const i = c.getModuleCount();
|
|
1264
1264
|
let a = 0;
|
|
1265
1265
|
for (let m = 0; m < i; m += 1)
|
|
1266
1266
|
for (let f = 0; f < i; f += 1) {
|
|
1267
|
-
let
|
|
1267
|
+
let h = 0;
|
|
1268
1268
|
const l = c.isDark(m, f);
|
|
1269
1269
|
for (let u = -1; u <= 1; u += 1)
|
|
1270
1270
|
if (!(m + u < 0 || i <= m + u))
|
|
1271
1271
|
for (let g = -1; g <= 1; g += 1)
|
|
1272
|
-
f + g < 0 || i <= f + g || u == 0 && g == 0 || l == c.isDark(m + u, f + g) && (
|
|
1273
|
-
|
|
1272
|
+
f + g < 0 || i <= f + g || u == 0 && g == 0 || l == c.isDark(m + u, f + g) && (h += 1);
|
|
1273
|
+
h > 5 && (a += 3 + h - 5);
|
|
1274
1274
|
}
|
|
1275
1275
|
for (let m = 0; m < i - 1; m += 1)
|
|
1276
1276
|
for (let f = 0; f < i - 1; f += 1) {
|
|
1277
|
-
let
|
|
1278
|
-
c.isDark(m, f) && (
|
|
1277
|
+
let h = 0;
|
|
1278
|
+
c.isDark(m, f) && (h += 1), c.isDark(m + 1, f) && (h += 1), c.isDark(m, f + 1) && (h += 1), c.isDark(m + 1, f + 1) && (h += 1), (h == 0 || h == 4) && (a += 3);
|
|
1279
1279
|
}
|
|
1280
1280
|
for (let m = 0; m < i; m += 1)
|
|
1281
1281
|
for (let f = 0; f < i - 6; f += 1)
|
|
@@ -1287,9 +1287,9 @@ const P = {
|
|
|
1287
1287
|
for (let m = 0; m < i; m += 1)
|
|
1288
1288
|
for (let f = 0; f < i; f += 1)
|
|
1289
1289
|
c.isDark(f, m) && (y += 1);
|
|
1290
|
-
const
|
|
1291
|
-
return a +=
|
|
1292
|
-
},
|
|
1290
|
+
const T = Math.abs(100 * y / i / i - 50) / 5;
|
|
1291
|
+
return a += T * 10, a;
|
|
1292
|
+
}, r;
|
|
1293
1293
|
})(), K = (function() {
|
|
1294
1294
|
const t = new Array(256), e = new Array(256);
|
|
1295
1295
|
for (let n = 0; n < 8; n += 1)
|
|
@@ -1298,51 +1298,51 @@ const P = {
|
|
|
1298
1298
|
t[n] = t[n - 4] ^ t[n - 5] ^ t[n - 6] ^ t[n - 8];
|
|
1299
1299
|
for (let n = 0; n < 255; n += 1)
|
|
1300
1300
|
e[t[n]] = n;
|
|
1301
|
-
const
|
|
1302
|
-
return
|
|
1301
|
+
const o = {};
|
|
1302
|
+
return o.glog = function(n) {
|
|
1303
1303
|
if (n < 1)
|
|
1304
1304
|
throw "glog(" + n + ")";
|
|
1305
1305
|
return e[n];
|
|
1306
|
-
},
|
|
1306
|
+
}, o.gexp = function(n) {
|
|
1307
1307
|
for (; n < 0; )
|
|
1308
1308
|
n += 255;
|
|
1309
1309
|
for (; n >= 256; )
|
|
1310
1310
|
n -= 255;
|
|
1311
1311
|
return t[n];
|
|
1312
|
-
},
|
|
1312
|
+
}, o;
|
|
1313
1313
|
})(), q = function(t, e) {
|
|
1314
1314
|
if (typeof t.length > "u")
|
|
1315
1315
|
throw t.length + "/" + e;
|
|
1316
|
-
const
|
|
1317
|
-
let
|
|
1318
|
-
for (;
|
|
1319
|
-
|
|
1320
|
-
const s = new Array(t.length -
|
|
1321
|
-
for (let c = 0; c < t.length -
|
|
1322
|
-
s[c] = t[c +
|
|
1316
|
+
const o = (function() {
|
|
1317
|
+
let r = 0;
|
|
1318
|
+
for (; r < t.length && t[r] == 0; )
|
|
1319
|
+
r += 1;
|
|
1320
|
+
const s = new Array(t.length - r + e);
|
|
1321
|
+
for (let c = 0; c < t.length - r; c += 1)
|
|
1322
|
+
s[c] = t[c + r];
|
|
1323
1323
|
return s;
|
|
1324
1324
|
})(), n = {};
|
|
1325
|
-
return n.getAt = function(
|
|
1326
|
-
return r
|
|
1325
|
+
return n.getAt = function(r) {
|
|
1326
|
+
return o[r];
|
|
1327
1327
|
}, n.getLength = function() {
|
|
1328
|
-
return
|
|
1329
|
-
}, n.multiply = function(
|
|
1330
|
-
const s = new Array(n.getLength() +
|
|
1328
|
+
return o.length;
|
|
1329
|
+
}, n.multiply = function(r) {
|
|
1330
|
+
const s = new Array(n.getLength() + r.getLength() - 1);
|
|
1331
1331
|
for (let c = 0; c < n.getLength(); c += 1)
|
|
1332
|
-
for (let i = 0; i <
|
|
1333
|
-
s[c + i] ^= K.gexp(K.glog(n.getAt(c)) + K.glog(
|
|
1332
|
+
for (let i = 0; i < r.getLength(); i += 1)
|
|
1333
|
+
s[c + i] ^= K.gexp(K.glog(n.getAt(c)) + K.glog(r.getAt(i)));
|
|
1334
1334
|
return q(s, 0);
|
|
1335
|
-
}, n.mod = function(
|
|
1336
|
-
if (n.getLength() -
|
|
1335
|
+
}, n.mod = function(r) {
|
|
1336
|
+
if (n.getLength() - r.getLength() < 0)
|
|
1337
1337
|
return n;
|
|
1338
|
-
const s = K.glog(n.getAt(0)) - K.glog(
|
|
1338
|
+
const s = K.glog(n.getAt(0)) - K.glog(r.getAt(0)), c = new Array(n.getLength());
|
|
1339
1339
|
for (let i = 0; i < n.getLength(); i += 1)
|
|
1340
1340
|
c[i] = n.getAt(i);
|
|
1341
|
-
for (let i = 0; i <
|
|
1342
|
-
c[i] ^= K.gexp(K.glog(
|
|
1343
|
-
return q(c, 0).mod(
|
|
1341
|
+
for (let i = 0; i < r.getLength(); i += 1)
|
|
1342
|
+
c[i] ^= K.gexp(K.glog(r.getAt(i)) + s);
|
|
1343
|
+
return q(c, 0).mod(r);
|
|
1344
1344
|
}, n;
|
|
1345
|
-
},
|
|
1345
|
+
}, Nt = (function() {
|
|
1346
1346
|
const t = [
|
|
1347
1347
|
// L
|
|
1348
1348
|
// M
|
|
@@ -1548,67 +1548,67 @@ const P = {
|
|
|
1548
1548
|
[18, 75, 47, 31, 76, 48],
|
|
1549
1549
|
[34, 54, 24, 34, 55, 25],
|
|
1550
1550
|
[20, 45, 15, 61, 46, 16]
|
|
1551
|
-
], e = function(
|
|
1551
|
+
], e = function(r, s) {
|
|
1552
1552
|
const c = {};
|
|
1553
|
-
return c.totalCount =
|
|
1554
|
-
},
|
|
1553
|
+
return c.totalCount = r, c.dataCount = s, c;
|
|
1554
|
+
}, o = {}, n = function(r, s) {
|
|
1555
1555
|
switch (s) {
|
|
1556
1556
|
case X.L:
|
|
1557
|
-
return t[(
|
|
1557
|
+
return t[(r - 1) * 4 + 0];
|
|
1558
1558
|
case X.M:
|
|
1559
|
-
return t[(
|
|
1559
|
+
return t[(r - 1) * 4 + 1];
|
|
1560
1560
|
case X.Q:
|
|
1561
|
-
return t[(
|
|
1561
|
+
return t[(r - 1) * 4 + 2];
|
|
1562
1562
|
case X.H:
|
|
1563
|
-
return t[(
|
|
1563
|
+
return t[(r - 1) * 4 + 3];
|
|
1564
1564
|
default:
|
|
1565
1565
|
return;
|
|
1566
1566
|
}
|
|
1567
1567
|
};
|
|
1568
|
-
return
|
|
1569
|
-
const c = n(
|
|
1568
|
+
return o.getRSBlocks = function(r, s) {
|
|
1569
|
+
const c = n(r, s);
|
|
1570
1570
|
if (typeof c > "u")
|
|
1571
|
-
throw "bad rs block @ typeNumber:" +
|
|
1571
|
+
throw "bad rs block @ typeNumber:" + r + "/errorCorrectionLevel:" + s;
|
|
1572
1572
|
const i = c.length / 3, a = [];
|
|
1573
1573
|
for (let y = 0; y < i; y += 1) {
|
|
1574
|
-
const
|
|
1575
|
-
for (let
|
|
1574
|
+
const T = c[y * 3 + 0], m = c[y * 3 + 1], f = c[y * 3 + 2];
|
|
1575
|
+
for (let h = 0; h < T; h += 1)
|
|
1576
1576
|
a.push(e(m, f));
|
|
1577
1577
|
}
|
|
1578
1578
|
return a;
|
|
1579
|
-
},
|
|
1580
|
-
})(),
|
|
1579
|
+
}, o;
|
|
1580
|
+
})(), Mt = function() {
|
|
1581
1581
|
const t = [];
|
|
1582
1582
|
let e = 0;
|
|
1583
|
-
const
|
|
1584
|
-
return
|
|
1583
|
+
const o = {};
|
|
1584
|
+
return o.getBuffer = function() {
|
|
1585
1585
|
return t;
|
|
1586
|
-
},
|
|
1587
|
-
const
|
|
1588
|
-
return (t[
|
|
1589
|
-
},
|
|
1590
|
-
for (let s = 0; s <
|
|
1591
|
-
|
|
1592
|
-
},
|
|
1586
|
+
}, o.getAt = function(n) {
|
|
1587
|
+
const r = Math.floor(n / 8);
|
|
1588
|
+
return (t[r] >>> 7 - n % 8 & 1) == 1;
|
|
1589
|
+
}, o.put = function(n, r) {
|
|
1590
|
+
for (let s = 0; s < r; s += 1)
|
|
1591
|
+
o.putBit((n >>> r - s - 1 & 1) == 1);
|
|
1592
|
+
}, o.getLengthInBits = function() {
|
|
1593
1593
|
return e;
|
|
1594
|
-
},
|
|
1595
|
-
const
|
|
1596
|
-
t.length <=
|
|
1597
|
-
},
|
|
1594
|
+
}, o.putBit = function(n) {
|
|
1595
|
+
const r = Math.floor(e / 8);
|
|
1596
|
+
t.length <= r && t.push(0), n && (t[r] |= 128 >>> e % 8), e += 1;
|
|
1597
|
+
}, o;
|
|
1598
1598
|
}, Ae = function(t) {
|
|
1599
|
-
const e = P.MODE_NUMBER,
|
|
1599
|
+
const e = P.MODE_NUMBER, o = t, n = {};
|
|
1600
1600
|
n.getMode = function() {
|
|
1601
1601
|
return e;
|
|
1602
1602
|
}, n.getLength = function(c) {
|
|
1603
|
-
return
|
|
1603
|
+
return o.length;
|
|
1604
1604
|
}, n.write = function(c) {
|
|
1605
|
-
const i =
|
|
1605
|
+
const i = o;
|
|
1606
1606
|
let a = 0;
|
|
1607
1607
|
for (; a + 2 < i.length; )
|
|
1608
|
-
c.put(
|
|
1609
|
-
a < i.length && (i.length - a == 1 ? c.put(
|
|
1608
|
+
c.put(r(i.substring(a, a + 3)), 10), a += 3;
|
|
1609
|
+
a < i.length && (i.length - a == 1 ? c.put(r(i.substring(a, a + 1)), 4) : i.length - a == 2 && c.put(r(i.substring(a, a + 2)), 7));
|
|
1610
1610
|
};
|
|
1611
|
-
const
|
|
1611
|
+
const r = function(c) {
|
|
1612
1612
|
let i = 0;
|
|
1613
1613
|
for (let a = 0; a < c.length; a += 1)
|
|
1614
1614
|
i = i * 10 + s(c.charAt(a));
|
|
@@ -1620,22 +1620,22 @@ const P = {
|
|
|
1620
1620
|
};
|
|
1621
1621
|
return n;
|
|
1622
1622
|
}, Oe = function(t) {
|
|
1623
|
-
const e = P.MODE_ALPHA_NUM,
|
|
1623
|
+
const e = P.MODE_ALPHA_NUM, o = t, n = {};
|
|
1624
1624
|
n.getMode = function() {
|
|
1625
1625
|
return e;
|
|
1626
1626
|
}, n.getLength = function(s) {
|
|
1627
|
-
return
|
|
1627
|
+
return o.length;
|
|
1628
1628
|
}, n.write = function(s) {
|
|
1629
|
-
const c =
|
|
1629
|
+
const c = o;
|
|
1630
1630
|
let i = 0;
|
|
1631
1631
|
for (; i + 1 < c.length; )
|
|
1632
1632
|
s.put(
|
|
1633
|
-
|
|
1633
|
+
r(c.charAt(i)) * 45 + r(c.charAt(i + 1)),
|
|
1634
1634
|
11
|
|
1635
1635
|
), i += 2;
|
|
1636
|
-
i < c.length && s.put(
|
|
1636
|
+
i < c.length && s.put(r(c.charAt(i)), 6);
|
|
1637
1637
|
};
|
|
1638
|
-
const
|
|
1638
|
+
const r = function(s) {
|
|
1639
1639
|
if ("0" <= s && s <= "9")
|
|
1640
1640
|
return s.charCodeAt(0) - 48;
|
|
1641
1641
|
if ("A" <= s && s <= "Z")
|
|
@@ -1665,28 +1665,28 @@ const P = {
|
|
|
1665
1665
|
};
|
|
1666
1666
|
return n;
|
|
1667
1667
|
}, Ne = function(t) {
|
|
1668
|
-
const e = P.MODE_8BIT_BYTE,
|
|
1668
|
+
const e = P.MODE_8BIT_BYTE, o = V.stringToBytes(t), n = {};
|
|
1669
1669
|
return n.getMode = function() {
|
|
1670
1670
|
return e;
|
|
1671
|
-
}, n.getLength = function(
|
|
1672
|
-
return
|
|
1673
|
-
}, n.write = function(
|
|
1674
|
-
for (let s = 0; s <
|
|
1675
|
-
|
|
1671
|
+
}, n.getLength = function(r) {
|
|
1672
|
+
return o.length;
|
|
1673
|
+
}, n.write = function(r) {
|
|
1674
|
+
for (let s = 0; s < o.length; s += 1)
|
|
1675
|
+
r.put(o[s], 8);
|
|
1676
1676
|
}, n;
|
|
1677
1677
|
}, Me = function(t) {
|
|
1678
|
-
const e = P.MODE_KANJI,
|
|
1678
|
+
const e = P.MODE_KANJI, o = V.stringToBytes;
|
|
1679
1679
|
(function(s, c) {
|
|
1680
|
-
const i =
|
|
1680
|
+
const i = o(s);
|
|
1681
1681
|
if (i.length != 2 || (i[0] << 8 | i[1]) != c)
|
|
1682
1682
|
throw "sjis not supported.";
|
|
1683
1683
|
})("友", 38726);
|
|
1684
|
-
const n =
|
|
1685
|
-
return
|
|
1684
|
+
const n = o(t), r = {};
|
|
1685
|
+
return r.getMode = function() {
|
|
1686
1686
|
return e;
|
|
1687
|
-
},
|
|
1687
|
+
}, r.getLength = function(s) {
|
|
1688
1688
|
return ~~(n.length / 2);
|
|
1689
|
-
},
|
|
1689
|
+
}, r.write = function(s) {
|
|
1690
1690
|
const c = n;
|
|
1691
1691
|
let i = 0;
|
|
1692
1692
|
for (; i + 1 < c.length; ) {
|
|
@@ -1701,32 +1701,32 @@ const P = {
|
|
|
1701
1701
|
}
|
|
1702
1702
|
if (i < c.length)
|
|
1703
1703
|
throw "illegal char at " + (i + 1);
|
|
1704
|
-
},
|
|
1705
|
-
},
|
|
1704
|
+
}, r;
|
|
1705
|
+
}, Gt = function() {
|
|
1706
1706
|
const t = [], e = {};
|
|
1707
|
-
return e.writeByte = function(
|
|
1708
|
-
t.push(
|
|
1709
|
-
}, e.writeShort = function(
|
|
1710
|
-
e.writeByte(
|
|
1711
|
-
}, e.writeBytes = function(
|
|
1712
|
-
n = n || 0,
|
|
1713
|
-
for (let s = 0; s <
|
|
1714
|
-
e.writeByte(
|
|
1715
|
-
}, e.writeString = function(
|
|
1716
|
-
for (let n = 0; n <
|
|
1717
|
-
e.writeByte(
|
|
1707
|
+
return e.writeByte = function(o) {
|
|
1708
|
+
t.push(o & 255);
|
|
1709
|
+
}, e.writeShort = function(o) {
|
|
1710
|
+
e.writeByte(o), e.writeByte(o >>> 8);
|
|
1711
|
+
}, e.writeBytes = function(o, n, r) {
|
|
1712
|
+
n = n || 0, r = r || o.length;
|
|
1713
|
+
for (let s = 0; s < r; s += 1)
|
|
1714
|
+
e.writeByte(o[s + n]);
|
|
1715
|
+
}, e.writeString = function(o) {
|
|
1716
|
+
for (let n = 0; n < o.length; n += 1)
|
|
1717
|
+
e.writeByte(o.charCodeAt(n));
|
|
1718
1718
|
}, e.toByteArray = function() {
|
|
1719
1719
|
return t;
|
|
1720
1720
|
}, e.toString = function() {
|
|
1721
|
-
let
|
|
1722
|
-
|
|
1721
|
+
let o = "";
|
|
1722
|
+
o += "[";
|
|
1723
1723
|
for (let n = 0; n < t.length; n += 1)
|
|
1724
|
-
n > 0 && (
|
|
1725
|
-
return
|
|
1724
|
+
n > 0 && (o += ","), o += t[n];
|
|
1725
|
+
return o += "]", o;
|
|
1726
1726
|
}, e;
|
|
1727
1727
|
}, xe = function() {
|
|
1728
|
-
let t = 0, e = 0,
|
|
1729
|
-
const
|
|
1728
|
+
let t = 0, e = 0, o = 0, n = "";
|
|
1729
|
+
const r = {}, s = function(i) {
|
|
1730
1730
|
n += String.fromCharCode(c(i & 63));
|
|
1731
1731
|
}, c = function(i) {
|
|
1732
1732
|
if (i < 0)
|
|
@@ -1743,38 +1743,38 @@ const P = {
|
|
|
1743
1743
|
return 47;
|
|
1744
1744
|
throw "n:" + i;
|
|
1745
1745
|
};
|
|
1746
|
-
return
|
|
1747
|
-
for (t = t << 8 | i & 255, e += 8,
|
|
1746
|
+
return r.writeByte = function(i) {
|
|
1747
|
+
for (t = t << 8 | i & 255, e += 8, o += 1; e >= 6; )
|
|
1748
1748
|
s(t >>> e - 6), e -= 6;
|
|
1749
|
-
},
|
|
1750
|
-
if (e > 0 && (s(t << 6 - e), t = 0, e = 0),
|
|
1751
|
-
const i = 3 -
|
|
1749
|
+
}, r.flush = function() {
|
|
1750
|
+
if (e > 0 && (s(t << 6 - e), t = 0, e = 0), o % 3 != 0) {
|
|
1751
|
+
const i = 3 - o % 3;
|
|
1752
1752
|
for (let a = 0; a < i; a += 1)
|
|
1753
1753
|
n += "=";
|
|
1754
1754
|
}
|
|
1755
|
-
},
|
|
1755
|
+
}, r.toString = function() {
|
|
1756
1756
|
return n;
|
|
1757
|
-
},
|
|
1757
|
+
}, r;
|
|
1758
1758
|
}, $e = function(t) {
|
|
1759
1759
|
const e = t;
|
|
1760
|
-
let
|
|
1760
|
+
let o = 0, n = 0, r = 0;
|
|
1761
1761
|
const s = {};
|
|
1762
1762
|
s.read = function() {
|
|
1763
|
-
for (;
|
|
1764
|
-
if (
|
|
1765
|
-
if (
|
|
1763
|
+
for (; r < 8; ) {
|
|
1764
|
+
if (o >= e.length) {
|
|
1765
|
+
if (r == 0)
|
|
1766
1766
|
return -1;
|
|
1767
|
-
throw "unexpected end of file./" +
|
|
1767
|
+
throw "unexpected end of file./" + r;
|
|
1768
1768
|
}
|
|
1769
|
-
const a = e.charAt(
|
|
1770
|
-
if (
|
|
1771
|
-
return
|
|
1769
|
+
const a = e.charAt(o);
|
|
1770
|
+
if (o += 1, a == "=")
|
|
1771
|
+
return r = 0, -1;
|
|
1772
1772
|
if (a.match(/^\s$/))
|
|
1773
1773
|
continue;
|
|
1774
|
-
n = n << 6 | c(a.charCodeAt(0)),
|
|
1774
|
+
n = n << 6 | c(a.charCodeAt(0)), r += 6;
|
|
1775
1775
|
}
|
|
1776
|
-
const i = n >>>
|
|
1777
|
-
return
|
|
1776
|
+
const i = n >>> r - 8 & 255;
|
|
1777
|
+
return r -= 8, i;
|
|
1778
1778
|
};
|
|
1779
1779
|
const c = function(i) {
|
|
1780
1780
|
if (65 <= i && i <= 90)
|
|
@@ -1791,56 +1791,56 @@ const P = {
|
|
|
1791
1791
|
};
|
|
1792
1792
|
return s;
|
|
1793
1793
|
}, Le = function(t, e) {
|
|
1794
|
-
const
|
|
1795
|
-
s.setPixel = function(y,
|
|
1796
|
-
|
|
1794
|
+
const o = t, n = e, r = new Array(t * e), s = {};
|
|
1795
|
+
s.setPixel = function(y, T, m) {
|
|
1796
|
+
r[T * o + y] = m;
|
|
1797
1797
|
}, s.write = function(y) {
|
|
1798
|
-
y.writeString("GIF87a"), y.writeShort(
|
|
1799
|
-
const
|
|
1800
|
-
y.writeByte(
|
|
1798
|
+
y.writeString("GIF87a"), y.writeShort(o), y.writeShort(n), y.writeByte(128), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(255), y.writeByte(255), y.writeByte(255), y.writeString(","), y.writeShort(0), y.writeShort(0), y.writeShort(o), y.writeShort(n), y.writeByte(0);
|
|
1799
|
+
const T = 2, m = i(T);
|
|
1800
|
+
y.writeByte(T);
|
|
1801
1801
|
let f = 0;
|
|
1802
1802
|
for (; m.length - f > 255; )
|
|
1803
1803
|
y.writeByte(255), y.writeBytes(m, f, 255), f += 255;
|
|
1804
1804
|
y.writeByte(m.length - f), y.writeBytes(m, f, m.length - f), y.writeByte(0), y.writeString(";");
|
|
1805
1805
|
};
|
|
1806
1806
|
const c = function(y) {
|
|
1807
|
-
const
|
|
1807
|
+
const T = y;
|
|
1808
1808
|
let m = 0, f = 0;
|
|
1809
|
-
const
|
|
1810
|
-
return
|
|
1809
|
+
const h = {};
|
|
1810
|
+
return h.write = function(l, u) {
|
|
1811
1811
|
if (l >>> u)
|
|
1812
1812
|
throw "length over";
|
|
1813
1813
|
for (; m + u >= 8; )
|
|
1814
|
-
|
|
1814
|
+
T.writeByte(255 & (l << m | f)), u -= 8 - m, l >>>= 8 - m, f = 0, m = 0;
|
|
1815
1815
|
f = l << m | f, m = m + u;
|
|
1816
|
-
},
|
|
1817
|
-
m > 0 &&
|
|
1818
|
-
},
|
|
1816
|
+
}, h.flush = function() {
|
|
1817
|
+
m > 0 && T.writeByte(f);
|
|
1818
|
+
}, h;
|
|
1819
1819
|
}, i = function(y) {
|
|
1820
|
-
const
|
|
1820
|
+
const T = 1 << y, m = (1 << y) + 1;
|
|
1821
1821
|
let f = y + 1;
|
|
1822
|
-
const
|
|
1823
|
-
for (let C = 0; C <
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
const l =
|
|
1827
|
-
u.write(
|
|
1828
|
-
let g = 0, A = String.fromCharCode(
|
|
1829
|
-
for (g += 1; g <
|
|
1830
|
-
const C = String.fromCharCode(
|
|
1831
|
-
g += 1,
|
|
1822
|
+
const h = a();
|
|
1823
|
+
for (let C = 0; C < T; C += 1)
|
|
1824
|
+
h.add(String.fromCharCode(C));
|
|
1825
|
+
h.add(String.fromCharCode(T)), h.add(String.fromCharCode(m));
|
|
1826
|
+
const l = Gt(), u = c(l);
|
|
1827
|
+
u.write(T, f);
|
|
1828
|
+
let g = 0, A = String.fromCharCode(r[g]);
|
|
1829
|
+
for (g += 1; g < r.length; ) {
|
|
1830
|
+
const C = String.fromCharCode(r[g]);
|
|
1831
|
+
g += 1, h.contains(A + C) ? A = A + C : (u.write(h.indexOf(A), f), h.size() < 4095 && (h.size() == 1 << f && (f += 1), h.add(A + C)), A = C);
|
|
1832
1832
|
}
|
|
1833
|
-
return u.write(
|
|
1833
|
+
return u.write(h.indexOf(A), f), u.write(m, f), u.flush(), l.toByteArray();
|
|
1834
1834
|
}, a = function() {
|
|
1835
1835
|
const y = {};
|
|
1836
|
-
let
|
|
1836
|
+
let T = 0;
|
|
1837
1837
|
const m = {};
|
|
1838
1838
|
return m.add = function(f) {
|
|
1839
1839
|
if (m.contains(f))
|
|
1840
1840
|
throw "dup key:" + f;
|
|
1841
|
-
y[f] =
|
|
1841
|
+
y[f] = T, T += 1;
|
|
1842
1842
|
}, m.size = function() {
|
|
1843
|
-
return
|
|
1843
|
+
return T;
|
|
1844
1844
|
}, m.indexOf = function(f) {
|
|
1845
1845
|
return y[f];
|
|
1846
1846
|
}, m.contains = function(f) {
|
|
@@ -1848,74 +1848,74 @@ const P = {
|
|
|
1848
1848
|
}, m;
|
|
1849
1849
|
};
|
|
1850
1850
|
return s;
|
|
1851
|
-
}, _e = function(t, e,
|
|
1851
|
+
}, _e = function(t, e, o) {
|
|
1852
1852
|
const n = Le(t, e);
|
|
1853
1853
|
for (let i = 0; i < e; i += 1)
|
|
1854
1854
|
for (let a = 0; a < t; a += 1)
|
|
1855
|
-
n.setPixel(a, i,
|
|
1856
|
-
const
|
|
1857
|
-
n.write(
|
|
1858
|
-
const s = xe(), c =
|
|
1855
|
+
n.setPixel(a, i, o(a, i));
|
|
1856
|
+
const r = Gt();
|
|
1857
|
+
n.write(r);
|
|
1858
|
+
const s = xe(), c = r.toByteArray();
|
|
1859
1859
|
for (let i = 0; i < c.length; i += 1)
|
|
1860
1860
|
s.writeByte(c[i]);
|
|
1861
1861
|
return s.flush(), "data:image/gif;base64," + s;
|
|
1862
1862
|
};
|
|
1863
1863
|
V.stringToBytes;
|
|
1864
1864
|
function De(t) {
|
|
1865
|
-
const e = V(0, "M"),
|
|
1866
|
-
e.addData(
|
|
1865
|
+
const e = V(0, "M"), o = Array.from(new TextEncoder().encode(t), (s) => String.fromCharCode(s)).join("");
|
|
1866
|
+
e.addData(o, /^\d+$/.test(t) ? "Numeric" : "Byte"), e.make();
|
|
1867
1867
|
const n = e.getModuleCount();
|
|
1868
|
-
let
|
|
1869
|
-
for (let s = 0; s < n; s++) for (let c = 0; c < n; c++) e.isDark(s, c) && (
|
|
1870
|
-
return { count: n, path:
|
|
1868
|
+
let r = "";
|
|
1869
|
+
for (let s = 0; s < n; s++) for (let c = 0; c < n; c++) e.isDark(s, c) && (r += `M${c} ${s}h1v1h-1z`);
|
|
1870
|
+
return { count: n, path: r };
|
|
1871
1871
|
}
|
|
1872
1872
|
class ut extends Error {
|
|
1873
|
-
constructor(
|
|
1874
|
-
super(
|
|
1875
|
-
|
|
1876
|
-
this.name = "AnswerSheetDataError", this.issues =
|
|
1873
|
+
constructor(o) {
|
|
1874
|
+
super(o[0]?.message || "题卡数据无效");
|
|
1875
|
+
wt(this, "issues");
|
|
1876
|
+
this.name = "AnswerSheetDataError", this.issues = o;
|
|
1877
1877
|
}
|
|
1878
1878
|
}
|
|
1879
1879
|
function ke(t, e) {
|
|
1880
|
-
const
|
|
1880
|
+
const o = (l, u = "题卡数据结构无效") => {
|
|
1881
1881
|
throw new ut([{ code: "INVALID_DATA", path: l, message: u }]);
|
|
1882
|
-
}, n = (l, u) => !l || typeof l != "object" || Array.isArray(l) ?
|
|
1883
|
-
typeof l != "string" &&
|
|
1882
|
+
}, n = (l, u) => !l || typeof l != "object" || Array.isArray(l) ? o(u) : l, r = (l, u) => Array.isArray(l) ? l : o(u), s = (l, u) => {
|
|
1883
|
+
typeof l != "string" && o(u);
|
|
1884
1884
|
}, c = (l, u, g = 0, A = 1e5) => {
|
|
1885
|
-
(typeof l != "number" || !Number.isFinite(l) || l < g || l > A) &&
|
|
1885
|
+
(typeof l != "number" || !Number.isFinite(l) || l < g || l > A) && o(u);
|
|
1886
1886
|
}, i = (l, u) => {
|
|
1887
1887
|
n(l, u);
|
|
1888
1888
|
const g = e.validateDocument(l);
|
|
1889
|
-
g.length &&
|
|
1889
|
+
g.length && o(u, g[0]);
|
|
1890
1890
|
}, a = (l, u) => {
|
|
1891
1891
|
const g = n(l, u);
|
|
1892
|
-
if (s(g.id, `${u}.id`), s(g.label, `${u}.label`), (typeof g.multiple != "boolean" || typeof g.breakBefore != "boolean") &&
|
|
1892
|
+
if (s(g.id, `${u}.id`), s(g.label, `${u}.label`), (typeof g.multiple != "boolean" || typeof g.breakBefore != "boolean") && o(u), g.contentTarget !== void 0 && g.contentTarget !== null) {
|
|
1893
1893
|
const A = n(g.contentTarget, `${u}.contentTarget`);
|
|
1894
|
-
s(A.groupId, `${u}.contentTarget.groupId`),
|
|
1894
|
+
s(A.groupId, `${u}.contentTarget.groupId`), r(A.optionIds, `${u}.contentTarget.optionIds`).forEach((C, M) => s(C, `${u}.contentTarget.optionIds.${M}`));
|
|
1895
1895
|
}
|
|
1896
|
-
|
|
1897
|
-
const
|
|
1898
|
-
s(
|
|
1899
|
-
}),
|
|
1896
|
+
r(g.options, `${u}.options`).forEach((A, C) => {
|
|
1897
|
+
const M = n(A, `${u}.options.${C}`);
|
|
1898
|
+
s(M.id, `${u}.options.${C}.id`), s(M.label, `${u}.options.${C}.label`);
|
|
1899
|
+
}), r(g.correctIds, `${u}.correctIds`).forEach((A, C) => s(A, `${u}.correctIds.${C}`));
|
|
1900
1900
|
}, y = (l, u) => {
|
|
1901
1901
|
const g = n(l, u);
|
|
1902
|
-
(!["row", "column"].includes(String(g.direction)) || !["concentrated", "distributed", "stem", "option"].includes(String(g.presentation)) || !["box", "check", "bubble"].includes(String(g.marker))) &&
|
|
1903
|
-
},
|
|
1902
|
+
(!["row", "column"].includes(String(g.direction)) || !["concentrated", "distributed", "stem", "option"].includes(String(g.presentation)) || !["box", "check", "bubble"].includes(String(g.marker))) && o(u), c(g.rowsPerColumn, `${u}.rowsPerColumn`, 1, 5), c(g.rowGap, `${u}.rowGap`, 0, 64), c(g.columnGap, `${u}.columnGap`, 0, 64), r(g.questions, `${u}.questions`).forEach((A, C) => a(A, `${u}.questions.${C}`));
|
|
1903
|
+
}, T = /* @__PURE__ */ new WeakSet(), m = (l, u) => {
|
|
1904
1904
|
if (!(!l || typeof l != "object")) {
|
|
1905
|
-
if (
|
|
1906
|
-
|
|
1905
|
+
if (T.has(l)) return o(u, "题卡必须是无循环引用的 JSON 数据");
|
|
1906
|
+
T.add(l), Object.entries(l).forEach(([g, A]) => m(A, `${u}.${g}`)), T.delete(l);
|
|
1907
1907
|
}
|
|
1908
1908
|
}, f = n(t, "");
|
|
1909
|
-
if (f.version !== 1 &&
|
|
1910
|
-
f[l] !== void 0 && typeof f[l] != "boolean" &&
|
|
1911
|
-
}), ["a4", "a3-two", "a3-three"].includes(String(f.preset)) ||
|
|
1909
|
+
if (f.version !== 1 && o("version", "不支持的题卡数据版本"), s(f.title, "title"), f.usage !== void 0 && !["exam", "homework"].includes(String(f.usage)) && o("usage"), ["questionCard", "duplex", "scanMarking", "halfPoint", "mergeObjective"].forEach((l) => {
|
|
1910
|
+
f[l] !== void 0 && typeof f[l] != "boolean" && o(l);
|
|
1911
|
+
}), ["a4", "a3-two", "a3-three"].includes(String(f.preset)) || o("preset"), c(f.margin, "margin", 0, 100), c(f.gap, "gap", 0, 100), f.creation) {
|
|
1912
1912
|
const l = n(f.creation, "creation");
|
|
1913
|
-
["template", "exam"].includes(String(l.mode)) ||
|
|
1914
|
-
for (const u of ["gradeCode", "courseCode", "subjectCode"]) l[u] !== void 0 && (typeof l[u] != "string" || !l[u].trim()) &&
|
|
1915
|
-
l.phaseCode !== void 0 && !["P", "J", "S"].includes(String(l.phaseCode)) &&
|
|
1913
|
+
["template", "exam"].includes(String(l.mode)) || o("creation.mode"), ["name", "grade", "subject"].forEach((u) => s(l[u], `creation.${u}`));
|
|
1914
|
+
for (const u of ["gradeCode", "courseCode", "subjectCode"]) l[u] !== void 0 && (typeof l[u] != "string" || !l[u].trim()) && o(`creation.${u}`);
|
|
1915
|
+
l.phaseCode !== void 0 && !["P", "J", "S"].includes(String(l.phaseCode)) && o("creation.phaseCode"), l.createMode !== void 0 && !["MANUALLY", "IMPORTED", "THIRD"].includes(String(l.createMode)) && o("creation.createMode");
|
|
1916
1916
|
for (const u of ["id", "exampaperId"]) if (l[u] !== void 0) {
|
|
1917
1917
|
const g = l[u];
|
|
1918
|
-
typeof g == "string" && g.trim() || typeof g == "number" && Number.isSafeInteger(g) && g >= 0 ||
|
|
1918
|
+
typeof g == "string" && g.trim() || typeof g == "number" && Number.isSafeInteger(g) && g >= 0 || o(`creation.${u}`);
|
|
1919
1919
|
}
|
|
1920
1920
|
}
|
|
1921
1921
|
if (f.paperTitle) {
|
|
@@ -1924,16 +1924,16 @@ function ke(t, e) {
|
|
|
1924
1924
|
}
|
|
1925
1925
|
if (f.header) {
|
|
1926
1926
|
const l = n(f.header, "header");
|
|
1927
|
-
["code", "school"].includes(String(l.kaohao)) ||
|
|
1927
|
+
["code", "school"].includes(String(l.kaohao)) || o("header.kaohao"), c(l.weishu, "header.weishu", 1, 20), l.tiaomaStyle !== void 0 && ![1, 2].includes(l.tiaomaStyle) && o("header.tiaomaStyle"), l.classText !== void 0 && typeof l.classText != "boolean" && o("header.classText");
|
|
1928
1928
|
}
|
|
1929
1929
|
if (f.recognition !== void 0) {
|
|
1930
1930
|
const l = n(f.recognition, "recognition");
|
|
1931
|
-
for (const u of ["examQrCode", "subjectMarkers", "pointBlack"]) l[u] !== void 0 && typeof l[u] != "boolean" &&
|
|
1931
|
+
for (const u of ["examQrCode", "subjectMarkers", "pointBlack"]) l[u] !== void 0 && typeof l[u] != "boolean" && o(`recognition.${u}`);
|
|
1932
1932
|
}
|
|
1933
|
-
|
|
1933
|
+
r(f.blocks, "blocks").forEach((l, u) => {
|
|
1934
1934
|
const g = `blocks.${u}`, A = n(l, g);
|
|
1935
1935
|
if (s(A.id, `${g}.id`), s(A.title, `${g}.title`), c(A.answerHeight, `${g}.answerHeight`), i(A.document, `${g}.document`), A.kind === "area") {
|
|
1936
|
-
(!["forbiden", "editArea"].includes(String(A.areaType)) || A.reference || A.choices || A.exercise) &&
|
|
1936
|
+
(!["forbiden", "editArea"].includes(String(A.areaType)) || A.reference || A.choices || A.exercise) && o(`${g}.areaType`), c(A.answerHeight, `${g}.answerHeight`, 100, 4e3);
|
|
1937
1937
|
return;
|
|
1938
1938
|
}
|
|
1939
1939
|
if (!A.reference) {
|
|
@@ -1941,28 +1941,28 @@ function ke(t, e) {
|
|
|
1941
1941
|
y(A.choices, `${g}.choices`);
|
|
1942
1942
|
return;
|
|
1943
1943
|
}
|
|
1944
|
-
|
|
1944
|
+
o(`${g}.reference`, "请使用包含 reference 题目结构的制卡数据");
|
|
1945
1945
|
}
|
|
1946
1946
|
const C = n(A.reference, `${g}.reference`);
|
|
1947
|
-
C.material !== void 0 && i(C.material, `${g}.reference.material`), C.textVersion !== void 0 && C.textVersion !== 1 &&
|
|
1948
|
-
const
|
|
1949
|
-
Object.hasOwn(lt, String(O.type)) ||
|
|
1950
|
-
const
|
|
1951
|
-
if (!
|
|
1952
|
-
const
|
|
1953
|
-
i(
|
|
1947
|
+
C.material !== void 0 && i(C.material, `${g}.reference.material`), C.textVersion !== void 0 && C.textVersion !== 1 && o(`${g}.reference.textVersion`), Object.hasOwn(It, String(C.type)) || o(`${g}.reference.type`), y(C.layout, `${g}.reference.layout`), c(C.optionalHeight, `${g}.reference.optionalHeight`), r(C.questions, `${g}.reference.questions`).forEach((M, $) => {
|
|
1948
|
+
const b = `${g}.reference.questions.${$}`, O = n(M, b);
|
|
1949
|
+
Object.hasOwn(lt, String(O.type)) || o(`${b}.type`), s(O.id, `${b}.id`), s(O.label, `${b}.label`), a(O.choice, `${b}.choice`), ["height", "contentHeight", "characters", "lines"].forEach((E) => c(O[E], `${b}.${E}`)), i(O.document, `${b}.document`);
|
|
1950
|
+
const p = (E, d) => {
|
|
1951
|
+
if (!E) return;
|
|
1952
|
+
const I = n(E, d);
|
|
1953
|
+
i(I.content, `${d}.content`), n(I.layout, `${d}.layout`), s(I.groupId, `${d}.groupId`), r(I.itemsContent, `${d}.itemsContent`).forEach((w, S) => {
|
|
1954
1954
|
const N = n(w, `${d}.itemsContent.${S}`);
|
|
1955
1955
|
s(N.id, `${d}.itemsContent.${S}.id`), s(N.key, `${d}.itemsContent.${S}.key`), i(N.content, `${d}.itemsContent.${S}.content`);
|
|
1956
1956
|
});
|
|
1957
1957
|
};
|
|
1958
|
-
|
|
1959
|
-
const
|
|
1960
|
-
s(w.id, `${
|
|
1958
|
+
p(O.text, `${b}.text`), r(O.parts, `${b}.parts`).forEach((E, d) => {
|
|
1959
|
+
const I = `${b}.parts.${d}`, w = n(E, I);
|
|
1960
|
+
s(w.id, `${I}.id`), s(w.label, `${I}.label`), c(w.width, `${I}.width`), c(w.height, `${I}.height`), i(w.document, `${I}.document`), a(w.choice, `${I}.choice`), p(w.text, `${I}.text`);
|
|
1961
1961
|
});
|
|
1962
1962
|
});
|
|
1963
1963
|
}), m(t, "");
|
|
1964
|
-
const
|
|
1965
|
-
(
|
|
1964
|
+
const h = Ct(t);
|
|
1965
|
+
(h.columnWidth < 100 || h.contentHeight < 100) && o("margin", "边距或栏间距过大,纸张没有足够的作答区域");
|
|
1966
1966
|
}
|
|
1967
1967
|
function rt(t) {
|
|
1968
1968
|
return !t || t.marks?.some((e) => e.type === "documentLabel") ? !1 : t.type === "text" ? !!t.text?.trim() : t.type === "image" ? !!t.attrs?.src : t.type === "formula" || t.type === "blockFormula" ? !!t.attrs?.latex?.trim() : !!t.content?.some(rt);
|
|
@@ -1970,155 +1970,155 @@ function rt(t) {
|
|
|
1970
1970
|
function Nn(t, e) {
|
|
1971
1971
|
try {
|
|
1972
1972
|
ke(t, e);
|
|
1973
|
-
} catch (
|
|
1974
|
-
return { valid: !1, issues:
|
|
1973
|
+
} catch (h) {
|
|
1974
|
+
return { valid: !1, issues: h instanceof ut ? h.issues : [{ code: "INVALID_DATA", path: "", message: "题卡数据无法读取" }] };
|
|
1975
1975
|
}
|
|
1976
|
-
const
|
|
1976
|
+
const o = [];
|
|
1977
1977
|
let n = {};
|
|
1978
|
-
const
|
|
1979
|
-
(!
|
|
1980
|
-
}, i = (
|
|
1981
|
-
(
|
|
1982
|
-
}, a = (
|
|
1983
|
-
(
|
|
1984
|
-
}, y = (
|
|
1985
|
-
A && !rt(
|
|
1978
|
+
const r = (h, l, u) => o.push({ code: h, path: l, message: u, ...n }), s = /* @__PURE__ */ new Set(), c = (h, l) => {
|
|
1979
|
+
(!h.trim() || s.has(h)) && r("DUPLICATE_ID", l, "题块、题目和选项 ID 必须非空且唯一"), s.add(h);
|
|
1980
|
+
}, i = (h, l, u) => {
|
|
1981
|
+
(h === null || !Number.isFinite(h) || h < (t.usage === "homework" ? 0 : 0.5) || h > l || !Number.isInteger(h * 2)) && r("INVALID_SCORE", u, `分值须为 ${t.usage === "homework" ? 0 : 0.5}–${l} 分,按 0.5 分递增`);
|
|
1982
|
+
}, a = (h, l, u) => {
|
|
1983
|
+
(h.options.length < l[0] || h.options.length > l[1]) && r("INVALID_OPTIONS", `${u}.options`, `选项个数须为 ${l[0]}–${l[1]}`), h.options.forEach((g, A) => c(g.id, `${u}.options.${A}.id`)), (new Set(h.correctIds).size !== h.correctIds.length || h.correctIds.some((g) => !h.options.some((A) => A.id === g))) && r("INVALID_ANSWER_REFERENCE", `${u}.correctIds`, "答案引用了不存在或重复的选项");
|
|
1984
|
+
}, y = (h, l, u, g = 0, A = !0) => {
|
|
1985
|
+
A && !rt(h?.content.content) && r("MISSING_CONTENT", `${l}.content`, "请填写题干或材料"), u && (h?.itemsContent.length !== g || h.itemsContent.some((C) => !rt(C.content.content))) && r("MISSING_OPTION_CONTENT", `${l}.itemsContent`, "请补全每个选项的内容");
|
|
1986
1986
|
};
|
|
1987
|
-
if (t.title.trim() ||
|
|
1988
|
-
const
|
|
1989
|
-
if (!
|
|
1987
|
+
if (t.title.trim() || r("MISSING_TITLE", "title", "请填写题卡名称"), t.recognition?.examQrCode) {
|
|
1988
|
+
const h = String(t.creation?.exampaperId ?? "").trim();
|
|
1989
|
+
if (!h) r("MISSING_EXAM_ID", "creation.exampaperId", "显示试卷二维码需要填写试卷 ID");
|
|
1990
1990
|
else
|
|
1991
1991
|
try {
|
|
1992
|
-
De(
|
|
1992
|
+
De(h);
|
|
1993
1993
|
} catch {
|
|
1994
|
-
|
|
1994
|
+
r("INVALID_QR_PAYLOAD", "creation.exampaperId", "试卷 ID 太长,无法生成二维码");
|
|
1995
1995
|
}
|
|
1996
1996
|
}
|
|
1997
|
-
t.header && t.recognition?.subjectMarkers !== !1 && !
|
|
1998
|
-
n = { blockId:
|
|
1997
|
+
t.header && t.recognition?.subjectMarkers !== !1 && !jt[Se(t.creation) || ""] && r("UNKNOWN_SUBJECT_MARK", "creation.subjectCode", "当前学科没有参考识别编码,请配置标准学科或关闭学科标记"), (!t.creation?.grade.trim() || !t.creation.subject.trim()) && r("MISSING_CREATION", "creation", "请选择年级和学科"), (!t.paperTitle || !rt(t.paperTitle.document.content)) && r("MISSING_PAPER_TITLE", "paperTitle", "请填写纸面标题"), t.blocks.some((h) => h.kind !== "area") || r("EMPTY_CARD", "blocks", "请至少添加一个题块和一道题目"), t.paperTitle && c(t.paperTitle.id, "paperTitle.id"), t.blocks.forEach((h, l) => {
|
|
1998
|
+
n = { blockId: h.id };
|
|
1999
1999
|
const u = `blocks.${l}`;
|
|
2000
|
-
if (c(
|
|
2001
|
-
|
|
2000
|
+
if (c(h.id, `${u}.id`), h.kind === "area") {
|
|
2001
|
+
h.areaType === (t.questionCard ? "forbiden" : "editArea") && r("INVALID_AREA_MODE", `${u}.areaType`, "题卡合一使用空白答题区,独立答题卡使用禁止答题区");
|
|
2002
2002
|
return;
|
|
2003
2003
|
}
|
|
2004
|
-
|
|
2005
|
-
const g =
|
|
2004
|
+
h.title.trim() || r("MISSING_BLOCK_TITLE", `${u}.title`, "请填写题块标题"), h.id === "reference-merged-objective" && r("RESERVED_ID", `${u}.id`, "题块使用了系统保留 ID");
|
|
2005
|
+
const g = h.reference;
|
|
2006
2006
|
if (!g) {
|
|
2007
|
-
|
|
2008
|
-
n = { blockId:
|
|
2007
|
+
h.choices?.questions.length || r("EMPTY_BLOCK", u, "题块中没有题目"), h.choices?.questions.forEach((C, M) => {
|
|
2008
|
+
n = { blockId: h.id, questionId: C.id }, c(C.id, `${u}.choices.questions.${M}.id`), a(C, [2, 12], `${u}.choices.questions.${M}`), i(C.score ?? null, 15, `${u}.choices.questions.${M}.score`);
|
|
2009
2009
|
});
|
|
2010
2010
|
return;
|
|
2011
2011
|
}
|
|
2012
|
-
g.questions.length ||
|
|
2013
|
-
const A =
|
|
2014
|
-
if ((A.some((C) => !C.trim()) || new Set(A).size !== A.length) &&
|
|
2015
|
-
n = { blockId:
|
|
2016
|
-
const
|
|
2017
|
-
c(C.id, `${
|
|
2012
|
+
g.questions.length || r("EMPTY_BLOCK", `${u}.reference.questions`, "题块中没有题目");
|
|
2013
|
+
const A = yt(g);
|
|
2014
|
+
if ((A.some((C) => !C.trim()) || new Set(A).size !== A.length) && r("INVALID_QUESTION_NUMBER", `${u}.reference.questions`, "同一题块内的题号须非空且不能重复"), g.optional && (g.type !== "SHORTANSWER" || !Number.isInteger(g.choose) || g.choose < 1 || g.choose >= g.questions.length) && r("INVALID_OPTIONAL", `${u}.reference.choose`, "选做题须为解答题,且选做数量小于总题数"), g.type === "CCOMPOSITION" && g.questions.length > 1 && r("INVALID_COUNT", `${u}.reference.questions`, "语文作文每组只能有一道题"), g.questions.forEach((C, M) => {
|
|
2015
|
+
n = { blockId: h.id, questionId: C.id };
|
|
2016
|
+
const $ = `${u}.reference.questions.${M}`, b = lt[C.type];
|
|
2017
|
+
c(C.id, `${$}.id`), g.type !== "MIXED" && g.type !== C.type && r("TYPE_MISMATCH", `${$}.type`, "题目类型与题块不一致"), C.choice.id !== C.id && r("INVALID_BINDING", `${$}.choice.id`, "题目与填涂项 ID 不一致");
|
|
2018
2018
|
const O = R(C.type) || ["FILLBLANK", "SHORTANSWER"].includes(C.type);
|
|
2019
|
-
(O && (C.parts.length < 1 || C.parts.length >
|
|
2020
|
-
const d = `${
|
|
2021
|
-
n = { blockId:
|
|
2019
|
+
(O && (C.parts.length < 1 || C.parts.length > b.parts) || !O && C.parts.length) && r("INVALID_PARTS", `${$}.parts`, `子题/空数须为 ${O ? `1–${b.parts}` : "0"}`), C.parts.length ? C.score !== Bt(C.parts) && r("SCORE_MISMATCH", `${$}.score`, "总分与子题分值之和不一致") : i(C.score, b.score, `${$}.score`), Y(C.type) && !R(C.type) && a(C.choice, b.options, `${$}.choice`), C.type === "INFO_MATCHING" && (a(C.choice, b.options, `${$}.choice`), C.parts.length > C.choice.options.length && r("INVALID_OPTIONS", `${$}.choice.options`, "信息匹配的选项数不能少于子题数")), C.type === "MCHOICE" && (!Number.isFinite(C.choice.lessScore) || C.choice.lessScore < 0 || C.choice.lessScore > (C.score || 0) || !Number.isInteger(C.choice.lessScore * 2)) && r("INVALID_LESS_SCORE", `${$}.choice.lessScore`, "少选得分须按 0.5 分递增且不能超过本题分值"), C.type === "CHUNK_CHOICE" && (!C.rightAnswers || !Number.isInteger(C.rightAnswers) || C.rightAnswers >= C.choice.options.length || !C.singleScore || C.singleScore < 0.5 || !Number.isInteger(C.singleScore * 2) || C.score !== 0 && C.singleScore * C.rightAnswers > (C.score || 0)) && r("INVALID_CHUNK_SCORE", $, "请检查正确答案个数及每处得分"), C.type === "CCOMPOSITION" && (!Number.isInteger(C.characters) || C.characters < 1 || C.characters > 1200) && r("INVALID_GRID_COUNT", `${$}.characters`, "作文格数须为 1–1200"), C.type === "ECOMPOSITION" && (!Number.isInteger(C.lines) || C.lines < 1 || C.lines > 100) && r("INVALID_LINE_COUNT", `${$}.lines`, "作文行数须为 1–100"), t.questionCard && y(C.text, `${$}.text`, ["SCHOICE", "MCHOICE"].includes(C.type), C.choice.options.length), C.parts.forEach((p, E) => {
|
|
2020
|
+
const d = `${$}.parts.${E}`;
|
|
2021
|
+
n = { blockId: h.id, questionId: p.id }, c(p.id, `${d}.id`), i(p.score, b.score, `${d}.score`), R(C.type) && Y(C.type) && (a(p.choice, b.options, `${d}.choice`), p.choice.id !== p.id && r("INVALID_BINDING", `${d}.choice.id`, "子题与填涂项 ID 不一致")), t.questionCard && ["CLOZE", "READTHENANSWER"].includes(C.type) && y(p.text, `${d}.text`, !0, p.choice.options.length, C.type === "READTHENANSWER");
|
|
2022
2022
|
});
|
|
2023
|
-
}), n = { blockId:
|
|
2024
|
-
const C = g.questions.filter((
|
|
2025
|
-
|
|
2023
|
+
}), n = { blockId: h.id }, t.questionCard && g.layout.presentation !== "concentrated") {
|
|
2024
|
+
const C = g.questions.filter(($) => Y($.type)).flatMap(($) => R($.type) ? $.parts.map((b) => b.choice) : [$.choice]);
|
|
2025
|
+
Zt({ ...g.layout, questions: C }, h.document, !0).concentrated.questions.length && r("MISSING_FILL_TARGET", `${u}.reference.layout.presentation`, "部分填涂框没有对应的题干或选项位置");
|
|
2026
2026
|
}
|
|
2027
2027
|
}), n = {};
|
|
2028
|
-
const
|
|
2029
|
-
|
|
2030
|
-
}, m = (
|
|
2031
|
-
|
|
2032
|
-
}, f = (
|
|
2033
|
-
m(
|
|
2028
|
+
const T = (h, l) => {
|
|
2029
|
+
h.type === "image" && (!h.attrs?.src || /^blob:/i.test(h.attrs.src)) && r("INVALID_IMAGE_URL", l, "图片缺少可保存的地址,请上传后使用持久 URL 或内嵌图片"), ["formula", "blockFormula"].includes(h.type || "") && !String(h.attrs?.latex || "").trim() && r("EMPTY_FORMULA", l, "请填写公式或删除空公式"), h.content?.forEach((u, g) => T(u, `${l}.content.${g}`));
|
|
2030
|
+
}, m = (h, l) => {
|
|
2031
|
+
h && T(h.content, `${l}.content`);
|
|
2032
|
+
}, f = (h, l) => {
|
|
2033
|
+
m(h?.content, `${l}.content`), h?.itemsContent.forEach((u, g) => m(u.content, `${l}.itemsContent.${g}.content`));
|
|
2034
2034
|
};
|
|
2035
|
-
return m(t.paperTitle?.document, "paperTitle.document"), t.blocks.forEach((
|
|
2036
|
-
n = { blockId:
|
|
2035
|
+
return m(t.paperTitle?.document, "paperTitle.document"), t.blocks.forEach((h, l) => {
|
|
2036
|
+
n = { blockId: h.id };
|
|
2037
2037
|
const u = `blocks.${l}`;
|
|
2038
|
-
m(
|
|
2039
|
-
n = { blockId:
|
|
2038
|
+
m(h.document, `${u}.document`), m(h.reference?.material, `${u}.reference.material`), h.reference?.questions.forEach((g, A) => {
|
|
2039
|
+
n = { blockId: h.id, questionId: g.id };
|
|
2040
2040
|
const C = `blocks.${l}.reference.questions.${A}`;
|
|
2041
|
-
m(g.document, `${C}.document`), f(g.text, `${C}.text`), g.parts.forEach((
|
|
2042
|
-
n = { blockId:
|
|
2041
|
+
m(g.document, `${C}.document`), f(g.text, `${C}.text`), g.parts.forEach((M, $) => {
|
|
2042
|
+
n = { blockId: h.id, questionId: M.id }, m(M.document, `${C}.parts.${$}.document`), f(M.text, `${C}.parts.${$}.text`);
|
|
2043
2043
|
});
|
|
2044
2044
|
});
|
|
2045
|
-
}), { valid:
|
|
2045
|
+
}), { valid: o.length === 0, issues: o };
|
|
2046
2046
|
}
|
|
2047
|
-
function
|
|
2047
|
+
function gt(t) {
|
|
2048
2048
|
if (t !== void 0)
|
|
2049
2049
|
try {
|
|
2050
|
-
const e =
|
|
2050
|
+
const e = Lt(t);
|
|
2051
2051
|
return { grades: e.grades, gradeCourseMap: e.gradeCourseMap, defaultGradeCode: e.defaultGradeCode || void 0, defaultCourseCode: e.defaultCourseCode || void 0 };
|
|
2052
2052
|
} catch (e) {
|
|
2053
|
-
throw e instanceof
|
|
2053
|
+
throw e instanceof mt ? new ut([{ code: "INVALID_DICTIONARIES", path: e.path, message: e.message }]) : e;
|
|
2054
2054
|
}
|
|
2055
2055
|
}
|
|
2056
2056
|
function Pe(t, e) {
|
|
2057
|
-
const
|
|
2058
|
-
throw new ut([{ code: "INVALID_INITIALIZATION", path:
|
|
2059
|
-
}, n = (
|
|
2060
|
-
if (!
|
|
2061
|
-
const
|
|
2062
|
-
for (const [d] of
|
|
2063
|
-
return Object.fromEntries(
|
|
2064
|
-
},
|
|
2065
|
-
|
|
2066
|
-
}, c = (
|
|
2067
|
-
|
|
2068
|
-
}, i = (
|
|
2069
|
-
|
|
2070
|
-
}, a = n(t, "initialization", ["name", "grade", "subject", "gradeCode", "courseCode", "subjectCode", "mode", "id", "exampaperId", "createMode", "layout", "header", "recognition"]), y =
|
|
2071
|
-
y.length > 30 &&
|
|
2072
|
-
const
|
|
2057
|
+
const o = (b, O) => {
|
|
2058
|
+
throw new ut([{ code: "INVALID_INITIALIZATION", path: b, message: O }]);
|
|
2059
|
+
}, n = (b, O, p) => {
|
|
2060
|
+
if (!b || typeof b != "object" || Array.isArray(b)) return o(O, "初始化配置必须是对象");
|
|
2061
|
+
const E = Object.entries(b);
|
|
2062
|
+
for (const [d] of E) p.includes(d) || o(`${O}.${d}`, "不支持的初始化字段");
|
|
2063
|
+
return Object.fromEntries(E.filter(([, d]) => d !== void 0));
|
|
2064
|
+
}, r = (b, O) => typeof b != "string" || !b.trim() ? o(O, "请提供非空的试卷名称、年级和学科") : b.trim(), s = (b, O, p) => {
|
|
2065
|
+
b !== void 0 && !p.includes(b) && o(O, `可选值为 ${p.join("、")}`);
|
|
2066
|
+
}, c = (b, O) => {
|
|
2067
|
+
b !== void 0 && typeof b != "boolean" && o(O, "请使用布尔值");
|
|
2068
|
+
}, i = (b, O, p, E) => {
|
|
2069
|
+
b !== void 0 && (typeof b != "number" || !Number.isFinite(b) || b < p || b > E) && o(O, `数值必须在 ${p}–${E} 之间`);
|
|
2070
|
+
}, a = n(t, "initialization", ["name", "grade", "subject", "gradeCode", "courseCode", "subjectCode", "mode", "id", "exampaperId", "createMode", "layout", "header", "recognition"]), y = r(a.name, "initialization.name");
|
|
2071
|
+
y.length > 30 && o("initialization.name", "试卷名称最多 30 个字符");
|
|
2072
|
+
const T = Lt(gt(e)), m = a.gradeCode !== void 0 || a.courseCode !== void 0 || a.subjectCode !== void 0;
|
|
2073
2073
|
let f;
|
|
2074
2074
|
if (m) {
|
|
2075
2075
|
try {
|
|
2076
|
-
f =
|
|
2077
|
-
} catch (
|
|
2078
|
-
if (
|
|
2079
|
-
throw
|
|
2076
|
+
f = dt(T, r(a.gradeCode, "initialization.gradeCode"), r(a.courseCode, "initialization.courseCode"));
|
|
2077
|
+
} catch (b) {
|
|
2078
|
+
if (b instanceof mt) return o(b.path, b.message);
|
|
2079
|
+
throw b;
|
|
2080
2080
|
}
|
|
2081
|
-
for (const
|
|
2081
|
+
for (const b of ["grade", "subject", "subjectCode"]) a[b] !== void 0 && r(a[b], `initialization.${b}`) !== f[b] && o(`initialization.${b}`, "名称或学科编码与课程字典不一致");
|
|
2082
2082
|
} else {
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
const
|
|
2086
|
-
d.length > 1 &&
|
|
2083
|
+
const b = r(a.grade, "initialization.grade"), O = r(a.subject, "initialization.subject"), p = T.grades.filter((I) => I.label === b);
|
|
2084
|
+
p.length > 1 && o("initialization.grade", "同名年级不唯一,请使用 gradeCode");
|
|
2085
|
+
const E = p[0], d = E ? T.gradeCourseMap[E.value].filter((I) => I.label === O) : [];
|
|
2086
|
+
d.length > 1 && o("initialization.subject", "同名课程不唯一,请使用 courseCode"), e && (!E || !d.length) && o(E ? "initialization.subject" : "initialization.grade", "名称不在可用字典中,请使用年级和课程编码"), f = E && d.length ? dt(T, E.value, d[0].value) : { grade: b, subject: O };
|
|
2087
2087
|
}
|
|
2088
2088
|
s(a.mode, "initialization.mode", ["template", "exam"]), s(a.createMode, "initialization.createMode", ["MANUALLY", "IMPORTED", "THIRD"]);
|
|
2089
|
-
const
|
|
2090
|
-
for (const
|
|
2091
|
-
const O = a[
|
|
2092
|
-
typeof O == "string" ?
|
|
2089
|
+
const h = {};
|
|
2090
|
+
for (const b of ["id", "exampaperId"]) if (a[b] !== void 0) {
|
|
2091
|
+
const O = a[b];
|
|
2092
|
+
typeof O == "string" ? h[b] = r(O, `initialization.${b}`) : typeof O == "number" && Number.isSafeInteger(O) && O >= 0 ? h[b] = O : o(`initialization.${b}`, "ID 必须是非空字符串或非负安全整数");
|
|
2093
2093
|
}
|
|
2094
|
-
a.createMode !== void 0 && (
|
|
2095
|
-
const l = a.layout === void 0 ? {} : n(a.layout, "initialization.layout", ["usage", "preset", "margin", "gap", "questionCard", "scanMarking", "halfPoint", "choiceDirection", "mergeObjective", "pageNum", "quesCard", "scoreType", "choiceType", "mixOb"]), u = (
|
|
2096
|
-
l[
|
|
2094
|
+
a.createMode !== void 0 && (h.createMode = a.createMode);
|
|
2095
|
+
const l = a.layout === void 0 ? {} : n(a.layout, "initialization.layout", ["usage", "preset", "margin", "gap", "questionCard", "duplex", "scanMarking", "halfPoint", "choiceDirection", "mergeObjective", "pageNum", "quesCard", "scoreType", "choiceType", "mixOb"]), u = (b, O, p) => {
|
|
2096
|
+
l[b] !== void 0 && (l[O] !== void 0 && l[O] !== p && o(`initialization.layout.${b}`, `与 ${O} 设置冲突`), l[O] = p, delete l[b]);
|
|
2097
2097
|
};
|
|
2098
|
-
l.pageNum !== void 0 && ![1, 2, 3].includes(l.pageNum) &&
|
|
2099
|
-
for (const [
|
|
2100
|
-
c(l[
|
|
2098
|
+
l.pageNum !== void 0 && ![1, 2, 3].includes(l.pageNum) && o("initialization.layout.pageNum", "分栏数为 1、2 或 3"), u("pageNum", "preset", { 1: "a4", 2: "a3-two", 3: "a3-three" }[l.pageNum]);
|
|
2099
|
+
for (const [b, O] of [["quesCard", "questionCard"], ["scoreType", "halfPoint"], ["mixOb", "mergeObjective"], ["choiceType", "choiceDirection"]])
|
|
2100
|
+
c(l[b], `initialization.layout.${b}`), u(b, O, b === "choiceType" ? l[b] ? "column" : "row" : l[b]);
|
|
2101
2101
|
s(l.preset, "initialization.layout.preset", ["a4", "a3-two", "a3-three"]), s(l.usage, "initialization.layout.usage", ["exam", "homework"]), s(l.choiceDirection, "initialization.layout.choiceDirection", ["row", "column"]), i(l.margin, "initialization.layout.margin", 0, 100), i(l.gap, "initialization.layout.gap", 0, 100);
|
|
2102
|
-
for (const
|
|
2102
|
+
for (const b of ["questionCard", "duplex", "scanMarking", "halfPoint", "mergeObjective"]) c(l[b], `initialization.layout.${b}`);
|
|
2103
2103
|
const g = a.header === void 0 ? {} : n(a.header, "initialization.header", ["focusText", "writeKaohao", "missExam", "mifeng", "kaohao", "weishu", "tiaomaStyle", "classText"]);
|
|
2104
|
-
for (const
|
|
2105
|
-
g.tiaomaStyle !== void 0 && ![1, 2].includes(g.tiaomaStyle) &&
|
|
2106
|
-
const A =
|
|
2107
|
-
if (C) for (const
|
|
2108
|
-
const
|
|
2109
|
-
return (
|
|
2104
|
+
for (const b of ["focusText", "writeKaohao", "missExam", "mifeng", "classText"]) c(g[b], `initialization.header.${b}`);
|
|
2105
|
+
g.tiaomaStyle !== void 0 && ![1, 2].includes(g.tiaomaStyle) && o("initialization.header.tiaomaStyle", "考号版式为 1(填涂)或 2(条形码)"), s(g.kaohao, "initialization.header.kaohao", ["school", "code"]), i(g.weishu, "initialization.header.weishu", 4, 12), g.weishu !== void 0 && !Number.isInteger(g.weishu) && o("initialization.header.weishu", "考号位数必须是整数");
|
|
2106
|
+
const A = ae({ name: y, ...f, ...h, mode: a.mode ?? "template" }), C = a.recognition === void 0 ? void 0 : n(a.recognition, "initialization.recognition", ["examQrCode", "subjectMarkers", "pointBlack"]);
|
|
2107
|
+
if (C) for (const b of ["examQrCode", "subjectMarkers", "pointBlack"]) c(C[b], `initialization.recognition.${b}`);
|
|
2108
|
+
const M = { ...A, ...l, header: { ...A.header, ...g }, ...C ? { recognition: C } : {} }, $ = Ct(M);
|
|
2109
|
+
return ($.columnWidth < 100 || $.contentHeight < 100) && o("initialization.layout", "边距或栏间距过大,纸张没有足够的作答区域"), M;
|
|
2110
2110
|
}
|
|
2111
2111
|
function Mn(t, e) {
|
|
2112
2112
|
if (typeof document > "u") throw new Error("请在浏览器挂载后创建制卡实例");
|
|
2113
|
-
const
|
|
2114
|
-
if (!(
|
|
2113
|
+
const o = vt(e?.plugins || []), n = gt(e.dictionaries), r = typeof t == "string" ? document.querySelector(t) : t;
|
|
2114
|
+
if (!(r instanceof HTMLElement) || r.ownerDocument !== document || /^(INPUT|TEXTAREA|SELECT|BUTTON|IMG|CANVAS|IFRAME)$/.test(r.tagName)) throw new Error("制卡需要一个空的 HTML 容器,例如 div");
|
|
2115
2115
|
if (document.querySelector("[data-uni-answer-sheet-mount], #uni-answer-sheet")) throw new Error("当前文档已挂载制卡工作区;切换容器前请先 destroy()");
|
|
2116
|
-
if (
|
|
2116
|
+
if (r.textContent?.trim() || r.children.length) throw new Error("请提供空容器,已有题卡请通过 initialValue 传入");
|
|
2117
2117
|
const s = document.createElement("div");
|
|
2118
|
-
s.className = "uni-answer-sheet-host", s.dataset.uniAnswerSheetMount = "", s.style.height = "100%",
|
|
2119
|
-
let c = !1, i = { ...e, dictionaries: n }, a, y,
|
|
2118
|
+
s.className = "uni-answer-sheet-host", s.dataset.uniAnswerSheetMount = "", s.style.height = "100%", r.append(s);
|
|
2119
|
+
let c = !1, i = { ...e, dictionaries: n }, a, y, T;
|
|
2120
2120
|
const m = new Promise((u, g) => {
|
|
2121
|
-
y = u,
|
|
2121
|
+
y = u, T = g;
|
|
2122
2122
|
});
|
|
2123
2123
|
m.catch(() => {
|
|
2124
2124
|
});
|
|
@@ -2126,79 +2126,79 @@ function Mn(t, e) {
|
|
|
2126
2126
|
if (c) throw new Error("制卡实例已销毁");
|
|
2127
2127
|
if (!a?.isReady()) throw new Error("请先等待 sheet.ready");
|
|
2128
2128
|
return a;
|
|
2129
|
-
},
|
|
2129
|
+
}, h = async () => (await m, f()), l = {
|
|
2130
2130
|
ready: m,
|
|
2131
2131
|
async initialize(u) {
|
|
2132
2132
|
if (c) throw new Error("制卡实例已销毁");
|
|
2133
2133
|
const g = Pe(u, i.dictionaries);
|
|
2134
|
-
a || (i = { ...i, initialValue: g }), await (await
|
|
2134
|
+
a || (i = { ...i, initialValue: g }), await (await h()).setDocument(g);
|
|
2135
2135
|
},
|
|
2136
2136
|
getDocument: () => f().getDocument(),
|
|
2137
|
-
load: async (u) => (await
|
|
2138
|
-
setDocument: async (u) => (await
|
|
2139
|
-
newDocument: async (u) => (await
|
|
2137
|
+
load: async (u) => (await h()).setDocument(u),
|
|
2138
|
+
setDocument: async (u) => (await h()).setDocument(u),
|
|
2139
|
+
newDocument: async (u) => (await h()).newDocument(u),
|
|
2140
2140
|
getReferenceData: () => f().getReferenceData(),
|
|
2141
|
-
setReferenceData: async (u) => (await
|
|
2142
|
-
validate: async () => (await
|
|
2143
|
-
save: async () => (await
|
|
2144
|
-
getRecognitionData: async () => (await
|
|
2141
|
+
setReferenceData: async (u) => (await h()).setReferenceData(u),
|
|
2142
|
+
validate: async () => (await h()).validate(),
|
|
2143
|
+
save: async () => (await h()).save(),
|
|
2144
|
+
getRecognitionData: async () => (await h()).getRecognitionData(),
|
|
2145
2145
|
focusIssue: (u) => f().focusIssue(u),
|
|
2146
2146
|
setOptions(u) {
|
|
2147
2147
|
if (c) throw new Error("制卡实例已销毁");
|
|
2148
|
-
const g = Object.hasOwn(u, "dictionaries") ?
|
|
2148
|
+
const g = Object.hasOwn(u, "dictionaries") ? gt(u.dictionaries) : i.dictionaries;
|
|
2149
2149
|
i = { ...i, ...u, dictionaries: g }, a?.update(i);
|
|
2150
2150
|
},
|
|
2151
2151
|
destroy() {
|
|
2152
|
-
c || (c = !0, a?.destroy(), s.remove(),
|
|
2152
|
+
c || (c = !0, a?.destroy(), s.remove(), T(new DOMException("制卡实例已销毁", "AbortError")));
|
|
2153
2153
|
}
|
|
2154
2154
|
};
|
|
2155
|
-
return Promise.all([
|
|
2156
|
-
c || (a = u(s,
|
|
2157
|
-
|
|
2155
|
+
return Promise.all([o.prepare(), import("./runtime-C9TDF-ed.js")]).then(([, { mountAnswerSheet: u }]) => {
|
|
2156
|
+
c || (a = u(s, o, i, y, (g) => {
|
|
2157
|
+
T(g), l.destroy(), i.onError?.(g instanceof Error ? g : new Error(String(g)));
|
|
2158
2158
|
}));
|
|
2159
2159
|
}).catch((u) => {
|
|
2160
|
-
|
|
2160
|
+
T(u), l.destroy(), i.onError?.(u instanceof Error ? u : new Error(String(u)));
|
|
2161
2161
|
}), l;
|
|
2162
2162
|
}
|
|
2163
2163
|
export {
|
|
2164
2164
|
Ze as $,
|
|
2165
2165
|
On as A,
|
|
2166
|
-
|
|
2166
|
+
ue as B,
|
|
2167
2167
|
An as C,
|
|
2168
|
-
|
|
2169
|
-
|
|
2168
|
+
Lt as D,
|
|
2169
|
+
se as E,
|
|
2170
2170
|
fn as F,
|
|
2171
2171
|
ln as G,
|
|
2172
2172
|
et as H,
|
|
2173
2173
|
In as I,
|
|
2174
|
-
|
|
2174
|
+
ae as J,
|
|
2175
2175
|
un as K,
|
|
2176
2176
|
v as L,
|
|
2177
2177
|
W as M,
|
|
2178
2178
|
Ke as N,
|
|
2179
2179
|
ze as O,
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2180
|
+
Yt as P,
|
|
2181
|
+
xt as Q,
|
|
2182
|
+
Jt as R,
|
|
2183
|
+
Dt as S,
|
|
2184
2184
|
ve as T,
|
|
2185
2185
|
Ue as U,
|
|
2186
2186
|
at as V,
|
|
2187
2187
|
je as W,
|
|
2188
2188
|
Ge as X,
|
|
2189
|
-
|
|
2189
|
+
Tt as Y,
|
|
2190
2190
|
Fe as Z,
|
|
2191
2191
|
tn as _,
|
|
2192
2192
|
be as a,
|
|
2193
|
-
|
|
2193
|
+
oe as a0,
|
|
2194
2194
|
on as a1,
|
|
2195
2195
|
en as a2,
|
|
2196
2196
|
nn as a3,
|
|
2197
2197
|
rn as a4,
|
|
2198
2198
|
Xe as a5,
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2199
|
+
ne as a6,
|
|
2200
|
+
re as a7,
|
|
2201
|
+
ie as a8,
|
|
2202
2202
|
Ve as a9,
|
|
2203
2203
|
Sn as aA,
|
|
2204
2204
|
De as aB,
|
|
@@ -2207,23 +2207,23 @@ export {
|
|
|
2207
2207
|
Nn as aE,
|
|
2208
2208
|
Mn as aF,
|
|
2209
2209
|
Je as aa,
|
|
2210
|
-
|
|
2210
|
+
qt as ab,
|
|
2211
2211
|
sn as ac,
|
|
2212
2212
|
qe as ad,
|
|
2213
2213
|
Qe as ae,
|
|
2214
2214
|
lt as af,
|
|
2215
|
-
|
|
2215
|
+
Rt as ag,
|
|
2216
2216
|
mn as ah,
|
|
2217
2217
|
bn as ai,
|
|
2218
2218
|
gn as aj,
|
|
2219
2219
|
Cn as ak,
|
|
2220
2220
|
wn as al,
|
|
2221
|
-
|
|
2221
|
+
ht as am,
|
|
2222
2222
|
cn as an,
|
|
2223
2223
|
Ye as ao,
|
|
2224
2224
|
Be as ap,
|
|
2225
|
-
|
|
2226
|
-
|
|
2225
|
+
dt as aq,
|
|
2226
|
+
le as ar,
|
|
2227
2227
|
We as as,
|
|
2228
2228
|
he as at,
|
|
2229
2229
|
En as au,
|
|
@@ -2231,30 +2231,30 @@ export {
|
|
|
2231
2231
|
an as aw,
|
|
2232
2232
|
it as ax,
|
|
2233
2233
|
Se as ay,
|
|
2234
|
-
|
|
2234
|
+
jt as az,
|
|
2235
2235
|
pn as b,
|
|
2236
2236
|
Ie as c,
|
|
2237
|
-
|
|
2237
|
+
Ht as d,
|
|
2238
2238
|
ye as e,
|
|
2239
|
-
|
|
2239
|
+
pt as f,
|
|
2240
2240
|
Y as g,
|
|
2241
2241
|
yn as h,
|
|
2242
2242
|
R as i,
|
|
2243
2243
|
j,
|
|
2244
2244
|
dn as k,
|
|
2245
|
-
|
|
2245
|
+
kt as l,
|
|
2246
2246
|
Q as m,
|
|
2247
|
-
|
|
2247
|
+
St as n,
|
|
2248
2248
|
hn as o,
|
|
2249
2249
|
ge as p,
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2250
|
+
It as q,
|
|
2251
|
+
Zt as r,
|
|
2252
|
+
Bt as s,
|
|
2253
2253
|
J as t,
|
|
2254
2254
|
st as u,
|
|
2255
|
-
|
|
2255
|
+
Pt as v,
|
|
2256
2256
|
pe as w,
|
|
2257
|
-
|
|
2257
|
+
Ot as x,
|
|
2258
2258
|
Z as y,
|
|
2259
2259
|
nt as z
|
|
2260
2260
|
};
|