@citolab/tspci-tao 2.3.0-alpha.4 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citolab/tspci-tao",
3
- "version": "2.3.0-alpha.4",
3
+ "version": "2.3.0",
4
4
  "description": "create a zip file that can be imported into TAO",
5
5
  "author": "patrick <patrick.deklein@cito.nl>, Marcel Hoekstra <marcel.hoekstra@cito.nl>",
6
6
  "repository": "",
@@ -12,5 +12,5 @@
12
12
  "inquirer": "9.2.0"
13
13
  },
14
14
  "scripts": {},
15
- "gitHead": "a73cb286cca0f12d474e155915c251f85abf4b16"
15
+ "gitHead": "c7100a7ee3cd62cb7beb2bd6379c830cdec04a59"
16
16
  }
package/readme.md CHANGED
@@ -17,15 +17,49 @@ Configuration of a PCI can be done by the author because this packager reads the
17
17
  If scoring can be done with a MATCH_CORRECT (single string comparison) the item author can provide the correct answer in TAO by interaction with the PCI.
18
18
  This way one PCI can be re-used in different configurations supporting multiple items.
19
19
 
20
+ ## Cli
21
+ To add TAO support to an existing tspci PCI you can run:
22
+
23
+ ``` sh
24
+ tspci add --target tao
25
+ ```
26
+
27
+ This command and all the TAO specific changes that are needed to build importable TAO zip file. This will work for a new project created by ``` tspci init ```. For PCI's that are modified, it will do best effort to fully implement TAO specific changes. Please read the rest of this file in case ``` tspci init ``` fails on your PCI.
28
+
29
+ <p align="center">
30
+ <img src="https://github.com/Citolab/tspci/blob/main/lib/tspci-tao/readme-images/tspci-tao-console.png" alt="cli in console">
31
+ </p>
32
+
33
+ The cli will ask a few things before the script is executed:
34
+
35
+ - short: name on the interaction icon in TAO.
36
+ - label: label of the interaction
37
+ - scoringMethod: the MATCH CORRECT scoring can be applied on the PCI. The user can interacted with the PCI to provide the correct response. To be able to show the correct response in the author system after the author provided the correct response; the setResponse function of the TAO interface should be implemented. Scoring can (for now) only be done using a string comparison. But sinces the PCI developer implement the getResponse method, as string comparison can be done to compare JSON of formatted numbers.
38
+
39
+ ## Changes
40
+
20
41
  To be able to add an IMS-PCI to the TAO authoring system properties are added to the `package.json`
21
42
  and implemented lifecycle events that should be implemented in the PCI.
22
43
 
23
- To create this zip file run:
44
+
45
+
46
+ or
47
+
48
+ ``` sh
49
+ npm run tspci -- add --target tao
50
+ ```
51
+
52
+ To create the zip file that can be added in TAO run:
24
53
 
25
54
  ``` sh
26
55
  tspci --target tao
27
56
  ```
28
57
 
58
+ or
59
+
60
+ ``` sh
61
+ npm run tspci -- --target tao
62
+ ```
29
63
  ## life cycle methods
30
64
 
31
65
  To be TAO compliant the TAOpci interface should be implemented:
@@ -68,6 +102,20 @@ class App implements IMSpci<PropTypes>, TAOpci {
68
102
 
69
103
 
70
104
  ### package.json
105
+
106
+ The version and description fields of the package.json are used while creating the zip file and are mandatory.
107
+
108
+ Other config properties should be placed under: config -> tspci:
109
+
110
+ ``` json
111
+ "config": {
112
+ "tspci": {
113
+ "typeIdentifier": "myPci",
114
+ ...
115
+ }
116
+ }
117
+ ```
118
+
71
119
  - typeIdentifier: a field 'typeIdentifier' should be added. This should match the 'typeIdentifier' value in the PCI entry file (The one that implements IMSPci). Only (alpha)numeric values are allowed. This because a hyphen in the identifier causes an error in TAO. To be sure, only alphanumeric are allowed.
72
120
  - label: used as label in TAO
73
121
  - short: short name used in TAO to label the PCI where you can drag it in an item.
package/release-notes.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.3.0
2
+ - added a script to add TAO support in a PCI that only support the IMS interface.
3
+
1
4
  # 2.0.0
2
5
 
3
6
  - synchronized versions across tspci libraries
package/src/init.mjs CHANGED
@@ -3,6 +3,7 @@ import path from "path";
3
3
  import readline from "readline";
4
4
  import chalk from "chalk";
5
5
  import inquirer from "inquirer";
6
+
6
7
  function askOption(prompt) {
7
8
  const rl = readline.createInterface({
8
9
  input: process.stdin,
@@ -59,11 +60,23 @@ export const init = async () => {
59
60
  packageData.config.tspci.typeIdentifier = typeIdentifer;
60
61
  packageData.config.tspci.score = scoreMethodArray;
61
62
 
63
+ packageData.devDependencies = packageData.devDependencies || {};
64
+
65
+ // get package.json from PACKAGER_PATH
66
+ const PACKAGER_PATH = path.join(PACKAGE_ROOT_PATH + "/node_modules/@citolab/tspci-tao");
67
+ const packagerPackageData = JSON.parse(fs.readFileSync(path.join(PACKAGER_PATH, "package.json"), "utf8"));
68
+ // add devDependencies from packagerPackageData to packageData
69
+ Object.keys(packagerPackageData.devDependencies).forEach((key) => {
70
+ packageData.devDependencies[key] = packagerPackageData.devDependencies[key];
71
+ });
72
+
73
+ packageData.dependencies["@citolab/tspci"] = "^1.0.0";
62
74
  packageData.scripts = packageData.scripts || {};
63
75
  packageData.scripts["package:tao"] = "tspci --target tao";
64
76
  // store packageData
65
77
  fs.writeFileSync(path.join(PACKAGE_ROOT_PATH, "package.json"), JSON.stringify(packageData, null, 2), "utf8");
66
-
78
+ console.log(chalk.green("📦 Installing dependencies"));
79
+ execSync("npm install", { cwd: destinationFolder, stdio: [0, 1, 2] });
67
80
  console.log("Adding TAO interface to PCI");
68
81
  if (!packageData.source) {
69
82
  console.error("Failed implementing TAO interface; No source property found in package.json.");
@@ -85,19 +98,19 @@ export const init = async () => {
85
98
  newSourceFile = `import { QtiVariableJSON } from "@citolab/tspci";\r\n${newSourceFile}`;
86
99
  }
87
100
  const defaultImplementation = `
88
- off = () => {}; // called when setting correct response in tao
89
- on = (val) => {};
90
- trigger = (event: string, value: any) => {
91
- this.config.properties[event] = value;
92
- this.render();
93
- };
94
- resetResponse = () => {
95
- // used in tao to reset the response. clean-up and re-render the PCI would be best.
96
- // this.render();
97
- };
98
- setResponse = (response: QtiVariableJSON) => {
99
- // used to set the response in tao. E.g. when the item author has set a correct response. And you refresh TAO it will call this method to set the response in the PCI in the score-editor.
100
- };
101
+ off = () => {}; // called when setting correct response in tao
102
+ on = (val) => {};
103
+ trigger = (event: string, value: any) => {
104
+ this.config.properties[event] = value;
105
+ this.render();
106
+ };
107
+ resetResponse = () => {
108
+ // used in tao to reset the response. clean-up and re-render the PCI would be best.
109
+ // this.render();
110
+ };
111
+ setResponse = (response: QtiVariableJSON) => {
112
+ // used to set the response in tao. E.g. when the item author has set a correct response. And you refresh TAO it will call this method to set the response in the PCI in the score-editor.
113
+ };
101
114
  `
102
115
  const lastBracket = newSourceFile.lastIndexOf("}");
103
116
  newSourceFile = newSourceFile.substring(0, lastBracket) + defaultImplementation + newSourceFile.substring(lastBracket);