@nakafa/aksara-contracts 6.4.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 +30 -6
- package/dist/assessment/catalog.js +33 -10
- 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 +376 -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 +37 -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 +180 -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 +111 -33
- package/dist/transport/request.d.ts +1174 -114
- package/dist/transport/response.d.ts +64 -64
- package/dist/transport/snapshot.d.ts +74 -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array as Arr, Schema } from "effect";
|
|
2
2
|
import { hasDistinctIds } from "#contracts/assessment/identity";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { cardFields, TextSchema } from "#contracts/visual/card";
|
|
4
|
+
import { figure } from "#contracts/visual/entry";
|
|
5
5
|
/**
|
|
6
6
|
* One series of a chart: its name, whether it is drawn as bars or as a line,
|
|
7
7
|
* and one value for each category. A value is null where the series has no
|
|
@@ -9,7 +9,7 @@ import { PlainTextSchema } from "#contracts/assessment/scalar";
|
|
|
9
9
|
* some years.
|
|
10
10
|
*/
|
|
11
11
|
const ChartSeriesSchema = Schema.Struct({
|
|
12
|
-
label:
|
|
12
|
+
label: TextSchema,
|
|
13
13
|
mark: Schema.Literals(["bar", "line"]),
|
|
14
14
|
values: Schema.NonEmptyArray(Schema.NullOr(Schema.Finite)),
|
|
15
15
|
});
|
|
@@ -20,20 +20,26 @@ const ValueRangeSchema = Schema.Struct({
|
|
|
20
20
|
}).check(Schema.makeFilter(({ max, min }) => min < max, {
|
|
21
21
|
message: "Expected a value range whose minimum is below its maximum.",
|
|
22
22
|
}));
|
|
23
|
-
|
|
23
|
+
/** The data a chart relates: its bar placement, its categories, and its series. */
|
|
24
|
+
const ChartDataSchema = Schema.Struct({
|
|
24
25
|
/**
|
|
25
26
|
* How the bars of a chart that has bars stand: `apart` leaves a gap between
|
|
26
|
-
* neighboring categories, as a bar chart does, and `touching` closes it, as
|
|
27
|
-
* histogram of classes does. A chart of lines alone has no bars to place.
|
|
27
|
+
* neighboring categories, as a bar chart does, and `touching` closes it, as
|
|
28
|
+
* a histogram of classes does. A chart of lines alone has no bars to place.
|
|
28
29
|
*/
|
|
29
30
|
bars: Schema.optionalKey(Schema.Literals(["apart", "touching"])),
|
|
30
|
-
categories: Schema.NonEmptyArray(
|
|
31
|
-
description: RichTextSchema,
|
|
31
|
+
categories: Schema.NonEmptyArray(TextSchema),
|
|
32
32
|
series: Schema.NonEmptyArray(ChartSeriesSchema),
|
|
33
|
-
title: RichTextSchema,
|
|
34
|
-
valueLabel: Schema.optionalKey(PlainTextSchema),
|
|
35
|
-
valueRange: Schema.optionalKey(ValueRangeSchema),
|
|
36
33
|
});
|
|
34
|
+
/** The fields of a chart, before the checks that relate them. */
|
|
35
|
+
function chartFields(rich) {
|
|
36
|
+
return Schema.Struct({
|
|
37
|
+
...cardFields(rich),
|
|
38
|
+
...ChartDataSchema.fields,
|
|
39
|
+
valueLabel: Schema.optionalKey(TextSchema),
|
|
40
|
+
valueRange: Schema.optionalKey(ValueRangeSchema),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
37
43
|
/** Checks that every series has one value for each category, and at least one that is not null. */
|
|
38
44
|
function hasValuePerCategory(chart) {
|
|
39
45
|
return Arr.every(chart.series, ({ values }) => values.length === chart.categories.length &&
|
|
@@ -55,10 +61,12 @@ function hasBarPlacement(chart) {
|
|
|
55
61
|
* learner reads the same values that the figure draws. Every series has a
|
|
56
62
|
* name, because no meaning may ride on color alone.
|
|
57
63
|
*/
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
export function chartProps(rich) {
|
|
65
|
+
return figure(chartFields(rich).check(Schema.makeFilter(hasValuePerCategory, {
|
|
66
|
+
message: "Expected each series to have one value for each category, and at least one value.",
|
|
67
|
+
}), Schema.makeFilter(hasDistinctSeries, {
|
|
68
|
+
message: "Expected each series to have a name of its own.",
|
|
69
|
+
}), Schema.makeFilter(hasBarPlacement, {
|
|
70
|
+
message: "Expected a bar placement on a chart with bars, and on no other.",
|
|
71
|
+
})));
|
|
72
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type RichSlot } from "#contracts/visual/card";
|
|
3
|
+
/**
|
|
4
|
+
* The charts of data and functions. A regression line and its residuals are
|
|
5
|
+
* the result of fitting the points, so they are answer state; the data a chart
|
|
6
|
+
* draws is the question itself.
|
|
7
|
+
*/
|
|
8
|
+
export declare function chartVisuals<E>(rich: RichSlot<E>): {
|
|
9
|
+
BarChart: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
10
|
+
readonly description: RichSlot<E>;
|
|
11
|
+
readonly title: RichSlot<E>;
|
|
12
|
+
readonly chartConfig: Schema.$Record<Schema.Trimmed, Schema.Struct<{
|
|
13
|
+
readonly colors: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
14
|
+
readonly dark: Schema.optionalKey<Schema.$Array<Schema.Trimmed>>;
|
|
15
|
+
readonly light: Schema.$Array<Schema.Trimmed>;
|
|
16
|
+
}>, Schema.Struct<{
|
|
17
|
+
readonly dark: Schema.$Array<Schema.Trimmed>;
|
|
18
|
+
}>]>>;
|
|
19
|
+
readonly cue: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
20
|
+
readonly activeDot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
21
|
+
readonly dot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
22
|
+
readonly kind: Schema.Literal<"line">;
|
|
23
|
+
readonly strokeDasharray: Schema.optionalKey<Schema.Trimmed>;
|
|
24
|
+
}>, Schema.Struct<{
|
|
25
|
+
readonly activeDot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
26
|
+
readonly dot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
27
|
+
readonly kind: Schema.Literal<"point">;
|
|
28
|
+
}>, Schema.Struct<{
|
|
29
|
+
readonly kind: Schema.Literal<"bar">;
|
|
30
|
+
readonly radius: Schema.Finite;
|
|
31
|
+
readonly variant: Schema.Literals<readonly ["default", "hatched"]>;
|
|
32
|
+
}>]>>;
|
|
33
|
+
readonly label: Schema.optionalKey<RichSlot<E>>;
|
|
34
|
+
}>>;
|
|
35
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
36
|
+
readonly name: Schema.Trimmed;
|
|
37
|
+
readonly value: Schema.Finite;
|
|
38
|
+
}>>;
|
|
39
|
+
readonly yAxisLabel: Schema.Trimmed;
|
|
40
|
+
}>>;
|
|
41
|
+
Chart: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
42
|
+
readonly description: RichSlot<E>;
|
|
43
|
+
readonly title: RichSlot<E>;
|
|
44
|
+
readonly bars: Schema.optionalKey<Schema.Literals<readonly ["apart", "touching"]>>;
|
|
45
|
+
readonly categories: Schema.NonEmptyArray<Schema.Trimmed>;
|
|
46
|
+
readonly series: Schema.NonEmptyArray<Schema.Struct<{
|
|
47
|
+
readonly label: Schema.Trimmed;
|
|
48
|
+
readonly mark: Schema.Literals<readonly ["bar", "line"]>;
|
|
49
|
+
readonly values: Schema.NonEmptyArray<Schema.NullOr<Schema.Finite>>;
|
|
50
|
+
}>>;
|
|
51
|
+
readonly valueLabel: Schema.optionalKey<Schema.Trimmed>;
|
|
52
|
+
readonly valueRange: Schema.optionalKey<Schema.Struct<{
|
|
53
|
+
readonly max: Schema.Finite;
|
|
54
|
+
readonly min: Schema.Finite;
|
|
55
|
+
}>>;
|
|
56
|
+
}>>;
|
|
57
|
+
FunctionChart: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
58
|
+
readonly description: RichSlot<E>;
|
|
59
|
+
readonly title: RichSlot<E>;
|
|
60
|
+
readonly a: Schema.Finite;
|
|
61
|
+
readonly mode: Schema.optionalKey<Schema.Literals<readonly ["continuous", "discrete"]>>;
|
|
62
|
+
readonly n: Schema.optionalKey<Schema.Int>;
|
|
63
|
+
readonly p: Schema.Finite;
|
|
64
|
+
}>>;
|
|
65
|
+
HistogramChart: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
66
|
+
readonly description: RichSlot<E>;
|
|
67
|
+
readonly title: RichSlot<E>;
|
|
68
|
+
readonly chartConfig: Schema.$Record<Schema.Trimmed, Schema.Struct<{
|
|
69
|
+
readonly colors: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
70
|
+
readonly dark: Schema.optionalKey<Schema.$Array<Schema.Trimmed>>;
|
|
71
|
+
readonly light: Schema.$Array<Schema.Trimmed>;
|
|
72
|
+
}>, Schema.Struct<{
|
|
73
|
+
readonly dark: Schema.$Array<Schema.Trimmed>;
|
|
74
|
+
}>]>>;
|
|
75
|
+
readonly cue: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
76
|
+
readonly activeDot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
77
|
+
readonly dot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
78
|
+
readonly kind: Schema.Literal<"line">;
|
|
79
|
+
readonly strokeDasharray: Schema.optionalKey<Schema.Trimmed>;
|
|
80
|
+
}>, Schema.Struct<{
|
|
81
|
+
readonly activeDot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
82
|
+
readonly dot: Schema.Literals<readonly ["default", "border", "colored-border", "square", "square-border", "diamond", "diamond-border", "triangle", "triangle-border"]>;
|
|
83
|
+
readonly kind: Schema.Literal<"point">;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly kind: Schema.Literal<"bar">;
|
|
86
|
+
readonly radius: Schema.Finite;
|
|
87
|
+
readonly variant: Schema.Literals<readonly ["default", "hatched"]>;
|
|
88
|
+
}>]>>;
|
|
89
|
+
readonly label: Schema.optionalKey<RichSlot<E>>;
|
|
90
|
+
}>>;
|
|
91
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
92
|
+
readonly name: Schema.Trimmed;
|
|
93
|
+
readonly value: Schema.Finite;
|
|
94
|
+
}>>;
|
|
95
|
+
readonly yAxisLabel: Schema.Trimmed;
|
|
96
|
+
}>>;
|
|
97
|
+
ScatterDiagram: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
98
|
+
readonly description: RichSlot<E>;
|
|
99
|
+
readonly title: RichSlot<E>;
|
|
100
|
+
readonly calculateRegressionLine: Schema.optionalKey<Schema.Boolean>;
|
|
101
|
+
readonly datasets: Schema.$Array<Schema.Struct<{
|
|
102
|
+
readonly color: Schema.Trimmed;
|
|
103
|
+
readonly name: Schema.Trimmed;
|
|
104
|
+
readonly points: Schema.$Array<Schema.Struct<{
|
|
105
|
+
readonly x: Schema.Finite;
|
|
106
|
+
readonly y: Schema.Finite;
|
|
107
|
+
}>>;
|
|
108
|
+
}>>;
|
|
109
|
+
readonly regressionLineStyle: Schema.optionalKey<Schema.Struct<{
|
|
110
|
+
readonly color: Schema.optionalKey<Schema.Trimmed>;
|
|
111
|
+
readonly strokeDasharray: Schema.optionalKey<Schema.Trimmed>;
|
|
112
|
+
}>>;
|
|
113
|
+
readonly showResiduals: Schema.optionalKey<Schema.Boolean>;
|
|
114
|
+
readonly xAxisDomain: Schema.optionalKey<Schema.Literal<"min-max">>;
|
|
115
|
+
readonly xAxisLabel: Schema.optionalKey<Schema.Trimmed>;
|
|
116
|
+
readonly yAxisLabel: Schema.optionalKey<Schema.Trimmed>;
|
|
117
|
+
}>>;
|
|
118
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { cardFields, TextSchema } from "#contracts/visual/card";
|
|
3
|
+
import { answerAt, figure } from "#contracts/visual/entry";
|
|
4
|
+
import { chartProps } from "#contracts/visual/mathematics/chart";
|
|
5
|
+
/** How a chart marks a point of a line or a scatter. */
|
|
6
|
+
const DotSchema = Schema.Literals([
|
|
7
|
+
"default",
|
|
8
|
+
"border",
|
|
9
|
+
"colored-border",
|
|
10
|
+
"square",
|
|
11
|
+
"square-border",
|
|
12
|
+
"diamond",
|
|
13
|
+
"diamond-border",
|
|
14
|
+
"triangle",
|
|
15
|
+
"triangle-border",
|
|
16
|
+
]);
|
|
17
|
+
/** The cue that tells one series apart without its color: a line, points, or bars. */
|
|
18
|
+
const SeriesCueSchema = Schema.Union([
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
activeDot: DotSchema,
|
|
21
|
+
dot: DotSchema,
|
|
22
|
+
kind: Schema.Literal("line"),
|
|
23
|
+
strokeDasharray: Schema.optionalKey(TextSchema),
|
|
24
|
+
}),
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
activeDot: DotSchema,
|
|
27
|
+
dot: DotSchema,
|
|
28
|
+
kind: Schema.Literal("point"),
|
|
29
|
+
}),
|
|
30
|
+
Schema.Struct({
|
|
31
|
+
kind: Schema.Literal("bar"),
|
|
32
|
+
radius: Schema.Finite,
|
|
33
|
+
variant: Schema.Literals(["default", "hatched"]),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
/** The colors of one series in a light and a dark theme; at least one theme is set. */
|
|
37
|
+
const ThemeColorsSchema = Schema.Union([
|
|
38
|
+
Schema.Struct({
|
|
39
|
+
dark: Schema.optionalKey(Schema.Array(TextSchema)),
|
|
40
|
+
light: Schema.Array(TextSchema),
|
|
41
|
+
}),
|
|
42
|
+
Schema.Struct({ dark: Schema.Array(TextSchema) }),
|
|
43
|
+
]);
|
|
44
|
+
/** Props of `BarChart` and `HistogramChart`: one value for each named bar. */
|
|
45
|
+
function barChart(rich) {
|
|
46
|
+
return figure(Schema.Struct({
|
|
47
|
+
...cardFields(rich),
|
|
48
|
+
chartConfig: Schema.Record(TextSchema, Schema.Struct({
|
|
49
|
+
colors: Schema.optionalKey(ThemeColorsSchema),
|
|
50
|
+
cue: Schema.optionalKey(SeriesCueSchema),
|
|
51
|
+
label: Schema.optionalKey(rich),
|
|
52
|
+
})),
|
|
53
|
+
data: Schema.Array(Schema.Struct({ name: TextSchema, value: Schema.Finite })),
|
|
54
|
+
yAxisLabel: TextSchema,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/** Props of `ScatterDiagram`: named series of points, with an optional regression. */
|
|
58
|
+
function scatterDiagram(rich) {
|
|
59
|
+
return Schema.Struct({
|
|
60
|
+
...cardFields(rich),
|
|
61
|
+
calculateRegressionLine: Schema.optionalKey(Schema.Boolean),
|
|
62
|
+
datasets: Schema.Array(Schema.Struct({
|
|
63
|
+
color: TextSchema,
|
|
64
|
+
name: TextSchema,
|
|
65
|
+
points: Schema.Array(Schema.Struct({ x: Schema.Finite, y: Schema.Finite })),
|
|
66
|
+
})),
|
|
67
|
+
regressionLineStyle: Schema.optionalKey(Schema.Struct({
|
|
68
|
+
color: Schema.optionalKey(TextSchema),
|
|
69
|
+
strokeDasharray: Schema.optionalKey(TextSchema),
|
|
70
|
+
})),
|
|
71
|
+
showResiduals: Schema.optionalKey(Schema.Boolean),
|
|
72
|
+
xAxisDomain: Schema.optionalKey(Schema.Literal("min-max")),
|
|
73
|
+
xAxisLabel: Schema.optionalKey(TextSchema),
|
|
74
|
+
yAxisLabel: Schema.optionalKey(TextSchema),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Props of `FunctionChart`: the exponential model `p · aˣ` and its table. */
|
|
78
|
+
function functionChart(rich) {
|
|
79
|
+
return figure(Schema.Struct({
|
|
80
|
+
...cardFields(rich),
|
|
81
|
+
a: Schema.Finite.check(Schema.isGreaterThan(0)),
|
|
82
|
+
mode: Schema.optionalKey(Schema.Literals(["continuous", "discrete"])),
|
|
83
|
+
n: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(2))),
|
|
84
|
+
p: Schema.Finite,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The charts of data and functions. A regression line and its residuals are
|
|
89
|
+
* the result of fitting the points, so they are answer state; the data a chart
|
|
90
|
+
* draws is the question itself.
|
|
91
|
+
*/
|
|
92
|
+
export function chartVisuals(rich) {
|
|
93
|
+
return {
|
|
94
|
+
BarChart: barChart(rich),
|
|
95
|
+
Chart: chartProps(rich),
|
|
96
|
+
FunctionChart: functionChart(rich),
|
|
97
|
+
HistogramChart: barChart(rich),
|
|
98
|
+
ScatterDiagram: figure(scatterDiagram(rich), answerAt(["calculateRegressionLine"], ["showResiduals"])),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type RichSlot } from "#contracts/visual/card";
|
|
3
|
+
/**
|
|
4
|
+
* The visuals of functions, relations, and sequences. The output of the
|
|
5
|
+
* inverse machine is the value the reader would compute, so it is answer
|
|
6
|
+
* state. A diagram is a card around relation visualizers, its children, so
|
|
7
|
+
* it is markup, and an assessment places the visualizer itself as its figure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function functionVisuals<E>(rich: RichSlot<E>): {
|
|
10
|
+
BacterialGrowth: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
11
|
+
readonly formulaType: Schema.optionalKey<Schema.Literals<readonly ["geometric", "exponential"]>>;
|
|
12
|
+
readonly initialCount: Schema.optionalKey<Schema.Finite>;
|
|
13
|
+
readonly labels: Schema.optionalKey<Schema.Struct<{
|
|
14
|
+
readonly bacterial: Schema.optionalKey<Schema.Trimmed>;
|
|
15
|
+
readonly description: Schema.optionalKey<RichSlot<E>>;
|
|
16
|
+
readonly title: Schema.optionalKey<RichSlot<E>>;
|
|
17
|
+
}>>;
|
|
18
|
+
readonly maxGenerations: Schema.optionalKey<Schema.Int>;
|
|
19
|
+
readonly ratio: Schema.optionalKey<Schema.Finite>;
|
|
20
|
+
readonly timeInterval: Schema.optionalKey<Schema.Finite>;
|
|
21
|
+
readonly timeUnit: Schema.optionalKey<Schema.Trimmed>;
|
|
22
|
+
}>>;
|
|
23
|
+
FunctionAndNonFunctionDiagram: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
24
|
+
readonly description: RichSlot<E>;
|
|
25
|
+
readonly title: RichSlot<E>;
|
|
26
|
+
}>>;
|
|
27
|
+
FunctionAndNonFunctionRelationVisualizer: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
28
|
+
readonly accessibilityLabel: Schema.Trimmed;
|
|
29
|
+
readonly codomain: Schema.$Array<Schema.Struct<{
|
|
30
|
+
readonly id: Schema.Trimmed;
|
|
31
|
+
readonly label: RichSlot<E>;
|
|
32
|
+
}>>;
|
|
33
|
+
readonly codomainLabel: RichSlot<E>;
|
|
34
|
+
readonly domain: Schema.$Array<Schema.Struct<{
|
|
35
|
+
readonly id: Schema.Trimmed;
|
|
36
|
+
readonly label: RichSlot<E>;
|
|
37
|
+
}>>;
|
|
38
|
+
readonly domainLabel: RichSlot<E>;
|
|
39
|
+
readonly mappings: Schema.$Array<Schema.Struct<{
|
|
40
|
+
readonly from: Schema.Trimmed;
|
|
41
|
+
readonly to: Schema.Trimmed;
|
|
42
|
+
}>>;
|
|
43
|
+
}>>;
|
|
44
|
+
FunctionExplorationVirusChart: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
45
|
+
readonly labels: Schema.Struct<{
|
|
46
|
+
readonly caption: RichSlot<E>;
|
|
47
|
+
readonly description: RichSlot<E>;
|
|
48
|
+
readonly exponential: RichSlot<E>;
|
|
49
|
+
readonly linear: RichSlot<E>;
|
|
50
|
+
readonly logarithmic: RichSlot<E>;
|
|
51
|
+
readonly phase: Schema.Trimmed;
|
|
52
|
+
readonly title: RichSlot<E>;
|
|
53
|
+
readonly yLabel: Schema.Trimmed;
|
|
54
|
+
}>;
|
|
55
|
+
}>>;
|
|
56
|
+
FunctionMachine: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
57
|
+
readonly description: RichSlot<E>;
|
|
58
|
+
readonly title: RichSlot<E>;
|
|
59
|
+
readonly inputLabel: Schema.Trimmed;
|
|
60
|
+
}>>;
|
|
61
|
+
InverseFunctionIllustration: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
62
|
+
readonly description: RichSlot<E>;
|
|
63
|
+
readonly title: RichSlot<E>;
|
|
64
|
+
readonly content: Schema.Struct<{
|
|
65
|
+
readonly input: RichSlot<E>;
|
|
66
|
+
readonly output: RichSlot<E>;
|
|
67
|
+
}>;
|
|
68
|
+
readonly machineLabel: RichSlot<E>;
|
|
69
|
+
}>>;
|
|
70
|
+
SequenceConceptTableChairsAnimation: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
|
|
71
|
+
readonly labels: Schema.Struct<{
|
|
72
|
+
readonly chair: Schema.Trimmed;
|
|
73
|
+
readonly pause: Schema.Trimmed;
|
|
74
|
+
readonly play: Schema.Trimmed;
|
|
75
|
+
readonly reset: Schema.Trimmed;
|
|
76
|
+
readonly setSpeed: Schema.Trimmed;
|
|
77
|
+
readonly setTableCount: Schema.Trimmed;
|
|
78
|
+
readonly table: Schema.Trimmed;
|
|
79
|
+
readonly title: RichSlot<E>;
|
|
80
|
+
}>;
|
|
81
|
+
}>>;
|
|
82
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { cardFields, TextSchema } from "#contracts/visual/card";
|
|
3
|
+
import { answerAt, figure, markup } from "#contracts/visual/entry";
|
|
4
|
+
/** The ways the bacterial growth animation counts generations. */
|
|
5
|
+
const GROWTH_FORMULAS = ["geometric", "exponential"];
|
|
6
|
+
/** One element of a set in a relation diagram: an identifier and its label. */
|
|
7
|
+
function relationElement(rich) {
|
|
8
|
+
return Schema.Struct({ id: TextSchema, label: rich });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Props of `FunctionAndNonFunctionDiagram`: the card around one or more
|
|
12
|
+
* relation visualizers, which are its children.
|
|
13
|
+
*/
|
|
14
|
+
function functionDiagram(rich) {
|
|
15
|
+
return markup(Schema.Struct({ ...cardFields(rich) }));
|
|
16
|
+
}
|
|
17
|
+
/** Props of `FunctionAndNonFunctionRelationVisualizer`: arrows from a domain to a codomain. */
|
|
18
|
+
function relationVisualizer(rich) {
|
|
19
|
+
return figure(Schema.Struct({
|
|
20
|
+
accessibilityLabel: TextSchema,
|
|
21
|
+
codomain: Schema.Array(relationElement(rich)),
|
|
22
|
+
codomainLabel: rich,
|
|
23
|
+
domain: Schema.Array(relationElement(rich)),
|
|
24
|
+
domainLabel: rich,
|
|
25
|
+
mappings: Schema.Array(Schema.Struct({ from: TextSchema, to: TextSchema })),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/** Props of `FunctionMachine`: an input that a machine turns into an output. */
|
|
29
|
+
function functionMachine(rich) {
|
|
30
|
+
return figure(Schema.Struct({ ...cardFields(rich), inputLabel: TextSchema }));
|
|
31
|
+
}
|
|
32
|
+
/** Props of `InverseFunctionIllustration`: a machine run forward and back. */
|
|
33
|
+
function inverseIllustration(rich) {
|
|
34
|
+
return figure(Schema.Struct({
|
|
35
|
+
...cardFields(rich),
|
|
36
|
+
content: Schema.Struct({ input: rich, output: rich }),
|
|
37
|
+
machineLabel: rich,
|
|
38
|
+
}), answerAt(["content", "output"]));
|
|
39
|
+
}
|
|
40
|
+
/** Props of `FunctionExplorationVirusChart`: linear, exponential, and logarithmic spread. */
|
|
41
|
+
function virusChart(rich) {
|
|
42
|
+
return figure(Schema.Struct({
|
|
43
|
+
labels: Schema.Struct({
|
|
44
|
+
caption: rich,
|
|
45
|
+
description: rich,
|
|
46
|
+
exponential: rich,
|
|
47
|
+
linear: rich,
|
|
48
|
+
logarithmic: rich,
|
|
49
|
+
phase: TextSchema,
|
|
50
|
+
title: rich,
|
|
51
|
+
yLabel: TextSchema,
|
|
52
|
+
}),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/** Props of `BacterialGrowth`: cells that split once in each time interval. */
|
|
56
|
+
function bacterialGrowth(rich) {
|
|
57
|
+
return figure(Schema.Struct({
|
|
58
|
+
formulaType: Schema.optionalKey(Schema.Literals(GROWTH_FORMULAS)),
|
|
59
|
+
initialCount: Schema.optionalKey(Schema.Finite),
|
|
60
|
+
labels: Schema.optionalKey(Schema.Struct({
|
|
61
|
+
bacterial: Schema.optionalKey(TextSchema),
|
|
62
|
+
description: Schema.optionalKey(rich),
|
|
63
|
+
title: Schema.optionalKey(rich),
|
|
64
|
+
})),
|
|
65
|
+
maxGenerations: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
66
|
+
ratio: Schema.optionalKey(Schema.Finite),
|
|
67
|
+
timeInterval: Schema.optionalKey(Schema.Finite),
|
|
68
|
+
timeUnit: Schema.optionalKey(TextSchema),
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
/** Props of `SequenceConceptTableChairsAnimation`: tables in a row and the chairs around them. */
|
|
72
|
+
function tableChairs(rich) {
|
|
73
|
+
return figure(Schema.Struct({
|
|
74
|
+
labels: Schema.Struct({
|
|
75
|
+
chair: TextSchema,
|
|
76
|
+
pause: TextSchema,
|
|
77
|
+
play: TextSchema,
|
|
78
|
+
reset: TextSchema,
|
|
79
|
+
setSpeed: TextSchema,
|
|
80
|
+
setTableCount: TextSchema,
|
|
81
|
+
table: TextSchema,
|
|
82
|
+
title: rich,
|
|
83
|
+
}),
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The visuals of functions, relations, and sequences. The output of the
|
|
88
|
+
* inverse machine is the value the reader would compute, so it is answer
|
|
89
|
+
* state. A diagram is a card around relation visualizers, its children, so
|
|
90
|
+
* it is markup, and an assessment places the visualizer itself as its figure.
|
|
91
|
+
*/
|
|
92
|
+
export function functionVisuals(rich) {
|
|
93
|
+
return {
|
|
94
|
+
BacterialGrowth: bacterialGrowth(rich),
|
|
95
|
+
FunctionAndNonFunctionDiagram: functionDiagram(rich),
|
|
96
|
+
FunctionAndNonFunctionRelationVisualizer: relationVisualizer(rich),
|
|
97
|
+
FunctionExplorationVirusChart: virusChart(rich),
|
|
98
|
+
FunctionMachine: functionMachine(rich),
|
|
99
|
+
InverseFunctionIllustration: inverseIllustration(rich),
|
|
100
|
+
SequenceConceptTableChairsAnimation: tableChairs(rich),
|
|
101
|
+
};
|
|
102
|
+
}
|