cognikit 0.1.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/LICENSE +21 -0
- package/README.md +316 -0
- package/dist/core/BaseInteraction.d.ts +78 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/utilities/ProgressTracker.d.ts +58 -0
- package/dist/core/utilities/ScoringTracker.d.ts +0 -0
- package/dist/core/utilities/index.d.ts +1 -0
- package/dist/engines/index.d.ts +2 -0
- package/dist/engines/tables/implementation/graders.d.ts +23 -0
- package/dist/engines/tables/implementation/index.d.ts +4 -0
- package/dist/engines/tables/implementation/parsers.d.ts +36 -0
- package/dist/engines/tables/implementation/utils.d.ts +18 -0
- package/dist/engines/tables/implementation/validators.d.ts +9 -0
- package/dist/engines/tables/index.d.ts +2 -0
- package/dist/engines/tables/script.d.ts +37 -0
- package/dist/engines/text/implementation/graders.d.ts +69 -0
- package/dist/engines/text/implementation/index.d.ts +3 -0
- package/dist/engines/text/implementation/parsers.d.ts +9 -0
- package/dist/engines/text/implementation/validators.d.ts +41 -0
- package/dist/engines/text/index.d.ts +2 -0
- package/dist/engines/text/script.d.ts +56 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4518 -0
- package/dist/index.js.map +7 -0
- package/dist/interactions/adjacency-table/index.d.ts +26 -0
- package/dist/interactions/categorize-the-words/index.d.ts +2 -0
- package/dist/interactions/categorize-the-words/sequential.d.ts +33 -0
- package/dist/interactions/categorize-the-words/static.d.ts +22 -0
- package/dist/interactions/classification-matrix/index.d.ts +31 -0
- package/dist/interactions/fill-blanks/index.d.ts +2 -0
- package/dist/interactions/fill-blanks/sequential.d.ts +32 -0
- package/dist/interactions/fill-blanks/static.d.ts +23 -0
- package/dist/interactions/index.d.ts +17 -0
- package/dist/interactions/list-recall/implementation/grader.d.ts +0 -0
- package/dist/interactions/list-recall/implementation/index.d.ts +0 -0
- package/dist/interactions/list-recall/implementation/parser.d.ts +0 -0
- package/dist/interactions/list-recall/implementation/validator.d.ts +0 -0
- package/dist/interactions/list-recall/index.d.ts +1 -0
- package/dist/interactions/list-recall/script.d.ts +25 -0
- package/dist/interactions/lookup-table/index.d.ts +26 -0
- package/dist/interactions/mark-the-words/index.d.ts +2 -0
- package/dist/interactions/mark-the-words/sequential.d.ts +34 -0
- package/dist/interactions/mark-the-words/static.d.ts +40 -0
- package/dist/interactions/mcq-mrq/implementation/grader.d.ts +20 -0
- package/dist/interactions/mcq-mrq/implementation/index.d.ts +3 -0
- package/dist/interactions/mcq-mrq/implementation/parser.d.ts +21 -0
- package/dist/interactions/mcq-mrq/implementation/validator.d.ts +17 -0
- package/dist/interactions/mcq-mrq/index.d.ts +2 -0
- package/dist/interactions/mcq-mrq/script.d.ts +37 -0
- package/dist/interactions/nary-choice-table/index.d.ts +28 -0
- package/dist/interactions/open-classification/index.d.ts +32 -0
- package/dist/interactions/rank-order/implementation/grader.d.ts +15 -0
- package/dist/interactions/rank-order/implementation/index.d.ts +3 -0
- package/dist/interactions/rank-order/implementation/parser.d.ts +25 -0
- package/dist/interactions/rank-order/implementation/validator.d.ts +3 -0
- package/dist/interactions/rank-order/index.d.ts +2 -0
- package/dist/interactions/rank-order/script.d.ts +39 -0
- package/dist/interactions/register-builtins.d.ts +1 -0
- package/dist/interactions/registry.d.ts +30 -0
- package/dist/interactions/sequential-classification/index.d.ts +49 -0
- package/dist/interactions/shared/association-implementation/grader.d.ts +3 -0
- package/dist/interactions/shared/association-implementation/index.d.ts +1 -0
- package/dist/interactions/shared/association-implementation/parser.d.ts +0 -0
- package/dist/interactions/shared/association-implementation/validator.d.ts +0 -0
- package/dist/interactions/shared/classification-implementation/grader.d.ts +3 -0
- package/dist/interactions/shared/classification-implementation/index.d.ts +1 -0
- package/dist/interactions/shared/classification-implementation/parser.d.ts +11 -0
- package/dist/interactions/shared/classification-implementation/validator.d.ts +3 -0
- package/dist/interactions/simultaneous-association/index.d.ts +34 -0
- package/dist/interactions/text-transformation/index.d.ts +2 -0
- package/dist/interactions/text-transformation/sequential.d.ts +37 -0
- package/dist/interactions/text-transformation/static.d.ts +47 -0
- package/dist/shared/assets.d.ts +6 -0
- package/dist/shared/dsl.d.ts +9 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/managers/AnimationsManager.d.ts +55 -0
- package/dist/shared/managers/SoundManager.d.ts +78 -0
- package/dist/shared/managers/index.d.ts +3 -0
- package/dist/shared/types.d.ts +25 -0
- package/dist/shared/utils.d.ts +13 -0
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/simple-shell/index.d.ts +1 -0
- package/dist/shell/simple-shell/script.d.ts +61 -0
- package/dist/types/Assets.d.ts +40 -0
- package/dist/types/Data.d.ts +32 -0
- package/dist/types/Global.d.ts +24 -0
- package/dist/types/Grading.d.ts +8 -0
- package/dist/types/Input.d.ts +35 -0
- package/dist/types/Interactions.d.ts +28 -0
- package/dist/types/Tables.d.ts +40 -0
- package/dist/types/Text.d.ts +125 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/input/color/color-picker.d.ts +37 -0
- package/dist/ui/input/color/index.d.ts +0 -0
- package/dist/ui/input/index.d.ts +1 -0
- package/dist/ui/input/input/index.d.ts +1 -0
- package/dist/ui/input/input/input.d.ts +22 -0
- package/dist/ui/input/letter/index.d.ts +0 -0
- package/dist/ui/input/letter/letter-picker.d.ts +27 -0
- package/dist/ui/misc/block.d.ts +14 -0
- package/dist/ui/misc/chip/chip.d.ts +46 -0
- package/dist/ui/misc/chip/index.d.ts +1 -0
- package/dist/ui/misc/dialog.d.ts +24 -0
- package/dist/ui/misc/index.d.ts +4 -0
- package/dist/ui/misc/media.d.ts +54 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yahir Adolfo de los Santos Beras
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# COGNIKIT
|
|
2
|
+
|
|
3
|
+
A TypesScript framework for creating cognitively-grounded assessment systems, quizzes and interactive educationally-oriented exercises.
|
|
4
|
+
It is built on research in assessment design, psycometrics and cognitive science, while not limiting itself from implementing from casual
|
|
5
|
+
environments like classrooms (the author, *me*, is a teacher), and being flexible enough to be used in other contexts like games, articles,
|
|
6
|
+
and more.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
'Cognikit' provides a structured approach to building educational assessments while aligning them with specific cognitive processes, a curated list
|
|
13
|
+
of the later which are suitable for simple implementations anywhere and do not require "heavy machinery" to do so.
|
|
14
|
+
|
|
15
|
+
Key end-use features:
|
|
16
|
+
|
|
17
|
+
- **Simple authoring for each interaction**
|
|
18
|
+
- **Validators to enforce constraints over the data passed to the interactions**
|
|
19
|
+
- **Utility Components**
|
|
20
|
+
- **Engines for unique tools**
|
|
21
|
+
- **Styling variations supporting components**
|
|
22
|
+
- **Grading utilities**
|
|
23
|
+
|
|
24
|
+
Key development features:
|
|
25
|
+
|
|
26
|
+
- **One dependency**
|
|
27
|
+
- **Uses vanilla web technologies (and typescript)**
|
|
28
|
+
- **Strongly typed system**
|
|
29
|
+
- **Modular Arquitecture**
|
|
30
|
+
- **Mixes up OOP and FP**
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Take a look at the file structure to also visualize some of the features mentioned:
|
|
35
|
+
|
|
36
|
+
```txt
|
|
37
|
+
src/
|
|
38
|
+
// base *abstract* class which is used for all other interactions.
|
|
39
|
+
// It itself depends on the *shell* custom component at @shell
|
|
40
|
+
core/
|
|
41
|
+
BaseInteraction.ts
|
|
42
|
+
|
|
43
|
+
// modules which on themselves provide the *interactions*, more detailed later
|
|
44
|
+
modules/
|
|
45
|
+
classification/
|
|
46
|
+
discrimination/
|
|
47
|
+
recognition/
|
|
48
|
+
seriation/
|
|
49
|
+
comparison/
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
engines/
|
|
53
|
+
tables/
|
|
54
|
+
html/
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
// Custom base component that listens to the events of an interactions and triggers features like
|
|
58
|
+
// progress, radio navigation, check button, prompt visualization and timer.
|
|
59
|
+
shell/
|
|
60
|
+
base/
|
|
61
|
+
script.ts
|
|
62
|
+
|
|
63
|
+
ui/
|
|
64
|
+
input/
|
|
65
|
+
misc/
|
|
66
|
+
|
|
67
|
+
shared/
|
|
68
|
+
...
|
|
69
|
+
|
|
70
|
+
types/
|
|
71
|
+
Tables.ts
|
|
72
|
+
Grading.ts
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Each 'module' follow a designed pattern:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
modules/<process>/
|
|
79
|
+
module.ts // Central object that exports all features of the module
|
|
80
|
+
interactions/
|
|
81
|
+
<interaction>.ts // Classes that extend the *BaseInteraction* abstract class to create a unique way to complete an item
|
|
82
|
+
utilitits/
|
|
83
|
+
parser.ts
|
|
84
|
+
grader.ts
|
|
85
|
+
validator.ts
|
|
86
|
+
doc/
|
|
87
|
+
interactions.ts // Use the "IInteraction" interface and works as a programmatic documentation object
|
|
88
|
+
<process>.md // Research and justification of the 'conginitive process'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Architecture Overview
|
|
94
|
+
|
|
95
|
+
[https://sage-babka-680d4e.netlify.app]
|
|
96
|
+
|
|
97
|
+
### Common Patterns
|
|
98
|
+
|
|
99
|
+
There are built-in parsers that read a specific pattern in a string and generate the data for the interaction, but the data
|
|
100
|
+
can be generated in any other way and ultimatilely GUI forms are best for managing assets.
|
|
101
|
+
|
|
102
|
+
Check this example workflow (doesn't utilize assets):
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// *CLASSIFICATION* module 'DSL'
|
|
106
|
+
const data = `
|
|
107
|
+
AMERICA = DR | USA | Mexico;
|
|
108
|
+
ASIA = Thailand | PNG | India | Mongolia;
|
|
109
|
+
Africa = Madagascar | Kenya;
|
|
110
|
+
= Antartica | Greenland;
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
const parsedData = classificationParser(data);
|
|
114
|
+
const isValid = classificationValidator(parsedData);
|
|
115
|
+
|
|
116
|
+
if (isValid) {
|
|
117
|
+
console.log(parsedData);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Which would be equal to something like this:
|
|
121
|
+
* [
|
|
122
|
+
* { label: 'AMERICA', items: [ 'DR', 'USA', 'Mexico ] },
|
|
123
|
+
* { label: 'ASIA', items: [ 'Thailand', 'PNG', 'India', 'Mongolia' ] },
|
|
124
|
+
* { label: 'Africa', items: [ 'Madagascar' | 'Kenya' ] }
|
|
125
|
+
* ],
|
|
126
|
+
* [ 'Antartica', 'Greenland' ] -> These are distractors
|
|
127
|
+
*/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Example expected data objects
|
|
131
|
+
```ts
|
|
132
|
+
interface ClassificationData {
|
|
133
|
+
type: 'classification';
|
|
134
|
+
categories: { label: string; items: string[] }[];
|
|
135
|
+
distractors?: string[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface AssociationData {
|
|
139
|
+
type: 'association';
|
|
140
|
+
pairs: { left: string; right: string }[];
|
|
141
|
+
distractors?: string[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface FreeRecallData {
|
|
145
|
+
type: 'freerecall';
|
|
146
|
+
instructions: { prompt: string; words: string[] }[];
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## NOTES
|
|
151
|
+
|
|
152
|
+
1) Each module has a unique text-based way of representing their required data
|
|
153
|
+
2) Each data model is defined in the central types (@src/shared/types.ts)
|
|
154
|
+
3) While it's heavily focused on this method, the way to construct the data can be done in any other way, interactions are unrelated to those processes
|
|
155
|
+
4) ** The 'engines' use this pattern too, but the way to use them is different since they are stand-alone.**
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// example "interaction" that uses the *TABLES* engine
|
|
159
|
+
export class ClassificationMatrix extends BaseInteraction<BaseTableData> {
|
|
160
|
+
|
|
161
|
+
private _tableConfig: TableConfiguration;
|
|
162
|
+
private _$table!: EduTable;
|
|
163
|
+
|
|
164
|
+
constructor(options: InteractionOptions<BaseTableData>) {
|
|
165
|
+
super(options);
|
|
166
|
+
|
|
167
|
+
this._tableConfig = {
|
|
168
|
+
rows: this.data.rows,
|
|
169
|
+
cols: this.data.cols,
|
|
170
|
+
answerKey: this.data.answerKey,
|
|
171
|
+
cellKind: 'checkbox',
|
|
172
|
+
preset: 'classification',
|
|
173
|
+
variant: this.data.variant ?? 'outline'
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
this.initializeProgress(this.data.rows.length);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
render(): void {
|
|
180
|
+
const content = this.getContentArea();
|
|
181
|
+
|
|
182
|
+
this._$table = document.createElement('edu-table') as EduTable;
|
|
183
|
+
this._$table.config = this._tableConfig;
|
|
184
|
+
|
|
185
|
+
content.innerHTML = '';
|
|
186
|
+
content.append(this._$table);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
getCurrentState(): any {
|
|
190
|
+
return this._$table.getState();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
isInteractionComplete(): boolean {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Variant System
|
|
202
|
+
|
|
203
|
+
All custom components support a `variant` attribute for consistent theming:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
type Variant =
|
|
207
|
+
| 'elegant'
|
|
208
|
+
| 'playful'
|
|
209
|
+
| 'outline'
|
|
210
|
+
| 'letter'
|
|
211
|
+
| 'sign'
|
|
212
|
+
| 'minimal'
|
|
213
|
+
| 'glass'
|
|
214
|
+
| 'empty';
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Variants are applied via CSS host selectors:
|
|
218
|
+
|
|
219
|
+
```css
|
|
220
|
+
:host([variant="elegant"]) {
|
|
221
|
+
/* Elegant styling */
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
:host([variant="playful"]) {
|
|
225
|
+
/* Playful styling */
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### SPECIFICS
|
|
232
|
+
|
|
233
|
+
Most subdirectories that introduce some sort of system or important file provide a README.md that is to be read to get more insight on what it does and
|
|
234
|
+
how it works. This overview here provides a great general idea of how everything pretty much works, but reading specifics is also necessary.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
### Setup
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
pnpm install
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Scripts
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
pnpm dev # Watch mode with hot reload
|
|
250
|
+
pnpm build # Build library + types + demo
|
|
251
|
+
pnpm build:lib # Build library only
|
|
252
|
+
pnpm build:demo # Build demo app
|
|
253
|
+
pnpm types
|
|
254
|
+
pnpm serve
|
|
255
|
+
pnpm clean
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Build Configuration
|
|
259
|
+
|
|
260
|
+
- **Bundler**: esbuild
|
|
261
|
+
- **Module Format**: ESM
|
|
262
|
+
- **Platform**: Browser
|
|
263
|
+
- **Loaders**:
|
|
264
|
+
- `.html` files as text
|
|
265
|
+
- `.css` files as text
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Usage
|
|
270
|
+
|
|
271
|
+
### Creating a Module
|
|
272
|
+
|
|
273
|
+
1. Create directory: `src/modules/<process>/`
|
|
274
|
+
2. Implement parser, validator, grader in `utilities/`
|
|
275
|
+
3. Create interaction classes in `interactions/`
|
|
276
|
+
4. Define module metadata in `module.ts`
|
|
277
|
+
5. Document in `doc/`
|
|
278
|
+
|
|
279
|
+
### Creating an Interaction
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { BaseInteraction } from 'core';
|
|
283
|
+
import { InteractionOptions } from "types/interactions";
|
|
284
|
+
import { NormalizedAssets } from "shared/assets";
|
|
285
|
+
import { MyInteractionData } from "...";
|
|
286
|
+
|
|
287
|
+
export class MyInteraction extends BaseInteraction<MyDataType> {
|
|
288
|
+
|
|
289
|
+
constructor(data: MyInteractionData, config: InteractionConfig, assets?: NormalizedAssets) {
|
|
290
|
+
super(data, config, assets);
|
|
291
|
+
this.initializeProgress(/* total steps */);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
render(): void {
|
|
295
|
+
const content = this.getContentArea();
|
|
296
|
+
// Render interaction UI
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
getCurrentState(): any {
|
|
300
|
+
// Return current user state
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
isInteractionComplete(): boolean {
|
|
304
|
+
// Check completion status
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
protected submitForScoring(): void {
|
|
308
|
+
const state = this.getCurrentState();
|
|
309
|
+
// Grade and handle result
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Contributing
|
|
315
|
+
|
|
316
|
+
This is a research project in active development. Feedback and contributions welcome at the GitHub repository.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ProgressTracker } from "./utilities/ProgressTracker";
|
|
2
|
+
import { Variant } from "../shared/types";
|
|
3
|
+
import { Validator } from "../types/Global";
|
|
4
|
+
import { InteractionConfig, InteractionMechanic } from "../types/Interactions";
|
|
5
|
+
import { InteractionData } from "../types/Data";
|
|
6
|
+
import { NormalizedAssets } from "../types/Assets";
|
|
7
|
+
import { AnimationsManager, SoundManager } from "../shared/managers";
|
|
8
|
+
export type InteractionEventMap = {
|
|
9
|
+
'interaction:ready': CustomEvent<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>;
|
|
12
|
+
'interaction:progress': CustomEvent<{
|
|
13
|
+
current: number;
|
|
14
|
+
total: number;
|
|
15
|
+
percentage: number;
|
|
16
|
+
}>;
|
|
17
|
+
'interaction:state-change': CustomEvent<{
|
|
18
|
+
state: any;
|
|
19
|
+
isComplete: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
'interaction:complete': CustomEvent<{
|
|
22
|
+
state: any;
|
|
23
|
+
id: string;
|
|
24
|
+
}>;
|
|
25
|
+
'interaction:hint-shown': CustomEvent<{
|
|
26
|
+
message?: string;
|
|
27
|
+
}>;
|
|
28
|
+
'interaction:error': CustomEvent<{
|
|
29
|
+
error: Error;
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
export declare abstract class BaseInteraction<T extends InteractionData> extends HTMLElement {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
abstract readonly interactionMechanic: InteractionMechanic;
|
|
36
|
+
isValid: boolean;
|
|
37
|
+
implementsProgress: boolean;
|
|
38
|
+
protected data: T;
|
|
39
|
+
config: InteractionConfig;
|
|
40
|
+
protected assets: NormalizedAssets | null;
|
|
41
|
+
progressTracker: ProgressTracker;
|
|
42
|
+
protected animationsManager: AnimationsManager;
|
|
43
|
+
protected soundManager: SoundManager;
|
|
44
|
+
private _initialized;
|
|
45
|
+
errors: string;
|
|
46
|
+
constructor(data: T, config: InteractionConfig, assets?: NormalizedAssets | null, validator?: Validator);
|
|
47
|
+
connectedCallback(): void;
|
|
48
|
+
disconnectedCallback(): void;
|
|
49
|
+
abstract render(): void;
|
|
50
|
+
abstract getCurrentState(): any;
|
|
51
|
+
abstract isInteractionComplete(): boolean;
|
|
52
|
+
abstract onVariantChange(variant: Variant): void;
|
|
53
|
+
abstract onHint(): void;
|
|
54
|
+
protected initialize(): void;
|
|
55
|
+
protected cleanup(): void;
|
|
56
|
+
protected initializeProgress(total: number): void;
|
|
57
|
+
protected setProgress(current: number): void;
|
|
58
|
+
protected incrementProgress(): void;
|
|
59
|
+
protected decrementProgress(): void;
|
|
60
|
+
protected getProgress(): {
|
|
61
|
+
current: number;
|
|
62
|
+
total: number;
|
|
63
|
+
percentage: number;
|
|
64
|
+
};
|
|
65
|
+
private emitReady;
|
|
66
|
+
protected emitProgress(): void;
|
|
67
|
+
protected emitStateChange(): void;
|
|
68
|
+
protected emitComplete(): void;
|
|
69
|
+
protected emitHintShown(message?: string): void;
|
|
70
|
+
protected emitError(error: Error, message?: string): void;
|
|
71
|
+
onChange(newVariant: Variant): void;
|
|
72
|
+
setSteps(steps: number): void;
|
|
73
|
+
submit(): void;
|
|
74
|
+
hint(): void;
|
|
75
|
+
reset(): void;
|
|
76
|
+
set(variant: Variant): void;
|
|
77
|
+
get(): Variant;
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseInteraction } from "./BaseInteraction";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProgressTracker - Utility for tracking interaction progress
|
|
3
|
+
*
|
|
4
|
+
* Shell-agnostic progress tracking that can be used by any interaction.
|
|
5
|
+
* Maintains current/total state and calculates percentage.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const tracker = new ProgressTracker();
|
|
10
|
+
* tracker.initialize(10);
|
|
11
|
+
* tracker.increment(); // current = 1
|
|
12
|
+
* tracker.getPercentage(); // 10
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class ProgressTracker {
|
|
16
|
+
private _current;
|
|
17
|
+
_total: number;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize tracker with total number of items
|
|
20
|
+
*/
|
|
21
|
+
initialize(total: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Set current progress value
|
|
24
|
+
*/
|
|
25
|
+
setCurrent(value: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Increment progress by 1
|
|
28
|
+
*/
|
|
29
|
+
increment(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Decrement progress by 1
|
|
32
|
+
*/
|
|
33
|
+
decrement(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Reset progress to 0
|
|
36
|
+
*/
|
|
37
|
+
reset(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get progress percentage (0-100)
|
|
40
|
+
*/
|
|
41
|
+
getPercentage(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Check if progress is complete
|
|
44
|
+
*/
|
|
45
|
+
isComplete(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get current value
|
|
48
|
+
*/
|
|
49
|
+
get current(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get total value
|
|
52
|
+
*/
|
|
53
|
+
get total(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get remaining items
|
|
56
|
+
*/
|
|
57
|
+
get remaining(): number;
|
|
58
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressTracker } from './ProgressTracker';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TableCompletion, TableState } from "../../../types/Tables";
|
|
2
|
+
import { GradingResult } from "../../../types/Grading";
|
|
3
|
+
import { CellGradingState } from "../../../types/Tables";
|
|
4
|
+
export declare function naryTableGrader(answerKey: Map<string, string[]>, userData: TableCompletion, rows: string[]): GradingResult;
|
|
5
|
+
export declare function lookupTableGrader(answerKey: TableState, userData: TableCompletion, rows: string[], cols: string[]): GradingResult;
|
|
6
|
+
export declare function classificationTableGrader(answerKey: Map<string, string[]>, userData: TableCompletion, rows: string[], cols: string[]): GradingResult;
|
|
7
|
+
export declare function adjacencyTableGrader(answerKey: TableState, userData: TableCompletion, rows: string[]): GradingResult;
|
|
8
|
+
/**
|
|
9
|
+
* Generate per-cell grading state for adjacency tables
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAdjacencyCellGrading(answerKey: TableState, userData: TableCompletion, rows: string[]): CellGradingState;
|
|
12
|
+
/**
|
|
13
|
+
* Generate per-cell grading state for lookup tables
|
|
14
|
+
*/
|
|
15
|
+
export declare function getLookupCellGrading(answerKey: TableState, userData: TableCompletion, rows: string[], cols: string[]): CellGradingState;
|
|
16
|
+
/**
|
|
17
|
+
* Generate per-cell grading state for classification tables
|
|
18
|
+
*/
|
|
19
|
+
export declare function getClassificationCellGrading(answerKey: Map<string, string[]>, userData: TableCompletion, rows: string[], cols: string[]): CellGradingState;
|
|
20
|
+
/**
|
|
21
|
+
* Generate per-cell grading state for n-ary tables
|
|
22
|
+
*/
|
|
23
|
+
export declare function getNaryCellGrading(answerKey: Map<string, string[]>, userData: TableCompletion, rows: string[]): CellGradingState;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseTableData, ValueTableData } from "../../../types/Tables";
|
|
2
|
+
type ParseResult = {
|
|
3
|
+
data: BaseTableData;
|
|
4
|
+
errors?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
type ValueTableParseResult = {
|
|
7
|
+
data: ValueTableData;
|
|
8
|
+
errors?: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The classification table presents a default configuration where we have non-equal rows and columns and
|
|
12
|
+
* participant is presented with check boxes on each cell to add 'attributes' to each row item.
|
|
13
|
+
*
|
|
14
|
+
* The n-ary table is just a superset or the former, with the discrepancies being using radio buttons instead
|
|
15
|
+
* (single selection) and not allowing row items to be in more than one category (this is handled in the
|
|
16
|
+
* n-ary table validator).
|
|
17
|
+
*
|
|
18
|
+
* For grading, we take the row item and the checked columns. Using the answerKey, we check if those columns
|
|
19
|
+
* that were selected contain the row item; correct if yes, wrong otherwise. If there are mixed correct/wrong,
|
|
20
|
+
* we just fractionate the grading n/100, where n = correct items.
|
|
21
|
+
*
|
|
22
|
+
* Classification Example - Notice repetitions
|
|
23
|
+
*
|
|
24
|
+
* WORK = Talk with my colleagues | Eat | Report Attendance;
|
|
25
|
+
* SCHOOL = Eat | Complete my examns | Play in the basketball club;
|
|
26
|
+
* HOME = Eat | Talk with my colleagues | Sleep;
|
|
27
|
+
*
|
|
28
|
+
* N-ARY example
|
|
29
|
+
*
|
|
30
|
+
* TRUE = Water is Blue | An active volcano is hot;
|
|
31
|
+
* FALSE = MJ was a piano player | Africa is above Europe | A chef is someone who writes poems
|
|
32
|
+
*/
|
|
33
|
+
export declare function basicTableDataParser(code: string): ParseResult;
|
|
34
|
+
export declare function adjacencyTableDataParser(code: string): ValueTableParseResult;
|
|
35
|
+
export declare function lookupTableDataParser(code: string): ValueTableParseResult;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CellValue, CellKind, TableState } from "../../../types/Tables";
|
|
2
|
+
/**
|
|
3
|
+
* Extract all values from a TableState answer key
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAllValues(answerKey: TableState): CellValue[];
|
|
6
|
+
/**
|
|
7
|
+
* Get all unique values from a TableState answer key
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAllUniqueValues(answerKey: TableState): CellValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Auto-detect the best cell kind based on the values in the answer key
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectCellKind(values: CellValue[]): CellKind;
|
|
14
|
+
/**
|
|
15
|
+
* Compare two cell values for equality
|
|
16
|
+
* Handles string, number, and boolean comparisons
|
|
17
|
+
*/
|
|
18
|
+
export declare function compareValues(expected: CellValue, actual: CellValue): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseTableData, ValueTableData } from "../../../types/Tables";
|
|
2
|
+
type ValidationResult = {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
errors?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export declare function basicTableDataValidator(data: BaseTableData, preset?: 'classification' | 'n-ary'): ValidationResult;
|
|
7
|
+
export declare function adjacencyTableDataValidator(data: ValueTableData): ValidationResult;
|
|
8
|
+
export declare function lookupTableDataValidator(data: ValueTableData): ValidationResult;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TableConfiguration, TableState, CellGradingState, TableCompletion } from "../../types/Tables";
|
|
2
|
+
type EduTableElement = HTMLElement & {
|
|
3
|
+
config: TableConfiguration;
|
|
4
|
+
getValue(): TableState;
|
|
5
|
+
setValue(next: TableState): void;
|
|
6
|
+
getState(): TableCompletion;
|
|
7
|
+
reset(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare class EduTable extends HTMLElement implements EduTableElement {
|
|
10
|
+
private _config;
|
|
11
|
+
private _state;
|
|
12
|
+
private _mounted;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
private $wrapEl;
|
|
15
|
+
constructor();
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
set config(v: TableConfiguration);
|
|
19
|
+
get config(): TableConfiguration;
|
|
20
|
+
get value(): TableState;
|
|
21
|
+
set value(v: TableState);
|
|
22
|
+
getValue(): TableState;
|
|
23
|
+
setValue(next: TableState): void;
|
|
24
|
+
getState(): TableCompletion;
|
|
25
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
26
|
+
private initState;
|
|
27
|
+
private render;
|
|
28
|
+
private renderCell;
|
|
29
|
+
reset(): void;
|
|
30
|
+
setGradingState(gradingState: CellGradingState): void;
|
|
31
|
+
clearGradingState(): void;
|
|
32
|
+
private onChange;
|
|
33
|
+
private onInput;
|
|
34
|
+
private applyCellValue;
|
|
35
|
+
private emitChange;
|
|
36
|
+
}
|
|
37
|
+
export {};
|