@citolab/tspci 2.6.2 → 2.6.3-beta.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/CHANGELOG.md +16 -0
- package/package.json +3 -3
- package/preset/javascript/src/index.js +28 -1
- package/preset/preact/src/index.tsx +13 -0
- package/preset/typescript/src/index.ts +13 -1
- package/readme.md +4 -0
- package/types/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.6.3-beta.0](/compare/v2.6.2...v2.6.3-beta.0) (2025-04-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update tailwindcss version to 4.1.3 in package.json and package-lock.json 55c8ccb
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* implement setResponse method in PCI 1e4dffa
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.6.2](/compare/v2.6.1...v2.6.2) (2025-02-04)
|
|
7
23
|
|
|
8
24
|
**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.6.
|
|
3
|
+
"version": "2.6.3-beta.0",
|
|
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",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
47
47
|
"rollup-plugin-postcss": "^4.0.2",
|
|
48
48
|
"rollup-plugin-string": "^3.0.0",
|
|
49
|
-
"tailwindcss": "^4.
|
|
49
|
+
"tailwindcss": "^4.1.3"
|
|
50
50
|
},
|
|
51
51
|
"resolutions": {
|
|
52
52
|
"chokidar": "^4.0.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "ff7ff2668a565e76002b9cc79414d1e70fe61924"
|
|
55
55
|
}
|
|
@@ -2,7 +2,6 @@ import * as ctx from "qtiCustomInteractionContext";
|
|
|
2
2
|
import configProps from "./config.json";
|
|
3
3
|
import style from "./styles.css"; // import and bundle this style file ( you can use tailwind and nested css )
|
|
4
4
|
import procenten from "./assets/procenten.png"; // image types are bundled inside the js
|
|
5
|
-
|
|
6
5
|
class Pci {
|
|
7
6
|
/**
|
|
8
7
|
* @constructor
|
|
@@ -41,6 +40,13 @@ class Pci {
|
|
|
41
40
|
|
|
42
41
|
this.shadowdom = dom.attachShadow({ mode: "closed" });
|
|
43
42
|
this.render();
|
|
43
|
+
|
|
44
|
+
if (this.config.boundTo && Object.keys(this.config.boundTo).length > 0) {
|
|
45
|
+
const responseIdentifier = Object.keys(this.config.boundTo)[0];
|
|
46
|
+
const response = this.config.boundTo[responseIdentifier];
|
|
47
|
+
this.setResponse(response);
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
const event = {
|
|
45
51
|
interaction: this,
|
|
46
52
|
responseIdentifier: this.config.responseIdentifier,
|
|
@@ -68,6 +74,12 @@ class Pci {
|
|
|
68
74
|
this.dom.dispatchEvent(interactionChangedEvent);
|
|
69
75
|
};
|
|
70
76
|
|
|
77
|
+
setResponse = (response) => {
|
|
78
|
+
// TODO restore the response
|
|
79
|
+
// Get the actual value by the variable type like:
|
|
80
|
+
// - response?.base?.string or response?.base?.integer
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
render = () => {
|
|
72
84
|
this.shadowdom.addEventListener("change", (e) => {
|
|
73
85
|
const value = e.target.value;
|
|
@@ -108,6 +120,21 @@ class Pci {
|
|
|
108
120
|
*/
|
|
109
121
|
getState = () => this.state.toString();
|
|
110
122
|
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @method resetResponse
|
|
126
|
+
* @description Can set the response to a previously stored state.
|
|
127
|
+
* Also a way in TAO to show the correct response in the score-editor.
|
|
128
|
+
* @param {QtiVariableJSON} response - The response to set.
|
|
129
|
+
* @returns {void}
|
|
130
|
+
* @example
|
|
131
|
+
* const response = {
|
|
132
|
+
* base: {
|
|
133
|
+
* integer: 100
|
|
134
|
+
* }
|
|
135
|
+
* };
|
|
136
|
+
*/
|
|
137
|
+
setResponse = (response) => { }
|
|
111
138
|
/**
|
|
112
139
|
* @method oncompleted
|
|
113
140
|
* @description called when the PCI is completed.
|
|
@@ -60,6 +60,12 @@ class App implements IMSpci<PropTypes> {
|
|
|
60
60
|
|
|
61
61
|
this.render();
|
|
62
62
|
|
|
63
|
+
if (this.config.boundTo && Object.keys(this.config.boundTo).length > 0) {
|
|
64
|
+
const responseIdentifier = Object.keys(this.config.boundTo)[0];
|
|
65
|
+
const response = this.config.boundTo[responseIdentifier];
|
|
66
|
+
this.setResponse(response);
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
if (this.config.onready) {
|
|
64
70
|
this.config.onready(this);
|
|
65
71
|
}
|
|
@@ -73,6 +79,13 @@ class App implements IMSpci<PropTypes> {
|
|
|
73
79
|
render(<Interaction config={this.config.properties} dom={this.shadowdom} store={this.store} />, this.shadowdom);
|
|
74
80
|
};
|
|
75
81
|
|
|
82
|
+
setResponse = (response: QtiVariableJSON) => {
|
|
83
|
+
// TODO restore the response
|
|
84
|
+
// Get the actual value by the variable type like:
|
|
85
|
+
// - response?.base?.string or response?.base?.integer
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
76
89
|
getState = () =>
|
|
77
90
|
JSON.stringify({
|
|
78
91
|
state: this.store.getState(),
|
|
@@ -25,7 +25,7 @@ class Pci implements IMSpci<PropTypes> {
|
|
|
25
25
|
// config is the configuration object which has an onready
|
|
26
26
|
getInstance = (dom: HTMLElement, config: ConfigProperties<PropTypes>, state: string) => {
|
|
27
27
|
config.properties = { ...configProps, ...config.properties }; // merge current props with incoming
|
|
28
|
-
this.config = config;
|
|
28
|
+
this.config = config;
|
|
29
29
|
this.state = state ? state : "";
|
|
30
30
|
if (!dom) {
|
|
31
31
|
throw new Error("No DOM Element provided");
|
|
@@ -35,9 +35,21 @@ class Pci implements IMSpci<PropTypes> {
|
|
|
35
35
|
|
|
36
36
|
this.render();
|
|
37
37
|
|
|
38
|
+
if (this.config.boundTo && Object.keys(this.config.boundTo).length > 0) {
|
|
39
|
+
const responseIdentifier = Object.keys(this.config.boundTo)[0];
|
|
40
|
+
const response = this.config.boundTo[responseIdentifier];
|
|
41
|
+
this.setResponse(response);
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
config.onready(this);
|
|
39
45
|
};
|
|
40
46
|
|
|
47
|
+
setResponse = (response: QtiVariableJSON) => {
|
|
48
|
+
// TODO restore the response
|
|
49
|
+
// Get the actual value by the variable type like:
|
|
50
|
+
// - response?.base?.string or response?.base?.integer
|
|
51
|
+
}
|
|
52
|
+
|
|
41
53
|
private interactionChanged = () => {
|
|
42
54
|
const event: QtiInteractionChangedDetail = {
|
|
43
55
|
interaction: this,
|
package/readme.md
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export interface IMSpci<T> {
|
|
|
52
52
|
*/
|
|
53
53
|
getState: () => string;
|
|
54
54
|
oncompleted?: () => void;
|
|
55
|
+
setResponse?: (response: QtiVariableJSON) => void; // No IMS specification for this, but best option to set the response when bound to a QTI variable
|
|
55
56
|
destroy?: () => void; // Not used in IMS and not in TAO implementation, so not used here (optional)
|
|
56
57
|
}
|
|
57
58
|
|