@pie-element/ebsr 14.3.2-beta.6 → 14.3.2-beta.8
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/defaults.js +229 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +155 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +222 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/defaults.js +31 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +448 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +18 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +207 -0
- package/lib/index.js.map +1 -0
- package/lib/print.js +186 -0
- package/lib/print.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_styles","Panel","toggle","radio","dropdown","settings","PartLabel","styled","theme","paddingBottom","spacing","Divider","flex","height","Main","React","Component","constructor","args","_defineProperty2","default","choices","correctFound","map","choice","correct","model","key","onModelChanged","props","partA","choiceMode","removeExtraChoices","partB","render","configuration","onConfigurationChanged","partLabelType","modelPartA","modelPartB","extraCSSRules","contentDimensions","partialScoring","settingsPanelDisabled","scoringType","language","languageChoices","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","panelSettings","partLabels","label","enabled","options","panelSettingsPartA","panelPropertiesPartA","panelSettingsPartB","panelPropertiesPartB","createElement","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onChangeConfiguration","groups","id","ref","_model","errors","exports","PropTypes","object","func","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { settings, layout } from '@pie-lib/config-ui';\nimport { styled } from '@mui/material/styles';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst PartLabel = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n}));\n\nconst Divider = styled('div')(({ theme }) => ({\n flex: 1,\n height: theme.spacing(2.5),\n}));\n\nexport class Main extends React.Component {\n static propTypes = {\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\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 { model, configuration, onConfigurationChanged } = this.props;\n const { partLabelType, partA: modelPartA, partB: modelPartB, extraCSSRules } = model;\n const {\n contentDimensions = {},\n partA = {},\n partB = {},\n partialScoring = {},\n settingsPanelDisabled,\n scoringType = {},\n language = {},\n languageChoices = {},\n ...generalConfiguration\n } = 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\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:\n modelPartA.choices && modelPartA.choices.length\n ? Array.from({ length: modelPartA.choices.length }, (_, i) => `${i + 1}`)\n : [],\n partB:\n modelPartB.choices && modelPartB.choices.length\n ? Array.from({ length: modelPartB.choices.length }, (_, i) => `${i + 1}`)\n : [],\n };\n\n const panelSettings = {\n partLabels: generalConfiguration.partLabels.settings && toggle(generalConfiguration.partLabels.label),\n partLabelType: model.partLabels && dropdown('', ['Numbers', 'Letters']),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelSettingsPartA = {\n 'partA.choiceMode': choiceModeA.settings && radio(choiceModeA.label, ['checkbox', 'radio']),\n 'partA.choicePrefix': choicePrefixA.settings && radio(choicePrefixA.label, ['numbers', 'letters']),\n 'partA.lockChoiceOrder': lockChoiceOrderA.settings && toggle(lockChoiceOrderA.label),\n 'partA.choicesLayout':\n choicesLayoutA.settings && dropdown(choicesLayoutA.label, ['vertical', 'grid', 'horizontal']),\n 'partA.gridColumns':\n choicesLayoutA.settings &&\n modelPartA.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partA.length > 0 &&\n dropdown(gridColumnsA.label, nrOfColumnsAvailable.partA),\n };\n const panelPropertiesPartA = {\n 'partA.feedbackEnabled': feedbackA.settings && toggle(feedbackA.label),\n 'partA.promptEnabled': promptA.settings && toggle(promptA.label),\n 'partA.teacherInstructionsEnabled': teacherInstructionsA.settings && toggle(teacherInstructionsA.label),\n 'partA.studentInstructionsEnabled': studentInstructionsA.settings && toggle(studentInstructionsA.label),\n 'partA.rationaleEnabled': rationaleA.settings && toggle(rationaleA.label),\n 'partA.spellCheckEnabled': spellCheckA.settings && toggle(spellCheckA.label),\n };\n\n const panelSettingsPartB = {\n 'partB.choiceMode': choiceModeB.settings && radio(choiceModeB.label, ['checkbox', 'radio']),\n 'partB.choicePrefix': choicePrefixB.settings && radio(choicePrefixB.label, ['numbers', 'letters']),\n 'partB.lockChoiceOrder': lockChoiceOrderB.settings && toggle(lockChoiceOrderB.label),\n 'partB.choicesLayout':\n choicesLayoutB.settings && dropdown(choicesLayoutB.label, ['vertical', 'grid', 'horizontal']),\n 'partB.gridColumns':\n choicesLayoutB.settings &&\n modelPartB.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partB.length > 0 &&\n dropdown(gridColumnsB.label, nrOfColumnsAvailable.partB),\n };\n const panelPropertiesPartB = {\n 'partB.feedbackEnabled': feedbackB.settings && toggle(feedbackB.label),\n 'partB.promptEnabled': promptB.settings && toggle(promptB.label),\n 'partB.teacherInstructionsEnabled': teacherInstructionsB.settings && toggle(teacherInstructionsB.label),\n 'partB.studentInstructionsEnabled': studentInstructionsB.settings && toggle(studentInstructionsB.label),\n 'partB.rationaleEnabled': rationaleB.settings && toggle(rationaleB.label),\n 'partB.spellCheckEnabled': spellCheckB.settings && toggle(spellCheckB.label),\n };\n\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={this.onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings for both': panelSettings,\n [`Settings ${firstPart}`]: panelSettingsPartA,\n [`Properties ${firstPart}`]: panelPropertiesPartA,\n [`Settings ${secondPart}`]: panelSettingsPartB,\n [`Properties ${secondPart}`]: panelPropertiesPartB,\n }}\n />\n }\n >\n {model.partLabels && <PartLabel>{firstPart}</PartLabel>}\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\n <Divider />\n\n {model.partLabels && <PartLabel>{secondPart}</PartLabel>}\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 </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAM;EAAEI,KAAK;EAAEC,MAAM;EAAEC,KAAK;EAAEC;AAAS,CAAC,GAAGC,kBAAQ;AAEnD,MAAMC,SAAS,GAAG,IAAAC,cAAM,EAA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EVe,KAAK,CAACiE,UAAU,iBAAIhG,MAAA,CAAAyB,OAAA,CAAA+E,aAAA,CAAC7F,SAAS,QAAE6E,UAAsB,CAAC,eACxDxF,MAAA,CAAAyB,OAAA,CAAA+E,aAAA;MACEQ,EAAE,EAAC,GAAG;MACNhF,GAAG,EAAC,OAAO;MACXiF,GAAG,EAAGA,GAAG,IAAK;QACZ,IAAIA,GAAG,EAAE;UACP;UACA,IAAI,CAAC3E,KAAK,GAAG2E,GAAG;UAChB,IAAI,CAAC3E,KAAK,CAAC4E,MAAM,GAAG;YAClB,GAAG,IAAI,CAAChF,KAAK,CAACH,KAAK,CAACO,KAAK;YACzB6E,MAAM,EAAG,IAAI,CAACjF,KAAK,CAACH,KAAK,CAACoF,MAAM,IAAI,IAAI,CAACjF,KAAK,CAACH,KAAK,CAACoF,MAAM,CAAC7E,KAAK,IAAK,CAAC;UACzE,CAAC;UACD,IAAI,CAACA,KAAK,CAACE,aAAa,GAAG;YACzB,GAAGF,KAAK;YACR,GAAGc;UACL,CAAC;QACH;MACF;IAAE,CACH,CACkB,CAAC;EAE1B;AACF;AAACgE,OAAA,CAAAjG,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EAxNYN,IAAI,eACI;EACjBqB,aAAa,EAAE6E,kBAAS,CAACC,MAAM;EAC/BvF,KAAK,EAAEsF,kBAAS,CAACC,MAAM;EACvBrF,cAAc,EAAEoF,kBAAS,CAACE,IAAI;EAC9B9E,sBAAsB,EAAE4E,kBAAS,CAACE;AACpC,CAAC;AAAA,IAAAC,QAAA,GAAAJ,OAAA,CAAA3F,OAAA,GAoNYN,IAAI","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": "13.4.0-beta.
|
|
4
|
+
"version": "13.4.0-beta.14",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -11,9 +11,9 @@
|
|
|
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": "^13.4.2-beta.
|
|
14
|
+
"@pie-element/multiple-choice": "^13.4.2-beta.8",
|
|
15
15
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
16
|
-
"@pie-lib/config-ui": "13.0.22-beta.
|
|
16
|
+
"@pie-lib/config-ui": "13.0.22-beta.3",
|
|
17
17
|
"lodash-es": "^4.17.23",
|
|
18
18
|
"prop-types": "^15.8.1",
|
|
19
19
|
"react": "18.3.1",
|
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
|
+
# [11.4.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@11.4.0-beta.13...@pie-element/ebsr-controller@11.4.0-beta.14) (2026-09-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/ebsr-controller
|
|
9
|
+
|
|
10
|
+
# [11.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@11.4.0-beta.12...@pie-element/ebsr-controller@11.4.0-beta.13) (2026-09-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/ebsr-controller
|
|
13
|
+
|
|
6
14
|
# [11.4.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/ebsr-controller@11.4.0-beta.11...@pie-element/ebsr-controller@11.4.0-beta.12) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/ebsr-controller
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const partModel = base => ({
|
|
8
|
+
choiceMode: 'radio',
|
|
9
|
+
choicePrefix: 'letters',
|
|
10
|
+
choices: [],
|
|
11
|
+
choicesLayout: 'vertical',
|
|
12
|
+
feedbackEnabled: false,
|
|
13
|
+
gridColumns: 2,
|
|
14
|
+
prompt: '',
|
|
15
|
+
promptEnabled: true,
|
|
16
|
+
rationale: '',
|
|
17
|
+
rationaleEnabled: true,
|
|
18
|
+
spellCheckEnabled: true,
|
|
19
|
+
studentInstructionsEnabled: true,
|
|
20
|
+
teacherInstructions: '',
|
|
21
|
+
teacherInstructionsEnabled: true,
|
|
22
|
+
toolbarEditorPosition: 'bottom',
|
|
23
|
+
...base
|
|
24
|
+
});
|
|
25
|
+
var _default = exports.default = {
|
|
26
|
+
partLabels: true,
|
|
27
|
+
partLabelType: 'Letters',
|
|
28
|
+
partA: partModel(),
|
|
29
|
+
partB: partModel()
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["partModel","base","choiceMode","choicePrefix","choices","choicesLayout","feedbackEnabled","gridColumns","prompt","promptEnabled","rationale","rationaleEnabled","spellCheckEnabled","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","_default","exports","default","partLabels","partLabelType","partA","partB"],"sources":["../src/defaults.js"],"sourcesContent":["const 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 partLabels: true,\n partLabelType: 'Letters',\n partA: partModel(),\n partB: partModel(),\n};\n"],"mappings":";;;;;;AAAA,MAAMA,SAAS,GAAIC,IAAI,KAAM;EAC3BC,UAAU,EAAE,OAAO;EACnBC,YAAY,EAAE,SAAS;EACvBC,OAAO,EAAE,EAAE;EACXC,aAAa,EAAE,UAAU;EACzBC,eAAe,EAAE,KAAK;EACtBC,WAAW,EAAE,CAAC;EACdC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,IAAI;EACtBC,iBAAiB,EAAE,IAAI;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,qBAAqB,EAAE,QAAQ;EAC/B,GAAGf;AACL,CAAC,CAAC;AAAC,IAAAgB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY;EACbC,UAAU,EAAE,IAAI;EAChBC,aAAa,EAAE,SAAS;EACxBC,KAAK,EAAEtB,SAAS,CAAC,CAAC;EAClBuB,KAAK,EAAEvB,SAAS,CAAC;AACnB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getLogTrace = exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
|
|
8
|
+
exports.model = model;
|
|
9
|
+
exports.normalize = void 0;
|
|
10
|
+
exports.outcome = outcome;
|
|
11
|
+
exports.validate = void 0;
|
|
12
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
13
|
+
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
14
|
+
var _utils = require("./utils");
|
|
15
|
+
var _lodashEs = require("lodash-es");
|
|
16
|
+
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
17
|
+
const {
|
|
18
|
+
translator
|
|
19
|
+
} = _translator.default;
|
|
20
|
+
const prepareChoice = (model, env, defaultFeedback) => choice => {
|
|
21
|
+
const out = {
|
|
22
|
+
label: choice.label,
|
|
23
|
+
value: choice.value
|
|
24
|
+
};
|
|
25
|
+
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
26
|
+
out.rationale = model.rationaleEnabled ? choice.rationale : null;
|
|
27
|
+
} else {
|
|
28
|
+
out.rationale = null;
|
|
29
|
+
}
|
|
30
|
+
if (env.mode === 'evaluate') {
|
|
31
|
+
out.correct = !!choice.correct;
|
|
32
|
+
if (model.feedbackEnabled) {
|
|
33
|
+
const feedbackType = choice.feedback && choice.feedback.type || 'none';
|
|
34
|
+
if (feedbackType === 'default') {
|
|
35
|
+
out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
|
|
36
|
+
} else if (feedbackType === 'custom') {
|
|
37
|
+
out.feedback = choice.feedback.value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
};
|
|
43
|
+
const parsePart = (part, key, session, env) => {
|
|
44
|
+
const defaultFeedback = Object.assign({
|
|
45
|
+
correct: 'Correct',
|
|
46
|
+
incorrect: 'Incorrect'
|
|
47
|
+
}, part.defaultFeedback);
|
|
48
|
+
let choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];
|
|
49
|
+
return {
|
|
50
|
+
...part,
|
|
51
|
+
choices,
|
|
52
|
+
disabled: env.mode !== 'gather',
|
|
53
|
+
complete: {
|
|
54
|
+
min: part.choices.filter(c => c.correct).length
|
|
55
|
+
},
|
|
56
|
+
responseCorrect: env.mode === 'evaluate' ? (0, _utils.isResponseCorrect)(part, key, session) : undefined
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const normalizePart = (model, base) => ({
|
|
60
|
+
...base,
|
|
61
|
+
...model,
|
|
62
|
+
choicesLayout: model.choicesLayout || model.verticalMode === false && 'horizontal' || 'vertical'
|
|
63
|
+
});
|
|
64
|
+
const normalize = ({
|
|
65
|
+
partA = {},
|
|
66
|
+
partB = {},
|
|
67
|
+
language,
|
|
68
|
+
...question
|
|
69
|
+
}) => ({
|
|
70
|
+
..._defaults.default,
|
|
71
|
+
...question,
|
|
72
|
+
partA: normalizePart(partA, {
|
|
73
|
+
..._defaults.default.partA,
|
|
74
|
+
language
|
|
75
|
+
}),
|
|
76
|
+
partB: normalizePart(partB, {
|
|
77
|
+
..._defaults.default.partB,
|
|
78
|
+
language
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param {*} question
|
|
85
|
+
* @param {*} session
|
|
86
|
+
* @param {*} env
|
|
87
|
+
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
88
|
+
*/
|
|
89
|
+
exports.normalize = normalize;
|
|
90
|
+
async function model(question, session, env, updateSession) {
|
|
91
|
+
const normalizedQuestion = normalize(question);
|
|
92
|
+
const partA = parsePart(normalizedQuestion.partA, 'partA', session, env);
|
|
93
|
+
const partB = parsePart(normalizedQuestion.partB, 'partB', session, env);
|
|
94
|
+
const shuffledValues = {};
|
|
95
|
+
const us = part => (id, element, update) => new Promise(resolve => {
|
|
96
|
+
shuffledValues[part] = update.shuffledValues;
|
|
97
|
+
resolve();
|
|
98
|
+
});
|
|
99
|
+
const partASession = (0, _lodashEs.get)(session, 'value.partA');
|
|
100
|
+
const partALockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partA, partASession, env);
|
|
101
|
+
const {
|
|
102
|
+
choices: partAChoices
|
|
103
|
+
} = partA || {};
|
|
104
|
+
const {
|
|
105
|
+
choices: partBChoices
|
|
106
|
+
} = partB || {};
|
|
107
|
+
if (!partALockChoiceOrder && partAChoices && partAChoices.length) {
|
|
108
|
+
partA.choices = await (0, _controllerUtils.getShuffledChoices)(partAChoices, {
|
|
109
|
+
shuffledValues: (session.shuffledValues || {}).partA
|
|
110
|
+
}, us('partA'), 'value');
|
|
111
|
+
}
|
|
112
|
+
const partBSession = (0, _lodashEs.get)(session, 'value.partB');
|
|
113
|
+
const partBLockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partB, partBSession, env);
|
|
114
|
+
if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {
|
|
115
|
+
partB.choices = await (0, _controllerUtils.getShuffledChoices)(partBChoices, {
|
|
116
|
+
shuffledValues: (session.shuffledValues || {}).partB
|
|
117
|
+
}, us('partB'), 'value');
|
|
118
|
+
}
|
|
119
|
+
if (!(0, _lodashEs.isEmpty)(shuffledValues)) {
|
|
120
|
+
if (updateSession && typeof updateSession === 'function') {
|
|
121
|
+
updateSession(session.id, session.element, {
|
|
122
|
+
shuffledValues
|
|
123
|
+
}).catch(e => {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.error('update session failed', e);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (normalizedQuestion.partLabels) {
|
|
130
|
+
const language = normalizedQuestion.language;
|
|
131
|
+
partA.partLabel = translator.t('ebsr.part', {
|
|
132
|
+
lng: language,
|
|
133
|
+
index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1'
|
|
134
|
+
});
|
|
135
|
+
partB.partLabel = translator.t('ebsr.part', {
|
|
136
|
+
lng: language,
|
|
137
|
+
index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2'
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
partA.partLabel = undefined;
|
|
141
|
+
partB.partLabel = undefined;
|
|
142
|
+
}
|
|
143
|
+
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
144
|
+
partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled ? normalizedQuestion.partA.teacherInstructions : null;
|
|
145
|
+
partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled ? normalizedQuestion.partB.teacherInstructions : null;
|
|
146
|
+
} else {
|
|
147
|
+
partA.teacherInstructions = null;
|
|
148
|
+
partB.teacherInstructions = null;
|
|
149
|
+
}
|
|
150
|
+
partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;
|
|
151
|
+
partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;
|
|
152
|
+
return new Promise(resolve => {
|
|
153
|
+
resolve({
|
|
154
|
+
disabled: env.mode !== 'gather',
|
|
155
|
+
mode: env.mode,
|
|
156
|
+
extraCSSRules: normalizedQuestion.extraCSSRules,
|
|
157
|
+
partA,
|
|
158
|
+
partB
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const createDefaultModel = (model = {}) => new Promise(resolve => {
|
|
163
|
+
resolve({
|
|
164
|
+
..._defaults.default,
|
|
165
|
+
...model
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
exports.createDefaultModel = createDefaultModel;
|
|
169
|
+
const isCorrect = c => c.correct === true;
|
|
170
|
+
const getScore = (config, sessionPart, key, partialScoringEnabled) => {
|
|
171
|
+
const {
|
|
172
|
+
choices = []
|
|
173
|
+
} = config && config[key] || {};
|
|
174
|
+
const maxScore = choices.length;
|
|
175
|
+
const {
|
|
176
|
+
value: sessionPartValue
|
|
177
|
+
} = sessionPart || {};
|
|
178
|
+
const chosen = c => !!(sessionPartValue || []).find(v => v === c.value);
|
|
179
|
+
const correctAndNotChosen = c => isCorrect(c) && !chosen(c);
|
|
180
|
+
const incorrectAndChosen = c => !isCorrect(c) && chosen(c);
|
|
181
|
+
const correctChoices = choices.reduce((total, choice) => {
|
|
182
|
+
if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {
|
|
183
|
+
return total - 1;
|
|
184
|
+
} else {
|
|
185
|
+
return total;
|
|
186
|
+
}
|
|
187
|
+
}, choices.length);
|
|
188
|
+
|
|
189
|
+
// determine score for a part
|
|
190
|
+
if (!partialScoringEnabled && correctChoices < maxScore) {
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Generates detailed trace log for math-templated scoring evaluation
|
|
198
|
+
* @param {Object} question
|
|
199
|
+
* @param {Object} session
|
|
200
|
+
* @param {Object} env
|
|
201
|
+
* @returns {Array<string>} traceLog
|
|
202
|
+
*/
|
|
203
|
+
const getLogTrace = (question, session, env) => {
|
|
204
|
+
const traceLog = [];
|
|
205
|
+
if (!session || !session.value) {
|
|
206
|
+
traceLog.push('Student did not answer the question.');
|
|
207
|
+
return traceLog;
|
|
208
|
+
}
|
|
209
|
+
const {
|
|
210
|
+
value
|
|
211
|
+
} = session;
|
|
212
|
+
const {
|
|
213
|
+
partA,
|
|
214
|
+
partB
|
|
215
|
+
} = value;
|
|
216
|
+
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(question, env);
|
|
217
|
+
traceLog.push(`Scoring method: ${partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'}.`);
|
|
218
|
+
const partAquestionType = question.partA.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';
|
|
219
|
+
traceLog.push(`Part A question type: ${partAquestionType}.`);
|
|
220
|
+
const partASelections = partA?.value || [];
|
|
221
|
+
const partACorrectChoices = (question.partA.choices || []).filter(c => c.correct);
|
|
222
|
+
const partACorrectValues = partACorrectChoices.map(c => c.value);
|
|
223
|
+
const partACorrectSelected = partASelections.filter(v => partACorrectValues.includes(v));
|
|
224
|
+
const partAIncorrectSelected = partASelections.filter(v => !partACorrectValues.includes(v));
|
|
225
|
+
if (partASelections.length) {
|
|
226
|
+
traceLog.push(`Part A: student selected ${partASelections.length} choice(s) (${partACorrectSelected.length} correct, ${partAIncorrectSelected.length} incorrect).`);
|
|
227
|
+
}
|
|
228
|
+
const scoreA = getScore(question, partA, 'partA', partialScoringEnabled);
|
|
229
|
+
traceLog.push(`Part A score: ${scoreA}.`);
|
|
230
|
+
const partBquestionType = question.partB.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';
|
|
231
|
+
traceLog.push(`Part B question type: ${partBquestionType}.`);
|
|
232
|
+
const partBSelections = partB?.value || [];
|
|
233
|
+
const partBCorrectChoices = (question.partB.choices || []).filter(c => c.correct);
|
|
234
|
+
const partBCorrectValues = partBCorrectChoices.map(c => c.value);
|
|
235
|
+
const correctSelected = partBSelections.filter(v => partBCorrectValues.includes(v));
|
|
236
|
+
const incorrectSelected = partBSelections.filter(v => !partBCorrectValues.includes(v));
|
|
237
|
+
if (partBSelections.length) {
|
|
238
|
+
traceLog.push(`Part B: student selected ${partBSelections.length} choice(s) (${correctSelected.length} correct, ${incorrectSelected.length} incorrect).`);
|
|
239
|
+
}
|
|
240
|
+
const scoreB = getScore(question, partB, 'partB', partialScoringEnabled);
|
|
241
|
+
traceLog.push(`Part B score: ${scoreB}.`);
|
|
242
|
+
if (!partialScoringEnabled) {
|
|
243
|
+
traceLog.push('Final score is awarded only if both Part A and Part B are completely correct.');
|
|
244
|
+
traceLog.push(`Final score: ${scoreA === 1 && scoreB === 1 ? 1 : 0}.`);
|
|
245
|
+
} else {
|
|
246
|
+
traceLog.push('With partial scoring enabled, Part A must be correct to earn any credit.');
|
|
247
|
+
let finalScore = 0;
|
|
248
|
+
if (scoreA === 1 && scoreB === 1) {
|
|
249
|
+
finalScore = 2;
|
|
250
|
+
} else if (scoreA === 1 && scoreB < 1) {
|
|
251
|
+
finalScore = 1;
|
|
252
|
+
}
|
|
253
|
+
traceLog.push(`Final score: ${finalScore}.`);
|
|
254
|
+
}
|
|
255
|
+
return traceLog;
|
|
256
|
+
};
|
|
257
|
+
exports.getLogTrace = getLogTrace;
|
|
258
|
+
function outcome(config, session, env) {
|
|
259
|
+
return new Promise(resolve => {
|
|
260
|
+
const {
|
|
261
|
+
value
|
|
262
|
+
} = session || {};
|
|
263
|
+
if (!session || !value) {
|
|
264
|
+
resolve({
|
|
265
|
+
score: 0,
|
|
266
|
+
scoreA: 0,
|
|
267
|
+
scoreB: 0,
|
|
268
|
+
empty: true,
|
|
269
|
+
logTrace: ['Student did not answer the question.']
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (value) {
|
|
273
|
+
const {
|
|
274
|
+
partA,
|
|
275
|
+
partB
|
|
276
|
+
} = value || {};
|
|
277
|
+
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(config, env);
|
|
278
|
+
const scoreA = getScore(config, partA, 'partA', partialScoringEnabled);
|
|
279
|
+
const scoreB = getScore(config, partB, 'partB', partialScoringEnabled);
|
|
280
|
+
const logTrace = getLogTrace(config, session, env);
|
|
281
|
+
if (!partialScoringEnabled) {
|
|
282
|
+
// The EBSR item is worth 1 point
|
|
283
|
+
// That point is awarded if and only if both parts are fully correct, otherwise no points are awarded
|
|
284
|
+
resolve({
|
|
285
|
+
score: scoreA === 1 && scoreB === 1 ? 1 : 0,
|
|
286
|
+
scoreA,
|
|
287
|
+
scoreB,
|
|
288
|
+
max: 1,
|
|
289
|
+
logTrace
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
// The EBSR item is worth 2 points
|
|
293
|
+
if (scoreA === 1) {
|
|
294
|
+
if (scoreB === 1) {
|
|
295
|
+
// If Part A and Part B are both correct, 2 points are awarded
|
|
296
|
+
resolve({
|
|
297
|
+
score: 2,
|
|
298
|
+
scoreA,
|
|
299
|
+
scoreB,
|
|
300
|
+
max: 2,
|
|
301
|
+
logTrace
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
// If Part A is correct and part B is incorrect, 1 point is awarded
|
|
305
|
+
resolve({
|
|
306
|
+
score: 1,
|
|
307
|
+
scoreA,
|
|
308
|
+
scoreB,
|
|
309
|
+
max: 2,
|
|
310
|
+
logTrace
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
// For all other combinations, no points are awarded
|
|
315
|
+
resolve({
|
|
316
|
+
score: 0,
|
|
317
|
+
scoreA,
|
|
318
|
+
scoreB,
|
|
319
|
+
max: 2,
|
|
320
|
+
logTrace
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
const returnPartCorrect = choices => {
|
|
328
|
+
let answers = [];
|
|
329
|
+
choices.forEach(i => {
|
|
330
|
+
const {
|
|
331
|
+
correct,
|
|
332
|
+
value
|
|
333
|
+
} = i;
|
|
334
|
+
if (correct) {
|
|
335
|
+
answers.push(value);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return answers;
|
|
339
|
+
};
|
|
340
|
+
const createCorrectResponseSession = (question, env) => {
|
|
341
|
+
return new Promise(resolve => {
|
|
342
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
343
|
+
const {
|
|
344
|
+
partA,
|
|
345
|
+
partB
|
|
346
|
+
} = question;
|
|
347
|
+
const partACorrect = returnPartCorrect(partA.choices);
|
|
348
|
+
const partBCorrect = returnPartCorrect(partB.choices);
|
|
349
|
+
resolve({
|
|
350
|
+
value: {
|
|
351
|
+
partA: {
|
|
352
|
+
id: 'partA',
|
|
353
|
+
value: partACorrect
|
|
354
|
+
},
|
|
355
|
+
partB: {
|
|
356
|
+
id: 'partB',
|
|
357
|
+
value: partBCorrect
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
id: '1'
|
|
361
|
+
});
|
|
362
|
+
} else {
|
|
363
|
+
resolve(null);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// remove all html tags
|
|
369
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
370
|
+
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
371
|
+
|
|
372
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
373
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
374
|
+
const validatePart = (model = {}, config = {}) => {
|
|
375
|
+
const {
|
|
376
|
+
choices
|
|
377
|
+
} = model;
|
|
378
|
+
const {
|
|
379
|
+
minAnswerChoices = 2,
|
|
380
|
+
maxAnswerChoices
|
|
381
|
+
} = config;
|
|
382
|
+
const reversedChoices = [...(choices || [])].reverse();
|
|
383
|
+
const errors = {};
|
|
384
|
+
const choicesErrors = {};
|
|
385
|
+
const rationaleErrors = {};
|
|
386
|
+
let hasCorrectResponse = false;
|
|
387
|
+
['teacherInstructions', 'prompt'].forEach(field => {
|
|
388
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
389
|
+
errors[field] = 'This field is required.';
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
reversedChoices.forEach((choice, index) => {
|
|
393
|
+
const {
|
|
394
|
+
correct,
|
|
395
|
+
value,
|
|
396
|
+
label,
|
|
397
|
+
rationale
|
|
398
|
+
} = choice;
|
|
399
|
+
if (correct) {
|
|
400
|
+
hasCorrectResponse = true;
|
|
401
|
+
}
|
|
402
|
+
if (!getContent(label)) {
|
|
403
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
404
|
+
} else {
|
|
405
|
+
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
|
|
406
|
+
if (identicalAnswer) {
|
|
407
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (config.rationale?.required && !getContent(rationale)) {
|
|
411
|
+
rationaleErrors[value] = 'This field is required.';
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
const nbOfChoices = (choices || []).length;
|
|
415
|
+
if (nbOfChoices < minAnswerChoices) {
|
|
416
|
+
errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
|
|
417
|
+
} else if (nbOfChoices > maxAnswerChoices) {
|
|
418
|
+
errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
419
|
+
}
|
|
420
|
+
if (!hasCorrectResponse) {
|
|
421
|
+
errors.correctResponse = 'No correct response defined.';
|
|
422
|
+
}
|
|
423
|
+
if (!(0, _lodashEs.isEmpty)(choicesErrors)) {
|
|
424
|
+
errors.choices = choicesErrors;
|
|
425
|
+
}
|
|
426
|
+
if (!(0, _lodashEs.isEmpty)(rationaleErrors)) {
|
|
427
|
+
errors.rationale = rationaleErrors;
|
|
428
|
+
}
|
|
429
|
+
return errors;
|
|
430
|
+
};
|
|
431
|
+
const validate = (model = {}, config = {}) => {
|
|
432
|
+
const {
|
|
433
|
+
partA,
|
|
434
|
+
partB
|
|
435
|
+
} = model || {};
|
|
436
|
+
const {
|
|
437
|
+
partA: partAConfig,
|
|
438
|
+
partB: partBConfig
|
|
439
|
+
} = config || {};
|
|
440
|
+
const partAErrors = validatePart(partA, partAConfig);
|
|
441
|
+
const partBErrors = validatePart(partB, partBConfig);
|
|
442
|
+
return {
|
|
443
|
+
partA: partAErrors,
|
|
444
|
+
partB: partBErrors
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
exports.validate = validate;
|
|
448
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","getLogTrace","traceLog","push","partialScoring","enabled","partAquestionType","choiceMode","partASelections","partACorrectChoices","partACorrectValues","partACorrectSelected","includes","partAIncorrectSelected","scoreA","partBquestionType","partBSelections","partBCorrectChoices","partBCorrectValues","correctSelected","incorrectSelected","scoreB","finalScore","outcome","score","empty","logTrace","max","returnPartCorrect","answers","forEach","i","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\n/**\n * Generates detailed trace log for math-templated scoring evaluation\n * @param {Object} question\n * @param {Object} session\n * @param {Object} env\n * @returns {Array<string>} traceLog\n */\nexport const getLogTrace = (question, session, env) => {\n const traceLog = [];\n\n if (!session || !session.value) {\n traceLog.push('Student did not answer the question.');\n return traceLog;\n }\n\n const { value } = session;\n const { partA, partB } = value;\n\n const partialScoringEnabled = partialScoring.enabled(question, env);\n\n traceLog.push(\n `Scoring method: ${partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'}.`\n );\n\n const partAquestionType =\n question.partA.choiceMode === 'radio'\n ? 'multiple-choice (radio)'\n : 'multiple-select (checkbox)';\n traceLog.push(`Part A question type: ${partAquestionType}.`);\n\n const partASelections = partA?.value || [];\n const partACorrectChoices = (question.partA.choices || []).filter((c) => c.correct);\n const partACorrectValues = partACorrectChoices.map((c) => c.value);\n const partACorrectSelected = partASelections.filter((v) => partACorrectValues.includes(v));\n const partAIncorrectSelected = partASelections.filter((v) => !partACorrectValues.includes(v));\n\n if (partASelections.length) {\n traceLog.push(\n `Part A: student selected ${partASelections.length} choice(s) (${partACorrectSelected.length} correct, ${partAIncorrectSelected.length} incorrect).`\n );\n }\n \n const scoreA = getScore(question, partA, 'partA', partialScoringEnabled);\n traceLog.push(`Part A score: ${scoreA}.`);\n\n const partBquestionType =\n question.partB.choiceMode === 'radio'\n ? 'multiple-choice (radio)'\n : 'multiple-select (checkbox)';\n traceLog.push(`Part B question type: ${partBquestionType}.`);\n\n const partBSelections = partB?.value || [];\n const partBCorrectChoices = (question.partB.choices || []).filter((c) => c.correct);\n const partBCorrectValues = partBCorrectChoices.map((c) => c.value);\n const correctSelected = partBSelections.filter((v) => partBCorrectValues.includes(v));\n const incorrectSelected = partBSelections.filter((v) => !partBCorrectValues.includes(v));\n\n if (partBSelections.length) {\n traceLog.push(\n `Part B: student selected ${partBSelections.length} choice(s) (${correctSelected.length} correct, ${incorrectSelected.length} incorrect).`\n );\n }\n\n const scoreB = getScore(question, partB, 'partB', partialScoringEnabled);\n traceLog.push(`Part B score: ${scoreB}.`);\n\n if (!partialScoringEnabled) {\n traceLog.push(\n 'Final score is awarded only if both Part A and Part B are completely correct.'\n );\n traceLog.push(`Final score: ${scoreA === 1 && scoreB === 1 ? 1 : 0}.`);\n } else {\n traceLog.push(\n 'With partial scoring enabled, Part A must be correct to earn any credit.'\n );\n\n let finalScore = 0;\n if (scoreA === 1 && scoreB === 1) {\n finalScore = 2;\n } else if (scoreA === 1 && scoreB < 1) {\n finalScore = 1;\n }\n\n traceLog.push(`Final score: ${finalScore}.`);\n }\n\n return traceLog;\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, logTrace: ['Student did not answer the question.'] });\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 const logTrace = getLogTrace(config, session, env);\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, logTrace });\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, logTrace });\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, logTrace });\n }\n } else {\n // For all other combinations, no points are awarded\n resolve({ score: 0, scoreA, scoreB, max: 2, logTrace });\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,C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 -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isResponseCorrect = exports.getCorrectResponse = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
const getCorrectResponse = choices => choices && choices.filter(c => c.correct).map(c => c.value).sort();
|
|
9
|
+
exports.getCorrectResponse = getCorrectResponse;
|
|
10
|
+
const isResponseCorrect = (question, key, session) => {
|
|
11
|
+
let correctResponse = getCorrectResponse(question.choices);
|
|
12
|
+
if (session && session.value) {
|
|
13
|
+
return (0, _lodashEs.isEqual)((session.value[key].value || []).sort(), correctResponse);
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
exports.isResponseCorrect = isResponseCorrect;
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|