@pie-element/ebsr 7.0.24 → 7.0.25
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 +8 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/lib/main.js +6 -4
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +3 -3
- package/configure/src/__tests__/index.test.js +4 -2
- package/configure/src/main.jsx +8 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/index.js +79 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/index.js +55 -0
- package/module/configure.js +20 -15
- package/module/controller.js +56 -1
- package/module/element.js +2 -2
- package/module/index.html +1 -1
- package/module/manifest.json +3 -3
- package/module/print.html +1 -1
- package/module/print.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [7.0.25](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr@7.0.24...@pie-element/ebsr@7.0.25) (2022-05-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/ebsr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [7.0.24](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr@7.0.23...@pie-element/ebsr@7.0.24) (2022-05-16)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/ebsr
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [7.0.25](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-configure@7.0.24...@pie-element/ebsr-configure@7.0.25) (2022-05-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/ebsr-configure
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [7.0.24](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-configure@7.0.23...@pie-element/ebsr-configure@7.0.24) (2022-05-16)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/ebsr-configure
|
package/configure/lib/main.js
CHANGED
|
@@ -31,8 +31,6 @@ var _configUi = require("@pie-lib/config-ui");
|
|
|
31
31
|
|
|
32
32
|
var _styles = require("@material-ui/core/styles");
|
|
33
33
|
|
|
34
|
-
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
35
|
-
|
|
36
34
|
var _excluded = ["partA", "partB", "partialScoring", "scoringType"];
|
|
37
35
|
|
|
38
36
|
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; }
|
|
@@ -245,7 +243,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
245
243
|
if (_ref4) {
|
|
246
244
|
// do not use destructuring to get model from props
|
|
247
245
|
_this2.partA = _ref4;
|
|
248
|
-
_this2.partA._model = (
|
|
246
|
+
_this2.partA._model = _objectSpread(_objectSpread({}, _this2.props.model.partA), {}, {
|
|
247
|
+
errors: _this2.props.model.errors && _this2.props.model.errors.partA || {}
|
|
248
|
+
});
|
|
249
249
|
_this2.partA.configuration = _objectSpread(_objectSpread({}, partA), generalConfiguration);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -258,7 +258,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
258
258
|
if (_ref5) {
|
|
259
259
|
// do not use destructuring to get model from props
|
|
260
260
|
_this2.partB = _ref5;
|
|
261
|
-
_this2.partB._model = (
|
|
261
|
+
_this2.partB._model = _objectSpread(_objectSpread({}, _this2.props.model.partB), {}, {
|
|
262
|
+
errors: _this2.props.model.errors && _this2.props.model.errors.partB || {}
|
|
263
|
+
});
|
|
262
264
|
_this2.partB.configuration = _objectSpread(_objectSpread({}, partB), generalConfiguration);
|
|
263
265
|
}
|
|
264
266
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["Panel","settings","toggle","radio","dropdown","styles","theme","design","paddingTop","spacing","unit","part","display","flexDirection","padding","Main","choices","correctFound","map","choice","correct","model","key","onModelChanged","props","partA","choiceMode","removeExtraChoices","partB","classes","configuration","onConfigurationChanged","partLabelType","modelPartA","modelPartB","partialScoring","scoringType","generalConfiguration","feedback","feedbackA","choiceModeA","choicePrefix","choicePrefixA","lockChoiceOrder","lockChoiceOrderA","prompt","promptA","teacherInstructions","teacherInstructionsA","studentInstructions","studentInstructionsA","choicesLayout","choicesLayoutA","gridColumns","gridColumnsA","rationale","rationaleA","spellCheck","spellCheckA","feedbackB","choiceModeB","choicePrefixB","lockChoiceOrderB","promptB","teacherInstructionsB","studentInstructionsB","choicesLayoutB","gridColumnsB","rationaleB","spellCheckB","type","typeIsNumber","firstPart","secondPart","nrOfColumnsAvailable","length","Array","from","_","i","partLabels","label","ref","_model","React","Component","PropTypes","object","func","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAQA,KAAR,GAA2CC,kBAA3C,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA2CD,kBAA3C,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAA2CF,kBAA3C,CAAuBE,KAAvB;AAAA,IAA8BC,QAA9B,GAA2CH,kBAA3C,CAA8BG,QAA9B;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAA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AAA,sBAAsB,EAAEuD,sBAAUE;AALjB,C;AAiOrB,IAAMC,MAAM,GAAG,wBAAWpF,MAAX,EAAmBU,IAAnB,CAAf;eAEe0E,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { settings, layout } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport cloneDeep from 'lodash/cloneDeep';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst styles = theme => ({\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n part: {\n display: 'flex',\n flexDirection: 'column',\n padding: '16px 0 32px'\n }\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n configuration: PropTypes.object,\n model: PropTypes.object,\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func\n };\n\n removeExtraChoices = (choices) => {\n let correctFound = false;\n\n return (choices || []).map(choice => {\n if (correctFound) {\n choice.correct = false;\n return choice;\n }\n\n if (choice.correct) {\n correctFound = true;\n }\n\n return choice;\n });\n }\n\n onModelChanged = (model, key) => {\n const { onModelChanged } = this.props;\n\n if (key === 'partA.choiceMode' && model.partA.choiceMode === 'radio') {\n model.partA.choices = this.removeExtraChoices(model.partA.choices);\n\n return onModelChanged(model, true);\n }\n\n if (key === 'partB.choiceMode' && model.partB.choiceMode === 'radio') {\n model.partB.choices = this.removeExtraChoices(model.partB.choices);\n\n return onModelChanged(model, true);\n }\n\n return onModelChanged(model);\n }\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged\n } = this.props;\n const { partLabelType, partA: modelPartA, partB: modelPartB } = model;\n const { partA, partB, partialScoring, scoringType, ...generalConfiguration } = configuration;\n const {\n feedback: feedbackA = {},\n choiceMode: choiceModeA = {},\n choicePrefix: choicePrefixA = {},\n lockChoiceOrder: lockChoiceOrderA = {},\n prompt: promptA = {},\n teacherInstructions: teacherInstructionsA = {},\n studentInstructions: studentInstructionsA = {},\n choicesLayout: choicesLayoutA = {},\n gridColumns: gridColumnsA = {},\n rationale: rationaleA = {},\n spellCheck: spellCheckA = {}\n } = partA || {};\n const {\n feedback: feedbackB = {},\n choiceMode: choiceModeB = {},\n choicePrefix: choicePrefixB = {},\n lockChoiceOrder: lockChoiceOrderB = {},\n prompt: promptB = {},\n teacherInstructions: teacherInstructionsB = {},\n studentInstructions: studentInstructionsB = {},\n choicesLayout: choicesLayoutB = {},\n gridColumns: gridColumnsB = {},\n rationale: rationaleB = {},\n spellCheck: spellCheckB = {}\n } = partB || {};\n const type = partLabelType || 'Numbers';\n const typeIsNumber = type === 'Numbers';\n const firstPart = `Part ${typeIsNumber ? '1' : 'A'}`;\n const secondPart = `Part ${typeIsNumber ? '2' : 'B'}`;\n const nrOfColumnsAvailable = {\n partA: modelPartA.choices && modelPartA.choices.length ?\n Array.from({length: modelPartA.choices.length}, (_, i) => (`${i + 1}`)) : [],\n partB: modelPartB.choices && modelPartB.choices.length ?\n Array.from({length: modelPartB.choices.length}, (_, i) => (`${i + 1}`)) : [],\n };\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={this.onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings for both': {\n partLabels:\n generalConfiguration.partLabels.settings &&\n toggle(generalConfiguration.partLabels.label),\n partLabelType:\n model.partLabels && dropdown('', ['Numbers', 'Letters']),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n scoringType:\n scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])\n },\n [`Settings ${firstPart}`]: {\n 'partA.choiceMode':\n choiceModeA.settings &&\n radio(choiceModeA.label, ['checkbox', 'radio']),\n 'partA.choicePrefix':\n choicePrefixA.settings &&\n radio(choicePrefixA.label, ['numbers', 'letters']),\n 'partA.lockChoiceOrder':\n lockChoiceOrderA.settings && toggle(lockChoiceOrderA.label),\n 'partA.choicesLayout':\n choicesLayoutA.settings &&\n dropdown(choicesLayoutA.label, ['vertical', 'grid', 'horizontal']),\n 'partA.gridColumns':\n choicesLayoutA.settings && modelPartA.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partA.length > 0 &&\n dropdown(gridColumnsA.label, nrOfColumnsAvailable.partA)\n },\n [`Properties ${firstPart}`]: {\n 'partA.feedbackEnabled': feedbackA.settings &&\n toggle(feedbackA.label),\n 'partA.promptEnabled':\n promptA.settings && toggle(promptA.label),\n 'partA.teacherInstructionsEnabled':\n teacherInstructionsA.settings &&\n toggle(teacherInstructionsA.label),\n 'partA.studentInstructionsEnabled':\n studentInstructionsA.settings &&\n toggle(studentInstructionsA.label),\n 'partA.rationaleEnabled':\n rationaleA.settings && toggle(rationaleA.label),\n 'partA.spellCheckEnabled':\n spellCheckA.settings && toggle(spellCheckA.label),\n },\n [`Settings ${secondPart}`]: {\n 'partB.choiceMode':\n choiceModeB.settings &&\n radio(choiceModeB.label, ['checkbox', 'radio']),\n 'partB.choicePrefix':\n choicePrefixB.settings &&\n radio(choicePrefixB.label, ['numbers', 'letters']),\n 'partB.lockChoiceOrder':\n lockChoiceOrderB.settings && toggle(lockChoiceOrderB.label),\n 'partB.choicesLayout':\n choicesLayoutB.settings &&\n dropdown(choicesLayoutB.label, ['vertical', 'grid', 'horizontal']),\n 'partB.gridColumns':\n choicesLayoutB.settings && modelPartB.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partB.length > 0 &&\n dropdown(gridColumnsB.label, nrOfColumnsAvailable.partB)\n },\n [`Properties ${secondPart}`]: {\n 'partB.feedbackEnabled':\n feedbackB.settings && toggle(feedbackB.label),\n 'partB.promptEnabled':\n promptB.settings && toggle(promptB.label),\n 'partB.teacherInstructionsEnabled':\n teacherInstructionsB.settings &&\n toggle(teacherInstructionsB.label),\n 'partB.studentInstructionsEnabled':\n studentInstructionsB.settings &&\n toggle(studentInstructionsB.label),\n 'partB.rationaleEnabled':\n rationaleB.settings && toggle(rationaleB.label),\n 'partB.spellCheckEnabled':\n spellCheckB.settings && toggle(spellCheckB.label),\n }\n }}\n />\n }\n >\n <div>\n <div className={classes.part}>\n {model.partLabels && <p>{firstPart}</p>}\n <ebsr-multiple-choice-configure\n id=\"A\"\n key=\"partA\"\n ref={ref => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partA = ref;\n this.partA._model = cloneDeep(this.props.model.partA);\n this.partA.configuration = {\n ...partA,\n ...generalConfiguration\n };\n }\n }}\n />\n </div>\n\n <div className={classes.part}>\n {model.partLabels && <p>{secondPart}</p>}\n <ebsr-multiple-choice-configure\n id=\"B\"\n key=\"partB\"\n ref={ref => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partB = ref;\n this.partB._model = cloneDeep(this.props.model.partB);\n this.partB.configuration = {\n ...partB,\n ...generalConfiguration\n };\n }\n }}\n />\n </div>\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["Panel","settings","toggle","radio","dropdown","styles","theme","design","paddingTop","spacing","unit","part","display","flexDirection","padding","Main","choices","correctFound","map","choice","correct","model","key","onModelChanged","props","partA","choiceMode","removeExtraChoices","partB","classes","configuration","onConfigurationChanged","partLabelType","modelPartA","modelPartB","partialScoring","scoringType","generalConfiguration","feedback","feedbackA","choiceModeA","choicePrefix","choicePrefixA","lockChoiceOrder","lockChoiceOrderA","prompt","promptA","teacherInstructions","teacherInstructionsA","studentInstructions","studentInstructionsA","choicesLayout","choicesLayoutA","gridColumns","gridColumnsA","rationale","rationaleA","spellCheck","spellCheckA","feedbackB","choiceModeB","choicePrefixB","lockChoiceOrderB","promptB","teacherInstructionsB","studentInstructionsB","choicesLayoutB","gridColumnsB","rationaleB","spellCheckB","type","typeIsNumber","firstPart","secondPart","nrOfColumnsAvailable","length","Array","from","_","i","partLabels","label","ref","_model","errors","React","Component","PropTypes","object","func","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;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,MAAI,CAAC3D,KAAL,CAAWH,KAAX,CAAiBO,KADtB;AAEEwD,cAAAA,MAAM,EAAE,MAAI,CAAC5D,KAAL,CAAWH,KAAX,CAAiB+D,MAAjB,IAA2B,MAAI,CAAC5D,KAAL,CAAWH,KAAX,CAAiB+D,MAAjB,CAAwBxD,KAAnD,IAA4D;AAFtE;AAIA,YAAA,MAAI,CAACA,KAAL,CAAWE,aAAX,mCACKF,KADL,GAEKS,oBAFL;AAID;AACF;AAhBH,QAFF,CAvBF,CAzFF,CADF,CADF;AA2ID;;;EArOuBgD,kBAAMC,S;;;iCAAnBvE,I,eACQ;AACjBc,EAAAA,OAAO,EAAE0D,sBAAUC,MADF;AAEjB1D,EAAAA,aAAa,EAAEyD,sBAAUC,MAFR;AAGjBnE,EAAAA,KAAK,EAAEkE,sBAAUC,MAHA;AAIjBjE,EAAAA,cAAc,EAAEgE,sBAAUE,IAJT;AAKjB1D,EAAAA,sBAAsB,EAAEwD,sBAAUE;AALjB,C;AAuOrB,IAAMC,MAAM,GAAG,wBAAWrF,MAAX,EAAmBU,IAAnB,CAAf;eAEe2E,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { settings, layout } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst styles = theme => ({\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n part: {\n display: 'flex',\n flexDirection: 'column',\n padding: '16px 0 32px'\n }\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n configuration: PropTypes.object,\n model: PropTypes.object,\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func\n };\n\n removeExtraChoices = (choices) => {\n let correctFound = false;\n\n return (choices || []).map(choice => {\n if (correctFound) {\n choice.correct = false;\n return choice;\n }\n\n if (choice.correct) {\n correctFound = true;\n }\n\n return choice;\n });\n }\n\n onModelChanged = (model, key) => {\n const { onModelChanged } = this.props;\n\n if (key === 'partA.choiceMode' && model.partA.choiceMode === 'radio') {\n model.partA.choices = this.removeExtraChoices(model.partA.choices);\n\n return onModelChanged(model, true);\n }\n\n if (key === 'partB.choiceMode' && model.partB.choiceMode === 'radio') {\n model.partB.choices = this.removeExtraChoices(model.partB.choices);\n\n return onModelChanged(model, true);\n }\n\n return onModelChanged(model);\n }\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged\n } = this.props;\n const { partLabelType, partA: modelPartA, partB: modelPartB } = model;\n const { partA, partB, partialScoring, scoringType, ...generalConfiguration } = configuration;\n const {\n feedback: feedbackA = {},\n choiceMode: choiceModeA = {},\n choicePrefix: choicePrefixA = {},\n lockChoiceOrder: lockChoiceOrderA = {},\n prompt: promptA = {},\n teacherInstructions: teacherInstructionsA = {},\n studentInstructions: studentInstructionsA = {},\n choicesLayout: choicesLayoutA = {},\n gridColumns: gridColumnsA = {},\n rationale: rationaleA = {},\n spellCheck: spellCheckA = {}\n } = partA || {};\n const {\n feedback: feedbackB = {},\n choiceMode: choiceModeB = {},\n choicePrefix: choicePrefixB = {},\n lockChoiceOrder: lockChoiceOrderB = {},\n prompt: promptB = {},\n teacherInstructions: teacherInstructionsB = {},\n studentInstructions: studentInstructionsB = {},\n choicesLayout: choicesLayoutB = {},\n gridColumns: gridColumnsB = {},\n rationale: rationaleB = {},\n spellCheck: spellCheckB = {}\n } = partB || {};\n const type = partLabelType || 'Numbers';\n const typeIsNumber = type === 'Numbers';\n const firstPart = `Part ${typeIsNumber ? '1' : 'A'}`;\n const secondPart = `Part ${typeIsNumber ? '2' : 'B'}`;\n const nrOfColumnsAvailable = {\n partA: modelPartA.choices && modelPartA.choices.length ?\n Array.from({length: modelPartA.choices.length}, (_, i) => (`${i + 1}`)) : [],\n partB: modelPartB.choices && modelPartB.choices.length ?\n Array.from({length: modelPartB.choices.length}, (_, i) => (`${i + 1}`)) : [],\n };\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={this.onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings for both': {\n partLabels:\n generalConfiguration.partLabels.settings &&\n toggle(generalConfiguration.partLabels.label),\n partLabelType:\n model.partLabels && dropdown('', ['Numbers', 'Letters']),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n scoringType:\n scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])\n },\n [`Settings ${firstPart}`]: {\n 'partA.choiceMode':\n choiceModeA.settings &&\n radio(choiceModeA.label, ['checkbox', 'radio']),\n 'partA.choicePrefix':\n choicePrefixA.settings &&\n radio(choicePrefixA.label, ['numbers', 'letters']),\n 'partA.lockChoiceOrder':\n lockChoiceOrderA.settings && toggle(lockChoiceOrderA.label),\n 'partA.choicesLayout':\n choicesLayoutA.settings &&\n dropdown(choicesLayoutA.label, ['vertical', 'grid', 'horizontal']),\n 'partA.gridColumns':\n choicesLayoutA.settings && modelPartA.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partA.length > 0 &&\n dropdown(gridColumnsA.label, nrOfColumnsAvailable.partA)\n },\n [`Properties ${firstPart}`]: {\n 'partA.feedbackEnabled': feedbackA.settings &&\n toggle(feedbackA.label),\n 'partA.promptEnabled':\n promptA.settings && toggle(promptA.label),\n 'partA.teacherInstructionsEnabled':\n teacherInstructionsA.settings &&\n toggle(teacherInstructionsA.label),\n 'partA.studentInstructionsEnabled':\n studentInstructionsA.settings &&\n toggle(studentInstructionsA.label),\n 'partA.rationaleEnabled':\n rationaleA.settings && toggle(rationaleA.label),\n 'partA.spellCheckEnabled':\n spellCheckA.settings && toggle(spellCheckA.label),\n },\n [`Settings ${secondPart}`]: {\n 'partB.choiceMode':\n choiceModeB.settings &&\n radio(choiceModeB.label, ['checkbox', 'radio']),\n 'partB.choicePrefix':\n choicePrefixB.settings &&\n radio(choicePrefixB.label, ['numbers', 'letters']),\n 'partB.lockChoiceOrder':\n lockChoiceOrderB.settings && toggle(lockChoiceOrderB.label),\n 'partB.choicesLayout':\n choicesLayoutB.settings &&\n dropdown(choicesLayoutB.label, ['vertical', 'grid', 'horizontal']),\n 'partB.gridColumns':\n choicesLayoutB.settings && modelPartB.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partB.length > 0 &&\n dropdown(gridColumnsB.label, nrOfColumnsAvailable.partB)\n },\n [`Properties ${secondPart}`]: {\n 'partB.feedbackEnabled':\n feedbackB.settings && toggle(feedbackB.label),\n 'partB.promptEnabled':\n promptB.settings && toggle(promptB.label),\n 'partB.teacherInstructionsEnabled':\n teacherInstructionsB.settings &&\n toggle(teacherInstructionsB.label),\n 'partB.studentInstructionsEnabled':\n studentInstructionsB.settings &&\n toggle(studentInstructionsB.label),\n 'partB.rationaleEnabled':\n rationaleB.settings && toggle(rationaleB.label),\n 'partB.spellCheckEnabled':\n spellCheckB.settings && toggle(spellCheckB.label),\n }\n }}\n />\n }\n >\n <div>\n <div className={classes.part}>\n {model.partLabels && <p>{firstPart}</p>}\n <ebsr-multiple-choice-configure\n id=\"A\"\n key=\"partA\"\n ref={ref => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partA = ref;\n this.partA._model = {\n ...this.props.model.partA,\n errors: this.props.model.errors && this.props.model.errors.partA || {}\n };\n this.partA.configuration = {\n ...partA,\n ...generalConfiguration\n };\n }\n }}\n />\n </div>\n\n <div className={classes.part}>\n {model.partLabels && <p>{secondPart}</p>}\n <ebsr-multiple-choice-configure\n id=\"B\"\n key=\"partB\"\n ref={ref => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partB = ref;\n this.partB._model ={\n ...this.props.model.partB,\n errors: this.props.model.errors && this.props.model.errors.partB || {}\n };\n this.partB.configuration = {\n ...partB,\n ...generalConfiguration\n };\n }\n }}\n />\n </div>\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.25",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
|
-
"@pie-element/multiple-choice": "^6.3.
|
|
11
|
+
"@pie-element/multiple-choice": "^6.3.3",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
13
|
-
"@pie-lib/config-ui": "^10.13.
|
|
13
|
+
"@pie-lib/config-ui": "^10.13.2",
|
|
14
14
|
"lodash": "^4.17.15",
|
|
15
15
|
"prop-types": "^15.6.2",
|
|
16
16
|
"react": "^16.8.1",
|
|
@@ -79,7 +79,8 @@ const model = createDefaultModel(defaults.model, {
|
|
|
79
79
|
}
|
|
80
80
|
],
|
|
81
81
|
choicePrefix: 'numbers',
|
|
82
|
-
prompt: `prompt ${PART_A}
|
|
82
|
+
prompt: `prompt ${PART_A}`,
|
|
83
|
+
errors: {}
|
|
83
84
|
},
|
|
84
85
|
partB: {
|
|
85
86
|
choiceMode: 'radio',
|
|
@@ -102,7 +103,8 @@ const model = createDefaultModel(defaults.model, {
|
|
|
102
103
|
}
|
|
103
104
|
],
|
|
104
105
|
choicePrefix: 'numbers',
|
|
105
|
-
prompt: `prompt ${PART_B}
|
|
106
|
+
prompt: `prompt ${PART_B}`,
|
|
107
|
+
errors: {}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
108
110
|
|
package/configure/src/main.jsx
CHANGED
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { settings, layout } from '@pie-lib/config-ui';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
6
5
|
|
|
7
6
|
const { Panel, toggle, radio, dropdown } = settings;
|
|
8
7
|
|
|
@@ -208,7 +207,10 @@ export class Main extends React.Component {
|
|
|
208
207
|
if (ref) {
|
|
209
208
|
// do not use destructuring to get model from props
|
|
210
209
|
this.partA = ref;
|
|
211
|
-
this.partA._model =
|
|
210
|
+
this.partA._model = {
|
|
211
|
+
...this.props.model.partA,
|
|
212
|
+
errors: this.props.model.errors && this.props.model.errors.partA || {}
|
|
213
|
+
};
|
|
212
214
|
this.partA.configuration = {
|
|
213
215
|
...partA,
|
|
214
216
|
...generalConfiguration
|
|
@@ -227,7 +229,10 @@ export class Main extends React.Component {
|
|
|
227
229
|
if (ref) {
|
|
228
230
|
// do not use destructuring to get model from props
|
|
229
231
|
this.partB = ref;
|
|
230
|
-
this.partB._model =
|
|
232
|
+
this.partB._model ={
|
|
233
|
+
...this.props.model.partB,
|
|
234
|
+
errors: this.props.model.errors && this.props.model.errors.partB || {}
|
|
235
|
+
};
|
|
231
236
|
this.partB.configuration = {
|
|
232
237
|
...partB,
|
|
233
238
|
...generalConfiguration
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [6.0.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@6.0.4...@pie-element/ebsr-controller@6.0.5) (2022-05-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/ebsr-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [6.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@6.0.0...@pie-element/ebsr-controller@6.0.1) (2021-09-01)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/ebsr-controller
|
package/controller/lib/index.js
CHANGED
|
@@ -9,9 +9,12 @@ exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
|
9
9
|
exports.model = model;
|
|
10
10
|
exports.normalize = void 0;
|
|
11
11
|
exports.outcome = outcome;
|
|
12
|
+
exports.validate = void 0;
|
|
12
13
|
|
|
13
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
15
|
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
|
|
15
18
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
19
|
|
|
17
20
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
@@ -132,7 +135,7 @@ function model(_x, _x2, _x3, _x4) {
|
|
|
132
135
|
|
|
133
136
|
function _model() {
|
|
134
137
|
_model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env, updateSession) {
|
|
135
|
-
var normalizedQuestion, partA, partB, shuffledValues, us, partASession, partALockChoiceOrder,
|
|
138
|
+
var normalizedQuestion, partA, partB, shuffledValues, us, partASession, partALockChoiceOrder, _ref8, partAChoices, _ref9, partBChoices, partBSession, partBLockChoiceOrder;
|
|
136
139
|
|
|
137
140
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
138
141
|
while (1) {
|
|
@@ -154,8 +157,8 @@ function _model() {
|
|
|
154
157
|
|
|
155
158
|
partASession = (0, _get["default"])(session, 'value.partA');
|
|
156
159
|
partALockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partA, partASession, env);
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
_ref8 = partA || {}, partAChoices = _ref8.choices;
|
|
161
|
+
_ref9 = partB || {}, partBChoices = _ref9.choices;
|
|
159
162
|
|
|
160
163
|
if (!(!partALockChoiceOrder && partAChoices && partAChoices.length)) {
|
|
161
164
|
_context.next = 13;
|
|
@@ -392,4 +395,77 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
392
395
|
};
|
|
393
396
|
|
|
394
397
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
398
|
+
|
|
399
|
+
var validatePart = function validatePart() {
|
|
400
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
401
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
402
|
+
var choices = model.choices;
|
|
403
|
+
var _config$minAnswerChoi = config.minAnswerChoices,
|
|
404
|
+
minAnswerChoices = _config$minAnswerChoi === void 0 ? 2 : _config$minAnswerChoi,
|
|
405
|
+
maxAnswerChoices = config.maxAnswerChoices;
|
|
406
|
+
var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
|
|
407
|
+
var choicesErrors = {};
|
|
408
|
+
var hasCorrectResponse = false;
|
|
409
|
+
reversedChoices.forEach(function (choice, index) {
|
|
410
|
+
var correct = choice.correct,
|
|
411
|
+
value = choice.value,
|
|
412
|
+
label = choice.label;
|
|
413
|
+
|
|
414
|
+
if (correct) {
|
|
415
|
+
hasCorrectResponse = true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (label === '' || label === '<div></div>') {
|
|
419
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
420
|
+
} else {
|
|
421
|
+
var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
|
|
422
|
+
return c.label === label;
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
if (identicalAnswer) {
|
|
426
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
var errors = {};
|
|
431
|
+
var nbOfChoices = (choices || []).length;
|
|
432
|
+
|
|
433
|
+
if (nbOfChoices < minAnswerChoices) {
|
|
434
|
+
errors.answerChoicesError = "There should be at least ".concat(minAnswerChoices, " choices defined.");
|
|
435
|
+
} else if (nbOfChoices > maxAnswerChoices) {
|
|
436
|
+
errors.answerChoicesError = "No more than ".concat(maxAnswerChoices, " choices should be defined.");
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (!hasCorrectResponse) {
|
|
440
|
+
errors.correctResponseError = 'No correct response defined.';
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (!(0, _isEmpty["default"])(choicesErrors)) {
|
|
444
|
+
errors.choicesErrors = choicesErrors;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return errors;
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
var validate = function validate() {
|
|
451
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
452
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
453
|
+
|
|
454
|
+
var _ref6 = model || {},
|
|
455
|
+
partA = _ref6.partA,
|
|
456
|
+
partB = _ref6.partB;
|
|
457
|
+
|
|
458
|
+
var _ref7 = config || {},
|
|
459
|
+
partAConfig = _ref7.partA,
|
|
460
|
+
partBConfig = _ref7.partB;
|
|
461
|
+
|
|
462
|
+
var partAErrors = validatePart(partA, partAConfig);
|
|
463
|
+
var partBErrors = validatePart(partB, partBConfig);
|
|
464
|
+
return {
|
|
465
|
+
partA: partAErrors,
|
|
466
|
+
partB: partBErrors
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
exports.validate = validate;
|
|
395
471
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["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","undefined","normalize","partA","partB","question","partLabels","partLabelType","defaults","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","gridColumns","choicesLayout","verticalMode","updateSession","normalizedQuestion","shuffledValues","us","id","element","update","Promise","resolve","partASession","partALockChoiceOrder","partAChoices","partBChoices","partBSession","partBLockChoiceOrder","e","console","error","partLabel","teacherInstructions","prompt","createDefaultModel","isCorrect","getScore","config","sessionPart","maxScore","sessionPartValue","chosen","find","v","correctAndNotChosen","incorrectAndChosen","correctChoices","reduce","total","partialScoring","parseFloat","toFixed","outcome","score","scoreA","scoreB","empty","max","returnPartCorrect","answers","forEach","i","push","createCorrectResponseSession","partACorrect","partBCorrect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAC/D,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QACEL,GAAG,CAACM,IAAJ,KAAa,YAAb,KACCN,GAAG,CAACO,IAAJ,KAAa,MAAb,IAAuBP,GAAG,CAACO,IAAJ,KAAa,UADrC,CADF,EAGE;AACAJ,MAAAA,GAAG,CAACK,SAAJ,GAAgBT,KAAK,CAACU,gBAAN,GAAyBP,MAAM,CAACM,SAAhC,GAA4C,IAA5D;AACD,KALD,MAKO;AACLL,MAAAA,GAAG,CAACK,SAAJ,GAAgB,IAAhB;AACD;;AAED,QAAIR,GAAG,CAACO,IAAJ,KAAa,UAAjB,EAA6B;AAC3BJ,MAAAA,GAAG,CAACO,OAAJ,GAAc,CAAC,CAACR,MAAM,CAACQ,OAAvB;;AAEA,UAAIX,KAAK,CAACY,eAAV,EAA2B;AACzB,YAAMC,YAAY,GAAIV,MAAM,CAACW,QAAP,IAAmBX,MAAM,CAACW,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,YAAIF,YAAY,KAAK,SAArB,EAAgC;A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AVD;;AAYO,IAAMI,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAC5D,QAAD,EAAWnC,GAAX,EAAmB;AAC7D,SAAO,IAAIoD,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAIrD,GAAG,CAACO,IAAJ,KAAa,UAAb,IAA2BP,GAAG,CAACM,IAAJ,KAAa,YAA5C,EAA0D;AACxD,UAAQ2B,KAAR,GAAyBE,QAAzB,CAAQF,KAAR;AAAA,UAAeC,KAAf,GAAyBC,QAAzB,CAAeD,KAAf;AAEA,UAAM8D,YAAY,GAAGN,iBAAiB,CAACzD,KAAK,CAACX,OAAP,CAAtC;AACA,UAAM2E,YAAY,GAAGP,iBAAiB,CAACxD,KAAK,CAACZ,OAAP,CAAtC;AAEA+B,MAAAA,OAAO,CAAC;AACNhD,QAAAA,KAAK,EAAE;AACL4B,UAAAA,KAAK,EAAE;AACLgB,YAAAA,EAAE,EAAE,OADC;AAEL5C,YAAAA,KAAK,EAAE2F;AAFF,WADF;AAKL9D,UAAAA,KAAK,EAAE;AACLe,YAAAA,EAAE,EAAE,OADC;AAEL5C,YAAAA,KAAK,EAAE4F;AAFF;AALF,SADD;AAWNhD,QAAAA,EAAE,EAAE;AAXE,OAAD,CAAP;AAaD,KAnBD,MAmBO;AACLI,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAvBM,CAAP;AAwBD,CAzBM","sourcesContent":["import defaults from './defaults';\nimport { lockChoices, getShuffledChoices } from '@pie-lib/controller-utils';\nimport { isResponseCorrect } from './utils';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const out = {\n label: choice.label,\n value: choice.value\n };\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\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(\n { correct: 'Correct', incorrect: 'Incorrect' },\n part.defaultFeedback\n );\n\n let choices = part.choices\n ? part.choices.map(prepareChoice(part, env, defaultFeedback))\n : [];\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:\n env.mode === 'evaluate'\n ? isResponseCorrect(part, key, session)\n : undefined\n };\n};\n\nexport const normalize = ({ partA = {}, partB = {}, ...question }) => ({\n partLabels: true,\n partLabelType: 'Letters',\n ...question,\n partA: {\n ...defaults.partA,\n rationaleEnabled: true,\n feedbackEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partA,\n choicesLayout: partA.choicesLayout || (partA.verticalMode === false && 'horizontal') || 'vertical'\n },\n partB: {\n ...defaults.partB,\n rationaleEnabled: true,\n promptEnabled: true,\n feedbackEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partB,\n choicesLayout: partB.choicesLayout || (partB.verticalMode === false && 'horizontal') || 'vertical'\n }\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 console.error('update session failed', e);\n });\n }\n }\n\n if (normalizedQuestion.partLabels) {\n partA.partLabel =\n normalizedQuestion.partLabelType === 'Letters' ? 'Part A' : 'Part 1';\n partB.partLabel =\n normalizedQuestion.partLabelType === 'Letters' ? 'Part B' : 'Part 2';\n } else {\n partA.partLabel = undefined;\n partB.partLabel = undefined;\n }\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n partA.teacherInstructions = normalizedQuestion.partA\n .teacherInstructionsEnabled\n ? normalizedQuestion.partA.teacherInstructions\n : null;\n partB.teacherInstructions = normalizedQuestion.partB\n .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\n ? normalizedQuestion.partA.prompt\n : null;\n partB.prompt = normalizedQuestion.partB.promptEnabled\n ? normalizedQuestion.partB.prompt\n : null;\n\n return new Promise(resolve => {\n resolve({\n disabled: env.mode !== 'gather',\n mode: env.mode,\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) => {\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 (!config.partialScoring && correctChoices < maxScore) {\n return 0;\n }\n\n return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);\n};\n\nexport function outcome(config, session) {\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 scoreA = getScore(config, partA, 'partA');\n const scoreB = getScore(config, partB, 'partB');\n\n if (!config.partialScoring) {\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"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["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","undefined","normalize","partA","partB","question","partLabels","partLabelType","defaults","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","gridColumns","choicesLayout","verticalMode","updateSession","normalizedQuestion","shuffledValues","us","id","element","update","Promise","resolve","partASession","partALockChoiceOrder","partAChoices","partBChoices","partBSession","partBLockChoiceOrder","e","console","error","partLabel","teacherInstructions","prompt","createDefaultModel","isCorrect","getScore","config","sessionPart","maxScore","sessionPartValue","chosen","find","v","correctAndNotChosen","incorrectAndChosen","correctChoices","reduce","total","partialScoring","parseFloat","toFixed","outcome","score","scoreA","scoreB","empty","max","returnPartCorrect","answers","forEach","i","push","createCorrectResponseSession","partACorrect","partBCorrect","validatePart","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","hasCorrectResponse","index","identicalAnswer","slice","some","errors","nbOfChoices","answerChoicesError","correctResponseError","validate","partAConfig","partBConfig","partAErrors","partBErrors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAAAC,MAAM,EAAI;AAC/D,QAAMC,GAAG,GAAG;AACVC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AW,GAAGnB,YAAY,CAAChE,KAAD,EAAQiF,WAAR,CAAhC;AAEA,SAAO;AAAElF,IAAAA,KAAK,EAAEmF,WAAT;AAAsBlF,IAAAA,KAAK,EAAEmF;AAA7B,GAAP;AACD,CARM","sourcesContent":["import defaults from './defaults';\nimport { lockChoices, getShuffledChoices } from '@pie-lib/controller-utils';\nimport { isResponseCorrect } from './utils';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\n\nconst prepareChoice = (model, env, defaultFeedback) => choice => {\n const out = {\n label: choice.label,\n value: choice.value\n };\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\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(\n { correct: 'Correct', incorrect: 'Incorrect' },\n part.defaultFeedback\n );\n\n let choices = part.choices\n ? part.choices.map(prepareChoice(part, env, defaultFeedback))\n : [];\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:\n env.mode === 'evaluate'\n ? isResponseCorrect(part, key, session)\n : undefined\n };\n};\n\nexport const normalize = ({ partA = {}, partB = {}, ...question }) => ({\n partLabels: true,\n partLabelType: 'Letters',\n ...question,\n partA: {\n ...defaults.partA,\n rationaleEnabled: true,\n feedbackEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partA,\n choicesLayout: partA.choicesLayout || (partA.verticalMode === false && 'horizontal') || 'vertical'\n },\n partB: {\n ...defaults.partB,\n rationaleEnabled: true,\n promptEnabled: true,\n feedbackEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partB,\n choicesLayout: partB.choicesLayout || (partB.verticalMode === false && 'horizontal') || 'vertical'\n }\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 console.error('update session failed', e);\n });\n }\n }\n\n if (normalizedQuestion.partLabels) {\n partA.partLabel =\n normalizedQuestion.partLabelType === 'Letters' ? 'Part A' : 'Part 1';\n partB.partLabel =\n normalizedQuestion.partLabelType === 'Letters' ? 'Part B' : 'Part 2';\n } else {\n partA.partLabel = undefined;\n partB.partLabel = undefined;\n }\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\n partA.teacherInstructions = normalizedQuestion.partA\n .teacherInstructionsEnabled\n ? normalizedQuestion.partA.teacherInstructions\n : null;\n partB.teacherInstructions = normalizedQuestion.partB\n .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\n ? normalizedQuestion.partA.prompt\n : null;\n partB.prompt = normalizedQuestion.partB.promptEnabled\n ? normalizedQuestion.partB.prompt\n : null;\n\n return new Promise(resolve => {\n resolve({\n disabled: env.mode !== 'gather',\n mode: env.mode,\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) => {\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 (!config.partialScoring && correctChoices < maxScore) {\n return 0;\n }\n\n return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);\n};\n\nexport function outcome(config, session) {\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 scoreA = getScore(config, partA, 'partA');\n const scoreB = getScore(config, partB, 'partB');\n\n if (!config.partialScoring) {\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\nconst validatePart = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...choices || []].reverse();\n const choicesErrors = {};\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (label === '' || label === '<div></div>') {\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\n const errors = {};\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponseError = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\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"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/controller/src/index.js
CHANGED
|
@@ -298,3 +298,58 @@ export const createCorrectResponseSession = (question, env) => {
|
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
};
|
|
301
|
+
|
|
302
|
+
const validatePart = (model = {}, config = {}) => {
|
|
303
|
+
const { choices } = model;
|
|
304
|
+
const { minAnswerChoices = 2, maxAnswerChoices } = config;
|
|
305
|
+
const reversedChoices = [...choices || []].reverse();
|
|
306
|
+
const choicesErrors = {};
|
|
307
|
+
let hasCorrectResponse = false;
|
|
308
|
+
|
|
309
|
+
reversedChoices.forEach((choice, index) => {
|
|
310
|
+
const { correct, value, label } = choice;
|
|
311
|
+
|
|
312
|
+
if (correct) {
|
|
313
|
+
hasCorrectResponse = true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (label === '' || label === '<div></div>') {
|
|
317
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
318
|
+
} else {
|
|
319
|
+
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
|
|
320
|
+
|
|
321
|
+
if (identicalAnswer) {
|
|
322
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const errors = {};
|
|
328
|
+
const nbOfChoices = (choices || []).length;
|
|
329
|
+
|
|
330
|
+
if (nbOfChoices < minAnswerChoices) {
|
|
331
|
+
errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;
|
|
332
|
+
} else if (nbOfChoices > maxAnswerChoices) {
|
|
333
|
+
errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (!hasCorrectResponse) {
|
|
337
|
+
errors.correctResponseError = 'No correct response defined.';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (!isEmpty(choicesErrors)) {
|
|
341
|
+
errors.choicesErrors = choicesErrors;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return errors;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const validate = (model = {}, config = {}) => {
|
|
348
|
+
const { partA, partB } = model || {};
|
|
349
|
+
const { partA: partAConfig, partB: partBConfig } = config || {};
|
|
350
|
+
|
|
351
|
+
const partAErrors = validatePart(partA, partAConfig);
|
|
352
|
+
const partBErrors = validatePart(partB, partBConfig);
|
|
353
|
+
|
|
354
|
+
return { partA: partAErrors, partB: partBErrors };
|
|
355
|
+
};
|
package/module/configure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_lodash, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_lodash, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.19/module/index.js";
|
|
2
2
|
import MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';
|
|
3
|
-
import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.
|
|
3
|
+
import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.3.1/module/index.js";
|
|
4
4
|
var lib = {};
|
|
5
5
|
Object.defineProperty(lib, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -49,7 +49,6 @@ lib.InsertImageEvent = InsertImageEvent;
|
|
|
49
49
|
const React$1 = _dll_react;
|
|
50
50
|
const PropTypes = _dll_prop_types;
|
|
51
51
|
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
52
|
-
const {cloneDeep: cloneDeep$1} = _dll_lodash;
|
|
53
52
|
const {settings: settings} = _dll_pie_lib__config_ui;
|
|
54
53
|
const {layout: layout} = _dll_pie_lib__config_ui;
|
|
55
54
|
const _jsxFileName = "/home/circleci/repo/packages/ebsr/configure/src/main.jsx";
|
|
@@ -131,7 +130,7 @@ class Main extends React$1.Component {
|
|
|
131
130
|
__self: this,
|
|
132
131
|
__source: {
|
|
133
132
|
fileName: _jsxFileName,
|
|
134
|
-
lineNumber:
|
|
133
|
+
lineNumber: 110
|
|
135
134
|
}
|
|
136
135
|
}, React$1.createElement(layout.ConfigLayout, {
|
|
137
136
|
settings: React$1.createElement(Panel, {
|
|
@@ -180,32 +179,32 @@ class Main extends React$1.Component {
|
|
|
180
179
|
__self: this,
|
|
181
180
|
__source: {
|
|
182
181
|
fileName: _jsxFileName,
|
|
183
|
-
lineNumber:
|
|
182
|
+
lineNumber: 113
|
|
184
183
|
}
|
|
185
184
|
}),
|
|
186
185
|
__self: this,
|
|
187
186
|
__source: {
|
|
188
187
|
fileName: _jsxFileName,
|
|
189
|
-
lineNumber:
|
|
188
|
+
lineNumber: 111
|
|
190
189
|
}
|
|
191
190
|
}, React$1.createElement('div', {
|
|
192
191
|
__self: this,
|
|
193
192
|
__source: {
|
|
194
193
|
fileName: _jsxFileName,
|
|
195
|
-
lineNumber:
|
|
194
|
+
lineNumber: 200
|
|
196
195
|
}
|
|
197
196
|
}, React$1.createElement('div', {
|
|
198
197
|
className: classes.part,
|
|
199
198
|
__self: this,
|
|
200
199
|
__source: {
|
|
201
200
|
fileName: _jsxFileName,
|
|
202
|
-
lineNumber:
|
|
201
|
+
lineNumber: 201
|
|
203
202
|
}
|
|
204
203
|
}, model.partLabels && React$1.createElement('p', {
|
|
205
204
|
__self: this,
|
|
206
205
|
__source: {
|
|
207
206
|
fileName: _jsxFileName,
|
|
208
|
-
lineNumber:
|
|
207
|
+
lineNumber: 202
|
|
209
208
|
}
|
|
210
209
|
}, firstPart), React$1.createElement('ebsr-multiple-choice-configure', {
|
|
211
210
|
id: "A",
|
|
@@ -213,7 +212,10 @@ class Main extends React$1.Component {
|
|
|
213
212
|
ref: ref => {
|
|
214
213
|
if (ref) {
|
|
215
214
|
this.partA = ref;
|
|
216
|
-
this.partA._model =
|
|
215
|
+
this.partA._model = {
|
|
216
|
+
...this.props.model.partA,
|
|
217
|
+
errors: this.props.model.errors && this.props.model.errors.partA || ({})
|
|
218
|
+
};
|
|
217
219
|
this.partA.configuration = {
|
|
218
220
|
...partA,
|
|
219
221
|
...generalConfiguration
|
|
@@ -223,20 +225,20 @@ class Main extends React$1.Component {
|
|
|
223
225
|
__self: this,
|
|
224
226
|
__source: {
|
|
225
227
|
fileName: _jsxFileName,
|
|
226
|
-
lineNumber:
|
|
228
|
+
lineNumber: 203
|
|
227
229
|
}
|
|
228
230
|
})), React$1.createElement('div', {
|
|
229
231
|
className: classes.part,
|
|
230
232
|
__self: this,
|
|
231
233
|
__source: {
|
|
232
234
|
fileName: _jsxFileName,
|
|
233
|
-
lineNumber:
|
|
235
|
+
lineNumber: 223
|
|
234
236
|
}
|
|
235
237
|
}, model.partLabels && React$1.createElement('p', {
|
|
236
238
|
__self: this,
|
|
237
239
|
__source: {
|
|
238
240
|
fileName: _jsxFileName,
|
|
239
|
-
lineNumber:
|
|
241
|
+
lineNumber: 224
|
|
240
242
|
}
|
|
241
243
|
}, secondPart), React$1.createElement('ebsr-multiple-choice-configure', {
|
|
242
244
|
id: "B",
|
|
@@ -244,7 +246,10 @@ class Main extends React$1.Component {
|
|
|
244
246
|
ref: ref => {
|
|
245
247
|
if (ref) {
|
|
246
248
|
this.partB = ref;
|
|
247
|
-
this.partB._model =
|
|
249
|
+
this.partB._model = {
|
|
250
|
+
...this.props.model.partB,
|
|
251
|
+
errors: this.props.model.errors && this.props.model.errors.partB || ({})
|
|
252
|
+
};
|
|
248
253
|
this.partB.configuration = {
|
|
249
254
|
...partB,
|
|
250
255
|
...generalConfiguration
|
|
@@ -254,7 +259,7 @@ class Main extends React$1.Component {
|
|
|
254
259
|
__self: this,
|
|
255
260
|
__source: {
|
|
256
261
|
fileName: _jsxFileName,
|
|
257
|
-
lineNumber:
|
|
262
|
+
lineNumber: 225
|
|
258
263
|
}
|
|
259
264
|
})))));
|
|
260
265
|
}
|
package/module/controller.js
CHANGED
|
@@ -20753,4 +20753,59 @@ const createCorrectResponseSession = (question, env) => {
|
|
|
20753
20753
|
});
|
|
20754
20754
|
};
|
|
20755
20755
|
|
|
20756
|
-
|
|
20756
|
+
const validatePart = (model = {}, config = {}) => {
|
|
20757
|
+
const { choices } = model;
|
|
20758
|
+
const { minAnswerChoices = 2, maxAnswerChoices } = config;
|
|
20759
|
+
const reversedChoices = [...choices || []].reverse();
|
|
20760
|
+
const choicesErrors = {};
|
|
20761
|
+
let hasCorrectResponse = false;
|
|
20762
|
+
|
|
20763
|
+
reversedChoices.forEach((choice, index) => {
|
|
20764
|
+
const { correct, value, label } = choice;
|
|
20765
|
+
|
|
20766
|
+
if (correct) {
|
|
20767
|
+
hasCorrectResponse = true;
|
|
20768
|
+
}
|
|
20769
|
+
|
|
20770
|
+
if (label === '' || label === '<div></div>') {
|
|
20771
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
20772
|
+
} else {
|
|
20773
|
+
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
|
|
20774
|
+
|
|
20775
|
+
if (identicalAnswer) {
|
|
20776
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
20777
|
+
}
|
|
20778
|
+
}
|
|
20779
|
+
});
|
|
20780
|
+
|
|
20781
|
+
const errors = {};
|
|
20782
|
+
const nbOfChoices = (choices || []).length;
|
|
20783
|
+
|
|
20784
|
+
if (nbOfChoices < minAnswerChoices) {
|
|
20785
|
+
errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;
|
|
20786
|
+
} else if (nbOfChoices > maxAnswerChoices) {
|
|
20787
|
+
errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
20788
|
+
}
|
|
20789
|
+
|
|
20790
|
+
if (!hasCorrectResponse) {
|
|
20791
|
+
errors.correctResponseError = 'No correct response defined.';
|
|
20792
|
+
}
|
|
20793
|
+
|
|
20794
|
+
if (!isEmpty_1(choicesErrors)) {
|
|
20795
|
+
errors.choicesErrors = choicesErrors;
|
|
20796
|
+
}
|
|
20797
|
+
|
|
20798
|
+
return errors;
|
|
20799
|
+
};
|
|
20800
|
+
|
|
20801
|
+
const validate = (model = {}, config = {}) => {
|
|
20802
|
+
const { partA, partB } = model || {};
|
|
20803
|
+
const { partA: partAConfig, partB: partBConfig } = config || {};
|
|
20804
|
+
|
|
20805
|
+
const partAErrors = validatePart(partA, partAConfig);
|
|
20806
|
+
const partBErrors = validatePart(partB, partBConfig);
|
|
20807
|
+
|
|
20808
|
+
return { partA: partAErrors, partB: partBErrors };
|
|
20809
|
+
};
|
|
20810
|
+
|
|
20811
|
+
export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome, validate };
|
package/module/element.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.
|
|
2
|
-
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.
|
|
1
|
+
import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.19/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.7/module/index.js";
|
|
3
3
|
function getDefaultExportFromCjs(x) {
|
|
4
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
5
|
}
|
package/module/index.html
CHANGED
package/module/manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.24",
|
|
4
4
|
"modules": [
|
|
5
5
|
{
|
|
6
6
|
"name": "@pie-lib/shared-module",
|
|
7
|
-
"version": "^1.4.
|
|
7
|
+
"version": "^1.4.19"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"name": "@pie-lib/math-rendering-module",
|
|
11
|
-
"version": "^1.1.
|
|
11
|
+
"version": "^1.1.7"
|
|
12
12
|
}
|
|
13
13
|
]
|
|
14
14
|
}
|
package/module/print.html
CHANGED
package/module/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.
|
|
2
|
-
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.
|
|
1
|
+
import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.19/module/index.js";
|
|
2
|
+
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.7/module/index.js";
|
|
3
3
|
function getDefaultExportFromCjs(x) {
|
|
4
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@pie-element/multiple-choice": "^6.3.
|
|
10
|
+
"@pie-element/multiple-choice": "^6.3.3",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"debug": "^4.1.1",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "pie framework developers",
|
|
17
17
|
"license": "ISC",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "3f3d6edc68890098821978ebd5a8b90da31ab222",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"postpublish": "../../scripts/postpublish"
|
|
21
21
|
},
|