@citolab/tspci 2.5.30-beta.4 → 2.5.30-beta.5
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.5.30-beta.5](/compare/v2.5.30-beta.4...v2.5.30-beta.5) (2025-02-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @citolab/tspci
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [2.5.30-beta.4](/compare/v2.5.30-beta.3...v2.5.30-beta.4) (2025-02-03)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @citolab/tspci
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citolab/tspci",
|
|
3
|
-
"version": "2.5.30-beta.
|
|
3
|
+
"version": "2.5.30-beta.5",
|
|
4
4
|
"description": "an opiniated typescript ims-pci builder with tao integration",
|
|
5
5
|
"author": "patrick <patrick.deklein@cito.nl>",
|
|
6
6
|
"repository": "@citolab/tspci",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"resolutions": {
|
|
51
51
|
"chokidar": "^4.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "b9e35ba31c83b085f3a836adef7ccdf6fa7ed53a"
|
|
54
54
|
}
|
|
@@ -41,8 +41,17 @@ class Pci {
|
|
|
41
41
|
|
|
42
42
|
this.shadowdom = dom.attachShadow({ mode: "closed" });
|
|
43
43
|
this.render();
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const event = {
|
|
45
|
+
interaction: this,
|
|
46
|
+
responseIdentifier: this.config.responseIdentifier,
|
|
47
|
+
valid: true,
|
|
48
|
+
value: this.getResponse(),
|
|
49
|
+
};
|
|
50
|
+
// dispatch a custom event to notify the Delivery System that the interaction has changed
|
|
51
|
+
const interactionChangedEvent = new CustomEvent("qtiInteractionChanged", {
|
|
52
|
+
detail: event,
|
|
53
|
+
});
|
|
54
|
+
this.shadowdom.dispatchEvent(interactionChangedEvent);
|
|
46
55
|
};
|
|
47
56
|
|
|
48
57
|
render = () => {
|
|
@@ -20,7 +20,9 @@ class App implements IMSpci<PropTypes> {
|
|
|
20
20
|
private logActions: { type: string; payload: unknown }[] = []; // optional logActions
|
|
21
21
|
private initialState: StateModel = { input: undefined }; // optional initial state
|
|
22
22
|
constructor() {
|
|
23
|
-
|
|
23
|
+
if (ctx) {
|
|
24
|
+
ctx.register(this);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
getInstance = (dom: HTMLElement, config: Configuration<PropTypes>, stateString: string) => {
|
|
@@ -41,7 +43,9 @@ class App implements IMSpci<PropTypes> {
|
|
|
41
43
|
this.shadowdom = dom.attachShadow({ mode: "closed" });
|
|
42
44
|
this.render();
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
if (this.config.onready) {
|
|
47
|
+
this.config.onready(this);
|
|
48
|
+
}
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
render = () => {
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { Store } from "@citolab/preact-store";
|
|
2
2
|
|
|
3
3
|
export type ActionType = "SET_INPUT" | "RESTORE_STATE";
|
|
4
|
-
export type StateModel = { input: number };
|
|
4
|
+
export type StateModel = { input: number | undefined };
|
|
5
5
|
|
|
6
|
-
export const initStore = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export const initStore = (
|
|
7
|
+
initialState: StateModel,
|
|
8
|
+
restoreData?: {
|
|
9
|
+
state: StateModel;
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
actions: { type: string; payload: any; timestamp?: number }[];
|
|
12
|
+
}
|
|
13
|
+
) => {
|
|
10
14
|
const store = new Store<StateModel>(initialState, restoreData);
|
|
11
|
-
store.addReducer<{ input: number }>("SET_INPUT", (state, { input }) => {
|
|
12
|
-
return {...state, input };
|
|
15
|
+
store.addReducer<{ input: number | undefined }>("SET_INPUT", (state, { input }) => {
|
|
16
|
+
return { ...state, input };
|
|
13
17
|
});
|
|
14
18
|
return store;
|
|
15
|
-
}
|
|
19
|
+
};
|
|
@@ -15,7 +15,9 @@ class Pci implements IMSpci<PropTypes> {
|
|
|
15
15
|
shadowdom: ShadowRoot | Element; // Not mandatory, but its wise to create a shadowroot
|
|
16
16
|
|
|
17
17
|
constructor() {
|
|
18
|
-
|
|
18
|
+
if (ctx) {
|
|
19
|
+
ctx.register(this); // we assume the qtiCustomInteractionContext is avaible due to the import above
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// First in the lifecycle of a PCI, this method is called with the domElement ( usually qti-interaction-markup ) where we can add our dom tree.
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Define the payload structure for the custom event
|
|
2
2
|
export interface QtiInteractionChangedDetail {
|
|
3
|
-
interaction: IMSpci<
|
|
3
|
+
interaction: IMSpci<unknown>; // The PCI instance itself
|
|
4
4
|
responseIdentifier: string; // The response identifier provided in the getInstance call
|
|
5
5
|
valid?: boolean; // Optional boolean indicating if checkValidity() returns true
|
|
6
6
|
value?: QtiVariableJSON; // Optional value returned by getResponse()
|
|
@@ -14,9 +14,9 @@ export interface ConfigProperties<T> {
|
|
|
14
14
|
boundTo: Record<string, QtiVariableJSON>; // Follows structure in Appendix C
|
|
15
15
|
responseIdentifier: string; // Unique within interaction scope
|
|
16
16
|
|
|
17
|
-
onready: (interaction: IMSpci<
|
|
17
|
+
onready: (interaction: IMSpci<T>, state?: string) => void; // Callback when PCI is fully constructed and ready
|
|
18
18
|
ondone?: (
|
|
19
|
-
interaction: IMSpci<
|
|
19
|
+
interaction: IMSpci<T>,
|
|
20
20
|
response: Record<string, QtiVariableJSON>,
|
|
21
21
|
state: string,
|
|
22
22
|
status?: "interacting" | "closed" | "solution" | "review"
|