@pie-element/likert 4.1.2-next.1 → 4.1.2
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.json +1 -0
- package/CHANGELOG.md +1462 -0
- package/LICENSE.md +5 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +1379 -0
- package/configure/lib/choiceGenerator.js +219 -0
- package/configure/lib/choiceGenerator.js.map +1 -0
- package/configure/lib/defaults.js +100 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +106 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/likertEntities.js +24 -0
- package/configure/lib/likertEntities.js.map +1 -0
- package/configure/lib/main.js +388 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/package.json +27 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +90 -0
- package/controller/lib/defaults.js +17 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +81 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +17 -0
- package/docs/config-schema.json +2011 -0
- package/docs/config-schema.json.md +1487 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +22 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +966 -0
- package/docs/pie-schema.json.md +711 -0
- package/lib/choice-input.js +90 -0
- package/lib/choice-input.js.map +1 -0
- package/lib/index.js +64 -0
- package/lib/index.js.map +1 -0
- package/lib/likert.js +97 -0
- package/lib/likert.js.map +1 -0
- package/lib/likertEntities.js +11 -0
- package/lib/likertEntities.js.map +1 -0
- package/lib/main.js +42 -0
- package/lib/main.js.map +1 -0
- package/lib/session-updater.js +15 -0
- package/lib/session-updater.js.map +1 -0
- package/package.json +21 -84
- package/readme.md +55 -0
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choiceGenerator.d.ts +0 -13
- package/dist/author/choiceGenerator.js +0 -255
- package/dist/author/defaults.d.ts +0 -102
- package/dist/author/defaults.js +0 -60
- package/dist/author/index.d.ts +0 -31
- package/dist/author/index.js +0 -73
- package/dist/author/likertEntities.d.ts +0 -25
- package/dist/author/likertEntities.js +0 -18
- package/dist/author/main.d.ts +0 -27
- package/dist/author/main.js +0 -298
- package/dist/browser/Radio-CAjl01LA.js +0 -9447
- package/dist/browser/Radio-CAjl01LA.js.map +0 -1
- package/dist/browser/author/index.js +0 -39374
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -51
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -219
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/likert.css +0 -2
- package/dist/controller/defaults.d.ts +0 -19
- package/dist/controller/defaults.js +0 -13
- package/dist/controller/index.d.ts +0 -19
- package/dist/controller/index.js +0 -41
- package/dist/delivery/choice-input.d.ts +0 -27
- package/dist/delivery/choice-input.js +0 -59
- package/dist/delivery/index.d.ts +0 -19
- package/dist/delivery/index.js +0 -44
- package/dist/delivery/likert.d.ts +0 -26
- package/dist/delivery/likert.js +0 -70
- package/dist/delivery/likertEntities.d.ts +0 -12
- package/dist/delivery/likertEntities.js +0 -7
- package/dist/delivery/main.d.ts +0 -23
- package/dist/delivery/main.js +0 -37
- package/dist/delivery/session-updater.d.ts +0 -9
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -145
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createDefaultModel = createDefaultModel;
|
|
8
|
+
exports.model = model;
|
|
9
|
+
exports.normalize = void 0;
|
|
10
|
+
exports.outcome = outcome;
|
|
11
|
+
exports.validate = void 0;
|
|
12
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
13
|
+
const prepareChoice = choice => {
|
|
14
|
+
return {
|
|
15
|
+
label: choice.label,
|
|
16
|
+
value: choice.value
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
function createDefaultModel(model = {}) {
|
|
20
|
+
return new Promise(resolve => resolve({
|
|
21
|
+
..._defaults.default,
|
|
22
|
+
...model
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
const normalize = question => ({
|
|
26
|
+
..._defaults.default,
|
|
27
|
+
...question
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {*} question
|
|
33
|
+
* @param {*} session
|
|
34
|
+
* @param {*} env
|
|
35
|
+
*/
|
|
36
|
+
exports.normalize = normalize;
|
|
37
|
+
async function model(question, session, env) {
|
|
38
|
+
const normalizedQuestion = normalize(question);
|
|
39
|
+
let choices = normalizedQuestion.choices.map(prepareChoice);
|
|
40
|
+
const out = {
|
|
41
|
+
...normalizedQuestion,
|
|
42
|
+
choices,
|
|
43
|
+
disabled: env.mode !== 'gather',
|
|
44
|
+
mode: env.mode
|
|
45
|
+
};
|
|
46
|
+
const {
|
|
47
|
+
role,
|
|
48
|
+
mode
|
|
49
|
+
} = env || {};
|
|
50
|
+
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
51
|
+
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
52
|
+
} else {
|
|
53
|
+
out.teacherInstructions = null;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
function outcome() {
|
|
58
|
+
return new Promise(resolve => {
|
|
59
|
+
resolve({
|
|
60
|
+
score: 0,
|
|
61
|
+
empty: false
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// remove all html tags
|
|
67
|
+
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
68
|
+
|
|
69
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
70
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
71
|
+
const validate = (model = {}, config = {}) => {
|
|
72
|
+
const errors = {};
|
|
73
|
+
['teacherInstructions', 'prompt'].forEach(field => {
|
|
74
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
75
|
+
errors[field] = 'This field is required.';
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return errors;
|
|
79
|
+
};
|
|
80
|
+
exports.validate = validate;
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","prepareChoice","choice","label","value","createDefaultModel","model","Promise","resolve","defaults","normalize","question","exports","session","env","normalizedQuestion","choices","map","out","disabled","mode","role","teacherInstructions","teacherInstructionsEnabled","outcome","score","empty","getInnerText","html","replaceAll","getContent","replace","validate","config","errors","forEach","field","required"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\n\nconst prepareChoice = (choice) => {\n return {\n label: choice.label,\n value: choice.value,\n };\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n\n let choices = normalizedQuestion.choices.map(prepareChoice);\n\n const out = {\n ...normalizedQuestion,\n choices,\n disabled: env.mode !== 'gather',\n mode: env.mode,\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport function outcome() {\n return new Promise((resolve) => {\n resolve({ score: 0, empty: false });\n });\n}\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n\n ['teacherInstructions', 'prompt'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,aAAa,GAAIC,MAAM,IAAK;EAChC,OAAO;IACLC,KAAK,EAAED,MAAM,CAACC,KAAK;IACnBC,KAAK,EAAEF,MAAM,CAACE;EAChB,CAAC;AACH,CAAC;AAEM,SAASC,kBAAkBA,CAACC,KAAK,GAAG,CAAC,CAAC,EAAE;EAC7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAAC;IAAE,GAAGC,iBAAQ;IAAE,GAAGH;EAAM,CAAC,CAAC,CAAC;AACrE;AAEO,MAAMI,SAAS,GAAIC,QAAQ,KAAM;EAAE,GAAGF,iBAAQ;EAAE,GAAGE;AAAS,CAAC,CAAC;;AAErE;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAF,SAAA,GAAAA,SAAA;AAMO,eAAeJ,KAAKA,CAACK,QAAQ,EAAEE,OAAO,EAAEC,GAAG,EAAE;EAClD,MAAMC,kBAAkB,GAAGL,SAAS,CAACC,QAAQ,CAAC;EAE9C,IAAIK,OAAO,GAAGD,kBAAkB,CAACC,OAAO,CAACC,GAAG,CAAChB,aAAa,CAAC;EAE3D,MAAMiB,GAAG,GAAG;IACV,GAAGH,kBAAkB;IACrBC,OAAO;IACPG,QAAQ,EAAE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CAAC,CAAC;EAEF,OAAOF,MAAM;AACf,CAAC;AAACtB,OAAA,CAAAoB,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/likert-controller",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "3.0.3",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "src/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "./node_modules/.bin/jest"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"debug": "^4.1.1",
|
|
13
|
+
"lodash-es": "^4.17.23"
|
|
14
|
+
},
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC"
|
|
17
|
+
}
|