@citolab/tspci 2.5.30-beta.9 → 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 CHANGED
@@ -3,6 +3,73 @@
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
+
22
+ ## [2.6.2](/compare/v2.6.1...v2.6.2) (2025-02-04)
23
+
24
+ **Note:** Version bump only for package @citolab/tspci
25
+
26
+
27
+
28
+
29
+
30
+ ## [2.6.1](/compare/v2.6.0...v2.6.1) (2025-02-04)
31
+
32
+ **Note:** Version bump only for package @citolab/tspci
33
+
34
+
35
+
36
+
37
+
38
+ # [2.6.0](/compare/v2.5.30-beta.11...v2.6.0) (2025-02-04)
39
+
40
+ **Note:** Version bump only for package @citolab/tspci
41
+
42
+
43
+
44
+
45
+
46
+ # [2.6.0](/compare/v2.5.30-beta.11...v2.6.0) (2025-02-04)
47
+
48
+ **Note:** Version bump only for package @citolab/tspci
49
+
50
+
51
+
52
+
53
+
54
+ ## [2.5.30-beta.11](/compare/v2.5.30-beta.10...v2.5.30-beta.11) (2025-02-04)
55
+
56
+
57
+ ### Features
58
+
59
+ * add tailwindcss to devDependencies and set version based on @tailwindcss/postcss 907b541
60
+
61
+
62
+
63
+
64
+
65
+ ## [2.5.30-beta.10](/compare/v2.5.30-beta.9...v2.5.30-beta.10) (2025-02-04)
66
+
67
+ **Note:** Version bump only for package @citolab/tspci
68
+
69
+
70
+
71
+
72
+
6
73
  ## [2.5.30-beta.9](/compare/v2.5.30-beta.8...v2.5.30-beta.9) (2025-02-04)
7
74
 
8
75
  **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.9",
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.0.3"
49
+ "tailwindcss": "^4.1.3"
50
50
  },
51
51
  "resolutions": {
52
52
  "chokidar": "^4.0.0"
53
53
  },
54
- "gitHead": "faee45dd64a32b879dfbe94906a4e921102e03a9"
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
@@ -123,6 +123,10 @@ class Pci implements IMSpci<{}> {
123
123
  };
124
124
 
125
125
  getState = () => null;
126
+
127
+ setResponse = () => {
128
+
129
+ }
126
130
  }
127
131
  export default new Pci();
128
132
  ```
package/src/cli.js CHANGED
@@ -289,22 +289,38 @@ const run = async () => {
289
289
 
290
290
  // read postcss.config.js
291
291
  const postcssConfig = path.resolve(cliPath, "./../preset/tailwind/postcss.config.js");
292
+ // get all plugin names
292
293
  const postcssConfigContent = fs.readFileSync(postcssConfig, "utf8");
293
294
  // get all plugin names
294
- const pluginNames = postcssConfigContent
295
- .match(/require\('(.*)'\)/g)
296
- .map((plugin) => plugin.replace(/require\('(.*)'\)/, "$1"));
295
+ // Match require statements that use either single or double quotes
296
+ const pluginMatches = postcssConfigContent.match(/require\(["']([^"']+)["']\)/g);
297
+ let pluginNames = [];
298
+ if (pluginMatches) {
299
+ pluginNames = pluginMatches.map((plugin) => plugin.replace(/require\(["']([^"']+)["']\)/, "$1"));
300
+ } else {
301
+ console.log("No PostCSS plugins found.");
302
+ }
297
303
  const packageJsonCli = path.resolve(cliPath, "./../package.json");
298
304
  const packageJsonCliContent = fs.readFileSync(packageJsonCli, "utf8");
299
305
  const packageJsonCliContentJson = JSON.parse(packageJsonCliContent);
300
306
  // add all plugins to package.json and map the version to the version in tspci package.json
307
+ let version = "latest";
301
308
  for (const pluginName of pluginNames) {
302
309
  const pluginVersion = packageJsonCliContentJson.dependencies[pluginName];
310
+ if (pluginName === "@tailwindcss/postcss") {
311
+ version = pluginVersion.toString();
312
+ }
303
313
  packageJsonContentJson.devDependencies = {
304
314
  ...packageJsonContentJson.devDependencies,
305
315
  [pluginName]: pluginVersion,
306
316
  };
307
317
  }
318
+
319
+ // add tailwindcss itself to the devDependencies
320
+ packageJsonContentJson.devDependencies = {
321
+ ...packageJsonContentJson.devDependencies,
322
+ tailwindcss: version,
323
+ };
308
324
  const newPackageJsonContent = JSON.stringify(packageJsonContentJson, null, 2);
309
325
  fs.writeFileSync(packageJson, newPackageJsonContent);
310
326
  // copy tailwind config file
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