@nakafa/aksara-contracts 0.43.0 → 0.45.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.
Files changed (77) hide show
  1. package/README.md +22 -1
  2. package/dist/math/resolution.js +1 -1
  3. package/dist/math/scene.js +1 -1
  4. package/dist/preview/artifact.d.ts +44 -0
  5. package/dist/preview/document.d.ts +36 -12
  6. package/dist/preview/spec.d.ts +196 -36
  7. package/dist/preview/target.d.ts +10 -3
  8. package/dist/program/snapshot/digest.d.ts +1 -1
  9. package/dist/program/snapshot/digest.js +1 -1
  10. package/dist/program/snapshot/hash.d.ts +153 -0
  11. package/dist/program/snapshot/hash.js +31 -0
  12. package/dist/projection/digest.d.ts +74 -22
  13. package/dist/projection/material.d.ts +10 -0
  14. package/dist/projection/material.js +15 -0
  15. package/dist/projection/question.d.ts +188 -0
  16. package/dist/projection/spec.d.ts +45 -0
  17. package/dist/projection/verify.d.ts +127 -75
  18. package/dist/question/answer.d.ts +149 -0
  19. package/dist/question/answer.js +248 -0
  20. package/dist/question/item.d.ts +276 -1
  21. package/dist/question/item.js +63 -38
  22. package/dist/question/label.d.ts +3 -0
  23. package/dist/question/label.js +3 -0
  24. package/dist/question/points.d.ts +18 -0
  25. package/dist/question/points.js +22 -0
  26. package/dist/question/response.d.ts +187 -5
  27. package/dist/question/response.js +41 -4
  28. package/dist/question/rubric.d.ts +234 -0
  29. package/dist/question/rubric.js +182 -0
  30. package/dist/release/rollback/spec.d.ts +264 -0
  31. package/dist/release/snapshot/data.d.ts +52 -3
  32. package/dist/release/snapshot/{program-evidence.d.ts → evidence/program.d.ts} +2 -2
  33. package/dist/release/snapshot/{program-evidence.js → evidence/program.js} +1 -1
  34. package/dist/release/snapshot/{quran-evidence.d.ts → evidence/quran.d.ts} +2 -2
  35. package/dist/release/snapshot/{quran-evidence.js → evidence/quran.js} +1 -1
  36. package/dist/release/snapshot/{tryout-evidence.d.ts → evidence/tryout.d.ts} +2 -2
  37. package/dist/release/snapshot/{tryout-evidence.js → evidence/tryout.js} +4 -4
  38. package/dist/release/snapshot/evidence.d.ts +2 -2
  39. package/dist/release/snapshot/evidence.js +3 -3
  40. package/dist/release/snapshot/verify.d.ts +88 -31
  41. package/dist/runtime/spec.d.ts +25 -22
  42. package/dist/runtime/verify.d.ts +46 -44
  43. package/dist/transport/batch.d.ts +88 -0
  44. package/dist/transport/group.d.ts +288 -9
  45. package/dist/transport/request.d.ts +1858 -1018
  46. package/dist/transport/response.d.ts +499 -131
  47. package/dist/transport/snapshot.d.ts +104 -6
  48. package/dist/tryout/catalog.d.ts +28 -10
  49. package/dist/tryout/catalog.js +6 -2
  50. package/dist/tryout/closure/accounting.d.ts +16 -0
  51. package/dist/tryout/closure/accounting.js +68 -0
  52. package/dist/tryout/closure/locale.d.ts +14 -0
  53. package/dist/tryout/{locale-closure.js → closure/locale.js} +13 -72
  54. package/dist/tryout/{placement-closure.js → closure/placement.js} +1 -0
  55. package/dist/tryout/{catalog-hash.d.ts → hash/catalog.d.ts} +25 -20
  56. package/dist/tryout/{catalog-hash.js → hash/catalog.js} +8 -1
  57. package/dist/tryout/{content-hash.d.ts → hash/content.d.ts} +43 -0
  58. package/dist/tryout/{placement-hash.d.ts → hash/placement.d.ts} +1 -1
  59. package/dist/tryout/{placement-hash.js → hash/placement.js} +2 -1
  60. package/dist/tryout/placement.d.ts +136 -1
  61. package/dist/tryout/placement.js +16 -2
  62. package/dist/tryout/scoring.d.ts +37 -0
  63. package/dist/tryout/scoring.js +89 -0
  64. package/dist/tryout/spec.d.ts +32 -4
  65. package/dist/tryout/spec.js +35 -4
  66. package/package.json +28 -20
  67. package/dist/program/snapshot/row-hash.d.ts +0 -155
  68. package/dist/program/snapshot/row-hash.js +0 -34
  69. package/dist/tryout/locale-closure.d.ts +0 -20
  70. /package/dist/math/{arc-precision.d.ts → arc.d.ts} +0 -0
  71. /package/dist/math/{arc-precision.js → arc.js} +0 -0
  72. /package/dist/release/snapshot/{evidence-requirement.d.ts → evidence/requirement.d.ts} +0 -0
  73. /package/dist/release/snapshot/{evidence-requirement.js → evidence/requirement.js} +0 -0
  74. /package/dist/tryout/{placement-closure.d.ts → closure/placement.d.ts} +0 -0
  75. /package/dist/tryout/{row-hash.d.ts → digest.d.ts} +0 -0
  76. /package/dist/tryout/{row-hash.js → digest.js} +0 -0
  77. /package/dist/tryout/{content-hash.js → hash/content.js} +0 -0
@@ -0,0 +1,234 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * One learner-facing rubric label written for every active app locale. A
4
+ * learner reads it after the attempt in the app locale, even when the prompt
5
+ * is delivered in a fixed assessed language, so every rubric copy carries all
6
+ * locales.
7
+ */
8
+ export declare const QuestionRubricLabelSchema: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>;
9
+ export type QuestionRubricLabel = typeof QuestionRubricLabelSchema.Type;
10
+ /**
11
+ * Locale-neutral rubric scale that grading reads: ordered criteria with
12
+ * stable keys, ordered levels with points, and optional final-answer keys. It
13
+ * ignores labels, so content written in one language, such as a School
14
+ * tenant's rubric, validates its scale here and owns its own labels. A judged
15
+ * criterion maps onto one Effect `Decision.rate` decision keyed by
16
+ * `criterionKey`: its level keys are the rating scale from lowest to highest,
17
+ * a rating answer's probabilities are keyed by them, and the chosen level's
18
+ * points are earned. A final-answer criterion is graded with
19
+ * `matchesAnswerKey` instead: a match earns its upper level and any other
20
+ * answer its zero level. A blank answer earns zero on every criterion.
21
+ */
22
+ export declare const QuestionRubricScaleSchema: Schema.Struct<{
23
+ readonly criteria: Schema.$Array<Schema.Struct<{
24
+ readonly criterionKey: Schema.String;
25
+ readonly finalAnswer: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
26
+ readonly acceptsFractions: Schema.Boolean;
27
+ readonly kind: Schema.Literal<"number">;
28
+ readonly tolerance: Schema.optionalKey<Schema.Struct<{
29
+ readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
30
+ readonly value: Schema.String;
31
+ }>>;
32
+ readonly value: Schema.String;
33
+ }>, Schema.Struct<{
34
+ readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
35
+ readonly collapseWhitespace: Schema.Boolean;
36
+ readonly ignoreCase: Schema.Boolean;
37
+ readonly kind: Schema.Literal<"text">;
38
+ }>]>>;
39
+ readonly order: Schema.Int;
40
+ readonly levels: Schema.$Array<Schema.Struct<{
41
+ levelKey: Schema.String;
42
+ order: Schema.Int;
43
+ points: Schema.Int;
44
+ }>>;
45
+ }>>;
46
+ readonly kind: Schema.Literal<"rubric">;
47
+ }>;
48
+ export type QuestionRubricScale = typeof QuestionRubricScaleSchema.Type;
49
+ /**
50
+ * Frozen open-response rubric of Aksara content: the rubric scale with every
51
+ * criterion and level labeled in every active app locale.
52
+ */
53
+ export declare const QuestionRubricResponseSchema: Schema.Struct<{
54
+ readonly criteria: Schema.$Array<Schema.Struct<{
55
+ readonly criterionKey: Schema.String;
56
+ readonly finalAnswer: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
57
+ readonly acceptsFractions: Schema.Boolean;
58
+ readonly kind: Schema.Literal<"number">;
59
+ readonly tolerance: Schema.optionalKey<Schema.Struct<{
60
+ readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
61
+ readonly value: Schema.String;
62
+ }>>;
63
+ readonly value: Schema.String;
64
+ }>, Schema.Struct<{
65
+ readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
66
+ readonly collapseWhitespace: Schema.Boolean;
67
+ readonly ignoreCase: Schema.Boolean;
68
+ readonly kind: Schema.Literal<"text">;
69
+ }>]>>;
70
+ readonly order: Schema.Int;
71
+ readonly label: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>;
72
+ readonly levels: Schema.$Array<Schema.Struct<{
73
+ readonly levelKey: Schema.String;
74
+ readonly order: Schema.Int;
75
+ readonly points: Schema.Int;
76
+ readonly label: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>;
77
+ }>>;
78
+ }>>;
79
+ readonly kind: Schema.Literal<"rubric">;
80
+ }>;
81
+ export type QuestionRubricResponse = typeof QuestionRubricResponseSchema.Type;
82
+ /** One rubric authored in array order without duplicated runtime keys. */
83
+ export declare const QuestionRubricResponseSourceSchema: Schema.Struct<{
84
+ readonly criteria: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
85
+ readonly finalAnswer: Schema.mutableKey<Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
86
+ readonly acceptsFractions: Schema.Boolean;
87
+ readonly kind: Schema.Literal<"number">;
88
+ readonly tolerance: Schema.optionalKey<Schema.Struct<{
89
+ readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
90
+ readonly value: Schema.String;
91
+ }>>;
92
+ readonly value: Schema.String;
93
+ }>, Schema.Struct<{
94
+ readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
95
+ readonly collapseWhitespace: Schema.Boolean;
96
+ readonly ignoreCase: Schema.Boolean;
97
+ readonly kind: Schema.Literal<"text">;
98
+ }>]>>>;
99
+ readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
100
+ readonly levels: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
101
+ readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
102
+ readonly points: Schema.mutableKey<Schema.Int>;
103
+ }>>>>;
104
+ }>>>>;
105
+ readonly kind: Schema.mutableKey<Schema.Literal<"rubric">>;
106
+ }>;
107
+ export type QuestionRubricResponseSource = typeof QuestionRubricResponseSourceSchema.Type;
108
+ /** Derives stable criterion and level keys once from authored array order. */
109
+ export declare function freezeQuestionRubric(source: QuestionRubricResponseSource): {
110
+ readonly criteria: readonly {
111
+ readonly criterionKey: string;
112
+ readonly finalAnswer?: {
113
+ readonly acceptsFractions: boolean;
114
+ readonly kind: "number";
115
+ readonly tolerance?: {
116
+ readonly kind: "absolute" | "relative";
117
+ readonly value: string;
118
+ };
119
+ readonly value: string;
120
+ } | {
121
+ readonly acceptedAnswers: readonly [string, ...string[]];
122
+ readonly collapseWhitespace: boolean;
123
+ readonly ignoreCase: boolean;
124
+ readonly kind: "text";
125
+ };
126
+ readonly order: number;
127
+ readonly label: {
128
+ readonly de: string;
129
+ readonly en: string;
130
+ readonly id: string;
131
+ };
132
+ readonly levels: readonly {
133
+ readonly levelKey: string;
134
+ readonly order: number;
135
+ readonly points: number;
136
+ readonly label: {
137
+ readonly de: string;
138
+ readonly en: string;
139
+ readonly id: string;
140
+ };
141
+ }[];
142
+ }[];
143
+ readonly kind: "rubric";
144
+ };
145
+ /**
146
+ * Returns the rubric facts shared by every delivery language: keys, order,
147
+ * points, labels in every active app locale, and final-answer rules without
148
+ * accepted text written in one delivery language.
149
+ */
150
+ export declare function canonicalQuestionRubricStructure(rubric: QuestionRubricResponse): {
151
+ criteria: {
152
+ criterionKey: string;
153
+ finalAnswer?: {
154
+ acceptedAnswers: [string, ...string[]];
155
+ collapseWhitespace: boolean;
156
+ ignoreCase: boolean;
157
+ kind: "text";
158
+ } | {
159
+ acceptedAnswers?: never;
160
+ collapseWhitespace?: never;
161
+ ignoreCase?: never;
162
+ acceptsFractions: boolean;
163
+ kind: "number";
164
+ tolerance?: {
165
+ kind: "absolute" | "relative";
166
+ value: string;
167
+ };
168
+ value: string;
169
+ } | {
170
+ collapseWhitespace: boolean;
171
+ ignoreCase: boolean;
172
+ kind: "text";
173
+ };
174
+ label: {
175
+ readonly de: string;
176
+ readonly en: string;
177
+ readonly id: string;
178
+ };
179
+ levels: {
180
+ label: {
181
+ readonly de: string;
182
+ readonly en: string;
183
+ readonly id: string;
184
+ };
185
+ levelKey: string;
186
+ order: number;
187
+ points: number;
188
+ }[];
189
+ order: number;
190
+ }[];
191
+ kind: "rubric";
192
+ };
193
+ /** Returns every rubric fact, accepted final-answer text included. */
194
+ export declare function canonicalQuestionRubric(rubric: QuestionRubricResponse): {
195
+ criteria: {
196
+ criterionKey: string;
197
+ finalAnswer?: {
198
+ acceptedAnswers: [string, ...string[]];
199
+ collapseWhitespace: boolean;
200
+ ignoreCase: boolean;
201
+ kind: "text";
202
+ } | {
203
+ acceptedAnswers?: never;
204
+ collapseWhitespace?: never;
205
+ ignoreCase?: never;
206
+ acceptsFractions: boolean;
207
+ kind: "number";
208
+ tolerance?: {
209
+ kind: "absolute" | "relative";
210
+ value: string;
211
+ };
212
+ value: string;
213
+ };
214
+ label: {
215
+ readonly de: string;
216
+ readonly en: string;
217
+ readonly id: string;
218
+ };
219
+ levels: {
220
+ label: {
221
+ readonly de: string;
222
+ readonly en: string;
223
+ readonly id: string;
224
+ };
225
+ levelKey: string;
226
+ order: number;
227
+ points: number;
228
+ }[];
229
+ order: number;
230
+ }[];
231
+ kind: "rubric";
232
+ };
233
+ /** Returns the rubric total: the sum of every criterion's highest level. */
234
+ export declare function questionRubricPoints(rubric: QuestionRubricScale): number;
@@ -0,0 +1,182 @@
1
+ import { Schema, Struct } from "effect";
2
+ import { ActiveAppLocaleCodeSchema } from "#contracts/locale";
3
+ import { canonicalQuestionAnswerKey, canonicalQuestionAnswerKeyStructure, QuestionAnswerKeySchema, } from "#contracts/question/answer";
4
+ import { QuestionResponseLabelSchema } from "#contracts/question/label";
5
+ const CRITERION_KEY_PATTERN = /^criterion-[1-9]\d*$/u;
6
+ const LEVEL_KEY_PATTERN = /^level-[1-9]\d*$/u;
7
+ const PositiveOrderSchema = Schema.Int.check(Schema.isGreaterThan(0));
8
+ const LevelPointsSchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
9
+ /**
10
+ * One learner-facing rubric label written for every active app locale. A
11
+ * learner reads it after the attempt in the app locale, even when the prompt
12
+ * is delivered in a fixed assessed language, so every rubric copy carries all
13
+ * locales.
14
+ */
15
+ export const QuestionRubricLabelSchema = Schema.Record(ActiveAppLocaleCodeSchema, QuestionResponseLabelSchema);
16
+ /**
17
+ * Checks one criterion scale: two or more levels whose points strictly
18
+ * ascend. A final-answer criterion has exactly two levels and its lower level
19
+ * is worth zero, because a wrong result earns nothing.
20
+ */
21
+ function hasOrderedScale(criterion) {
22
+ let previous = -1;
23
+ for (const { points } of criterion.levels) {
24
+ if (points <= previous) {
25
+ return false;
26
+ }
27
+ previous = points;
28
+ }
29
+ if (criterion.finalAnswer === undefined) {
30
+ return criterion.levels.length >= 2;
31
+ }
32
+ const [lower] = criterion.levels;
33
+ return criterion.levels.length === 2 && lower?.points === 0;
34
+ }
35
+ const ORDERED_SCALE_MESSAGE = "Rubric criteria need two or more levels whose points strictly ascend, and a final-answer criterion needs exactly a zero level and one higher level.";
36
+ /** Checks one or more criteria and the stable keys derived from their order. */
37
+ function hasCanonicalCriteria(criteria) {
38
+ return (criteria.length > 0 &&
39
+ criteria.every(({ criterionKey, levels, order }, index) => order === index + 1 &&
40
+ criterionKey === `criterion-${order}` &&
41
+ levels.every((level, levelIndex) => level.order === levelIndex + 1 &&
42
+ level.levelKey === `level-${level.order}`)));
43
+ }
44
+ const CANONICAL_CRITERIA_MESSAGE = "Rubric criteria and levels require canonical keys and order.";
45
+ const LevelScaleFields = {
46
+ levelKey: Schema.String.check(Schema.isPattern(LEVEL_KEY_PATTERN)),
47
+ order: PositiveOrderSchema,
48
+ points: LevelPointsSchema,
49
+ };
50
+ const CriterionScaleFields = {
51
+ criterionKey: Schema.String.check(Schema.isPattern(CRITERION_KEY_PATTERN)),
52
+ finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
53
+ order: PositiveOrderSchema,
54
+ };
55
+ /** One label-free rubric criterion with its ordered level scale. */
56
+ const QuestionRubricCriterionScaleSchema = Schema.Struct({
57
+ ...CriterionScaleFields,
58
+ levels: Schema.Array(Schema.Struct(LevelScaleFields)),
59
+ }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
60
+ /**
61
+ * Locale-neutral rubric scale that grading reads: ordered criteria with
62
+ * stable keys, ordered levels with points, and optional final-answer keys. It
63
+ * ignores labels, so content written in one language, such as a School
64
+ * tenant's rubric, validates its scale here and owns its own labels. A judged
65
+ * criterion maps onto one Effect `Decision.rate` decision keyed by
66
+ * `criterionKey`: its level keys are the rating scale from lowest to highest,
67
+ * a rating answer's probabilities are keyed by them, and the chosen level's
68
+ * points are earned. A final-answer criterion is graded with
69
+ * `matchesAnswerKey` instead: a match earns its upper level and any other
70
+ * answer its zero level. A blank answer earns zero on every criterion.
71
+ */
72
+ export const QuestionRubricScaleSchema = Schema.Struct({
73
+ criteria: Schema.Array(QuestionRubricCriterionScaleSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
74
+ message: CANONICAL_CRITERIA_MESSAGE,
75
+ })),
76
+ kind: Schema.Literal("rubric"),
77
+ });
78
+ /** One frozen scoring level of a rubric criterion. */
79
+ const QuestionRubricLevelSchema = Schema.Struct({
80
+ ...LevelScaleFields,
81
+ label: QuestionRubricLabelSchema,
82
+ });
83
+ /** One frozen rubric criterion with its ordered level scale. */
84
+ const QuestionRubricCriterionSchema = Schema.Struct({
85
+ ...CriterionScaleFields,
86
+ label: QuestionRubricLabelSchema,
87
+ levels: Schema.Array(QuestionRubricLevelSchema),
88
+ }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
89
+ /**
90
+ * Frozen open-response rubric of Aksara content: the rubric scale with every
91
+ * criterion and level labeled in every active app locale.
92
+ */
93
+ export const QuestionRubricResponseSchema = Schema.Struct({
94
+ criteria: Schema.Array(QuestionRubricCriterionSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
95
+ message: CANONICAL_CRITERIA_MESSAGE,
96
+ })),
97
+ kind: Schema.Literal("rubric"),
98
+ });
99
+ /** One authored scoring level before its stable key is derived. */
100
+ const QuestionRubricLevelSourceSchema = Schema.Struct({
101
+ label: QuestionRubricLabelSchema,
102
+ points: LevelPointsSchema,
103
+ }).mapFields(Struct.map(Schema.mutableKey));
104
+ /** One authored criterion before its stable key and order are derived. */
105
+ const QuestionRubricCriterionSourceSchema = Schema.Struct({
106
+ finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
107
+ label: QuestionRubricLabelSchema,
108
+ levels: Schema.Array(QuestionRubricLevelSourceSchema).pipe(Schema.mutable),
109
+ })
110
+ .mapFields(Struct.map(Schema.mutableKey))
111
+ .check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
112
+ /** One rubric authored in array order without duplicated runtime keys. */
113
+ export const QuestionRubricResponseSourceSchema = Schema.Struct({
114
+ criteria: Schema.Array(QuestionRubricCriterionSourceSchema).pipe(Schema.mutable, Schema.check(Schema.makeFilter((criteria) => criteria.length > 0, {
115
+ message: "Expected at least one rubric criterion.",
116
+ }))),
117
+ kind: Schema.Literal("rubric"),
118
+ }).mapFields(Struct.map(Schema.mutableKey));
119
+ /** Derives stable criterion and level keys once from authored array order. */
120
+ export function freezeQuestionRubric(source) {
121
+ return QuestionRubricResponseSchema.make({
122
+ criteria: source.criteria.map((criterion, index) => ({
123
+ criterionKey: `criterion-${index + 1}`,
124
+ ...(criterion.finalAnswer === undefined
125
+ ? {}
126
+ : { finalAnswer: criterion.finalAnswer }),
127
+ label: criterion.label,
128
+ levels: criterion.levels.map(({ label, points }, levelIndex) => ({
129
+ label,
130
+ levelKey: `level-${levelIndex + 1}`,
131
+ order: levelIndex + 1,
132
+ points,
133
+ })),
134
+ order: index + 1,
135
+ })),
136
+ kind: "rubric",
137
+ });
138
+ }
139
+ /** Returns one label with every active app locale in alphabetical order. */
140
+ function canonicalRubricLabel(label) {
141
+ return { de: label.de, en: label.en, id: label.id };
142
+ }
143
+ /** Serializes criteria in stable field order with one answer-key encoding. */
144
+ function canonicalRubricCriteria(rubric, canonicalKey) {
145
+ return rubric.criteria.map(({ criterionKey, finalAnswer, label, levels, order }) => ({
146
+ criterionKey,
147
+ ...(finalAnswer === undefined
148
+ ? {}
149
+ : { finalAnswer: canonicalKey(finalAnswer) }),
150
+ label: canonicalRubricLabel(label),
151
+ levels: levels.map((level) => ({
152
+ label: canonicalRubricLabel(level.label),
153
+ levelKey: level.levelKey,
154
+ order: level.order,
155
+ points: level.points,
156
+ })),
157
+ order,
158
+ }));
159
+ }
160
+ /**
161
+ * Returns the rubric facts shared by every delivery language: keys, order,
162
+ * points, labels in every active app locale, and final-answer rules without
163
+ * accepted text written in one delivery language.
164
+ */
165
+ export function canonicalQuestionRubricStructure(rubric) {
166
+ return {
167
+ criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKeyStructure),
168
+ kind: rubric.kind,
169
+ };
170
+ }
171
+ /** Returns every rubric fact, accepted final-answer text included. */
172
+ export function canonicalQuestionRubric(rubric) {
173
+ return {
174
+ criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKey),
175
+ kind: rubric.kind,
176
+ };
177
+ }
178
+ /** Returns the rubric total: the sum of every criterion's highest level. */
179
+ export function questionRubricPoints(rubric) {
180
+ return rubric.criteria.reduce((total, { levels }) => total +
181
+ levels.reduce((highest, { points }) => Math.max(highest, points), 0), 0);
182
+ }