@nakafa/aksara-contracts 6.5.0 → 7.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.
- package/dist/assessment/catalog.d.ts +18 -5
- package/dist/assessment/catalog.js +18 -8
- package/dist/assessment/choice.d.ts +10 -0
- package/dist/assessment/closure.d.ts +2 -1
- package/dist/assessment/closure.js +43 -62
- package/dist/assessment/document.d.ts +18 -0
- package/dist/assessment/document.js +10 -0
- package/dist/assessment/figure.d.ts +47605 -1555
- package/dist/assessment/figure.js +14 -217
- package/dist/assessment/hash.d.ts +274 -4
- package/dist/assessment/inline.d.ts +25 -0
- package/dist/assessment/inline.js +22 -3
- package/dist/assessment/interaction.d.ts +10 -0
- package/dist/assessment/item.d.ts +864 -0
- package/dist/assessment/item.js +10 -2
- package/dist/assessment/locales.d.ts +10 -0
- package/dist/assessment/locales.js +58 -0
- package/dist/assessment/paper.d.ts +1349 -12
- package/dist/assessment/paper.js +93 -9
- package/dist/assessment/part.d.ts +5 -0
- package/dist/assessment/profile.d.ts +4 -4
- package/dist/assessment/rows.d.ts +1409 -0
- package/dist/assessment/rows.js +44 -0
- package/dist/assessment/scalar.d.ts +1 -1
- package/dist/assessment/scoring.d.ts +1 -1
- package/dist/assessment/snapshot.d.ts +372 -20
- package/dist/assessment/structure.d.ts +6 -0
- package/dist/assessment/structure.js +22 -2
- package/dist/locale.d.ts +9 -9
- package/dist/locale.js +4 -3
- package/dist/program/snapshot/hash.d.ts +2 -2
- package/dist/program/snapshot/spec.d.ts +2 -2
- package/dist/projection/material.d.ts +10 -0
- package/dist/projection/material.js +1 -1
- package/dist/quran/attribution.d.ts +2 -2
- package/dist/quran/identity.d.ts +31 -10
- package/dist/quran/identity.js +15 -3
- package/dist/quran/provenance.d.ts +16 -16
- package/dist/quran/provenance.js +4 -1
- package/dist/quran/snapshot/hash.d.ts +2 -2
- package/dist/quran/snapshot/row/hash.d.ts +48 -15
- package/dist/quran/snapshot/row.d.ts +18 -8
- package/dist/quran/snapshot/spec.d.ts +2 -2
- package/dist/quran/source.d.ts +17 -7
- package/dist/quran/source.js +13 -1
- package/dist/quran/spec.d.ts +4 -4
- package/dist/quran/spec.js +2 -1
- package/dist/release/current/evidence.d.ts +9 -9
- package/dist/release/current/state.d.ts +11 -11
- package/dist/release/hash.d.ts +2 -2
- package/dist/release/identity.d.ts +1 -1
- package/dist/release/lifecycle.d.ts +7 -7
- package/dist/release/policy.d.ts +1 -1
- package/dist/release/snapshot/data.d.ts +36 -11
- package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
- package/dist/release/snapshot/evidence/program.d.ts +1 -1
- package/dist/release/snapshot/evidence/quran.d.ts +1 -1
- package/dist/release/snapshot/evidence.d.ts +3 -3
- package/dist/release/snapshot/verify.d.ts +179 -12
- package/dist/release/spec.d.ts +13 -13
- package/dist/release/verify.d.ts +2 -2
- package/dist/runtime/spec.d.ts +6 -6
- package/dist/runtime/verify.d.ts +4 -4
- package/dist/transport/group.d.ts +108 -33
- package/dist/transport/request.d.ts +1166 -114
- package/dist/transport/response.d.ts +64 -64
- package/dist/transport/snapshot.d.ts +72 -22
- package/dist/visual/base/layout.d.ts +27 -0
- package/dist/visual/base/layout.js +35 -0
- package/dist/visual/base/math.d.ts +523 -0
- package/dist/visual/base/math.js +72 -0
- package/dist/visual/base/media.d.ts +13 -0
- package/dist/visual/base/media.js +25 -0
- package/dist/visual/biology.d.ts +203 -0
- package/dist/visual/biology.js +108 -0
- package/dist/visual/card.d.ts +32 -0
- package/dist/visual/card.js +30 -0
- package/dist/visual/catalog.d.ts +28633 -0
- package/dist/visual/catalog.js +73 -0
- package/dist/visual/chemistry/atom.d.ts +79 -0
- package/dist/visual/chemistry/atom.js +109 -0
- package/dist/visual/chemistry/electron.d.ts +41 -0
- package/dist/visual/chemistry/electron.js +69 -0
- package/dist/visual/chemistry/laws.d.ts +86 -0
- package/dist/visual/chemistry/laws.js +117 -0
- package/dist/visual/chemistry/particles.d.ts +114 -0
- package/dist/visual/chemistry/particles.js +149 -0
- package/dist/visual/chemistry/periodic.d.ts +52 -0
- package/dist/visual/chemistry/periodic.js +85 -0
- package/dist/visual/chemistry/reaction.d.ts +60 -0
- package/dist/visual/chemistry/reaction.js +76 -0
- package/dist/visual/entry.d.ts +42 -0
- package/dist/visual/entry.js +48 -0
- package/dist/visual/mathematics/chart.d.ts +30 -0
- package/dist/{assessment → visual/mathematics}/chart.js +26 -18
- package/dist/visual/mathematics/charts.d.ts +118 -0
- package/dist/visual/mathematics/charts.js +100 -0
- package/dist/visual/mathematics/function.d.ts +82 -0
- package/dist/visual/mathematics/function.js +102 -0
- package/dist/visual/mathematics/geometry.d.ts +222 -0
- package/dist/visual/mathematics/geometry.js +81 -0
- package/dist/visual/mathematics/line.d.ts +179 -0
- package/dist/visual/mathematics/line.js +156 -0
- package/dist/visual/mathematics/number.d.ts +21 -0
- package/dist/visual/mathematics/number.js +53 -0
- package/dist/visual/physics/measurement.d.ts +66 -0
- package/dist/visual/physics/measurement.js +85 -0
- package/dist/visual/physics/motion.d.ts +85 -0
- package/dist/visual/physics/motion.js +110 -0
- package/dist/visual/physics/parabolic.d.ts +42 -0
- package/dist/visual/physics/parabolic.js +56 -0
- package/dist/visual/physics/velocity.d.ts +112 -0
- package/dist/visual/physics/velocity.js +144 -0
- package/dist/visual/politics.d.ts +92 -0
- package/dist/visual/politics.js +76 -0
- package/package.json +13 -5
- package/dist/assessment/chart.d.ts +0 -62
package/dist/assessment/paper.js
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
import { Array as Arr, Effect, Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Effect, HashMap, Option, Order, Schema } from "effect";
|
|
2
2
|
import { ExamProfileIdSchema, hasDistinctIds, ItemFamilyIdSchema, KebabKeySchema, PaperIdSchema, } from "#contracts/assessment/identity";
|
|
3
|
-
import { StimulusReferenceSchema, } from "#contracts/assessment/item";
|
|
3
|
+
import { StimulusReferenceSchema, versionStructure, } from "#contracts/assessment/item";
|
|
4
|
+
import { hasSameKeyStructure, hasSameStructure, } from "#contracts/assessment/structure";
|
|
4
5
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
5
|
-
|
|
6
|
+
import { ContentLanguageSchema } from "#contracts/locale";
|
|
7
|
+
/** One language of a place: the language a learner reads it in and that item version's hash. */
|
|
8
|
+
export const PlacedVersionSchema = Schema.Struct({
|
|
9
|
+
hash: Sha256HashSchema,
|
|
10
|
+
language: ContentLanguageSchema,
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* One place in a section: an item family and its version in each language of
|
|
14
|
+
* the section, in the section's order. A learner answers the place once, and
|
|
15
|
+
* may read it in any of those languages.
|
|
16
|
+
*/
|
|
6
17
|
export const PlacementSchema = Schema.Struct({
|
|
7
18
|
family: ItemFamilyIdSchema,
|
|
8
|
-
|
|
19
|
+
versions: Schema.NonEmptyArray(PlacedVersionSchema),
|
|
9
20
|
});
|
|
10
|
-
/**
|
|
21
|
+
/** Checks that every place of a section holds a version in each of its languages, in its order. */
|
|
22
|
+
function hasSectionLanguages(section) {
|
|
23
|
+
const languages = Arr.join(section.languages, ",");
|
|
24
|
+
return Arr.every(section.placements, ({ versions }) => Arr.join(Arr.map(versions, ({ language }) => language), ",") === languages);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One section of a paper: the key of a section of the profile, the languages
|
|
28
|
+
* its questions are written in, the first being the one a learner starts in,
|
|
29
|
+
* and its places in order.
|
|
30
|
+
*/
|
|
11
31
|
export const PaperSectionSchema = Schema.Struct({
|
|
32
|
+
languages: Schema.NonEmptyArray(ContentLanguageSchema).check(Schema.makeFilter(hasDistinctIds, {
|
|
33
|
+
message: "Expected each section language once.",
|
|
34
|
+
})),
|
|
12
35
|
placements: Schema.NonEmptyArray(PlacementSchema),
|
|
13
36
|
section: KebabKeySchema,
|
|
14
|
-
})
|
|
37
|
+
}).check(Schema.makeFilter(hasSectionLanguages, {
|
|
38
|
+
message: "Expected every place to hold a version in each language of its section, in its order.",
|
|
39
|
+
}));
|
|
15
40
|
/**
|
|
16
41
|
* Checks that no section, and no item, appears twice. An item takes one place
|
|
17
42
|
* in a paper, because a paper is written in the languages of its places.
|
|
@@ -22,7 +47,8 @@ function hasOnePlaceEach(paper) {
|
|
|
22
47
|
}
|
|
23
48
|
/**
|
|
24
49
|
* A frozen paper: the profile it follows, by identifier and hash; the sections
|
|
25
|
-
* with their places in order, each place an item
|
|
50
|
+
* with their languages and their places in order, each place an item family
|
|
51
|
+
* with its version in every language of the section;
|
|
26
52
|
* and the stimulus versions that the items use, by identifier and hash. A
|
|
27
53
|
* paper is frozen and named by its content hash. A paper bundle carries
|
|
28
54
|
* prompts and stimuli only, never an answer key and never an explanation. A
|
|
@@ -56,8 +82,8 @@ export class PaperStimuliMismatchError extends Schema.TaggedError()("PaperStimul
|
|
|
56
82
|
* Requires a paper to list the stimulus versions that its item versions use,
|
|
57
83
|
* each once, and no other: the paper names the readings it uses and its items
|
|
58
84
|
* name theirs, and the two must agree. `versions` are the item versions that
|
|
59
|
-
* the places of the paper name,
|
|
60
|
-
* frozen.
|
|
85
|
+
* the places of the paper name, every language of every place. Run it before
|
|
86
|
+
* the paper is frozen.
|
|
61
87
|
*/
|
|
62
88
|
export const verifyPaperStimuli = Effect.fn("AksaraContracts.verifyPaperStimuli")(function* (paper, versions) {
|
|
63
89
|
const used = Arr.dedupeWith(Arr.flatMap(versions, ({ stimulus }) => stimulus === undefined ? [] : [stimulus]), sameReference);
|
|
@@ -67,3 +93,61 @@ export const verifyPaperStimuli = Effect.fn("AksaraContracts.verifyPaperStimuli"
|
|
|
67
93
|
return yield* new PaperStimuliMismatchError({ missing, unused });
|
|
68
94
|
}
|
|
69
95
|
});
|
|
96
|
+
/** Why a place of a paper does not hold one item in every language of its section. */
|
|
97
|
+
export const PaperPlaceReasonSchema = Schema.Literals([
|
|
98
|
+
"key",
|
|
99
|
+
"structure",
|
|
100
|
+
"version",
|
|
101
|
+
]);
|
|
102
|
+
/**
|
|
103
|
+
* A place names a version that is not of its family or not in the language it
|
|
104
|
+
* claims (`version`), its versions differ in more than words (`structure`), or
|
|
105
|
+
* their answer keys do (`key`).
|
|
106
|
+
*/
|
|
107
|
+
export class PaperPlaceMismatchError extends Schema.TaggedError()("PaperPlaceMismatchError", {
|
|
108
|
+
family: ItemFamilyIdSchema,
|
|
109
|
+
reason: PaperPlaceReasonSchema,
|
|
110
|
+
}) {
|
|
111
|
+
}
|
|
112
|
+
/** The answers of a key in the order of their interactions, as two languages are compared. */
|
|
113
|
+
function sortedAnswers(key) {
|
|
114
|
+
return Arr.sort(key.answers, Order.mapInput(Order.String, (answer) => answer.interaction));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Requires every place of a paper to hold one item in every language of its
|
|
118
|
+
* section: each placed version is of the place's family and written in the
|
|
119
|
+
* language it is placed for, the versions share one interaction structure, and
|
|
120
|
+
* their answer keys agree on every answer apart from the texts a learner may
|
|
121
|
+
* type and the words of a rubric. A learner answers a place once, so a switch
|
|
122
|
+
* of language never changes what is asked or how it is graded. `versions` and
|
|
123
|
+
* `keys` are the item versions and keys that the places name.
|
|
124
|
+
*/
|
|
125
|
+
export const verifyPaperPlaces = Effect.fn("AksaraContracts.verifyPaperPlaces")(function* (paper, versions, keys) {
|
|
126
|
+
const versionOf = HashMap.fromIterable(Arr.map(versions, (version) => [version.hash, version]));
|
|
127
|
+
const keyOf = HashMap.fromIterable(Arr.map(keys, (key) => [key.version, key]));
|
|
128
|
+
for (const { placements } of paper.sections) {
|
|
129
|
+
for (const { family, versions: placed } of placements) {
|
|
130
|
+
const found = Arr.getSomes(Arr.map(placed, ({ hash, language }) => Option.filter(HashMap.get(versionOf, hash), (version) => version.family === family &&
|
|
131
|
+
version.deliveryLanguage === language)));
|
|
132
|
+
if (!Arr.isReadonlyArrayNonEmpty(found) ||
|
|
133
|
+
found.length !== placed.length) {
|
|
134
|
+
return yield* new PaperPlaceMismatchError({
|
|
135
|
+
family,
|
|
136
|
+
reason: "version",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (!hasSameStructure(Arr.map(found, versionStructure))) {
|
|
140
|
+
return yield* new PaperPlaceMismatchError({
|
|
141
|
+
family,
|
|
142
|
+
reason: "structure",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const answers = Arr.getSomes(Arr.map(found, ({ hash }) => Option.map(HashMap.get(keyOf, hash), sortedAnswers)));
|
|
146
|
+
if (!Arr.isReadonlyArrayNonEmpty(answers) ||
|
|
147
|
+
answers.length !== found.length ||
|
|
148
|
+
!hasSameKeyStructure(answers)) {
|
|
149
|
+
return yield* new PaperPlaceMismatchError({ family, reason: "key" });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
@@ -22,6 +22,11 @@ export declare const TextPartSchema: Schema.Struct<{
|
|
|
22
22
|
readonly label: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
23
23
|
readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
24
24
|
readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
|
|
25
|
+
}>, Schema.Struct<{
|
|
26
|
+
readonly attrs: Schema.Struct<{
|
|
27
|
+
readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
|
|
28
|
+
}>;
|
|
29
|
+
readonly type: Schema.Literal<"highlight">;
|
|
25
30
|
}>, Schema.Struct<{
|
|
26
31
|
readonly attrs: Schema.Struct<{
|
|
27
32
|
readonly href: Schema.String;
|
|
@@ -8,7 +8,7 @@ export declare const SectionTemplateSchema: Schema.Struct<{
|
|
|
8
8
|
readonly id: Schema.String;
|
|
9
9
|
readonly interactions: Schema.NonEmptyArray<Schema.Union<[Schema.Literal<"choice"> | Schema.Literal<"extendedText"> | Schema.Literal<"gapMatch"> | Schema.Literal<"graphPoint"> | Schema.Literal<"hotspot"> | Schema.Literal<"inlineChoice"> | Schema.Literal<"match"> | Schema.Literal<"mathEntry"> | Schema.Literal<"matrix"> | Schema.Literal<"numericEntry"> | Schema.Literal<"order"> | Schema.Literal<"textEntry">, ...(Schema.Literal<"choice"> | Schema.Literal<"extendedText"> | Schema.Literal<"gapMatch"> | Schema.Literal<"graphPoint"> | Schema.Literal<"hotspot"> | Schema.Literal<"inlineChoice"> | Schema.Literal<"match"> | Schema.Literal<"mathEntry"> | Schema.Literal<"matrix"> | Schema.Literal<"numericEntry"> | Schema.Literal<"order"> | Schema.Literal<"textEntry">)[]]>>;
|
|
10
10
|
readonly items: Schema.Int;
|
|
11
|
-
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.Trimmed>;
|
|
11
|
+
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de", "ms"]>, Schema.Trimmed>;
|
|
12
12
|
readonly navigation: Schema.Literals<readonly ["free", "linear"]>;
|
|
13
13
|
readonly seconds: Schema.Int;
|
|
14
14
|
readonly tools: Schema.$Array<Schema.Literals<readonly ["calculator-basic", "calculator-scientific", "calculator-graphing", "formula-sheet", "option-eliminator", "highlighter", "mark-for-review", "notes", "line-reader", "zoom", "hide-timer", "text-to-speech"]>>;
|
|
@@ -105,7 +105,7 @@ export declare const ExamProfileSchema: Schema.Struct<{
|
|
|
105
105
|
*/
|
|
106
106
|
readonly graceSeconds: Schema.Int;
|
|
107
107
|
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraExamProfileId">;
|
|
108
|
-
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.Trimmed>;
|
|
108
|
+
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de", "ms"]>, Schema.Trimmed>;
|
|
109
109
|
readonly report: Schema.Struct<{
|
|
110
110
|
readonly sections: Schema.Boolean;
|
|
111
111
|
readonly standardError: Schema.Boolean;
|
|
@@ -134,14 +134,14 @@ export declare const ExamProfileSchema: Schema.Struct<{
|
|
|
134
134
|
readonly wrong: Schema.Int;
|
|
135
135
|
}>;
|
|
136
136
|
}>, Schema.Struct<{
|
|
137
|
-
readonly formula: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.Trimmed>;
|
|
137
|
+
readonly formula: Schema.$Record<Schema.Literals<readonly ["en", "id", "de", "ms"]>, Schema.Trimmed>;
|
|
138
138
|
readonly kind: Schema.Literal<"composite">;
|
|
139
139
|
}>]>;
|
|
140
140
|
readonly sections: Schema.NonEmptyArray<Schema.Struct<{
|
|
141
141
|
readonly id: Schema.String;
|
|
142
142
|
readonly interactions: Schema.NonEmptyArray<Schema.Union<[Schema.Literal<"choice"> | Schema.Literal<"extendedText"> | Schema.Literal<"gapMatch"> | Schema.Literal<"graphPoint"> | Schema.Literal<"hotspot"> | Schema.Literal<"inlineChoice"> | Schema.Literal<"match"> | Schema.Literal<"mathEntry"> | Schema.Literal<"matrix"> | Schema.Literal<"numericEntry"> | Schema.Literal<"order"> | Schema.Literal<"textEntry">, ...(Schema.Literal<"choice"> | Schema.Literal<"extendedText"> | Schema.Literal<"gapMatch"> | Schema.Literal<"graphPoint"> | Schema.Literal<"hotspot"> | Schema.Literal<"inlineChoice"> | Schema.Literal<"match"> | Schema.Literal<"mathEntry"> | Schema.Literal<"matrix"> | Schema.Literal<"numericEntry"> | Schema.Literal<"order"> | Schema.Literal<"textEntry">)[]]>>;
|
|
143
143
|
readonly items: Schema.Int;
|
|
144
|
-
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.Trimmed>;
|
|
144
|
+
readonly names: Schema.$Record<Schema.Literals<readonly ["en", "id", "de", "ms"]>, Schema.Trimmed>;
|
|
145
145
|
readonly navigation: Schema.Literals<readonly ["free", "linear"]>;
|
|
146
146
|
readonly seconds: Schema.Int;
|
|
147
147
|
readonly tools: Schema.$Array<Schema.Literals<readonly ["calculator-basic", "calculator-scientific", "calculator-graphing", "formula-sheet", "option-eliminator", "highlighter", "mark-for-review", "notes", "line-reader", "zoom", "hide-timer", "text-to-speech"]>>;
|