@pie-element/ebsr 13.0.0-beta.0 → 13.0.0-next.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 +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/defaults.js +9 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +6 -6
- package/configure/lib/index.js.map +1 -1
- package/configure/package.json +7 -7
- package/configure/src/defaults.js +3 -1
- package/configure/src/index.js +2 -2
- package/controller/CHANGELOG.md +0 -11
- package/controller/lib/index.js +6 -7
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +2 -3
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +4 -4
- package/controller/src/index.js +1 -2
- package/controller/src/utils.js +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/print.js +8 -9
- package/lib/print.js.map +1 -1
- package/module/configure.js +1 -0
- package/module/controller.js +5574 -0
- package/module/demo.js +77 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +115 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +10 -6
- package/src/index.js +1 -1
- package/src/print.js +9 -10
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +0 -1972
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +0 -4213
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +0 -35
- package/configure/node_modules/@pie-element/multiple-choice/README.md +0 -56
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +0 -1387
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +0 -3351
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/__tests__/root.test.js +0 -248
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +0 -200
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +0 -211
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +0 -477
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +0 -18
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +0 -22
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +0 -527
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +0 -2316
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/__tests__/index.test.js +0 -520
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/__tests__/utils.test.js +0 -8
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +0 -33
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +0 -251
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +0 -16
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +0 -15
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +0 -2993
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +0 -2217
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +0 -8
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +0 -61
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/pie.manifest.json +0 -11
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +0 -7
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +0 -1332
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +0 -1015
- package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/choice-input-test.js +0 -117
- package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/index-test.js +0 -151
- package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/key-events-test.js +0 -95
- package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/multiple-choice-test.js +0 -223
- package/configure/node_modules/@pie-element/multiple-choice/lib/__tests__/session-updater-test.js +0 -70
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +0 -370
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +0 -197
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +0 -130
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +0 -292
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +0 -54
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +0 -386
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +0 -92
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +0 -37
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +0 -1
- package/configure/node_modules/@pie-element/multiple-choice/package.json +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
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
|
-
## [12.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr@12.3.2...@pie-element/ebsr@12.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [12.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr@12.3.1...@pie-element/ebsr@12.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
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
|
-
## [11.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-configure@11.3.2...@pie-element/ebsr-configure@11.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [11.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-configure@11.3.1...@pie-element/ebsr-configure@11.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
9
8
|
const defaultConfig = {
|
|
10
9
|
addChoiceButton: {
|
|
11
10
|
settings: true,
|
|
@@ -125,6 +124,9 @@ const defaultConfig = {
|
|
|
125
124
|
}
|
|
126
125
|
},
|
|
127
126
|
baseInputConfiguration: {
|
|
127
|
+
h3: {
|
|
128
|
+
disabled: true
|
|
129
|
+
},
|
|
128
130
|
audio: {
|
|
129
131
|
disabled: false
|
|
130
132
|
},
|
|
@@ -173,6 +175,9 @@ var _default = exports.default = {
|
|
|
173
175
|
},
|
|
174
176
|
configuration: {
|
|
175
177
|
baseInputConfiguration: {
|
|
178
|
+
h3: {
|
|
179
|
+
disabled: true
|
|
180
|
+
},
|
|
176
181
|
audio: {
|
|
177
182
|
disabled: false
|
|
178
183
|
},
|
|
@@ -203,8 +208,8 @@ var _default = exports.default = {
|
|
|
203
208
|
settings: false,
|
|
204
209
|
label: 'Scoring Type'
|
|
205
210
|
},
|
|
206
|
-
partA: (0,
|
|
207
|
-
partB: (0,
|
|
211
|
+
partA: (0, _lodashEs.cloneDeep)(defaultConfig),
|
|
212
|
+
partB: (0, _lodashEs.cloneDeep)(defaultConfig),
|
|
208
213
|
partLabels: {
|
|
209
214
|
settings: true,
|
|
210
215
|
label: 'Part Labels'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","names":["
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["_lodashEs","require","defaultConfig","addChoiceButton","settings","label","choiceMode","choicePrefix","deleteChoice","feedback","lockChoiceOrder","prompt","inputConfiguration","audio","disabled","video","image","required","rationale","settingsPanelDisabled","studentInstructions","teacherInstructions","choicesLayout","gridColumns","spellCheck","enabled","maxImageWidth","choices","maxImageHeight","mathMlOptions","mmlOutput","mmlEditing","baseInputConfiguration","h3","textAlign","showParagraphs","separateParagraphs","partModel","base","feedbackEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","studentInstructionsEnabled","teacherInstructionsEnabled","toolbarEditorPosition","_default","exports","default","model","partLabels","partLabelType","partA","partB","configuration","partialScoring","scoringType","cloneDeep","language","languageChoices","options"],"sources":["../src/defaults.js"],"sourcesContent":["import { cloneDeep } from 'lodash-es';\n\nconst defaultConfig = {\n addChoiceButton: {\n settings: true,\n label: 'Add a Choice',\n },\n choiceMode: {\n settings: true,\n label: 'Response Type',\n },\n choicePrefix: {\n settings: true,\n label: 'Choice Labels',\n },\n deleteChoice: {\n settings: true,\n },\n feedback: {\n settings: true,\n label: 'Feedback',\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n settingsPanelDisabled: true,\n studentInstructions: {\n settings: false,\n label: 'Student Instructions',\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n choicesLayout: {\n settings: false,\n label: 'Choices Layout',\n },\n gridColumns: {\n label: 'Grid columns',\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 636,\n choices: 636,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n choices: 300,\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n choices: {\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n};\n\nconst partModel = (base) => ({\n choiceMode: 'radio',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n spellCheckEnabled: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n ...base,\n});\n\nexport default {\n model: {\n partLabels: true,\n partLabelType: 'Letters',\n // partialScoring: false,\n partA: partModel(),\n partB: partModel(),\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n partialScoring: {\n label: 'Allow Partial Scoring',\n // this will turn off partial scoring toggle in the settings tab by default for the interaction\n // as we'd like partial scoring to be controlled from the environment entirely\n // if any other consumers would like to enable it for themselves, they can do so from their model directly.\n settings: false,\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type',\n },\n partA: cloneDeep(defaultConfig),\n partB: cloneDeep(defaultConfig),\n partLabels: {\n settings: true,\n label: 'Part Labels',\n },\n settingsPanelDisabled: false,\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAAG;EACpBC,eAAe,EAAE;IACfC,QAAQ,EAAE,IAAI;IACdC,KAAK,EAAE;EACT,CAAC;EACDC,UAAU,EAAE;IACVF,QAAQ,EAAE,IAAI;IACdC,KAAK,EAAE;EACT,CAAC;EACDE,YAAY,EAAE;IACZH,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IAC/BmD,KAAK,EAAE,IAAAI,mBAAS,EAACvD,aAAa,CAAC;IAC/BgD,UAAU,EAAE;MACV9C,QAAQ,EAAE,IAAI;MACdC,KAAK,EAAE;IACT,CAAC;IACDc,qBAAqB,EAAE,KAAK;IAC5BuC,QAAQ,EAAE;MACRtD,QAAQ,EAAE,KAAK;MACfC,KAAK,EAAE,kBAAkB;MACzBoB,OAAO,EAAE;IACX,CAAC;IACDkC,eAAe,EAAE;MACftD,KAAK,EAAE,kBAAkB;MACzBuD,OAAO,EAAE;IACX;EACF;AACF,CAAC","ignoreList":[]}
|
package/configure/lib/index.js
CHANGED
|
@@ -10,9 +10,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _client = require("react-dom/client");
|
|
11
11
|
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
12
12
|
var _lib = _interopRequireDefault(require("@pie-element/multiple-choice/configure/lib"));
|
|
13
|
-
var
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
14
14
|
var _main = _interopRequireDefault(require("./main"));
|
|
15
|
-
var
|
|
15
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
16
16
|
const MODEL_UPDATED = _pieConfigureEvents.ModelUpdatedEvent.TYPE;
|
|
17
17
|
const MC_TAG_NAME = 'ebsr-multiple-choice-configure';
|
|
18
18
|
class EbsrMCConfigure extends _lib.default {}
|
|
@@ -23,7 +23,7 @@ const defineMultipleChoice = () => {
|
|
|
23
23
|
};
|
|
24
24
|
defineMultipleChoice();
|
|
25
25
|
const prepareCustomizationObject = (config, model) => {
|
|
26
|
-
const configuration = (0,
|
|
26
|
+
const configuration = (0, _lodashEs.defaults)(config, _defaults.default.configuration);
|
|
27
27
|
return {
|
|
28
28
|
configuration,
|
|
29
29
|
model
|
|
@@ -31,7 +31,7 @@ const prepareCustomizationObject = (config, model) => {
|
|
|
31
31
|
};
|
|
32
32
|
const {
|
|
33
33
|
model: modelDefault
|
|
34
|
-
} =
|
|
34
|
+
} = _defaults.default || {};
|
|
35
35
|
class EbsrConfigure extends HTMLElement {
|
|
36
36
|
constructor() {
|
|
37
37
|
super();
|
|
@@ -56,7 +56,7 @@ class EbsrConfigure extends HTMLElement {
|
|
|
56
56
|
});
|
|
57
57
|
this._root = null;
|
|
58
58
|
this._model = EbsrConfigure.createDefaultModel();
|
|
59
|
-
this._configuration =
|
|
59
|
+
this._configuration = _defaults.default.configuration;
|
|
60
60
|
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
61
61
|
}
|
|
62
62
|
set model(m) {
|
|
@@ -70,7 +70,7 @@ class EbsrConfigure extends HTMLElement {
|
|
|
70
70
|
set configuration(c) {
|
|
71
71
|
const info = prepareCustomizationObject(c, this._model);
|
|
72
72
|
const newConfiguration = {
|
|
73
|
-
...
|
|
73
|
+
..._defaults.default.configuration,
|
|
74
74
|
...info.configuration
|
|
75
75
|
};
|
|
76
76
|
this._configuration = newConfiguration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_pieConfigureEvents","_lib","_defaults","_main","_defaults2","MODEL_UPDATED","ModelUpdatedEvent","TYPE","MC_TAG_NAME","EbsrMCConfigure","MultipleChoiceConfigure","defineMultipleChoice","customElements","get","define","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","modelDefault","EbsrConfigure","HTMLElement","constructor","_defineProperty2","default","m","reset","_model","createDefaultModel","dispatchModelUpdated","_render","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","update","dispatchEvent","_root","_configuration","onConfigurationChanged","bind","resetValue","c","info","newConfiguration","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","onModelChanged","connectedCallback","addEventListener","onModelUpdated","element","React","createElement","Main","createRoot","render","disconnectedCallback","removeEventListener","unmount","exports","partA","partB","choicesLayout","verticalMode"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ModelUpdatedEvent } from '@pie-framework/pie-configure-events';\nimport MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';\nimport defaults from 'lodash/defaults';\nimport Main from './main';\n\nimport sensibleDefaults from './defaults';\n\nconst MODEL_UPDATED = ModelUpdatedEvent.TYPE;\nconst MC_TAG_NAME = 'ebsr-multiple-choice-configure';\n\nclass EbsrMCConfigure extends MultipleChoiceConfigure {}\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMCConfigure);\n }\n};\n\ndefineMultipleChoice();\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model,\n };\n};\n\nconst { model: modelDefault } = sensibleDefaults || {};\n\nexport default class EbsrConfigure extends HTMLElement {\n static createDefaultModel = ({ partA = {}, partB = {}, ...model } = {}, defaults = modelDefault) => ({\n ...defaults,\n ...model,\n partA: {\n ...defaults.partA,\n ...partA,\n choicesLayout:\n partA.choicesLayout || (partA.verticalMode === false && 'horizontal') || defaults.partA.choicesLayout,\n },\n partB: {\n ...defaults.partB,\n ...partB,\n choicesLayout:\n partB.choicesLayout || (partB.verticalMode === false && 'horizontal') || defaults.partB.choicesLayout,\n },\n });\n\n constructor() {\n super();\n this._root = null;\n\n this._model = EbsrConfigure.createDefaultModel();\n\n this._configuration = sensibleDefaults.configuration;\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(m) {\n this._model = EbsrConfigure.createDefaultModel(m, this._model);\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged = (m, reset) => {\n this._model = EbsrConfigure.createDefaultModel(m, this._model);\n\n this.dispatchModelUpdated(reset);\n this._render();\n };\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...info.configuration,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n onModelUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target && e.target.getAttribute('id');\n\n if (id) {\n if (e.update) {\n this._model[`part${id}`] = e.update;\n }\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n }\n };\n\n connectedCallback() {\n this.addEventListener(MODEL_UPDATED, this.onModelUpdated);\n this._render();\n }\n\n _render() {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n\n disconnectedCallback() {\n this.removeEventListener(MODEL_UPDATED, this.onModelUpdated);\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,I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,CAAC;EAAEC,KAAK,GAAG,CAAC,CAAC;EAAE,GAAG1D;AAAM,CAAC,GAAG,CAAC,CAAC,EAAEE,QAAQ,GAAGE,YAAY,MAAM;EACnG,GAAGF,QAAQ;EACX,GAAGF,KAAK;EACRyD,KAAK,EAAE;IACL,GAAGvD,QAAQ,CAACuD,KAAK;IACjB,GAAGA,KAAK;IACRE,aAAa,EACXF,KAAK,CAACE,aAAa,IAAKF,KAAK,CAACG,YAAY,KAAK,KAAK,IAAI,YAAa,IAAI1D,QAAQ,CAACuD,KAAK,CAACE;EAC5F,CAAC;EACDD,KAAK,EAAE;IACL,GAAGxD,QAAQ,CAACwD,KAAK;IACjB,GAAGA,KAAK;IACRC,aAAa,EACXD,KAAK,CAACC,aAAa,IAAKD,KAAK,CAACE,YAAY,KAAK,KAAK,IAAI,YAAa,IAAI1D,QAAQ,CAACwD,KAAK,CAACC;EAC5F;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_pieConfigureEvents","_lib","_lodashEs","_main","_defaults","MODEL_UPDATED","ModelUpdatedEvent","TYPE","MC_TAG_NAME","EbsrMCConfigure","MultipleChoiceConfigure","defineMultipleChoice","customElements","get","define","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","modelDefault","EbsrConfigure","HTMLElement","constructor","_defineProperty2","default","m","reset","_model","createDefaultModel","dispatchModelUpdated","_render","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","update","dispatchEvent","_root","_configuration","onConfigurationChanged","bind","resetValue","c","info","newConfiguration","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","onModelChanged","connectedCallback","addEventListener","onModelUpdated","element","React","createElement","Main","createRoot","render","disconnectedCallback","removeEventListener","unmount","exports","partA","partB","choicesLayout","verticalMode"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ModelUpdatedEvent } from '@pie-framework/pie-configure-events';\nimport MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';\nimport { defaults } from 'lodash-es';\nimport Main from './main';\n\nimport sensibleDefaults from './defaults';\n\nconst MODEL_UPDATED = ModelUpdatedEvent.TYPE;\nconst MC_TAG_NAME = 'ebsr-multiple-choice-configure';\n\nclass EbsrMCConfigure extends MultipleChoiceConfigure {}\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMCConfigure);\n }\n};\n\ndefineMultipleChoice();\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model,\n };\n};\n\nconst { model: modelDefault } = sensibleDefaults || {};\n\nexport default class EbsrConfigure extends HTMLElement {\n static createDefaultModel = ({ partA = {}, partB = {}, ...model } = {}, defaults = modelDefault) => ({\n ...defaults,\n ...model,\n partA: {\n ...defaults.partA,\n ...partA,\n choicesLayout:\n partA.choicesLayout || (partA.verticalMode === false && 'horizontal') || defaults.partA.choicesLayout,\n },\n partB: {\n ...defaults.partB,\n ...partB,\n choicesLayout:\n partB.choicesLayout || (partB.verticalMode === false && 'horizontal') || defaults.partB.choicesLayout,\n },\n });\n\n constructor() {\n super();\n this._root = null;\n\n this._model = EbsrConfigure.createDefaultModel();\n\n this._configuration = sensibleDefaults.configuration;\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(m) {\n this._model = EbsrConfigure.createDefaultModel(m, this._model);\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged = (m, reset) => {\n this._model = EbsrConfigure.createDefaultModel(m, this._model);\n\n this.dispatchModelUpdated(reset);\n this._render();\n };\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...info.configuration,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n onModelUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target && e.target.getAttribute('id');\n\n if (id) {\n if (e.update) {\n this._model[`part${id}`] = e.update;\n }\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n }\n };\n\n connectedCallback() {\n this.addEventListener(MODEL_UPDATED, this.onModelUpdated);\n this._render();\n }\n\n _render() {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n\n disconnectedCallback() {\n this.removeEventListener(MODEL_UPDATED, this.onModelUpdated);\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAA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AAC,CAAC;EAAE,GAAG1D;AAAM,CAAC,GAAG,CAAC,CAAC,EAAEE,QAAQ,GAAGE,YAAY,MAAM;EACnG,GAAGF,QAAQ;EACX,GAAGF,KAAK;EACRyD,KAAK,EAAE;IACL,GAAGvD,QAAQ,CAACuD,KAAK;IACjB,GAAGA,KAAK;IACRE,aAAa,EACXF,KAAK,CAACE,aAAa,IAAKF,KAAK,CAACG,YAAY,KAAK,KAAK,IAAI,YAAa,IAAI1D,QAAQ,CAACuD,KAAK,CAACE;EAC5F,CAAC;EACDD,KAAK,EAAE;IACL,GAAGxD,QAAQ,CAACwD,KAAK;IACjB,GAAGA,KAAK;IACRC,aAAa,EACXD,KAAK,CAACC,aAAa,IAAKD,KAAK,CAACE,YAAY,KAAK,KAAK,IAAI,YAAa,IAAI1D,QAAQ,CAACwD,KAAK,CAACC;EAC5F;AACF,CAAC,CAAC","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "12.0.0-beta.
|
|
4
|
+
"version": "12.0.0-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"@emotion/style": "^0.8.0",
|
|
12
12
|
"@mui/icons-material": "^7.3.4",
|
|
13
13
|
"@mui/material": "^7.3.4",
|
|
14
|
-
"@pie-element/multiple-choice": "12.0.0-beta.
|
|
14
|
+
"@pie-element/multiple-choice": "^12.0.0-beta.1",
|
|
15
15
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
16
|
-
"@pie-lib/config-ui": "
|
|
17
|
-
"lodash": "^4.17.
|
|
18
|
-
"prop-types": "^15.
|
|
19
|
-
"react": "18.
|
|
20
|
-
"react-dom": "18.
|
|
16
|
+
"@pie-lib/config-ui": "12.1.1-next.3",
|
|
17
|
+
"lodash-es": "^4.17.23",
|
|
18
|
+
"prop-types": "^15.8.1",
|
|
19
|
+
"react": "18.3.1",
|
|
20
|
+
"react-dom": "18.3.1"
|
|
21
21
|
},
|
|
22
22
|
"license": "ISC"
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import cloneDeep from 'lodash
|
|
1
|
+
import { cloneDeep } from 'lodash-es';
|
|
2
2
|
|
|
3
3
|
const defaultConfig = {
|
|
4
4
|
addChoiceButton: {
|
|
@@ -95,6 +95,7 @@ const defaultConfig = {
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
baseInputConfiguration: {
|
|
98
|
+
h3: { disabled: true },
|
|
98
99
|
audio: { disabled: false },
|
|
99
100
|
video: { disabled: false },
|
|
100
101
|
image: { disabled: false },
|
|
@@ -133,6 +134,7 @@ export default {
|
|
|
133
134
|
},
|
|
134
135
|
configuration: {
|
|
135
136
|
baseInputConfiguration: {
|
|
137
|
+
h3: { disabled: true },
|
|
136
138
|
audio: { disabled: false },
|
|
137
139
|
video: { disabled: false },
|
|
138
140
|
image: { disabled: false },
|
package/configure/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { ModelUpdatedEvent } from '@pie-framework/pie-configure-events';
|
|
4
4
|
import MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';
|
|
5
|
-
import defaults from 'lodash
|
|
5
|
+
import { defaults } from 'lodash-es';
|
|
6
6
|
import Main from './main';
|
|
7
7
|
|
|
8
8
|
import sensibleDefaults from './defaults';
|
|
@@ -104,7 +104,7 @@ export default class EbsrConfigure extends HTMLElement {
|
|
|
104
104
|
|
|
105
105
|
// check if the language is already included in the languageChoices.options array
|
|
106
106
|
// and if not, then add it.
|
|
107
|
-
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
107
|
+
if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {
|
|
108
108
|
this._configuration.languageChoices.options.push({
|
|
109
109
|
value: this._model.language,
|
|
110
110
|
label: this._model.language,
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
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
|
-
## [9.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@9.3.2...@pie-element/ebsr-controller@9.3.3) (2025-11-27)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* bump libs PD-5274, PD-5211, PD-5248 ([7610b25](https://github.com/pie-framework/pie-elements/commit/7610b25423956b6492f33322513b3430051fca77))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [9.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@9.3.1...@pie-element/ebsr-controller@9.3.2) (2025-10-22)
|
|
18
7
|
|
|
19
8
|
|
package/controller/lib/index.js
CHANGED
|
@@ -12,8 +12,7 @@ exports.validate = void 0;
|
|
|
12
12
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
13
13
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
14
14
|
var _utils = require("./utils");
|
|
15
|
-
var
|
|
16
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
15
|
+
var _lodashEs = require("lodash-es");
|
|
17
16
|
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
18
17
|
const {
|
|
19
18
|
translator
|
|
@@ -97,7 +96,7 @@ async function model(question, session, env, updateSession) {
|
|
|
97
96
|
shuffledValues[part] = update.shuffledValues;
|
|
98
97
|
resolve();
|
|
99
98
|
});
|
|
100
|
-
const partASession = (0,
|
|
99
|
+
const partASession = (0, _lodashEs.get)(session, 'value.partA');
|
|
101
100
|
const partALockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partA, partASession, env);
|
|
102
101
|
const {
|
|
103
102
|
choices: partAChoices
|
|
@@ -110,14 +109,14 @@ async function model(question, session, env, updateSession) {
|
|
|
110
109
|
shuffledValues: (session.shuffledValues || {}).partA
|
|
111
110
|
}, us('partA'), 'value');
|
|
112
111
|
}
|
|
113
|
-
const partBSession = (0,
|
|
112
|
+
const partBSession = (0, _lodashEs.get)(session, 'value.partB');
|
|
114
113
|
const partBLockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partB, partBSession, env);
|
|
115
114
|
if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {
|
|
116
115
|
partB.choices = await (0, _controllerUtils.getShuffledChoices)(partBChoices, {
|
|
117
116
|
shuffledValues: (session.shuffledValues || {}).partB
|
|
118
117
|
}, us('partB'), 'value');
|
|
119
118
|
}
|
|
120
|
-
if (!(0,
|
|
119
|
+
if (!(0, _lodashEs.isEmpty)(shuffledValues)) {
|
|
121
120
|
if (updateSession && typeof updateSession === 'function') {
|
|
122
121
|
updateSession(session.id, session.element, {
|
|
123
122
|
shuffledValues
|
|
@@ -352,10 +351,10 @@ const validatePart = (model = {}, config = {}) => {
|
|
|
352
351
|
if (!hasCorrectResponse) {
|
|
353
352
|
errors.correctResponse = 'No correct response defined.';
|
|
354
353
|
}
|
|
355
|
-
if (!(0,
|
|
354
|
+
if (!(0, _lodashEs.isEmpty)(choicesErrors)) {
|
|
356
355
|
errors.choices = choicesErrors;
|
|
357
356
|
}
|
|
358
|
-
if (!(0,
|
|
357
|
+
if (!(0, _lodashEs.isEmpty)(rationaleErrors)) {
|
|
359
358
|
errors.rationale = rationaleErrors;
|
|
360
359
|
}
|
|
361
360
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","_controllerUtils","_utils","_get","_isEmpty","_translator","translator","Translator","prepareChoice","model","env","defaultFeedback","choice","out","label","value","role","mode","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","parsePart","part","key","session","Object","assign","incorrect","choices","map","disabled","complete","min","filter","c","length","responseCorrect","isResponseCorrect","undefined","normalizePart","base","choicesLayout","verticalMode","normalize","partA","partB","language","question","defaults","exports","updateSession","normalizedQuestion","shuffledValues","us","id","element","update","Promise","resolve","partASession","get","partALockChoiceOrder","lockChoices","partAChoices","partBChoices","getShuffledChoices","partBSession","partBLockChoiceOrder","isEmpty","catch","e","console","error","partLabels","partLabel","t","lng","index","partLabelType","teacherInstructions","teacherInstructionsEnabled","prompt","promptEnabled","extraCSSRules","createDefaultModel","isCorrect","getScore","config","sessionPart","partialScoringEnabled","maxScore","sessionPartValue","chosen","find","v","correctAndNotChosen","incorrectAndChosen","correctChoices","reduce","total","parseFloat","toFixed","outcome","score","scoreA","scoreB","empty","partialScoring","enabled","max","returnPartCorrect","answers","forEach","i","push","createCorrectResponseSession","partACorrect","partBCorrect","getInnerText","html","replaceAll","getContent","replace","validatePart","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","errors","choicesErrors","rationaleErrors","hasCorrectResponse","field","required","identicalAnswer","slice","some","nbOfChoices","answerChoices","correctResponse","validate","partAConfig","partBConfig","partAErrors","partBErrors"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport { isResponseCorrect } from './utils';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (env.mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nconst parsePart = (part, key, session, env) => {\n const defaultFeedback = Object.assign({ correct: 'Correct', incorrect: 'Incorrect' }, part.defaultFeedback);\n\n let choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];\n\n return {\n ...part,\n choices,\n disabled: env.mode !== 'gather',\n complete: {\n min: part.choices.filter((c) => c.correct).length,\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(part, key, session) : undefined,\n };\n};\n\nconst normalizePart = (model, base) => ({\n ...base,\n ...model,\n choicesLayout: model.choicesLayout || (model.verticalMode === false && 'horizontal') || 'vertical',\n});\n\nexport const normalize = ({ partA = {}, partB = {}, language, ...question }) => ({\n ...defaults,\n ...question,\n partA: normalizePart(partA, { ...defaults.partA, language }),\n partB: normalizePart(partB, { ...defaults.partB, language }),\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n const partA = parsePart(normalizedQuestion.partA, 'partA', session, env);\n const partB = parsePart(normalizedQuestion.partB, 'partB', session, env);\n\n const shuffledValues = {};\n\n const us = (part) => (id, element, update) =>\n new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues;\n resolve();\n });\n\n const partASession = get(session, 'value.partA');\n const partALockChoiceOrder = lockChoices(normalizedQuestion.partA, partASession, env);\n\n const { choices: partAChoices } = partA || {};\n const { choices: partBChoices } = partB || {};\n\n if (!partALockChoiceOrder && partAChoices && partAChoices.length) {\n partA.choices = await getShuffledChoices(\n partAChoices,\n { shuffledValues: (session.shuffledValues || {}).partA },\n us('partA'),\n 'value',\n );\n }\n\n const partBSession = get(session, 'value.partB');\n const partBLockChoiceOrder = lockChoices(normalizedQuestion.partB, partBSession, env);\n\n if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {\n partB.choices = await getShuffledChoices(\n partBChoices,\n { shuffledValues: (session.shuffledValues || {}).partB },\n us('partB'),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (updateSession && typeof updateSession === 'function') {\n updateSession(session.id, session.element, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n\n if (normalizedQuestion.partLabels) {\n const language = normalizedQuestion.language;\n partA.partLabel = translator.t('ebsr.part', {\n lng: language,\n index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1',\n });\n partB.partLabel = translator.t('ebsr.part', {\n lng: language,\n index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2',\n });\n } else {\n partA.partLabel = undefined;\n partB.partLabel = undefined;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled\n ? normalizedQuestion.partA.teacherInstructions\n : null;\n partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled\n ? normalizedQuestion.partB.teacherInstructions\n : null;\n } else {\n partA.teacherInstructions = null;\n partB.teacherInstructions = null;\n }\n\n partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;\n partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;\n\n return new Promise((resolve) => {\n resolve({\n disabled: env.mode !== 'gather',\n mode: env.mode,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n partA,\n partB,\n });\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst isCorrect = (c) => c.correct === true;\n\nconst getScore = (config, sessionPart, key, partialScoringEnabled) => {\n const { choices = [] } = (config && config[key]) || {};\n const maxScore = choices.length;\n const { value: sessionPartValue } = sessionPart || {};\n\n const chosen = (c) => !!(sessionPartValue || []).find((v) => v === c.value);\n const correctAndNotChosen = (c) => isCorrect(c) && !chosen(c);\n const incorrectAndChosen = (c) => !isCorrect(c) && chosen(c);\n const correctChoices = choices.reduce((total, choice) => {\n if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {\n return total - 1;\n } else {\n return total;\n }\n }, choices.length);\n\n // determine score for a part\n if (!partialScoringEnabled && correctChoices < maxScore) {\n return 0;\n }\n\n return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);\n};\n\nexport function outcome(config, session, env) {\n return new Promise((resolve) => {\n const { value } = session || {};\n\n if (!session || !value) {\n resolve({ score: 0, scoreA: 0, scoreB: 0, empty: true });\n }\n\n if (value) {\n const { partA, partB } = value || {};\n\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n const scoreA = getScore(config, partA, 'partA', partialScoringEnabled);\n const scoreB = getScore(config, partB, 'partB', partialScoringEnabled);\n\n if (!partialScoringEnabled) {\n // The EBSR item is worth 1 point\n // That point is awarded if and only if both parts are fully correct, otherwise no points are awarded\n resolve({ score: scoreA === 1 && scoreB === 1 ? 1 : 0, scoreA, scoreB, max: 1 });\n } else {\n // The EBSR item is worth 2 points\n if (scoreA === 1) {\n if (scoreB === 1) {\n // If Part A and Part B are both correct, 2 points are awarded\n resolve({ score: 2, scoreA, scoreB, max: 2 });\n } else {\n // If Part A is correct and part B is incorrect, 1 point is awarded\n resolve({ score: 1, scoreA, scoreB, max: 2 });\n }\n } else {\n // For all other combinations, no points are awarded\n resolve({ score: 0, scoreA, scoreB, max: 2 });\n }\n }\n }\n });\n}\n\nconst returnPartCorrect = (choices) => {\n let answers = [];\n\n choices.forEach((i) => {\n const { correct, value } = i;\n if (correct) {\n answers.push(value);\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { partA, partB } = question;\n\n const partACorrect = returnPartCorrect(partA.choices);\n const partBCorrect = returnPartCorrect(partB.choices);\n\n resolve({\n value: {\n partA: {\n id: 'partA',\n value: partACorrect,\n },\n partB: {\n id: 'partB',\n value: partBCorrect,\n },\n },\n id: '1',\n });\n } else {\n resolve(null);\n }\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\nconst validatePart = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const rationaleErrors = {};\n let hasCorrectResponse = false;\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 reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { partA, partB } = model || {};\n const { partA: partAConfig, partB: partBConfig } = config || {};\n\n const partAErrors = validatePart(partA, partAConfig);\n const partBErrors = validatePart(partB, partBConfig);\n\n return { partA: partAErrors, partB: partBErrors };\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAM;EAAEM;AAAW,CAAC,GAAGC,mBAAU;AAEjC,MAAMC,aAAa,GAAGA,CAACC,KAAK,EAAEC,GAAG,EAAEC,eAAe,KAAMC,MAAM,IAAK;EACjE,MAAMC,GAAG,GAAG;IACVC,KAAK,EAAEF,MAAM,CAACE,KAAK;IACnBC,KAAK,EAAEH,MAAM,CAACG;EAChB,CAAC;EAED,IAAIL,GAAG,CAACM,IAAI,KAAK,YAAY,KAAKN,GAAG,CAACO,IAAI,KAAK,MAAM,IAAIP,GAAG,CAACO,IAAI,KAAK,UAAU,CAAC,EAAE;IACjFJ,GAAG,CAACK,SAAS,GAAGT,KAAK,CAACU,gBAAgB,GAAGP,MAAM,CAACM,SAAS,GAAG,IAAI;EAClE,CAAC,MAAM;IACLL,GAAG,CAACK,SAAS,GAAG,IAAI;EACtB;EAEA,IAAIR,GAAG,CAACO,IAAI,KAAK,UAAU,EAAE;IAC3BJ,GAAG,CAACO,OAAO,GAAG,CAAC,CAACR,MAAM,CAACQ,OAAO;IAE9B,IAAIX,KAAK,CAACY,eAAe,EAAE;MACzB,MAAMC,YAAY,GAAIV,MAAM,CAACW,QAAQ,IAAIX,MAAM,CAACW,QAAQ,CAACC,IAAI,IAAK,MAAM;MAExE,IAAIF,YAAY,KAAK,SAAS,EAAE;Q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|
1
|
+
{"version":3,"file":"index.js","names":["_defaults","_interopRequireDefault","require","_controllerUtils","_utils","_lodashEs","_translator","translator","Translator","prepareChoice","model","env","defaultFeedback","choice","out","label","value","role","mode","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","parsePart","part","key","session","Object","assign","incorrect","choices","map","disabled","complete","min","filter","c","length","responseCorrect","isResponseCorrect","undefined","normalizePart","base","choicesLayout","verticalMode","normalize","partA","partB","language","question","defaults","exports","updateSession","normalizedQuestion","shuffledValues","us","id","element","update","Promise","resolve","partASession","get","partALockChoiceOrder","lockChoices","partAChoices","partBChoices","getShuffledChoices","partBSession","partBLockChoiceOrder","isEmpty","catch","e","console","error","partLabels","partLabel","t","lng","index","partLabelType","teacherInstructions","teacherInstructionsEnabled","prompt","promptEnabled","extraCSSRules","createDefaultModel","isCorrect","getScore","config","sessionPart","partialScoringEnabled","maxScore","sessionPartValue","chosen","find","v","correctAndNotChosen","incorrectAndChosen","correctChoices","reduce","total","parseFloat","toFixed","outcome","score","scoreA","scoreB","empty","partialScoring","enabled","max","returnPartCorrect","answers","forEach","i","push","createCorrectResponseSession","partACorrect","partBCorrect","getInnerText","html","replaceAll","getContent","replace","validatePart","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","errors","choicesErrors","rationaleErrors","hasCorrectResponse","field","required","identicalAnswer","slice","some","nbOfChoices","answerChoices","correctResponse","validate","partAConfig","partBConfig","partAErrors","partBErrors"],"sources":["../src/index.js"],"sourcesContent":["import defaults from './defaults';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport { isResponseCorrect } from './utils';\nimport { get, isEmpty } from 'lodash-es';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (env.mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nconst parsePart = (part, key, session, env) => {\n const defaultFeedback = Object.assign({ correct: 'Correct', incorrect: 'Incorrect' }, part.defaultFeedback);\n\n let choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];\n\n return {\n ...part,\n choices,\n disabled: env.mode !== 'gather',\n complete: {\n min: part.choices.filter((c) => c.correct).length,\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(part, key, session) : undefined,\n };\n};\n\nconst normalizePart = (model, base) => ({\n ...base,\n ...model,\n choicesLayout: model.choicesLayout || (model.verticalMode === false && 'horizontal') || 'vertical',\n});\n\nexport const normalize = ({ partA = {}, partB = {}, language, ...question }) => ({\n ...defaults,\n ...question,\n partA: normalizePart(partA, { ...defaults.partA, language }),\n partB: normalizePart(partB, { ...defaults.partB, language }),\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n const partA = parsePart(normalizedQuestion.partA, 'partA', session, env);\n const partB = parsePart(normalizedQuestion.partB, 'partB', session, env);\n\n const shuffledValues = {};\n\n const us = (part) => (id, element, update) =>\n new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues;\n resolve();\n });\n\n const partASession = get(session, 'value.partA');\n const partALockChoiceOrder = lockChoices(normalizedQuestion.partA, partASession, env);\n\n const { choices: partAChoices } = partA || {};\n const { choices: partBChoices } = partB || {};\n\n if (!partALockChoiceOrder && partAChoices && partAChoices.length) {\n partA.choices = await getShuffledChoices(\n partAChoices,\n { shuffledValues: (session.shuffledValues || {}).partA },\n us('partA'),\n 'value',\n );\n }\n\n const partBSession = get(session, 'value.partB');\n const partBLockChoiceOrder = lockChoices(normalizedQuestion.partB, partBSession, env);\n\n if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {\n partB.choices = await getShuffledChoices(\n partBChoices,\n { shuffledValues: (session.shuffledValues || {}).partB },\n us('partB'),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (updateSession && typeof updateSession === 'function') {\n updateSession(session.id, session.element, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n\n if (normalizedQuestion.partLabels) {\n const language = normalizedQuestion.language;\n partA.partLabel = translator.t('ebsr.part', {\n lng: language,\n index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1',\n });\n partB.partLabel = translator.t('ebsr.part', {\n lng: language,\n index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2',\n });\n } else {\n partA.partLabel = undefined;\n partB.partLabel = undefined;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled\n ? normalizedQuestion.partA.teacherInstructions\n : null;\n partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled\n ? normalizedQuestion.partB.teacherInstructions\n : null;\n } else {\n partA.teacherInstructions = null;\n partB.teacherInstructions = null;\n }\n\n partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;\n partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;\n\n return new Promise((resolve) => {\n resolve({\n disabled: env.mode !== 'gather',\n mode: env.mode,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n partA,\n partB,\n });\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst isCorrect = (c) => c.correct === true;\n\nconst getScore = (config, sessionPart, key, partialScoringEnabled) => {\n const { choices = [] } = (config && config[key]) || {};\n const maxScore = choices.length;\n const { value: sessionPartValue } = sessionPart || {};\n\n const chosen = (c) => !!(sessionPartValue || []).find((v) => v === c.value);\n const correctAndNotChosen = (c) => isCorrect(c) && !chosen(c);\n const incorrectAndChosen = (c) => !isCorrect(c) && chosen(c);\n const correctChoices = choices.reduce((total, choice) => {\n if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {\n return total - 1;\n } else {\n return total;\n }\n }, choices.length);\n\n // determine score for a part\n if (!partialScoringEnabled && correctChoices < maxScore) {\n return 0;\n }\n\n return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);\n};\n\nexport function outcome(config, session, env) {\n return new Promise((resolve) => {\n const { value } = session || {};\n\n if (!session || !value) {\n resolve({ score: 0, scoreA: 0, scoreB: 0, empty: true });\n }\n\n if (value) {\n const { partA, partB } = value || {};\n\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n const scoreA = getScore(config, partA, 'partA', partialScoringEnabled);\n const scoreB = getScore(config, partB, 'partB', partialScoringEnabled);\n\n if (!partialScoringEnabled) {\n // The EBSR item is worth 1 point\n // That point is awarded if and only if both parts are fully correct, otherwise no points are awarded\n resolve({ score: scoreA === 1 && scoreB === 1 ? 1 : 0, scoreA, scoreB, max: 1 });\n } else {\n // The EBSR item is worth 2 points\n if (scoreA === 1) {\n if (scoreB === 1) {\n // If Part A and Part B are both correct, 2 points are awarded\n resolve({ score: 2, scoreA, scoreB, max: 2 });\n } else {\n // If Part A is correct and part B is incorrect, 1 point is awarded\n resolve({ score: 1, scoreA, scoreB, max: 2 });\n }\n } else {\n // For all other combinations, no points are awarded\n resolve({ score: 0, scoreA, scoreB, max: 2 });\n }\n }\n }\n });\n}\n\nconst returnPartCorrect = (choices) => {\n let answers = [];\n\n choices.forEach((i) => {\n const { correct, value } = i;\n if (correct) {\n answers.push(value);\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { partA, partB } = question;\n\n const partACorrect = returnPartCorrect(partA.choices);\n const partBCorrect = returnPartCorrect(partB.choices);\n\n resolve({\n value: {\n partA: {\n id: 'partA',\n value: partACorrect,\n },\n partB: {\n id: 'partB',\n value: partBCorrect,\n },\n },\n id: '1',\n });\n } else {\n resolve(null);\n }\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\nconst validatePart = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const rationaleErrors = {};\n let hasCorrectResponse = false;\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 reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { partA, partB } = model || {};\n const { partA: partAConfig, partB: partBConfig } = config || {};\n\n const partAErrors = validatePart(partA, partAConfig);\n const partBErrors = validatePart(partB, partBConfig);\n\n return { partA: partAErrors, partB: partBErrors };\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAM;EAAEK;AAAW,CAAC,GAAGC,mBAAU;AAEjC,MAAMC,aAAa,GAAGA,CAACC,KAAK,EAAEC,GAAG,EAAEC,eAAe,KAAMC,MAAM,IAAK;EACjE,MAAMC,GAAG,GAAG;IACVC,KAAK,EAAEF,MAAM,CAACE,KAAK;IACnBC,KAAK,EAAEH,MAAM,CAACG;EAChB,CAAC;EAED,IAAIL,GAAG,CAACM,IAAI,KAAK,YAAY,KAAKN,GAAG,CAACO,IAAI,KAAK,MAAM,IAAIP,GAAG,CAACO,IAAI,KAAK,UAAU,CAAC,EAAE;IACjFJ,GAAG,CAACK,SAAS,GAAGT,KAAK,CAACU,gBAAgB,GAAGP,MAAM,CAACM,SAAS,GAAG,IAAI;EAClE,CAAC,MAAM;IACLL,GAAG,CAACK,SAAS,GAAG,IAAI;EACtB;EAEA,IAAIR,GAAG,CAACO,IAAI,KAAK,UAAU,EAAE;IAC3BJ,GAAG,CAACO,OAAO,GAAG,CAAC,CAACR,MAAM,CAACQ,OAAO;IAE9B,IAAIX,KAAK,CAACY,eAAe,EAAE;MACzB,MAAMC,YAAY,GAAIV,MAAM,CAACW,QAAQ,IAAIX,MAAM,CAACW,QAAQ,CAACC,IAAI,IAAK,MAAM;MAEx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,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/controller/lib/utils.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
9
8
|
const getCorrectResponse = choices => choices && choices.filter(c => c.correct).map(c => c.value).sort();
|
|
10
9
|
exports.getCorrectResponse = getCorrectResponse;
|
|
11
10
|
const isResponseCorrect = (question, key, session) => {
|
|
12
11
|
let correctResponse = getCorrectResponse(question.choices);
|
|
13
12
|
if (session && session.value) {
|
|
14
|
-
return (0,
|
|
13
|
+
return (0, _lodashEs.isEqual)((session.value[key].value || []).sort(), correctResponse);
|
|
15
14
|
}
|
|
16
15
|
return false;
|
|
17
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_lodashEs","require","getCorrectResponse","choices","filter","c","correct","map","value","sort","exports","isResponseCorrect","question","key","session","correctResponse","isEqual"],"sources":["../src/utils.js"],"sourcesContent":["import { isEqual } from 'lodash-es';\n\nexport const getCorrectResponse = (choices) =>\n choices &&\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, key, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n\n if (session && session.value) {\n return isEqual((session.value[key].value || []).sort(), correctResponse);\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,OAAO,IACxCA,OAAO,IACPA,OAAO,CACJC,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAAC,CACxBC,GAAG,CAAEF,CAAC,IAAKA,CAAC,CAACG,KAAK,CAAC,CACnBC,IAAI,CAAC,CAAC;AAACC,OAAA,CAAAR,kBAAA,GAAAA,kBAAA;AAEL,MAAMS,iBAAiB,GAAGA,CAACC,QAAQ,EAAEC,GAAG,EAAEC,OAAO,KAAK;EAC3D,IAAIC,eAAe,GAAGb,kBAAkB,CAACU,QAAQ,CAACT,OAAO,CAAC;EAE1D,IAAIW,OAAO,IAAIA,OAAO,CAACN,KAAK,EAAE;IAC5B,OAAO,IAAAQ,iBAAO,EAAC,CAACF,OAAO,CAACN,KAAK,CAACK,GAAG,CAAC,CAACL,KAAK,IAAI,EAAE,EAAEC,IAAI,CAAC,CAAC,EAAEM,eAAe,CAAC;EAC1E;EAEA,OAAO,KAAK;AACd,CAAC;AAACL,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/controller/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@pie-lib/controller-utils": "
|
|
11
|
-
"@pie-lib/translator": "
|
|
12
|
-
"lodash": "^4.17.
|
|
10
|
+
"@pie-lib/controller-utils": "1.1.1-next.1",
|
|
11
|
+
"@pie-lib/translator": "3.1.1-next.1",
|
|
12
|
+
"lodash-es": "^4.17.23"
|
|
13
13
|
},
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
package/controller/src/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import defaults from './defaults';
|
|
2
2
|
import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';
|
|
3
3
|
import { isResponseCorrect } from './utils';
|
|
4
|
-
import get from 'lodash
|
|
5
|
-
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import { get, isEmpty } from 'lodash-es';
|
|
6
5
|
import Translator from '@pie-lib/translator';
|
|
7
6
|
|
|
8
7
|
const { translator } = Translator;
|
package/controller/src/utils.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.isSessionComplete = exports.default = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
10
10
|
var _multipleChoice = _interopRequireDefault(require("@pie-element/multiple-choice"));
|
|
11
|
-
var
|
|
11
|
+
var _lodashEs = require("lodash-es");
|
|
12
12
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
13
|
const SESSION_CHANGED = _piePlayerEvents.SessionChangedEvent.TYPE;
|
|
14
14
|
const MC_TAG_NAME = 'ebsr-multiple-choice';
|
|
@@ -22,8 +22,8 @@ const defineMultipleChoice = () => {
|
|
|
22
22
|
defineMultipleChoice();
|
|
23
23
|
const isNonEmptyArray = a => Array.isArray(a) && a.length > 0;
|
|
24
24
|
const isSessionComplete = session => {
|
|
25
|
-
const a = (0,
|
|
26
|
-
const b = (0,
|
|
25
|
+
const a = (0, _lodashEs.get)(session, 'value.partA.value');
|
|
26
|
+
const b = (0, _lodashEs.get)(session, 'value.partB.value');
|
|
27
27
|
return isNonEmptyArray(a) && isNonEmptyArray(b);
|
|
28
28
|
};
|
|
29
29
|
exports.isSessionComplete = isSessionComplete;
|