@pie-element/inline-dropdown 10.2.2-beta.6 → 10.2.2-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_reactDom","_propTypes","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_mathRendering","_renderUi","_lodashEs","_styles","_Tooltip","_Typography","_Accordion","_AccordionSummary","_AccordionDetails","_ExpandMore","_Info","_inlineDropdownToolbar","_utils","_responseArea","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","marginBottom","ChoiceRationaleHolder","StyledTypography","Typography","fontSize","typography","marginRight","RationaleLabel","display","alignItems","whiteSpace","color","disabled","padding","lineHeight","RationaleChoices","StyledAccordionDetails","AccordionDetails","paddingBottom","FlexContainer","StyledTooltip","Tooltip","maxWidth","ErrorText","palette","error","main","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","React","Component","constructor","args","_defineProperty2","warning","open","newVal","props","onModelChanged","model","prompt","onModelChange","rationale","index","choice","indexOfChoice","choices","findIndex","elem","label","value","splice","teacherInstructions","slateMarkup","confirmCallback","cancelCallback","setState","text","onClose","onConfirm","node","pos","editor","closeToolbar","onCancel","respAreaChoices","state","attrs","currentChoices","shouldWarn","length","find","c","correct","_holdInlineDropdownToolbarIndex","onCheck","deleteInlineDropdownByIndex","markup","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","existingRespAreaChoices","reduce","obj","key","isUndefined","newRespAreaChoices","cloneDeep","choiceIndex","maxResponseAreaChoices","configuration","showWarning","message","undefined","idx","max","map","parseInt","filter","val","isNaN","push","respIndex","selectedIndex","componentDidMount","UNSAFE_componentWillReceiveProps","nProps","newState","isEqual","isEmpty","componentDidUpdate","domNode","ReactDOM","findDOMNode","renderMath","render","onConfigurationChanged","imageSupport","uploadSoundSupport","baseInputConfiguration","choiceRationale","contentDimensions","lockChoiceOrder","maxResponseAreas","maxImageWidth","maxImageHeight","partialScoring","settingsPanelDisabled","spellCheck","template","withRubric","mathMlOptions","language","languageChoices","responseAreaInputConfiguration","choiceRationaleEnabled","errors","extraCSSRules","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","promptError","rationaleError","responseAreasError","responseAreaChoicesError","teacherInstructionsError","defaultImageMaxWidth","defaultImageMaxHeight","renderChoiceRationale","keys","slotProps","transition","timeout","enter","exit","expandIcon","component","Fragment","dangerouslySetInnerHTML","__html","pluginProps","getPluginProps","inputConfiguration","onChange","onChoiceRationaleChanged","toolbarOpts","position","validationMessage","generateValidationMessage","panelSettings","enabled","options","panelProperties","rubricEnabled","layout","ConfigLayout","names","rules","dimensions","hideSettings","onChangeModel","onChangeConfiguration","groups","Settings","Properties","onTeacherInstructionsChanged","nonEmpty","languageCharactersProps","onPromptChanged","disableUnderline","disableFocusListener","disableTouchListener","placement","title","editableHtmlProps","activePlugins","ALL_PLUGINS","responseAreaProps","type","duplicates","onToolbarCloseRequest","validateResponseAreaClose","respAreaToolbar","nodeInfo","_extends2","onAddChoice","onRemoveChoice","onSelectChoice","onToolbarDone","disableImageAlignmentButtons","highlightShape","onRationaleChanged","AlertDialog","disableAutoFocus","disableEnforceFocus","disableRestoreFocus","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS, deleteInlineDropdownByIndex } from '@pie-lib/editable-html-tip-tap';\nimport { AlertDialog, InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\nimport { cloneDeep, isEmpty, isEqual, isUndefined, max, reduce } from 'lodash-es';\nimport { styled } from '@mui/material/styles';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport Accordion from '@mui/material/Accordion';\nimport AccordionSummary from '@mui/material/AccordionSummary';\nimport AccordionDetails from '@mui/material/AccordionDetails';\nimport ExpandMoreIcon from '@mui/icons-material/ExpandMore';\nimport Info from '@mui/icons-material/Info';\n\nimport InlineDropdownToolbar from './inline-dropdown-toolbar';\nimport { generateValidationMessage } from './utils';\nimport ResponseAreaComponent from './response-area';\n\nconst { toggle, Panel, dropdown } = settings;\n\nconst PromptHolder = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst ChoiceRationaleHolder = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(0.5),\n marginBottom: theme.spacing(2),\n}));\n\nconst StyledTypography = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n marginRight: theme.spacing(1),\n}));\n\nconst RationaleLabel = styled('span')(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n whiteSpace: 'break-spaces',\n color: color.disabled(),\n padding: 0,\n fontSize: theme.typography.fontSize - 2,\n lineHeight: 1,\n}));\n\nconst RationaleChoices = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2.5),\n}));\n\nconst StyledAccordionDetails = styled(AccordionDetails)({\n display: 'block',\n paddingTop: 0,\n paddingBottom: 0,\n});\n\nconst FlexContainer = styled('div')(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing(1),\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 createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\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.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {\n warning: { open: false },\n };\n\n componentDidMount() {\n const {\n model: { choices },\n } = this.props;\n\n this.setState({ respAreaChoices: cloneDeep(choices) });\n }\n\n UNSAFE_componentWillReceiveProps(nProps) {\n const newState = {};\n\n if (\n !isEqual(nProps.model.choices, this.props.model.choices) ||\n !isEqual(nProps.model.choices, this.state.respAreaChoices)\n ) {\n newState.respAreaChoices = cloneDeep(nProps.model.choices);\n }\n\n if (!isEmpty(newState)) {\n this.setState(newState);\n }\n }\n\n componentDidUpdate() {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.onModelChange({ prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.onModelChange({ rationale });\n };\n\n onChoiceRationaleChanged = (index, choice) => {\n const { model } = this.props;\n const indexOfChoice =\n model.choices &&\n model.choices[index] &&\n model.choices[index].findIndex((elem) => elem.label === choice.label && elem.value === choice.value);\n\n model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);\n\n this.onModelChange(model);\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.onModelChange({ teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.onModelChange({ slateMarkup });\n };\n\n onCheck = (confirmCallback, cancelCallback) => {\n this.setState({\n warning: {\n open: true,\n text: 'Response areas with under 2 options or with no correct answers will be discarded.',\n onClose: () => {\n this.setState({ warning: { open: false } }, cancelCallback);\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, confirmCallback);\n },\n },\n });\n };\n\n validateResponseAreaClose = (node, pos, editor, closeToolbar, onCancel) => {\n const { respAreaChoices } = this.state;\n const index = node.attrs.index;\n const currentChoices = respAreaChoices[index] || [];\n const shouldWarn = currentChoices.length < 2 || !currentChoices.find((c) => c.correct);\n\n if (!shouldWarn) {\n closeToolbar();\n return;\n }\n\n editor._holdInlineDropdownToolbarIndex = index;\n\n this.onCheck(\n () => {\n delete editor._holdInlineDropdownToolbarIndex;\n deleteInlineDropdownByIndex(editor, index, pos);\n closeToolbar();\n },\n onCancel,\n );\n };\n\n onChange = (markup) => {\n const { respAreaChoices } = this.state;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"inline_dropdown\"]');\n const allChoices = {};\n\n allRespAreas.forEach((el) => {\n allChoices[el.dataset.index] = el.dataset.value || '';\n });\n\n const existingRespAreaChoices = reduce(\n respAreaChoices,\n (obj, choices, key) => {\n if (!isUndefined(allChoices[key])) {\n obj[key] = respAreaChoices[key];\n }\n\n return obj;\n },\n {},\n );\n\n const newRespAreaChoices = {};\n\n allRespAreas.forEach((el, index) => {\n const choices = existingRespAreaChoices[el.dataset.index];\n\n if (choices) {\n newRespAreaChoices[index] = choices;\n }\n\n el.dataset.index = index;\n });\n\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n });\n };\n\n onAddChoice = (index, label, choiceIndex) => {\n const { respAreaChoices } = this.state;\n const { maxResponseAreaChoices } = this.props.configuration;\n\n const showWarning = (message) =>\n this.setState({\n warning: {\n open: true,\n text: message,\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {\n showWarning(`There are only ${maxResponseAreaChoices} answers allowed per choice.`);\n return;\n }\n\n if (!respAreaChoices[index]) {\n respAreaChoices[index] = [];\n }\n\n // check for duplicate answer, but exclude the one that is currently edited\n if ((respAreaChoices[index] || []).find((r, idx) => r.label === label && idx !== choiceIndex)) {\n showWarning('Duplicate answers are not allowed.');\n return;\n }\n\n if (choiceIndex >= 0 && respAreaChoices[index]?.[choiceIndex]) {\n // we need to update the choice label with the new value\n respAreaChoices[index][choiceIndex].label = label;\n } else {\n // add a new choice\n const value =\n (respAreaChoices[index] &&\n max(respAreaChoices[index].map((c) => parseInt(c.value)).filter((val) => !isNaN(val)))) ||\n 0;\n\n respAreaChoices[index].push({\n label,\n value: `${value + 1}`,\n correct: false,\n });\n }\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onRemoveChoice = (respIndex, index) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex].splice(index, 1);\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n onSelectChoice = (respIndex, selectedIndex) => {\n const { respAreaChoices } = this.state;\n\n respAreaChoices[respIndex] = respAreaChoices[respIndex].map((choice, index) => ({\n ...choice,\n correct: index === selectedIndex,\n }));\n\n this.onModelChange({ choices: cloneDeep(respAreaChoices) });\n };\n\n render() {\n const { warning } = this.state;\n const { model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n baseInputConfiguration = {},\n choiceRationale = {},\n contentDimensions = {},\n lockChoiceOrder = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n partialScoring = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n template = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n responseAreaInputConfiguration = {},\n } = configuration || {};\n\n const {\n choiceRationaleEnabled,\n choices,\n errors,\n extraCSSRules,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const {\n prompt: promptError,\n rationale: rationaleError,\n responseAreasError,\n responseAreaChoicesError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const renderChoiceRationale = () =>\n (Object.keys(choices) || []).map((key, index) => (\n <RationaleChoices key={key}>\n <Accordion slotProps={{ transition: { timeout: { enter: 225, exit: 195 } } }}>\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <StyledTypography component={'div'}>{`Rationale for response area #${index + 1}`}</StyledTypography>\n </AccordionSummary>\n\n <StyledAccordionDetails>\n {(choices[key] || []).map((choice) => (\n <React.Fragment key={choice.label}>\n <RationaleLabel\n dangerouslySetInnerHTML={{\n __html: `${rationale.label} for ${choice.label} (${choice.correct ? 'correct' : 'incorrect'})`,\n }}\n />\n <ChoiceRationaleHolder>\n <EditableHtml\n markup={choice.rationale || ''}\n spellCheck={spellCheckEnabled}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n onChange={(c) => this.onChoiceRationaleChanged(key, { ...choice, rationale: c })}\n imageSupport={imageSupport}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n />\n </ChoiceRationaleHolder>\n </React.Fragment>\n ))}\n </StyledAccordionDetails>\n </Accordion>\n </RationaleChoices>\n ));\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.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 choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n return (\n <layout.ConfigLayout\n extraCSSRules={{\n names: ['red', 'blue'],\n rules: `\n .red {\n color: red !important;\n }\n\n .blue {\n color: blue !important;\n }\n `,\n }}\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 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 && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </PromptHolder>\n )}\n\n {promptEnabled && (\n <PromptHolder label={prompt.label}>\n <EditableHtml\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 && <ErrorText>{promptError}</ErrorText>}\n </PromptHolder>\n )}\n\n <FlexContainer>\n <StyledTypography component={'div'}>Define Template, Choices, and Correct Responses</StyledTypography>\n <StyledTooltip disableFocusListener disableTouchListener placement={'right'} title={validationMessage}>\n <Info fontSize={'small'} color={'primary'} />\n </StyledTooltip>\n </FlexContainer>\n\n <ResponseAreaComponent\n responseAreasError={responseAreasError}\n responseAreaChoicesError={responseAreaChoicesError}\n editableHtmlProps={{\n pluginProps: getPluginProps(template?.inputConfiguration),\n activePlugins: ALL_PLUGINS,\n toolbarOpts: { position: 'top' },\n extraCSSRules: {\n names: ['red', 'blue'],\n rules: `\n .red {\n color: red !important;\n }\n\n .blue {\n color: blue !important;\n }\n `,\n },\n responseAreaProps: {\n type: 'inline-dropdown',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n onToolbarCloseRequest: ([node, pos], editor, closeToolbar, onCancel) => {\n this.validateResponseAreaClose(node, pos, editor, closeToolbar, onCancel);\n },\n respAreaToolbar: (nodeInfo, editor, closeToolbar) => {\n const [node, pos] = nodeInfo;\n const { respAreaChoices } = this.state;\n\n return (props) => (\n <InlineDropdownToolbar\n {...props}\n onAddChoice={this.onAddChoice}\n onRemoveChoice={(index) => this.onRemoveChoice(node.attrs.index, index)}\n onSelectChoice={(index) => this.onSelectChoice(node.attrs.index, index)}\n node={node}\n pos={pos}\n editor={editor}\n onToolbarDone={closeToolbar}\n choices={respAreaChoices[node.attrs.index]}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n baseInputConfiguration={baseInputConfiguration}\n responseAreaInputConfiguration={responseAreaInputConfiguration}\n />\n );\n },\n },\n spellCheck: spellCheckEnabled,\n markup: model.slateMarkup || '',\n onChange: this.onChange,\n imageSupport: imageSupport,\n disableImageAlignmentButtons: true,\n disabled: false,\n highlightShape: false,\n error: responseAreasError,\n uploadSoundSupport: uploadSoundSupport,\n languageCharactersProps: [{ language: 'spanish' }, { language: 'special' }],\n mathMlOptions: mathMlOptions,\n }}\n />\n\n {choiceRationaleEnabled && renderChoiceRationale()}\n\n {rationaleEnabled && (\n <PromptHolder label={rationale.label}>\n <EditableHtml\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 && <ErrorText>{rationaleError}</ErrorText>}\n </PromptHolder>\n )}\n\n <AlertDialog\n open={warning.open}\n title=\"Warning\"\n text={warning.text}\n onClose={warning.onClose}\n onConfirm={warning.onConfirm}\n disableAutoFocus={true}\n disableEnforceFocus={true}\n disableRestoreFocus={true}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAC,uBAAA,CAAAJ,OAAA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MAAA,CAAAgC,OAAA,CAAAmD,aAAA,CAAC5E,SAAA,CAAA6Q,WAAW;MACVvL,IAAI,EAAED,OAAO,CAACC,IAAK;MACnBoK,KAAK,EAAC,SAAS;MACf9I,IAAI,EAAEvB,OAAO,CAACuB,IAAK;MACnBC,OAAO,EAAExB,OAAO,CAACwB,OAAQ;MACzBC,SAAS,EAAEzB,OAAO,CAACyB,SAAU;MAC7BgK,gBAAgB,EAAE,IAAK;MACvBC,mBAAmB,EAAE,IAAK;MAC1BC,mBAAmB,EAAE;IAAK,CAC3B,CACkB,CAAC;EAE1B;AACF;AAACC,OAAA,CAAAlM,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAA3D,OAAA,EAvgBYsD,IAAI,eACI;EACjBkE,aAAa,EAAEiI,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1C1L,KAAK,EAAEwL,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCC,gBAAgB,EAAEH,kBAAS,CAACI,IAAI;EAChC7L,cAAc,EAAEyL,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzCzG,sBAAsB,EAAEuG,kBAAS,CAACK,IAAI,CAACH,UAAU;EACjDxG,YAAY,EAAEsG,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFvG,kBAAkB,EAAEqG,kBAAS,CAACM,KAAK,CAAC;IAClCC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC;AACH,CAAC;AAAA,IAAAO,QAAA,GAAAV,OAAA,CAAAxP,OAAA,GA0fYsD,IAAI","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removeUnwantedCharacters = exports.processMarkup = exports.createSlateMarkup = exports.createElementFromHTML = void 0;
7
+ var _lodashEs = require("lodash-es");
8
+ // do not remove \t from \times, \triangle, \tan, \theta or \therefore
9
+ const tSymbols = 'imes|riangle|an|heta|herefore';
10
+ // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
11
+ const nSymbols = 'throot|parallel|cong|approx|eq|e|sim';
12
+ // match all \t and \n that are not part of math symbols that starts with \t or \n
13
+ const matchTabAndNewLine = new RegExp(`(\\t(?!${tSymbols}))|(\\n(?!${nSymbols}))|(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))`, 'g');
14
+ const removeUnwantedCharacters = markup => markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
15
+ exports.removeUnwantedCharacters = removeUnwantedCharacters;
16
+ const createElementFromHTML = htmlString => {
17
+ const div = document.createElement('div');
18
+ div.innerHTML = htmlString.trim();
19
+ return div;
20
+ };
21
+ exports.createElementFromHTML = createElementFromHTML;
22
+ const processMarkup = markup => {
23
+ const newMarkup = removeUnwantedCharacters(markup);
24
+ const slateMarkup = createElementFromHTML(newMarkup);
25
+ slateMarkup.querySelectorAll('[data-type="inline_dropdown"]').forEach(s => {
26
+ s.replaceWith(`{{${s.dataset.index}}}`);
27
+ });
28
+ return slateMarkup.innerHTML;
29
+ };
30
+ exports.processMarkup = processMarkup;
31
+ const REGEX = /\{\{(\d+)\}\}/g;
32
+ const createSlateMarkup = (markup, choices) => {
33
+ const newMarkup = removeUnwantedCharacters(markup);
34
+ const createSelect = index => {
35
+ let correctChoice = choices[index] && choices[index].find(c => c.correct);
36
+ if (!correctChoice || !correctChoice.value) {
37
+ correctChoice = {
38
+ id: '',
39
+ value: '',
40
+ label: ''
41
+ };
42
+ }
43
+ return `<span data-type="inline_dropdown" data-index="${index}" data-value="${(0, _lodashEs.escape)(correctChoice.label)}"></span>`;
44
+ };
45
+ return newMarkup.replace(REGEX, (match, g) => {
46
+ return createSelect(g);
47
+ });
48
+ };
49
+ exports.createSlateMarkup = createSlateMarkup;
50
+ //# sourceMappingURL=markupUtils.js.map
@@ -0,0 +1 @@
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","querySelectorAll","forEach","s","replaceWith","dataset","index","REGEX","createSlateMarkup","choices","createSelect","correctChoice","find","c","correct","value","id","label","escape","match","g"],"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\nexport const 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\n slateMarkup.querySelectorAll('[data-type=\"inline_dropdown\"]').forEach((s) => {\n s.replaceWith(`{{${s.dataset.index}}}`);\n });\n\n return slateMarkup.innerHTML;\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices) => {\n const newMarkup = removeUnwantedCharacters(markup);\n const createSelect = (index) => {\n let correctChoice = choices[index] && choices[index].find((c) => c.correct);\n\n if (!correctChoice || !correctChoice.value) {\n correctChoice = {\n id: '',\n value: '',\n label: '',\n };\n }\n\n return `<span data-type=\"inline_dropdown\" data-index=\"${index}\" data-value=\"${escape(\n correctChoice.label,\n )}\"></span>`;\n };\n\n return newMarkup.replace(REGEX, (match, g) => {\n return createSelect(g);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,QAAQ,GAAG,+BAA+B;AAChD;AACA,MAAMC,QAAQ,GAAG,sCAAsC;AACvD;AACA,MAAMC,kBAAkB,GAAG,IAAIC,MAAM,CACnC,UAAUH,QAAQ,aAAaC,QAAQ,eAAeD,QAAQ,eAAeC,QAAQ,IAAI,EACzF,GACF,CAAC;AAEM,MAAMG,wBAAwB,GAAIC,MAAM,IAC7CA,MAAM,CAACC,OAAO,CAACJ,kBAAkB,EAAE,EAAE,CAAC,CAACI,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;AAACC,OAAA,CAAAH,wBAAA,GAAAA,wBAAA;AAE7E,MAAMI,qBAAqB,GAAIC,UAAU,IAAK;EACnD,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAEzCF,GAAG,CAACG,SAAS,GAAGJ,UAAU,CAACK,IAAI,CAAC,CAAC;EAEjC,OAAOJ,GAAG;AACZ,CAAC;AAACH,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMO,aAAa,GAAIV,MAAM,IAAK;EACvC,MAAMW,SAAS,GAAGZ,wBAAwB,CAACC,MAAM,CAAC;EAClD,MAAMY,WAAW,GAAGT,qBAAqB,CAACQ,SAAS,CAAC;EAEpDC,WAAW,CAACC,gBAAgB,CAAC,+BAA+B,CAAC,CAACC,OAAO,CAAEC,CAAC,IAAK;IAC3EA,CAAC,CAACC,WAAW,CAAC,KAAKD,CAAC,CAACE,OAAO,CAACC,KAAK,IAAI,CAAC;EACzC,CAAC,CAAC;EAEF,OAAON,WAAW,CAACJ,SAAS;AAC9B,CAAC;AAACN,OAAA,CAAAQ,aAAA,GAAAA,aAAA;AAEF,MAAMS,KAAK,GAAG,gBAAgB;AAEvB,MAAMC,iBAAiB,GAAGA,CAACpB,MAAM,EAAEqB,OAAO,KAAK;EACpD,MAAMV,SAAS,GAAGZ,wBAAwB,CAACC,MAAM,CAAC;EAClD,MAAMsB,YAAY,GAAIJ,KAAK,IAAK;IAC9B,IAAIK,aAAa,GAAGF,OAAO,CAACH,KAAK,CAAC,IAAIG,OAAO,CAACH,KAAK,CAAC,CAACM,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,CAAC;IAE3E,IAAI,CAACH,aAAa,IAAI,CAACA,aAAa,CAACI,KAAK,EAAE;MAC1CJ,aAAa,GAAG;QACdK,EAAE,EAAE,EAAE;QACND,KAAK,EAAE,EAAE;QACTE,KAAK,EAAE;MACT,CAAC;IACH;IAEA,OAAO,iDAAiDX,KAAK,iBAAiB,IAAAY,gBAAM,EAClFP,aAAa,CAACM,KAChB,CAAC,WAAW;EACd,CAAC;EAED,OAAOlB,SAAS,CAACV,OAAO,CAACkB,KAAK,EAAE,CAACY,KAAK,EAAEC,CAAC,KAAK;IAC5C,OAAOV,YAAY,CAACU,CAAC,CAAC;EACxB,CAAC,CAAC;AACJ,CAAC;AAAC9B,OAAA,CAAAkB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _reactDom = _interopRequireDefault(require("react-dom"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _styles = require("@mui/material/styles");
13
+ var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
14
+ var _mathRendering = require("@pie-lib/math-rendering");
15
+ const ResponseArea = (0, _styles.styled)('div')(({
16
+ theme
17
+ }) => ({
18
+ paddingBottom: theme.spacing(2.5)
19
+ }));
20
+ const ErrorText = (0, _styles.styled)('div')(({
21
+ theme
22
+ }) => ({
23
+ fontSize: theme.typography.fontSize - 2,
24
+ color: theme.palette.error.main,
25
+ paddingTop: theme.spacing(1)
26
+ }));
27
+ class ResponseAreaComponent extends _react.default.Component {
28
+ componentDidMount() {
29
+ // eslint-disable-next-line react/no-find-dom-node
30
+ const domNode = _reactDom.default.findDOMNode(this);
31
+ (0, _mathRendering.renderMath)(domNode);
32
+ }
33
+ render() {
34
+ const {
35
+ editableHtmlProps,
36
+ responseAreasError,
37
+ responseAreaChoicesError
38
+ } = this.props;
39
+ return /*#__PURE__*/_react.default.createElement(ResponseArea, null, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, editableHtmlProps), responseAreasError && /*#__PURE__*/_react.default.createElement(ErrorText, null, responseAreasError), responseAreaChoicesError && /*#__PURE__*/_react.default.createElement(ErrorText, null, responseAreaChoicesError));
40
+ }
41
+ }
42
+ (0, _defineProperty2.default)(ResponseAreaComponent, "propTypes", {
43
+ editableHtmlProps: _propTypes.default.object.isRequired,
44
+ responseAreasError: _propTypes.default.string,
45
+ responseAreaChoicesError: _propTypes.default.string
46
+ });
47
+ var _default = exports.default = ResponseAreaComponent;
48
+ //# sourceMappingURL=response-area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-area.js","names":["_react","_interopRequireDefault","require","_reactDom","_propTypes","_styles","_editableHtmlTipTap","_mathRendering","ResponseArea","styled","theme","paddingBottom","spacing","ErrorText","fontSize","typography","color","palette","error","main","paddingTop","ResponseAreaComponent","React","Component","componentDidMount","domNode","ReactDOM","findDOMNode","renderMath","render","editableHtmlProps","responseAreasError","responseAreaChoicesError","props","default","createElement","_defineProperty2","PropTypes","object","isRequired","string","_default","exports"],"sources":["../src/response-area.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport EditableHtml from '@pie-lib/editable-html-tip-tap';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst ResponseArea = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2.5),\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\nclass ResponseAreaComponent extends React.Component {\n static propTypes = {\n editableHtmlProps: PropTypes.object.isRequired,\n responseAreasError: PropTypes.string,\n responseAreaChoicesError: PropTypes.string,\n };\n\n componentDidMount() {\n // eslint-disable-next-line react/no-find-dom-node\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n }\n\n render() {\n const { editableHtmlProps, responseAreasError, responseAreaChoicesError } = this.props;\n\n return (\n <ResponseArea>\n <EditableHtml {...editableHtmlProps} />\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n {responseAreaChoicesError && <ErrorText>{responseAreaChoicesError}</ErrorText>}\n </ResponseArea>\n );\n }\n}\n\nexport default ResponseAreaComponent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,MAAMM,YAAY,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACjDC,a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AACtC,CAAC;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAsBYb,qBAAqB","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPluginProps = exports.generateValidationMessage = void 0;
7
+ const generateValidationMessage = config => {
8
+ const {
9
+ maxResponseAreas,
10
+ maxResponseAreaChoices
11
+ } = config;
12
+ const responseAreasMessage = '\nThere should be at least 1 ' + (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.' + (maxResponseAreaChoices ? `\nThere should be at most ${maxResponseAreaChoices} choices defined per response area.` : '');
13
+ const message = 'Validation requirements:' + responseAreasMessage;
14
+ return message;
15
+ };
16
+ exports.generateValidationMessage = generateValidationMessage;
17
+ const getPluginProps = (props = {}, baseInputConfiguration = {}) => ({
18
+ ...baseInputConfiguration,
19
+ ...props
20
+ });
21
+ exports.getPluginProps = getPluginProps;
22
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["generateValidationMessage","config","maxResponseAreas","maxResponseAreaChoices","responseAreasMessage","message","exports","getPluginProps","props","baseInputConfiguration"],"sources":["../src/utils.js"],"sourcesContent":["export const generateValidationMessage = (config) => {\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n\n const responseAreasMessage =\n '\\nThere should be at least 1 ' +\n (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') +\n 'response area' +\n (maxResponseAreas ? 's' : '') +\n ' defined.' +\n (maxResponseAreaChoices\n ? `\\nThere should be at most ${maxResponseAreaChoices} choices defined per response area.`\n : '');\n\n const message = 'Validation requirements:' + responseAreasMessage;\n\n return message;\n};\n\nexport const getPluginProps = (props = {}, baseInputConfiguration = {}) => ({\n ...baseInputConfiguration,\n ...props,\n});\n"],"mappings":";;;;;;AAAO,MAAMA,yBAAyB,GAAIC,MAAM,IAAK;EACnD,MAAM;IAAEC,gBAAgB;IAAEC;EAAuB,CAAC,GAAGF,MAAM;EAE3D,MAAMG,oBAAoB,GACxB,+BAA+B,IAC9BF,gBAAgB,GAAG,eAAeA,gBAAgB,GAAG,GAAG,EAAE,CAAC,GAC5D,eAAe,IACdA,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC,GAC7B,WAAW,IACVC,sBAAsB,GACnB,6BAA6BA,sBAAsB,qCAAqC,GACxF,EAAE,CAAC;EAET,MAAME,OAAO,GAAG,0BAA0B,GAAGD,oBAAoB;EAEjE,OAAOC,OAAO;AAChB,CAAC;AAACC,OAAA,CAAAN,yBAAA,GAAAA,yBAAA;AAEK,MAAMO,cAAc,GAAGA,CAACC,KAAK,GAAG,CAAC,CAAC,EAAEC,sBAAsB,GAAG,CAAC,CAAC,MAAM;EAC1E,GAAGA,sBAAsB;EACzB,GAAGD;AACL,CAAC,CAAC;AAACF,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/inline-dropdown-configure",
3
- "version": "9.4.0-beta.12",
3
+ "version": "9.4.0-beta.14",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -10,8 +10,8 @@
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": "13.0.22-beta.1",
14
- "@pie-lib/editable-html-tip-tap": "2.1.20-beta.1",
13
+ "@pie-lib/config-ui": "13.0.22-beta.3",
14
+ "@pie-lib/editable-html-tip-tap": "2.1.20-beta.3",
15
15
  "@pie-lib/math-rendering": "5.1.0",
16
16
  "@pie-lib/render-ui": "6.1.3",
17
17
  "classnames": "^2.2.6",
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [9.4.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/inline-dropdown-controller@9.4.0-beta.13...@pie-element/inline-dropdown-controller@9.4.0-beta.14) (2026-09-29)
7
+
8
+ **Note:** Version bump only for package @pie-element/inline-dropdown-controller
9
+
10
+ # [9.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/inline-dropdown-controller@9.4.0-beta.12...@pie-element/inline-dropdown-controller@9.4.0-beta.13) (2026-09-24)
11
+
12
+ **Note:** Version bump only for package @pie-element/inline-dropdown-controller
13
+
6
14
  # [9.4.0-beta.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/inline-dropdown-controller@9.4.0-beta.11...@pie-element/inline-dropdown-controller@9.4.0-beta.12) (2026-09-24)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/inline-dropdown-controller
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = {
8
+ alternateResponse: {},
9
+ choiceRationaleEnabled: true,
10
+ choices: {},
11
+ disabled: false,
12
+ displayType: 'block',
13
+ markup: '',
14
+ mode: 'gather',
15
+ prompt: '',
16
+ promptEnabled: true,
17
+ rationale: '',
18
+ rationaleEnabled: true,
19
+ shuffle: true,
20
+ studentInstructionsEnabled: true,
21
+ teacherInstructions: '',
22
+ teacherInstructionsEnabled: true,
23
+ toolbarEditorPosition: 'bottom'
24
+ };
25
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":["alternateResponse","choiceRationaleEnabled","choices","disabled","displayType","markup","mode","prompt","promptEnabled","rationale","rationaleEnabled","shuffle","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n alternateResponse: {},\n choiceRationaleEnabled: true,\n choices: {},\n disabled: false,\n displayType: 'block',\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n shuffle: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n"],"mappings":";;;;;;iCAAe;EACbA,iBAAiB,EAAE,CAAC,CAAC;EACrBC,sBAAsB,EAAE,IAAI;EAC5BC,OAAO,EAAE,CAAC,CAAC;EACXC,QAAQ,EAAE,KAAK;EACfC,WAAW,EAAE,OAAO;EACpBC,MAAM,EAAE,EAAE;EACVC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,IAAI;EACtBC,OAAO,EAAE,IAAI;EACbC,0BAA0B,EAAE,IAAI;EAChCC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,qBAAqB,EAAE;AACzB,CAAC","ignoreList":[]}
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getScore = exports.getLogTrace = exports.createCorrectResponseSession = void 0;
8
+ exports.model = model;
9
+ exports.normalize = void 0;
10
+ exports.outcome = outcome;
11
+ exports.validate = void 0;
12
+ var _lodashEs = require("lodash-es");
13
+ var _controllerUtils = require("@pie-lib/controller-utils");
14
+ var _defaults = _interopRequireDefault(require("./defaults"));
15
+ var _utils = require("./utils");
16
+ const getFeedback = correct => {
17
+ if (correct) {
18
+ return 'correct';
19
+ }
20
+ return 'incorrect';
21
+ };
22
+ const normalize = question => ({
23
+ ..._defaults.default,
24
+ ...question
25
+ });
26
+
27
+ /**
28
+ *
29
+ * @param {*} question
30
+ * @param {*} session
31
+ * @param {*} env
32
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
33
+ */
34
+ exports.normalize = normalize;
35
+ async function model(question, session, env, updateSession) {
36
+ const normalizedQuestion = normalize(question);
37
+ const {
38
+ value = {}
39
+ } = session || {};
40
+ let choices = (0, _lodashEs.reduce)(normalizedQuestion.choices, (obj, area, key) => {
41
+ obj[key] = (0, _lodashEs.map)(area, choice => choice);
42
+ return obj;
43
+ }, {});
44
+ let feedback = {};
45
+ if (env.mode === 'evaluate') {
46
+ const allCorrectResponses = (0, _utils.getAllCorrectResponses)(normalizedQuestion);
47
+ const respAreaLength = Object.keys(allCorrectResponses).length;
48
+ let correctResponses = 0;
49
+ for (let i = 0; i < respAreaLength; i++) {
50
+ const result = (0, _lodashEs.reduce)(allCorrectResponses, (obj, choices, key) => {
51
+ const answer = value && value[key] || '';
52
+ const correctChoice = choices[i] || '';
53
+ const isCorrect = answer && correctChoice && correctChoice === answer;
54
+ obj.feedback[key] = getFeedback(isCorrect);
55
+ if (isCorrect) {
56
+ obj.correctResponses += 1;
57
+ }
58
+ return obj;
59
+ }, {
60
+ correctResponses: 0,
61
+ feedback: {}
62
+ });
63
+ if (result.correctResponses >= correctResponses) {
64
+ correctResponses = result.correctResponses;
65
+ feedback = result.feedback;
66
+ }
67
+ if (result.correctResponses === respAreaLength) {
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ const lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
73
+ if (!lockChoiceOrder) {
74
+ const shuffledValues = {};
75
+ const keys = Object.keys(choices);
76
+ const us = part => (id, element, update) => {
77
+ return new Promise(resolve => {
78
+ shuffledValues[part] = update.shuffledValues;
79
+ resolve();
80
+ });
81
+ };
82
+ let i;
83
+ for (i = 0; i < keys.length; i++) {
84
+ const key = keys[i];
85
+ const storedValues = session?.shuffledValues?.[key];
86
+ choices[key] = await (0, _controllerUtils.getShuffledChoices)(choices[key],
87
+ // the shuffledValues structure was updated to an object like { choice_key: [] }
88
+ // and we need to override shuffledValues if it's not an array
89
+ {
90
+ shuffledValues: Array.isArray(storedValues) ? storedValues : []
91
+ }, us(key), 'value');
92
+ }
93
+ if (!(0, _lodashEs.isEmpty)(shuffledValues)) {
94
+ if (session && updateSession && typeof updateSession === 'function') {
95
+ updateSession(session.id, session.element, {
96
+ shuffledValues
97
+ }).catch(e => {
98
+ // eslint-disable-next-line no-console
99
+ console.error('update session failed', e);
100
+ });
101
+ }
102
+ }
103
+ }
104
+ let teacherInstructions = null;
105
+ let rationale = null;
106
+ const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => {
107
+ acc[currentValue] = (choices[currentValue] || []).map(choice => ({
108
+ ...choice,
109
+ rationale: null
110
+ }));
111
+ return acc;
112
+ }, {});
113
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
114
+ rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
115
+ teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
116
+ choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;
117
+ } else {
118
+ rationale = null;
119
+ teacherInstructions = null;
120
+ choices = choicesWillNullRationales;
121
+ }
122
+ const out = {
123
+ disabled: env.mode !== 'gather',
124
+ mode: env.mode,
125
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
126
+ displayType: normalizedQuestion.displayType,
127
+ markup: normalizedQuestion.markup,
128
+ choices,
129
+ feedback,
130
+ responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
131
+ rationale,
132
+ teacherInstructions,
133
+ language: normalizedQuestion.language,
134
+ extraCSSRules: normalizedQuestion.extraCSSRules
135
+ };
136
+ return out;
137
+ }
138
+ const getScore = (config, session) => {
139
+ const {
140
+ value = {}
141
+ } = session || {};
142
+ const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;
143
+ const allCorrectResponses = (0, _utils.getAllCorrectResponses)(config);
144
+ let correctCount = 0;
145
+ for (let i = 0; i < maxScore; i++) {
146
+ const result = (0, _lodashEs.reduce)(allCorrectResponses, (total, choices, key) => {
147
+ const answer = value && value[key] || '';
148
+ const correctChoice = choices[i] || '';
149
+ if (correctChoice && answer && correctChoice === answer) {
150
+ return total;
151
+ }
152
+ return total - 1;
153
+ }, maxScore);
154
+ if (result > correctCount) {
155
+ correctCount = result;
156
+ }
157
+ if (result === maxScore) {
158
+ break;
159
+ }
160
+ }
161
+ const str = (correctCount / maxScore).toFixed(2);
162
+ return parseFloat(str);
163
+ };
164
+
165
+ /**
166
+ * Generates detailed trace log for scoring evaluation
167
+ * @param {Object} model - the question model
168
+ * @param {Object} session - the student session
169
+ * @param {Object} env - the environment
170
+ * @returns {Array} traceLog - array of trace messages
171
+ */
172
+ exports.getScore = getScore;
173
+ const getLogTrace = (model, session, env) => {
174
+ const traceLog = [];
175
+ const {
176
+ value = {}
177
+ } = session || {};
178
+ const allCorrectResponses = (0, _utils.getAllCorrectResponses)(model);
179
+ const responseAreaKeys = Object.keys(allCorrectResponses);
180
+ const totalAreas = responseAreaKeys.length;
181
+ traceLog.push(`${totalAreas} dropdown response area(s) defined in this question.`);
182
+ if (value && Object.keys(value).length > 0) {
183
+ const selectedAreas = Object.entries(value).filter(([key, val]) => val && val.trim()).length;
184
+ traceLog.push(`Student selected options in ${selectedAreas} out of ${totalAreas} dropdown(s).`);
185
+ responseAreaKeys.forEach(areaKey => {
186
+ const studentSelection = value && value[areaKey] || '';
187
+ const correctOptions = allCorrectResponses[areaKey] || [];
188
+ if (studentSelection.trim()) {
189
+ traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: student selected '${studentSelection}' (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);
190
+ } else {
191
+ traceLog.push(`Dropdown ${parseInt(areaKey) + 1}: no selection made (correct options: [${correctOptions.map(opt => `'${opt}'`).join(', ')}]).`);
192
+ }
193
+ });
194
+ } else {
195
+ traceLog.push('Student did not make any selections in the dropdowns.');
196
+ }
197
+ const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
198
+ traceLog.push(`Scoring method: ${partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'}.`);
199
+ const score = getScore(model, session);
200
+ traceLog.push(`Final score: ${score}.`);
201
+ return traceLog;
202
+ };
203
+
204
+ /**
205
+ *
206
+ * The score is partial by default for checkbox mode, allOrNothing for radio mode.
207
+ * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =
208
+ * false. the value in `env` will override the value in `model`.
209
+ * @param {Object} model - the main model
210
+ * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)
211
+ * @param {*} session
212
+ * @param {Object} env
213
+ * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides
214
+ * `model.partialScoring`.
215
+ */
216
+ exports.getLogTrace = getLogTrace;
217
+ function outcome(model, session, env = {}) {
218
+ return new Promise(resolve => {
219
+ if (!session || (0, _lodashEs.isEmpty)(session)) {
220
+ resolve({
221
+ score: 0,
222
+ empty: true,
223
+ traceLog: ['Student did not make any selections in the dropdowns. Score is 0.']
224
+ });
225
+ } else {
226
+ const traceLog = getLogTrace(model, session, env);
227
+ const score = getScore(model, session);
228
+ const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
229
+ resolve({
230
+ score: partialScoringEnabled ? score : Math.floor(score),
231
+ empty: false,
232
+ traceLog
233
+ });
234
+ }
235
+ });
236
+ }
237
+ const createCorrectResponseSession = (question, env) => {
238
+ return new Promise(resolve => {
239
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
240
+ const {
241
+ choices
242
+ } = question;
243
+ const value = {};
244
+ if (choices) {
245
+ Object.keys(choices).forEach((key, i) => {
246
+ const correctChoices = choices[key] && choices[key].filter(c => c.correct);
247
+ value[i] = correctChoices && correctChoices[0].value;
248
+ });
249
+ }
250
+ resolve({
251
+ id: '1',
252
+ value
253
+ });
254
+ } else {
255
+ resolve(null);
256
+ }
257
+ });
258
+ };
259
+
260
+ // remove all html tags
261
+ exports.createCorrectResponseSession = createCorrectResponseSession;
262
+ const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
263
+
264
+ // remove all html tags except img, iframe and source tag for audio
265
+ const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
266
+ const validate = (model = {}, config = {}) => {
267
+ const {
268
+ markup,
269
+ choices
270
+ } = model;
271
+ const {
272
+ maxResponseAreas,
273
+ maxResponseAreaChoices
274
+ } = config;
275
+ const errors = {};
276
+ ['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
277
+ if (config[field]?.required && !getContent(model[field])) {
278
+ errors[field] = 'This field is required.';
279
+ }
280
+ });
281
+ const nbOfResponseAreas = ((markup || '').match(/\{\{(\d+)\}\}/g) || []).length;
282
+ if (nbOfResponseAreas > maxResponseAreas) {
283
+ errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
284
+ } else if (nbOfResponseAreas < 1) {
285
+ errors.responseAreasError = 'There should be defined at least 1 response area.';
286
+ }
287
+ (Object.keys(choices) || []).forEach(choiceKey => {
288
+ if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {
289
+ errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;
290
+ }
291
+ });
292
+ return errors;
293
+ };
294
+ exports.validate = validate;
295
+ //# sourceMappingURL=index.js.map