@nakafa/aksara-contracts 0.49.0 → 0.50.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.
@@ -17,7 +17,7 @@ export declare class VersionHashMismatchError extends VersionHashMismatchError_b
17
17
  }
18
18
  /** Computes the hash that an item version carries, from all of its other fields. */
19
19
  export declare const hashItemVersion: (body: Omit<{
20
- readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
20
+ readonly deliveryLanguage: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentLanguage">;
21
21
  readonly family: string & import("effect/Brand").Brand<"@NakafaAI/AksaraItemFamilyId">;
22
22
  readonly interactions: readonly [{
23
23
  readonly id: string;
@@ -162,58 +162,6 @@ export declare const hashItemVersion: (body: Omit<{
162
162
  })[]];
163
163
  }[];
164
164
  readonly shuffle: boolean;
165
- } | {
166
- readonly id: string;
167
- readonly label: string;
168
- readonly expectedLength?: number;
169
- readonly kind: "textEntry";
170
- } | {
171
- readonly id: string;
172
- readonly label: string;
173
- readonly acceptsFractions: boolean;
174
- readonly kind: "numericEntry";
175
- readonly unit?: string;
176
- } | {
177
- readonly id: string;
178
- readonly label: string;
179
- readonly kind: "mathEntry";
180
- } | {
181
- readonly id: string;
182
- readonly label: string;
183
- readonly areas: readonly ({
184
- readonly id: string;
185
- readonly label: string;
186
- readonly coords: readonly [number, number, number, number];
187
- readonly shape: "rect";
188
- } | {
189
- readonly id: string;
190
- readonly label: string;
191
- readonly coords: readonly [number, number, number];
192
- readonly shape: "circle";
193
- } | {
194
- readonly id: string;
195
- readonly label: string;
196
- readonly coords: readonly [number, number, number, number];
197
- readonly shape: "ellipse";
198
- } | {
199
- readonly id: string;
200
- readonly label: string;
201
- readonly coords: readonly [number, number, number, number, number, number, ...number[]];
202
- readonly shape: "poly";
203
- } | {
204
- readonly id: string;
205
- readonly label: string;
206
- readonly shape: "default";
207
- })[];
208
- readonly image: {
209
- readonly alt: string;
210
- readonly asset: string;
211
- readonly height: number;
212
- readonly width: number;
213
- };
214
- readonly kind: "hotspot";
215
- readonly maxChoices: number;
216
- readonly minChoices: number;
217
165
  } | {
218
166
  readonly id: string;
219
167
  readonly label: string;
@@ -325,6 +273,58 @@ export declare const hashItemVersion: (body: Omit<{
325
273
  }[]];
326
274
  readonly kind: "gapMatch";
327
275
  readonly shuffle: boolean;
276
+ } | {
277
+ readonly id: string;
278
+ readonly label: string;
279
+ readonly areas: readonly ({
280
+ readonly id: string;
281
+ readonly label: string;
282
+ readonly coords: readonly [number, number, number, number];
283
+ readonly shape: "rect";
284
+ } | {
285
+ readonly id: string;
286
+ readonly label: string;
287
+ readonly coords: readonly [number, number, number];
288
+ readonly shape: "circle";
289
+ } | {
290
+ readonly id: string;
291
+ readonly label: string;
292
+ readonly coords: readonly [number, number, number, number];
293
+ readonly shape: "ellipse";
294
+ } | {
295
+ readonly id: string;
296
+ readonly label: string;
297
+ readonly coords: readonly [number, number, number, number, number, number, ...number[]];
298
+ readonly shape: "poly";
299
+ } | {
300
+ readonly id: string;
301
+ readonly label: string;
302
+ readonly shape: "default";
303
+ })[];
304
+ readonly image: {
305
+ readonly alt: string;
306
+ readonly asset: string;
307
+ readonly height: number;
308
+ readonly width: number;
309
+ };
310
+ readonly kind: "hotspot";
311
+ readonly maxChoices: number;
312
+ readonly minChoices: number;
313
+ } | {
314
+ readonly id: string;
315
+ readonly label: string;
316
+ readonly expectedLength?: number;
317
+ readonly kind: "textEntry";
318
+ } | {
319
+ readonly id: string;
320
+ readonly label: string;
321
+ readonly acceptsFractions: boolean;
322
+ readonly kind: "numericEntry";
323
+ readonly unit?: string;
324
+ } | {
325
+ readonly id: string;
326
+ readonly label: string;
327
+ readonly kind: "mathEntry";
328
328
  } | {
329
329
  readonly id: string;
330
330
  readonly label: string;
@@ -491,58 +491,6 @@ export declare const hashItemVersion: (body: Omit<{
491
491
  })[]];
492
492
  }[];
493
493
  readonly shuffle: boolean;
494
- } | {
495
- readonly id: string;
496
- readonly label: string;
497
- readonly expectedLength?: number;
498
- readonly kind: "textEntry";
499
- } | {
500
- readonly id: string;
501
- readonly label: string;
502
- readonly acceptsFractions: boolean;
503
- readonly kind: "numericEntry";
504
- readonly unit?: string;
505
- } | {
506
- readonly id: string;
507
- readonly label: string;
508
- readonly kind: "mathEntry";
509
- } | {
510
- readonly id: string;
511
- readonly label: string;
512
- readonly areas: readonly ({
513
- readonly id: string;
514
- readonly label: string;
515
- readonly coords: readonly [number, number, number, number];
516
- readonly shape: "rect";
517
- } | {
518
- readonly id: string;
519
- readonly label: string;
520
- readonly coords: readonly [number, number, number];
521
- readonly shape: "circle";
522
- } | {
523
- readonly id: string;
524
- readonly label: string;
525
- readonly coords: readonly [number, number, number, number];
526
- readonly shape: "ellipse";
527
- } | {
528
- readonly id: string;
529
- readonly label: string;
530
- readonly coords: readonly [number, number, number, number, number, number, ...number[]];
531
- readonly shape: "poly";
532
- } | {
533
- readonly id: string;
534
- readonly label: string;
535
- readonly shape: "default";
536
- })[];
537
- readonly image: {
538
- readonly alt: string;
539
- readonly asset: string;
540
- readonly height: number;
541
- readonly width: number;
542
- };
543
- readonly kind: "hotspot";
544
- readonly maxChoices: number;
545
- readonly minChoices: number;
546
494
  } | {
547
495
  readonly id: string;
548
496
  readonly label: string;
@@ -654,6 +602,58 @@ export declare const hashItemVersion: (body: Omit<{
654
602
  }[]];
655
603
  readonly kind: "gapMatch";
656
604
  readonly shuffle: boolean;
605
+ } | {
606
+ readonly id: string;
607
+ readonly label: string;
608
+ readonly areas: readonly ({
609
+ readonly id: string;
610
+ readonly label: string;
611
+ readonly coords: readonly [number, number, number, number];
612
+ readonly shape: "rect";
613
+ } | {
614
+ readonly id: string;
615
+ readonly label: string;
616
+ readonly coords: readonly [number, number, number];
617
+ readonly shape: "circle";
618
+ } | {
619
+ readonly id: string;
620
+ readonly label: string;
621
+ readonly coords: readonly [number, number, number, number];
622
+ readonly shape: "ellipse";
623
+ } | {
624
+ readonly id: string;
625
+ readonly label: string;
626
+ readonly coords: readonly [number, number, number, number, number, number, ...number[]];
627
+ readonly shape: "poly";
628
+ } | {
629
+ readonly id: string;
630
+ readonly label: string;
631
+ readonly shape: "default";
632
+ })[];
633
+ readonly image: {
634
+ readonly alt: string;
635
+ readonly asset: string;
636
+ readonly height: number;
637
+ readonly width: number;
638
+ };
639
+ readonly kind: "hotspot";
640
+ readonly maxChoices: number;
641
+ readonly minChoices: number;
642
+ } | {
643
+ readonly id: string;
644
+ readonly label: string;
645
+ readonly expectedLength?: number;
646
+ readonly kind: "textEntry";
647
+ } | {
648
+ readonly id: string;
649
+ readonly label: string;
650
+ readonly acceptsFractions: boolean;
651
+ readonly kind: "numericEntry";
652
+ readonly unit?: string;
653
+ } | {
654
+ readonly id: string;
655
+ readonly label: string;
656
+ readonly kind: "mathEntry";
657
657
  } | {
658
658
  readonly id: string;
659
659
  readonly label: string;
@@ -678,6 +678,15 @@ export declare const hashItemVersion: (body: Omit<{
678
678
  readonly expectedLines?: number;
679
679
  readonly kind: "extendedText";
680
680
  })[]];
681
+ readonly joint?: {
682
+ readonly levels: readonly [{
683
+ readonly correct: readonly [string, ...string[]];
684
+ readonly points: number;
685
+ }, ...{
686
+ readonly correct: readonly [string, ...string[]];
687
+ readonly points: number;
688
+ }[]];
689
+ };
681
690
  readonly prompt: {
682
691
  readonly content: readonly [import("./document.js").BlockNode, ...import("./document.js").BlockNode[]];
683
692
  readonly type: "doc";
@@ -691,6 +700,15 @@ export declare const hashItemVersion: (body: Omit<{
691
700
  readonly kind: "perPart";
692
701
  readonly penaltyPerWrongPart?: number;
693
702
  readonly pointsPerPart: number;
703
+ } | {
704
+ readonly bands: readonly [{
705
+ readonly points: number;
706
+ readonly wrong: number;
707
+ }, ...{
708
+ readonly points: number;
709
+ readonly wrong: number;
710
+ }[]];
711
+ readonly kind: "wrongParts";
694
712
  } | {
695
713
  readonly criteria: readonly [{
696
714
  readonly id: string;
@@ -720,7 +738,7 @@ export declare const hashItemVersion: (body: Omit<{
720
738
  }, "hash">) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, Schema.SchemaError | import("#contracts/hash/text").TextHashError, never>;
721
739
  /** Computes the hash that a stimulus version carries, from all of its other fields. */
722
740
  export declare const hashStimulusVersion: (body: Omit<{
723
- readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
741
+ readonly deliveryLanguage: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentLanguage">;
724
742
  readonly document: {
725
743
  readonly content: readonly [import("./document.js").BlockNode, ...import("./document.js").BlockNode[]];
726
744
  readonly type: "doc";
@@ -730,7 +748,7 @@ export declare const hashStimulusVersion: (body: Omit<{
730
748
  }, "hash">) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, Schema.SchemaError | import("#contracts/hash/text").TextHashError, never>;
731
749
  /** Requires an item version to carry the hash of its own content. */
732
750
  export declare const verifyItemVersion: (version: {
733
- readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
751
+ readonly deliveryLanguage: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentLanguage">;
734
752
  readonly family: string & import("effect/Brand").Brand<"@NakafaAI/AksaraItemFamilyId">;
735
753
  readonly interactions: readonly [{
736
754
  readonly id: string;
@@ -875,58 +893,6 @@ export declare const verifyItemVersion: (version: {
875
893
  })[]];
876
894
  }[];
877
895
  readonly shuffle: boolean;
878
- } | {
879
- readonly id: string;
880
- readonly label: string;
881
- readonly expectedLength?: number;
882
- readonly kind: "textEntry";
883
- } | {
884
- readonly id: string;
885
- readonly label: string;
886
- readonly acceptsFractions: boolean;
887
- readonly kind: "numericEntry";
888
- readonly unit?: string;
889
- } | {
890
- readonly id: string;
891
- readonly label: string;
892
- readonly kind: "mathEntry";
893
- } | {
894
- readonly id: string;
895
- readonly label: string;
896
- readonly areas: readonly ({
897
- readonly id: string;
898
- readonly label: string;
899
- readonly coords: readonly [number, number, number, number];
900
- readonly shape: "rect";
901
- } | {
902
- readonly id: string;
903
- readonly label: string;
904
- readonly coords: readonly [number, number, number];
905
- readonly shape: "circle";
906
- } | {
907
- readonly id: string;
908
- readonly label: string;
909
- readonly coords: readonly [number, number, number, number];
910
- readonly shape: "ellipse";
911
- } | {
912
- readonly id: string;
913
- readonly label: string;
914
- readonly coords: readonly [number, number, number, number, number, number, ...number[]];
915
- readonly shape: "poly";
916
- } | {
917
- readonly id: string;
918
- readonly label: string;
919
- readonly shape: "default";
920
- })[];
921
- readonly image: {
922
- readonly alt: string;
923
- readonly asset: string;
924
- readonly height: number;
925
- readonly width: number;
926
- };
927
- readonly kind: "hotspot";
928
- readonly maxChoices: number;
929
- readonly minChoices: number;
930
896
  } | {
931
897
  readonly id: string;
932
898
  readonly label: string;
@@ -1038,6 +1004,58 @@ export declare const verifyItemVersion: (version: {
1038
1004
  }[]];
1039
1005
  readonly kind: "gapMatch";
1040
1006
  readonly shuffle: boolean;
1007
+ } | {
1008
+ readonly id: string;
1009
+ readonly label: string;
1010
+ readonly areas: readonly ({
1011
+ readonly id: string;
1012
+ readonly label: string;
1013
+ readonly coords: readonly [number, number, number, number];
1014
+ readonly shape: "rect";
1015
+ } | {
1016
+ readonly id: string;
1017
+ readonly label: string;
1018
+ readonly coords: readonly [number, number, number];
1019
+ readonly shape: "circle";
1020
+ } | {
1021
+ readonly id: string;
1022
+ readonly label: string;
1023
+ readonly coords: readonly [number, number, number, number];
1024
+ readonly shape: "ellipse";
1025
+ } | {
1026
+ readonly id: string;
1027
+ readonly label: string;
1028
+ readonly coords: readonly [number, number, number, number, number, number, ...number[]];
1029
+ readonly shape: "poly";
1030
+ } | {
1031
+ readonly id: string;
1032
+ readonly label: string;
1033
+ readonly shape: "default";
1034
+ })[];
1035
+ readonly image: {
1036
+ readonly alt: string;
1037
+ readonly asset: string;
1038
+ readonly height: number;
1039
+ readonly width: number;
1040
+ };
1041
+ readonly kind: "hotspot";
1042
+ readonly maxChoices: number;
1043
+ readonly minChoices: number;
1044
+ } | {
1045
+ readonly id: string;
1046
+ readonly label: string;
1047
+ readonly expectedLength?: number;
1048
+ readonly kind: "textEntry";
1049
+ } | {
1050
+ readonly id: string;
1051
+ readonly label: string;
1052
+ readonly acceptsFractions: boolean;
1053
+ readonly kind: "numericEntry";
1054
+ readonly unit?: string;
1055
+ } | {
1056
+ readonly id: string;
1057
+ readonly label: string;
1058
+ readonly kind: "mathEntry";
1041
1059
  } | {
1042
1060
  readonly id: string;
1043
1061
  readonly label: string;
@@ -1204,58 +1222,6 @@ export declare const verifyItemVersion: (version: {
1204
1222
  })[]];
1205
1223
  }[];
1206
1224
  readonly shuffle: boolean;
1207
- } | {
1208
- readonly id: string;
1209
- readonly label: string;
1210
- readonly expectedLength?: number;
1211
- readonly kind: "textEntry";
1212
- } | {
1213
- readonly id: string;
1214
- readonly label: string;
1215
- readonly acceptsFractions: boolean;
1216
- readonly kind: "numericEntry";
1217
- readonly unit?: string;
1218
- } | {
1219
- readonly id: string;
1220
- readonly label: string;
1221
- readonly kind: "mathEntry";
1222
- } | {
1223
- readonly id: string;
1224
- readonly label: string;
1225
- readonly areas: readonly ({
1226
- readonly id: string;
1227
- readonly label: string;
1228
- readonly coords: readonly [number, number, number, number];
1229
- readonly shape: "rect";
1230
- } | {
1231
- readonly id: string;
1232
- readonly label: string;
1233
- readonly coords: readonly [number, number, number];
1234
- readonly shape: "circle";
1235
- } | {
1236
- readonly id: string;
1237
- readonly label: string;
1238
- readonly coords: readonly [number, number, number, number];
1239
- readonly shape: "ellipse";
1240
- } | {
1241
- readonly id: string;
1242
- readonly label: string;
1243
- readonly coords: readonly [number, number, number, number, number, number, ...number[]];
1244
- readonly shape: "poly";
1245
- } | {
1246
- readonly id: string;
1247
- readonly label: string;
1248
- readonly shape: "default";
1249
- })[];
1250
- readonly image: {
1251
- readonly alt: string;
1252
- readonly asset: string;
1253
- readonly height: number;
1254
- readonly width: number;
1255
- };
1256
- readonly kind: "hotspot";
1257
- readonly maxChoices: number;
1258
- readonly minChoices: number;
1259
1225
  } | {
1260
1226
  readonly id: string;
1261
1227
  readonly label: string;
@@ -1367,6 +1333,58 @@ export declare const verifyItemVersion: (version: {
1367
1333
  }[]];
1368
1334
  readonly kind: "gapMatch";
1369
1335
  readonly shuffle: boolean;
1336
+ } | {
1337
+ readonly id: string;
1338
+ readonly label: string;
1339
+ readonly areas: readonly ({
1340
+ readonly id: string;
1341
+ readonly label: string;
1342
+ readonly coords: readonly [number, number, number, number];
1343
+ readonly shape: "rect";
1344
+ } | {
1345
+ readonly id: string;
1346
+ readonly label: string;
1347
+ readonly coords: readonly [number, number, number];
1348
+ readonly shape: "circle";
1349
+ } | {
1350
+ readonly id: string;
1351
+ readonly label: string;
1352
+ readonly coords: readonly [number, number, number, number];
1353
+ readonly shape: "ellipse";
1354
+ } | {
1355
+ readonly id: string;
1356
+ readonly label: string;
1357
+ readonly coords: readonly [number, number, number, number, number, number, ...number[]];
1358
+ readonly shape: "poly";
1359
+ } | {
1360
+ readonly id: string;
1361
+ readonly label: string;
1362
+ readonly shape: "default";
1363
+ })[];
1364
+ readonly image: {
1365
+ readonly alt: string;
1366
+ readonly asset: string;
1367
+ readonly height: number;
1368
+ readonly width: number;
1369
+ };
1370
+ readonly kind: "hotspot";
1371
+ readonly maxChoices: number;
1372
+ readonly minChoices: number;
1373
+ } | {
1374
+ readonly id: string;
1375
+ readonly label: string;
1376
+ readonly expectedLength?: number;
1377
+ readonly kind: "textEntry";
1378
+ } | {
1379
+ readonly id: string;
1380
+ readonly label: string;
1381
+ readonly acceptsFractions: boolean;
1382
+ readonly kind: "numericEntry";
1383
+ readonly unit?: string;
1384
+ } | {
1385
+ readonly id: string;
1386
+ readonly label: string;
1387
+ readonly kind: "mathEntry";
1370
1388
  } | {
1371
1389
  readonly id: string;
1372
1390
  readonly label: string;
@@ -1391,6 +1409,15 @@ export declare const verifyItemVersion: (version: {
1391
1409
  readonly expectedLines?: number;
1392
1410
  readonly kind: "extendedText";
1393
1411
  })[]];
1412
+ readonly joint?: {
1413
+ readonly levels: readonly [{
1414
+ readonly correct: readonly [string, ...string[]];
1415
+ readonly points: number;
1416
+ }, ...{
1417
+ readonly correct: readonly [string, ...string[]];
1418
+ readonly points: number;
1419
+ }[]];
1420
+ };
1394
1421
  readonly prompt: {
1395
1422
  readonly content: readonly [import("./document.js").BlockNode, ...import("./document.js").BlockNode[]];
1396
1423
  readonly type: "doc";
@@ -1404,6 +1431,15 @@ export declare const verifyItemVersion: (version: {
1404
1431
  readonly kind: "perPart";
1405
1432
  readonly penaltyPerWrongPart?: number;
1406
1433
  readonly pointsPerPart: number;
1434
+ } | {
1435
+ readonly bands: readonly [{
1436
+ readonly points: number;
1437
+ readonly wrong: number;
1438
+ }, ...{
1439
+ readonly points: number;
1440
+ readonly wrong: number;
1441
+ }[]];
1442
+ readonly kind: "wrongParts";
1407
1443
  } | {
1408
1444
  readonly criteria: readonly [{
1409
1445
  readonly id: string;
@@ -1433,7 +1469,7 @@ export declare const verifyItemVersion: (version: {
1433
1469
  }) => Effect.Effect<undefined, Schema.SchemaError | import("#contracts/hash/text").TextHashError | VersionHashMismatchError, never>;
1434
1470
  /** Requires a stimulus version to carry the hash of its own content. */
1435
1471
  export declare const verifyStimulusVersion: (version: {
1436
- readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
1472
+ readonly deliveryLanguage: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentLanguage">;
1437
1473
  readonly document: {
1438
1474
  readonly content: readonly [import("./document.js").BlockNode, ...import("./document.js").BlockNode[]];
1439
1475
  readonly type: "doc";
@@ -30,13 +30,14 @@ export declare const StimulusReferenceSchema: Schema.Struct<{
30
30
  export type StimulusReference = typeof StimulusReferenceSchema.Type;
31
31
  /**
32
32
  * One item in one delivery language, without its hash: the prompt document,
33
- * its interactions, the scoring rules that override the exam profile, and the
34
- * shared reading it was written against, if it has one. The prompt carries no
35
- * answer key, and the version holds no explanation: the key and the explanation
36
- * are records of their own (`assessment/key`, `assessment/explanation`).
33
+ * its interactions, the scoring rules that override the exam profile, the joint
34
+ * rule when its answers depend on each other, and the shared reading it was
35
+ * written against, if it has one. The prompt carries no answer key, and the
36
+ * version holds no explanation: the key and the explanation are records of their
37
+ * own (`assessment/key`, `assessment/explanation`).
37
38
  */
38
39
  export declare const ItemVersionBodySchema: Schema.Struct<{
39
- deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
40
+ deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
40
41
  family: Schema.brand<Schema.String, "@NakafaAI/AksaraItemFamilyId">;
41
42
  interactions: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
42
43
  readonly id: Schema.String;
@@ -236,6 +237,12 @@ export declare const ItemVersionBodySchema: Schema.Struct<{
236
237
  readonly expectedLines: Schema.optionalKey<Schema.Int>;
237
238
  readonly kind: Schema.Literal<"extendedText">;
238
239
  }>]>>;
240
+ joint: Schema.optionalKey<Schema.Struct<{
241
+ readonly levels: Schema.NonEmptyArray<Schema.Struct<{
242
+ readonly correct: Schema.NonEmptyArray<Schema.String>;
243
+ readonly points: Schema.Int;
244
+ }>>;
245
+ }>>;
239
246
  prompt: Schema.decodeTo<Schema.Struct<{
240
247
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
241
248
  readonly type: Schema.Literal<"doc">;
@@ -249,6 +256,12 @@ export declare const ItemVersionBodySchema: Schema.Struct<{
249
256
  readonly kind: Schema.Literal<"perPart">;
250
257
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
251
258
  readonly pointsPerPart: Schema.Int;
259
+ }>, Schema.Struct<{
260
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
261
+ readonly points: Schema.Int;
262
+ readonly wrong: Schema.Int;
263
+ }>>;
264
+ readonly kind: Schema.Literal<"wrongParts">;
252
265
  }>, Schema.Struct<{
253
266
  readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
254
267
  readonly id: Schema.String;
@@ -274,7 +287,7 @@ export declare const ItemVersionBodySchema: Schema.Struct<{
274
287
  * by `assessment/record`.
275
288
  */
276
289
  export declare const ItemVersionSchema: Schema.Struct<{
277
- readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
290
+ readonly deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
278
291
  readonly family: Schema.brand<Schema.String, "@NakafaAI/AksaraItemFamilyId">;
279
292
  readonly interactions: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
280
293
  readonly id: Schema.String;
@@ -474,6 +487,12 @@ export declare const ItemVersionSchema: Schema.Struct<{
474
487
  readonly expectedLines: Schema.optionalKey<Schema.Int>;
475
488
  readonly kind: Schema.Literal<"extendedText">;
476
489
  }>]>>;
490
+ readonly joint: Schema.optionalKey<Schema.Struct<{
491
+ readonly levels: Schema.NonEmptyArray<Schema.Struct<{
492
+ readonly correct: Schema.NonEmptyArray<Schema.String>;
493
+ readonly points: Schema.Int;
494
+ }>>;
495
+ }>>;
477
496
  readonly prompt: Schema.decodeTo<Schema.Struct<{
478
497
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
479
498
  readonly type: Schema.Literal<"doc">;
@@ -487,6 +506,12 @@ export declare const ItemVersionSchema: Schema.Struct<{
487
506
  readonly kind: Schema.Literal<"perPart">;
488
507
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
489
508
  readonly pointsPerPart: Schema.Int;
509
+ }>, Schema.Struct<{
510
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
511
+ readonly points: Schema.Int;
512
+ readonly wrong: Schema.Int;
513
+ }>>;
514
+ readonly kind: Schema.Literal<"wrongParts">;
490
515
  }>, Schema.Struct<{
491
516
  readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
492
517
  readonly id: Schema.String;
@@ -523,7 +548,7 @@ export declare const ItemSchema: Schema.Struct<{
523
548
  readonly stimulus: Schema.optionalKey<Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">>;
524
549
  }>;
525
550
  readonly versions: Schema.NonEmptyArray<Schema.Struct<{
526
- readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
551
+ readonly deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
527
552
  readonly family: Schema.brand<Schema.String, "@NakafaAI/AksaraItemFamilyId">;
528
553
  readonly interactions: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
529
554
  readonly id: Schema.String;
@@ -723,6 +748,12 @@ export declare const ItemSchema: Schema.Struct<{
723
748
  readonly expectedLines: Schema.optionalKey<Schema.Int>;
724
749
  readonly kind: Schema.Literal<"extendedText">;
725
750
  }>]>>;
751
+ readonly joint: Schema.optionalKey<Schema.Struct<{
752
+ readonly levels: Schema.NonEmptyArray<Schema.Struct<{
753
+ readonly correct: Schema.NonEmptyArray<Schema.String>;
754
+ readonly points: Schema.Int;
755
+ }>>;
756
+ }>>;
726
757
  readonly prompt: Schema.decodeTo<Schema.Struct<{
727
758
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
728
759
  readonly type: Schema.Literal<"doc">;
@@ -736,6 +767,12 @@ export declare const ItemSchema: Schema.Struct<{
736
767
  readonly kind: Schema.Literal<"perPart">;
737
768
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
738
769
  readonly pointsPerPart: Schema.Int;
770
+ }>, Schema.Struct<{
771
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
772
+ readonly points: Schema.Int;
773
+ readonly wrong: Schema.Int;
774
+ }>>;
775
+ readonly kind: Schema.Literal<"wrongParts">;
739
776
  }>, Schema.Struct<{
740
777
  readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
741
778
  readonly id: Schema.String;
@@ -3,11 +3,12 @@ import { AssessmentDocumentSchema } from "#contracts/assessment/document";
3
3
  import { hasFittingRules, hasPlacedInteractions, } from "#contracts/assessment/fit";
4
4
  import { hasDistinctIds, ItemFamilyIdSchema, KebabKeySchema, StimulusIdSchema, } from "#contracts/assessment/identity";
5
5
  import { InteractionSchema } from "#contracts/assessment/interaction";
6
+ import { hasJointParts, hasOneItemRule, JointRuleSchema, sortedJoint, } from "#contracts/assessment/joint";
6
7
  import { isWithinRecordLimit } from "#contracts/assessment/record";
7
8
  import { ScoringOverrideSchema } from "#contracts/assessment/scoring";
8
9
  import { hasSameStructure } from "#contracts/assessment/structure";
9
10
  import { Sha256HashSchema } from "#contracts/ids";
10
- import { DeliveryLanguageSchema } from "#contracts/locale";
11
+ import { ContentLanguageSchema } from "#contracts/locale";
11
12
  /** The editorial facts that place an item in a blueprint. */
12
13
  export const ItemBlueprintSchema = Schema.Struct({
13
14
  cognitiveLevel: KebabKeySchema,
@@ -33,24 +34,30 @@ export const StimulusReferenceSchema = Schema.Struct({
33
34
  });
34
35
  /** The fields of an item version except its hash, which covers all of them. */
35
36
  const VersionFields = {
36
- deliveryLanguage: DeliveryLanguageSchema,
37
+ deliveryLanguage: ContentLanguageSchema,
37
38
  family: ItemFamilyIdSchema,
38
39
  interactions: Schema.NonEmptyArray(InteractionSchema),
40
+ joint: Schema.optionalKey(JointRuleSchema),
39
41
  prompt: AssessmentDocumentSchema,
40
42
  scoring: Schema.Array(ScoringOverrideSchema),
41
43
  stimulus: Schema.optionalKey(StimulusReferenceSchema),
42
44
  };
43
45
  /**
44
46
  * One item in one delivery language, without its hash: the prompt document,
45
- * its interactions, the scoring rules that override the exam profile, and the
46
- * shared reading it was written against, if it has one. The prompt carries no
47
- * answer key, and the version holds no explanation: the key and the explanation
48
- * are records of their own (`assessment/key`, `assessment/explanation`).
47
+ * its interactions, the scoring rules that override the exam profile, the joint
48
+ * rule when its answers depend on each other, and the shared reading it was
49
+ * written against, if it has one. The prompt carries no answer key, and the
50
+ * version holds no explanation: the key and the explanation are records of their
51
+ * own (`assessment/key`, `assessment/explanation`).
49
52
  */
50
53
  export const ItemVersionBodySchema = Schema.Struct(VersionFields).check(Schema.makeFilter(hasPlacedInteractions, {
51
54
  message: "Expected the prompt to place each interaction once, as its kind allows, and no other.",
52
55
  }), Schema.makeFilter(hasFittingRules, {
53
56
  message: "Expected each scoring rule to fit its interaction, and each extended text to carry a rubric.",
57
+ }), Schema.makeFilter(hasJointParts, {
58
+ message: "Expected a joint rule to name at least two interactions of the version, each level naming only those.",
59
+ }), Schema.makeFilter(hasOneItemRule, {
60
+ message: "Expected a joint rule to leave the scoring overrides empty, because one rule scores the item.",
54
61
  }));
55
62
  /**
56
63
  * An item version is immutable once published: a change is a new version. Its
@@ -69,12 +76,15 @@ const ItemFieldsSchema = Schema.Struct({
69
76
  * and answer key, and it still holds: a translation may change words, never
70
77
  * the task. If the structure were free to differ, one answer key, one scoring
71
78
  * rule, and one calibrated difficulty could not serve every language of an
72
- * item. The identifiers, counts, bounds, and scoring rules must agree; the
73
- * labels, the text alternatives, and the units are the words of a language.
79
+ * item. The identifiers, counts, bounds, joint rule, and scoring rules must
80
+ * agree; the labels, the text alternatives, and the units are the words of a
81
+ * language. The interactions of a joint level are a set, so a language may list
82
+ * them in another order.
74
83
  */
75
84
  function hasOneStructure(item) {
76
- return hasSameStructure(Arr.map(item.versions, ({ interactions, scoring }) => ({
85
+ return hasSameStructure(Arr.map(item.versions, ({ interactions, joint, scoring }) => ({
77
86
  interactions,
87
+ joint: joint === undefined ? undefined : sortedJoint(joint),
78
88
  scoring,
79
89
  })));
80
90
  }
@@ -0,0 +1,62 @@
1
+ import { Schema } from "effect";
2
+ import type { Interaction } from "#contracts/assessment/interaction";
3
+ import type { ScoringOverride } from "#contracts/assessment/scoring";
4
+ /**
5
+ * One level of a joint rule: the interactions that must all be correct for an
6
+ * item to earn the points of the level. An interaction is correct when its key
7
+ * matches it completely. The interactions form a set, so their order in the
8
+ * list carries no meaning.
9
+ */
10
+ export declare const JointLevelSchema: Schema.Struct<{
11
+ readonly correct: Schema.NonEmptyArray<Schema.String>;
12
+ readonly points: Schema.Int;
13
+ }>;
14
+ /**
15
+ * One rule for the whole item, for answers that depend on each other, such as an
16
+ * answer and its reason. The item scores the points of the first level whose
17
+ * interactions are all correct, and 0 when none is. Interactions scored together
18
+ * make a composite item, which QTI 3 scores by general response processing, not
19
+ * by a standard template (Best Practices and Implementation Guide, section 3.4.2).
20
+ */
21
+ export declare const JointRuleSchema: Schema.Struct<{
22
+ readonly levels: Schema.NonEmptyArray<Schema.Struct<{
23
+ readonly correct: Schema.NonEmptyArray<Schema.String>;
24
+ readonly points: Schema.Int;
25
+ }>>;
26
+ }>;
27
+ export type JointRule = typeof JointRuleSchema.Type;
28
+ /** Returns the most points that a joint rule can award: the points of its first level. */
29
+ export declare function jointCeiling(joint: JointRule): number;
30
+ /**
31
+ * Returns a joint rule with the interactions of each level in code-unit order.
32
+ * A level names a set, so the order of its listing is not part of the task: the
33
+ * structure check of a family compares this form, and the hash keeps the exact
34
+ * listing.
35
+ */
36
+ export declare function sortedJoint(joint: JointRule): {
37
+ levels: [{
38
+ correct: [string, ...string[]];
39
+ points: number;
40
+ }, ...{
41
+ correct: [string, ...string[]];
42
+ points: number;
43
+ }[]];
44
+ };
45
+ /**
46
+ * Checks that a joint rule has interactions to join: at least two in the
47
+ * version, and each level names only interactions of the version.
48
+ */
49
+ export declare function hasJointParts(version: {
50
+ readonly interactions: readonly Interaction[];
51
+ readonly joint?: JointRule;
52
+ }): boolean;
53
+ /**
54
+ * Checks that a version with a joint rule sets no scoring override: one rule
55
+ * scores the item. This also refuses an extended text in a joint item, because
56
+ * an extended text needs a rubric override (`fit`), and a joint item has none. A
57
+ * person judges an extended text, so no key can say that it is correct.
58
+ */
59
+ export declare function hasOneItemRule(version: {
60
+ readonly joint?: JointRule;
61
+ readonly scoring: readonly ScoringOverride[];
62
+ }): boolean;
@@ -0,0 +1,85 @@
1
+ import { Array as Arr, Order, Schema } from "effect";
2
+ import { hasDistinctIds, LocalIdSchema } from "#contracts/assessment/identity";
3
+ import { PositiveIntSchema } from "#contracts/assessment/scalar";
4
+ /**
5
+ * One level of a joint rule: the interactions that must all be correct for an
6
+ * item to earn the points of the level. An interaction is correct when its key
7
+ * matches it completely. The interactions form a set, so their order in the
8
+ * list carries no meaning.
9
+ */
10
+ export const JointLevelSchema = Schema.Struct({
11
+ correct: Schema.NonEmptyArray(LocalIdSchema).check(Schema.makeFilter(hasDistinctIds, {
12
+ message: "Expected each interaction of a level once.",
13
+ })),
14
+ points: PositiveIntSchema,
15
+ });
16
+ /** Checks that each level is worth fewer points than the level above it. */
17
+ function hasDescendingPoints(levels) {
18
+ return Arr.every(Arr.zip(levels, Arr.drop(levels, 1)), ([higher, lower]) => higher.points > lower.points);
19
+ }
20
+ /** Checks that the later list names every interaction of the earlier list. */
21
+ function namesEveryOf(later, earlier) {
22
+ return Arr.every(earlier, (id) => Arr.contains(later, id));
23
+ }
24
+ /**
25
+ * Checks that every level can score. The item awards the first level whose
26
+ * interactions are all correct, so a later level that names every interaction
27
+ * of an earlier level could never score: each answer that earns it also earns
28
+ * the earlier level, which comes first.
29
+ */
30
+ function hasReachableLevels(levels) {
31
+ return Arr.every(levels, (level, index) => Arr.every(Arr.take(levels, index), (earlier) => !namesEveryOf(level.correct, earlier.correct)));
32
+ }
33
+ /**
34
+ * One rule for the whole item, for answers that depend on each other, such as an
35
+ * answer and its reason. The item scores the points of the first level whose
36
+ * interactions are all correct, and 0 when none is. Interactions scored together
37
+ * make a composite item, which QTI 3 scores by general response processing, not
38
+ * by a standard template (Best Practices and Implementation Guide, section 3.4.2).
39
+ */
40
+ export const JointRuleSchema = Schema.Struct({
41
+ levels: Schema.NonEmptyArray(JointLevelSchema).check(Schema.makeFilter(hasDescendingPoints, {
42
+ message: "Expected the points of the levels to descend.",
43
+ }), Schema.makeFilter(hasReachableLevels, {
44
+ message: "Expected no level to name every interaction of an earlier level, because the earlier level would always score first.",
45
+ })),
46
+ });
47
+ /** Returns the most points that a joint rule can award: the points of its first level. */
48
+ export function jointCeiling(joint) {
49
+ return Arr.headNonEmpty(joint.levels).points;
50
+ }
51
+ /**
52
+ * Returns a joint rule with the interactions of each level in code-unit order.
53
+ * A level names a set, so the order of its listing is not part of the task: the
54
+ * structure check of a family compares this form, and the hash keeps the exact
55
+ * listing.
56
+ */
57
+ export function sortedJoint(joint) {
58
+ return {
59
+ levels: Arr.map(joint.levels, ({ correct, points }) => ({
60
+ correct: Arr.sort(correct, Order.String),
61
+ points,
62
+ })),
63
+ };
64
+ }
65
+ /**
66
+ * Checks that a joint rule has interactions to join: at least two in the
67
+ * version, and each level names only interactions of the version.
68
+ */
69
+ export function hasJointParts(version) {
70
+ if (version.joint === undefined) {
71
+ return true;
72
+ }
73
+ const ids = Arr.map(version.interactions, ({ id }) => id);
74
+ return (version.interactions.length >= 2 &&
75
+ Arr.every(version.joint.levels, ({ correct }) => Arr.every(correct, (id) => Arr.contains(ids, id))));
76
+ }
77
+ /**
78
+ * Checks that a version with a joint rule sets no scoring override: one rule
79
+ * scores the item. This also refuses an extended text in a joint item, because
80
+ * an extended text needs a rubric override (`fit`), and a joint item has none. A
81
+ * person judges an extended text, so no key can say that it is correct.
82
+ */
83
+ export function hasOneItemRule(version) {
84
+ return version.joint === undefined || version.scoring.length === 0;
85
+ }
@@ -95,7 +95,7 @@ export declare const verifyPaperStimuli: (paper: {
95
95
  readonly id: string & import("effect/Brand").Brand<"@NakafaAI/AksaraStimulusId">;
96
96
  }[];
97
97
  }, versions: readonly {
98
- readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
98
+ readonly deliveryLanguage: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentLanguage">;
99
99
  readonly family: string & import("effect/Brand").Brand<"@NakafaAI/AksaraItemFamilyId">;
100
100
  readonly interactions: readonly [{
101
101
  readonly id: string;
@@ -756,6 +756,15 @@ export declare const verifyPaperStimuli: (paper: {
756
756
  readonly expectedLines?: number;
757
757
  readonly kind: "extendedText";
758
758
  })[]];
759
+ readonly joint?: {
760
+ readonly levels: readonly [{
761
+ readonly correct: readonly [string, ...string[]];
762
+ readonly points: number;
763
+ }, ...{
764
+ readonly correct: readonly [string, ...string[]];
765
+ readonly points: number;
766
+ }[]];
767
+ };
759
768
  readonly prompt: {
760
769
  readonly content: readonly [import("./document.js").BlockNode, ...import("./document.js").BlockNode[]];
761
770
  readonly type: "doc";
@@ -769,6 +778,15 @@ export declare const verifyPaperStimuli: (paper: {
769
778
  readonly kind: "perPart";
770
779
  readonly penaltyPerWrongPart?: number;
771
780
  readonly pointsPerPart: number;
781
+ } | {
782
+ readonly bands: readonly [{
783
+ readonly points: number;
784
+ readonly wrong: number;
785
+ }, ...{
786
+ readonly points: number;
787
+ readonly wrong: number;
788
+ }[]];
789
+ readonly kind: "wrongParts";
772
790
  } | {
773
791
  readonly criteria: readonly [{
774
792
  readonly id: string;
@@ -89,6 +89,12 @@ export declare const ExamProfileSchema: Schema.Struct<{
89
89
  readonly kind: Schema.Literal<"perPart">;
90
90
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
91
91
  readonly pointsPerPart: Schema.Int;
92
+ }>, Schema.Struct<{
93
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
94
+ readonly points: Schema.Int;
95
+ readonly wrong: Schema.Int;
96
+ }>>;
97
+ readonly kind: Schema.Literal<"wrongParts">;
92
98
  }>]>;
93
99
  }>>;
94
100
  /**
@@ -28,6 +28,33 @@ export declare const PerPartRuleSchema: Schema.Struct<{
28
28
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
29
29
  readonly pointsPerPart: Schema.Int;
30
30
  }>;
31
+ /**
32
+ * Points by the number of wrong parts, such as the AKM rule of a complex
33
+ * multiple choice with more than five statements and more than two options: 2
34
+ * points with no wrong part, 1 point with one or two, and 0 with more. An answer
35
+ * scores the points of the first band whose `wrong` is at least its number of
36
+ * wrong parts, and 0 when no band holds it. The parts are the ones the per-part
37
+ * rule counts, as the key defines them for each kind.
38
+ *
39
+ * It corresponds to no standard response processing template of QTI 3.
40
+ * `match_correct` gives 1 or 0 for the whole interaction. `map_response` maps
41
+ * each response value and sums the results. With one value for the correct parts
42
+ * and one for the wrong parts, each wrong part moves the score by the same step,
43
+ * and clamping the sum to its bounds flattens only its two ends. The table 2, 1,
44
+ * 1, 0 for 0 to 3 wrong parts has a flat step in the middle, so no sum over the
45
+ * parts gives it. Section 3.4.2 of the QTI 3 Best Practices and Implementation
46
+ * Guide says that a composite item needs general response processing, not a
47
+ * standard template. A table over the wrong parts is that kind of score, so it
48
+ * corresponds to the general response processing of that section.
49
+ */
50
+ export declare const WrongPartsRuleSchema: Schema.Struct<{
51
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
52
+ readonly points: Schema.Int;
53
+ readonly wrong: Schema.Int;
54
+ }>>;
55
+ readonly kind: Schema.Literal<"wrongParts">;
56
+ }>;
57
+ export type WrongPartsRule = typeof WrongPartsRuleSchema.Type;
31
58
  /**
32
59
  * Criteria, each with ordered levels and the points of each level. The learner
33
60
  * sees the criteria and the level reached; what earns a level is a descriptor
@@ -54,6 +81,12 @@ export declare const ScoringRuleSchema: Schema.Union<readonly [Schema.Struct<{
54
81
  readonly kind: Schema.Literal<"perPart">;
55
82
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
56
83
  readonly pointsPerPart: Schema.Int;
84
+ }>, Schema.Struct<{
85
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
86
+ readonly points: Schema.Int;
87
+ readonly wrong: Schema.Int;
88
+ }>>;
89
+ readonly kind: Schema.Literal<"wrongParts">;
57
90
  }>, Schema.Struct<{
58
91
  readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
59
92
  readonly id: Schema.String;
@@ -78,6 +111,12 @@ export declare const DefaultRuleSchema: Schema.Union<readonly [Schema.Struct<{
78
111
  readonly kind: Schema.Literal<"perPart">;
79
112
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
80
113
  readonly pointsPerPart: Schema.Int;
114
+ }>, Schema.Struct<{
115
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
116
+ readonly points: Schema.Int;
117
+ readonly wrong: Schema.Int;
118
+ }>>;
119
+ readonly kind: Schema.Literal<"wrongParts">;
81
120
  }>]>;
82
121
  /** A rule that one item sets for one of its interactions, instead of the default. */
83
122
  export declare const ScoringOverrideSchema: Schema.Struct<{
@@ -89,6 +128,12 @@ export declare const ScoringOverrideSchema: Schema.Struct<{
89
128
  readonly kind: Schema.Literal<"perPart">;
90
129
  readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
91
130
  readonly pointsPerPart: Schema.Int;
131
+ }>, Schema.Struct<{
132
+ readonly bands: Schema.NonEmptyArray<Schema.Struct<{
133
+ readonly points: Schema.Int;
134
+ readonly wrong: Schema.Int;
135
+ }>>;
136
+ readonly kind: Schema.Literal<"wrongParts">;
92
137
  }>, Schema.Struct<{
93
138
  readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
94
139
  readonly id: Schema.String;
@@ -109,13 +154,21 @@ export type ScoringOverride = typeof ScoringOverrideSchema.Type;
109
154
  * interaction, and only a per-part rule reads it.
110
155
  */
111
156
  export declare function scoreCeiling(rule: ScoringRule, parts: number): number;
157
+ /**
158
+ * Returns the points that a wrong-parts table gives an answer with this many
159
+ * wrong parts: the points of the first band that holds it, or 0 when none does.
160
+ * It reads the table alone, never a learner's answer: grading an answer is the
161
+ * work of Nakafa's engine.
162
+ */
163
+ export declare function pointsForWrongParts(rule: WrongPartsRule, wrongParts: number): number;
112
164
  /**
113
165
  * Checks that a rule can score an interaction of this kind. A rubric scores an
114
166
  * extended text and nothing else, and an extended text takes no other rule. A
115
167
  * field has one part, worth the points of its rule: one point, or more when
116
168
  * the item is worth more. The floor of a rule per part is at most those
117
- * points. Every other kind has the parts that its key counts, so the key checks
118
- * the floor of a rule for those.
169
+ * points, and a wrong-parts table has one band for no wrong part. Every other
170
+ * kind has the parts that its key counts, so the key checks the floor of a rule
171
+ * for those.
119
172
  */
120
173
  export declare function supportsRule(kind: InteractionKind, rule: ScoringRule): boolean;
121
174
  /**
@@ -1,4 +1,4 @@
1
- import { Array as Arr, Match, Schema } from "effect";
1
+ import { Array as Arr, Match, Option, Schema } from "effect";
2
2
  import { hasUniqueIds, LocalIdSchema } from "#contracts/assessment/identity";
3
3
  import { canSitInText, } from "#contracts/assessment/interaction";
4
4
  import { LocalizedTextSchema, NonNegativeIntSchema, PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
@@ -30,6 +30,40 @@ export const PerPartRuleSchema = Schema.Struct({
30
30
  penaltyPerWrongPart: Schema.optionalKey(PositiveIntSchema),
31
31
  pointsPerPart: PositiveIntSchema,
32
32
  });
33
+ /** One band of a wrong-parts table: the points that an answer keeps with up to `wrong` wrong parts. */
34
+ const WrongPartsBandSchema = Schema.Struct({
35
+ points: PositiveIntSchema,
36
+ wrong: NonNegativeIntSchema,
37
+ });
38
+ /** Checks that the bands rise in wrong parts and fall in points, so each band is a step. */
39
+ function hasWrongPartsSteps(bands) {
40
+ return Arr.every(Arr.zip(bands, Arr.drop(bands, 1)), ([lower, higher]) => lower.wrong < higher.wrong && lower.points > higher.points);
41
+ }
42
+ /**
43
+ * Points by the number of wrong parts, such as the AKM rule of a complex
44
+ * multiple choice with more than five statements and more than two options: 2
45
+ * points with no wrong part, 1 point with one or two, and 0 with more. An answer
46
+ * scores the points of the first band whose `wrong` is at least its number of
47
+ * wrong parts, and 0 when no band holds it. The parts are the ones the per-part
48
+ * rule counts, as the key defines them for each kind.
49
+ *
50
+ * It corresponds to no standard response processing template of QTI 3.
51
+ * `match_correct` gives 1 or 0 for the whole interaction. `map_response` maps
52
+ * each response value and sums the results. With one value for the correct parts
53
+ * and one for the wrong parts, each wrong part moves the score by the same step,
54
+ * and clamping the sum to its bounds flattens only its two ends. The table 2, 1,
55
+ * 1, 0 for 0 to 3 wrong parts has a flat step in the middle, so no sum over the
56
+ * parts gives it. Section 3.4.2 of the QTI 3 Best Practices and Implementation
57
+ * Guide says that a composite item needs general response processing, not a
58
+ * standard template. A table over the wrong parts is that kind of score, so it
59
+ * corresponds to the general response processing of that section.
60
+ */
61
+ export const WrongPartsRuleSchema = Schema.Struct({
62
+ bands: Schema.NonEmptyArray(WrongPartsBandSchema).check(Schema.makeFilter(hasWrongPartsSteps, {
63
+ message: "Expected the bands to rise in wrong parts and fall in points.",
64
+ })),
65
+ kind: Schema.Literal("wrongParts"),
66
+ });
33
67
  const RubricLevelSchema = Schema.Struct({
34
68
  id: LocalIdSchema,
35
69
  label: PlainTextSchema,
@@ -64,6 +98,7 @@ export const RubricRuleSchema = Schema.Struct({
64
98
  export const ScoringRuleSchema = Schema.Union([
65
99
  AllOrNothingRuleSchema,
66
100
  PerPartRuleSchema,
101
+ WrongPartsRuleSchema,
67
102
  RubricRuleSchema,
68
103
  ]);
69
104
  /**
@@ -73,6 +108,7 @@ export const ScoringRuleSchema = Schema.Union([
73
108
  export const DefaultRuleSchema = Schema.Union([
74
109
  AllOrNothingRuleSchema,
75
110
  PerPartRuleSchema,
111
+ WrongPartsRuleSchema,
76
112
  ]);
77
113
  /** A rule that one item sets for one of its interactions, instead of the default. */
78
114
  export const ScoringOverrideSchema = Schema.Struct({
@@ -93,26 +129,45 @@ export function scoreCeiling(rule, parts) {
93
129
  allOrNothing: () => 1,
94
130
  perPart: ({ pointsPerPart }) => pointsPerPart * parts,
95
131
  rubric: ({ criteria }) => Arr.reduce(criteria, 0, (total, criterion) => total + highestPoints(criterion)),
132
+ wrongParts: ({ bands }) => Arr.headNonEmpty(bands).points,
96
133
  }));
97
134
  }
98
135
  /**
99
- * Checks that the floor of a per-part rule is at most the points of a field.
100
- * A field has one part, so the points of the part are the most it can score.
136
+ * Returns the points that a wrong-parts table gives an answer with this many
137
+ * wrong parts: the points of the first band that holds it, or 0 when none does.
138
+ * It reads the table alone, never a learner's answer: grading an answer is the
139
+ * work of Nakafa's engine.
140
+ */
141
+ export function pointsForWrongParts(rule, wrongParts) {
142
+ return Arr.findFirst(rule.bands, ({ wrong }) => wrong >= wrongParts).pipe(Option.map(({ points }) => points), Option.getOrElse(() => 0));
143
+ }
144
+ /**
145
+ * Checks that a rule can score a field, which has one part. The floor of a
146
+ * per-part rule is at most the points of that part. A wrong-parts table has one
147
+ * band, for no wrong part, because a field has one part: any other band would
148
+ * award points for a wrong answer.
101
149
  */
102
- function hasFieldFloor(rule) {
103
- return rule.kind !== "perPart" || rule.floor <= scoreCeiling(rule, 1);
150
+ function fitsField(rule) {
151
+ if (rule.kind === "perPart") {
152
+ return rule.floor <= scoreCeiling(rule, 1);
153
+ }
154
+ if (rule.kind === "wrongParts") {
155
+ return rule.bands.length === 1 && Arr.headNonEmpty(rule.bands).wrong === 0;
156
+ }
157
+ return true;
104
158
  }
105
159
  /**
106
160
  * Checks that a rule can score an interaction of this kind. A rubric scores an
107
161
  * extended text and nothing else, and an extended text takes no other rule. A
108
162
  * field has one part, worth the points of its rule: one point, or more when
109
163
  * the item is worth more. The floor of a rule per part is at most those
110
- * points. Every other kind has the parts that its key counts, so the key checks
111
- * the floor of a rule for those.
164
+ * points, and a wrong-parts table has one band for no wrong part. Every other
165
+ * kind has the parts that its key counts, so the key checks the floor of a rule
166
+ * for those.
112
167
  */
113
168
  export function supportsRule(kind, rule) {
114
169
  return ((kind === "extendedText") === (rule.kind === "rubric") &&
115
- (!canSitInText(kind) || hasFieldFloor(rule)));
170
+ (!canSitInText(kind) || fitsField(rule)));
116
171
  }
117
172
  /**
118
173
  * Whole marks that a penalized exam awards for a correct, a wrong, and a blank
@@ -4,7 +4,7 @@ import { Schema } from "effect";
4
4
  * is a document that places no interaction.
5
5
  */
6
6
  export declare const StimulusVersionBodySchema: Schema.Struct<{
7
- deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
7
+ deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
8
8
  document: Schema.decodeTo<Schema.Struct<{
9
9
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
10
10
  readonly type: Schema.Literal<"doc">;
@@ -19,7 +19,7 @@ export declare const StimulusVersionBodySchema: Schema.Struct<{
19
19
  * `assessment/record`.
20
20
  */
21
21
  export declare const StimulusVersionSchema: Schema.Struct<{
22
- readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
22
+ readonly deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
23
23
  readonly document: Schema.decodeTo<Schema.Struct<{
24
24
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
25
25
  readonly type: Schema.Literal<"doc">;
@@ -36,7 +36,7 @@ export type StimulusVersion = typeof StimulusVersionSchema.Type;
36
36
  export declare const StimulusSchema: Schema.Struct<{
37
37
  readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">;
38
38
  readonly versions: Schema.NonEmptyArray<Schema.Struct<{
39
- readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
39
+ readonly deliveryLanguage: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
40
40
  readonly document: Schema.decodeTo<Schema.Struct<{
41
41
  readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
42
42
  readonly type: Schema.Literal<"doc">;
@@ -3,10 +3,10 @@ import { ContentDocumentSchema } from "#contracts/assessment/document";
3
3
  import { hasDistinctIds, StimulusIdSchema, } from "#contracts/assessment/identity";
4
4
  import { isWithinRecordLimit } from "#contracts/assessment/record";
5
5
  import { Sha256HashSchema } from "#contracts/ids";
6
- import { DeliveryLanguageSchema } from "#contracts/locale";
6
+ import { ContentLanguageSchema } from "#contracts/locale";
7
7
  /** The fields of a stimulus version except its hash, which covers all of them. */
8
8
  const VersionFields = {
9
- deliveryLanguage: DeliveryLanguageSchema,
9
+ deliveryLanguage: ContentLanguageSchema,
10
10
  document: ContentDocumentSchema,
11
11
  id: StimulusIdSchema,
12
12
  };
package/dist/locale.d.ts CHANGED
@@ -13,6 +13,15 @@ export declare function makeAppLocale<const Code extends AppLocaleCode>(code: Co
13
13
  /** Language delivered by content whose language may differ from the app shell. */
14
14
  export declare const DeliveryLanguageSchema: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
15
15
  export type DeliveryLanguage = typeof DeliveryLanguageSchema.Type;
16
+ /**
17
+ * A language of one assessment text, as a BCP 47 tag in its canonical form, such
18
+ * as `ar`, `de-CH`, or `zh-Hant-TW`. Unlike `DeliveryLanguageSchema`, it is not
19
+ * limited to the app locales, so a school can write in any language. The
20
+ * direction of a text is not stored: the renderer takes it from the script of
21
+ * each text.
22
+ */
23
+ export declare const ContentLanguageSchema: Schema.brand<Schema.String, "@NakafaAI/AksaraContentLanguage">;
24
+ export type ContentLanguage = typeof ContentLanguageSchema.Type;
16
25
  /** Locale identity of one immutable compiled content artifact. */
17
26
  export declare const ArtifactLocaleSchema: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
18
27
  export type ArtifactLocale = typeof ArtifactLocaleSchema.Type;
package/dist/locale.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Schema } from "effect";
1
+ import { Array as Arr, Option, Schema } from "effect";
2
2
  import { hasCanonicalOrder } from "#contracts/canonical";
3
3
  /** Stable locale codes supported by the current Aksara contract. */
4
4
  export const AppLocaleCodeSchema = Schema.Literals(["en", "id", "de"]);
@@ -16,6 +16,30 @@ export function makeAppLocale(code) {
16
16
  }
17
17
  /** Language delivered by content whose language may differ from the app shell. */
18
18
  export const DeliveryLanguageSchema = AppLocaleCodeSchema.pipe(Schema.brand("@NakafaAI/AksaraDeliveryLanguage"));
19
+ const CONTENT_LANGUAGE_BRAND = "@NakafaAI/AksaraContentLanguage";
20
+ /** Intl's canonical form of one language tag, or nothing when Intl rejects the tag. */
21
+ const canonicalLanguageTag = Option.liftThrowable((tag) => Intl.getCanonicalLocales(tag));
22
+ /**
23
+ * Explains why a string is not a content language. Intl must accept it, and it
24
+ * must already be the one canonical form that Intl writes for it. A tag that
25
+ * Intl rewrites names that form, so the author can correct it.
26
+ */
27
+ function contentLanguageIssue(tag) {
28
+ return Option.match(Option.flatMap(canonicalLanguageTag(tag), Arr.head), {
29
+ onNone: () => "Expected a well-formed BCP 47 language tag.",
30
+ onSome: (canonical) => canonical === tag
31
+ ? undefined
32
+ : `Expected the canonical language tag "${canonical}".`,
33
+ });
34
+ }
35
+ /**
36
+ * A language of one assessment text, as a BCP 47 tag in its canonical form, such
37
+ * as `ar`, `de-CH`, or `zh-Hant-TW`. Unlike `DeliveryLanguageSchema`, it is not
38
+ * limited to the app locales, so a school can write in any language. The
39
+ * direction of a text is not stored: the renderer takes it from the script of
40
+ * each text.
41
+ */
42
+ export const ContentLanguageSchema = Schema.String.pipe(Schema.check(Schema.makeFilter(contentLanguageIssue)), Schema.brand(CONTENT_LANGUAGE_BRAND));
19
43
  /** Locale identity of one immutable compiled content artifact. */
20
44
  export const ArtifactLocaleSchema = AppLocaleCodeSchema.pipe(Schema.brand("@NakafaAI/AksaraArtifactLocale"));
21
45
  /** Canonical locale order used by every active-locale subset. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakafa/aksara-contracts",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "description": "Schemas and verification contracts for Nakafa content releases.",
5
5
  "homepage": "https://github.com/nakafaai/aksara#readme",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -108,6 +108,10 @@
108
108
  "types": "./dist/assessment/item.d.ts",
109
109
  "import": "./dist/assessment/item.js"
110
110
  },
111
+ "./assessment/joint": {
112
+ "types": "./dist/assessment/joint.d.ts",
113
+ "import": "./dist/assessment/joint.js"
114
+ },
111
115
  "./assessment/key": {
112
116
  "types": "./dist/assessment/key.d.ts",
113
117
  "import": "./dist/assessment/key.js"