uni-answer-sheet 2.1.0 → 2.2.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 +7 -0
- package/README.md +16 -8
- package/dist/browser.js +46 -46
- package/dist/chunks/{index-CDvIw14k.js → index-ChLOq9ID.js} +479 -475
- package/dist/chunks/{runtime-C-fdAw2T.js → runtime-QFMZtUfH.js} +7895 -7796
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
var Ft = Object.defineProperty;
|
|
2
|
+
var Kt = (t, e, r) => e in t ? Ft(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var Tt = (t, e, r) => Kt(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
const vt = ["pagination", "content-identity", "choice-fill", "answer-regions", "html-codec", "status"];
|
|
5
|
+
function zt(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
8
|
const r = e[0];
|
|
9
|
-
if (r.apiVersion !== 1 || r.documentVersion !== 1 ||
|
|
9
|
+
if (r.apiVersion !== 1 || r.documentVersion !== 1 || vt.some((n) => !r.capabilities?.includes(n)) || typeof r.prepare != "function" || typeof r.create != "function" || typeof r.validateDocument != "function" || typeof r.html?.parse != "function" || typeof r.html?.serialize != "function") throw new Error("富文本插件协议不兼容,需要支持制卡协议 v1 的 uni-editor/plugin");
|
|
10
10
|
return r;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function $t(t) {
|
|
13
13
|
const e = [], r = (n) => {
|
|
14
14
|
if (n.type === "choiceGroup") {
|
|
15
15
|
typeof n.attrs?.id == "string" && e.push({
|
|
@@ -23,13 +23,13 @@ function xt(t) {
|
|
|
23
23
|
};
|
|
24
24
|
return r(t.content), e;
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class Ct extends Error {
|
|
27
27
|
constructor(e, r) {
|
|
28
28
|
super(r), this.path = e;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const B = (t, e) => {
|
|
32
|
-
throw new
|
|
32
|
+
throw new Ct(t, e);
|
|
33
33
|
}, ot = {
|
|
34
34
|
语文: "CHINESE",
|
|
35
35
|
数学: "MATHS",
|
|
@@ -46,50 +46,50 @@ const B = (t, e) => {
|
|
|
46
46
|
信息科技: "IT",
|
|
47
47
|
信息技术: "IT",
|
|
48
48
|
日语: "JAPANESE"
|
|
49
|
-
},
|
|
49
|
+
}, Wt = {
|
|
50
50
|
P: ["语文", "数学", "英语", "科学", "道德与法治"],
|
|
51
51
|
J: ["语文", "数学", "英语", "物理", "化学", "生物", "地理", "历史", "道德与法治", "信息科技"],
|
|
52
52
|
S: ["语文", "数学", "英语", "物理", "化学", "生物", "政治", "历史", "地理", "信息技术", "日语"]
|
|
53
|
-
},
|
|
53
|
+
}, Vt = ["一年级", "二年级", "三年级", "四年级", "五年级", "六年级", "初一", "初二", "初三", "高一", "高二", "高三"], Qt = Vt.map((t, e) => {
|
|
54
54
|
const r = e < 6 ? "P" : e < 9 ? "J" : "S";
|
|
55
55
|
return { label: t, value: `${r}0${e < 6 ? e + 1 : (e - 6) % 3 + 1}`, classify: r };
|
|
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
|
|
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, "字典必须是对象"), Lt = (t) => t.classify || (/^[PJS]/.test(t.value) ? t.value[0] : void 0);
|
|
57
|
+
function _t(t = {}) {
|
|
58
58
|
const e = tt(t, "dictionaries"), r = (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 x = tt(A, `${u}.${C}`), M = z(x.value, `${u}.${C}.value`),
|
|
63
|
-
return g.has(M) && B(`${u}.${C}.value`, "字典编码重复"), g.add(M), { ...x, value: M, label:
|
|
62
|
+
const x = tt(A, `${u}.${C}`), M = z(x.value, `${u}.${C}.value`), T = z(x.label, `${u}.${C}.label`);
|
|
63
|
+
return g.has(M) && B(`${u}.${C}.value`, "字典编码重复"), g.add(M), { ...x, value: M, label: T };
|
|
64
64
|
});
|
|
65
|
-
}, n = r(e.grades === void 0 ?
|
|
65
|
+
}, n = r(e.grades === void 0 ? Qt : 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 })), o = 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
|
-
x.subjectCode !== void 0 &&
|
|
71
|
-
const O = z(x.subjectCode ??
|
|
68
|
+
const u = Lt(l), g = (u ? Wt[u] : []).map((x) => ({ value: ot[x], label: x, subjectCode: ot[x] })), A = `dictionaries.gradeCourseMap.${l.value}`, C = r(o ? o[l.value] ?? [] : g, A).map((x, M) => {
|
|
69
|
+
const T = s[x.value];
|
|
70
|
+
x.subjectCode !== void 0 && T !== void 0 && x.subjectCode !== T && B(`${A}.${M}.subjectCode`, "课程对应的学科编码冲突");
|
|
71
|
+
const O = z(x.subjectCode ?? T ?? (Object.values(ot).includes(x.value) ? x.value : void 0), `${A}.${M}.subjectCode`);
|
|
72
72
|
return c.has(x.value) && c.get(x.value) !== O && B(`${A}.${M}.subjectCode`, "同一课程不能对应不同学科"), c.set(x.value, O), x.custom !== void 0 && typeof x.custom != "boolean" && B(`${A}.${M}.custom`, "custom 必须是布尔值"), { value: x.value, label: x.label, subjectCode: O, ...x.custom === void 0 ? {} : { custom: x.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"), b = a.find((l) => l.value === y)?.value || a[0]?.value || "", m = e.defaultCourseCode === void 0 ? void 0 : z(e.defaultCourseCode, "dictionaries.defaultCourseCode"), f = i[b] || [], p = f.find((l) => l.value === m)?.value || f[0]?.value || "";
|
|
76
|
+
return { grades: a, gradeCourseMap: i, defaultGradeCode: b, defaultCourseCode: p };
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function ht(t, e, r) {
|
|
79
79
|
const n = t.grades.find((s) => s.value === e);
|
|
80
80
|
if (!n) return B("initialization.gradeCode", "年级不在可用字典中");
|
|
81
81
|
const o = t.gradeCourseMap[e]?.find((s) => s.value === r);
|
|
82
|
-
return o ? { grade: n.label, subject: o.label, gradeCode: e, courseCode: r, subjectCode: o.subjectCode, phaseCode:
|
|
82
|
+
return o ? { grade: n.label, subject: o.label, gradeCode: e, courseCode: r, subjectCode: o.subjectCode, phaseCode: Lt(n) } : B("initialization.courseCode", "当前年级没有此课程");
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function Be(t, e = {}) {
|
|
85
85
|
const n = t.grades.find((c) => c.value === e.gradeCode || !e.gradeCode && c.label === e.grade)?.value || t.defaultGradeCode, o = t.gradeCourseMap[n] || [], s = o.find((c) => c.value === e.courseCode || !e.courseCode && c.label === e.subject)?.value || (n === t.defaultGradeCode ? t.defaultCourseCode : o[0]?.value) || "";
|
|
86
|
-
return n && s ?
|
|
86
|
+
return n && s ? ht(t, n, s) : { grade: "", subject: "", gradeCode: "", courseCode: "" };
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function Dt(t) {
|
|
89
89
|
return t?.subjectCode || ot[t?.subject || ""];
|
|
90
90
|
}
|
|
91
|
-
const W = { questions: 200, options: 12, score: 15 },
|
|
92
|
-
function
|
|
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), pt = (t) => !!(Dt(t) === "MATHS" && (t?.phaseCode ? t.phaseCode === "S" : t?.gradeCode ? t.gradeCode.startsWith("S") : /^高[一二三]/.test(t?.grade || "")));
|
|
92
|
+
function Jt(t) {
|
|
93
93
|
const e = typeof t.score == "number" && v(t.score) && t.score >= 0.5 && t.score <= W.score ? t.score : null, r = [...new Set(t.correctIds)].filter((n) => t.options.some((o) => o.id === n));
|
|
94
94
|
return {
|
|
95
95
|
...t,
|
|
@@ -100,32 +100,32 @@ function Qt(t) {
|
|
|
100
100
|
correctIds: t.multiple ? r : r.slice(0, 1)
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function St(t, e, r) {
|
|
104
104
|
let n = { ...t };
|
|
105
105
|
if (e.kind !== void 0) {
|
|
106
106
|
const o = e.kind !== "single";
|
|
107
|
-
o && !t.multiple && (n.scoreType =
|
|
107
|
+
o && !t.multiple && (n.scoreType = pt(r) ? "ITEM_SCORE" : "LESS_SCORE", typeof n.score != "number" && pt(r) && (n.score = 6)), n.multiple = o, n.indefinite = e.kind === "indefinite";
|
|
108
108
|
}
|
|
109
109
|
if (e.optionCount !== void 0) {
|
|
110
110
|
const o = Math.max(2, Math.min(W.options, Math.round(e.optionCount)));
|
|
111
111
|
n.options = Array.from({ length: o }, (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), Jt(n);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function kt(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
|
-
function je(t) {
|
|
119
|
-
return t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !Dt(t) ? t.score / t.correctIds.length : null;
|
|
120
|
-
}
|
|
121
118
|
function Ge(t) {
|
|
119
|
+
return t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !kt(t) ? t.score / t.correctIds.length : null;
|
|
120
|
+
}
|
|
121
|
+
function Ue(t) {
|
|
122
122
|
const e = t.map((o) => Number(o.label)).filter((o) => Number.isSafeInteger(o) && o > 0 && o < 1e5);
|
|
123
123
|
let r = String(Math.max(0, ...e) + 1);
|
|
124
124
|
const n = new Set(t.map((o) => o.label));
|
|
125
125
|
for (; n.has(r); ) r = String(Number(r) + 1);
|
|
126
126
|
return r;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function Fe(t, e) {
|
|
129
129
|
const r = new Map(t.options.map((n) => [n.id, crypto.randomUUID()]));
|
|
130
130
|
return {
|
|
131
131
|
...t,
|
|
@@ -137,73 +137,73 @@ function Ue(t, e) {
|
|
|
137
137
|
correctIds: t.correctIds.map((n) => r.get(n)).filter(Boolean)
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function Xt(t, e, r) {
|
|
141
141
|
return r.trim() ? t.some((n) => n.id !== e && n.label.trim() === r.trim()) ? "题组内题号不能重复" : null : "题号不能为空";
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function Ke(t, e, r, n) {
|
|
144
144
|
const o = t.questions.filter((a) => e.includes(a.id));
|
|
145
145
|
if (!o.length) return { error: "请选择要修改的题目" };
|
|
146
146
|
let s;
|
|
147
147
|
if (r.type === "settings") {
|
|
148
148
|
if (!Object.keys(r.patch).length) return { error: "请设置需要修改的属性" };
|
|
149
|
-
const { optionCount: a, score: y, lessScore:
|
|
149
|
+
const { optionCount: a, score: y, lessScore: b } = r.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 = o.map((m) =>
|
|
152
|
+
if (b !== void 0 && (!v(b) || b < 0)) return { error: "少选得分须为非负的 0.5 倍数" };
|
|
153
|
+
if (s = o.map((m) => St(m, r.patch, n)), b !== void 0 && s.some((m) => m.multiple && m.scoreType !== "ITEM_SCORE" && b > (m.score ?? 0))) return { error: "少选得分不能超过所选题目的分值" };
|
|
154
154
|
} else if (r.type === "numbering") {
|
|
155
155
|
if (!Number.isInteger(r.start) || r.start < 1 || r.start + o.length - 1 > 1e3) return { error: "连续题号须在 1–1000 内" };
|
|
156
156
|
s = o.map((a, y) => ({ ...a, label: String(r.start + y) }));
|
|
157
157
|
} else if (r.type === "average") {
|
|
158
158
|
const a = r.total / o.length;
|
|
159
159
|
if (!v(a) || a < 0.5 || a > W.score) return { error: "总分无法平均分配,每题须为 0.5–15 分且为 0.5 的倍数" };
|
|
160
|
-
s = o.map((y) =>
|
|
160
|
+
s = o.map((y) => St(y, { score: a }));
|
|
161
161
|
} else {
|
|
162
162
|
const a = r.text.toUpperCase().trim().split(/[\s,,;;]+/).filter(Boolean);
|
|
163
163
|
if (a.length !== o.length) return { error: `需要 ${o.length} 组答案,当前为 ${a.length} 组` };
|
|
164
164
|
s = [];
|
|
165
165
|
for (let y = 0; y < o.length; y++) {
|
|
166
|
-
const
|
|
167
|
-
if (m !== "-" && (!/^[A-T]+$/.test(m) || new Set(m).size !== m.length || [...m].some((p) => !
|
|
168
|
-
const f = m === "-" ? [] : [...m].map((p) =>
|
|
169
|
-
if (!
|
|
170
|
-
s.push({ ...
|
|
166
|
+
const b = o[y], m = a[y];
|
|
167
|
+
if (m !== "-" && (!/^[A-T]+$/.test(m) || new Set(m).size !== m.length || [...m].some((p) => !b.options.some((l) => l.label === p)))) return { error: `第 ${b.label} 题包含无效或重复选项` };
|
|
168
|
+
const f = m === "-" ? [] : [...m].map((p) => b.options.find((l) => l.label === p).id);
|
|
169
|
+
if (!b.multiple && f.length > 1) return { error: `第 ${b.label} 题为单选,只能设置一个答案` };
|
|
170
|
+
s.push({ ...b, 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 = Xt(i, a.id, a.label) || kt(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
|
|
182
|
-
const n =
|
|
180
|
+
const Yt = { layout: "natural", columns: 2, indent: !1, rowGap: 0, columnGap: 32, marker: "letter" }, At = (t) => `question:${t}`, Zt = (t) => t.presentation === "stem" ? "stem" : ["option", "distributed"].includes(t.presentation) ? "option" : "concentrated";
|
|
181
|
+
function ve(t, e, r) {
|
|
182
|
+
const n = $t(e), o = /* @__PURE__ */ new Map(), s = (i, a) => {
|
|
183
183
|
const y = i.attrs?.contentId || a;
|
|
184
|
-
i.type === "choiceGroup" && y && o.set(i.attrs.id, y), i.content?.forEach((
|
|
184
|
+
i.type === "choiceGroup" && y && o.set(i.attrs.id, y), i.content?.forEach((b) => s(b, y));
|
|
185
185
|
};
|
|
186
186
|
s(e.content);
|
|
187
187
|
const c = new Set(t.questions.map((i) => i.contentTarget?.groupId));
|
|
188
188
|
return { ...t, presentation: r, questions: t.questions.map((i, a) => {
|
|
189
|
-
const y = n.find((
|
|
190
|
-
return r === "concentrated" || i.contentTarget !== void 0 || !y || c.has(y.id) ? i : (c.add(y.id), { ...i, contentTarget: { groupId: y.id, optionIds: y.options.map((
|
|
189
|
+
const y = n.find((b) => o.get(b.id) === i.id) || (o.size ? void 0 : n[a]);
|
|
190
|
+
return r === "concentrated" || i.contentTarget !== void 0 || !y || c.has(y.id) ? i : (c.add(y.id), { ...i, contentTarget: { groupId: y.id, optionIds: y.options.map((b) => b.id) } });
|
|
191
191
|
}) };
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
const n =
|
|
193
|
+
function qt(t, e, r) {
|
|
194
|
+
const n = Zt(t), o = new Map($t(e).map((f) => [f.id, f])), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = (f, p) => {
|
|
195
195
|
const l = f.attrs?.contentId || p;
|
|
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 = [],
|
|
199
|
+
const y = [], b = /* @__PURE__ */ new Set(), m = t.questions.filter((f) => {
|
|
200
200
|
if (!r || n === "concentrated") return !0;
|
|
201
|
-
if (n === "stem" && s.has(
|
|
202
|
-
return y.push({ groupId:
|
|
201
|
+
if (n === "stem" && s.has(At(f.id)))
|
|
202
|
+
return y.push({ groupId: At(f.id), questionId: f.id, options: f.options.map((C) => ({ ...C, contentOptionId: C.id })) }), !1;
|
|
203
203
|
const p = c.get(f.id), l = p?.length === 1 ? o.get(p[0]) : void 0, u = l ? { groupId: l.id, optionIds: l.options.map((C) => C.id) } : f.contentTarget, g = u && o.get(u.groupId);
|
|
204
|
-
if (!u || !g ||
|
|
204
|
+
if (!u || !g || b.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((x) => x.id === C)) ? !0 : (
|
|
206
|
+
return A.length !== f.options.length || new Set(A).size !== A.length || A.some((C) => !g.options.some((x) => x.id === C)) ? !0 : (b.add(g.id), y.push({ groupId: g.id, questionId: f.id, options: f.options.map((C, x) => ({ ...C, contentOptionId: A[x] })) }), !1);
|
|
207
207
|
});
|
|
208
208
|
return { position: n === "concentrated" ? void 0 : n, bindings: y, concentrated: { ...t, questions: m } };
|
|
209
209
|
}
|
|
@@ -221,7 +221,7 @@ function at(t, e = 4) {
|
|
|
221
221
|
options: Array.from({ length: e }, (r, n) => ({ id: crypto.randomUUID(), label: String.fromCharCode(65 + n) }))
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function te(t = 8) {
|
|
225
225
|
return {
|
|
226
226
|
source: "manual",
|
|
227
227
|
presentation: "concentrated",
|
|
@@ -233,10 +233,10 @@ function qt(t = 8) {
|
|
|
233
233
|
questions: Array.from({ length: t }, (e, r) => at(r))
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function
|
|
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 ee(t) {
|
|
240
240
|
const e = [];
|
|
241
241
|
for (const r of t.questions) {
|
|
242
242
|
const n = e.at(-1);
|
|
@@ -244,13 +244,13 @@ function te(t) {
|
|
|
244
244
|
}
|
|
245
245
|
return e;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function We(t) {
|
|
248
248
|
const e = [];
|
|
249
|
-
for (const r of
|
|
249
|
+
for (const r of ee(t))
|
|
250
250
|
(!e.length || r[0].breakBefore) && e.push([]), e[e.length - 1].push(r);
|
|
251
251
|
return e;
|
|
252
252
|
}
|
|
253
|
-
const
|
|
253
|
+
const ne = {
|
|
254
254
|
judge: "判断题",
|
|
255
255
|
fill: "填空题",
|
|
256
256
|
answer: "解答题",
|
|
@@ -269,11 +269,11 @@ const ee = {
|
|
|
269
269
|
composite: "材料/复合题",
|
|
270
270
|
optional: "选做题组",
|
|
271
271
|
practice: "实践评价"
|
|
272
|
-
},
|
|
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: ["正确", "错误"] }, oe = (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 re(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
|
|
276
|
+
function ie(t, e = "1") {
|
|
277
277
|
const r = crypto.randomUUID();
|
|
278
278
|
return {
|
|
279
279
|
id: r,
|
|
@@ -285,7 +285,7 @@ function re(t, e = "1") {
|
|
|
285
285
|
score: null,
|
|
286
286
|
choice: { ...at(0, t === "judge" ? 2 : 4), id: r, label: e },
|
|
287
287
|
presentation: "concentrated",
|
|
288
|
-
blanks: [
|
|
288
|
+
blanks: [re()],
|
|
289
289
|
steps: [],
|
|
290
290
|
needsReason: !1,
|
|
291
291
|
judgment: null,
|
|
@@ -293,12 +293,12 @@ function re(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 se(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
|
-
function
|
|
299
|
+
function Ye(t) {
|
|
300
300
|
return {
|
|
301
|
-
items: [
|
|
301
|
+
items: [ie(se(t))],
|
|
302
302
|
judgeLabels: "symbols",
|
|
303
303
|
fillNewLine: !0,
|
|
304
304
|
pool: [],
|
|
@@ -319,10 +319,10 @@ function Xe(t) {
|
|
|
319
319
|
attachmentUrl: ""
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
|
-
function
|
|
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
|
|
325
|
+
function Pt(t) {
|
|
326
326
|
const e = structuredClone(t), r = /* @__PURE__ */ new Map(), n = (s) => {
|
|
327
327
|
!s || typeof s != "object" || Object.entries(s).forEach(([c, i]) => {
|
|
328
328
|
["id", "answerId"].includes(c) && typeof i == "string" ? r.set(i, crypto.randomUUID()) : n(i);
|
|
@@ -332,24 +332,24 @@ function kt(t) {
|
|
|
332
332
|
const o = (s) => typeof s == "string" ? r.get(s) || s : Array.isArray(s) ? s.map(o) : s && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([c, i]) => [r.get(c) || c, o(i)])) : s;
|
|
333
333
|
return o(e);
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
const r =
|
|
335
|
+
function qe(t, e) {
|
|
336
|
+
const r = Pt(t);
|
|
337
337
|
return { ...r, label: e, choice: { ...r.choice, label: e } };
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function tn(t, e, r) {
|
|
340
340
|
const n = t.findIndex((c) => c.id === e), o = n + r;
|
|
341
341
|
if (n < 0 || o < 0 || o >= t.length) return t;
|
|
342
342
|
const s = [...t];
|
|
343
343
|
return s.splice(o, 0, ...s.splice(n, 1)), s;
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function en(t, e) {
|
|
346
346
|
return { ...t, pool: t.pool.filter((r) => r.id !== e), sequence: t.sequence.filter((r) => r !== e), assignments: Object.fromEntries(Object.entries(t.assignments).filter(([r]) => r !== e)), items: t.items.map((r) => ({ ...r, targets: r.targets.filter((n) => n !== e) })) };
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function nn(t, e, r) {
|
|
349
349
|
const n = [...new Set(r)].filter((s) => t.pool.some((c) => c.id === s)), o = t.relation === "one" ? n.slice(-1) : n;
|
|
350
350
|
return { ...t, items: t.items.map((s) => s.id === e ? { ...s, targets: o } : t.reuseOptions ? s : { ...s, targets: s.targets.filter((c) => !o.includes(c)) }) };
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function on(t, e) {
|
|
353
353
|
let r = 0;
|
|
354
354
|
for (; r < e.length && r < t.chunkText.length && e[r] === t.chunkText[r]; ) r++;
|
|
355
355
|
let n = 0;
|
|
@@ -357,11 +357,11 @@ function nn(t, e) {
|
|
|
357
357
|
const o = t.chunkText.length - n, s = /* @__PURE__ */ new Set(), c = t.chunkPoints.filter((i) => i.offset <= r || i.offset >= o).map((i) => ({ ...i, offset: i.offset <= r ? 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
|
-
function
|
|
360
|
+
function rn(t, e) {
|
|
361
361
|
const r = [], n = t.items.map((o) => o.label.trim());
|
|
362
362
|
(n.some((o) => !o) || new Set(n).size !== n.length) && r.push("题号不能为空或重复");
|
|
363
363
|
for (const o of t.items) {
|
|
364
|
-
o.score !== null && (!Number.isFinite(o.score) || o.score < 0.5 || o.score >
|
|
364
|
+
o.score !== null && (!Number.isFinite(o.score) || o.score < 0.5 || o.score > oe(o.kind) || !Number.isInteger(o.score * 2)) && r.push(`${o.label} 题分值超出范围或不是 0.5 的倍数`);
|
|
365
365
|
const c = (o.kind === "fill" ? o.blanks : o.steps).map((i) => i.score);
|
|
366
366
|
c.length && o.score !== null && c.every((i) => i !== null) && c.reduce((i, a) => i + (a || 0), 0) !== o.score && r.push(`${o.label} 题分项分值之和与题分不一致`);
|
|
367
367
|
}
|
|
@@ -371,15 +371,15 @@ function on(t, e) {
|
|
|
371
371
|
}
|
|
372
372
|
return e === "optional" && t.chooseCount > t.items.length && r.push("选做数量不能超过题目数量"), e === "chunk" && t.chunkCorrect.length > t.chunkMax && r.push("正确断点数不能超过最多选择数"), r;
|
|
373
373
|
}
|
|
374
|
-
function
|
|
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
378
|
const e = (r) => !!(r.text || r.type && !["doc", "paragraph", "choiceStemAnchor"].includes(r.type) || r.content?.some(e));
|
|
379
379
|
return !e(t.content);
|
|
380
380
|
}
|
|
381
|
-
const
|
|
382
|
-
function
|
|
381
|
+
const cn = { choice: "选择题", area: "空白区域", ...ne };
|
|
382
|
+
function an(t) {
|
|
383
383
|
return {
|
|
384
384
|
id: crypto.randomUUID(),
|
|
385
385
|
kind: "area",
|
|
@@ -389,10 +389,10 @@ function cn(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
|
|
392
|
+
function ce() {
|
|
393
393
|
return { version: 1, title: "", questionCard: !1, preset: "a3-two", margin: 15, gap: 10, blocks: [] };
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function ae(t = "") {
|
|
396
396
|
return {
|
|
397
397
|
// 22px title + the configured 9mm line spacing + 10px bottom inset.
|
|
398
398
|
id: crypto.randomUUID(),
|
|
@@ -404,56 +404,56 @@ function ce(t = "") {
|
|
|
404
404
|
}] } }
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function le(t) {
|
|
408
408
|
return {
|
|
409
|
-
...
|
|
409
|
+
...ce(),
|
|
410
410
|
title: t.name,
|
|
411
411
|
creation: t,
|
|
412
|
-
paperTitle:
|
|
412
|
+
paperTitle: ae(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 ue = {
|
|
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 r =
|
|
426
|
-
return { ...r, width: n, height: o, margin: s, topInset:
|
|
423
|
+
}, et = 44, it = 16, dt = 1;
|
|
424
|
+
function It(t, e) {
|
|
425
|
+
const r = ue[t.preset], n = Q(r.width), o = Q(r.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 * (r.columns - 1)) / r.columns, b = Math.max(s, t.header ? t.recognition?.examQrCode ? 64 : 39 : 0), m = Math.max(s, t.header ? 56 : 0), f = o - b - m, p = 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 = (T, O = 0) => !!t.paperTitle && (t.header ? T % 2 === 0 && O === 0 : T === 0), C = (T, O = 0) => A(T, O) ? g : 0;
|
|
426
|
+
return { ...r, width: n, height: o, margin: s, topInset: b, bottomInset: m, gap: c, sealWidth: i, contentWidth: a, contentHeight: f, columnWidth: y, columnX: (T, O) => s + (T % 2 === 0 ? i : 0) + O * (y + c), titleWidth: l, titleMaxHeight: p, hasHeader: A, headerHeight: C, capacity: (T, O = 0) => f - C(T, O) };
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
const n =
|
|
428
|
+
function ln(t, e, r) {
|
|
429
|
+
const n = It(t, r);
|
|
430
430
|
let o = 0, s = 0, c = 0;
|
|
431
431
|
const i = () => {
|
|
432
432
|
s++, s === n.columns && (s = 0, o++), c = 0;
|
|
433
|
-
}, a = t.blocks.map((
|
|
434
|
-
const m = e[
|
|
435
|
-
if (p.length > 1 && p.every((M,
|
|
436
|
-
const O = p[
|
|
433
|
+
}, a = t.blocks.map((b) => {
|
|
434
|
+
const m = e[b.id], f = m && Math.abs(m.width - n.columnWidth) < 1 ? m.height : 100 + b.answerHeight, p = m && Math.abs(m.width - n.columnWidth) < 1 ? [...new Set([...m.breaks || [], f].filter((M) => Number.isFinite(M) && M > 0 && M <= f))].sort((M, T) => M - T) : [], l = b.reference?.type === "CCOMPOSITION", u = (M) => l && M > 0 ? Math.max(0, 6 - Math.max(0, (m?.compositionStart || 0) - M)) : 0;
|
|
435
|
+
if (p.length > 1 && p.every((M, T) => {
|
|
436
|
+
const O = p[T - 1] || 0;
|
|
437
437
|
return M - O + u(O) <= n.capacity(1) + 0.5;
|
|
438
438
|
})) {
|
|
439
439
|
const M = [];
|
|
440
|
-
let
|
|
441
|
-
for (;
|
|
442
|
-
const h = n.capacity(o, s) - c, I =
|
|
443
|
-
if (
|
|
440
|
+
let T = 0;
|
|
441
|
+
for (; T < f - 0.5; ) {
|
|
442
|
+
const h = n.capacity(o, s) - c, I = T, d = u(T), E = (N) => m?.markingFrames?.some((L) => L.from >= I - 0.5 && L.from < N - 0.5 && L.to > N + 0.5) ? 22 : 0, w = p.filter((N) => N > I + 0.5 && N + E(N) <= I + h - d + 0.5).at(-1);
|
|
443
|
+
if (w === void 0) {
|
|
444
444
|
i();
|
|
445
445
|
continue;
|
|
446
446
|
}
|
|
447
|
-
const S = l &&
|
|
448
|
-
M.push({ page: o, column: s, x: n.columnX(o, s), y: o * (n.height + et) + n.topInset + n.headerHeight(o, s) + c, from:
|
|
447
|
+
const S = l && w < f - 0.5 ? Math.max(E(w), h - d - (w - T)) : E(w);
|
|
448
|
+
M.push({ page: o, column: s, x: n.columnX(o, s), y: o * (n.height + et) + n.topInset + n.headerHeight(o, s) + c, from: T, to: w, ...d ? { topPadding: d } : {}, ...S ? { bottomPadding: S } : {} }), c += w - T + d, T = w, T < f - 0.5 && i();
|
|
449
449
|
}
|
|
450
450
|
c += it;
|
|
451
451
|
const O = M[0];
|
|
452
|
-
return { id:
|
|
452
|
+
return { id: b.id, ...O, height: f, available: n.capacity(O.page, O.column), overflowing: !1, fragments: M };
|
|
453
453
|
}
|
|
454
454
|
for (; c + f > n.capacity(o, s) + 0.5 && (c > 0 || n.headerHeight(o, s) > 0); ) i();
|
|
455
455
|
const A = n.capacity(o, s), C = f > A + 0.5, x = {
|
|
456
|
-
id:
|
|
456
|
+
id: b.id,
|
|
457
457
|
page: o,
|
|
458
458
|
column: s,
|
|
459
459
|
x: n.columnX(o, s),
|
|
@@ -465,19 +465,22 @@ function an(t, e, r) {
|
|
|
465
465
|
};
|
|
466
466
|
return c += Math.min(f, A) + it, x;
|
|
467
467
|
}), y = /* @__PURE__ */ new Map();
|
|
468
|
-
|
|
468
|
+
a.forEach((b, m) => b.fragments.forEach((f) => {
|
|
469
469
|
const p = `${f.page}/${f.column}`, l = y.get(p) || [];
|
|
470
|
-
l.push({ fragment: f, placement:
|
|
471
|
-
})), y.forEach((
|
|
472
|
-
const m =
|
|
470
|
+
l.push({ fragment: f, placement: b, blockIndex: m }), y.set(p, l);
|
|
471
|
+
})), y.forEach((b) => {
|
|
472
|
+
const m = b.filter((u) => ["answer", "writing", "english", "composite", "area"].includes(t.blocks[u.blockIndex].kind)).at(-1);
|
|
473
473
|
if (!m || t.blocks[m.blockIndex].reference?.type !== "CCOMPOSITION" && t.blocks[m.blockIndex].kind !== "area") return;
|
|
474
|
-
const f =
|
|
475
|
-
l <= 0 || l > 30 || (m.fragment.bottomPadding = (m.fragment.bottomPadding || 0) + l,
|
|
474
|
+
const f = b.at(-1).fragment, l = f.page * (n.height + et) + n.height - n.bottomInset - f.y - (f.to - f.from) - (f.topPadding || 0) - (f.bottomPadding || 0);
|
|
475
|
+
l <= 0 || l > 30 || (m.fragment.bottomPadding = (m.fragment.bottomPadding || 0) + l, b.slice(b.indexOf(m) + 1).forEach(({ fragment: u, placement: g }) => {
|
|
476
476
|
u.y += l, g.fragments[0] === u && (g.y = u.y);
|
|
477
477
|
}));
|
|
478
|
-
})
|
|
478
|
+
});
|
|
479
|
+
for (const b of a)
|
|
480
|
+
(b.overflowing || b.fragments.some((m) => m.page >= dt)) && (b.overflowFrom = b.fragments.filter((m) => m.page < dt).at(-1)?.to || 0);
|
|
481
|
+
return { geometry: n, placements: a, pageCount: dt, requiredPageCount: o + 1 };
|
|
479
482
|
}
|
|
480
|
-
function
|
|
483
|
+
function gt(t, e) {
|
|
481
484
|
return { version: 1, content: { type: "doc", content: [{ type: "paragraph", content: [
|
|
482
485
|
{ type: "text", text: `${t}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] },
|
|
483
486
|
...e ? [{ type: "text", text: `(${e}分)`, marks: [{ type: "documentLabel", attrs: { kind: "score" } }] }] : []
|
|
@@ -488,8 +491,8 @@ function st(t, e, r) {
|
|
|
488
491
|
if (!o.content) return o;
|
|
489
492
|
let s;
|
|
490
493
|
const c = o.content.flatMap((a) => {
|
|
491
|
-
const y = a.type === "text" && a.marks?.find((f) => f.type === "documentLabel")?.attrs?.kind,
|
|
492
|
-
if (s = y,
|
|
494
|
+
const y = a.type === "text" && a.marks?.find((f) => f.type === "documentLabel")?.attrs?.kind, b = y && y === s;
|
|
495
|
+
if (s = y, b) return [];
|
|
493
496
|
if (!y) return [n(a)];
|
|
494
497
|
const m = y === "number" ? `${e}.` : r ? `(${r}分)` : "";
|
|
495
498
|
return m ? [{ ...a, text: m }] : [];
|
|
@@ -498,7 +501,7 @@ function st(t, e, r) {
|
|
|
498
501
|
};
|
|
499
502
|
return { ...t, content: n(t.content) };
|
|
500
503
|
}
|
|
501
|
-
const
|
|
504
|
+
const yt = {
|
|
502
505
|
SCHOICE: "单选题",
|
|
503
506
|
MCHOICE: "多选题",
|
|
504
507
|
JUDGE: "判断题",
|
|
@@ -512,19 +515,19 @@ const It = {
|
|
|
512
515
|
ECOMPOSITION: "英语作文",
|
|
513
516
|
CCOMPOSITION: "语文作文",
|
|
514
517
|
CHUNK_CHOICE: "断句题"
|
|
515
|
-
},
|
|
516
|
-
function
|
|
517
|
-
const r =
|
|
518
|
-
return e ? ["CHINESE", "JAPANESE"].includes(r || "") ? [...n, "CHUNK_CHOICE"] : n : r === "CHINESE" ? [...n, "CCOMPOSITION", "CHUNK_CHOICE"] : r === "ENGLISH" ? [...n, "CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION", "ECOMPOSITION"] : r === "JAPANESE" ? Object.keys(
|
|
518
|
+
}, Ot = ["SCHOICE", "MCHOICE", "JUDGE", "FILLBLANK", "SHORTANSWER", "MIXED"];
|
|
519
|
+
function un(t, e = !1) {
|
|
520
|
+
const r = Dt(t), n = e ? Ot.filter((o) => o !== "MIXED") : Ot;
|
|
521
|
+
return e ? ["CHINESE", "JAPANESE"].includes(r || "") ? [...n, "CHUNK_CHOICE"] : n : r === "CHINESE" ? [...n, "CCOMPOSITION", "CHUNK_CHOICE"] : r === "ENGLISH" ? [...n, "CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION", "ECOMPOSITION"] : r === "JAPANESE" ? Object.keys(yt) : ["POLITICAL", "HISTORY"].includes(r || "") ? [...n, "CCOMPOSITION"] : n;
|
|
519
522
|
}
|
|
520
|
-
const
|
|
521
|
-
function
|
|
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 Rt(t, e, r = !1) {
|
|
522
525
|
return {
|
|
523
526
|
content: j(),
|
|
524
527
|
numbered: !r,
|
|
525
528
|
groupId: `options:${e.id}`,
|
|
526
|
-
layout: { ...
|
|
527
|
-
itemsContent: !r &&
|
|
529
|
+
layout: { ...Yt, columns: t === "CLOZE" ? 4 : 2, ...t === "READTHENANSWER" ? { layout: "fixed", columnGap: 0 } : {} },
|
|
530
|
+
itemsContent: !r && de(t) ? e.options.map((n) => ({ id: n.id, key: n.label, content: j() })) : []
|
|
528
531
|
};
|
|
529
532
|
}
|
|
530
533
|
const ct = (t) => {
|
|
@@ -532,7 +535,7 @@ const ct = (t) => {
|
|
|
532
535
|
const { contentId: e, ...r } = t.attrs || {};
|
|
533
536
|
return { ...t, ...t.attrs ? { attrs: r } : {}, ...t.content ? { content: t.content.map(ct).filter((n) => n !== null) } : {} };
|
|
534
537
|
};
|
|
535
|
-
function
|
|
538
|
+
function Nt(t, e, r) {
|
|
536
539
|
const o = (t.content.content.content || [{ type: "paragraph" }]).map((s) => ({ ...s, attrs: { ...s.attrs, contentId: e } }));
|
|
537
540
|
if (t.numbered) {
|
|
538
541
|
const s = { type: "text", text: `${r}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] };
|
|
@@ -544,7 +547,7 @@ function Ot(t, e, r) {
|
|
|
544
547
|
content: s.content.content.content || [{ type: "paragraph" }]
|
|
545
548
|
})) }), o;
|
|
546
549
|
}
|
|
547
|
-
function
|
|
550
|
+
function he(t, e) {
|
|
548
551
|
const r = e.filter((i) => i.type === "choiceGroup"), n = r.find((i) => i.attrs?.id === t.groupId) || (r.length === 1 ? r[0] : void 0), o = e.filter((i) => i !== n);
|
|
549
552
|
let s = !1;
|
|
550
553
|
const c = (i) => {
|
|
@@ -559,45 +562,45 @@ function de(t, e) {
|
|
|
559
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)) }))
|
|
560
563
|
};
|
|
561
564
|
}
|
|
562
|
-
function
|
|
565
|
+
function pe(t, e, r, n) {
|
|
563
566
|
const o = /* @__PURE__ */ new Map();
|
|
564
567
|
e.content.content?.forEach((i) => {
|
|
565
568
|
i.attrs?.contentId && o.set(i.attrs.contentId, [...o.get(i.attrs.contentId) || [], i]);
|
|
566
569
|
});
|
|
567
|
-
const s = new Set(n?.content.content?.map((i) => i.attrs?.contentId).filter(Boolean)), c = (i, a) => a && (o.has(i) || s.has(i)) ?
|
|
570
|
+
const s = new Set(n?.content.content?.map((i) => i.attrs?.contentId).filter(Boolean)), c = (i, a) => a && (o.has(i) || s.has(i)) ? he(a, o.get(i) || []) : a;
|
|
568
571
|
return {
|
|
569
572
|
...t,
|
|
570
573
|
...o.has(r) ? { material: Z(o.get(r).map((i) => ct(i))) } : {},
|
|
571
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) })) }))
|
|
572
575
|
};
|
|
573
576
|
}
|
|
574
|
-
function
|
|
577
|
+
function ge(t) {
|
|
575
578
|
const e = t.reference, r = [];
|
|
576
579
|
e.type === "MIXED" && r.push(...(e.material || j()).content.content.map((o) => ({ ...o, attrs: { ...o.attrs, contentId: t.id } }))), e.questions.forEach((o) => {
|
|
577
|
-
o.text && r.push(...
|
|
578
|
-
s.text && r.push(...
|
|
580
|
+
o.text && r.push(...Nt(o.text, o.id, o.label)), fe(o.type) && o.parts.forEach((s) => {
|
|
581
|
+
s.text && r.push(...Nt(s.text, s.id, s.label));
|
|
579
582
|
});
|
|
580
583
|
});
|
|
581
584
|
const n = (t.document.content.content || []).filter((o) => !o.attrs?.contentId);
|
|
582
585
|
return J(Z(n)) || r.push(...n), Z(r);
|
|
583
586
|
}
|
|
584
|
-
function
|
|
587
|
+
function me(t, e) {
|
|
585
588
|
const r = (n, o, s) => !n || !s || o.options.map((c) => c.id).join() === s.options.map((c) => c.id).join() ? n : { ...n, itemsContent: o.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() })) };
|
|
586
589
|
return { ...t, questions: t.questions.map((n) => {
|
|
587
590
|
const o = e.questions.find((s) => s.id === n.id);
|
|
588
591
|
return { ...n, text: r(n.text, n.choice, o?.choice), parts: n.parts.map((s) => ({ ...s, text: r(s.text, s.choice, o?.parts.find((c) => c.id === s.id)?.choice) })) };
|
|
589
592
|
}) };
|
|
590
593
|
}
|
|
591
|
-
function
|
|
594
|
+
function fn(t, e, r) {
|
|
592
595
|
if (t.reference?.textVersion !== 1) return t;
|
|
593
596
|
let n = t.reference;
|
|
594
597
|
if (!e && !J(t.document) && !t.document.content.content?.some((s) => s.attrs?.contentId)) return { ...t, reference: { ...n, textVersion: void 0 } };
|
|
595
598
|
if (e?.reference === n && e.document === t.document && !J(t.document)) return t;
|
|
596
|
-
if (t.document !== e?.document && (!J(t.document) || e) && (n =
|
|
599
|
+
if (t.document !== e?.document && (!J(t.document) || e) && (n = pe(n, t.document, t.id, e?.document), e && t.reference === e.reference))
|
|
597
600
|
return { ...t, reference: n };
|
|
598
|
-
e?.reference && t.reference !== e.reference && (n =
|
|
601
|
+
e?.reference && t.reference !== e.reference && (n = me(n, e.reference));
|
|
599
602
|
const o = { ...t, reference: n };
|
|
600
|
-
return r || !J(t.document) ? { ...o, document:
|
|
603
|
+
return r || !J(t.document) ? { ...o, document: ge(o) } : o;
|
|
601
604
|
}
|
|
602
605
|
const lt = {
|
|
603
606
|
SCHOICE: { count: 200, options: [2, 12], parts: 1, score: 15 },
|
|
@@ -612,15 +615,15 @@ const lt = {
|
|
|
612
615
|
TEXT_COMPLETION: { count: 20, options: [0, 0], parts: 20, score: 15 },
|
|
613
616
|
CCOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 },
|
|
614
617
|
ECOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 }
|
|
615
|
-
}, Y = (t) => ["SCHOICE", "MCHOICE", "JUDGE", "CHUNK_CHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING"].includes(t), R = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t),
|
|
616
|
-
function
|
|
617
|
-
return { type: t, textVersion: 1, questions: [], layout:
|
|
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", Ht = (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
|
+
function Ie(t) {
|
|
620
|
+
return { type: t, textVersion: 1, questions: [], layout: te(0), fillNewLine: !1, optional: !1, choose: 1, optionalHeight: 200, scoreType: "LESS_SCORE" };
|
|
618
621
|
}
|
|
619
|
-
function
|
|
620
|
-
return { id: crypto.randomUUID(), kind:
|
|
622
|
+
function hn(t) {
|
|
623
|
+
return { id: crypto.randomUUID(), kind: Ce[t], title: yt[t], answerHeight: 0, document: j(), reference: Ie(t) };
|
|
621
624
|
}
|
|
622
|
-
function
|
|
623
|
-
const n = t === "MCHOICE" &&
|
|
625
|
+
function pn(t, e = 1, r) {
|
|
626
|
+
const n = t === "MCHOICE" && pt(r);
|
|
624
627
|
return {
|
|
625
628
|
type: t,
|
|
626
629
|
start: e,
|
|
@@ -636,12 +639,12 @@ function hn(t, e = 1, r) {
|
|
|
636
639
|
singleScore: 1
|
|
637
640
|
};
|
|
638
641
|
}
|
|
639
|
-
function
|
|
642
|
+
function Bt(t, e, r) {
|
|
640
643
|
const n = Array.from({ length: r }, (o, s) => ({ ...t.options[s] || { id: crypto.randomUUID() }, label: e === "JUDGE" ? ["T", "F"][s] : String.fromCharCode(65 + s) }));
|
|
641
644
|
return { ...t, options: n, multiple: e === "MCHOICE" || e === "CHUNK_CHOICE", indefinite: !1, correctIds: t.correctIds.filter((o) => n.some((s) => s.id === o)).slice(0, e === "MCHOICE" || e === "CHUNK_CHOICE" ? r : 1) };
|
|
642
645
|
}
|
|
643
|
-
function
|
|
644
|
-
const o = crypto.randomUUID(), s = { ...
|
|
646
|
+
function ye(t, e, r, n = 4) {
|
|
647
|
+
const o = crypto.randomUUID(), s = { ...Bt(at(0), r, n), id: o, label: t, score: e };
|
|
645
648
|
return {
|
|
646
649
|
id: o,
|
|
647
650
|
label: t,
|
|
@@ -649,22 +652,22 @@ function Ie(t, e, r, n = 4) {
|
|
|
649
652
|
width: 25,
|
|
650
653
|
breakAfter: !1,
|
|
651
654
|
height: 100,
|
|
652
|
-
document: r === "SHORTANSWER" ?
|
|
655
|
+
document: r === "SHORTANSWER" ? gt(t, e) : j(),
|
|
653
656
|
choice: s,
|
|
654
|
-
...R(r) && r !== "TEXT_COMPLETION" ? { text:
|
|
657
|
+
...R(r) && r !== "TEXT_COMPLETION" ? { text: Rt(r, s) } : {}
|
|
655
658
|
};
|
|
656
659
|
}
|
|
657
|
-
function
|
|
658
|
-
const r = crypto.randomUUID(), { type: n, score: o } = t, s = String(e), c = t.partCount || 1, i = Array.from({ length: R(n) || ["FILLBLANK", "SHORTANSWER"].includes(n) ? c : 0 }, (y,
|
|
660
|
+
function be(t, e) {
|
|
661
|
+
const r = crypto.randomUUID(), { type: n, score: o } = t, s = String(e), c = t.partCount || 1, i = Array.from({ length: R(n) || ["FILLBLANK", "SHORTANSWER"].includes(n) ? c : 0 }, (y, b) => ye(R(n) ? String(e + b) : c === 1 ? s : `${s}.${b + 1}`, o, n, t.optionCount || 4)), a = { ...Bt(at(0), n, t.optionCount || 4), id: r, label: s, score: o, scoreType: t.scoreType, lessScore: t.lessScore };
|
|
659
662
|
return {
|
|
660
663
|
id: r,
|
|
661
664
|
type: n,
|
|
662
665
|
label: s,
|
|
663
|
-
score: i.length ?
|
|
666
|
+
score: i.length ? jt(i) : o,
|
|
664
667
|
choice: a,
|
|
665
|
-
text:
|
|
668
|
+
text: Rt(n, a, R(n)),
|
|
666
669
|
parts: i,
|
|
667
|
-
document: n === "ECOMPOSITION" ? { version: 1, content: { type: "doc", content: [...
|
|
670
|
+
document: n === "ECOMPOSITION" ? { version: 1, content: { type: "doc", content: [...gt(s, o).content.content, ...Ee(t.lines, t.paperWidth || 600).content.content] } } : n === "CCOMPOSITION" ? gt(s, o) : j(),
|
|
668
671
|
height: n === "ECOMPOSITION" ? 50 * t.lines + 40 : 100,
|
|
669
672
|
contentHeight: 38,
|
|
670
673
|
characters: t.characters,
|
|
@@ -674,19 +677,19 @@ function ye(t, e) {
|
|
|
674
677
|
singleScore: t.singleScore
|
|
675
678
|
};
|
|
676
679
|
}
|
|
677
|
-
const
|
|
678
|
-
function
|
|
680
|
+
const jt = (t) => t.some((e) => e.score === null) ? null : t.reduce((e, r) => e + (r.score || 0), 0);
|
|
681
|
+
function bt(t) {
|
|
679
682
|
return t.questions.flatMap((e) => R(e.type) ? e.parts.map((r) => r.label) : [e.label]);
|
|
680
683
|
}
|
|
681
|
-
function
|
|
682
|
-
return Math.max(0, ...
|
|
684
|
+
function gn(t) {
|
|
685
|
+
return Math.max(0, ...bt(t).map(Number).filter(Number.isFinite)) + 1;
|
|
683
686
|
}
|
|
684
|
-
function
|
|
685
|
-
const o = lt[e.type], s =
|
|
687
|
+
function mn(t, e, r = !1, n = !1) {
|
|
688
|
+
const o = lt[e.type], s = Ht(e.type) ? 1 : e.end - e.start + 1;
|
|
686
689
|
if (!Number.isInteger(e.start) || e.start < 1 || e.end > 1e3 || !Number.isInteger(s) || s < 1 || s > o.count) return `题号须为 1–1000,单次题数为 1–${o.count}`;
|
|
687
690
|
if (t.type === "CCOMPOSITION" && t.questions.length) return "语文作文每组只能有一道题";
|
|
688
691
|
if (t.optional) return "选做题组不能追加题目";
|
|
689
|
-
const c =
|
|
692
|
+
const c = bt(t);
|
|
690
693
|
if (Array.from({ length: s }, (i, a) => String(e.start + a)).some((i) => c.includes(i))) return "同一分组内,题号不能重复";
|
|
691
694
|
if (Y(e.type) && (e.optionCount === null || !Number.isInteger(e.optionCount) || e.optionCount < o.options[0] || e.optionCount > o.options[1])) return `选项个数须为 ${o.options[0]}–${o.options[1]}`;
|
|
692
695
|
if ((R(e.type) || ["FILLBLANK", "SHORTANSWER"].includes(e.type)) && (!e.partCount || !Number.isInteger(e.partCount) || e.partCount < 1 || e.partCount > o.parts)) return `子题/空数须为 1–${o.parts}`;
|
|
@@ -701,40 +704,40 @@ function gn(t, e, r = !1, n = !1) {
|
|
|
701
704
|
}
|
|
702
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;
|
|
703
706
|
}
|
|
704
|
-
function
|
|
707
|
+
function Cn(t, e, r) {
|
|
705
708
|
const n = R(e.type) ? e.partCount : 1, o = [];
|
|
706
|
-
for (let i = e.start; i <= (
|
|
709
|
+
for (let i = e.start; i <= (Ht(e.type) ? e.start : e.end); i += n) o.push(be(e, i));
|
|
707
710
|
const s = [...t.questions], c = s.findIndex((i) => i.id === r || i.parts.some((a) => a.id === r));
|
|
708
711
|
return s.splice(c < 0 ? s.length : c + 1, 0, ...o), { ...t, questions: s };
|
|
709
712
|
}
|
|
710
|
-
function
|
|
713
|
+
function In(t) {
|
|
711
714
|
return t.questions.flatMap((e) => [e, ...e.parts]);
|
|
712
715
|
}
|
|
713
|
-
function
|
|
716
|
+
function yn(t) {
|
|
714
717
|
return t.questions.filter((e) => Y(e.type)).flatMap((e) => R(e.type) ? e.parts.map((r) => ({ ...r.choice, label: r.label, score: r.score })) : [{ ...e.choice, label: e.label, score: e.score }]);
|
|
715
718
|
}
|
|
716
|
-
function
|
|
717
|
-
const r =
|
|
719
|
+
function bn(t, e) {
|
|
720
|
+
const r = Pt(t);
|
|
718
721
|
return r.referenceData && (r.referenceData = { ...r.referenceData, questionId: r.id }), r.text && (r.text.groupId = `options:${r.id}`), r.label = String(e), r.choice.label = r.label, r.choice.contentTarget = null, r.choice.breakBefore = !1, r.parts.forEach((n, o) => {
|
|
719
722
|
n.label = R(r.type) ? String(e + o) : r.parts.length === 1 ? r.label : `${e}.${o + 1}`, n.choice.label = n.label, n.choice.contentTarget = null, n.choice.breakBefore = !1;
|
|
720
723
|
}), r.parts.forEach((n) => {
|
|
721
724
|
n.text && (n.text.groupId = `options:${n.id}`), n.referenceData && (n.referenceData = { ...n.referenceData, questionId: n.id, questionPid: r.id });
|
|
722
725
|
}), r.document = st(r.document, r.label, r.score), r.parts = r.parts.map((n) => ({ ...n, document: st(n.document, n.label, n.score) })), r;
|
|
723
726
|
}
|
|
724
|
-
function
|
|
727
|
+
function En(t) {
|
|
725
728
|
return Math.max(1, Math.floor((t - 6) / 31));
|
|
726
729
|
}
|
|
727
|
-
function
|
|
730
|
+
function Ee(t, e) {
|
|
728
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" } }] }] })) } };
|
|
729
732
|
}
|
|
730
|
-
function
|
|
733
|
+
function wn(t, e, r = !1) {
|
|
731
734
|
const n = t.questions.reduce((s, c) => s + (c.parts.length || 1), 0), o = e / n;
|
|
732
735
|
return !n || !Number.isFinite(o) || o < (r ? 0 : 0.5) || !Number.isInteger(o * 2) || t.questions.some((s) => o > lt[s.type].score || o !== 0 && s.type === "CHUNK_CHOICE" && (s.rightAnswers || 0) * (s.singleScore || 0) > o) ? null : { ...t, questions: t.questions.map((s) => ({ ...s, score: o * (s.parts.length || 1), document: st(s.document, s.label, o * (s.parts.length || 1)), choice: { ...s.choice, score: o, lessScore: Math.min(s.choice.lessScore || 0, o) }, parts: s.parts.map((c) => ({ ...c, score: o, document: st(c.document, c.label, o), choice: { ...c.choice, score: o } })) })) };
|
|
733
736
|
}
|
|
734
|
-
function
|
|
737
|
+
function Tn(t, e) {
|
|
735
738
|
return [...t <= 17 ? Array.from({ length: 18 }, (r, n) => 17 - n <= t ? String(17 - n) : "") : [...Array.from({ length: 7 }, (r, n) => 7 - n <= Math.floor(t / 10) ? `${7 - n}0` : ""), "", ...Array.from({ length: 10 }, (r, n) => String(9 - n))], e ? "0.5" : ""];
|
|
736
739
|
}
|
|
737
|
-
const
|
|
740
|
+
const we = ["000", "100", "110", "111", "101", "010", "011", "001"], Sn = (t) => we[t - 1], Gt = {
|
|
738
741
|
CHINESE: [1],
|
|
739
742
|
MATHS: [2],
|
|
740
743
|
ENGLISH: [3],
|
|
@@ -750,7 +753,7 @@ const Ee = ["000", "100", "110", "111", "101", "010", "011", "001"], Tn = (t) =>
|
|
|
750
753
|
ART: [1, 3, 4],
|
|
751
754
|
SCIENCE: [2, 3, 4],
|
|
752
755
|
HISTORY: [1, 2, 3, 4]
|
|
753
|
-
},
|
|
756
|
+
}, Te = {
|
|
754
757
|
语文: "CHINESE",
|
|
755
758
|
数学: "MATHS",
|
|
756
759
|
英语: "ENGLISH",
|
|
@@ -770,11 +773,11 @@ const Ee = ["000", "100", "110", "111", "101", "010", "011", "001"], Tn = (t) =>
|
|
|
770
773
|
科学: "SCIENCE",
|
|
771
774
|
历史: "HISTORY"
|
|
772
775
|
};
|
|
773
|
-
function
|
|
774
|
-
return t?.subjectCode || (t?.courseCode &&
|
|
776
|
+
function Se(t) {
|
|
777
|
+
return t?.subjectCode || (t?.courseCode && Gt[t.courseCode] ? t.courseCode : Te[t?.subject || ""]);
|
|
775
778
|
}
|
|
776
|
-
const nt = (t) => Math.round(t * 1e3) / 1e3,
|
|
777
|
-
function
|
|
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
|
+
function On(t, e) {
|
|
778
781
|
const r = Math.max(t.x, e.x), n = Math.max(t.y, e.y), o = Math.min(t.x + t.width, e.x + e.width) - r, s = Math.min(t.y + t.height, e.y + e.height) - n;
|
|
779
782
|
return o > 0.01 && s > 0.01 ? { x: r, y: n, width: o, height: s } : void 0;
|
|
780
783
|
}
|
|
@@ -782,27 +785,27 @@ const V = function(t, e) {
|
|
|
782
785
|
let o = t;
|
|
783
786
|
const s = X[e];
|
|
784
787
|
let c = null, i = 0, a = null;
|
|
785
|
-
const y = [],
|
|
788
|
+
const y = [], b = {}, m = function(h, I) {
|
|
786
789
|
i = o * 4 + 17, c = (function(d) {
|
|
787
|
-
const
|
|
788
|
-
for (let
|
|
789
|
-
|
|
790
|
+
const E = new Array(d);
|
|
791
|
+
for (let w = 0; w < d; w += 1) {
|
|
792
|
+
E[w] = new Array(d);
|
|
790
793
|
for (let S = 0; S < d; S += 1)
|
|
791
|
-
|
|
794
|
+
E[w][S] = null;
|
|
792
795
|
}
|
|
793
|
-
return
|
|
796
|
+
return E;
|
|
794
797
|
})(i), f(0, 0), f(i - 7, 0), f(0, i - 7), u(), l(), A(h, I), o >= 7 && g(h), a == null && (a = M(o, s, y)), C(a, I);
|
|
795
798
|
}, f = function(h, I) {
|
|
796
799
|
for (let d = -1; d <= 7; d += 1)
|
|
797
800
|
if (!(h + d <= -1 || i <= h + d))
|
|
798
|
-
for (let
|
|
799
|
-
I +
|
|
801
|
+
for (let E = -1; E <= 7; E += 1)
|
|
802
|
+
I + E <= -1 || i <= I + E || (0 <= d && d <= 6 && (E == 0 || E == 6) || 0 <= E && E <= 6 && (d == 0 || d == 6) || 2 <= d && d <= 4 && 2 <= E && E <= 4 ? c[h + d][I + E] = !0 : c[h + d][I + E] = !1);
|
|
800
803
|
}, p = function() {
|
|
801
804
|
let h = 0, I = 0;
|
|
802
805
|
for (let d = 0; d < 8; d += 1) {
|
|
803
806
|
m(!0, d);
|
|
804
|
-
const
|
|
805
|
-
(d == 0 || h >
|
|
807
|
+
const E = F.getLostPoint(b);
|
|
808
|
+
(d == 0 || h > E) && (h = E, I = d);
|
|
806
809
|
}
|
|
807
810
|
return I;
|
|
808
811
|
}, l = function() {
|
|
@@ -814,62 +817,62 @@ const V = function(t, e) {
|
|
|
814
817
|
const h = F.getPatternPosition(o);
|
|
815
818
|
for (let I = 0; I < h.length; I += 1)
|
|
816
819
|
for (let d = 0; d < h.length; d += 1) {
|
|
817
|
-
const
|
|
818
|
-
if (c[
|
|
820
|
+
const E = h[I], w = h[d];
|
|
821
|
+
if (c[E][w] == null)
|
|
819
822
|
for (let S = -2; S <= 2; S += 1)
|
|
820
823
|
for (let N = -2; N <= 2; N += 1)
|
|
821
|
-
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[E + S][w + N] = !0 : c[E + S][w + N] = !1;
|
|
822
825
|
}
|
|
823
826
|
}, g = function(h) {
|
|
824
827
|
const I = F.getBCHTypeNumber(o);
|
|
825
828
|
for (let d = 0; d < 18; d += 1) {
|
|
826
|
-
const
|
|
827
|
-
c[Math.floor(d / 3)][d % 3 + i - 8 - 3] =
|
|
829
|
+
const E = !h && (I >> d & 1) == 1;
|
|
830
|
+
c[Math.floor(d / 3)][d % 3 + i - 8 - 3] = E;
|
|
828
831
|
}
|
|
829
832
|
for (let d = 0; d < 18; d += 1) {
|
|
830
|
-
const
|
|
831
|
-
c[d % 3 + i - 8 - 3][Math.floor(d / 3)] =
|
|
833
|
+
const E = !h && (I >> d & 1) == 1;
|
|
834
|
+
c[d % 3 + i - 8 - 3][Math.floor(d / 3)] = E;
|
|
832
835
|
}
|
|
833
836
|
}, A = function(h, I) {
|
|
834
|
-
const d = s << 3 | I,
|
|
835
|
-
for (let
|
|
836
|
-
const S = !h && (
|
|
837
|
-
|
|
837
|
+
const d = s << 3 | I, E = F.getBCHTypeInfo(d);
|
|
838
|
+
for (let w = 0; w < 15; w += 1) {
|
|
839
|
+
const S = !h && (E >> w & 1) == 1;
|
|
840
|
+
w < 6 ? c[w][8] = S : w < 8 ? c[w + 1][8] = S : c[i - 15 + w][8] = S;
|
|
838
841
|
}
|
|
839
|
-
for (let
|
|
840
|
-
const S = !h && (
|
|
841
|
-
|
|
842
|
+
for (let w = 0; w < 15; w += 1) {
|
|
843
|
+
const S = !h && (E >> w & 1) == 1;
|
|
844
|
+
w < 8 ? c[8][i - w - 1] = S : w < 9 ? c[8][15 - w - 1 + 1] = S : c[8][15 - w - 1] = S;
|
|
842
845
|
}
|
|
843
846
|
c[i - 8][8] = !h;
|
|
844
847
|
}, C = function(h, I) {
|
|
845
|
-
let d = -1,
|
|
848
|
+
let d = -1, E = i - 1, w = 7, S = 0;
|
|
846
849
|
const N = F.getMaskFunction(I);
|
|
847
850
|
for (let L = i - 1; L > 0; L -= 2)
|
|
848
851
|
for (L == 6 && (L -= 1); ; ) {
|
|
849
852
|
for (let _ = 0; _ < 2; _ += 1)
|
|
850
|
-
if (c[
|
|
853
|
+
if (c[E][L - _] == null) {
|
|
851
854
|
let k = !1;
|
|
852
|
-
S < h.length && (k = (h[S] >>>
|
|
855
|
+
S < h.length && (k = (h[S] >>> w & 1) == 1), N(E, L - _) && (k = !k), c[E][L - _] = k, w -= 1, w == -1 && (S += 1, w = 7);
|
|
853
856
|
}
|
|
854
|
-
if (
|
|
855
|
-
|
|
857
|
+
if (E += d, E < 0 || i <= E) {
|
|
858
|
+
E -= d, d = -d;
|
|
856
859
|
break;
|
|
857
860
|
}
|
|
858
861
|
}
|
|
859
862
|
}, x = function(h, I) {
|
|
860
|
-
let d = 0,
|
|
863
|
+
let d = 0, E = 0, w = 0;
|
|
861
864
|
const S = new Array(I.length), N = new Array(I.length);
|
|
862
865
|
for (let $ = 0; $ < I.length; $ += 1) {
|
|
863
866
|
const D = I[$].dataCount, H = I[$].totalCount - D;
|
|
864
|
-
|
|
867
|
+
E = Math.max(E, D), w = Math.max(w, H), S[$] = new Array(D);
|
|
865
868
|
for (let G = 0; G < S[$].length; G += 1)
|
|
866
869
|
S[$][G] = 255 & h.getBuffer()[G + d];
|
|
867
870
|
d += D;
|
|
868
|
-
const ft = F.getErrorCorrectPolynomial(H),
|
|
871
|
+
const ft = F.getErrorCorrectPolynomial(H), Et = q(S[$], ft.getLength() - 1).mod(ft);
|
|
869
872
|
N[$] = new Array(ft.getLength() - 1);
|
|
870
873
|
for (let G = 0; G < N[$].length; G += 1) {
|
|
871
|
-
const
|
|
872
|
-
N[$][G] =
|
|
874
|
+
const wt = G + Et.getLength() - N[$].length;
|
|
875
|
+
N[$][G] = wt >= 0 ? Et.getAt(wt) : 0;
|
|
873
876
|
}
|
|
874
877
|
}
|
|
875
878
|
let L = 0;
|
|
@@ -877,115 +880,115 @@ const V = function(t, e) {
|
|
|
877
880
|
L += I[$].totalCount;
|
|
878
881
|
const _ = new Array(L);
|
|
879
882
|
let k = 0;
|
|
880
|
-
for (let $ = 0; $ <
|
|
883
|
+
for (let $ = 0; $ < E; $ += 1)
|
|
881
884
|
for (let D = 0; D < I.length; D += 1)
|
|
882
885
|
$ < S[D].length && (_[k] = S[D][$], k += 1);
|
|
883
|
-
for (let $ = 0; $ <
|
|
886
|
+
for (let $ = 0; $ < w; $ += 1)
|
|
884
887
|
for (let D = 0; D < I.length; D += 1)
|
|
885
888
|
$ < N[D].length && (_[k] = N[D][$], k += 1);
|
|
886
889
|
return _;
|
|
887
890
|
}, M = function(h, I, d) {
|
|
888
|
-
const
|
|
891
|
+
const E = Mt.getRSBlocks(h, I), w = xt();
|
|
889
892
|
for (let N = 0; N < d.length; N += 1) {
|
|
890
893
|
const L = d[N];
|
|
891
|
-
|
|
894
|
+
w.put(L.getMode(), 4), w.put(L.getLength(), F.getLengthInBits(L.getMode(), h)), L.write(w);
|
|
892
895
|
}
|
|
893
896
|
let S = 0;
|
|
894
|
-
for (let N = 0; N <
|
|
895
|
-
S +=
|
|
896
|
-
if (
|
|
897
|
-
throw "code length overflow. (" +
|
|
898
|
-
for (
|
|
899
|
-
|
|
900
|
-
for (; !(
|
|
901
|
-
|
|
902
|
-
return x(
|
|
897
|
+
for (let N = 0; N < E.length; N += 1)
|
|
898
|
+
S += E[N].dataCount;
|
|
899
|
+
if (w.getLengthInBits() > S * 8)
|
|
900
|
+
throw "code length overflow. (" + w.getLengthInBits() + ">" + S * 8 + ")";
|
|
901
|
+
for (w.getLengthInBits() + 4 <= S * 8 && w.put(0, 4); w.getLengthInBits() % 8 != 0; )
|
|
902
|
+
w.putBit(!1);
|
|
903
|
+
for (; !(w.getLengthInBits() >= S * 8 || (w.put(236, 8), w.getLengthInBits() >= S * 8)); )
|
|
904
|
+
w.put(17, 8);
|
|
905
|
+
return x(w, E);
|
|
903
906
|
};
|
|
904
|
-
|
|
907
|
+
b.addData = function(h, I) {
|
|
905
908
|
I = I || "Byte";
|
|
906
909
|
let d = null;
|
|
907
910
|
switch (I) {
|
|
908
911
|
case "Numeric":
|
|
909
|
-
d =
|
|
912
|
+
d = Ae(h);
|
|
910
913
|
break;
|
|
911
914
|
case "Alphanumeric":
|
|
912
|
-
d =
|
|
915
|
+
d = Oe(h);
|
|
913
916
|
break;
|
|
914
917
|
case "Byte":
|
|
915
|
-
d =
|
|
918
|
+
d = Ne(h);
|
|
916
919
|
break;
|
|
917
920
|
case "Kanji":
|
|
918
|
-
d =
|
|
921
|
+
d = Me(h);
|
|
919
922
|
break;
|
|
920
923
|
default:
|
|
921
924
|
throw "mode:" + I;
|
|
922
925
|
}
|
|
923
926
|
y.push(d), a = null;
|
|
924
|
-
},
|
|
927
|
+
}, b.isDark = function(h, I) {
|
|
925
928
|
if (h < 0 || i <= h || I < 0 || i <= I)
|
|
926
929
|
throw h + "," + I;
|
|
927
930
|
return c[h][I];
|
|
928
|
-
},
|
|
931
|
+
}, b.getModuleCount = function() {
|
|
929
932
|
return i;
|
|
930
|
-
},
|
|
933
|
+
}, b.make = function() {
|
|
931
934
|
if (o < 1) {
|
|
932
935
|
let h = 1;
|
|
933
936
|
for (; h < 40; h++) {
|
|
934
|
-
const I =
|
|
935
|
-
for (let
|
|
936
|
-
const S = y[
|
|
937
|
+
const I = Mt.getRSBlocks(h, s), d = xt();
|
|
938
|
+
for (let w = 0; w < y.length; w++) {
|
|
939
|
+
const S = y[w];
|
|
937
940
|
d.put(S.getMode(), 4), d.put(S.getLength(), F.getLengthInBits(S.getMode(), h)), S.write(d);
|
|
938
941
|
}
|
|
939
|
-
let
|
|
940
|
-
for (let
|
|
941
|
-
|
|
942
|
-
if (d.getLengthInBits() <=
|
|
942
|
+
let E = 0;
|
|
943
|
+
for (let w = 0; w < I.length; w++)
|
|
944
|
+
E += I[w].dataCount;
|
|
945
|
+
if (d.getLengthInBits() <= E * 8)
|
|
943
946
|
break;
|
|
944
947
|
}
|
|
945
948
|
o = h;
|
|
946
949
|
}
|
|
947
950
|
m(!1, p());
|
|
948
|
-
},
|
|
951
|
+
}, b.createTableTag = function(h, I) {
|
|
949
952
|
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
950
953
|
let d = "";
|
|
951
954
|
d += '<table style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: " + I + "px;", d += '">', d += "<tbody>";
|
|
952
|
-
for (let
|
|
955
|
+
for (let E = 0; E < b.getModuleCount(); E += 1) {
|
|
953
956
|
d += "<tr>";
|
|
954
|
-
for (let
|
|
955
|
-
d += '<td style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: 0px;", d += " width: " + h + "px;", d += " height: " + h + "px;", d += " background-color: ", d +=
|
|
957
|
+
for (let w = 0; w < b.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: " + h + "px;", d += " height: " + h + "px;", d += " background-color: ", d += b.isDark(E, w) ? "#000000" : "#ffffff", d += ";", d += '"/>';
|
|
956
959
|
d += "</tr>";
|
|
957
960
|
}
|
|
958
961
|
return d += "</tbody>", d += "</table>", d;
|
|
959
|
-
},
|
|
960
|
-
let
|
|
961
|
-
typeof arguments[0] == "object" && (
|
|
962
|
-
const S =
|
|
962
|
+
}, b.createSvgTag = function(h, I, d, E) {
|
|
963
|
+
let w = {};
|
|
964
|
+
typeof arguments[0] == "object" && (w = arguments[0], h = w.cellSize, I = w.margin, d = w.alt, E = w.title), h = h || 2, I = typeof I > "u" ? h * 4 : I, d = typeof d == "string" ? { text: d } : d || {}, d.text = d.text || null, d.id = d.text ? d.id || "qrcode-description" : null, E = typeof E == "string" ? { text: E } : E || {}, E.text = E.text || null, E.id = E.text ? E.id || "qrcode-title" : null;
|
|
965
|
+
const S = b.getModuleCount() * h + I * 2;
|
|
963
966
|
let N, L, _, k, $ = "", D;
|
|
964
|
-
for (D = "l" + h + ",0 0," + h + " -" + h + ",0 0,-" + h + "z ", $ += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', $ +=
|
|
965
|
-
for (k = _ * h + I, N = 0; N <
|
|
966
|
-
|
|
967
|
+
for (D = "l" + h + ",0 0," + h + " -" + h + ",0 0,-" + h + "z ", $ += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', $ += w.scalable ? "" : ' width="' + S + 'px" height="' + S + 'px"', $ += ' viewBox="0 0 ' + S + " " + S + '" ', $ += ' preserveAspectRatio="xMinYMin meet"', $ += E.text || d.text ? ' role="img" aria-labelledby="' + T([E.id, d.id].join(" ").trim()) + '"' : "", $ += ">", $ += E.text ? '<title id="' + T(E.id) + '">' + T(E.text) + "</title>" : "", $ += d.text ? '<description id="' + T(d.id) + '">' + T(d.text) + "</description>" : "", $ += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', $ += '<path d="', _ = 0; _ < b.getModuleCount(); _ += 1)
|
|
968
|
+
for (k = _ * h + I, N = 0; N < b.getModuleCount(); N += 1)
|
|
969
|
+
b.isDark(_, N) && (L = N * h + I, $ += "M" + L + "," + k + D);
|
|
967
970
|
return $ += '" stroke="transparent" fill="black"/>', $ += "</svg>", $;
|
|
968
|
-
},
|
|
971
|
+
}, b.createDataURL = function(h, I) {
|
|
969
972
|
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
970
|
-
const d =
|
|
971
|
-
return
|
|
972
|
-
if (
|
|
973
|
-
const L = Math.floor((S -
|
|
974
|
-
return
|
|
973
|
+
const d = b.getModuleCount() * h + I * 2, E = I, w = d - I;
|
|
974
|
+
return _e(d, d, function(S, N) {
|
|
975
|
+
if (E <= S && S < w && E <= N && N < w) {
|
|
976
|
+
const L = Math.floor((S - E) / h), _ = Math.floor((N - E) / h);
|
|
977
|
+
return b.isDark(_, L) ? 0 : 1;
|
|
975
978
|
} else
|
|
976
979
|
return 1;
|
|
977
980
|
});
|
|
978
|
-
},
|
|
981
|
+
}, b.createImgTag = function(h, I, d) {
|
|
979
982
|
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
980
|
-
const
|
|
981
|
-
let
|
|
982
|
-
return
|
|
983
|
+
const E = b.getModuleCount() * h + I * 2;
|
|
984
|
+
let w = "";
|
|
985
|
+
return w += "<img", w += ' src="', w += b.createDataURL(h, I), w += '"', w += ' width="', w += E, w += '"', w += ' height="', w += E, w += '"', d && (w += ' alt="', w += T(d), w += '"'), w += "/>", w;
|
|
983
986
|
};
|
|
984
|
-
const
|
|
987
|
+
const T = function(h) {
|
|
985
988
|
let I = "";
|
|
986
989
|
for (let d = 0; d < h.length; d += 1) {
|
|
987
|
-
const
|
|
988
|
-
switch (
|
|
990
|
+
const E = h.charAt(d);
|
|
991
|
+
switch (E) {
|
|
989
992
|
case "<":
|
|
990
993
|
I += "<";
|
|
991
994
|
break;
|
|
@@ -999,14 +1002,14 @@ const V = function(t, e) {
|
|
|
999
1002
|
I += """;
|
|
1000
1003
|
break;
|
|
1001
1004
|
default:
|
|
1002
|
-
I +=
|
|
1005
|
+
I += E;
|
|
1003
1006
|
break;
|
|
1004
1007
|
}
|
|
1005
1008
|
}
|
|
1006
1009
|
return I;
|
|
1007
1010
|
}, O = function(h) {
|
|
1008
1011
|
h = typeof h > "u" ? 2 : h;
|
|
1009
|
-
const d =
|
|
1012
|
+
const d = b.getModuleCount() * 1 + h * 2, E = h, w = d - h;
|
|
1010
1013
|
let S, N, L, _, k;
|
|
1011
1014
|
const $ = {
|
|
1012
1015
|
"██": "█",
|
|
@@ -1021,36 +1024,36 @@ const V = function(t, e) {
|
|
|
1021
1024
|
};
|
|
1022
1025
|
let H = "";
|
|
1023
1026
|
for (S = 0; S < d; S += 2) {
|
|
1024
|
-
for (L = Math.floor((S -
|
|
1025
|
-
k = "█",
|
|
1027
|
+
for (L = Math.floor((S - E) / 1), _ = Math.floor((S + 1 - E) / 1), N = 0; N < d; N += 1)
|
|
1028
|
+
k = "█", E <= N && N < w && E <= S && S < w && b.isDark(L, Math.floor((N - E) / 1)) && (k = " "), E <= N && N < w && E <= S + 1 && S + 1 < w && b.isDark(_, Math.floor((N - E) / 1)) ? k += " " : k += "█", H += h < 1 && S + 1 >= w ? D[k] : $[k];
|
|
1026
1029
|
H += `
|
|
1027
1030
|
`;
|
|
1028
1031
|
}
|
|
1029
1032
|
return d % 2 && h > 0 ? H.substring(0, H.length - d - 1) + Array(d + 1).join("▀") : H.substring(0, H.length - 1);
|
|
1030
1033
|
};
|
|
1031
|
-
return
|
|
1034
|
+
return b.createASCII = function(h, I) {
|
|
1032
1035
|
if (h = h || 1, h < 2)
|
|
1033
1036
|
return O(I);
|
|
1034
1037
|
h -= 1, I = typeof I > "u" ? h * 2 : I;
|
|
1035
|
-
const d =
|
|
1038
|
+
const d = b.getModuleCount() * h + I * 2, E = I, w = d - I;
|
|
1036
1039
|
let S, N, L, _;
|
|
1037
1040
|
const k = Array(h + 1).join("██"), $ = Array(h + 1).join(" ");
|
|
1038
1041
|
let D = "", H = "";
|
|
1039
1042
|
for (S = 0; S < d; S += 1) {
|
|
1040
|
-
for (L = Math.floor((S -
|
|
1041
|
-
_ = 1,
|
|
1043
|
+
for (L = Math.floor((S - E) / h), H = "", N = 0; N < d; N += 1)
|
|
1044
|
+
_ = 1, E <= N && N < w && E <= S && S < w && b.isDark(L, Math.floor((N - E) / h)) && (_ = 0), H += _ ? k : $;
|
|
1042
1045
|
for (L = 0; L < h; L += 1)
|
|
1043
1046
|
D += H + `
|
|
1044
1047
|
`;
|
|
1045
1048
|
}
|
|
1046
1049
|
return D.substring(0, D.length - 1);
|
|
1047
|
-
},
|
|
1050
|
+
}, b.renderTo2dContext = function(h, I) {
|
|
1048
1051
|
I = I || 2;
|
|
1049
|
-
const d =
|
|
1050
|
-
for (let
|
|
1051
|
-
for (let
|
|
1052
|
-
h.fillStyle =
|
|
1053
|
-
},
|
|
1052
|
+
const d = b.getModuleCount();
|
|
1053
|
+
for (let E = 0; E < d; E++)
|
|
1054
|
+
for (let w = 0; w < d; w++)
|
|
1055
|
+
h.fillStyle = b.isDark(E, w) ? "black" : "white", h.fillRect(w * I, E * I, I, I);
|
|
1056
|
+
}, b;
|
|
1054
1057
|
};
|
|
1055
1058
|
V.stringToBytes = function(t) {
|
|
1056
1059
|
const e = [];
|
|
@@ -1062,7 +1065,7 @@ V.stringToBytes = function(t) {
|
|
|
1062
1065
|
};
|
|
1063
1066
|
V.createStringToBytes = function(t, e) {
|
|
1064
1067
|
const r = (function() {
|
|
1065
|
-
const o =
|
|
1068
|
+
const o = $e(t), s = function() {
|
|
1066
1069
|
const a = o.read();
|
|
1067
1070
|
if (a == -1) throw "eof";
|
|
1068
1071
|
return a;
|
|
@@ -1072,7 +1075,7 @@ V.createStringToBytes = function(t, e) {
|
|
|
1072
1075
|
for (; ; ) {
|
|
1073
1076
|
const a = o.read();
|
|
1074
1077
|
if (a == -1) break;
|
|
1075
|
-
const y = s(),
|
|
1078
|
+
const y = s(), b = s(), m = s(), f = String.fromCharCode(a << 8 | y), p = b << 8 | m;
|
|
1076
1079
|
i[f] = p, c += 1;
|
|
1077
1080
|
}
|
|
1078
1081
|
if (c != e)
|
|
@@ -1284,8 +1287,8 @@ const P = {
|
|
|
1284
1287
|
for (let m = 0; m < i; m += 1)
|
|
1285
1288
|
for (let f = 0; f < i; f += 1)
|
|
1286
1289
|
c.isDark(f, m) && (y += 1);
|
|
1287
|
-
const
|
|
1288
|
-
return a +=
|
|
1290
|
+
const b = Math.abs(100 * y / i / i - 50) / 5;
|
|
1291
|
+
return a += b * 10, a;
|
|
1289
1292
|
}, o;
|
|
1290
1293
|
})(), K = (function() {
|
|
1291
1294
|
const t = new Array(256), e = new Array(256);
|
|
@@ -1339,7 +1342,7 @@ const P = {
|
|
|
1339
1342
|
c[i] ^= K.gexp(K.glog(o.getAt(i)) + s);
|
|
1340
1343
|
return q(c, 0).mod(o);
|
|
1341
1344
|
}, n;
|
|
1342
|
-
},
|
|
1345
|
+
}, Mt = (function() {
|
|
1343
1346
|
const t = [
|
|
1344
1347
|
// L
|
|
1345
1348
|
// M
|
|
@@ -1568,13 +1571,13 @@ const P = {
|
|
|
1568
1571
|
throw "bad rs block @ typeNumber:" + o + "/errorCorrectionLevel:" + s;
|
|
1569
1572
|
const i = c.length / 3, a = [];
|
|
1570
1573
|
for (let y = 0; y < i; y += 1) {
|
|
1571
|
-
const
|
|
1572
|
-
for (let p = 0; p <
|
|
1574
|
+
const b = c[y * 3 + 0], m = c[y * 3 + 1], f = c[y * 3 + 2];
|
|
1575
|
+
for (let p = 0; p < b; p += 1)
|
|
1573
1576
|
a.push(e(m, f));
|
|
1574
1577
|
}
|
|
1575
1578
|
return a;
|
|
1576
1579
|
}, r;
|
|
1577
|
-
})(),
|
|
1580
|
+
})(), xt = function() {
|
|
1578
1581
|
const t = [];
|
|
1579
1582
|
let e = 0;
|
|
1580
1583
|
const r = {};
|
|
@@ -1592,7 +1595,7 @@ const P = {
|
|
|
1592
1595
|
const o = Math.floor(e / 8);
|
|
1593
1596
|
t.length <= o && t.push(0), n && (t[o] |= 128 >>> e % 8), e += 1;
|
|
1594
1597
|
}, r;
|
|
1595
|
-
},
|
|
1598
|
+
}, Ae = function(t) {
|
|
1596
1599
|
const e = P.MODE_NUMBER, r = t, n = {};
|
|
1597
1600
|
n.getMode = function() {
|
|
1598
1601
|
return e;
|
|
@@ -1616,7 +1619,7 @@ const P = {
|
|
|
1616
1619
|
throw "illegal char :" + c;
|
|
1617
1620
|
};
|
|
1618
1621
|
return n;
|
|
1619
|
-
},
|
|
1622
|
+
}, Oe = function(t) {
|
|
1620
1623
|
const e = P.MODE_ALPHA_NUM, r = t, n = {};
|
|
1621
1624
|
n.getMode = function() {
|
|
1622
1625
|
return e;
|
|
@@ -1661,7 +1664,7 @@ const P = {
|
|
|
1661
1664
|
}
|
|
1662
1665
|
};
|
|
1663
1666
|
return n;
|
|
1664
|
-
},
|
|
1667
|
+
}, Ne = function(t) {
|
|
1665
1668
|
const e = P.MODE_8BIT_BYTE, r = V.stringToBytes(t), n = {};
|
|
1666
1669
|
return n.getMode = function() {
|
|
1667
1670
|
return e;
|
|
@@ -1671,7 +1674,7 @@ const P = {
|
|
|
1671
1674
|
for (let s = 0; s < r.length; s += 1)
|
|
1672
1675
|
o.put(r[s], 8);
|
|
1673
1676
|
}, n;
|
|
1674
|
-
},
|
|
1677
|
+
}, Me = function(t) {
|
|
1675
1678
|
const e = P.MODE_KANJI, r = V.stringToBytes;
|
|
1676
1679
|
(function(s, c) {
|
|
1677
1680
|
const i = r(s);
|
|
@@ -1699,7 +1702,7 @@ const P = {
|
|
|
1699
1702
|
if (i < c.length)
|
|
1700
1703
|
throw "illegal char at " + (i + 1);
|
|
1701
1704
|
}, o;
|
|
1702
|
-
},
|
|
1705
|
+
}, Ut = function() {
|
|
1703
1706
|
const t = [], e = {};
|
|
1704
1707
|
return e.writeByte = function(r) {
|
|
1705
1708
|
t.push(r & 255);
|
|
@@ -1721,7 +1724,7 @@ const P = {
|
|
|
1721
1724
|
n > 0 && (r += ","), r += t[n];
|
|
1722
1725
|
return r += "]", r;
|
|
1723
1726
|
}, e;
|
|
1724
|
-
},
|
|
1727
|
+
}, xe = function() {
|
|
1725
1728
|
let t = 0, e = 0, r = 0, n = "";
|
|
1726
1729
|
const o = {}, s = function(i) {
|
|
1727
1730
|
n += String.fromCharCode(c(i & 63));
|
|
@@ -1752,7 +1755,7 @@ const P = {
|
|
|
1752
1755
|
}, o.toString = function() {
|
|
1753
1756
|
return n;
|
|
1754
1757
|
}, o;
|
|
1755
|
-
},
|
|
1758
|
+
}, $e = function(t) {
|
|
1756
1759
|
const e = t;
|
|
1757
1760
|
let r = 0, n = 0, o = 0;
|
|
1758
1761
|
const s = {};
|
|
@@ -1787,41 +1790,41 @@ const P = {
|
|
|
1787
1790
|
throw "c:" + i;
|
|
1788
1791
|
};
|
|
1789
1792
|
return s;
|
|
1790
|
-
},
|
|
1793
|
+
}, Le = function(t, e) {
|
|
1791
1794
|
const r = t, n = e, o = new Array(t * e), s = {};
|
|
1792
|
-
s.setPixel = function(y,
|
|
1793
|
-
o[
|
|
1795
|
+
s.setPixel = function(y, b, m) {
|
|
1796
|
+
o[b * r + y] = m;
|
|
1794
1797
|
}, s.write = function(y) {
|
|
1795
1798
|
y.writeString("GIF87a"), y.writeShort(r), 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(r), y.writeShort(n), y.writeByte(0);
|
|
1796
|
-
const
|
|
1797
|
-
y.writeByte(
|
|
1799
|
+
const b = 2, m = i(b);
|
|
1800
|
+
y.writeByte(b);
|
|
1798
1801
|
let f = 0;
|
|
1799
1802
|
for (; m.length - f > 255; )
|
|
1800
1803
|
y.writeByte(255), y.writeBytes(m, f, 255), f += 255;
|
|
1801
1804
|
y.writeByte(m.length - f), y.writeBytes(m, f, m.length - f), y.writeByte(0), y.writeString(";");
|
|
1802
1805
|
};
|
|
1803
1806
|
const c = function(y) {
|
|
1804
|
-
const
|
|
1807
|
+
const b = y;
|
|
1805
1808
|
let m = 0, f = 0;
|
|
1806
1809
|
const p = {};
|
|
1807
1810
|
return p.write = function(l, u) {
|
|
1808
1811
|
if (l >>> u)
|
|
1809
1812
|
throw "length over";
|
|
1810
1813
|
for (; m + u >= 8; )
|
|
1811
|
-
|
|
1814
|
+
b.writeByte(255 & (l << m | f)), u -= 8 - m, l >>>= 8 - m, f = 0, m = 0;
|
|
1812
1815
|
f = l << m | f, m = m + u;
|
|
1813
1816
|
}, p.flush = function() {
|
|
1814
|
-
m > 0 &&
|
|
1817
|
+
m > 0 && b.writeByte(f);
|
|
1815
1818
|
}, p;
|
|
1816
1819
|
}, i = function(y) {
|
|
1817
|
-
const
|
|
1820
|
+
const b = 1 << y, m = (1 << y) + 1;
|
|
1818
1821
|
let f = y + 1;
|
|
1819
1822
|
const p = a();
|
|
1820
|
-
for (let C = 0; C <
|
|
1823
|
+
for (let C = 0; C < b; C += 1)
|
|
1821
1824
|
p.add(String.fromCharCode(C));
|
|
1822
|
-
p.add(String.fromCharCode(
|
|
1823
|
-
const l =
|
|
1824
|
-
u.write(
|
|
1825
|
+
p.add(String.fromCharCode(b)), p.add(String.fromCharCode(m));
|
|
1826
|
+
const l = Ut(), u = c(l);
|
|
1827
|
+
u.write(b, f);
|
|
1825
1828
|
let g = 0, A = String.fromCharCode(o[g]);
|
|
1826
1829
|
for (g += 1; g < o.length; ) {
|
|
1827
1830
|
const C = String.fromCharCode(o[g]);
|
|
@@ -1830,14 +1833,14 @@ const P = {
|
|
|
1830
1833
|
return u.write(p.indexOf(A), f), u.write(m, f), u.flush(), l.toByteArray();
|
|
1831
1834
|
}, a = function() {
|
|
1832
1835
|
const y = {};
|
|
1833
|
-
let
|
|
1836
|
+
let b = 0;
|
|
1834
1837
|
const m = {};
|
|
1835
1838
|
return m.add = function(f) {
|
|
1836
1839
|
if (m.contains(f))
|
|
1837
1840
|
throw "dup key:" + f;
|
|
1838
|
-
y[f] =
|
|
1841
|
+
y[f] = b, b += 1;
|
|
1839
1842
|
}, m.size = function() {
|
|
1840
|
-
return
|
|
1843
|
+
return b;
|
|
1841
1844
|
}, m.indexOf = function(f) {
|
|
1842
1845
|
return y[f];
|
|
1843
1846
|
}, m.contains = function(f) {
|
|
@@ -1845,20 +1848,20 @@ const P = {
|
|
|
1845
1848
|
}, m;
|
|
1846
1849
|
};
|
|
1847
1850
|
return s;
|
|
1848
|
-
},
|
|
1849
|
-
const n =
|
|
1851
|
+
}, _e = function(t, e, r) {
|
|
1852
|
+
const n = Le(t, e);
|
|
1850
1853
|
for (let i = 0; i < e; i += 1)
|
|
1851
1854
|
for (let a = 0; a < t; a += 1)
|
|
1852
1855
|
n.setPixel(a, i, r(a, i));
|
|
1853
|
-
const o =
|
|
1856
|
+
const o = Ut();
|
|
1854
1857
|
n.write(o);
|
|
1855
|
-
const s =
|
|
1858
|
+
const s = xe(), c = o.toByteArray();
|
|
1856
1859
|
for (let i = 0; i < c.length; i += 1)
|
|
1857
1860
|
s.writeByte(c[i]);
|
|
1858
1861
|
return s.flush(), "data:image/gif;base64," + s;
|
|
1859
1862
|
};
|
|
1860
1863
|
V.stringToBytes;
|
|
1861
|
-
function
|
|
1864
|
+
function De(t) {
|
|
1862
1865
|
const e = V(0, "M"), r = Array.from(new TextEncoder().encode(t), (s) => String.fromCharCode(s)).join("");
|
|
1863
1866
|
e.addData(r, /^\d+$/.test(t) ? "Numeric" : "Byte"), e.make();
|
|
1864
1867
|
const n = e.getModuleCount();
|
|
@@ -1869,11 +1872,11 @@ function _e(t) {
|
|
|
1869
1872
|
class ut extends Error {
|
|
1870
1873
|
constructor(r) {
|
|
1871
1874
|
super(r[0]?.message || "题卡数据无效");
|
|
1872
|
-
|
|
1875
|
+
Tt(this, "issues");
|
|
1873
1876
|
this.name = "AnswerSheetDataError", this.issues = r;
|
|
1874
1877
|
}
|
|
1875
1878
|
}
|
|
1876
|
-
function
|
|
1879
|
+
function ke(t, e) {
|
|
1877
1880
|
const r = (l, u = "题卡数据结构无效") => {
|
|
1878
1881
|
throw new ut([{ code: "INVALID_DATA", path: l, message: u }]);
|
|
1879
1882
|
}, n = (l, u) => !l || typeof l != "object" || Array.isArray(l) ? r(u) : l, o = (l, u) => Array.isArray(l) ? l : r(u), s = (l, u) => {
|
|
@@ -1897,10 +1900,10 @@ function De(t, e) {
|
|
|
1897
1900
|
}, y = (l, u) => {
|
|
1898
1901
|
const g = n(l, u);
|
|
1899
1902
|
(!["row", "column"].includes(String(g.direction)) || !["concentrated", "distributed", "stem", "option"].includes(String(g.presentation)) || !["box", "check", "bubble"].includes(String(g.marker))) && r(u), c(g.rowsPerColumn, `${u}.rowsPerColumn`, 1, 5), c(g.rowGap, `${u}.rowGap`, 0, 64), c(g.columnGap, `${u}.columnGap`, 0, 64), o(g.questions, `${u}.questions`).forEach((A, C) => a(A, `${u}.questions.${C}`));
|
|
1900
|
-
},
|
|
1903
|
+
}, b = /* @__PURE__ */ new WeakSet(), m = (l, u) => {
|
|
1901
1904
|
if (!(!l || typeof l != "object")) {
|
|
1902
|
-
if (
|
|
1903
|
-
|
|
1905
|
+
if (b.has(l)) return r(u, "题卡必须是无循环引用的 JSON 数据");
|
|
1906
|
+
b.add(l), Object.entries(l).forEach(([g, A]) => m(A, `${u}.${g}`)), b.delete(l);
|
|
1904
1907
|
}
|
|
1905
1908
|
}, f = n(t, "");
|
|
1906
1909
|
if (f.version !== 1 && r("version", "不支持的题卡数据版本"), s(f.title, "title"), f.usage !== void 0 && !["exam", "homework"].includes(String(f.usage)) && r("usage"), ["questionCard", "scanMarking", "halfPoint", "mergeObjective"].forEach((l) => {
|
|
@@ -1941,32 +1944,32 @@ function De(t, e) {
|
|
|
1941
1944
|
r(`${g}.reference`, "请使用包含 reference 题目结构的制卡数据");
|
|
1942
1945
|
}
|
|
1943
1946
|
const C = n(A.reference, `${g}.reference`);
|
|
1944
|
-
C.material !== void 0 && i(C.material, `${g}.reference.material`), C.textVersion !== void 0 && C.textVersion !== 1 && r(`${g}.reference.textVersion`), Object.hasOwn(
|
|
1945
|
-
const
|
|
1946
|
-
Object.hasOwn(lt, String(O.type)) || r(`${
|
|
1947
|
+
C.material !== void 0 && i(C.material, `${g}.reference.material`), C.textVersion !== void 0 && C.textVersion !== 1 && r(`${g}.reference.textVersion`), Object.hasOwn(yt, String(C.type)) || r(`${g}.reference.type`), y(C.layout, `${g}.reference.layout`), c(C.optionalHeight, `${g}.reference.optionalHeight`), o(C.questions, `${g}.reference.questions`).forEach((x, M) => {
|
|
1948
|
+
const T = `${g}.reference.questions.${M}`, O = n(x, T);
|
|
1949
|
+
Object.hasOwn(lt, String(O.type)) || r(`${T}.type`), s(O.id, `${T}.id`), s(O.label, `${T}.label`), a(O.choice, `${T}.choice`), ["height", "contentHeight", "characters", "lines"].forEach((I) => c(O[I], `${T}.${I}`)), i(O.document, `${T}.document`);
|
|
1947
1950
|
const h = (I, d) => {
|
|
1948
1951
|
if (!I) return;
|
|
1949
|
-
const
|
|
1950
|
-
i(
|
|
1951
|
-
const N = n(
|
|
1952
|
+
const E = n(I, d);
|
|
1953
|
+
i(E.content, `${d}.content`), n(E.layout, `${d}.layout`), s(E.groupId, `${d}.groupId`), o(E.itemsContent, `${d}.itemsContent`).forEach((w, S) => {
|
|
1954
|
+
const N = n(w, `${d}.itemsContent.${S}`);
|
|
1952
1955
|
s(N.id, `${d}.itemsContent.${S}.id`), s(N.key, `${d}.itemsContent.${S}.key`), i(N.content, `${d}.itemsContent.${S}.content`);
|
|
1953
1956
|
});
|
|
1954
1957
|
};
|
|
1955
|
-
h(O.text, `${
|
|
1956
|
-
const
|
|
1957
|
-
s(
|
|
1958
|
+
h(O.text, `${T}.text`), o(O.parts, `${T}.parts`).forEach((I, d) => {
|
|
1959
|
+
const E = `${T}.parts.${d}`, w = n(I, E);
|
|
1960
|
+
s(w.id, `${E}.id`), s(w.label, `${E}.label`), c(w.width, `${E}.width`), c(w.height, `${E}.height`), i(w.document, `${E}.document`), a(w.choice, `${E}.choice`), h(w.text, `${E}.text`);
|
|
1958
1961
|
});
|
|
1959
1962
|
});
|
|
1960
1963
|
}), m(t, "");
|
|
1961
|
-
const p =
|
|
1964
|
+
const p = It(t);
|
|
1962
1965
|
(p.columnWidth < 100 || p.contentHeight < 100) && r("margin", "边距或栏间距过大,纸张没有足够的作答区域");
|
|
1963
1966
|
}
|
|
1964
1967
|
function rt(t) {
|
|
1965
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);
|
|
1966
1969
|
}
|
|
1967
|
-
function
|
|
1970
|
+
function Nn(t, e) {
|
|
1968
1971
|
try {
|
|
1969
|
-
|
|
1972
|
+
ke(t, e);
|
|
1970
1973
|
} catch (p) {
|
|
1971
1974
|
return { valid: !1, issues: p instanceof ut ? p.issues : [{ code: "INVALID_DATA", path: "", message: "题卡数据无法读取" }] };
|
|
1972
1975
|
}
|
|
@@ -1986,12 +1989,12 @@ function On(t, e) {
|
|
|
1986
1989
|
if (!p) o("MISSING_EXAM_ID", "creation.exampaperId", "显示试卷二维码需要填写试卷 ID");
|
|
1987
1990
|
else
|
|
1988
1991
|
try {
|
|
1989
|
-
|
|
1992
|
+
De(p);
|
|
1990
1993
|
} catch {
|
|
1991
1994
|
o("INVALID_QR_PAYLOAD", "creation.exampaperId", "试卷 ID 太长,无法生成二维码");
|
|
1992
1995
|
}
|
|
1993
1996
|
}
|
|
1994
|
-
t.header && t.recognition?.subjectMarkers !== !1 && !
|
|
1997
|
+
t.header && t.recognition?.subjectMarkers !== !1 && !Gt[Se(t.creation) || ""] && o("UNKNOWN_SUBJECT_MARK", "creation.subjectCode", "当前学科没有参考识别编码,请配置标准学科或关闭学科标记"), (!t.creation?.grade.trim() || !t.creation.subject.trim()) && o("MISSING_CREATION", "creation", "请选择年级和学科"), (!t.paperTitle || !rt(t.paperTitle.document.content)) && o("MISSING_PAPER_TITLE", "paperTitle", "请填写纸面标题"), t.blocks.some((p) => p.kind !== "area") || o("EMPTY_CARD", "blocks", "请至少添加一个题块和一道题目"), t.paperTitle && c(t.paperTitle.id, "paperTitle.id"), t.blocks.forEach((p, l) => {
|
|
1995
1998
|
n = { blockId: p.id };
|
|
1996
1999
|
const u = `blocks.${l}`;
|
|
1997
2000
|
if (c(p.id, `${u}.id`), p.kind === "area") {
|
|
@@ -2007,25 +2010,25 @@ function On(t, e) {
|
|
|
2007
2010
|
return;
|
|
2008
2011
|
}
|
|
2009
2012
|
g.questions.length || o("EMPTY_BLOCK", `${u}.reference.questions`, "题块中没有题目");
|
|
2010
|
-
const A =
|
|
2013
|
+
const A = bt(g);
|
|
2011
2014
|
if ((A.some((C) => !C.trim()) || new Set(A).size !== A.length) && o("INVALID_QUESTION_NUMBER", `${u}.reference.questions`, "同一题块内的题号须非空且不能重复"), g.optional && (g.type !== "SHORTANSWER" || !Number.isInteger(g.choose) || g.choose < 1 || g.choose >= g.questions.length) && o("INVALID_OPTIONAL", `${u}.reference.choose`, "选做题须为解答题,且选做数量小于总题数"), g.type === "CCOMPOSITION" && g.questions.length > 1 && o("INVALID_COUNT", `${u}.reference.questions`, "语文作文每组只能有一道题"), g.questions.forEach((C, x) => {
|
|
2012
2015
|
n = { blockId: p.id, questionId: C.id };
|
|
2013
|
-
const M = `${u}.reference.questions.${x}`,
|
|
2016
|
+
const M = `${u}.reference.questions.${x}`, T = lt[C.type];
|
|
2014
2017
|
c(C.id, `${M}.id`), g.type !== "MIXED" && g.type !== C.type && o("TYPE_MISMATCH", `${M}.type`, "题目类型与题块不一致"), C.choice.id !== C.id && o("INVALID_BINDING", `${M}.choice.id`, "题目与填涂项 ID 不一致");
|
|
2015
2018
|
const O = R(C.type) || ["FILLBLANK", "SHORTANSWER"].includes(C.type);
|
|
2016
|
-
(O && (C.parts.length < 1 || C.parts.length >
|
|
2019
|
+
(O && (C.parts.length < 1 || C.parts.length > T.parts) || !O && C.parts.length) && o("INVALID_PARTS", `${M}.parts`, `子题/空数须为 ${O ? `1–${T.parts}` : "0"}`), C.parts.length ? C.score !== jt(C.parts) && o("SCORE_MISMATCH", `${M}.score`, "总分与子题分值之和不一致") : i(C.score, T.score, `${M}.score`), Y(C.type) && !R(C.type) && a(C.choice, T.options, `${M}.choice`), C.type === "INFO_MATCHING" && (a(C.choice, T.options, `${M}.choice`), C.parts.length > C.choice.options.length && o("INVALID_OPTIONS", `${M}.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)) && o("INVALID_LESS_SCORE", `${M}.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)) && o("INVALID_CHUNK_SCORE", M, "请检查正确答案个数及每处得分"), C.type === "CCOMPOSITION" && (!Number.isInteger(C.characters) || C.characters < 1 || C.characters > 1200) && o("INVALID_GRID_COUNT", `${M}.characters`, "作文格数须为 1–1200"), C.type === "ECOMPOSITION" && (!Number.isInteger(C.lines) || C.lines < 1 || C.lines > 100) && o("INVALID_LINE_COUNT", `${M}.lines`, "作文行数须为 1–100"), t.questionCard && y(C.text, `${M}.text`, ["SCHOICE", "MCHOICE"].includes(C.type), C.choice.options.length), C.parts.forEach((h, I) => {
|
|
2017
2020
|
const d = `${M}.parts.${I}`;
|
|
2018
|
-
n = { blockId: p.id, questionId: h.id }, c(h.id, `${d}.id`), i(h.score,
|
|
2021
|
+
n = { blockId: p.id, questionId: h.id }, c(h.id, `${d}.id`), i(h.score, T.score, `${d}.score`), R(C.type) && Y(C.type) && (a(h.choice, T.options, `${d}.choice`), h.choice.id !== h.id && o("INVALID_BINDING", `${d}.choice.id`, "子题与填涂项 ID 不一致")), t.questionCard && ["CLOZE", "READTHENANSWER"].includes(C.type) && y(h.text, `${d}.text`, !0, h.choice.options.length, C.type === "READTHENANSWER");
|
|
2019
2022
|
});
|
|
2020
2023
|
}), n = { blockId: p.id }, t.questionCard && g.layout.presentation !== "concentrated") {
|
|
2021
|
-
const C = g.questions.filter((M) => Y(M.type)).flatMap((M) => R(M.type) ? M.parts.map((
|
|
2022
|
-
|
|
2024
|
+
const C = g.questions.filter((M) => Y(M.type)).flatMap((M) => R(M.type) ? M.parts.map((T) => T.choice) : [M.choice]);
|
|
2025
|
+
qt({ ...g.layout, questions: C }, p.document, !0).concentrated.questions.length && o("MISSING_FILL_TARGET", `${u}.reference.layout.presentation`, "部分填涂框没有对应的题干或选项位置");
|
|
2023
2026
|
}
|
|
2024
2027
|
}), n = {};
|
|
2025
|
-
const
|
|
2026
|
-
p.type === "image" && (!p.attrs?.src || /^blob:/i.test(p.attrs.src)) && o("INVALID_IMAGE_URL", l, "图片缺少可保存的地址,请上传后使用持久 URL 或内嵌图片"), ["formula", "blockFormula"].includes(p.type || "") && !String(p.attrs?.latex || "").trim() && o("EMPTY_FORMULA", l, "请填写公式或删除空公式"), p.content?.forEach((u, g) =>
|
|
2028
|
+
const b = (p, l) => {
|
|
2029
|
+
p.type === "image" && (!p.attrs?.src || /^blob:/i.test(p.attrs.src)) && o("INVALID_IMAGE_URL", l, "图片缺少可保存的地址,请上传后使用持久 URL 或内嵌图片"), ["formula", "blockFormula"].includes(p.type || "") && !String(p.attrs?.latex || "").trim() && o("EMPTY_FORMULA", l, "请填写公式或删除空公式"), p.content?.forEach((u, g) => b(u, `${l}.content.${g}`));
|
|
2027
2030
|
}, m = (p, l) => {
|
|
2028
|
-
p &&
|
|
2031
|
+
p && b(p.content, `${l}.content`);
|
|
2029
2032
|
}, f = (p, l) => {
|
|
2030
2033
|
m(p?.content, `${l}.content`), p?.itemsContent.forEach((u, g) => m(u.content, `${l}.itemsContent.${g}.content`));
|
|
2031
2034
|
};
|
|
@@ -2041,81 +2044,81 @@ function On(t, e) {
|
|
|
2041
2044
|
});
|
|
2042
2045
|
}), { valid: r.length === 0, issues: r };
|
|
2043
2046
|
}
|
|
2044
|
-
function
|
|
2047
|
+
function mt(t) {
|
|
2045
2048
|
if (t !== void 0)
|
|
2046
2049
|
try {
|
|
2047
|
-
const e =
|
|
2050
|
+
const e = _t(t);
|
|
2048
2051
|
return { grades: e.grades, gradeCourseMap: e.gradeCourseMap, defaultGradeCode: e.defaultGradeCode || void 0, defaultCourseCode: e.defaultCourseCode || void 0 };
|
|
2049
2052
|
} catch (e) {
|
|
2050
|
-
throw e instanceof
|
|
2053
|
+
throw e instanceof Ct ? new ut([{ code: "INVALID_DICTIONARIES", path: e.path, message: e.message }]) : e;
|
|
2051
2054
|
}
|
|
2052
2055
|
}
|
|
2053
|
-
function
|
|
2054
|
-
const r = (
|
|
2055
|
-
throw new ut([{ code: "INVALID_INITIALIZATION", path:
|
|
2056
|
-
}, n = (
|
|
2057
|
-
if (!
|
|
2058
|
-
const I = Object.entries(
|
|
2056
|
+
function Pe(t, e) {
|
|
2057
|
+
const r = (T, O) => {
|
|
2058
|
+
throw new ut([{ code: "INVALID_INITIALIZATION", path: T, message: O }]);
|
|
2059
|
+
}, n = (T, O, h) => {
|
|
2060
|
+
if (!T || typeof T != "object" || Array.isArray(T)) return r(O, "初始化配置必须是对象");
|
|
2061
|
+
const I = Object.entries(T);
|
|
2059
2062
|
for (const [d] of I) h.includes(d) || r(`${O}.${d}`, "不支持的初始化字段");
|
|
2060
2063
|
return Object.fromEntries(I.filter(([, d]) => d !== void 0));
|
|
2061
|
-
}, o = (
|
|
2062
|
-
|
|
2063
|
-
}, c = (
|
|
2064
|
-
|
|
2065
|
-
}, i = (
|
|
2066
|
-
|
|
2064
|
+
}, o = (T, O) => typeof T != "string" || !T.trim() ? r(O, "请提供非空的试卷名称、年级和学科") : T.trim(), s = (T, O, h) => {
|
|
2065
|
+
T !== void 0 && !h.includes(T) && r(O, `可选值为 ${h.join("、")}`);
|
|
2066
|
+
}, c = (T, O) => {
|
|
2067
|
+
T !== void 0 && typeof T != "boolean" && r(O, "请使用布尔值");
|
|
2068
|
+
}, i = (T, O, h, I) => {
|
|
2069
|
+
T !== void 0 && (typeof T != "number" || !Number.isFinite(T) || T < h || T > I) && r(O, `数值必须在 ${h}–${I} 之间`);
|
|
2067
2070
|
}, a = n(t, "initialization", ["name", "grade", "subject", "gradeCode", "courseCode", "subjectCode", "mode", "id", "exampaperId", "createMode", "layout", "header", "recognition"]), y = o(a.name, "initialization.name");
|
|
2068
2071
|
y.length > 30 && r("initialization.name", "试卷名称最多 30 个字符");
|
|
2069
|
-
const
|
|
2072
|
+
const b = _t(mt(e)), m = a.gradeCode !== void 0 || a.courseCode !== void 0 || a.subjectCode !== void 0;
|
|
2070
2073
|
let f;
|
|
2071
2074
|
if (m) {
|
|
2072
2075
|
try {
|
|
2073
|
-
f =
|
|
2074
|
-
} catch (
|
|
2075
|
-
if (
|
|
2076
|
-
throw
|
|
2076
|
+
f = ht(b, o(a.gradeCode, "initialization.gradeCode"), o(a.courseCode, "initialization.courseCode"));
|
|
2077
|
+
} catch (T) {
|
|
2078
|
+
if (T instanceof Ct) return r(T.path, T.message);
|
|
2079
|
+
throw T;
|
|
2077
2080
|
}
|
|
2078
|
-
for (const
|
|
2081
|
+
for (const T of ["grade", "subject", "subjectCode"]) a[T] !== void 0 && o(a[T], `initialization.${T}`) !== f[T] && r(`initialization.${T}`, "名称或学科编码与课程字典不一致");
|
|
2079
2082
|
} else {
|
|
2080
|
-
const
|
|
2083
|
+
const T = o(a.grade, "initialization.grade"), O = o(a.subject, "initialization.subject"), h = b.grades.filter((E) => E.label === T);
|
|
2081
2084
|
h.length > 1 && r("initialization.grade", "同名年级不唯一,请使用 gradeCode");
|
|
2082
|
-
const I = h[0], d = I ?
|
|
2083
|
-
d.length > 1 && r("initialization.subject", "同名课程不唯一,请使用 courseCode"), e && (!I || !d.length) && r(I ? "initialization.subject" : "initialization.grade", "名称不在可用字典中,请使用年级和课程编码"), f = I && d.length ?
|
|
2085
|
+
const I = h[0], d = I ? b.gradeCourseMap[I.value].filter((E) => E.label === O) : [];
|
|
2086
|
+
d.length > 1 && r("initialization.subject", "同名课程不唯一,请使用 courseCode"), e && (!I || !d.length) && r(I ? "initialization.subject" : "initialization.grade", "名称不在可用字典中,请使用年级和课程编码"), f = I && d.length ? ht(b, I.value, d[0].value) : { grade: T, subject: O };
|
|
2084
2087
|
}
|
|
2085
2088
|
s(a.mode, "initialization.mode", ["template", "exam"]), s(a.createMode, "initialization.createMode", ["MANUALLY", "IMPORTED", "THIRD"]);
|
|
2086
2089
|
const p = {};
|
|
2087
|
-
for (const
|
|
2088
|
-
const O = a[
|
|
2089
|
-
typeof O == "string" ? p[
|
|
2090
|
+
for (const T of ["id", "exampaperId"]) if (a[T] !== void 0) {
|
|
2091
|
+
const O = a[T];
|
|
2092
|
+
typeof O == "string" ? p[T] = o(O, `initialization.${T}`) : typeof O == "number" && Number.isSafeInteger(O) && O >= 0 ? p[T] = O : r(`initialization.${T}`, "ID 必须是非空字符串或非负安全整数");
|
|
2090
2093
|
}
|
|
2091
2094
|
a.createMode !== void 0 && (p.createMode = a.createMode);
|
|
2092
|
-
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 = (
|
|
2093
|
-
l[
|
|
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 = (T, O, h) => {
|
|
2096
|
+
l[T] !== void 0 && (l[O] !== void 0 && l[O] !== h && r(`initialization.layout.${T}`, `与 ${O} 设置冲突`), l[O] = h, delete l[T]);
|
|
2094
2097
|
};
|
|
2095
2098
|
l.pageNum !== void 0 && ![1, 2, 3].includes(l.pageNum) && r("initialization.layout.pageNum", "分栏数为 1、2 或 3"), u("pageNum", "preset", { 1: "a4", 2: "a3-two", 3: "a3-three" }[l.pageNum]);
|
|
2096
|
-
for (const [
|
|
2097
|
-
c(l[
|
|
2099
|
+
for (const [T, O] of [["quesCard", "questionCard"], ["scoreType", "halfPoint"], ["mixOb", "mergeObjective"], ["choiceType", "choiceDirection"]])
|
|
2100
|
+
c(l[T], `initialization.layout.${T}`), u(T, O, T === "choiceType" ? l[T] ? "column" : "row" : l[T]);
|
|
2098
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);
|
|
2099
|
-
for (const
|
|
2102
|
+
for (const T of ["questionCard", "scanMarking", "halfPoint", "mergeObjective"]) c(l[T], `initialization.layout.${T}`);
|
|
2100
2103
|
const g = a.header === void 0 ? {} : n(a.header, "initialization.header", ["focusText", "writeKaohao", "missExam", "mifeng", "kaohao", "weishu", "tiaomaStyle", "classText"]);
|
|
2101
|
-
for (const
|
|
2104
|
+
for (const T of ["focusText", "writeKaohao", "missExam", "mifeng", "classText"]) c(g[T], `initialization.header.${T}`);
|
|
2102
2105
|
g.tiaomaStyle !== void 0 && ![1, 2].includes(g.tiaomaStyle) && r("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) && r("initialization.header.weishu", "考号位数必须是整数");
|
|
2103
|
-
const A =
|
|
2104
|
-
if (C) for (const
|
|
2105
|
-
const x = { ...A, ...l, header: { ...A.header, ...g }, ...C ? { recognition: C } : {} }, M =
|
|
2106
|
+
const A = le({ name: y, ...f, ...p, mode: a.mode ?? "template" }), C = a.recognition === void 0 ? void 0 : n(a.recognition, "initialization.recognition", ["examQrCode", "subjectMarkers", "pointBlack"]);
|
|
2107
|
+
if (C) for (const T of ["examQrCode", "subjectMarkers", "pointBlack"]) c(C[T], `initialization.recognition.${T}`);
|
|
2108
|
+
const x = { ...A, ...l, header: { ...A.header, ...g }, ...C ? { recognition: C } : {} }, M = It(x);
|
|
2106
2109
|
return (M.columnWidth < 100 || M.contentHeight < 100) && r("initialization.layout", "边距或栏间距过大,纸张没有足够的作答区域"), x;
|
|
2107
2110
|
}
|
|
2108
|
-
function
|
|
2111
|
+
function Mn(t, e) {
|
|
2109
2112
|
if (typeof document > "u") throw new Error("请在浏览器挂载后创建制卡实例");
|
|
2110
|
-
const r =
|
|
2113
|
+
const r = zt(e?.plugins || []), n = mt(e.dictionaries), o = typeof t == "string" ? document.querySelector(t) : t;
|
|
2111
2114
|
if (!(o instanceof HTMLElement) || o.ownerDocument !== document || /^(INPUT|TEXTAREA|SELECT|BUTTON|IMG|CANVAS|IFRAME)$/.test(o.tagName)) throw new Error("制卡需要一个空的 HTML 容器,例如 div");
|
|
2112
2115
|
if (document.querySelector("[data-uni-answer-sheet-mount], #uni-answer-sheet")) throw new Error("当前文档已挂载制卡工作区;切换容器前请先 destroy()");
|
|
2113
2116
|
if (o.textContent?.trim() || o.children.length) throw new Error("请提供空容器,已有题卡请通过 initialValue 传入");
|
|
2114
2117
|
const s = document.createElement("div");
|
|
2115
2118
|
s.className = "uni-answer-sheet-host", s.dataset.uniAnswerSheetMount = "", s.style.height = "100%", o.append(s);
|
|
2116
|
-
let c = !1, i = { ...e, dictionaries: n }, a, y,
|
|
2119
|
+
let c = !1, i = { ...e, dictionaries: n }, a, y, b;
|
|
2117
2120
|
const m = new Promise((u, g) => {
|
|
2118
|
-
y = u,
|
|
2121
|
+
y = u, b = g;
|
|
2119
2122
|
});
|
|
2120
2123
|
m.catch(() => {
|
|
2121
2124
|
});
|
|
@@ -2127,7 +2130,7 @@ function Nn(t, e) {
|
|
|
2127
2130
|
ready: m,
|
|
2128
2131
|
async initialize(u) {
|
|
2129
2132
|
if (c) throw new Error("制卡实例已销毁");
|
|
2130
|
-
const g =
|
|
2133
|
+
const g = Pe(u, i.dictionaries);
|
|
2131
2134
|
a || (i = { ...i, initialValue: g }), await (await p()).setDocument(g);
|
|
2132
2135
|
},
|
|
2133
2136
|
getDocument: () => f().getDocument(),
|
|
@@ -2142,115 +2145,116 @@ function Nn(t, e) {
|
|
|
2142
2145
|
focusIssue: (u) => f().focusIssue(u),
|
|
2143
2146
|
setOptions(u) {
|
|
2144
2147
|
if (c) throw new Error("制卡实例已销毁");
|
|
2145
|
-
const g = Object.hasOwn(u, "dictionaries") ?
|
|
2148
|
+
const g = Object.hasOwn(u, "dictionaries") ? mt(u.dictionaries) : i.dictionaries;
|
|
2146
2149
|
i = { ...i, ...u, dictionaries: g }, a?.update(i);
|
|
2147
2150
|
},
|
|
2148
2151
|
destroy() {
|
|
2149
|
-
c || (c = !0, a?.destroy(), s.remove(),
|
|
2152
|
+
c || (c = !0, a?.destroy(), s.remove(), b(new DOMException("制卡实例已销毁", "AbortError")));
|
|
2150
2153
|
}
|
|
2151
2154
|
};
|
|
2152
|
-
return Promise.all([r.prepare(), import("./runtime-
|
|
2155
|
+
return Promise.all([r.prepare(), import("./runtime-QFMZtUfH.js")]).then(([, { mountAnswerSheet: u }]) => {
|
|
2153
2156
|
c || (a = u(s, r, i, y, (g) => {
|
|
2154
|
-
|
|
2157
|
+
b(g), l.destroy(), i.onError?.(g instanceof Error ? g : new Error(String(g)));
|
|
2155
2158
|
}));
|
|
2156
2159
|
}).catch((u) => {
|
|
2157
|
-
|
|
2160
|
+
b(u), l.destroy(), i.onError?.(u instanceof Error ? u : new Error(String(u)));
|
|
2158
2161
|
}), l;
|
|
2159
2162
|
}
|
|
2160
2163
|
export {
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2164
|
+
Ze as $,
|
|
2165
|
+
On as A,
|
|
2166
|
+
dt as B,
|
|
2167
|
+
An as C,
|
|
2168
|
+
_t as D,
|
|
2169
|
+
ce as E,
|
|
2170
|
+
fn as F,
|
|
2171
|
+
ln as G,
|
|
2172
|
+
et as H,
|
|
2173
|
+
In as I,
|
|
2174
|
+
le as J,
|
|
2175
|
+
un as K,
|
|
2176
|
+
v as L,
|
|
2177
|
+
W as M,
|
|
2178
|
+
Ke as N,
|
|
2179
|
+
ze as O,
|
|
2180
|
+
Zt as P,
|
|
2181
|
+
$t as Q,
|
|
2182
|
+
Xt as R,
|
|
2183
|
+
kt as S,
|
|
2184
|
+
ve as T,
|
|
2185
|
+
Ue as U,
|
|
2186
|
+
at as V,
|
|
2184
2187
|
je as W,
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2188
|
+
Ge as X,
|
|
2189
|
+
St as Y,
|
|
2190
|
+
Fe as Z,
|
|
2191
|
+
tn as _,
|
|
2192
|
+
be as a,
|
|
2193
|
+
re as a0,
|
|
2194
|
+
on as a1,
|
|
2192
2195
|
en as a2,
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2196
|
+
nn as a3,
|
|
2197
|
+
rn as a4,
|
|
2198
|
+
Xe as a5,
|
|
2199
|
+
oe as a6,
|
|
2197
2200
|
ie as a7,
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
+
se as a8,
|
|
2202
|
+
Ve as a9,
|
|
2203
|
+
Sn as aA,
|
|
2201
2204
|
De as aB,
|
|
2202
|
-
|
|
2203
|
-
|
|
2205
|
+
ke as aC,
|
|
2206
|
+
ut as aD,
|
|
2204
2207
|
Nn as aE,
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2208
|
+
Mn as aF,
|
|
2209
|
+
Je as aa,
|
|
2210
|
+
te as ab,
|
|
2211
|
+
sn as ac,
|
|
2212
|
+
qe as ad,
|
|
2213
|
+
Qe as ae,
|
|
2214
|
+
lt as af,
|
|
2215
|
+
Ht as ag,
|
|
2216
|
+
mn as ah,
|
|
2217
|
+
bn as ai,
|
|
2218
|
+
gn as aj,
|
|
2219
|
+
Cn as ak,
|
|
2220
|
+
wn as al,
|
|
2221
|
+
pt as am,
|
|
2222
|
+
cn as an,
|
|
2223
|
+
Ye as ao,
|
|
2224
|
+
Be as ap,
|
|
2225
|
+
ht as aq,
|
|
2226
|
+
ue as ar,
|
|
2227
|
+
We as as,
|
|
2228
|
+
he as at,
|
|
2229
|
+
En as au,
|
|
2230
|
+
Tn as av,
|
|
2231
|
+
an as aw,
|
|
2232
|
+
it as ax,
|
|
2233
|
+
Se as ay,
|
|
2234
|
+
Gt as az,
|
|
2235
|
+
pn as b,
|
|
2236
|
+
Ie as c,
|
|
2237
|
+
Bt as d,
|
|
2238
|
+
ye as e,
|
|
2239
|
+
gt as f,
|
|
2236
2240
|
Y as g,
|
|
2237
|
-
|
|
2241
|
+
yn as h,
|
|
2238
2242
|
R as i,
|
|
2239
2243
|
j,
|
|
2240
|
-
|
|
2241
|
-
|
|
2244
|
+
dn as k,
|
|
2245
|
+
Pt as l,
|
|
2242
2246
|
Q as m,
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2247
|
+
At as n,
|
|
2248
|
+
hn as o,
|
|
2249
|
+
ge as p,
|
|
2250
|
+
yt as q,
|
|
2251
|
+
qt as r,
|
|
2252
|
+
jt as s,
|
|
2249
2253
|
J as t,
|
|
2250
2254
|
st as u,
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2255
|
+
Rt as v,
|
|
2256
|
+
pe as w,
|
|
2257
|
+
Nt as x,
|
|
2254
2258
|
Z as y,
|
|
2255
2259
|
nt as z
|
|
2256
2260
|
};
|