@pie-element/explicit-constructed-response 6.10.2-next.1 → 6.10.2-next.10
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/configure/lib/alternateResponses.js +243 -0
- package/configure/lib/alternateResponses.js.map +1 -0
- package/configure/lib/alternateSection.js +403 -0
- package/configure/lib/alternateSection.js.map +1 -0
- package/configure/lib/defaults.js +188 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/ecr-toolbar.js +184 -0
- package/configure/lib/ecr-toolbar.js.map +1 -0
- package/configure/lib/index.js +228 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +611 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/markupUtils.js +77 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +1 -1
- package/controller/lib/defaults.js +20 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +387 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +124 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +279 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +115 -0
- package/lib/print.js.map +1 -0
- package/module/configure.js +17141 -0
- package/module/controller.js +24955 -0
- package/module/demo.js +45 -0
- package/module/element.js +129047 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +83 -0
- package/module/print.html +18 -0
- package/module/print.js +128990 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","dropdown","styles","theme","promptHolder","width","paddingTop","spacing","unit","marginBottom","markup","minHeight","choiceConfiguration","paddingBottom","switchElement","justifyContent","margin","addButton","text","fontSize","typography","tooltip","whiteSpace","maxWidth","errorText","color","palette","error","main","flexContainer","display","alignItems","responseHeader","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","errors","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreasError","responseAreas","teacherInstructionsError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","onModelChange","Settings","Properties","onTeacherInstructionsChanged","inputConfiguration","onPromptChanged","marginLeft","ALL_PLUGINS","type","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,MAAR,GAAoCC,kBAApC,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAAoCD,kBAApC,CAAgBC,KAAhB;AAAA,IAAuBC,QAAvB,GAAoCF,kBAApC,CAA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gB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB,CAPG;AAWjBjE,EAAAA,kBAAkB,EAAE+D,sBAAUC;AAXb,C;AA4ZrB,IAAMO,MAAM,GAAG,wBAAWtK,MAAX,EAAmBuC,IAAnB,CAAf;eAEe+H,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport { EditableHtml, ALL_PLUGINS } from '@pie-lib/pie-toolbox/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/pie-toolbox/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\nimport classnames from 'classnames';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n text: {\n fontSize: theme.typography.fontSize + 2,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end',\n },\n responseHeader: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit,\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n template = {},\n settingsPanelDisabled,\n spellCheck = {},\n editSource = {},\n teacherInstructions = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n } = configuration || {};\n const {\n errors,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const {\n choices: choicesErrors = {},\n prompt: promptError,\n rationale: rationaleError,\n responseAreas: responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n 'editSource.enabled': editSource?.settings && toggle(editSource.label, true),\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n return (\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {teacherInstructionsError && <div className={classes.errorText}>{teacherInstructionsError}</div>}\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {promptError && <div className={classes.errorText}>{promptError}</div>}\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>Define Template, Choices, and Correct Responses</Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(template?.inputConfiguration)}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.get('index')] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.get('index'), newVal)}\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classnames(classes.text, classes.responseHeader)}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {rationaleError && <div className={classes.errorText}>{rationaleError}</div>}\n </InputContainer>\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.createSlateMarkup = void 0;
|
|
9
|
+
|
|
10
|
+
var _escape = _interopRequireDefault(require("lodash/escape"));
|
|
11
|
+
|
|
12
|
+
// do not remove \t from \times, \triangle, \tan, \theta or \therefore
|
|
13
|
+
var tSymbols = 'imes|riangle|an|heta|herefore'; // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
|
|
14
|
+
|
|
15
|
+
var nSymbols = 'throot|parallel|cong|approx|eq|e|sim'; // match all \t and \n that are not part of math symbols that starts with \t or \n
|
|
16
|
+
|
|
17
|
+
var matchTabAndNewLine = new RegExp("(\\t(?!".concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
|
|
18
|
+
|
|
19
|
+
var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
|
|
20
|
+
return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.removeUnwantedCharacters = removeUnwantedCharacters;
|
|
24
|
+
|
|
25
|
+
var createElementFromHTML = function createElementFromHTML() {
|
|
26
|
+
var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
27
|
+
var div = document.createElement('div');
|
|
28
|
+
div.innerHTML = htmlString.trim();
|
|
29
|
+
return div;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var processMarkup = function processMarkup(markup) {
|
|
33
|
+
var newMarkup = removeUnwantedCharacters(markup || '');
|
|
34
|
+
var slateMarkup = createElementFromHTML(newMarkup || '');
|
|
35
|
+
var index = 0;
|
|
36
|
+
slateMarkup.querySelectorAll('[data-type="explicit_constructed_response"]').forEach(function (s) {
|
|
37
|
+
s.replaceWith("{{".concat(index++, "}}"));
|
|
38
|
+
});
|
|
39
|
+
return slateMarkup.innerHTML;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.processMarkup = processMarkup;
|
|
43
|
+
var REGEX = /\{\{(\d+)\}\}/g;
|
|
44
|
+
|
|
45
|
+
var createSlateMarkup = function createSlateMarkup(markup, choices) {
|
|
46
|
+
if (!markup) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var newMarkup = removeUnwantedCharacters(markup);
|
|
51
|
+
return newMarkup.replace(REGEX, function (match, g) {
|
|
52
|
+
var label = choices[g][0].label || '';
|
|
53
|
+
return "<span data-type=\"explicit_constructed_response\" data-index=\"".concat(g, "\" data-value=\"").concat((0, _escape["default"])(label), "\"></span>");
|
|
54
|
+
});
|
|
55
|
+
}; // also used in controller/src/index.js
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
exports.createSlateMarkup = createSlateMarkup;
|
|
59
|
+
|
|
60
|
+
var getAdjustedLength = function getAdjustedLength(length) {
|
|
61
|
+
if (length <= 2) {
|
|
62
|
+
return length + 2;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (length <= 4) {
|
|
66
|
+
return length + 3;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (length <= 6) {
|
|
70
|
+
return length + 4;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return length + 5;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.getAdjustedLength = getAdjustedLength;
|
|
77
|
+
//# sourceMappingURL=markupUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/markupUtils.js"],"names":["tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label","getAdjustedLength","length"],"mappings":";;;;;;;;;AAAA;;AAEA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AI,CAACnB,MAAL,EAAa;AACX,WAAO,EAAP;AACD;;AAED,MAAMU,SAAS,GAAGX,wBAAwB,CAACC,MAAD,CAA1C;AAEA,SAAOU,SAAS,CAACT,OAAV,CAAkBgB,KAAlB,EAAyB,UAACG,KAAD,EAAQC,CAAR,EAAc;AAC5C,QAAMC,KAAK,GAAGH,OAAO,CAACE,CAAD,CAAP,CAAW,CAAX,EAAcC,KAAd,IAAuB,EAArC;AAEA,oFAAsED,CAAtE,6BAAwF,wBAAOC,KAAP,CAAxF;AACD,GAJM,CAAP;AAKD,CAZM,C,CAcP;;;;;AACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,MAAD,EAAY;AAC3C,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,MAAIA,MAAM,IAAI,CAAd,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,SAAOA,MAAM,GAAG,CAAhB;AACD,CAdM","sourcesContent":["import escape from 'lodash/escape';\n\n// do not remove \\t from \\times, \\triangle, \\tan, \\theta or \\therefore\nconst tSymbols = 'imes|riangle|an|heta|herefore';\n// do not remove \\n from \\nthroot, \\nparallel, \\ncong, \\napprox, \\neq, \\ne or \\nsim\nconst nSymbols = 'throot|parallel|cong|approx|eq|e|sim';\n// match all \\t and \\n that are not part of math symbols that starts with \\t or \\n\nconst matchTabAndNewLine = new RegExp(\n `(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))|(\\\\\\\\t(?!${tSymbols}))|(\\\\\\\\n(?!${nSymbols}))`,\n 'g',\n);\n\nexport const removeUnwantedCharacters = (markup) =>\n markup.replace(matchTabAndNewLine, '').replace(/\\\\\"/g, '\"').replace(/\\\\\\//g, '/');\n\nconst createElementFromHTML = (htmlString = '') => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport const processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup || '');\n const slateMarkup = createElementFromHTML(newMarkup || '');\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]').forEach((s) => {\n s.replaceWith(`{{${index++}}}`);\n });\n\n return slateMarkup.innerHTML;\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices) => {\n if (!markup) {\n return '';\n }\n\n const newMarkup = removeUnwantedCharacters(markup);\n\n return newMarkup.replace(REGEX, (match, g) => {\n const label = choices[g][0].label || '';\n\n return `<span data-type=\"explicit_constructed_response\" data-index=\"${g}\" data-value=\"${escape(label)}\"></span>`;\n });\n};\n\n// also used in controller/src/index.js\nexport const getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n"],"file":"markupUtils.js"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateValidationMessage = void 0;
|
|
7
|
+
|
|
8
|
+
var generateValidationMessage = function generateValidationMessage(config) {
|
|
9
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
10
|
+
var responseAreasMessage = '\nCorrect answers should not be blank.' + '\nEach answer defined for a response area should be unique.' + '\nThere should be at least 1 ' + (maxResponseAreas ? "and at most ".concat(maxResponseAreas, " ") : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';
|
|
11
|
+
return 'Validation requirements:' + responseAreasMessage;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","maxResponseAreas","responseAreasMessage"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,MAAD,EAAY;AACnD,MAAQC,gBAAR,GAA6BD,MAA7B,CAAQC,gBAAR;AAEA,MAAMC,oBAAoB,GACxB,2CACA,6DADA,GAEA,+BAFA,IAGCD,gBAAgB,yBAAkBA,gBAAlB,SAAwC,EAHzD,IAIA,eAJA,IAKCA,gBAAgB,GAAG,GAAH,GAAS,EAL1B,IAMA,WAPF;AASA,SAAO,6BAA6BC,oBAApC;AACD,CAbM","sourcesContent":["export const generateValidationMessage = (config) => {\n const { maxResponseAreas } = config;\n\n const responseAreasMessage =\n '\\nCorrect answers should not be blank.' +\n '\\nEach answer defined for a response area should be unique.' +\n '\\nThere should be at least 1 ' +\n (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') +\n 'response area' +\n (maxResponseAreas ? 's' : '') +\n ' defined.';\n\n return 'Validation requirements:' + responseAreasMessage;\n};\n"],"file":"utils.js"}
|
package/configure/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@material-ui/core": "^3.9.2",
|
|
9
9
|
"@material-ui/icons": "^3.0.1",
|
|
10
10
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
11
|
-
"@pie-lib/pie-toolbox": "1.13.
|
|
11
|
+
"@pie-lib/pie-toolbox": "1.13.1",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"debug": "^3.1.0",
|
|
14
14
|
"lodash": "^4.17.15",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
prompt: 'Which of these northern European countries are EU members?',
|
|
9
|
+
choiceMode: 'checkbox',
|
|
10
|
+
choicePrefix: 'numbers',
|
|
11
|
+
choices: [{
|
|
12
|
+
value: 'sweden',
|
|
13
|
+
label: 'Sweden'
|
|
14
|
+
}, {
|
|
15
|
+
value: 'iceland',
|
|
16
|
+
label: 'Iceland'
|
|
17
|
+
}]
|
|
18
|
+
};
|
|
19
|
+
exports["default"] = _default;
|
|
20
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","choiceMode","choicePrefix","choices","value","label"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,4DADK;AAEbC,EAAAA,UAAU,EAAE,UAFC;AAGbC,EAAAA,YAAY,EAAE,SAHD;AAIbC,EAAAA,OAAO,EAAE,CACP;AACEC,IAAAA,KAAK,EAAE,QADT;AAEEC,IAAAA,KAAK,EAAE;AAFT,GADO,EAKP;AACED,IAAAA,KAAK,EAAE,SADT;AAEEC,IAAAA,KAAK,EAAE;AAFT,GALO;AAJI,C","sourcesContent":["export default {\n prompt: 'Which of these northern European countries are EU members?',\n choiceMode: 'checkbox',\n choicePrefix: 'numbers',\n choices: [\n {\n value: 'sweden',\n label: 'Sweden',\n },\n {\n value: 'iceland',\n label: 'Iceland',\n },\n ],\n};\n"],"file":"defaults.js"}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getScore = exports.createCorrectResponseSession = void 0;
|
|
9
|
+
exports.model = model;
|
|
10
|
+
exports.normalize = void 0;
|
|
11
|
+
exports.outcome = outcome;
|
|
12
|
+
exports.validate = exports.prepareVal = exports.prepareChoice = void 0;
|
|
13
|
+
|
|
14
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
+
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
+
|
|
20
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _map = _interopRequireDefault(require("lodash/map"));
|
|
25
|
+
|
|
26
|
+
var _reduce = _interopRequireDefault(require("lodash/reduce"));
|
|
27
|
+
|
|
28
|
+
var _find = _interopRequireDefault(require("lodash/find"));
|
|
29
|
+
|
|
30
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
31
|
+
|
|
32
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
+
|
|
34
|
+
var _controllerUtils = require("@pie-lib/pie-toolbox/controller-utils");
|
|
35
|
+
|
|
36
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
37
|
+
|
|
38
|
+
var _translator = _interopRequireDefault(require("@pie-lib/pie-toolbox/translator"));
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
var translator = _translator["default"].translator;
|
|
45
|
+
var log = (0, _debug["default"])('explicit-constructed-response:controller');
|
|
46
|
+
|
|
47
|
+
var prepareChoice = function prepareChoice(mode, defaultFeedback) {
|
|
48
|
+
return function (choice) {
|
|
49
|
+
var out = {
|
|
50
|
+
label: choice.label,
|
|
51
|
+
value: choice.value
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (mode === 'evaluate') {
|
|
55
|
+
out.correct = true;
|
|
56
|
+
var feedbackType = choice.feedback && choice.feedback.type || 'none';
|
|
57
|
+
|
|
58
|
+
if (feedbackType === 'default') {
|
|
59
|
+
out.feedback = defaultFeedback['correct'];
|
|
60
|
+
} else if (feedbackType === 'custom') {
|
|
61
|
+
out.feedback = choice.feedback.value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return out;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.prepareChoice = prepareChoice;
|
|
70
|
+
|
|
71
|
+
var getFeedback = function getFeedback(value) {
|
|
72
|
+
if (value) {
|
|
73
|
+
return 'correct';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return 'incorrect';
|
|
77
|
+
}; // also used in configure/src/markupUtils.js
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
var getAdjustedLength = function getAdjustedLength(length) {
|
|
81
|
+
if (length <= 2) {
|
|
82
|
+
return length + 2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (length <= 4) {
|
|
86
|
+
return length + 3;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (length <= 6) {
|
|
90
|
+
return length + 4;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return length + 5;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var normalize = function normalize(question) {
|
|
97
|
+
return _objectSpread(_objectSpread({}, _defaults["default"]), {}, {
|
|
98
|
+
rationaleEnabled: true,
|
|
99
|
+
promptEnabled: true,
|
|
100
|
+
teacherInstructionsEnabled: true,
|
|
101
|
+
studentInstructionsEnabled: true
|
|
102
|
+
}, question);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param {*} question
|
|
107
|
+
* @param {*} session
|
|
108
|
+
* @param {*} env
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
exports.normalize = normalize;
|
|
113
|
+
|
|
114
|
+
function model(question, session, env) {
|
|
115
|
+
return new Promise( /*#__PURE__*/function () {
|
|
116
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve) {
|
|
117
|
+
var normalizedQuestion, defaultFeedback, _ref2, _ref2$value, value, preparChoiceFn, choices, feedback, showNote, note, _normalizedQuestion$m, maxLengthPerChoice, maxLengthPerChoiceEnabled, undefinedLengths, out;
|
|
118
|
+
|
|
119
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
120
|
+
while (1) {
|
|
121
|
+
switch (_context.prev = _context.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
// this was added to treat an exception, when the model has choices without the "value" property
|
|
124
|
+
// like: { label: 'test' }
|
|
125
|
+
if (question.choices) {
|
|
126
|
+
Object.keys(question.choices).forEach(function (key) {
|
|
127
|
+
question.choices[key] = (question.choices[key] || []).map(function (item, index) {
|
|
128
|
+
if (!item.value) {
|
|
129
|
+
log('Choice does not contain "value" property, which is required.', item);
|
|
130
|
+
return _objectSpread({
|
|
131
|
+
value: "".concat(index)
|
|
132
|
+
}, item);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return item;
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
normalizedQuestion = normalize(question);
|
|
141
|
+
defaultFeedback = Object.assign({
|
|
142
|
+
correct: 'Correct',
|
|
143
|
+
incorrect: 'Incorrect'
|
|
144
|
+
}, normalizedQuestion.defaultFeedback);
|
|
145
|
+
_ref2 = session || {}, _ref2$value = _ref2.value, value = _ref2$value === void 0 ? {} : _ref2$value;
|
|
146
|
+
preparChoiceFn = prepareChoice(env.mode, defaultFeedback);
|
|
147
|
+
choices = (0, _reduce["default"])(normalizedQuestion.choices, function (obj, area, key) {
|
|
148
|
+
obj[key] = (0, _map["default"])(area, preparChoiceFn);
|
|
149
|
+
return obj;
|
|
150
|
+
}, {});
|
|
151
|
+
feedback = {};
|
|
152
|
+
|
|
153
|
+
if (env.mode === 'evaluate') {
|
|
154
|
+
feedback = (0, _reduce["default"])(normalizedQuestion.choices, function (obj, respArea, key) {
|
|
155
|
+
var chosenValue = value && value[key];
|
|
156
|
+
var val = !(0, _isEmpty["default"])(chosenValue) && (0, _find["default"])(respArea, function (c) {
|
|
157
|
+
return prepareVal(c.label) === prepareVal(chosenValue);
|
|
158
|
+
});
|
|
159
|
+
obj[key] = getFeedback(val);
|
|
160
|
+
return obj;
|
|
161
|
+
}, {});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
showNote = false; // check if a choice has an alternate
|
|
165
|
+
|
|
166
|
+
Object.values(choices).forEach(function (choice) {
|
|
167
|
+
if (choice && choice.length > 1) {
|
|
168
|
+
showNote = true;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
note = normalizedQuestion.note;
|
|
172
|
+
|
|
173
|
+
if (!note) {
|
|
174
|
+
note = translator.t('common:commonCorrectAnswerWithAlternates', {
|
|
175
|
+
lng: normalizedQuestion.language
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
_normalizedQuestion$m = normalizedQuestion.maxLengthPerChoice, maxLengthPerChoice = _normalizedQuestion$m === void 0 ? [] : _normalizedQuestion$m, maxLengthPerChoiceEnabled = normalizedQuestion.maxLengthPerChoiceEnabled;
|
|
180
|
+
undefinedLengths = !maxLengthPerChoice.length; // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
|
|
181
|
+
|
|
182
|
+
Object.values(choices).forEach(function (choice, index) {
|
|
183
|
+
var labelLengthsArr = (choice || []).map(function (choice) {
|
|
184
|
+
return (choice.label || '').length;
|
|
185
|
+
});
|
|
186
|
+
var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
187
|
+
|
|
188
|
+
if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
|
|
189
|
+
maxLengthPerChoice[index] = getAdjustedLength(length);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
out = {
|
|
193
|
+
disabled: env.mode !== 'gather',
|
|
194
|
+
mode: env.mode,
|
|
195
|
+
prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
|
|
196
|
+
markup: normalizedQuestion.markup,
|
|
197
|
+
choices: choices,
|
|
198
|
+
feedback: feedback,
|
|
199
|
+
env: env,
|
|
200
|
+
note: note,
|
|
201
|
+
showNote: showNote,
|
|
202
|
+
maxLengthPerChoice: maxLengthPerChoice,
|
|
203
|
+
maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
|
|
204
|
+
displayType: normalizedQuestion.displayType,
|
|
205
|
+
playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,
|
|
206
|
+
responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
|
|
207
|
+
language: normalizedQuestion.language
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
211
|
+
out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
|
|
212
|
+
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
213
|
+
} else {
|
|
214
|
+
out.rationale = null;
|
|
215
|
+
out.teacherInstructions = null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
resolve(out);
|
|
219
|
+
|
|
220
|
+
case 18:
|
|
221
|
+
case "end":
|
|
222
|
+
return _context.stop();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}, _callee);
|
|
226
|
+
}));
|
|
227
|
+
|
|
228
|
+
return function (_x) {
|
|
229
|
+
return _ref.apply(this, arguments);
|
|
230
|
+
};
|
|
231
|
+
}());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var getTextFromHTML = function getTextFromHTML(html) {
|
|
235
|
+
return (html || '').replace(/<\/?[^>]+(>|$)/g, '');
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
var prepareVal = function prepareVal(html) {
|
|
239
|
+
var value = getTextFromHTML(html);
|
|
240
|
+
return value.trim();
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
exports.prepareVal = prepareVal;
|
|
244
|
+
|
|
245
|
+
var getScore = function getScore(config, session) {
|
|
246
|
+
var _ref3 = session || {},
|
|
247
|
+
value = _ref3.value;
|
|
248
|
+
|
|
249
|
+
if (!session || (0, _isEmpty["default"])(session) || !value) {
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var responseAreas = config.markup && config.markup.match(/\{\{(.)\}\}/g);
|
|
254
|
+
var maxScore = responseAreas ? responseAreas.length : 0;
|
|
255
|
+
var correctCount = (0, _reduce["default"])(config.choices, function (total, respArea, key) {
|
|
256
|
+
var chosenValue = value && value[key];
|
|
257
|
+
|
|
258
|
+
if ((0, _isEmpty["default"])(chosenValue) || !(0, _find["default"])(respArea, function (c) {
|
|
259
|
+
return prepareVal(c.label) === prepareVal(chosenValue);
|
|
260
|
+
})) {
|
|
261
|
+
return total;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return total + 1;
|
|
265
|
+
}, 0);
|
|
266
|
+
var str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;
|
|
267
|
+
return parseFloat(str);
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* The score is partial by default for checkbox mode, allOrNothing for radio mode.
|
|
272
|
+
* To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =
|
|
273
|
+
* false. the value in `env` will override the value in `model`.
|
|
274
|
+
* @param {Object} model - the main model
|
|
275
|
+
* @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)
|
|
276
|
+
* @param {*} session
|
|
277
|
+
* @param {Object} env
|
|
278
|
+
* @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides
|
|
279
|
+
* `model.partialScoring`.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
exports.getScore = getScore;
|
|
284
|
+
|
|
285
|
+
function outcome(model, session) {
|
|
286
|
+
var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
287
|
+
return new Promise(function (resolve) {
|
|
288
|
+
var partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
|
|
289
|
+
|
|
290
|
+
var score = getScore(model, session);
|
|
291
|
+
resolve({
|
|
292
|
+
score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
|
|
293
|
+
empty: (0, _isEmpty["default"])(session)
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
|
|
299
|
+
return new Promise(function (resolve) {
|
|
300
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
301
|
+
var choices = question.choices;
|
|
302
|
+
var value = {};
|
|
303
|
+
Object.keys(choices).forEach(function (key, i) {
|
|
304
|
+
value[i] = choices[key][0].label;
|
|
305
|
+
});
|
|
306
|
+
resolve({
|
|
307
|
+
id: '1',
|
|
308
|
+
value: value
|
|
309
|
+
});
|
|
310
|
+
} else {
|
|
311
|
+
resolve(null);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}; // remove all html tags
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
318
|
+
|
|
319
|
+
var getInnerText = function getInnerText(html) {
|
|
320
|
+
return (html || '').replaceAll(/<[^>]*>/g, '');
|
|
321
|
+
}; // remove all html tags except img and iframe
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
var getContent = function getContent(html) {
|
|
325
|
+
return (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var validate = function validate() {
|
|
329
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
330
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
331
|
+
var choices = model.choices,
|
|
332
|
+
markup = model.markup;
|
|
333
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
334
|
+
var allChoicesErrors = {};
|
|
335
|
+
var errors = {};
|
|
336
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach(function (field) {
|
|
337
|
+
var _config$field;
|
|
338
|
+
|
|
339
|
+
if ((_config$field = config[field]) !== null && _config$field !== void 0 && _config$field.required && !getContent(model[field])) {
|
|
340
|
+
errors[field] = 'This field is required.';
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
Object.entries(choices || {}).forEach(function (_ref4) {
|
|
344
|
+
var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
|
|
345
|
+
key = _ref5[0],
|
|
346
|
+
values = _ref5[1];
|
|
347
|
+
|
|
348
|
+
var reversedChoices = (0, _toConsumableArray2["default"])(values || []).reverse();
|
|
349
|
+
var choicesErrors = {};
|
|
350
|
+
reversedChoices.forEach(function (choice, index) {
|
|
351
|
+
var value = choice.value,
|
|
352
|
+
label = choice.label;
|
|
353
|
+
|
|
354
|
+
if (label === '' || label === '<div></div>') {
|
|
355
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
356
|
+
} else {
|
|
357
|
+
var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
|
|
358
|
+
return c.label === label;
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
if (identicalAnswer) {
|
|
362
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
if (!(0, _isEmpty["default"])(choicesErrors)) {
|
|
368
|
+
allChoicesErrors[key] = choicesErrors;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
var nbOfResponseAreas = (markup.match(/\{\{(\d+)\}\}/g) || []).length;
|
|
372
|
+
|
|
373
|
+
if (nbOfResponseAreas > maxResponseAreas) {
|
|
374
|
+
errors.responseAreas = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
|
|
375
|
+
} else if (nbOfResponseAreas < 1) {
|
|
376
|
+
errors.responseAreas = 'There should be at least 1 response area defined.';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (!(0, _isEmpty["default"])(allChoicesErrors)) {
|
|
380
|
+
errors.choices = allChoicesErrors;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return errors;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
exports.validate = validate;
|
|
387
|
+
//# sourceMappingURL=index.js.map
|