@nakafa/aksara-contracts 1.0.1 → 2.0.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 (164) hide show
  1. package/README.md +8 -25
  2. package/dist/{question → assessment}/answer.d.ts +14 -58
  3. package/dist/{question → assessment}/answer.js +13 -60
  4. package/dist/assessment/catalog.d.ts +235 -0
  5. package/dist/assessment/catalog.js +115 -0
  6. package/dist/assessment/chart.d.ts +62 -0
  7. package/dist/assessment/chart.js +64 -0
  8. package/dist/assessment/closure.d.ts +28 -0
  9. package/dist/assessment/closure.js +164 -0
  10. package/dist/assessment/explanation.d.ts +13 -8
  11. package/dist/assessment/explanation.js +14 -8
  12. package/dist/assessment/figure.d.ts +140 -1
  13. package/dist/assessment/figure.js +9 -2
  14. package/dist/assessment/hash.d.ts +348 -208
  15. package/dist/assessment/hash.js +14 -0
  16. package/dist/assessment/inline.d.ts +3 -1
  17. package/dist/assessment/inline.js +20 -5
  18. package/dist/assessment/item.d.ts +8 -4
  19. package/dist/assessment/item.js +6 -2
  20. package/dist/assessment/key.js +6 -6
  21. package/dist/assessment/paper.d.ts +74 -74
  22. package/dist/assessment/snapshot.d.ts +3778 -0
  23. package/dist/assessment/snapshot.js +192 -0
  24. package/dist/cache/content.d.ts +4 -4
  25. package/dist/canonical.d.ts +6 -0
  26. package/dist/canonical.js +8 -1
  27. package/dist/content.d.ts +1 -1
  28. package/dist/content.js +0 -1
  29. package/dist/delivery.d.ts +0 -3
  30. package/dist/delivery.js +0 -5
  31. package/dist/preview/artifact.d.ts +1 -120
  32. package/dist/preview/document.d.ts +0 -586
  33. package/dist/preview/document.js +1 -47
  34. package/dist/preview/spec.d.ts +6 -1984
  35. package/dist/preview/spec.js +7 -47
  36. package/dist/preview/target.d.ts +0 -173
  37. package/dist/preview/target.js +1 -70
  38. package/dist/projection/digest.d.ts +0 -127
  39. package/dist/projection/hash.d.ts +0 -127
  40. package/dist/projection/spec.d.ts +6 -211
  41. package/dist/projection/spec.js +4 -18
  42. package/dist/projection/verify.d.ts +0 -127
  43. package/dist/projection/verify.js +0 -3
  44. package/dist/release/canonical.d.ts +2 -2
  45. package/dist/release/current/evidence.d.ts +24 -24
  46. package/dist/release/current/state.d.ts +28 -56
  47. package/dist/release/current/state.js +1 -6
  48. package/dist/release/digest.d.ts +2 -2
  49. package/dist/release/hash.d.ts +5 -5
  50. package/dist/release/head.d.ts +10 -57
  51. package/dist/release/head.js +3 -14
  52. package/dist/release/identity.d.ts +3 -3
  53. package/dist/release/items.d.ts +2 -2
  54. package/dist/release/lifecycle.d.ts +18 -18
  55. package/dist/release/policy.d.ts +3 -4
  56. package/dist/release/policy.js +2 -11
  57. package/dist/release/result/digest.d.ts +6 -18
  58. package/dist/release/result/digest.js +1 -2
  59. package/dist/release/rollback/digest.d.ts +4 -19
  60. package/dist/release/rollback/spec.d.ts +30 -792
  61. package/dist/release/rollback/spec.js +1 -4
  62. package/dist/release/snapshot/data.d.ts +599 -249
  63. package/dist/release/snapshot/data.js +11 -28
  64. package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
  65. package/dist/release/snapshot/evidence/assessment.js +44 -0
  66. package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
  67. package/dist/release/snapshot/evidence.d.ts +19 -19
  68. package/dist/release/snapshot/evidence.js +2 -2
  69. package/dist/release/snapshot/scope.d.ts +5 -5
  70. package/dist/release/snapshot/scope.js +1 -1
  71. package/dist/release/snapshot/spec.d.ts +15 -15
  72. package/dist/release/snapshot/spec.js +8 -8
  73. package/dist/release/snapshot/verify.d.ts +1278 -268
  74. package/dist/release/snapshot/verify.js +8 -5
  75. package/dist/release/spec.d.ts +33 -33
  76. package/dist/release/verify.d.ts +5 -5
  77. package/dist/runtime/spec.d.ts +38 -38
  78. package/dist/runtime/spec.js +4 -5
  79. package/dist/runtime/verify.d.ts +40 -40
  80. package/dist/signature/spec.d.ts +5 -5
  81. package/dist/signature/spec.js +0 -1
  82. package/dist/transport/batch.d.ts +6 -244
  83. package/dist/transport/failure.d.ts +6 -20
  84. package/dist/transport/failure.js +0 -10
  85. package/dist/transport/group.d.ts +1969 -1369
  86. package/dist/transport/group.js +0 -2
  87. package/dist/transport/request.d.ts +10691 -5086
  88. package/dist/transport/request.js +0 -3
  89. package/dist/transport/response.d.ts +219 -1442
  90. package/dist/transport/response.js +0 -4
  91. package/dist/transport/snapshot.d.ts +1187 -487
  92. package/package.json +187 -295
  93. package/dist/projection/question.d.ts +0 -1067
  94. package/dist/projection/question.js +0 -121
  95. package/dist/question/identity.d.ts +0 -175
  96. package/dist/question/identity.js +0 -207
  97. package/dist/question/item.d.ts +0 -450
  98. package/dist/question/item.js +0 -174
  99. package/dist/question/label.d.ts +0 -3
  100. package/dist/question/label.js +0 -3
  101. package/dist/question/points.d.ts +0 -18
  102. package/dist/question/points.js +0 -22
  103. package/dist/question/response.d.ts +0 -289
  104. package/dist/question/response.js +0 -167
  105. package/dist/question/rubric.d.ts +0 -234
  106. package/dist/question/rubric.js +0 -186
  107. package/dist/release/current/runtime.d.ts +0 -4
  108. package/dist/release/current/runtime.js +0 -15
  109. package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
  110. package/dist/release/snapshot/evidence/tryout.js +0 -91
  111. package/dist/runtime/protected/limits.d.ts +0 -10
  112. package/dist/runtime/protected/limits.js +0 -16
  113. package/dist/runtime/protected/spec.d.ts +0 -310
  114. package/dist/runtime/protected/spec.js +0 -80
  115. package/dist/runtime/protected/verify.d.ts +0 -83
  116. package/dist/runtime/protected/verify.js +0 -70
  117. package/dist/transport/runtime.d.ts +0 -77
  118. package/dist/transport/runtime.js +0 -33
  119. package/dist/tryout/canonical.d.ts +0 -12
  120. package/dist/tryout/canonical.js +0 -7
  121. package/dist/tryout/catalog.d.ts +0 -396
  122. package/dist/tryout/catalog.js +0 -155
  123. package/dist/tryout/closure/accounting.d.ts +0 -20
  124. package/dist/tryout/closure/accounting.js +0 -70
  125. package/dist/tryout/closure/locale.d.ts +0 -14
  126. package/dist/tryout/closure/locale.js +0 -113
  127. package/dist/tryout/closure/placement.d.ts +0 -5
  128. package/dist/tryout/closure/placement.js +0 -32
  129. package/dist/tryout/digest.d.ts +0 -34
  130. package/dist/tryout/digest.js +0 -57
  131. package/dist/tryout/hash/catalog.d.ts +0 -364
  132. package/dist/tryout/hash/catalog.js +0 -209
  133. package/dist/tryout/hash/content.d.ts +0 -215
  134. package/dist/tryout/hash/content.js +0 -75
  135. package/dist/tryout/hash/placement.d.ts +0 -242
  136. package/dist/tryout/hash/placement.js +0 -56
  137. package/dist/tryout/identity.d.ts +0 -12
  138. package/dist/tryout/identity.js +0 -47
  139. package/dist/tryout/key.d.ts +0 -4
  140. package/dist/tryout/key.js +0 -8
  141. package/dist/tryout/language.d.ts +0 -24
  142. package/dist/tryout/language.js +0 -30
  143. package/dist/tryout/placement.d.ts +0 -331
  144. package/dist/tryout/placement.js +0 -96
  145. package/dist/tryout/runtime/canonical.d.ts +0 -8
  146. package/dist/tryout/runtime/canonical.js +0 -34
  147. package/dist/tryout/runtime/hash.d.ts +0 -34
  148. package/dist/tryout/runtime/hash.js +0 -13
  149. package/dist/tryout/runtime/source.d.ts +0 -44
  150. package/dist/tryout/runtime/source.js +0 -47
  151. package/dist/tryout/runtime/spec.d.ts +0 -58
  152. package/dist/tryout/runtime/spec.js +0 -21
  153. package/dist/tryout/runtime/verify.d.ts +0 -69
  154. package/dist/tryout/runtime/verify.js +0 -67
  155. package/dist/tryout/scoring.d.ts +0 -148
  156. package/dist/tryout/scoring.js +0 -98
  157. package/dist/tryout/snapshot/canonical.d.ts +0 -7
  158. package/dist/tryout/snapshot/canonical.js +0 -18
  159. package/dist/tryout/snapshot/hash.d.ts +0 -49
  160. package/dist/tryout/snapshot/hash.js +0 -22
  161. package/dist/tryout/snapshot/spec.d.ts +0 -46
  162. package/dist/tryout/snapshot/spec.js +0 -30
  163. package/dist/tryout/spec.d.ts +0 -41
  164. package/dist/tryout/spec.js +0 -46
@@ -1,289 +0,0 @@
1
- import { Schema } from "effect";
2
- /**
3
- * Response formats supported by one assessment item. `short-answer` grades one
4
- * typed number or text deterministically, and `rubric` scores an open response
5
- * per criterion.
6
- */
7
- export declare const QuestionResponseKindSchema: Schema.Literals<readonly ["category", "multiple-choice", "rubric", "short-answer", "single-choice"]>;
8
- export type QuestionResponseKind = typeof QuestionResponseKindSchema.Type;
9
- /** One option of a single or multiple choice response, keyed by its identity. */
10
- export declare const QuestionOptionSchema: Schema.Struct<{
11
- readonly isCorrect: Schema.Boolean;
12
- readonly label: Schema.String;
13
- readonly optionKey: Schema.String;
14
- readonly order: Schema.Int;
15
- }>;
16
- /** One named category of a category response, keyed by its identity. */
17
- export declare const QuestionCategorySchema: Schema.Struct<{
18
- readonly categoryKey: Schema.String;
19
- readonly label: Schema.String;
20
- readonly order: Schema.Int;
21
- }>;
22
- /** One statement classified into one category, keyed by its identity. */
23
- export declare const QuestionCategoryStatementSchema: Schema.Struct<{
24
- readonly correctCategoryKey: Schema.String;
25
- readonly label: Schema.String;
26
- readonly order: Schema.Int;
27
- readonly statementKey: Schema.String;
28
- }>;
29
- /** Frozen locale-specific response used from publication through review. */
30
- export declare const QuestionResponseSchema: Schema.Union<readonly [Schema.Struct<{
31
- readonly categories: Schema.$Array<Schema.Struct<{
32
- readonly categoryKey: Schema.String;
33
- readonly label: Schema.String;
34
- readonly order: Schema.Int;
35
- }>>;
36
- readonly kind: Schema.Literal<"category">;
37
- readonly statements: Schema.$Array<Schema.Struct<{
38
- readonly correctCategoryKey: Schema.String;
39
- readonly label: Schema.String;
40
- readonly order: Schema.Int;
41
- readonly statementKey: Schema.String;
42
- }>>;
43
- }>, Schema.Struct<{
44
- readonly kind: Schema.Literal<"multiple-choice">;
45
- readonly options: Schema.$Array<Schema.Struct<{
46
- readonly isCorrect: Schema.Boolean;
47
- readonly label: Schema.String;
48
- readonly optionKey: Schema.String;
49
- readonly order: Schema.Int;
50
- }>>;
51
- }>, Schema.Struct<{
52
- readonly criteria: Schema.$Array<Schema.Struct<{
53
- readonly criterionKey: Schema.String;
54
- readonly finalAnswer: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
55
- readonly acceptsFractions: Schema.Boolean;
56
- readonly kind: Schema.Literal<"number">;
57
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
58
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
59
- readonly value: Schema.String;
60
- }>>;
61
- readonly value: Schema.String;
62
- }>, Schema.Struct<{
63
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
64
- readonly collapseWhitespace: Schema.Boolean;
65
- readonly ignoreCase: Schema.Boolean;
66
- readonly kind: Schema.Literal<"text">;
67
- }>]>>;
68
- readonly order: Schema.Int;
69
- readonly label: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>;
70
- readonly levels: Schema.$Array<Schema.Struct<{
71
- readonly levelKey: Schema.String;
72
- readonly order: Schema.Int;
73
- readonly points: Schema.Int;
74
- readonly label: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>;
75
- }>>;
76
- }>>;
77
- readonly kind: Schema.Literal<"rubric">;
78
- }>, Schema.Struct<{
79
- readonly key: Schema.Union<readonly [Schema.Struct<{
80
- readonly acceptsFractions: Schema.Boolean;
81
- readonly kind: Schema.Literal<"number">;
82
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
83
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
84
- readonly value: Schema.String;
85
- }>>;
86
- readonly value: Schema.String;
87
- }>, Schema.Struct<{
88
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
89
- readonly collapseWhitespace: Schema.Boolean;
90
- readonly ignoreCase: Schema.Boolean;
91
- readonly kind: Schema.Literal<"text">;
92
- }>]>;
93
- readonly kind: Schema.Literal<"short-answer">;
94
- }>, Schema.Struct<{
95
- readonly kind: Schema.Literal<"single-choice">;
96
- readonly options: Schema.$Array<Schema.Struct<{
97
- readonly isCorrect: Schema.Boolean;
98
- readonly label: Schema.String;
99
- readonly optionKey: Schema.String;
100
- readonly order: Schema.Int;
101
- }>>;
102
- }>]>;
103
- export type QuestionResponse = typeof QuestionResponseSchema.Type;
104
- /**
105
- * Returns the response identity shared by every delivery language: keys,
106
- * order, and answer keys without labels or accepted text written in one
107
- * delivery language. A rubric keeps its labels because each copy carries them
108
- * in every active app locale.
109
- */
110
- export declare function canonicalQuestionResponseStructure(response: QuestionResponse): {
111
- criteria: {
112
- criterionKey: string;
113
- finalAnswer?: {
114
- acceptedAnswers: [string, ...string[]];
115
- collapseWhitespace: boolean;
116
- ignoreCase: boolean;
117
- kind: "text";
118
- } | {
119
- acceptedAnswers?: never;
120
- collapseWhitespace?: never;
121
- ignoreCase?: never;
122
- acceptsFractions: boolean;
123
- kind: "number";
124
- tolerance?: {
125
- kind: "absolute" | "relative";
126
- value: string;
127
- };
128
- value: string;
129
- } | {
130
- collapseWhitespace: boolean;
131
- ignoreCase: boolean;
132
- kind: "text";
133
- };
134
- label: {
135
- readonly de: string;
136
- readonly en: string;
137
- readonly id: string;
138
- };
139
- levels: {
140
- label: {
141
- readonly de: string;
142
- readonly en: string;
143
- readonly id: string;
144
- };
145
- levelKey: string;
146
- order: number;
147
- points: number;
148
- }[];
149
- order: number;
150
- }[];
151
- kind: "rubric";
152
- } | {
153
- key: {
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
- kind: "short-answer";
175
- categories?: never;
176
- statements?: never;
177
- options?: never;
178
- } | {
179
- key?: never;
180
- categories: {
181
- categoryKey: string;
182
- order: number;
183
- }[];
184
- kind: "category";
185
- statements: {
186
- correctCategoryKey: string;
187
- order: number;
188
- statementKey: string;
189
- }[];
190
- options?: never;
191
- } | {
192
- key?: never;
193
- categories?: never;
194
- statements?: never;
195
- kind: "multiple-choice" | "single-choice";
196
- options: {
197
- isCorrect: boolean;
198
- optionKey: string;
199
- order: number;
200
- }[];
201
- };
202
- /** Returns response facts in stable field order for signed canonicalizers. */
203
- export declare function canonicalQuestionResponse(response: QuestionResponse): {
204
- criteria: {
205
- criterionKey: string;
206
- finalAnswer?: {
207
- acceptedAnswers: [string, ...string[]];
208
- collapseWhitespace: boolean;
209
- ignoreCase: boolean;
210
- kind: "text";
211
- } | {
212
- acceptedAnswers?: never;
213
- collapseWhitespace?: never;
214
- ignoreCase?: never;
215
- acceptsFractions: boolean;
216
- kind: "number";
217
- tolerance?: {
218
- kind: "absolute" | "relative";
219
- value: string;
220
- };
221
- value: string;
222
- };
223
- label: {
224
- readonly de: string;
225
- readonly en: string;
226
- readonly id: string;
227
- };
228
- levels: {
229
- label: {
230
- readonly de: string;
231
- readonly en: string;
232
- readonly id: string;
233
- };
234
- levelKey: string;
235
- order: number;
236
- points: number;
237
- }[];
238
- order: number;
239
- }[];
240
- kind: "rubric";
241
- } | {
242
- categories?: never;
243
- statements?: never;
244
- options?: never;
245
- key: {
246
- acceptedAnswers: [string, ...string[]];
247
- collapseWhitespace: boolean;
248
- ignoreCase: boolean;
249
- kind: "text";
250
- } | {
251
- acceptedAnswers?: never;
252
- collapseWhitespace?: never;
253
- ignoreCase?: never;
254
- acceptsFractions: boolean;
255
- kind: "number";
256
- tolerance?: {
257
- kind: "absolute" | "relative";
258
- value: string;
259
- };
260
- value: string;
261
- };
262
- kind: "short-answer";
263
- } | {
264
- key?: never;
265
- options?: never;
266
- categories: {
267
- categoryKey: string;
268
- label: string;
269
- order: number;
270
- }[];
271
- kind: "category";
272
- statements: {
273
- correctCategoryKey: string;
274
- label: string;
275
- order: number;
276
- statementKey: string;
277
- }[];
278
- } | {
279
- key?: never;
280
- categories?: never;
281
- statements?: never;
282
- kind: "multiple-choice" | "single-choice";
283
- options: {
284
- isCorrect: boolean;
285
- label: string;
286
- optionKey: string;
287
- order: number;
288
- }[];
289
- };
@@ -1,167 +0,0 @@
1
- import { Array as Arr, HashSet, Schema } from "effect";
2
- import { canonicalQuestionAnswerKey, canonicalQuestionAnswerKeyStructure, QuestionAnswerKeySchema, } from "#contracts/question/answer";
3
- import { QuestionResponseLabelSchema } from "#contracts/question/label";
4
- import { canonicalQuestionRubric, canonicalQuestionRubricStructure, QuestionRubricResponseSchema, } from "#contracts/question/rubric";
5
- const OPTION_KEY_PATTERN = /^option-[1-9]\d*$/u;
6
- const CATEGORY_KEY_PATTERN = /^category-[1-9]\d*$/u;
7
- const STATEMENT_KEY_PATTERN = /^statement-[1-9]\d*$/u;
8
- const PositiveOrderSchema = Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0)));
9
- /**
10
- * Response formats supported by one assessment item. `short-answer` grades one
11
- * typed number or text deterministically, and `rubric` scores an open response
12
- * per criterion.
13
- */
14
- export const QuestionResponseKindSchema = Schema.Literals([
15
- "category",
16
- "multiple-choice",
17
- "rubric",
18
- "short-answer",
19
- "single-choice",
20
- ]);
21
- /** One option of a single or multiple choice response, keyed by its identity. */
22
- export const QuestionOptionSchema = Schema.Struct({
23
- isCorrect: Schema.Boolean,
24
- label: QuestionResponseLabelSchema,
25
- optionKey: Schema.String.pipe(Schema.check(Schema.isPattern(OPTION_KEY_PATTERN))),
26
- order: PositiveOrderSchema,
27
- });
28
- /** Checks stable option identities, order, and format-specific correctness. */
29
- function hasCanonicalOptions(options, kind) {
30
- const correct = Arr.filter(options, ({ isCorrect }) => isCorrect).length;
31
- return (options.length >= 2 &&
32
- Arr.every(options, ({ optionKey, order }, index) => order === index + 1 && optionKey === `option-${order}`) &&
33
- (kind === "single-choice"
34
- ? correct === 1
35
- : correct >= 2 && correct < options.length));
36
- }
37
- const SingleChoiceResponseSchema = Schema.Struct({
38
- kind: Schema.Literal("single-choice"),
39
- options: Schema.Array(QuestionOptionSchema),
40
- }).pipe(Schema.check(Schema.makeFilter(({ options }) => hasCanonicalOptions(options, "single-choice"), {
41
- message: "Single-choice responses require canonical options and one correct answer.",
42
- })));
43
- const MultipleChoiceResponseSchema = Schema.Struct({
44
- kind: Schema.Literal("multiple-choice"),
45
- options: Schema.Array(QuestionOptionSchema),
46
- }).pipe(Schema.check(Schema.makeFilter(({ options }) => hasCanonicalOptions(options, "multiple-choice"), {
47
- message: "Multiple-choice responses require canonical options, several correct answers, and one distractor.",
48
- })));
49
- /** One named category of a category response, keyed by its identity. */
50
- export const QuestionCategorySchema = Schema.Struct({
51
- categoryKey: Schema.String.pipe(Schema.check(Schema.isPattern(CATEGORY_KEY_PATTERN))),
52
- label: QuestionResponseLabelSchema,
53
- order: PositiveOrderSchema,
54
- });
55
- /** One statement classified into one category, keyed by its identity. */
56
- export const QuestionCategoryStatementSchema = Schema.Struct({
57
- correctCategoryKey: Schema.String.pipe(Schema.check(Schema.isPattern(CATEGORY_KEY_PATTERN))),
58
- label: QuestionResponseLabelSchema,
59
- order: PositiveOrderSchema,
60
- statementKey: Schema.String.pipe(Schema.check(Schema.isPattern(STATEMENT_KEY_PATTERN))),
61
- });
62
- /** Checks stable category and statement identities plus valid references. */
63
- function hasCanonicalCategories(input) {
64
- const categoryKeys = HashSet.fromIterable(Arr.map(input.categories, ({ categoryKey }) => categoryKey));
65
- return (input.categories.length >= 2 &&
66
- input.statements.length > 0 &&
67
- Arr.every(input.categories, ({ categoryKey, order }, index) => order === index + 1 && categoryKey === `category-${order}`) &&
68
- Arr.every(input.statements, ({ correctCategoryKey, order, statementKey }, index) => order === index + 1 &&
69
- statementKey === `statement-${order}` &&
70
- HashSet.has(categoryKeys, correctCategoryKey)));
71
- }
72
- const CategoryResponseSchema = Schema.Struct({
73
- categories: Schema.Array(QuestionCategorySchema),
74
- kind: Schema.Literal("category"),
75
- statements: Schema.Array(QuestionCategoryStatementSchema),
76
- }).pipe(Schema.check(Schema.makeFilter(hasCanonicalCategories, {
77
- message: "Category responses require canonical categories and classified statements.",
78
- })));
79
- /** One typed number or text graded with `matchesAnswerKey` against its key. */
80
- const ShortAnswerResponseSchema = Schema.Struct({
81
- key: QuestionAnswerKeySchema,
82
- kind: Schema.Literal("short-answer"),
83
- });
84
- /** Frozen locale-specific response used from publication through review. */
85
- export const QuestionResponseSchema = Schema.Union([
86
- CategoryResponseSchema,
87
- MultipleChoiceResponseSchema,
88
- QuestionRubricResponseSchema,
89
- ShortAnswerResponseSchema,
90
- SingleChoiceResponseSchema,
91
- ]);
92
- /**
93
- * Returns the response identity shared by every delivery language: keys,
94
- * order, and answer keys without labels or accepted text written in one
95
- * delivery language. A rubric keeps its labels because each copy carries them
96
- * in every active app locale.
97
- */
98
- export function canonicalQuestionResponseStructure(response) {
99
- if (response.kind === "rubric") {
100
- return canonicalQuestionRubricStructure(response);
101
- }
102
- if (response.kind === "short-answer") {
103
- return {
104
- key: canonicalQuestionAnswerKeyStructure(response.key),
105
- kind: response.kind,
106
- };
107
- }
108
- if (response.kind === "category") {
109
- return {
110
- categories: Arr.map(response.categories, ({ categoryKey, order }) => ({
111
- categoryKey,
112
- order,
113
- })),
114
- kind: response.kind,
115
- statements: Arr.map(response.statements, ({ correctCategoryKey, order, statementKey }) => ({
116
- correctCategoryKey,
117
- order,
118
- statementKey,
119
- })),
120
- };
121
- }
122
- return {
123
- kind: response.kind,
124
- options: Arr.map(response.options, ({ isCorrect, optionKey, order }) => ({
125
- isCorrect,
126
- optionKey,
127
- order,
128
- })),
129
- };
130
- }
131
- /** Returns response facts in stable field order for signed canonicalizers. */
132
- export function canonicalQuestionResponse(response) {
133
- if (response.kind === "rubric") {
134
- return canonicalQuestionRubric(response);
135
- }
136
- if (response.kind === "short-answer") {
137
- return {
138
- key: canonicalQuestionAnswerKey(response.key),
139
- kind: response.kind,
140
- };
141
- }
142
- if (response.kind === "category") {
143
- return {
144
- categories: Arr.map(response.categories, ({ categoryKey, label, order }) => ({
145
- categoryKey,
146
- label,
147
- order,
148
- })),
149
- kind: response.kind,
150
- statements: Arr.map(response.statements, ({ correctCategoryKey, label, order, statementKey }) => ({
151
- correctCategoryKey,
152
- label,
153
- order,
154
- statementKey,
155
- })),
156
- };
157
- }
158
- return {
159
- kind: response.kind,
160
- options: Arr.map(response.options, ({ isCorrect, label, optionKey, order }) => ({
161
- isCorrect,
162
- label,
163
- optionKey,
164
- order,
165
- })),
166
- };
167
- }
@@ -1,234 +0,0 @@
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;