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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SEQUENTIAL CLASSIFICATION - Classify items one at a time
|
|
3
|
+
*
|
|
4
|
+
* interaction mechanics inspired from
|
|
5
|
+
* @see https://learningapps.org
|
|
6
|
+
*/
|
|
7
|
+
import { BaseInteraction } from "../../core/BaseInteraction";
|
|
8
|
+
import { Variant } from "../../shared/types";
|
|
9
|
+
import { InteractionConfig, InteractionMechanic } from "../../types/Interactions";
|
|
10
|
+
import { NormalizedAssets } from "../../types/Assets";
|
|
11
|
+
import { ClassificationData } from "../../types/Data";
|
|
12
|
+
export declare class SequentialClassification extends BaseInteraction<ClassificationData> {
|
|
13
|
+
interactionMechanic: InteractionMechanic;
|
|
14
|
+
private categories;
|
|
15
|
+
private allItems;
|
|
16
|
+
private categorized;
|
|
17
|
+
private container;
|
|
18
|
+
private centerZone;
|
|
19
|
+
private zonesGrid;
|
|
20
|
+
private zones;
|
|
21
|
+
private chips;
|
|
22
|
+
private activeChip;
|
|
23
|
+
private currentZone;
|
|
24
|
+
private isDragging;
|
|
25
|
+
private startX;
|
|
26
|
+
private startY;
|
|
27
|
+
private offsetX;
|
|
28
|
+
private offsetY;
|
|
29
|
+
private boundPointerMove;
|
|
30
|
+
private boundPointerUp;
|
|
31
|
+
private variant;
|
|
32
|
+
constructor(data: ClassificationData, config: InteractionConfig, assets: NormalizedAssets | null);
|
|
33
|
+
protected initialize(): void;
|
|
34
|
+
protected cleanup(): void;
|
|
35
|
+
onVariantChange(newVariant: Variant): void;
|
|
36
|
+
render(): void;
|
|
37
|
+
private createDropZones;
|
|
38
|
+
private showNextChip;
|
|
39
|
+
private reparentChip;
|
|
40
|
+
private handlePointerDown;
|
|
41
|
+
private handlePointerMove;
|
|
42
|
+
private handlePointerUp;
|
|
43
|
+
private checkZoneOverlap;
|
|
44
|
+
getCurrentState(): any;
|
|
45
|
+
isInteractionComplete(): boolean;
|
|
46
|
+
onHint(): void;
|
|
47
|
+
submit(): void;
|
|
48
|
+
reset(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./grader";
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { classificationGrader } from "./grader";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ParsingResult } from "../../../shared";
|
|
2
|
+
/**
|
|
3
|
+
* Example
|
|
4
|
+
* ---
|
|
5
|
+
* RED FRUITS = apple | strawberry | cherry;
|
|
6
|
+
* Yellow Fruits = banana | pineapple | mango;
|
|
7
|
+
* Green Fruits = watermelon | avocado;
|
|
8
|
+
* = coconut | eggplant;
|
|
9
|
+
* ---
|
|
10
|
+
*/
|
|
11
|
+
export declare function classificationParser(code: string): ParsingResult;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseInteraction } from "../../core/BaseInteraction";
|
|
2
|
+
import { Variant } from "../../shared/types";
|
|
3
|
+
import { InteractionConfig, InteractionMechanic } from "../../types/Interactions";
|
|
4
|
+
import { NormalizedAssets } from "../../types/Assets";
|
|
5
|
+
import { AssociationData } from "../../types/Data";
|
|
6
|
+
type SimultaneousAssociationSpec = {
|
|
7
|
+
rightColumnLabel: string;
|
|
8
|
+
leftColumnLabel: string;
|
|
9
|
+
layoutDirection: 'vertical' | 'horizontal';
|
|
10
|
+
};
|
|
11
|
+
export declare class SimultaneousAssociation extends BaseInteraction<AssociationData> {
|
|
12
|
+
interactionMechanic: InteractionMechanic;
|
|
13
|
+
private leftItems;
|
|
14
|
+
private rightItems;
|
|
15
|
+
private matched;
|
|
16
|
+
private matchColors;
|
|
17
|
+
private currentSelected;
|
|
18
|
+
private currentEl;
|
|
19
|
+
private currentColor;
|
|
20
|
+
private $leftCol;
|
|
21
|
+
private $rightCol;
|
|
22
|
+
constructor(data: AssociationData, config: InteractionConfig, assets: NormalizedAssets | null, spec: SimultaneousAssociationSpec | null);
|
|
23
|
+
protected initialize(): void;
|
|
24
|
+
protected cleanup(): void;
|
|
25
|
+
onVariantChange(newVariant: Variant): void;
|
|
26
|
+
render(): void;
|
|
27
|
+
private renderItems;
|
|
28
|
+
getCurrentState(): any;
|
|
29
|
+
isInteractionComplete(): boolean;
|
|
30
|
+
onHint(): void;
|
|
31
|
+
submit(): void;
|
|
32
|
+
reset(): void;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseInteraction } from "../../core/BaseInteraction";
|
|
2
|
+
import { Variant } from "../../shared/types";
|
|
3
|
+
import { InteractionConfig, InteractionMechanic } from "../../types/Interactions";
|
|
4
|
+
import { GradingResult } from "../../types/Grading";
|
|
5
|
+
import { TextEngineSequentialInteractionData } from "../../types/Text";
|
|
6
|
+
export type SequentialTransformationExpectations = Record<number, Record<number, string[]>>;
|
|
7
|
+
export declare class SequentialTextTransformation extends BaseInteraction<TextEngineSequentialInteractionData> {
|
|
8
|
+
interactionMechanic: InteractionMechanic;
|
|
9
|
+
private _slides;
|
|
10
|
+
private _currentStep;
|
|
11
|
+
private _textConfig;
|
|
12
|
+
private _$text;
|
|
13
|
+
private _responses;
|
|
14
|
+
private _gradingByStep;
|
|
15
|
+
private _isGraded;
|
|
16
|
+
private _expectedByStep;
|
|
17
|
+
get slidesCount(): number;
|
|
18
|
+
constructor(data: TextEngineSequentialInteractionData, config: InteractionConfig, expectedByStep?: SequentialTransformationExpectations);
|
|
19
|
+
protected initialize(): void;
|
|
20
|
+
protected cleanup(): void;
|
|
21
|
+
onVariantChange(newVariant: Variant): void;
|
|
22
|
+
setSteps(stepIndex: number): void;
|
|
23
|
+
render(): void;
|
|
24
|
+
private getTotalTargetCount;
|
|
25
|
+
private buildDefaultExpectations;
|
|
26
|
+
private getExpectedForStep;
|
|
27
|
+
private saveCurrentStepResponse;
|
|
28
|
+
private getResponseForStep;
|
|
29
|
+
private updateProgressAcrossSteps;
|
|
30
|
+
getCurrentState(): any;
|
|
31
|
+
isInteractionComplete(): boolean;
|
|
32
|
+
onHint(): void;
|
|
33
|
+
grade(): GradingResult;
|
|
34
|
+
submit(): void;
|
|
35
|
+
reset(): void;
|
|
36
|
+
setExpectedTransformationsByStep(expectedByStep: SequentialTransformationExpectations): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseInteraction } from "../../core/BaseInteraction";
|
|
2
|
+
import { Variant } from "../../shared/types";
|
|
3
|
+
import { InteractionConfig, InteractionMechanic } from "../../types/Interactions";
|
|
4
|
+
import { TextEngineBaseData } from "../../types/Text";
|
|
5
|
+
import { type TextEngineBaseUserData } from "../../engines/text";
|
|
6
|
+
/**
|
|
7
|
+
* Text Transformation Interaction
|
|
8
|
+
*
|
|
9
|
+
* Users edit highlighted text segments to transform them according to instructions.
|
|
10
|
+
* For example: convert present tense to past tense, singular to plural, etc.
|
|
11
|
+
*
|
|
12
|
+
* Example data:
|
|
13
|
+
* ```
|
|
14
|
+
* {
|
|
15
|
+
* type: 'base',
|
|
16
|
+
* parts: ['I', 'drink', 'water', 'every', 'day'],
|
|
17
|
+
* targets: [
|
|
18
|
+
* { words: ['drink'], startPos: 1, endPos: 1 }
|
|
19
|
+
* ]
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Expected transformations would be provided separately in config or instructions.
|
|
24
|
+
*/
|
|
25
|
+
export declare class TextTransformation extends BaseInteraction<TextEngineBaseData> {
|
|
26
|
+
interactionMechanic: InteractionMechanic;
|
|
27
|
+
private _textConfig;
|
|
28
|
+
private _$text;
|
|
29
|
+
private _expectedTransformations;
|
|
30
|
+
constructor(data: TextEngineBaseData, config: InteractionConfig, expectedTransformations?: Record<number, string[]>);
|
|
31
|
+
protected initialize(): void;
|
|
32
|
+
protected cleanup(): void;
|
|
33
|
+
onVariantChange(newVariant: Variant): void;
|
|
34
|
+
render(): void;
|
|
35
|
+
getCurrentState(): TextEngineBaseUserData;
|
|
36
|
+
isInteractionComplete(): boolean;
|
|
37
|
+
onHint(): void;
|
|
38
|
+
getUserData(): TextEngineBaseUserData;
|
|
39
|
+
submit(): void;
|
|
40
|
+
grade(): import("../../types").GradingResult;
|
|
41
|
+
reset(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Set the expected transformations after construction
|
|
44
|
+
* Useful for dynamic configuration
|
|
45
|
+
*/
|
|
46
|
+
setExpectedTransformations(transformations: Record<number, string[]>): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GrammarParser } from "../types/Global";
|
|
2
|
+
import { TextData, NumberData, SelectData, DateData, TimeData } from "../types/Input";
|
|
3
|
+
export declare const parseTX: GrammarParser<TextData>;
|
|
4
|
+
export declare const parseSL: GrammarParser<SelectData>;
|
|
5
|
+
export declare const parseNM: GrammarParser<NumberData>;
|
|
6
|
+
export declare const parseDT: GrammarParser<DateData>;
|
|
7
|
+
export declare const parseTM: GrammarParser<TimeData>;
|
|
8
|
+
export declare function isInteractionSequential(s: string): boolean;
|
|
9
|
+
export declare function splitByDoubleSemiColon(s: string): string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnimationsManager - Utility for managing animations in Shadow DOM components
|
|
3
|
+
*
|
|
4
|
+
* Shadow DOM components cannot access keyframes defined in the main document.
|
|
5
|
+
* This manager injects keyframe definitions into Shadow DOM and provides
|
|
6
|
+
* a simple API to apply animations to elements.
|
|
7
|
+
*/
|
|
8
|
+
export type AnimationName = 'shake' | 'pulse-green' | 'bounce-in' | 'float' | 'rubber' | 'jello' | 'heartbeat' | 'shimmer' | 'wobble' | 'pop' | 'fade-slide' | 'swing' | 'orbit' | 'flash' | 'spin-pulse';
|
|
9
|
+
export interface AnimationOptions {
|
|
10
|
+
duration?: string;
|
|
11
|
+
timing?: string;
|
|
12
|
+
iterations?: string | number;
|
|
13
|
+
delay?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class AnimationsManager {
|
|
16
|
+
private static injectedRoots;
|
|
17
|
+
isEnabled: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Inject keyframes into a Shadow DOM
|
|
20
|
+
* Call this once during component initialization
|
|
21
|
+
*/
|
|
22
|
+
static injectKeyframes(shadowRoot: ShadowRoot): void;
|
|
23
|
+
/**
|
|
24
|
+
* Apply animation to an element
|
|
25
|
+
* @param element - The element to animate (can be in Shadow DOM)
|
|
26
|
+
* @param animationName - Name of the animation
|
|
27
|
+
* @param options - Optional animation configuration
|
|
28
|
+
*/
|
|
29
|
+
animate(element: HTMLElement, animationName: AnimationName, options?: AnimationOptions): void;
|
|
30
|
+
/**
|
|
31
|
+
* Stop/clear animation on an element
|
|
32
|
+
*/
|
|
33
|
+
stop(element: HTMLElement): void;
|
|
34
|
+
/**
|
|
35
|
+
* Animate element for a specific duration then auto-stop
|
|
36
|
+
* @param element - The element to animate
|
|
37
|
+
* @param animationName - Name of the animation
|
|
38
|
+
* @param durationMs - Duration in milliseconds before auto-stopping
|
|
39
|
+
* @param options - Optional animation configuration
|
|
40
|
+
*/
|
|
41
|
+
animateFor(element: HTMLElement, animationName: AnimationName, durationMs: number, options?: AnimationOptions): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get all available animation names
|
|
44
|
+
*/
|
|
45
|
+
getAvailableAnimations(): AnimationName[];
|
|
46
|
+
/**
|
|
47
|
+
* Apply animation using CSS class (for hover/active states)
|
|
48
|
+
* Requires keyframes to be available in the component's Shadow DOM
|
|
49
|
+
*/
|
|
50
|
+
addAnimationClass(element: HTMLElement, animationName: AnimationName): void;
|
|
51
|
+
/**
|
|
52
|
+
* Remove animation class
|
|
53
|
+
*/
|
|
54
|
+
removeAnimationClass(element: HTMLElement, animationName: AnimationName): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundManager - Centralized audio playback utility
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Play local sounds from /public/assets/audio/
|
|
6
|
+
* - Play sounds from external URLs
|
|
7
|
+
* - Preload and cache audio for better performance
|
|
8
|
+
* - Volume control with fade effects
|
|
9
|
+
* - Error handling and fallbacks
|
|
10
|
+
*/
|
|
11
|
+
export type SoundName = 'success' | 'failure' | 'pop' | 'low-time' | 'start' | 'flip';
|
|
12
|
+
export interface PlaySoundOptions {
|
|
13
|
+
volume?: number;
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
fadeIn?: number;
|
|
16
|
+
fadeOut?: number;
|
|
17
|
+
playbackRate?: number;
|
|
18
|
+
onEnd?: () => void;
|
|
19
|
+
onError?: (error: Error) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare class SoundManager {
|
|
22
|
+
isEnabled: boolean;
|
|
23
|
+
private audioCache;
|
|
24
|
+
private activeSounds;
|
|
25
|
+
private baseUrl;
|
|
26
|
+
private localSounds;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Play a sound by name or URL
|
|
30
|
+
* @param soundNameOrUrl - Predefined sound name or full URL
|
|
31
|
+
* @param options - Playback options
|
|
32
|
+
*/
|
|
33
|
+
playSound(soundNameOrUrl: SoundName | string, options?: PlaySoundOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Preload sounds for better performance
|
|
36
|
+
* @param sounds - Array of sound names or URLs to preload
|
|
37
|
+
*/
|
|
38
|
+
preload(sounds: (SoundName | string)[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Stop all currently playing sounds
|
|
41
|
+
*/
|
|
42
|
+
stopAll(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Stop a specific sound
|
|
45
|
+
* @param soundNameOrUrl - Sound to stop
|
|
46
|
+
*/
|
|
47
|
+
stop(soundNameOrUrl: SoundName | string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clear the audio cache
|
|
50
|
+
*/
|
|
51
|
+
clearCache(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Set global volume for all future sounds
|
|
54
|
+
* @param volume - Volume level (0.0 to 1.0)
|
|
55
|
+
*/
|
|
56
|
+
setGlobalVolume(volume: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve sound name to full URL
|
|
59
|
+
*/
|
|
60
|
+
private resolveUrl;
|
|
61
|
+
/**
|
|
62
|
+
* Get or create audio element
|
|
63
|
+
*/
|
|
64
|
+
private getAudio;
|
|
65
|
+
/**
|
|
66
|
+
* Configure audio element with options
|
|
67
|
+
*/
|
|
68
|
+
private configureAudio;
|
|
69
|
+
/**
|
|
70
|
+
* Play audio with error handling
|
|
71
|
+
*/
|
|
72
|
+
private playAudio;
|
|
73
|
+
/**
|
|
74
|
+
* Fade volume over time
|
|
75
|
+
*/
|
|
76
|
+
private fadeVolume;
|
|
77
|
+
}
|
|
78
|
+
export declare const soundManager: SoundManager;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InteractionData } from "../types/Data";
|
|
2
|
+
export type Variant = 'elegant' | 'playful' | 'outline' | 'letter' | 'sign' | 'minimal' | 'glass' | 'empty';
|
|
3
|
+
export type CognitiveOp = 'discrimination' | 'classification' | 'freerecall' | 'production' | 'association' | 'comparisson' | 'transformation' | 'seriation' | 'recognition' | 'cuedrecall' | 'evaluation';
|
|
4
|
+
export interface Module {
|
|
5
|
+
id: string;
|
|
6
|
+
process: CognitiveOp;
|
|
7
|
+
implementation: {
|
|
8
|
+
parser(code: string): ParsingResult;
|
|
9
|
+
validator(data: InteractionData): ValidationResult;
|
|
10
|
+
interactions: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
help: string;
|
|
13
|
+
}
|
|
14
|
+
export type ParsingResult = {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
data?: InteractionData | null;
|
|
17
|
+
errors?: Record<string, string> | null;
|
|
18
|
+
};
|
|
19
|
+
export type ValidationResult = {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
errors: Record<string, string> | null;
|
|
22
|
+
};
|
|
23
|
+
export type GrammarParser = (code: string) => GrammarParseResult;
|
|
24
|
+
export type GrammarParseResult = ParsingResult;
|
|
25
|
+
export type SimpleErrorObject = Record<string, string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const randomHexColorsList: string[];
|
|
2
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
3
|
+
export declare const hash: (str: string, seed?: number) => string;
|
|
4
|
+
export declare function escapeHtml(s: string): string;
|
|
5
|
+
export declare function parseYamlAssets(yamlText: string): unknown;
|
|
6
|
+
export declare function isString(v: unknown): v is string;
|
|
7
|
+
export declare function isNumber(v: unknown): v is number;
|
|
8
|
+
export declare function looksLikeTime(s: string): boolean;
|
|
9
|
+
export declare function typeOf(v: unknown): string;
|
|
10
|
+
export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
|
|
11
|
+
export declare function splitByPipes(input: string): string[];
|
|
12
|
+
export declare const dedupe: <T>(arr: T[]) => T[];
|
|
13
|
+
export declare function isOneOf<const T extends readonly string[]>(value: string, allowed: T): value is T[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InteractionsBaseShell } from "./simple-shell";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InteractionsBaseShell } from "./script";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseInteraction } from "../../core/BaseInteraction";
|
|
2
|
+
import { InteractionData } from "../../types/Data";
|
|
3
|
+
export declare class InteractionsBaseShell extends HTMLElement {
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
private soundManager;
|
|
6
|
+
private animationsManager;
|
|
7
|
+
private $titleEl;
|
|
8
|
+
private $promptBtn;
|
|
9
|
+
private $timerEl;
|
|
10
|
+
private $headerEl;
|
|
11
|
+
private $footerEl;
|
|
12
|
+
private $contentEl;
|
|
13
|
+
private $checkBtn;
|
|
14
|
+
private $seeAnswersBtn;
|
|
15
|
+
private $scoresBtn;
|
|
16
|
+
private $retryBtn;
|
|
17
|
+
private $radioNav;
|
|
18
|
+
private $progressContainer;
|
|
19
|
+
private $progressBar;
|
|
20
|
+
private $progressIcon;
|
|
21
|
+
private $progressCounter;
|
|
22
|
+
private $interactionScreen;
|
|
23
|
+
private $errorContent;
|
|
24
|
+
private $attemptsMessage;
|
|
25
|
+
private $scoreDisplay;
|
|
26
|
+
private $timerDisplay;
|
|
27
|
+
private interaction?;
|
|
28
|
+
private timerInterval;
|
|
29
|
+
private remainingSeconds;
|
|
30
|
+
private interactionComplete;
|
|
31
|
+
private attemptCount;
|
|
32
|
+
private attemptLimit;
|
|
33
|
+
private currentScreen;
|
|
34
|
+
constructor();
|
|
35
|
+
connectedCallback(): void;
|
|
36
|
+
disconnectedCallback(): void;
|
|
37
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
38
|
+
setInteraction<T extends InteractionData>(interaction: BaseInteraction<T>): void;
|
|
39
|
+
removeInteraction(): void;
|
|
40
|
+
private setupShellListeners;
|
|
41
|
+
private setupInteractionListeners;
|
|
42
|
+
private removeInteractionListeners;
|
|
43
|
+
private updateProgress;
|
|
44
|
+
private handleCompletion;
|
|
45
|
+
private handleGraded;
|
|
46
|
+
private reset;
|
|
47
|
+
private handleRetry;
|
|
48
|
+
private openPromptDialog;
|
|
49
|
+
private switchScreen;
|
|
50
|
+
private startTimer;
|
|
51
|
+
private stopTimer;
|
|
52
|
+
private getFormattedTime;
|
|
53
|
+
private updateTimerDisplay;
|
|
54
|
+
private handleTimerComplete;
|
|
55
|
+
pauseTimer(): void;
|
|
56
|
+
resumeTimer(): void;
|
|
57
|
+
resetTimer(): void;
|
|
58
|
+
private updateVisibility;
|
|
59
|
+
private renderRadioNav;
|
|
60
|
+
getContentArea(): HTMLElement;
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type AssetType = "image" | "video" | "audio" | "html" | "tts";
|
|
2
|
+
export type AssetRegistryInput = Record<string, unknown>;
|
|
3
|
+
export interface BaseAsset {
|
|
4
|
+
id: string;
|
|
5
|
+
type: AssetType;
|
|
6
|
+
dialog?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ImageAsset extends BaseAsset {
|
|
9
|
+
type: "image";
|
|
10
|
+
url: string;
|
|
11
|
+
size?: "small" | "medium" | "large" | string;
|
|
12
|
+
}
|
|
13
|
+
export interface AudioAsset extends BaseAsset {
|
|
14
|
+
type: "audio";
|
|
15
|
+
url: string;
|
|
16
|
+
volume?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface VideoAsset extends BaseAsset {
|
|
19
|
+
type: "video";
|
|
20
|
+
url: string;
|
|
21
|
+
span?: {
|
|
22
|
+
from: string;
|
|
23
|
+
to: string;
|
|
24
|
+
};
|
|
25
|
+
source?: 'general' | 'youtube';
|
|
26
|
+
}
|
|
27
|
+
export interface HtmlAsset extends BaseAsset {
|
|
28
|
+
type: "html";
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TtsAsset extends BaseAsset {
|
|
32
|
+
type: "tts";
|
|
33
|
+
content: string;
|
|
34
|
+
volume?: number;
|
|
35
|
+
}
|
|
36
|
+
export type Asset = ImageAsset | AudioAsset | VideoAsset | HtmlAsset | TtsAsset;
|
|
37
|
+
export interface NormalizedAssets {
|
|
38
|
+
assetsById: Record<string, Asset>;
|
|
39
|
+
assetsList: Asset[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseTableData, ValueTableData } from "./Tables";
|
|
2
|
+
import { TextEngineBaseData, TextEngineBlanksData, TextEngineClassificationData, TextEngineSequentialInteractionData } from "./Text";
|
|
3
|
+
export type InteractionData = ClassificationData | AssociationData | BaseTableData | ValueTableData | TextEngineBaseData | TextEngineBlanksData | TextEngineClassificationData | TextEngineSequentialInteractionData | FreeRecallData | RecognitionData | SeriationData;
|
|
4
|
+
export type ClassificationData = {
|
|
5
|
+
type: 'classification';
|
|
6
|
+
categories: {
|
|
7
|
+
label: string;
|
|
8
|
+
items: string[];
|
|
9
|
+
}[];
|
|
10
|
+
distractors?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type AssociationData = {
|
|
13
|
+
type: 'association';
|
|
14
|
+
pairs: {
|
|
15
|
+
left: string;
|
|
16
|
+
right: string;
|
|
17
|
+
}[];
|
|
18
|
+
distractors?: string[];
|
|
19
|
+
};
|
|
20
|
+
export type SeriationData = {
|
|
21
|
+
type: 'seriation';
|
|
22
|
+
items: string[];
|
|
23
|
+
};
|
|
24
|
+
export type FreeRecallData = SeriationData;
|
|
25
|
+
export interface RecognitionData {
|
|
26
|
+
type: 'recognition';
|
|
27
|
+
data: {
|
|
28
|
+
question: string;
|
|
29
|
+
correctOptions: string[];
|
|
30
|
+
options: string[];
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InteractionData } from "./Data";
|
|
2
|
+
import { InputElementData } from "./Input";
|
|
3
|
+
export type StyleVariant = 'elegant' | 'playful' | 'outline' | 'letter' | 'sign' | 'minimal' | 'card' | 'glass' | 'empty';
|
|
4
|
+
export type CognitiveOperation = 'discrimination' | 'classification' | 'freerecall' | 'production' | 'association' | 'comparisson' | 'transformation' | 'seriation' | 'recognition' | 'cuedrecall' | 'evaluation';
|
|
5
|
+
export type ParsingResult = {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
data?: InteractionData | null;
|
|
8
|
+
errors?: Record<string, string> | null;
|
|
9
|
+
};
|
|
10
|
+
export type ValidationResult = {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
errors: Record<string, string> | null;
|
|
13
|
+
};
|
|
14
|
+
type DataTypesUnion = InteractionData | InputElementData;
|
|
15
|
+
export type GrammarParseResult<T extends DataTypesUnion = DataTypesUnion> = {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
data?: T | null;
|
|
18
|
+
errors?: SimpleErrorObject | SimpleErrorObject[] | null;
|
|
19
|
+
};
|
|
20
|
+
export type SimpleErrorObject = Record<string, string>;
|
|
21
|
+
export type ComplexErrorObject = SimpleErrorObject[];
|
|
22
|
+
export type GrammarParser<T extends DataTypesUnion = DataTypesUnion> = (code: string) => GrammarParseResult<T>;
|
|
23
|
+
export type Validator = (data: InteractionData) => ValidationResult;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type InputModality = 'text' | 'number' | 'select' | 'date' | 'time';
|
|
2
|
+
export type InputElementReference = 'tx' | 'nm' | 'sl' | 'dt' | 'tm';
|
|
3
|
+
export type MediaRenference = 'im' | 'au' | 'tt' | 'vi' | 'ht';
|
|
4
|
+
export type InputElementData = TextData | NumberData | SelectData | DateData | TimeData;
|
|
5
|
+
interface InputElementBaseData {
|
|
6
|
+
type: InputModality;
|
|
7
|
+
id: string;
|
|
8
|
+
html: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TextData extends InputElementBaseData {
|
|
11
|
+
type: 'text';
|
|
12
|
+
value: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface NumberData extends InputElementBaseData {
|
|
15
|
+
type: 'number';
|
|
16
|
+
targets: number[];
|
|
17
|
+
ranges?: {
|
|
18
|
+
from: number;
|
|
19
|
+
to: number;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export interface SelectData extends InputElementBaseData {
|
|
23
|
+
type: 'select';
|
|
24
|
+
correctOptions: string[];
|
|
25
|
+
options: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface DateData extends InputElementBaseData {
|
|
28
|
+
type: 'date';
|
|
29
|
+
value: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TimeData extends InputElementBaseData {
|
|
32
|
+
type: 'time';
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Variant } from "../shared/types";
|
|
2
|
+
import { InteractionData } from "./Data";
|
|
3
|
+
import { AssetType } from "./Assets";
|
|
4
|
+
export type InteractionMechanic = 'static' | 'sequential' | 'automatic-sequencing' | 'prefers-horizontal-overflow' | 'prefers-vertical-overflow' | 'implements-open-canvas' | 'game';
|
|
5
|
+
export type IInteractionSpec = unknown;
|
|
6
|
+
export type InteractionConfig = {
|
|
7
|
+
prompt: string;
|
|
8
|
+
promptModality?: AssetType;
|
|
9
|
+
promptData?: string;
|
|
10
|
+
promptDataSpec?: string;
|
|
11
|
+
variant: Variant;
|
|
12
|
+
shuffle: boolean;
|
|
13
|
+
construct?: string;
|
|
14
|
+
playStaggeringAnimation?: boolean;
|
|
15
|
+
animationsEnabled?: boolean;
|
|
16
|
+
soundEnabled?: boolean;
|
|
17
|
+
inLineFeedback?: boolean;
|
|
18
|
+
immediateFeedback?: boolean;
|
|
19
|
+
attemptLimit: number | null;
|
|
20
|
+
timer: number | null;
|
|
21
|
+
};
|
|
22
|
+
export type IInteraction = {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
data?: InteractionData;
|
|
26
|
+
css: string;
|
|
27
|
+
examples: Record<string, string>;
|
|
28
|
+
};
|