@pie-element/explicit-constructed-response 10.0.0-next.43 → 10.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/alternateResponses.js +7 -10
- package/configure/lib/alternateResponses.js.map +1 -1
- package/configure/lib/alternateSection.js +4 -6
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/defaults.js +3 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +6 -7
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +8 -11
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +2 -3
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/package.json +6 -6
- package/controller/lib/index.js +12 -15
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +4 -4
- package/lib/main.js +4 -6
- package/lib/main.js.map +1 -1
- package/lib/print.js +2 -2
- package/lib/print.js.map +1 -1
- package/module/configure.js +1 -1
- package/module/controller.js +2809 -4679
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +4 -4
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +12 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_cloneDeep","_isEmpty","_pick","_throttle","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_styles","_Typography","_Info","_Tooltip","_ecrToolbar","_alternateResponses","_markupUtils","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","toggle","Panel","dropdown","settings","PromptHolder","styled","InputContainer","theme","width","paddingTop","spacing","marginTop","marginBottom","MarkupContainer","EditableHtml","minHeight","StyledText","Typography","fontSize","typography","StyledTooltip","Tooltip","whiteSpace","maxWidth","ErrorText","color","palette","error","main","FlexContainer","display","alignItems","ResponseHeader","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","React","Component","constructor","args","_defineProperty2","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","decodeHTML","length","label","value","nbOfMissingChoices","Array","fill","splice","getAdjustedLength","markup","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","cloneDeep","dataset","callback","setState","cachedChoices","undefined","throttle","nodes","state","newCachedChoices","node","keyForNode","assign","pick","prototype","trailing","leading","componentDidMount","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","render","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","spanishButton","responseAreaInputConfiguration","errors","extraCSSRules","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreas","responseAreasError","teacherInstructionsError","validationMessage","generateValidationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onModelChange","onChangeConfiguration","groups","Settings","Properties","className","onChange","onTeacherInstructionsChanged","nonEmpty","pluginProps","inputConfiguration","languageCharactersProps","autoWidthToolbar","onPromptChanged","disableUnderline","component","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","activePlugins","ALL_PLUGINS","responseAreaProps","type","duplicates","respAreaToolbar","editor","onToolbarDone","correctChoice","attrs","onChangeResponse","onHandleAreaChange","disableImageAlignmentButtons","onBlur","disabled","highlightShape","isEmpty","onResponsesChanged","onLengthChange","onLengthChanged","onRationaleChanged","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"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/editable-html-tip-tap';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { decodeHTML, getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst PromptHolder = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(1),\n marginTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst MarkupContainer = styled(EditableHtml)(({ theme }) => ({\n minHeight: '100px',\n paddingTop: theme.spacing(1),\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n}));\n\nconst StyledText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst ResponseHeader = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n marginTop: theme.spacing(3),\n marginBottom: theme.spacing(1),\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 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) => decodeHTML(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 = decodeHTML(newVal || '').length;\n\n if (!choices[index] || !choices[index].length) {\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.index;\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (Object.prototype.hasOwnProperty.call(newCachedChoices, keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (Object.prototype.hasOwnProperty.call(newChoices, 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 { 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 spanishButton = {},\n responseAreaInputConfiguration = {},\n } = configuration || {};\n const {\n errors,\n extraCSSRules,\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 'responseAreaInputConfiguration.inputConfiguration.characters.disabled':\n spanishButton.settings && toggle(spanishButton.label, true),\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 return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\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 <PromptHolder label={teacherInstructions.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </PromptHolder>\n )}\n\n {promptEnabled && (\n <PromptHolder label={prompt.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {promptError && <ErrorText>{promptError}</ErrorText>}\n </PromptHolder>\n )}\n\n <FlexContainer>\n <StyledText component=\"div\">\n Define Template, Choices, and Correct Responses\n </StyledText>\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </StyledTooltip>\n </FlexContainer>\n\n <MarkupContainer\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, editor, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.attrs.index] || [])[0];\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.attrs.index, newVal)}\n node={node}\n editor={editor}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\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 autoWidthToolbar\n />\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n\n {!isEmpty(model.choices) && (\n <ResponseHeader>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </ResponseHeader>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n\n {rationaleEnabled && (\n <PromptHolder label={rationale.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {rationaleError && <ErrorText>{rationaleError}</ErrorText>}\n </PromptHolder>\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,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,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a,EAAGA,aAAa,IAAIA,aAAa,CAACzD,SAAS,IAAKwF,oBAAqB;MAClF9B,cAAc,EAAGA,cAAc,IAAIA,cAAc,CAAC1D,SAAS,IAAKyF,qBAAsB;MACtFnC,kBAAkB,EAAEA,kBAAmB;MACvC6D,uBAAuB,EAAE,CAAC;QAAE/C,QAAQ,EAAE;MAAU,CAAC,EAAE;QAAEA,QAAQ,EAAE;MAAU,CAAC,CAAE;MAC5ED,aAAa,EAAEA,aAAc;MAC7BiD,gBAAgB;IAAA,CACjB,CAAC,EACDlC,cAAc,iBAAI3K,MAAA,CAAA6B,OAAA,CAAA8C,aAAA,CAACb,SAAS,QAAE6G,cAA0B,CAC7C,CAEG,CAAC;EAE1B;AACF;AAACiE,OAAA,CAAA9J,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAAtD,OAAA,EApaYiD,IAAI,eACI;EACjB8D,aAAa,EAAEiG,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1CxJ,KAAK,EAAEsJ,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCC,gBAAgB,EAAEH,kBAAS,CAACI,IAAI;EAChC3J,cAAc,EAAEuJ,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzClG,sBAAsB,EAAEgG,kBAAS,CAACK,IAAI,CAACH,UAAU;EACjDjG,YAAY,EAAE+F,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFhG,kBAAkB,EAAE8F,kBAAS,CAACC;AAChC,CAAC;AAAA,IAAAQ,QAAA,GAAAV,OAAA,CAAA/M,OAAA,GA0ZYiD,IAAI","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_lodashEs","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_styles","_Typography","_Info","_Tooltip","_ecrToolbar","_alternateResponses","_markupUtils","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","toggle","Panel","dropdown","settings","PromptHolder","styled","InputContainer","theme","width","paddingTop","spacing","marginTop","marginBottom","MarkupContainer","EditableHtml","minHeight","StyledText","Typography","fontSize","typography","StyledTooltip","Tooltip","whiteSpace","maxWidth","ErrorText","color","palette","error","main","FlexContainer","display","alignItems","ResponseHeader","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","React","Component","constructor","args","_defineProperty2","newVal","props","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","decodeHTML","length","label","value","nbOfMissingChoices","Array","fill","splice","getAdjustedLength","markup","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","cloneDeep","dataset","callback","setState","cachedChoices","undefined","throttle","nodes","state","newCachedChoices","node","keyForNode","assign","pick","prototype","trailing","leading","componentDidMount","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","render","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","template","settingsPanelDisabled","spellCheck","editSource","withRubric","mathMlOptions","language","languageChoices","spanishButton","responseAreaInputConfiguration","errors","extraCSSRules","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","promptError","rationaleError","responseAreas","responseAreasError","teacherInstructionsError","validationMessage","generateValidationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","enabled","options","panelProperties","playerSpellCheckEnabled","rubricEnabled","getPluginProps","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onModelChange","onChangeConfiguration","groups","Settings","Properties","className","onChange","onTeacherInstructionsChanged","nonEmpty","pluginProps","inputConfiguration","languageCharactersProps","autoWidthToolbar","onPromptChanged","disableUnderline","component","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","activePlugins","ALL_PLUGINS","responseAreaProps","type","duplicates","respAreaToolbar","editor","onToolbarDone","correctChoice","attrs","onChangeResponse","onHandleAreaChange","disableImageAlignmentButtons","onBlur","disabled","highlightShape","isEmpty","onResponsesChanged","onLengthChange","onLengthChanged","onRationaleChanged","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { cloneDeep, isEmpty, pick, throttle } from 'lodash-es';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { decodeHTML, getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst PromptHolder = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(1),\n marginTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst MarkupContainer = styled(EditableHtml)(({ theme }) => ({\n minHeight: '100px',\n paddingTop: theme.spacing(1),\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n}));\n\nconst StyledText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst ResponseHeader = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n marginTop: theme.spacing(3),\n marginBottom: theme.spacing(1),\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 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) => decodeHTML(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 = decodeHTML(newVal || '').length;\n\n if (!choices[index] || !choices[index].length) {\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.index;\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (Object.prototype.hasOwnProperty.call(newCachedChoices, keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (Object.prototype.hasOwnProperty.call(newChoices, 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 { 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 spanishButton = {},\n responseAreaInputConfiguration = {},\n } = configuration || {};\n const {\n errors,\n extraCSSRules,\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 'responseAreaInputConfiguration.inputConfiguration.characters.disabled':\n spanishButton.settings && toggle(spanishButton.label, true),\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 return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\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 <PromptHolder label={teacherInstructions.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </PromptHolder>\n )}\n\n {promptEnabled && (\n <PromptHolder label={prompt.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {promptError && <ErrorText>{promptError}</ErrorText>}\n </PromptHolder>\n )}\n\n <FlexContainer>\n <StyledText component=\"div\">Define Template, Choices, and Correct Responses</StyledText>\n <StyledTooltip disableFocusListener disableTouchListener placement={'right'} title={validationMessage}>\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </StyledTooltip>\n </FlexContainer>\n\n <MarkupContainer\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, editor, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.attrs.index] || [])[0];\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.attrs.index, newVal)}\n node={node}\n editor={editor}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\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 autoWidthToolbar\n />\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n\n {!isEmpty(model.choices) && (\n <ResponseHeader>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </ResponseHeader>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n pluginProps={getPluginProps(responseAreaInputConfiguration?.inputConfiguration)}\n />\n\n {rationaleEnabled && (\n <PromptHolder label={rationale.label}>\n <EditableHtml\n className=\"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 autoWidthToolbar\n />\n {rationaleError && <ErrorText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
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.stripHtmlTags = exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.decodeHTML = exports.createSlateMarkup = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
9
8
|
// do not remove \t from \times, \triangle, \tan, \theta or \therefore
|
|
10
9
|
const tSymbols = 'imes|riangle|an|heta|herefore';
|
|
11
10
|
// do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
|
|
@@ -37,7 +36,7 @@ const createSlateMarkup = (markup, choices) => {
|
|
|
37
36
|
const newMarkup = removeUnwantedCharacters(markup);
|
|
38
37
|
return newMarkup.replace(REGEX, (match, g) => {
|
|
39
38
|
const label = choices[g][0].label || '';
|
|
40
|
-
return `<span data-type="explicit_constructed_response" data-index="${g}" data-value="${(0,
|
|
39
|
+
return `<span data-type="explicit_constructed_response" data-index="${g}" data-value="${(0, _lodashEs.escape)(label)}"></span>`;
|
|
41
40
|
});
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markupUtils.js","names":["
|
|
1
|
+
{"version":3,"file":"markupUtils.js","names":["_lodashEs","require","tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","exports","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label","escape","getAdjustedLength","length","stripHtmlTags","decodeHTML","html","doc","DOMParser","parseFromString","body","textContent"],"sources":["../src/markupUtils.js"],"sourcesContent":["import { escape } from 'lodash-es';\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\nexport const stripHtmlTags = (markup) => {\n if (typeof markup !== 'string') {\n return '';\n }\n return markup.replace(/<\\/?[^>]+(>|$)/g, \"\");\n};\n\nexport const decodeHTML = (html) => {\n const doc = new DOMParser().parseFromString(html, 'text/html');\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AAE;AACnC,CAAC;AAAChC,OAAA,CAAA0B,UAAA,GAAAA,UAAA","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-configure",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.0-next.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"modue": "src/index.js",
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"@mui/icons-material": "^7.3.4",
|
|
11
11
|
"@mui/material": "^7.3.4",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
13
|
-
"@pie-lib/config-ui": "12.1.1-next.
|
|
14
|
-
"@pie-lib/editable-html-tip-tap": "1.1.1-next.
|
|
13
|
+
"@pie-lib/config-ui": "12.1.1-next.3",
|
|
14
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.3",
|
|
15
15
|
"classnames": "^2.2.6",
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
|
-
"lodash": "^4.17.
|
|
17
|
+
"lodash-es": "^4.17.23",
|
|
18
18
|
"prop-types": "^15.6.2",
|
|
19
|
-
"react": "18.
|
|
20
|
-
"react-dom": "18.
|
|
19
|
+
"react": "18.3.1",
|
|
20
|
+
"react-dom": "18.3.1"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/controller/lib/index.js
CHANGED
|
@@ -10,10 +10,7 @@ exports.normalize = void 0;
|
|
|
10
10
|
exports.outcome = outcome;
|
|
11
11
|
exports.validate = exports.prepareVal = exports.prepareChoice = void 0;
|
|
12
12
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
var
|
|
14
|
-
var _reduce = _interopRequireDefault(require("lodash/reduce"));
|
|
15
|
-
var _find = _interopRequireDefault(require("lodash/find"));
|
|
16
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
17
14
|
var _he = require("he");
|
|
18
15
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
19
16
|
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
@@ -66,7 +63,7 @@ const getAdjustedLength = length => {
|
|
|
66
63
|
// we can't use the dom parser here because it is not available in the node environment
|
|
67
64
|
const decodeHtmlEntities = str => {
|
|
68
65
|
if (!str) return '';
|
|
69
|
-
return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'|'/g, '
|
|
66
|
+
return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'|'/g, "'").replace(/&/g, '&');
|
|
70
67
|
};
|
|
71
68
|
const normalize = question => ({
|
|
72
69
|
..._defaults.default,
|
|
@@ -103,16 +100,16 @@ async function model(question, session, env) {
|
|
|
103
100
|
incorrect: 'Incorrect'
|
|
104
101
|
}, normalizedQuestion.defaultFeedback);
|
|
105
102
|
const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback);
|
|
106
|
-
const choices = (0,
|
|
107
|
-
obj[key] = (0,
|
|
103
|
+
const choices = (0, _lodashEs.reduce)(normalizedQuestion.choices, (obj, area, key) => {
|
|
104
|
+
obj[key] = (0, _lodashEs.map)(area, prepareChoiceFn);
|
|
108
105
|
return obj;
|
|
109
106
|
}, {});
|
|
110
107
|
const {
|
|
111
108
|
value = {}
|
|
112
109
|
} = session || {};
|
|
113
|
-
const feedback = env.mode === 'evaluate' ? (0,
|
|
110
|
+
const feedback = env.mode === 'evaluate' ? (0, _lodashEs.reduce)(normalizedQuestion.choices, (obj, respArea, key) => {
|
|
114
111
|
const chosenValue = value && value[key];
|
|
115
|
-
const val = !(0,
|
|
112
|
+
const val = !(0, _lodashEs.isEmpty)(chosenValue) && (0, _lodashEs.find)(respArea, c => prepareVal(c.label) === prepareVal(chosenValue));
|
|
116
113
|
obj[key] = getFeedback(val);
|
|
117
114
|
return obj;
|
|
118
115
|
}, {}) : {};
|
|
@@ -171,14 +168,14 @@ const getScore = (config, session) => {
|
|
|
171
168
|
const {
|
|
172
169
|
value
|
|
173
170
|
} = session || {};
|
|
174
|
-
if (!session || (0,
|
|
171
|
+
if (!session || (0, _lodashEs.isEmpty)(session) || !value) {
|
|
175
172
|
return 0;
|
|
176
173
|
}
|
|
177
174
|
const responseAreas = config.markup && config.markup.match(/\{\{(.+?)\}\}/g);
|
|
178
175
|
const maxScore = responseAreas ? responseAreas.length : 0;
|
|
179
|
-
const correctCount = (0,
|
|
176
|
+
const correctCount = (0, _lodashEs.reduce)(config.choices, (total, respArea, key) => {
|
|
180
177
|
const chosenValue = value && value[key];
|
|
181
|
-
if ((0,
|
|
178
|
+
if ((0, _lodashEs.isEmpty)(chosenValue) || !(0, _lodashEs.find)(respArea, c => prepareVal(c.label) === prepareVal(chosenValue))) {
|
|
182
179
|
return total;
|
|
183
180
|
}
|
|
184
181
|
return total + 1;
|
|
@@ -205,7 +202,7 @@ function outcome(model, session, env = {}) {
|
|
|
205
202
|
const score = getScore(model, session);
|
|
206
203
|
resolve({
|
|
207
204
|
score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
|
|
208
|
-
empty: (0,
|
|
205
|
+
empty: (0, _lodashEs.isEmpty)(session)
|
|
209
206
|
});
|
|
210
207
|
});
|
|
211
208
|
}
|
|
@@ -279,7 +276,7 @@ const validate = (model = {}, config = {}) => {
|
|
|
279
276
|
}
|
|
280
277
|
}
|
|
281
278
|
});
|
|
282
|
-
if (!(0,
|
|
279
|
+
if (!(0, _lodashEs.isEmpty)(choicesErrors)) {
|
|
283
280
|
allChoicesErrors[key] = choicesErrors;
|
|
284
281
|
}
|
|
285
282
|
});
|
|
@@ -289,7 +286,7 @@ const validate = (model = {}, config = {}) => {
|
|
|
289
286
|
} else if (nbOfResponseAreas < 1) {
|
|
290
287
|
errors.responseAreas = 'There should be at least 1 response area defined.';
|
|
291
288
|
}
|
|
292
|
-
if (!(0,
|
|
289
|
+
if (!(0, _lodashEs.isEmpty)(allChoicesErrors)) {
|
|
293
290
|
errors.choices = allChoicesErrors;
|
|
294
291
|
}
|
|
295
292
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_map","_reduce","_find","_isEmpty","_he","_controllerUtils","_translator","_defaults","translator","Translator","log","debug","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","exports","getFeedback","getAdjustedLength","length","Math","abs","Infinity","decodeHtmlEntities","str","replace","normalize","question","defaults","model","session","env","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","prepareChoiceFn","reduce","obj","area","respArea","chosenValue","val","isEmpty","find","c","prepareVal","showNote","values","some","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","max","disabled","displayType","role","markup","playerSpellCheckEnabled","prompt","promptEnabled","rationale","responseCorrect","getScore","undefined","teacherInstructions","responseAreaInputConfiguration","extraCSSRules","rationaleEnabled","teacherInstructionsEnabled","html","decodeHTML","getInnerText","trim","config","responseAreas","match","maxScore","correctCount","total","toFixed","parseFloat","outcome","Promise","resolve","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","replaceAll","decode","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","nbOfResponseAreas"],"sources":["../src/index.js"],"sourcesContent":["import debug from 'debug';\nimport map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport { decode } from 'he';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport Translator from '@pie-lib/translator';\nimport defaults from './defaults';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (Math.abs(length) === Infinity) {\n return 2;\n }\n\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\n// we can't use the dom parser here because it is not available in the node environment\nconst decodeHtmlEntities = (str) => {\n if (!str) return '';\n return str\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'|'/g, '\\'')\n .replace(/&/g, '&');\n};\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n // this was added to treat an exception, when the model has choices without\n // the \"value\" property like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback);\n const choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, prepareChoiceFn);\n\n return obj;\n },\n {},\n );\n\n const { value = {} } = session || {};\n const feedback =\n env.mode === 'evaluate'\n ? reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val =\n !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n )\n : {};\n\n // check if at least one choice has an alternate\n const showNote = Object.values(choices).some((choice) => choice?.length > 1);\n const note =\n normalizedQuestion.note ||\n translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\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) => decodeHtmlEntities(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 const out = {\n choices,\n disabled: env.mode !== 'gather',\n displayType: normalizedQuestion.displayType,\n mode: env.mode,\n role: env.role,\n feedback,\n language: normalizedQuestion.language,\n markup: normalizedQuestion.markup,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt,\n rationale: defaults.rationale,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n showNote,\n teacherInstructions: defaults.teacherInstructions,\n responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : defaults.teacherInstructions;\n }\n\n return out;\n}\n\nexport const prepareVal = (html) => {\n return decodeHTML(getInnerText(html).trim());\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.+?)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({ id: '1', value });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\n// const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\nconst getInnerText = (html) => {\n if (typeof html !== 'string') {\n return '';\n }\n if (typeof html.replaceAll === 'function') {\n return html.replaceAll(/<[^>]*>/g, '');\n } else {\n // Polyfill for replaceAll using replace and a global regex\n return html.replace(/<[^>]*>/g, '');\n }\n};\n\nconst decodeHTML = (html) => decode(html);\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreas = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choices = allChoicesErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,GAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,I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,CAAC3B,MAAM,EAAE+B,KAAK,KAAK;MACzC,MAAM;QAAE5B,KAAK;QAAED;MAAM,CAAC,GAAGF,MAAM;MAE/B,IAAIE,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAK,aAAa,EAAE;QAC3C2G,aAAa,CAAC1G,KAAK,CAAC,GAAG,8BAA8B;MACvD,CAAC,MAAM;QACL,MAAM2G,eAAe,GAAGH,eAAe,CAACI,KAAK,CAAChF,KAAK,GAAG,CAAC,CAAC,CAACiB,IAAI,CAAEJ,CAAC,IAAKA,CAAC,CAAC1C,KAAK,KAAKA,KAAK,CAAC;QAEvF,IAAI4G,eAAe,EAAE;UACnBD,aAAa,CAAC1G,KAAK,CAAC,GAAG,2BAA2B;QACpD;MACF;IACF,CAAC,CAAC;IAEF,IAAI,CAAC,IAAAuC,gBAAO,EAACmE,aAAa,CAAC,EAAE;MAC3BP,gBAAgB,CAAC1E,GAAG,CAAC,GAAGiF,aAAa;IACvC;EACF,CAAC,CAAC;EAEF,MAAMG,iBAAiB,GAAG,CAACnD,MAAM,CAACmB,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAErE,MAAM;EAEvE,IAAIqG,iBAAiB,GAAGX,gBAAgB,EAAE;IACxCE,MAAM,CAACxB,aAAa,GAAG,gBAAgBsB,gBAAgB,oCAAoC;EAC7F,CAAC,MAAM,IAAIW,iBAAiB,GAAG,CAAC,EAAE;IAChCT,MAAM,CAACxB,aAAa,GAAG,mDAAmD;EAC5E;EAEA,IAAI,CAAC,IAAArC,gBAAO,EAAC4D,gBAAgB,CAAC,EAAE;IAC9BC,MAAM,CAAC/E,OAAO,GAAG8E,gBAAgB;EACnC;EAEA,OAAOC,MAAM;AACf,CAAC;AAAC/F,OAAA,CAAA4F,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_lodashEs","_he","_controllerUtils","_translator","_defaults","translator","Translator","log","debug","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","exports","getFeedback","getAdjustedLength","length","Math","abs","Infinity","decodeHtmlEntities","str","replace","normalize","question","defaults","model","session","env","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","prepareChoiceFn","reduce","obj","area","respArea","chosenValue","val","isEmpty","find","c","prepareVal","showNote","values","some","note","t","lng","language","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","max","disabled","displayType","role","markup","playerSpellCheckEnabled","prompt","promptEnabled","rationale","responseCorrect","getScore","undefined","teacherInstructions","responseAreaInputConfiguration","extraCSSRules","rationaleEnabled","teacherInstructionsEnabled","html","decodeHTML","getInnerText","trim","config","responseAreas","match","maxScore","correctCount","total","toFixed","parseFloat","outcome","Promise","resolve","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","replaceAll","decode","getContent","validate","maxResponseAreas","allChoicesErrors","errors","field","required","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","nbOfResponseAreas"],"sources":["../src/index.js"],"sourcesContent":["import debug from 'debug';\nimport { find, isEmpty, map, reduce } from 'lodash-es';\nimport { decode } from 'he';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport Translator from '@pie-lib/translator';\nimport defaults from './defaults';\n\nconst { translator } = Translator;\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (Math.abs(length) === Infinity) {\n return 2;\n }\n\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\n// we can't use the dom parser here because it is not available in the node environment\nconst decodeHtmlEntities = (str) => {\n if (!str) return '';\n return str\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'|'/g, \"'\")\n .replace(/&/g, '&');\n};\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n // this was added to treat an exception, when the model has choices without\n // the \"value\" property like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback);\n const choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, prepareChoiceFn);\n\n return obj;\n },\n {},\n );\n\n const { value = {} } = session || {};\n const feedback =\n env.mode === 'evaluate'\n ? reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n )\n : {};\n\n // check if at least one choice has an alternate\n const showNote = Object.values(choices).some((choice) => choice?.length > 1);\n const note =\n normalizedQuestion.note ||\n translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\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) => decodeHtmlEntities(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 const out = {\n choices,\n disabled: env.mode !== 'gather',\n displayType: normalizedQuestion.displayType,\n mode: env.mode,\n role: env.role,\n feedback,\n language: normalizedQuestion.language,\n markup: normalizedQuestion.markup,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n note,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt,\n rationale: defaults.rationale,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n showNote,\n teacherInstructions: defaults.teacherInstructions,\n responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : defaults.teacherInstructions;\n }\n\n return out;\n}\n\nexport const prepareVal = (html) => {\n return decodeHTML(getInnerText(html).trim());\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.+?)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({ id: '1', value });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\n// const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\nconst getInnerText = (html) => {\n if (typeof html !== 'string') {\n return '';\n }\n if (typeof html.replaceAll === 'function') {\n return html.replaceAll(/<[^>]*>/g, '');\n } else {\n // Polyfill for replaceAll using replace and a global regex\n return html.replace(/<[^>]*>/g, '');\n }\n};\n\nconst decodeHTML = (html) => decode(html);\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreas = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreas = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choices = allChoicesErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAM;EAAEM;AAAW,CAAC,GAAGC,mBAAU;AAEjC,MAAMC,GAAG,GAAG,IAAAC,cAAK,EAAC,0CAA0C,CAAC;AAEtD,MAAMC,aAAa,GAAGA,CAACC,IAAI,EAAEC,eAAe,KAAMC,MAAM,IAAK;EAClE,MAAMC,GAAG,GAAG;IACVC,KAAK,EAAEF,MAAM,CAACE,KAAK;IACnBC,KAAK,EAAEH,MAAM,CAACG;EAChB,CAAC;EAED,IAAIL,IAAI,KAAK,UAAU,EAAE;IACvBG,GAAG,C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,CAAC1G,KAAK,CAAC,GAAG,2BAA2B;QACpD;MACF;IACF,CAAC,CAAC;IAEF,IAAI,CAAC,IAAAuC,iBAAO,EAACmE,aAAa,CAAC,EAAE;MAC3BP,gBAAgB,CAAC1E,GAAG,CAAC,GAAGiF,aAAa;IACvC;EACF,CAAC,CAAC;EAEF,MAAMG,iBAAiB,GAAG,CAACnD,MAAM,CAACmB,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAErE,MAAM;EAEvE,IAAIqG,iBAAiB,GAAGX,gBAAgB,EAAE;IACxCE,MAAM,CAACxB,aAAa,GAAG,gBAAgBsB,gBAAgB,oCAAoC;EAC7F,CAAC,MAAM,IAAIW,iBAAiB,GAAG,CAAC,EAAE;IAChCT,MAAM,CAACxB,aAAa,GAAG,mDAAmD;EAC5E;EAEA,IAAI,CAAC,IAAArC,iBAAO,EAAC4D,gBAAgB,CAAC,EAAE;IAC9BC,MAAM,CAAC/E,OAAO,GAAG8E,gBAAgB;EACnC;EAEA,OAAOC,MAAM;AACf,CAAC;AAAC/F,OAAA,CAAA4F,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/controller/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.1.0-next.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@pie-lib/controller-utils": "1.1.1-next.
|
|
12
|
-
"@pie-lib/translator": "3.1.1-next.
|
|
11
|
+
"@pie-lib/controller-utils": "1.1.1-next.1",
|
|
12
|
+
"@pie-lib/translator": "3.1.1-next.1",
|
|
13
13
|
"debug": "^4.1.1",
|
|
14
14
|
"he": "^1.2.0",
|
|
15
|
-
"lodash": "^4.17.
|
|
15
|
+
"lodash-es": "^4.17.23",
|
|
16
16
|
"type-of": "^2.0.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/lib/main.js
CHANGED
|
@@ -9,9 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var
|
|
13
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
14
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
|
+
var _lodashEs = require("lodash-es");
|
|
15
13
|
var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
|
|
16
14
|
var _maskMarkup = require("@pie-lib/mask-markup");
|
|
17
15
|
var _renderUi = require("@pie-lib/render-ui");
|
|
@@ -56,7 +54,7 @@ class Main extends _react.default.Component {
|
|
|
56
54
|
showCorrectAnswer: this.props.alwaysShowCorrect || false
|
|
57
55
|
});
|
|
58
56
|
// if for all responses max length is 1, call onChange for each keystroke
|
|
59
|
-
(0, _defineProperty2.default)(this, "getChangeSession", maxLengthPerChoice => maxLengthPerChoice && maxLengthPerChoice.every((val, _i, arr) => val === arr[0] && val === 1) ? this.props.onChange : (0,
|
|
57
|
+
(0, _defineProperty2.default)(this, "getChangeSession", maxLengthPerChoice => maxLengthPerChoice && maxLengthPerChoice.every((val, _i, arr) => val === arr[0] && val === 1) ? this.props.onChange : (0, _lodashEs.debounce)(this.props.onChange, 200, {
|
|
60
58
|
maxWait: 200
|
|
61
59
|
}));
|
|
62
60
|
(0, _defineProperty2.default)(this, "toggleShowCorrect", () => {
|
|
@@ -77,7 +75,7 @@ class Main extends _react.default.Component {
|
|
|
77
75
|
let {
|
|
78
76
|
note
|
|
79
77
|
} = this.props;
|
|
80
|
-
if ((0,
|
|
78
|
+
if ((0, _lodashEs.isEmpty)(nextProps.feedback)) {
|
|
81
79
|
this.setState({
|
|
82
80
|
showCorrectAnswer: false
|
|
83
81
|
});
|
|
@@ -87,7 +85,7 @@ class Main extends _react.default.Component {
|
|
|
87
85
|
showCorrectAnswer: true
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
|
-
if (maxLengthPerChoice && !(0,
|
|
88
|
+
if (maxLengthPerChoice && !(0, _lodashEs.isEqual)(maxLengthPerChoice, nextProps.maxLengthPerChoice)) {
|
|
91
89
|
this.changeSession = this.getChangeSession(nextProps.maxLengthPerChoice);
|
|
92
90
|
}
|
|
93
91
|
|