@nakafa/aksara-contracts 0.44.0 → 0.46.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 +4 -2
- package/dist/question/answer.d.ts +8 -0
- package/dist/question/answer.js +11 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,8 +38,10 @@ Current consumers use unversioned semantic Interfaces:
|
|
|
38
38
|
- `question/answer` owns deterministic short-answer and final-answer keys: an
|
|
39
39
|
exact canonical decimal with an optional tolerance and an explicit fraction
|
|
40
40
|
flag, or accepted text with explicit normalization rules. Every runtime
|
|
41
|
-
grades a typed answer only through `matchesAnswerKey`,
|
|
42
|
-
|
|
41
|
+
grades a typed answer only through `matchesAnswerKey`, reads a typed number
|
|
42
|
+
only through `readNumberAnswer`, the one number grammar, and decides that a
|
|
43
|
+
typed answer is blank only through `isBlankAnswer`, so whitespace and
|
|
44
|
+
invisible format characters alone never count as an answer.
|
|
43
45
|
- `question/rubric` owns the locale-neutral `QuestionRubricScaleSchema`
|
|
44
46
|
(ordered criteria and levels with points and optional final-answer keys)
|
|
45
47
|
and the Aksara rubric, which labels every criterion and level in every
|
|
@@ -75,6 +75,14 @@ export interface QuestionNumberAnswer {
|
|
|
75
75
|
readonly fraction: boolean;
|
|
76
76
|
readonly numerator: BigDecimal.BigDecimal;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks whether one typed learner answer is blank: nothing remains once it is
|
|
80
|
+
* read as visible text, so whitespace and invisible format characters alone
|
|
81
|
+
* are no answer. Every runtime decides whether a typed answer exists only
|
|
82
|
+
* through this check. A blank answer is unanswered, matches no key, and earns
|
|
83
|
+
* zero on every rubric criterion.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isBlankAnswer(answer: string): boolean;
|
|
78
86
|
/**
|
|
79
87
|
* Reads one typed learner number exactly, under the single grammar every
|
|
80
88
|
* runtime grades with. The input is first read as visible text, as for text
|
package/dist/question/answer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigDecimal, Option, Schema } from "effect";
|
|
1
|
+
import { BigDecimal, Option, Schema, String as Str } from "effect";
|
|
2
2
|
const DECIMAL_PATTERN = /^(?:0|-?[1-9]\d*|-?(?:0|[1-9]\d*)\.\d*[1-9])$/u;
|
|
3
3
|
const UNTYPABLE_CHARACTER_PATTERN = /[\p{Cc}\p{Cf}]|[^\S ]/u;
|
|
4
4
|
const FORMAT_CHARACTER_PATTERN = /\p{Cf}/gu;
|
|
@@ -144,6 +144,16 @@ function readFraction(typed) {
|
|
|
144
144
|
? Option.none()
|
|
145
145
|
: Option.some({ denominator, fraction: true, numerator }));
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Checks whether one typed learner answer is blank: nothing remains once it is
|
|
149
|
+
* read as visible text, so whitespace and invisible format characters alone
|
|
150
|
+
* are no answer. Every runtime decides whether a typed answer exists only
|
|
151
|
+
* through this check. A blank answer is unanswered, matches no key, and earns
|
|
152
|
+
* zero on every rubric criterion.
|
|
153
|
+
*/
|
|
154
|
+
export function isBlankAnswer(answer) {
|
|
155
|
+
return Str.isEmpty(visibleText(answer));
|
|
156
|
+
}
|
|
147
157
|
/**
|
|
148
158
|
* Reads one typed learner number exactly, under the single grammar every
|
|
149
159
|
* runtime grades with. The input is first read as visible text, as for text
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nakafa/aksara-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.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",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"directory": "packages/contracts"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"effect": "4.0.
|
|
24
|
+
"effect": "4.0.1"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
"./content": {
|