@nakafa/aksara-contracts 0.48.8 → 0.49.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/README.md +9 -0
- package/dist/assessment/choice.d.ts +154 -0
- package/dist/assessment/choice.js +87 -0
- package/dist/assessment/document.d.ts +219 -0
- package/dist/assessment/document.js +162 -0
- package/dist/assessment/entry.d.ts +50 -0
- package/dist/assessment/entry.js +48 -0
- package/dist/assessment/explanation.d.ts +19 -0
- package/dist/assessment/explanation.js +18 -0
- package/dist/assessment/figure.d.ts +1938 -0
- package/dist/assessment/figure.js +236 -0
- package/dist/assessment/fit.d.ts +21 -0
- package/dist/assessment/fit.js +42 -0
- package/dist/assessment/graphic.d.ts +95 -0
- package/dist/assessment/graphic.js +106 -0
- package/dist/assessment/hash.d.ts +1444 -0
- package/dist/assessment/hash.js +66 -0
- package/dist/assessment/identity.d.ts +37 -0
- package/dist/assessment/identity.js +50 -0
- package/dist/assessment/inline.d.ts +124 -0
- package/dist/assessment/inline.js +92 -0
- package/dist/assessment/interaction.d.ts +219 -0
- package/dist/assessment/interaction.js +38 -0
- package/dist/assessment/item.d.ts +759 -0
- package/dist/assessment/item.js +98 -0
- package/dist/assessment/key.d.ts +195 -0
- package/dist/assessment/key.js +136 -0
- package/dist/assessment/paper.d.ts +799 -0
- package/dist/assessment/paper.js +69 -0
- package/dist/assessment/part.d.ts +47 -0
- package/dist/assessment/part.js +32 -0
- package/dist/assessment/profile.d.ts +153 -0
- package/dist/assessment/profile.js +160 -0
- package/dist/assessment/record.d.ts +18 -0
- package/dist/assessment/record.js +27 -0
- package/dist/assessment/scalar.d.ts +18 -0
- package/dist/assessment/scalar.js +18 -0
- package/dist/assessment/scoring.d.ts +157 -0
- package/dist/assessment/scoring.js +150 -0
- package/dist/assessment/stimulus.d.ts +48 -0
- package/dist/assessment/stimulus.js +42 -0
- package/dist/assessment/structure.d.ts +13 -0
- package/dist/assessment/structure.js +29 -0
- package/dist/assessment/tools.d.ts +17 -0
- package/dist/assessment/tools.js +39 -0
- package/dist/projection/verify.d.ts +23 -23
- package/dist/release/current/evidence.d.ts +12 -12
- package/dist/release/current/state.d.ts +4 -4
- package/dist/release/lifecycle.d.ts +4 -4
- package/dist/release/spec.d.ts +49 -49
- package/dist/release/spec.js +12 -2
- package/dist/runtime/verify.d.ts +46 -46
- package/dist/transport/request.d.ts +138 -138
- package/dist/transport/response.d.ts +172 -172
- package/package.json +69 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type InteractionKind } from "#contracts/assessment/interaction";
|
|
3
|
+
/**
|
|
4
|
+
* All or nothing: category 1 for a fully correct answer and 0 for any other,
|
|
5
|
+
* so k is 1. It is `match_correct` of QTI response processing.
|
|
6
|
+
*
|
|
7
|
+
* Scoring is data. The outcome of an interaction is a score category from 0 to
|
|
8
|
+
* k, where k is the most points its rule can award, so a partial score can
|
|
9
|
+
* enter an IRT model through GPCM later.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AllOrNothingRuleSchema: Schema.Struct<{
|
|
12
|
+
readonly kind: Schema.Literal<"allOrNothing">;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Points for each correct part, an optional penalty for each wrong part, and a
|
|
16
|
+
* floor that the score never falls below. Because an outcome is a category
|
|
17
|
+
* from 0 to k, the floor is zero or more and at most k. A field has one part,
|
|
18
|
+
* so an item version and an exam profile check the floor of a field themselves
|
|
19
|
+
* (`supportsRule`); the key counts the parts of every other kind, so the check
|
|
20
|
+
* of those waits for the key. It is `map_response` of QTI response processing:
|
|
21
|
+
* a `qti-mapping` whose map entries are the correct parts, whose
|
|
22
|
+
* `default-value` is the negative of the penalty, and whose `lower-bound` is
|
|
23
|
+
* the floor.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PerPartRuleSchema: Schema.Struct<{
|
|
26
|
+
readonly floor: Schema.Int;
|
|
27
|
+
readonly kind: Schema.Literal<"perPart">;
|
|
28
|
+
readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
|
|
29
|
+
readonly pointsPerPart: Schema.Int;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Criteria, each with ordered levels and the points of each level. The learner
|
|
33
|
+
* sees the criteria and the level reached; what earns a level is a descriptor
|
|
34
|
+
* in the key. It is the rule of `qti-extended-text-interaction`, whose
|
|
35
|
+
* scoring QTI leaves to a person: `qti-rubric-block` with `use="scoring"`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RubricRuleSchema: Schema.Struct<{
|
|
38
|
+
readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
|
|
39
|
+
readonly id: Schema.String;
|
|
40
|
+
readonly label: Schema.Trimmed;
|
|
41
|
+
readonly levels: Schema.$Array<Schema.Struct<{
|
|
42
|
+
readonly id: Schema.String;
|
|
43
|
+
readonly label: Schema.Trimmed;
|
|
44
|
+
readonly points: Schema.Int;
|
|
45
|
+
}>>;
|
|
46
|
+
}>>;
|
|
47
|
+
readonly kind: Schema.Literal<"rubric">;
|
|
48
|
+
}>;
|
|
49
|
+
/** The rule that scores one interaction. */
|
|
50
|
+
export declare const ScoringRuleSchema: Schema.Union<readonly [Schema.Struct<{
|
|
51
|
+
readonly kind: Schema.Literal<"allOrNothing">;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly floor: Schema.Int;
|
|
54
|
+
readonly kind: Schema.Literal<"perPart">;
|
|
55
|
+
readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
|
|
56
|
+
readonly pointsPerPart: Schema.Int;
|
|
57
|
+
}>, Schema.Struct<{
|
|
58
|
+
readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
|
|
59
|
+
readonly id: Schema.String;
|
|
60
|
+
readonly label: Schema.Trimmed;
|
|
61
|
+
readonly levels: Schema.$Array<Schema.Struct<{
|
|
62
|
+
readonly id: Schema.String;
|
|
63
|
+
readonly label: Schema.Trimmed;
|
|
64
|
+
readonly points: Schema.Int;
|
|
65
|
+
}>>;
|
|
66
|
+
}>>;
|
|
67
|
+
readonly kind: Schema.Literal<"rubric">;
|
|
68
|
+
}>]>;
|
|
69
|
+
export type ScoringRule = typeof ScoringRuleSchema.Type;
|
|
70
|
+
/**
|
|
71
|
+
* A rule that an exam profile can set for every interaction of a kind. A
|
|
72
|
+
* rubric is never a default: its criteria belong to one item.
|
|
73
|
+
*/
|
|
74
|
+
export declare const DefaultRuleSchema: Schema.Union<readonly [Schema.Struct<{
|
|
75
|
+
readonly kind: Schema.Literal<"allOrNothing">;
|
|
76
|
+
}>, Schema.Struct<{
|
|
77
|
+
readonly floor: Schema.Int;
|
|
78
|
+
readonly kind: Schema.Literal<"perPart">;
|
|
79
|
+
readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
|
|
80
|
+
readonly pointsPerPart: Schema.Int;
|
|
81
|
+
}>]>;
|
|
82
|
+
/** A rule that one item sets for one of its interactions, instead of the default. */
|
|
83
|
+
export declare const ScoringOverrideSchema: Schema.Struct<{
|
|
84
|
+
readonly interaction: Schema.String;
|
|
85
|
+
readonly rule: Schema.Union<readonly [Schema.Struct<{
|
|
86
|
+
readonly kind: Schema.Literal<"allOrNothing">;
|
|
87
|
+
}>, Schema.Struct<{
|
|
88
|
+
readonly floor: Schema.Int;
|
|
89
|
+
readonly kind: Schema.Literal<"perPart">;
|
|
90
|
+
readonly penaltyPerWrongPart: Schema.optionalKey<Schema.Int>;
|
|
91
|
+
readonly pointsPerPart: Schema.Int;
|
|
92
|
+
}>, Schema.Struct<{
|
|
93
|
+
readonly criteria: Schema.NonEmptyArray<Schema.Struct<{
|
|
94
|
+
readonly id: Schema.String;
|
|
95
|
+
readonly label: Schema.Trimmed;
|
|
96
|
+
readonly levels: Schema.$Array<Schema.Struct<{
|
|
97
|
+
readonly id: Schema.String;
|
|
98
|
+
readonly label: Schema.Trimmed;
|
|
99
|
+
readonly points: Schema.Int;
|
|
100
|
+
}>>;
|
|
101
|
+
}>>;
|
|
102
|
+
readonly kind: Schema.Literal<"rubric">;
|
|
103
|
+
}>]>;
|
|
104
|
+
}>;
|
|
105
|
+
export type ScoringOverride = typeof ScoringOverrideSchema.Type;
|
|
106
|
+
/**
|
|
107
|
+
* Returns k, the most points a rule can award, which is the top score
|
|
108
|
+
* category. `parts` is the number of parts the key defines for the
|
|
109
|
+
* interaction, and only a per-part rule reads it.
|
|
110
|
+
*/
|
|
111
|
+
export declare function scoreCeiling(rule: ScoringRule, parts: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Checks that a rule can score an interaction of this kind. A rubric scores an
|
|
114
|
+
* extended text and nothing else, and an extended text takes no other rule. A
|
|
115
|
+
* field has one part, worth the points of its rule: one point, or more when
|
|
116
|
+
* 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.
|
|
119
|
+
*/
|
|
120
|
+
export declare function supportsRule(kind: InteractionKind, rule: ScoringRule): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whole marks that a penalized exam awards for a correct, a wrong, and a blank
|
|
123
|
+
* answer, such as +4, -1, and 0. A wrong answer costs marks, a blank never
|
|
124
|
+
* scores below a wrong answer, and a correct answer scores above a blank.
|
|
125
|
+
*/
|
|
126
|
+
export declare const MarksSchema: Schema.Struct<{
|
|
127
|
+
readonly blank: Schema.Int;
|
|
128
|
+
readonly correct: Schema.Int;
|
|
129
|
+
readonly wrong: Schema.Int;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* How an exam turns outcomes into a score. `irt` estimates ability from the
|
|
133
|
+
* outcomes, `raw` sums points, `penalized` adds marks for each outcome, and
|
|
134
|
+
* `composite` combines section scores by a formula that is written out for
|
|
135
|
+
* the reader in every language.
|
|
136
|
+
*/
|
|
137
|
+
export declare const ScoringStrategySchema: Schema.Union<readonly [Schema.Struct<{
|
|
138
|
+
readonly kind: Schema.Literal<"irt">;
|
|
139
|
+
}>, Schema.Struct<{
|
|
140
|
+
readonly kind: Schema.Literal<"raw">;
|
|
141
|
+
}>, Schema.Struct<{
|
|
142
|
+
readonly kind: Schema.Literal<"penalized">;
|
|
143
|
+
readonly marks: Schema.Struct<{
|
|
144
|
+
readonly blank: Schema.Int;
|
|
145
|
+
readonly correct: Schema.Int;
|
|
146
|
+
readonly wrong: Schema.Int;
|
|
147
|
+
}>;
|
|
148
|
+
}>, Schema.Struct<{
|
|
149
|
+
readonly formula: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.Trimmed>;
|
|
150
|
+
readonly kind: Schema.Literal<"composite">;
|
|
151
|
+
}>]>;
|
|
152
|
+
export type ScoringStrategy = typeof ScoringStrategySchema.Type;
|
|
153
|
+
/** The range of a reported score, such as 400 to 1600. */
|
|
154
|
+
export declare const ScoreScaleSchema: Schema.Struct<{
|
|
155
|
+
readonly maximum: Schema.Finite;
|
|
156
|
+
readonly minimum: Schema.Finite;
|
|
157
|
+
}>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Array as Arr, Match, Schema } from "effect";
|
|
2
|
+
import { hasUniqueIds, LocalIdSchema } from "#contracts/assessment/identity";
|
|
3
|
+
import { canSitInText, } from "#contracts/assessment/interaction";
|
|
4
|
+
import { LocalizedTextSchema, NonNegativeIntSchema, PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
|
|
5
|
+
/**
|
|
6
|
+
* All or nothing: category 1 for a fully correct answer and 0 for any other,
|
|
7
|
+
* so k is 1. It is `match_correct` of QTI response processing.
|
|
8
|
+
*
|
|
9
|
+
* Scoring is data. The outcome of an interaction is a score category from 0 to
|
|
10
|
+
* k, where k is the most points its rule can award, so a partial score can
|
|
11
|
+
* enter an IRT model through GPCM later.
|
|
12
|
+
*/
|
|
13
|
+
export const AllOrNothingRuleSchema = Schema.Struct({
|
|
14
|
+
kind: Schema.Literal("allOrNothing"),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Points for each correct part, an optional penalty for each wrong part, and a
|
|
18
|
+
* floor that the score never falls below. Because an outcome is a category
|
|
19
|
+
* from 0 to k, the floor is zero or more and at most k. A field has one part,
|
|
20
|
+
* so an item version and an exam profile check the floor of a field themselves
|
|
21
|
+
* (`supportsRule`); the key counts the parts of every other kind, so the check
|
|
22
|
+
* of those waits for the key. It is `map_response` of QTI response processing:
|
|
23
|
+
* a `qti-mapping` whose map entries are the correct parts, whose
|
|
24
|
+
* `default-value` is the negative of the penalty, and whose `lower-bound` is
|
|
25
|
+
* the floor.
|
|
26
|
+
*/
|
|
27
|
+
export const PerPartRuleSchema = Schema.Struct({
|
|
28
|
+
floor: NonNegativeIntSchema,
|
|
29
|
+
kind: Schema.Literal("perPart"),
|
|
30
|
+
penaltyPerWrongPart: Schema.optionalKey(PositiveIntSchema),
|
|
31
|
+
pointsPerPart: PositiveIntSchema,
|
|
32
|
+
});
|
|
33
|
+
const RubricLevelSchema = Schema.Struct({
|
|
34
|
+
id: LocalIdSchema,
|
|
35
|
+
label: PlainTextSchema,
|
|
36
|
+
points: NonNegativeIntSchema,
|
|
37
|
+
});
|
|
38
|
+
/** Checks that each level is worth more than the one below it. */
|
|
39
|
+
function hasAscendingPoints(levels) {
|
|
40
|
+
return Arr.every(Arr.zip(levels, Arr.drop(levels, 1)), ([lower, higher]) => lower.points < higher.points);
|
|
41
|
+
}
|
|
42
|
+
const RubricCriterionSchema = Schema.Struct({
|
|
43
|
+
id: LocalIdSchema,
|
|
44
|
+
label: PlainTextSchema,
|
|
45
|
+
levels: Schema.Array(RubricLevelSchema).check(Schema.isMinLength(2), Schema.makeFilter(hasUniqueIds, {
|
|
46
|
+
message: "Expected each level to have its own identifier.",
|
|
47
|
+
}), Schema.makeFilter(hasAscendingPoints, {
|
|
48
|
+
message: "Expected the points of the levels to ascend.",
|
|
49
|
+
})),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Criteria, each with ordered levels and the points of each level. The learner
|
|
53
|
+
* sees the criteria and the level reached; what earns a level is a descriptor
|
|
54
|
+
* in the key. It is the rule of `qti-extended-text-interaction`, whose
|
|
55
|
+
* scoring QTI leaves to a person: `qti-rubric-block` with `use="scoring"`.
|
|
56
|
+
*/
|
|
57
|
+
export const RubricRuleSchema = Schema.Struct({
|
|
58
|
+
criteria: Schema.NonEmptyArray(RubricCriterionSchema).check(Schema.makeFilter(hasUniqueIds, {
|
|
59
|
+
message: "Expected each criterion to have its own identifier.",
|
|
60
|
+
})),
|
|
61
|
+
kind: Schema.Literal("rubric"),
|
|
62
|
+
});
|
|
63
|
+
/** The rule that scores one interaction. */
|
|
64
|
+
export const ScoringRuleSchema = Schema.Union([
|
|
65
|
+
AllOrNothingRuleSchema,
|
|
66
|
+
PerPartRuleSchema,
|
|
67
|
+
RubricRuleSchema,
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* A rule that an exam profile can set for every interaction of a kind. A
|
|
71
|
+
* rubric is never a default: its criteria belong to one item.
|
|
72
|
+
*/
|
|
73
|
+
export const DefaultRuleSchema = Schema.Union([
|
|
74
|
+
AllOrNothingRuleSchema,
|
|
75
|
+
PerPartRuleSchema,
|
|
76
|
+
]);
|
|
77
|
+
/** A rule that one item sets for one of its interactions, instead of the default. */
|
|
78
|
+
export const ScoringOverrideSchema = Schema.Struct({
|
|
79
|
+
interaction: LocalIdSchema,
|
|
80
|
+
rule: ScoringRuleSchema,
|
|
81
|
+
});
|
|
82
|
+
/** Returns the points of the highest level of a criterion. */
|
|
83
|
+
function highestPoints(criterion) {
|
|
84
|
+
return Arr.reduce(criterion.levels, 0, (highest, { points }) => Math.max(highest, points));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns k, the most points a rule can award, which is the top score
|
|
88
|
+
* category. `parts` is the number of parts the key defines for the
|
|
89
|
+
* interaction, and only a per-part rule reads it.
|
|
90
|
+
*/
|
|
91
|
+
export function scoreCeiling(rule, parts) {
|
|
92
|
+
return Match.value(rule).pipe(Match.discriminatorsExhaustive("kind")({
|
|
93
|
+
allOrNothing: () => 1,
|
|
94
|
+
perPart: ({ pointsPerPart }) => pointsPerPart * parts,
|
|
95
|
+
rubric: ({ criteria }) => Arr.reduce(criteria, 0, (total, criterion) => total + highestPoints(criterion)),
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
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.
|
|
101
|
+
*/
|
|
102
|
+
function hasFieldFloor(rule) {
|
|
103
|
+
return rule.kind !== "perPart" || rule.floor <= scoreCeiling(rule, 1);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Checks that a rule can score an interaction of this kind. A rubric scores an
|
|
107
|
+
* extended text and nothing else, and an extended text takes no other rule. A
|
|
108
|
+
* field has one part, worth the points of its rule: one point, or more when
|
|
109
|
+
* 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.
|
|
112
|
+
*/
|
|
113
|
+
export function supportsRule(kind, rule) {
|
|
114
|
+
return ((kind === "extendedText") === (rule.kind === "rubric") &&
|
|
115
|
+
(!canSitInText(kind) || hasFieldFloor(rule)));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Whole marks that a penalized exam awards for a correct, a wrong, and a blank
|
|
119
|
+
* answer, such as +4, -1, and 0. A wrong answer costs marks, a blank never
|
|
120
|
+
* scores below a wrong answer, and a correct answer scores above a blank.
|
|
121
|
+
*/
|
|
122
|
+
export const MarksSchema = Schema.Struct({
|
|
123
|
+
blank: Schema.Int,
|
|
124
|
+
correct: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
125
|
+
wrong: Schema.Int.check(Schema.isLessThan(0)),
|
|
126
|
+
}).check(Schema.makeFilter(({ blank, correct, wrong }) => wrong <= blank && blank < correct, {
|
|
127
|
+
message: "Expected wrong marks at or below blank marks, and blank marks below correct marks.",
|
|
128
|
+
}));
|
|
129
|
+
/**
|
|
130
|
+
* How an exam turns outcomes into a score. `irt` estimates ability from the
|
|
131
|
+
* outcomes, `raw` sums points, `penalized` adds marks for each outcome, and
|
|
132
|
+
* `composite` combines section scores by a formula that is written out for
|
|
133
|
+
* the reader in every language.
|
|
134
|
+
*/
|
|
135
|
+
export const ScoringStrategySchema = Schema.Union([
|
|
136
|
+
Schema.Struct({ kind: Schema.Literal("irt") }),
|
|
137
|
+
Schema.Struct({ kind: Schema.Literal("raw") }),
|
|
138
|
+
Schema.Struct({ kind: Schema.Literal("penalized"), marks: MarksSchema }),
|
|
139
|
+
Schema.Struct({
|
|
140
|
+
formula: LocalizedTextSchema,
|
|
141
|
+
kind: Schema.Literal("composite"),
|
|
142
|
+
}),
|
|
143
|
+
]);
|
|
144
|
+
/** The range of a reported score, such as 400 to 1600. */
|
|
145
|
+
export const ScoreScaleSchema = Schema.Struct({
|
|
146
|
+
maximum: Schema.Finite,
|
|
147
|
+
minimum: Schema.Finite,
|
|
148
|
+
}).check(Schema.makeFilter(({ maximum, minimum }) => minimum < maximum, {
|
|
149
|
+
message: "Expected a scale whose minimum is below its maximum.",
|
|
150
|
+
}));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* One shared reading or figure in one delivery language, without its hash. It
|
|
4
|
+
* is a document that places no interaction.
|
|
5
|
+
*/
|
|
6
|
+
export declare const StimulusVersionBodySchema: Schema.Struct<{
|
|
7
|
+
deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
|
|
8
|
+
document: Schema.decodeTo<Schema.Struct<{
|
|
9
|
+
readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
|
|
10
|
+
readonly type: Schema.Literal<"doc">;
|
|
11
|
+
}>, Schema.Unknown, never, never>;
|
|
12
|
+
id: Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* A stimulus version is immutable once published: a change is a new version.
|
|
16
|
+
* Its `hash` is the SHA-256 of the canonical encoding of the body (see
|
|
17
|
+
* `assessment/hash`). Items use the version by identifier and hash and never
|
|
18
|
+
* copy its document into their prompts. Its size is limited by
|
|
19
|
+
* `assessment/record`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const StimulusVersionSchema: Schema.Struct<{
|
|
22
|
+
readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
|
|
23
|
+
readonly document: Schema.decodeTo<Schema.Struct<{
|
|
24
|
+
readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
|
|
25
|
+
readonly type: Schema.Literal<"doc">;
|
|
26
|
+
}>, Schema.Unknown, never, never>;
|
|
27
|
+
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">;
|
|
28
|
+
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
29
|
+
}>;
|
|
30
|
+
export type StimulusVersion = typeof StimulusVersionSchema.Type;
|
|
31
|
+
/**
|
|
32
|
+
* One stimulus with a version for each delivery language. Its identifier is
|
|
33
|
+
* namespaced, so two sets that both call a reading `passage-1` have two
|
|
34
|
+
* stimuli. A group of items uses one by reference and hash.
|
|
35
|
+
*/
|
|
36
|
+
export declare const StimulusSchema: Schema.Struct<{
|
|
37
|
+
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">;
|
|
38
|
+
readonly versions: Schema.NonEmptyArray<Schema.Struct<{
|
|
39
|
+
readonly deliveryLanguage: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraDeliveryLanguage">;
|
|
40
|
+
readonly document: Schema.decodeTo<Schema.Struct<{
|
|
41
|
+
readonly content: Schema.NonEmptyArray<Schema.Codec<import("#contracts/assessment/document").BlockNode, import("#contracts/assessment/document").BlockNode, never, never>>;
|
|
42
|
+
readonly type: Schema.Literal<"doc">;
|
|
43
|
+
}>, Schema.Unknown, never, never>;
|
|
44
|
+
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraStimulusId">;
|
|
45
|
+
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
46
|
+
}>>;
|
|
47
|
+
}>;
|
|
48
|
+
export type Stimulus = typeof StimulusSchema.Type;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { ContentDocumentSchema } from "#contracts/assessment/document";
|
|
3
|
+
import { hasDistinctIds, StimulusIdSchema, } from "#contracts/assessment/identity";
|
|
4
|
+
import { isWithinRecordLimit } from "#contracts/assessment/record";
|
|
5
|
+
import { Sha256HashSchema } from "#contracts/ids";
|
|
6
|
+
import { DeliveryLanguageSchema } from "#contracts/locale";
|
|
7
|
+
/** The fields of a stimulus version except its hash, which covers all of them. */
|
|
8
|
+
const VersionFields = {
|
|
9
|
+
deliveryLanguage: DeliveryLanguageSchema,
|
|
10
|
+
document: ContentDocumentSchema,
|
|
11
|
+
id: StimulusIdSchema,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* One shared reading or figure in one delivery language, without its hash. It
|
|
15
|
+
* is a document that places no interaction.
|
|
16
|
+
*/
|
|
17
|
+
export const StimulusVersionBodySchema = Schema.Struct(VersionFields);
|
|
18
|
+
/**
|
|
19
|
+
* A stimulus version is immutable once published: a change is a new version.
|
|
20
|
+
* Its `hash` is the SHA-256 of the canonical encoding of the body (see
|
|
21
|
+
* `assessment/hash`). Items use the version by identifier and hash and never
|
|
22
|
+
* copy its document into their prompts. Its size is limited by
|
|
23
|
+
* `assessment/record`.
|
|
24
|
+
*/
|
|
25
|
+
export const StimulusVersionSchema = StimulusVersionBodySchema.mapFields((fields) => ({ ...fields, hash: Sha256HashSchema }), { unsafePreserveChecks: true }).check(isWithinRecordLimit);
|
|
26
|
+
const StimulusFieldsSchema = Schema.Struct({
|
|
27
|
+
id: StimulusIdSchema,
|
|
28
|
+
versions: Schema.NonEmptyArray(StimulusVersionSchema),
|
|
29
|
+
});
|
|
30
|
+
/** Checks that every version names the stimulus, in a language of its own. */
|
|
31
|
+
function hasOwnVersions(stimulus) {
|
|
32
|
+
return (Arr.every(stimulus.versions, ({ id }) => id === stimulus.id) &&
|
|
33
|
+
hasDistinctIds(Arr.map(stimulus.versions, ({ deliveryLanguage }) => deliveryLanguage)));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One stimulus with a version for each delivery language. Its identifier is
|
|
37
|
+
* namespaced, so two sets that both call a reading `passage-1` have two
|
|
38
|
+
* stimuli. A group of items uses one by reference and hash.
|
|
39
|
+
*/
|
|
40
|
+
export const StimulusSchema = StimulusFieldsSchema.check(Schema.makeFilter(hasOwnVersions, {
|
|
41
|
+
message: "Expected each version to name the stimulus, in a language of its own.",
|
|
42
|
+
}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Array as Arr } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a value without its words: every field in `LANGUAGE_FIELDS` is
|
|
4
|
+
* dropped at every depth, so what remains is identifiers, counts, bounds, and
|
|
5
|
+
* flags.
|
|
6
|
+
*/
|
|
7
|
+
export declare function structureOf(value: unknown): unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Checks that every value has the structure of the first. The structure of an
|
|
10
|
+
* interaction is what its answer key and its scoring rule are written
|
|
11
|
+
* against, so translations of one item may change words and never structure.
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasSameStructure(values: Arr.NonEmptyReadonlyArray<unknown>): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Array as Arr, Equal, HashSet, Predicate, Record as Rec } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* The fields that hold the words of a language: a label, a text alternative,
|
|
4
|
+
* and a unit. Everything else in an interaction is structure.
|
|
5
|
+
*/
|
|
6
|
+
const LANGUAGE_FIELDS = HashSet.make("alt", "label", "unit");
|
|
7
|
+
/**
|
|
8
|
+
* Returns a value without its words: every field in `LANGUAGE_FIELDS` is
|
|
9
|
+
* dropped at every depth, so what remains is identifiers, counts, bounds, and
|
|
10
|
+
* flags.
|
|
11
|
+
*/
|
|
12
|
+
export function structureOf(value) {
|
|
13
|
+
if (Arr.isArray(value)) {
|
|
14
|
+
return Arr.map(value, (part) => structureOf(part));
|
|
15
|
+
}
|
|
16
|
+
if (Predicate.isObject(value)) {
|
|
17
|
+
return Rec.map(Rec.filter(value, (_, key) => !HashSet.has(LANGUAGE_FIELDS, key)), (part) => structureOf(part));
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks that every value has the structure of the first. The structure of an
|
|
23
|
+
* interaction is what its answer key and its scoring rule are written
|
|
24
|
+
* against, so translations of one item may change words and never structure.
|
|
25
|
+
*/
|
|
26
|
+
export function hasSameStructure(values) {
|
|
27
|
+
const first = structureOf(Arr.headNonEmpty(values));
|
|
28
|
+
return Arr.every(values, (value) => Equal.equals(structureOf(value), first));
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* The calculators a section can offer. A section with none of them offers no
|
|
4
|
+
* calculator; "none" is the absence of every identifier here.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CalculatorToolSchema: Schema.Literals<readonly ["calculator-basic", "calculator-scientific", "calculator-graphing"]>;
|
|
7
|
+
/**
|
|
8
|
+
* The registry of player tools. A section of an exam profile enables tools by
|
|
9
|
+
* these identifiers: a calculator of one level, a formula sheet, an option
|
|
10
|
+
* eliminator, a highlighter, mark for review, notes, a line reader, zoom, hide
|
|
11
|
+
* timer, and text to speech.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ToolIdSchema: 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"]>;
|
|
14
|
+
export type ToolId = typeof ToolIdSchema.Type;
|
|
15
|
+
/** A set of tools: each once, and at most one calculator. */
|
|
16
|
+
export declare const ToolSetSchema: 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"]>>;
|
|
17
|
+
export type ToolSet = typeof ToolSetSchema.Type;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { hasDistinctIds } from "#contracts/assessment/identity";
|
|
3
|
+
/**
|
|
4
|
+
* The calculators a section can offer. A section with none of them offers no
|
|
5
|
+
* calculator; "none" is the absence of every identifier here.
|
|
6
|
+
*/
|
|
7
|
+
export const CalculatorToolSchema = Schema.Literals([
|
|
8
|
+
"calculator-basic",
|
|
9
|
+
"calculator-scientific",
|
|
10
|
+
"calculator-graphing",
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* The registry of player tools. A section of an exam profile enables tools by
|
|
14
|
+
* these identifiers: a calculator of one level, a formula sheet, an option
|
|
15
|
+
* eliminator, a highlighter, mark for review, notes, a line reader, zoom, hide
|
|
16
|
+
* timer, and text to speech.
|
|
17
|
+
*/
|
|
18
|
+
export const ToolIdSchema = Schema.Literals([
|
|
19
|
+
...CalculatorToolSchema.literals,
|
|
20
|
+
"formula-sheet",
|
|
21
|
+
"option-eliminator",
|
|
22
|
+
"highlighter",
|
|
23
|
+
"mark-for-review",
|
|
24
|
+
"notes",
|
|
25
|
+
"line-reader",
|
|
26
|
+
"zoom",
|
|
27
|
+
"hide-timer",
|
|
28
|
+
"text-to-speech",
|
|
29
|
+
]);
|
|
30
|
+
/** Checks that a set of tools offers at most one calculator. */
|
|
31
|
+
function hasOneCalculator(tools) {
|
|
32
|
+
return Arr.filter(tools, Schema.is(CalculatorToolSchema)).length <= 1;
|
|
33
|
+
}
|
|
34
|
+
/** A set of tools: each once, and at most one calculator. */
|
|
35
|
+
export const ToolSetSchema = Schema.Array(ToolIdSchema).check(Schema.makeFilter(hasDistinctIds, {
|
|
36
|
+
message: "Expected each tool once.",
|
|
37
|
+
}), Schema.makeFilter(hasOneCalculator, {
|
|
38
|
+
message: "Expected at most one calculator.",
|
|
39
|
+
}));
|
|
@@ -44,7 +44,11 @@ export type VerifiedContentProjections = typeof VerifiedContentProjectionsSchema
|
|
|
44
44
|
/** Strictly decodes a replayable canonical content projection stream. */
|
|
45
45
|
export declare function decodeContentProjections<E, R>(projections: Stream.Stream<unknown, E, R>): Stream.Stream<{
|
|
46
46
|
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
47
|
+
readonly articleRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
|
|
48
|
+
readonly articleSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleSlug">;
|
|
47
49
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
50
|
+
readonly category: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleCategory">;
|
|
51
|
+
readonly categoryRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
|
|
48
52
|
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
49
53
|
readonly graph: {
|
|
50
54
|
readonly alignmentId: string;
|
|
@@ -53,11 +57,9 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
|
|
|
53
57
|
readonly learningObjectId: string;
|
|
54
58
|
readonly lensId: string;
|
|
55
59
|
};
|
|
56
|
-
readonly materialKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialKey">;
|
|
57
|
-
readonly order: number;
|
|
58
60
|
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
59
|
-
readonly
|
|
60
|
-
readonly kind: "
|
|
61
|
+
readonly categoryTitle: string;
|
|
62
|
+
readonly kind: "article";
|
|
61
63
|
readonly metadata: {
|
|
62
64
|
readonly dateModified?: string;
|
|
63
65
|
readonly datePublished: string;
|
|
@@ -65,20 +67,23 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
|
|
|
65
67
|
readonly name: string;
|
|
66
68
|
}[];
|
|
67
69
|
readonly description?: string | undefined;
|
|
68
|
-
readonly searchTitle?: string;
|
|
69
|
-
readonly subject?: string | undefined;
|
|
70
70
|
readonly title: string;
|
|
71
71
|
};
|
|
72
|
+
readonly official: boolean;
|
|
72
73
|
readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
74
|
+
readonly references: readonly {
|
|
75
|
+
readonly authors: string;
|
|
76
|
+
readonly citation?: string | undefined;
|
|
77
|
+
readonly details?: string | undefined;
|
|
78
|
+
readonly publication?: string | undefined;
|
|
79
|
+
readonly title: string;
|
|
80
|
+
readonly url?: string | undefined;
|
|
81
|
+
readonly year: number;
|
|
82
|
+
}[];
|
|
73
83
|
readonly sitemap: true;
|
|
74
|
-
readonly topicTitle: string;
|
|
75
84
|
} | {
|
|
76
85
|
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
77
|
-
readonly articleRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
|
|
78
|
-
readonly articleSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleSlug">;
|
|
79
86
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
80
|
-
readonly category: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleCategory">;
|
|
81
|
-
readonly categoryRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
|
|
82
87
|
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
83
88
|
readonly graph: {
|
|
84
89
|
readonly alignmentId: string;
|
|
@@ -87,9 +92,11 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
|
|
|
87
92
|
readonly learningObjectId: string;
|
|
88
93
|
readonly lensId: string;
|
|
89
94
|
};
|
|
95
|
+
readonly materialKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialKey">;
|
|
96
|
+
readonly order: number;
|
|
90
97
|
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
91
|
-
readonly
|
|
92
|
-
readonly kind: "
|
|
98
|
+
readonly sectionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialSection">;
|
|
99
|
+
readonly kind: "subject-lesson";
|
|
93
100
|
readonly metadata: {
|
|
94
101
|
readonly dateModified?: string;
|
|
95
102
|
readonly datePublished: string;
|
|
@@ -97,20 +104,13 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
|
|
|
97
104
|
readonly name: string;
|
|
98
105
|
}[];
|
|
99
106
|
readonly description?: string | undefined;
|
|
107
|
+
readonly searchTitle?: string;
|
|
108
|
+
readonly subject?: string | undefined;
|
|
100
109
|
readonly title: string;
|
|
101
110
|
};
|
|
102
|
-
readonly official: boolean;
|
|
103
111
|
readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
104
|
-
readonly references: readonly {
|
|
105
|
-
readonly authors: string;
|
|
106
|
-
readonly citation?: string | undefined;
|
|
107
|
-
readonly details?: string | undefined;
|
|
108
|
-
readonly publication?: string | undefined;
|
|
109
|
-
readonly title: string;
|
|
110
|
-
readonly url?: string | undefined;
|
|
111
|
-
readonly year: number;
|
|
112
|
-
}[];
|
|
113
112
|
readonly sitemap: true;
|
|
113
|
+
readonly topicTitle: string;
|
|
114
114
|
} | {
|
|
115
115
|
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
116
116
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|