@citolab/tspci-tao 2.3.0-alpha.4 → 2.3.0-alpha.6
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 +2 -2
- package/src/init.mjs +25 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citolab/tspci-tao",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.6",
|
|
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": "
|
|
15
|
+
"gitHead": "30554601c3d8204dd6bf0e237d5fd6e4a5401560"
|
|
16
16
|
}
|
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,6 +60,17 @@ 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
|
|
@@ -85,19 +97,19 @@ export const init = async () => {
|
|
|
85
97
|
newSourceFile = `import { QtiVariableJSON } from "@citolab/tspci";\r\n${newSourceFile}`;
|
|
86
98
|
}
|
|
87
99
|
const defaultImplementation = `
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
off = () => {}; // called when setting correct response in tao
|
|
101
|
+
on = (val) => {};
|
|
102
|
+
trigger = (event: string, value: any) => {
|
|
103
|
+
this.config.properties[event] = value;
|
|
104
|
+
this.render();
|
|
105
|
+
};
|
|
106
|
+
resetResponse = () => {
|
|
107
|
+
// used in tao to reset the response. clean-up and re-render the PCI would be best.
|
|
108
|
+
// this.render();
|
|
109
|
+
};
|
|
110
|
+
setResponse = (response: QtiVariableJSON) => {
|
|
111
|
+
// 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.
|
|
112
|
+
};
|
|
101
113
|
`
|
|
102
114
|
const lastBracket = newSourceFile.lastIndexOf("}");
|
|
103
115
|
newSourceFile = newSourceFile.substring(0, lastBracket) + defaultImplementation + newSourceFile.substring(lastBracket);
|