@pie-element/math-templated 2.11.2-next.7000

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.
Files changed (48) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +528 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +0 -0
  5. package/configure/CHANGELOG.json +1 -0
  6. package/configure/CHANGELOG.md +486 -0
  7. package/configure/lib/defaults.js +158 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/design.js +597 -0
  10. package/configure/lib/design.js.map +1 -0
  11. package/configure/lib/index.js +227 -0
  12. package/configure/lib/index.js.map +1 -0
  13. package/configure/lib/markupUtils.js +51 -0
  14. package/configure/lib/markupUtils.js.map +1 -0
  15. package/configure/lib/response.js +442 -0
  16. package/configure/lib/response.js.map +1 -0
  17. package/configure/package.json +20 -0
  18. package/controller/CHANGELOG.json +1 -0
  19. package/controller/CHANGELOG.md +391 -0
  20. package/controller/lib/defaults.js +21 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +302 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/package.json +19 -0
  25. package/docs/config-schema.json +104 -0
  26. package/docs/config-schema.json.md +85 -0
  27. package/docs/demo/config.js +8 -0
  28. package/docs/demo/generate.js +42 -0
  29. package/docs/demo/index.html +1 -0
  30. package/docs/demo/session.js +14 -0
  31. package/docs/pie-schema.json +51 -0
  32. package/docs/pie-schema.json.md +37 -0
  33. package/lib/index.js +121 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/main.js +843 -0
  36. package/lib/main.js.map +1 -0
  37. package/lib/print.js +130 -0
  38. package/lib/print.js.map +1 -0
  39. package/module/configure.js +106458 -0
  40. package/module/controller.js +23132 -0
  41. package/module/demo.js +67 -0
  42. package/module/element.js +127550 -0
  43. package/module/index.html +21 -0
  44. package/module/manifest.json +14 -0
  45. package/module/print-demo.js +105 -0
  46. package/module/print.html +18 -0
  47. package/module/print.js +127498 -0
  48. package/package.json +29 -0
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.validate = exports.prepareVal = exports.outcome = exports.normalizeSession = exports.model = exports.getPartialScore = exports.getCorrectness = exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
11
+
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _debug = _interopRequireDefault(require("debug"));
17
+
18
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
19
+
20
+ var _translator = _interopRequireDefault(require("@pie-lib/pie-toolbox/translator"));
21
+
22
+ var mv = _interopRequireWildcard(require("@pie-framework/math-validation"));
23
+
24
+ var _feedback = require("@pie-lib/pie-toolbox/feedback");
25
+
26
+ var _defaults = _interopRequireDefault(require("./defaults"));
27
+
28
+ var _controllerUtils = require("@pie-lib/pie-toolbox/controller-utils");
29
+
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
+
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+
34
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
35
+
36
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37
+
38
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
39
+
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
+
44
+ var translator = _translator["default"].translator;
45
+ var log = (0, _debug["default"])('@pie-element:math-templated:controller');
46
+
47
+ var getFeedback = function getFeedback(value) {
48
+ return value ? 'correct' : 'incorrect';
49
+ };
50
+
51
+ var getIsAnswerCorrect = function getIsAnswerCorrect(correctResponse, answerItem) {
52
+ var answerCorrect = false;
53
+
54
+ var opts = _objectSpread({
55
+ mode: correctResponse.validation || _defaults["default"].validationDefault
56
+ }, correctResponse.validation === 'literal' && {
57
+ literal: {
58
+ allowTrailingZeros: correctResponse.allowTrailingZeros || false,
59
+ ignoreOrder: correctResponse.ignoreOrder || false
60
+ }
61
+ });
62
+
63
+ if (!answerCorrect) {
64
+ var acceptedValues = [correctResponse.answer].concat((0, _toConsumableArray2["default"])(Object.values(correctResponse.alternates || {})));
65
+
66
+ try {
67
+ var _iterator = _createForOfIteratorHelper(acceptedValues),
68
+ _step;
69
+
70
+ try {
71
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
72
+ var value = _step.value;
73
+ answerCorrect = mv.latexEqual(answerItem.value, value, opts);
74
+ if (answerCorrect) break;
75
+ }
76
+ } catch (err) {
77
+ _iterator.e(err);
78
+ } finally {
79
+ _iterator.f();
80
+ }
81
+ } catch (e) {
82
+ log('Parse failure when evaluating math', e, correctResponse, answerItem);
83
+ answerCorrect = false;
84
+ }
85
+ }
86
+
87
+ return answerCorrect;
88
+ };
89
+
90
+ var getResponseCorrectness = function getResponseCorrectness(question, sessionResponse) {
91
+ var correctResponses = question.responses;
92
+
93
+ if (!sessionResponse) {
94
+ return {
95
+ correctness: 'unanswered',
96
+ score: 0,
97
+ correct: false
98
+ };
99
+ } else {
100
+ var correctAnswers = 0;
101
+ var score = 0;
102
+ var correct = false;
103
+ Object.keys(correctResponses).forEach(function (responseId) {
104
+ var answerItem = sessionResponse['r' + responseId];
105
+ var correctResponse = correctResponses[responseId];
106
+ var answerCorrect = getIsAnswerCorrect(correctResponse, answerItem);
107
+
108
+ if (answerCorrect) {
109
+ correctAnswers++;
110
+ }
111
+ }); // partial credit scoring: each correct answer is worth 1 / total answers point
112
+ // dichotomous scoring: for credit to be awarded, a correct answer must be entered for every response area
113
+
114
+ score = (correctAnswers / Object.keys(correctResponses).length).toFixed(2);
115
+ return {
116
+ correctness: correctAnswers > 0 ? 'correct' : 'incorrect',
117
+ score: correctAnswers > 0 ? score : 0,
118
+ correct: correct
119
+ };
120
+ }
121
+ };
122
+
123
+ var getCorrectness = function getCorrectness(question, env, session) {
124
+ if (env.mode === 'evaluate') {
125
+ return getResponseCorrectness(question, session && session.answers);
126
+ }
127
+ };
128
+
129
+ exports.getCorrectness = getCorrectness;
130
+
131
+ var getPartialScore = function getPartialScore(question, session) {
132
+ if (!session || (0, _isEmpty["default"])(session)) {
133
+ return 0;
134
+ }
135
+
136
+ return 1;
137
+ };
138
+
139
+ exports.getPartialScore = getPartialScore;
140
+
141
+ var outcome = function outcome(question, session, env) {
142
+ return new Promise(function (resolve) {
143
+ if (!session || (0, _isEmpty["default"])(session)) {
144
+ resolve({
145
+ score: 0,
146
+ empty: true
147
+ });
148
+ }
149
+
150
+ var partialScoringEnabled = _controllerUtils.partialScoring.enabled(question, env);
151
+
152
+ console.log('partialScoringEnabled: ', partialScoringEnabled);
153
+ session = normalizeSession(session);
154
+
155
+ if (env.mode !== 'evaluate') {
156
+ resolve({
157
+ score: undefined,
158
+ completed: undefined
159
+ });
160
+ } else {
161
+ var correctness = getCorrectness(question, env, session, true);
162
+ var score = correctness.score;
163
+ resolve({
164
+ score: partialScoringEnabled ? score : score === 1 ? 1 : 0
165
+ });
166
+ }
167
+ });
168
+ };
169
+
170
+ exports.outcome = outcome;
171
+
172
+ var createDefaultModel = function createDefaultModel() {
173
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
174
+ return _objectSpread(_objectSpread({}, _defaults["default"].model), model);
175
+ };
176
+
177
+ exports.createDefaultModel = createDefaultModel;
178
+
179
+ var normalizeSession = function normalizeSession(s) {
180
+ return _objectSpread({}, s);
181
+ };
182
+
183
+ exports.normalizeSession = normalizeSession;
184
+
185
+ var getTextFromHTML = function getTextFromHTML(html) {
186
+ return (html || '').replace(/<\/?[^>]+(>|$)/g, '');
187
+ };
188
+
189
+ var prepareVal = function prepareVal(html) {
190
+ return getTextFromHTML(html).trim();
191
+ };
192
+
193
+ exports.prepareVal = prepareVal;
194
+
195
+ var model = function model(question, session, env) {
196
+ return new Promise(function (resolve) {
197
+ session = session || {};
198
+ var normalizedQuestion = createDefaultModel(question);
199
+ var correctness = getCorrectness(normalizedQuestion, env, session);
200
+ var responses = normalizedQuestion.responses,
201
+ language = normalizedQuestion.language;
202
+ var note = normalizedQuestion.note;
203
+ var showNote = false; // check if there is at least one alternate response or if the validation for at least one response is not literal
204
+
205
+ Object.keys(responses).forEach(function (responseId) {
206
+ var correctResponse = responses[responseId];
207
+
208
+ if (correctResponse.alternates && Object.keys(correctResponse.alternates).length > 0) {
209
+ showNote = true;
210
+ } else if (correctResponse.validation !== 'literal') {
211
+ showNote = true;
212
+ }
213
+ });
214
+
215
+ if (!note) {
216
+ note = translator.t('mathInline.primaryCorrectWithAlternates', {
217
+ lng: language
218
+ });
219
+ }
220
+
221
+ var out = {
222
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
223
+ markup: normalizedQuestion.markup,
224
+ responses: env.mode === 'gather' ? null : normalizedQuestion.responses,
225
+ language: normalizedQuestion.language,
226
+ equationEditor: normalizedQuestion.equationEditor,
227
+ customKeys: normalizedQuestion.customKeys,
228
+ disabled: env.mode !== 'gather',
229
+ view: env.mode === 'view',
230
+ correctness: correctness,
231
+ env: env
232
+ };
233
+
234
+ var _ref = session || {},
235
+ _ref$answers = _ref.answers,
236
+ answers = _ref$answers === void 0 ? {} : _ref$answers;
237
+
238
+ var feedback = {};
239
+
240
+ if (env.mode === 'evaluate') {
241
+ Object.keys(responses).forEach(function (responseId) {
242
+ var answerItem = answers['r' + responseId];
243
+ var correctResponse = responses[responseId];
244
+ feedback[responseId] = getIsAnswerCorrect(correctResponse, answerItem);
245
+ });
246
+ }
247
+
248
+ if (env.mode === 'evaluate') {
249
+ out.correctResponse = {};
250
+ out.showNote = showNote;
251
+ out.note = note;
252
+ out.feedback = feedback;
253
+ } else {
254
+ out.responses = {};
255
+ out.showNote = false;
256
+ }
257
+
258
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
259
+ out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
260
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
261
+ } else {
262
+ out.rationale = null;
263
+ out.teacherInstructions = null;
264
+ }
265
+
266
+ log('out: ', out);
267
+ resolve(out);
268
+ });
269
+ };
270
+
271
+ exports.model = model;
272
+
273
+ var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
274
+ return new Promise(function (resolve) {
275
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
276
+ var correctResponse = Object.keys(question.responses).reduce(function (acc, responseId) {
277
+ acc['r' + responseId] = {
278
+ value: question.responses[responseId].answer
279
+ };
280
+ return acc;
281
+ }, {});
282
+ resolve({
283
+ id: '1',
284
+ answers: correctResponse
285
+ });
286
+ } else {
287
+ resolve(null);
288
+ }
289
+ });
290
+ };
291
+
292
+ exports.createCorrectResponseSession = createCorrectResponseSession;
293
+
294
+ var validate = function validate() {
295
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
296
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
297
+ var errors = {};
298
+ return errors;
299
+ };
300
+
301
+ exports.validate = validate;
302
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":["translator","Translator","log","getFeedback","value","getIsAnswerCorrect","correctResponse","answerItem","answerCorrect","opts","mode","validation","defaults","validationDefault","literal","allowTrailingZeros","ignoreOrder","acceptedValues","answer","Object","values","alternates","mv","latexEqual","e","getResponseCorrectness","question","sessionResponse","correctResponses","responses","correctness","score","correct","correctAnswers","keys","forEach","responseId","length","toFixed","getCorrectness","env","session","answers","getPartialScore","outcome","Promise","resolve","empty","partialScoringEnabled","partialScoring","enabled","console","normalizeSession","undefined","completed","createDefaultModel","model","s","getTextFromHTML","html","replace","prepareVal","trim","normalizedQuestion","language","note","showNote","t","lng","out","prompt","promptEnabled","markup","equationEditor","customKeys","disabled","view","feedback","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","createCorrectResponseSession","reduce","acc","id","validate","config","errors"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AACA,IAAME,GAAG,GAAG,uBAAM,wCAAN,CAAZ;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAAAC,KAAK;AAAA,SAAIA,KAAK,GAAG,SAAH,GAAe,WAAxB;AAAA,CAAzB;;AAEA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,eAAD,EAAkBC,UAAlB,EAAiC;AAC1D,MAAIC,aAAa,GAAG,KAApB;;AAEA,MAAMC,IAAI;AACRC,IAAAA,IAAI,EAAEJ,eAAe,CAACK,UAAhB,IAA8BC,qBAASC;AADrC,KAEJP,eAAe,CAACK,UAAhB,KAA+B,SAA/B,IAA4C;AAC9CG,IAAAA,OAAO,EAAE;AACPC,MAAAA,kBAAkB,EAAET,eAAe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,UAAAA,KAAK,EAAEsB,QAAQ,CAACG,SAAT,CAAmBO,UAAnB,EAA+BlB;AAAxC,SAAxB;AACA,eAAOmE,GAAP;AACD,OAHuB,EAGrB,EAHqB,CAAxB;AAKAvC,MAAAA,OAAO,CAAC;AAAEwC,QAAAA,EAAE,EAAE,GAAN;AAAW5C,QAAAA,OAAO,EAAEpC;AAApB,OAAD,CAAP;AACD,KAPD,MAOO;AACLwC,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAXD,CAD0C;AAAA,CAArC;;;;AAcA,IAAMyC,QAAQ,GAAG,SAAXA,QAAW,GAA6B;AAAA,MAA5B/B,KAA4B,uEAApB,EAAoB;AAAA,MAAhBgC,MAAgB,uEAAP,EAAO;AACnD,MAAMC,MAAM,GAAG,EAAf;AAEA,SAAOA,MAAP;AACD,CAJM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport Translator from '@pie-lib/pie-toolbox/translator';\nimport * as mv from '@pie-framework/math-validation';\nimport { getFeedbackForCorrectness } from '@pie-lib/pie-toolbox/feedback';\n\nimport defaults from './defaults';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\n\nconst { translator } = Translator;\nconst log = debug('@pie-element:math-templated:controller');\n\nconst getFeedback = value => value ? 'correct' : 'incorrect';\n\nconst getIsAnswerCorrect = (correctResponse, answerItem) => {\n let answerCorrect = false;\n\n const opts = {\n mode: correctResponse.validation || defaults.validationDefault,\n ...(correctResponse.validation === 'literal' && {\n literal: {\n allowTrailingZeros: correctResponse.allowTrailingZeros || false,\n ignoreOrder: correctResponse.ignoreOrder || false,\n }\n })\n };\n\n if (!answerCorrect) {\n const acceptedValues = [\n correctResponse.answer,\n ...Object.values(correctResponse.alternates || {})\n ];\n\n try {\n for (const value of acceptedValues) {\n answerCorrect = mv.latexEqual(answerItem.value, value, opts);\n if (answerCorrect) break;\n }\n } catch (e) {\n log('Parse failure when evaluating math', e, correctResponse, answerItem);\n answerCorrect = false;\n }\n }\n\n return answerCorrect;\n};\n\nconst getResponseCorrectness = (question, sessionResponse) => {\n const correctResponses = question.responses;\n\n if (!sessionResponse) {\n return {\n correctness: 'unanswered',\n score: 0,\n correct: false,\n };\n } else {\n let correctAnswers = 0;\n let score = 0;\n let correct = false;\n Object.keys(correctResponses).forEach((responseId) => {\n const answerItem = sessionResponse['r' + responseId];\n const correctResponse = correctResponses[responseId];\n\n const answerCorrect = getIsAnswerCorrect(correctResponse, answerItem);\n if (answerCorrect) {\n correctAnswers++;\n }\n });\n\n // partial credit scoring: each correct answer is worth 1 / total answers point\n // dichotomous scoring: for credit to be awarded, a correct answer must be entered for every response area\n score = (correctAnswers / Object.keys(correctResponses).length).toFixed(2);\n\n return {\n correctness: correctAnswers > 0 ? 'correct' : 'incorrect',\n score: correctAnswers > 0 ? score : 0,\n correct\n };\n }\n};\n\nexport const getCorrectness = (question, env, session) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(\n question,\n session && session.answers\n );\n }\n};\n\nexport const getPartialScore = (question, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n return 1;\n};\n\nexport const outcome = (question, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n const partialScoringEnabled = partialScoring.enabled(question, env);\n console.log('partialScoringEnabled: ', partialScoringEnabled);\n session = normalizeSession(session);\n\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n const correctness = getCorrectness(question, env, session, true);\n const score = correctness.score;\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0 });\n }\n });\n\nexport const createDefaultModel = (model = {}) => ({\n ...defaults.model,\n ...model,\n});\n\nexport const normalizeSession = (s) => ({ ...s });\n\nconst getTextFromHTML = html => (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n\nexport const prepareVal = html => getTextFromHTML(html).trim();\n\nexport const model = (question, session, env) => {\n return new Promise((resolve) => {\n session = session || {};\n const normalizedQuestion = createDefaultModel(question);\n const correctness = getCorrectness(normalizedQuestion, env, session);\n const { responses, language } = normalizedQuestion;\n let { note } = normalizedQuestion;\n let showNote = false;\n\n // check if there is at least one alternate response or if the validation for at least one response is not literal\n Object.keys(responses).forEach((responseId) => {\n const correctResponse = responses[responseId];\n if (correctResponse.alternates && Object.keys(correctResponse.alternates).length > 0) {\n showNote = true;\n } else if (correctResponse.validation !== 'literal') {\n showNote = true;\n }\n });\n\n if (!note) {\n note = translator.t('mathInline.primaryCorrectWithAlternates', { lng: language });\n }\n\n const out = {\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n responses: env.mode === 'gather' ? null : normalizedQuestion.responses,\n language: normalizedQuestion.language,\n equationEditor: normalizedQuestion.equationEditor,\n customKeys: normalizedQuestion.customKeys,\n disabled: env.mode !== 'gather',\n view: env.mode === 'view',\n correctness,\n env,\n };\n\n const { answers = {} } = session || {};\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n Object.keys(responses).forEach((responseId) => {\n const answerItem = answers['r' + responseId];\n const correctResponse = responses[responseId];\n feedback[responseId] = getIsAnswerCorrect(correctResponse, answerItem);\n });\n }\n\n if (env.mode === 'evaluate') {\n out.correctResponse = {};\n out.showNote = showNote;\n out.note = note;\n out.feedback = feedback;\n } else {\n out.responses = {};\n out.showNote = false;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n log('out: ', out);\n resolve(out);\n });\n};\n\nexport const createCorrectResponseSession = (question, env) =>\n new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const correctResponse = Object.keys(question.responses).reduce((acc, responseId) => {\n acc['r' + responseId] = { value: question.responses[responseId].answer };\n return acc;\n }, {});\n\n resolve({ id: '1', answers: correctResponse });\n } else {\n resolve(null);\n }\n });\n\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n\n return errors;\n};\n"],"file":"index.js"}
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@pie-element/math-templated-controller",
3
+ "private": true,
4
+ "version": "2.9.1",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "dependencies": {
9
+ "@pie-lib/pie-toolbox": "1.19.0",
10
+ "@pie-framework/math-validation": "^1.2.2",
11
+ "debug": "^3.1.0",
12
+ "lodash": "^4.17.15"
13
+ },
14
+ "devDependencies": {
15
+ "lodash": "^4.17.15"
16
+ },
17
+ "author": "",
18
+ "license": "ISC"
19
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "description": "Config Object for @pie-elements/boilerplate-item-type",
3
+ "additionalProperties": false,
4
+ "type": "object",
5
+ "properties": {
6
+ "prompt": {
7
+ "title": "ConfigureProp",
8
+ "type": "object",
9
+ "properties": {
10
+ "settings": {
11
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
12
+ "type": "boolean",
13
+ "title": "settings"
14
+ },
15
+ "label": {
16
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
17
+ "type": "string",
18
+ "title": "label"
19
+ }
20
+ }
21
+ },
22
+ "showPrompt": {
23
+ "description": "Determines whether prompt field will be displayed or not",
24
+ "default": true,
25
+ "type": "boolean",
26
+ "title": "showPrompt"
27
+ },
28
+ "promptLabel": {
29
+ "description": "The label for the item stem/prompt field",
30
+ "default": "Item Stemm",
31
+ "type": "string",
32
+ "title": "promptLabel"
33
+ },
34
+ "contentDimensions": {
35
+ "description": "Indicates the dimensions configuration for the authoring container\nNote: Some items have a default minimum width because of their content, but if\nthe minWidth is lower than this, the overflow behavior will take care of that",
36
+ "default": ": {}",
37
+ "type": "object",
38
+ "properties": {
39
+ "maxHeight": {
40
+ "description": "Indicates the max height of the authoring container",
41
+ "default": "undefined",
42
+ "type": [
43
+ "string",
44
+ "number"
45
+ ],
46
+ "title": "maxHeight"
47
+ },
48
+ "maxWidth": {
49
+ "description": "Indicates the max width of the authoring container",
50
+ "default": "undefined",
51
+ "type": [
52
+ "string",
53
+ "number"
54
+ ],
55
+ "title": "maxWidth"
56
+ },
57
+ "minHeight": {
58
+ "description": "Indicates the min height of the authoring container",
59
+ "default": "undefined",
60
+ "type": [
61
+ "string",
62
+ "number"
63
+ ],
64
+ "title": "minHeight"
65
+ },
66
+ "minWidth": {
67
+ "description": "Indicates the min width of the authoring container",
68
+ "default": "undefined",
69
+ "type": [
70
+ "string",
71
+ "number"
72
+ ],
73
+ "title": "minWidth"
74
+ }
75
+ },
76
+ "title": "contentDimensions"
77
+ },
78
+ "settingsPartialScoring": {
79
+ "description": "Indicates whether the settings panel wil allow the author to modify settings for partial scoring",
80
+ "default": true,
81
+ "type": "boolean",
82
+ "title": "settingsPartialScoring"
83
+ }
84
+ },
85
+ "definitions": {
86
+ "ConfigureProp": {
87
+ "title": "ConfigureProp",
88
+ "type": "object",
89
+ "properties": {
90
+ "settings": {
91
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
92
+ "type": "boolean",
93
+ "title": "settings"
94
+ },
95
+ "label": {
96
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
97
+ "type": "string",
98
+ "title": "label"
99
+ }
100
+ }
101
+ }
102
+ },
103
+ "$schema": "http://json-schema.org/draft-07/schema#"
104
+ }
@@ -0,0 +1,85 @@
1
+ Config Object for @pie-elements/boilerplate-item-type
2
+
3
+ The schema defines the following properties:
4
+
5
+ # `prompt` (object)
6
+
7
+ Properties of the `prompt` object:
8
+
9
+ ## `settings` (boolean)
10
+
11
+ Indicates if the item has to be displayed in the Settings Panel
12
+
13
+ ## `label` (string)
14
+
15
+ Indicates the label for the item that has to be displayed in the Settings Panel
16
+
17
+ # `showPrompt` (boolean)
18
+
19
+ Determines whether prompt field will be displayed or not
20
+
21
+ Default: `true`
22
+
23
+ # `promptLabel` (string)
24
+
25
+ The label for the item stem/prompt field
26
+
27
+ Default: `"Item Stemm"`
28
+
29
+ # `contentDimensions` (object)
30
+
31
+ Indicates the dimensions configuration for the authoring container
32
+ Note: Some items have a default minimum width because of their content, but if
33
+ the minWidth is lower than this, the overflow behavior will take care of that
34
+
35
+ Properties of the `contentDimensions` object:
36
+
37
+ ## `maxHeight` (string,number)
38
+
39
+ Indicates the max height of the authoring container
40
+
41
+ Default: `"undefined"`
42
+
43
+ ## `maxWidth` (string,number)
44
+
45
+ Indicates the max width of the authoring container
46
+
47
+ Default: `"undefined"`
48
+
49
+ ## `minHeight` (string,number)
50
+
51
+ Indicates the min height of the authoring container
52
+
53
+ Default: `"undefined"`
54
+
55
+ ## `minWidth` (string,number)
56
+
57
+ Indicates the min width of the authoring container
58
+
59
+ Default: `"undefined"`
60
+
61
+ Default: `": {}"`
62
+
63
+ # `settingsPartialScoring` (boolean)
64
+
65
+ Indicates whether the settings panel wil allow the author to modify settings for partial scoring
66
+
67
+ Default: `true`
68
+
69
+ ---
70
+
71
+ # Sub Schemas
72
+
73
+ The schema defines the following additional types:
74
+
75
+ ## `ConfigureProp` (object)
76
+
77
+ Properties of the `ConfigureProp` object:
78
+
79
+ ### `settings` (boolean)
80
+
81
+ Indicates if the item has to be displayed in the Settings Panel
82
+
83
+ ### `label` (string)
84
+
85
+ Indicates the label for the item that has to be displayed in the Settings Panel
@@ -0,0 +1,8 @@
1
+ const { model } = require('./generate');
2
+
3
+ module.exports = {
4
+ elements: {
5
+ 'math-templated': '../..',
6
+ },
7
+ models: [model('1', 'math-templated')],
8
+ };
@@ -0,0 +1,42 @@
1
+ exports.model = (id, element) => ({
2
+ id,
3
+ element,
4
+ rationale: 'Rationale',
5
+ partialScoring: true,
6
+ prompt: 'There are 24 students in the class. They had the choice to buy supplies from two different stores, Store A and B. Each of them bought 2 binders and 5 notebooks. The students have a total of $420 to spend.',
7
+ scoringType: 'auto',
8
+ feedbackEnabled: false,
9
+ promptEnabled: true,
10
+ rationaleEnabled: true,
11
+ teacherInstructionsEnabled: true,
12
+ studentInstructionsEnabled: true,
13
+ toolbarEditorPosition: 'bottom',
14
+ validationDefault: 'literal',
15
+ ignoreOrderDefault: false,
16
+ allowTrailingZerosDefault: false,
17
+ teacherInstructions: 'These are teacher instructions',
18
+ customKeys: [], // these have effect on player only?
19
+ equationEditor: 'geometry',
20
+ markup: `
21
+ <p>If the unit price of a notebook in Store A is $1.50, what is the unit price of a binder? \${{0}}</p>
22
+ <p>If the unit price of a binder in Store B is $2.80, what is the unit price of a notebook? \${{1}}</p>
23
+ `,
24
+ responses: {
25
+ 0: {
26
+ allowTrailingZeros: false,
27
+ answer: '5',
28
+ id: '1',
29
+ validation: 'symbolic',
30
+ ignoreOrder: false,
31
+ alternates: {}
32
+ },
33
+ 1: {
34
+ allowTrailingZeros: false,
35
+ answer: '2.38',
36
+ id: '1',
37
+ validation: 'literal',
38
+ ignoreOrder: false,
39
+ alternates: {}
40
+ }
41
+ }
42
+ });
@@ -0,0 +1 @@
1
+ <math-templated pie-id="1"></math-templated>
@@ -0,0 +1,14 @@
1
+ module.exports = [
2
+ {
3
+ "id": "1",
4
+ "element": "math-templated",
5
+ "answers": {
6
+ "r0": {
7
+ "value": "0"
8
+ },
9
+ "r1": {
10
+ "value": "1"
11
+ },
12
+ }
13
+ },
14
+ ];
@@ -0,0 +1,51 @@
1
+ {
2
+ "description": "Pie Model Object for @pie-elements/boilerplate-item-type",
3
+ "additionalProperties": false,
4
+ "type": "object",
5
+ "properties": {
6
+ "prompt": {
7
+ "description": "The user prompt/item stem",
8
+ "type": "string",
9
+ "title": "prompt"
10
+ },
11
+ "promptEnabled": {
12
+ "description": "Determines if prompt should show",
13
+ "type": "boolean",
14
+ "title": "promptEnabled"
15
+ },
16
+ "id": {
17
+ "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
18
+ "type": "string",
19
+ "title": "id"
20
+ },
21
+ "element": {
22
+ "description": "The html Element tag name",
23
+ "type": "string",
24
+ "title": "element"
25
+ }
26
+ },
27
+ "required": [
28
+ "element",
29
+ "id",
30
+ "prompt"
31
+ ],
32
+ "definitions": {
33
+ "ConfigureProp": {
34
+ "title": "ConfigureProp",
35
+ "type": "object",
36
+ "properties": {
37
+ "settings": {
38
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
39
+ "type": "boolean",
40
+ "title": "settings"
41
+ },
42
+ "label": {
43
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
44
+ "type": "string",
45
+ "title": "label"
46
+ }
47
+ }
48
+ }
49
+ },
50
+ "$schema": "http://json-schema.org/draft-07/schema#"
51
+ }