@pie-element/explicit-constructed-response 3.7.19-next.85 → 3.8.1-beta.587
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +541 -0
- package/configure/CHANGELOG.md +482 -0
- package/configure/lib/alternateResponses.js +45 -12
- package/configure/lib/alternateResponses.js.map +1 -1
- package/configure/lib/alternateSection.js +116 -19
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/defaults.js +35 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/ecr-toolbar.js +35 -19
- package/configure/lib/ecr-toolbar.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +291 -58
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +29 -3
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +23 -5
- package/controller/CHANGELOG.md +107 -0
- package/controller/lib/defaults.js +1 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +109 -6
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +137 -0
- package/docs/config-schema.json.md +105 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +6 -2
- package/docs/pie-schema.json +68 -0
- package/docs/pie-schema.json.md +53 -0
- package/lib/index.js +8 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +95 -25
- package/lib/main.js.map +1 -1
- package/lib/print.js +115 -0
- package/lib/print.js.map +1 -0
- package/package.json +14 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","lineHeight","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","index","label","value","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","newChoices","Object","values","setState","classes","configuration","onConfigurationChanged","imageSupport","partialScoring","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","onModelChange","Settings","Properties","onTeacherInstructionsChanged","onPromptChanged","ALL_PLUGINS","position","type","options","duplicates","respAreaToolbar","node","onToolbarDone","correctChoice","data","get","onChangeResponse","onChange","onBlur","onResponsesChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;IAFQA,M,GAAkBC,kB,CAAlBD,M;IAAQE,K,GAAUD,kB,CAAVC,K;;AAIhB,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADS;AAMvBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANe;AAUvBO,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENF,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAF3B;AAGNH,MAAAA,KAAK,EAAE,MAHD;AAIN,sCAAgC;AAC9BQ,QAAAA,SAAS,EAAE;AADmB;AAJ1B,KAVe;AAkBvBC,IAAAA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BAIE,gCAAC,wBAAD;AACE,QAAA,SAAS,EAAEoD,OAAO,CAAC9C,MADrB;AAEE,QAAA,MAAM,EAAE2B,KAAK,CAACC,SAAN,IAAmB,EAF7B;AAGE,QAAA,QAAQ,EAAE,KAAK8C,kBAHjB;AAIE,QAAA,YAAY,EAAEzB;AAJhB,QAJF,CA9EJ,CA1BF,CADF,CADF;AA0HD;;;EArQuB0B,kBAAMC,S;;;iCAAnBrD,I,eACQ;AACjBwB,EAAAA,aAAa,EAAE8B,sBAAUC,MAAV,CAAiBC,UADf;AAEjBpD,EAAAA,KAAK,EAAEkD,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjBvD,EAAAA,cAAc,EAAEmD,sBAAUK,IAAV,CAAeH,UAJd;AAKjB/B,EAAAA,sBAAsB,EAAE6B,sBAAUK,IAAV,CAAeH,UALtB;AAMjBjC,EAAAA,OAAO,EAAE+B,sBAAUC,MAAV,CAAiBC,UANT;AAOjB9B,EAAAA,YAAY,EAAE4B,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AAuQrB,IAAMM,MAAM,GAAG,wBAAW7F,MAAX,EAAmB+B,IAAnB,CAAf;eAEe8D,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\n\nconst { toggle, Panel } = settings;\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\n\nconst styles = theme => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px'\n }\n },\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n addButton: {\n float: 'right'\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: '16px',\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4\n }\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 classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n })\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup }\n } = this.props;\n\n this.setState({\n markup: slateMarkup\n });\n }\n\n onModelChange = newVal => {\n this.props.onModelChanged({\n ...this.props.model,\n ...newVal\n });\n };\n\n onPromptChanged = prompt => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt\n });\n };\n\n onRationaleChanged = rationale => {\n this.props.onModelChanged({\n ...this.props.model,\n rationale\n });\n };\n\n onTeacherInstructionsChanged = teacherInstructions => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...model,\n teacherInstructions\n });\n };\n\n onMarkupChanged = slateMarkup => {\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup\n });\n };\n\n onResponsesChanged = choices => {\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChangeResponse = (index, newVal) => {\n const {\n model: { choices }\n } = this.props;\n\n if (!choices[index]) {\n choices[index] = [{ label: '', value: '0' }];\n }\n\n choices[index][0].label = newVal || '';\n\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChange = markup => {\n const {\n model: { choices }\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll(\n '[data-type=\"explicit_constructed_response\"]'\n );\n\n const allChoices = {};\n\n allRespAreas.forEach((el, index) => {\n el.dataset.index = index;\n });\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(Object.values(choices)[index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0'\n };\n }\n\n allChoices[el.dataset.index] = newChoices;\n });\n\n this.props.onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML\n });\n };\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n imageSupport\n } = this.props;\n const {\n prompt = {},\n partialScoring = {},\n rationale = {},\n teacherInstructions = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled } =\n model || {};\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => this.onModelChange(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label)\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label)\n }\n }}\n />\n }\n >\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n />\n </InputContainer>\n )}\n <Typography className={classes.text}>\n Define Template, Choices, and Correct Responses\n </Typography>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true\n },\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[\n node.data.get('index')\n ] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={newVal =>\n this.onChangeResponse(node.data.get('index'), newVal)\n }\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n }\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n />\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n Define Alternates\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n />\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","typography","lineHeight","marginTop","tooltip","whiteSpace","maxWidth","errorText","flexContainer","display","alignItems","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","maxImageWidth","maxImageHeight","maxResponseAreas","partialScoring","playerSpellCheck","settingsPanelDisabled","spellCheck","withRubric","errors","maxLengthPerChoiceEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","choicesErrors","responseAreasError","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","panelProperties","playerSpellCheckEnabled","rubricEnabled","onModelChange","Settings","Properties","onTeacherInstructionsChanged","language","onPromptChanged","marginLeft","ALL_PLUGINS","type","options","duplicates","respAreaToolbar","nodePath","editor","onToolbarDone","correctChoice","onChangeResponse","error","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAQA,MAAR,GAA0BC,kBAA1B,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAA0BD,kBAA1B,CAAgBC,KAAhB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KA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,IAAgDqE,qBARlE;AASE,QAAA,kBAAkB,EAAEpB,kBATtB;AAUE,QAAA,uBAAuB,EAAE,CAAC;AAAE+B,UAAAA,QAAQ,EAAE;AAAZ,SAAD,EAA0B;AAAEA,UAAAA,QAAQ,EAAE;AAAZ,SAA1B;AAV3B,QADF,CA5GJ,CAfF,CADF,CADF;AAgJD;;;EAxXuBoB,kBAAMC,S;;;iCAAnB1G,I,eACQ;AACjBmD,EAAAA,aAAa,EAAEwD,sBAAUC,MAAV,CAAiBC,UADf;AAEjBzG,EAAAA,KAAK,EAAEuG,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjB5G,EAAAA,cAAc,EAAEwG,sBAAUK,IAAV,CAAeH,UAJd;AAKjBzD,EAAAA,sBAAsB,EAAEuD,sBAAUK,IAAV,CAAeH,UALtB;AAMjB3D,EAAAA,OAAO,EAAEyD,sBAAUC,MAAV,CAAiBC,UANT;AAOjBxD,EAAAA,YAAY,EAAEsD,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AA0XrB,IAAMM,MAAM,GAAG,wBAAW1J,MAAX,EAAmBuC,IAAnB,CAAf;eAEemH,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\n// import EditableHtmlNew from 'editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport { generateValidationMessage } from './utils';\n\nconst { toggle, Panel } = settings;\n\nconst styles = (theme) => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px',\n },\n },\n design: {\n paddingTop: theme.spacing.unit * 3,\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2,\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0,\n },\n addButton: {\n float: 'right',\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: theme.typography.fontSize + 2,\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: 'red',\n paddingTop: theme.spacing.unit,\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end',\n },\n});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = [] },\n onModelChanged,\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({ ...this.props.model, maxLengthPerChoice });\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({ ...this.props.model, ...newVal });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({ ...this.props.model, prompt });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({ ...this.props.model, rationale });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, teacherInstructions });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({ ...this.props.model, slateMarkup });\n };\n\n onResponsesChanged = (choices) => {\n this.props.onModelChanged({ ...this.props.model, choices });\n };\n\n onLengthChanged = (maxLengthPerChoice) => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({ ...model, maxLengthPerChoice });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged } = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1)];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice &&\n (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({ ...model, choices, maxLengthPerChoice });\n };\n\n onChange = (markup) => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged,\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]');\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0',\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () =>\n onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice,\n });\n\n this.setState({ cachedChoices: undefined }, callback);\n };\n\n onHandleAreaChange = throttle(\n (nodes) => {\n const {\n model: { choices },\n onModelChanged,\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.index;\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({ ...this.props.model, choices: newChoices });\n\n this.setState({ cachedChoices: newCachedChoices }, callback);\n },\n 500,\n { trailing: false, leading: true },\n );\n\n render() {\n const { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n maxImageWidth = {},\n maxImageHeight = {},\n maxLengthPerChoice = {},\n maxResponseAreas,\n partialScoring = {},\n playerSpellCheck = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n } = configuration || {};\n const {\n errors,\n maxLengthPerChoiceEnabled,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n\n const { choicesErrors = {}, responseAreasError } = 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 };\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 };\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\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 <div>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\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 />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </InputContainer>\n )}\n\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>Define Template, Choices, and Correct Responses</Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, nodePath, editor, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[node.data.index] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={(newVal) => this.onChangeResponse(node.data.index, newVal)}\n node={node}\n nodePath={nodePath}\n editor={editor}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange,\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\n\n {rationaleEnabled && (\n <InputContainer label={rationale.label} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\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 />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
|
|
@@ -5,12 +5,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.createSlateMarkup = void 0;
|
|
9
9
|
|
|
10
10
|
var _escape = _interopRequireDefault(require("lodash/escape"));
|
|
11
11
|
|
|
12
|
+
// do not remove \t from \times, \triangle, \tan, \theta or \therefore
|
|
13
|
+
var tSymbols = 'imes|riangle|an|heta|herefore'; // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
|
|
14
|
+
|
|
15
|
+
var nSymbols = 'throot|parallel|cong|approx|eq|e|sim'; // match all \t and \n that are not part of math symbols that starts with \t or \n
|
|
16
|
+
|
|
17
|
+
var matchTabAndNewLine = new RegExp("(\\t(?!".concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
|
|
18
|
+
|
|
12
19
|
var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
|
|
13
|
-
return markup.replace(
|
|
20
|
+
return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
|
|
14
21
|
};
|
|
15
22
|
|
|
16
23
|
exports.removeUnwantedCharacters = removeUnwantedCharacters;
|
|
@@ -45,7 +52,26 @@ var createSlateMarkup = function createSlateMarkup(markup, choices) {
|
|
|
45
52
|
var label = choices[g][0].label || '';
|
|
46
53
|
return "<span data-type=\"explicit_constructed_response\" data-index=\"".concat(g, "\" data-value=\"").concat((0, _escape["default"])(label), "\"></span>");
|
|
47
54
|
});
|
|
48
|
-
};
|
|
55
|
+
}; // also used in controller/src/index.js
|
|
56
|
+
|
|
49
57
|
|
|
50
58
|
exports.createSlateMarkup = createSlateMarkup;
|
|
59
|
+
|
|
60
|
+
var getAdjustedLength = function getAdjustedLength(length) {
|
|
61
|
+
if (length <= 2) {
|
|
62
|
+
return length + 2;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (length <= 4) {
|
|
66
|
+
return length + 3;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (length <= 6) {
|
|
70
|
+
return length + 4;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return length + 5;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.getAdjustedLength = getAdjustedLength;
|
|
51
77
|
//# sourceMappingURL=markupUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/markupUtils.js"],"names":["removeUnwantedCharacters","markup","replace","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label"],"mappings":";;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["../src/markupUtils.js"],"names":["tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","processMarkup","newMarkup","slateMarkup","index","querySelectorAll","forEach","s","replaceWith","REGEX","createSlateMarkup","choices","match","g","label","getAdjustedLength","length"],"mappings":";;;;;;;;;AAAA;;AAEA;AACA,IAAMA,QAAQ,GAAG,+BAAjB,C,CACA;;AACA,IAAMC,QAAQ,GAAG,sCAAjB,C,CACA;;AACA,IAAMC,kBAAkB,GAAG,IAAIC,MAAJ,kBACfH,QADe,uBACMC,QADN,yBAC6BD,QAD7B,yBACoDC,QADpD,SAEzB,GAFyB,CAA3B;;AAKO,IAAMG,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,MAAD;AAAA,SACtCA,MAAM,CAACC,OAAP,CAAeJ,kBAAf,EAAmC,EAAnC,EAAuCI,OAAvC,CAA+C,MAA/C,EAAuD,GAAvD,EAA4DA,OAA5D,CAAoE,OAApE,EAA6E,GAA7E,CADsC;AAAA,CAAjC;;;;AAGP,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAwB,GAAqB;AAAA,MAApBC,UAAoB,uEAAP,EAAO;AACjD,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AAEAF,EAAAA,GAAG,CAAC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,EAAiB;AACf,WAAOA,MAAM,GAAG,CAAhB;AACD;;AAED,SAAOA,MAAM,GAAG,CAAhB;AACD,CAdM","sourcesContent":["import escape from 'lodash/escape';\n\n// do not remove \\t from \\times, \\triangle, \\tan, \\theta or \\therefore\nconst tSymbols = 'imes|riangle|an|heta|herefore';\n// do not remove \\n from \\nthroot, \\nparallel, \\ncong, \\napprox, \\neq, \\ne or \\nsim\nconst nSymbols = 'throot|parallel|cong|approx|eq|e|sim';\n// match all \\t and \\n that are not part of math symbols that starts with \\t or \\n\nconst matchTabAndNewLine = new RegExp(\n `(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))|(\\\\\\\\t(?!${tSymbols}))|(\\\\\\\\n(?!${nSymbols}))`,\n 'g',\n);\n\nexport const removeUnwantedCharacters = (markup) =>\n markup.replace(matchTabAndNewLine, '').replace(/\\\\\"/g, '\"').replace(/\\\\\\//g, '/');\n\nconst createElementFromHTML = (htmlString = '') => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\nexport const processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup || '');\n const slateMarkup = createElementFromHTML(newMarkup || '');\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"explicit_constructed_response\"]').forEach((s) => {\n s.replaceWith(`{{${index++}}}`);\n });\n\n return slateMarkup.innerHTML;\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices) => {\n if (!markup) {\n return '';\n }\n\n const newMarkup = removeUnwantedCharacters(markup);\n\n return newMarkup.replace(REGEX, (match, g) => {\n const label = choices[g][0].label || '';\n\n return `<span data-type=\"explicit_constructed_response\" data-index=\"${g}\" data-value=\"${escape(label)}\"></span>`;\n });\n};\n\n// also used in controller/src/index.js\nexport const getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n"],"file":"markupUtils.js"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateValidationMessage = void 0;
|
|
7
|
+
|
|
8
|
+
var generateValidationMessage = function generateValidationMessage(config) {
|
|
9
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
10
|
+
var responseAreasMessage = '\nCorrect answers should not be blank.' + '\nEach answer defined for a response area should be unique.' + '\nThere should be at least 1 ' + (maxResponseAreas ? "and at most ".concat(maxResponseAreas, " ") : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';
|
|
11
|
+
return 'Validation requirements:' + responseAreasMessage;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","maxResponseAreas","responseAreasMessage"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,MAAD,EAAY;AACnD,MAAQC,gBAAR,GAA6BD,MAA7B,CAAQC,gBAAR;AAEA,MAAMC,oBAAoB,GACxB,2CACA,6DADA,GAEA,+BAFA,IAGCD,gBAAgB,yBAAkBA,gBAAlB,SAAwC,EAHzD,IAIA,eAJA,IAKCA,gBAAgB,GAAG,GAAH,GAAS,EAL1B,IAMA,WAPF;AASA,SAAO,6BAA6BC,oBAApC;AACD,CAbM","sourcesContent":["export const generateValidationMessage = (config) => {\n const { maxResponseAreas } = config;\n\n const responseAreasMessage =\n '\\nCorrect answers should not be blank.' +\n '\\nEach answer defined for a response area should be unique.' +\n '\\nThere should be at least 1 ' +\n (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') +\n 'response area' +\n (maxResponseAreas ? 's' : '') +\n ' defined.';\n\n return 'Validation requirements:' + responseAreasMessage;\n};\n"],"file":"utils.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-configure",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"modue": "src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@material-ui/core": "^3.9.2",
|
|
9
9
|
"@material-ui/icons": "^3.0.1",
|
|
10
|
-
"@pie-framework/pie-configure-events": "^1.
|
|
11
|
-
"@pie-lib/config-ui": "
|
|
12
|
-
"@pie-lib/editable-html": "
|
|
10
|
+
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
11
|
+
"@pie-lib/config-ui": "12.0.0-beta.3",
|
|
12
|
+
"@pie-lib/editable-html": "10.0.0-beta.4",
|
|
13
13
|
"classnames": "^2.2.6",
|
|
14
14
|
"debug": "^3.1.0",
|
|
15
15
|
"lodash": "^4.17.15",
|
|
16
16
|
"prop-types": "^15.6.2",
|
|
17
17
|
"react": "^16.8.1",
|
|
18
|
-
"react-dom": "^16.8.1"
|
|
18
|
+
"react-dom": "^16.8.1",
|
|
19
|
+
"@types/is-hotkey": "^0.1.1",
|
|
20
|
+
"@types/lodash": "^4.14.149",
|
|
21
|
+
"direction": "^1.0.3",
|
|
22
|
+
"is-plain-object": "^5.0.0",
|
|
23
|
+
"scroll-into-view-if-needed": "^2.2.20",
|
|
24
|
+
"tiny-invariant": "1.0.6",
|
|
25
|
+
"@emotion/css": "^11.10.0",
|
|
26
|
+
"is-hotkey": "^0.2.0",
|
|
27
|
+
"slate": "^0.82.1",
|
|
28
|
+
"slate-dev-environment": "^0.2.5",
|
|
29
|
+
"slate-edit-list": "^0.12.1",
|
|
30
|
+
"slate-edit-table": "^0.18.0",
|
|
31
|
+
"slate-history": "^0.66.0",
|
|
32
|
+
"slate-html-serializer": "^0.8.13",
|
|
33
|
+
"slate-hyperscript": "^0.77.0",
|
|
34
|
+
"slate-plain-serializer": "^0.7.13",
|
|
35
|
+
"slate-prop-types": "^0.5.44",
|
|
36
|
+
"slate-react": "0.92.0"
|
|
19
37
|
}
|
|
20
38
|
}
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,113 @@
|
|
|
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
|
+
# [3.5.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.9...@pie-element/explicit-constructed-response-controller@3.5.0) (2022-12-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update libs ([441f403](https://github.com/pie-framework/pie-elements/commit/441f403870b7bec0d61fab58b8d93dbe0ead4c32))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **explicit-constructed-response:** added configurable validation PD-1706 ([327af4a](https://github.com/pie-framework/pie-elements/commit/327af4abe87af52389232c56afdd6e0dfd6c77f7))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [3.4.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.8...@pie-element/explicit-constructed-response-controller@3.4.9) (2022-05-16)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [3.4.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.7...@pie-element/explicit-constructed-response-controller@3.4.8) (2022-03-28)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [3.4.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.6...@pie-element/explicit-constructed-response-controller@3.4.7) (2022-03-08)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [3.4.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.2...@pie-element/explicit-constructed-response-controller@3.4.3) (2021-12-01)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## [3.4.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.4.1...@pie-element/explicit-constructed-response-controller@3.4.2) (2021-11-29)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## [3.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.3.3...@pie-element/explicit-constructed-response-controller@3.4.1) (2021-11-11)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# [3.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.3.2...@pie-element/explicit-constructed-response-controller@3.4.0) (2021-11-11)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Features
|
|
74
|
+
|
|
75
|
+
* **explicit-constructed-response:** Added a max limit of characters and adjusted the width PD-794 ([135f176](https://github.com/pie-framework/pie-elements/commit/135f176402187e9a6120b88768ae7fb0152ac418))
|
|
76
|
+
* **explicit-constructed-response:** Calculate maxChoicesLength if it's undefined. Fixed delete response area and choices bug. BREAKING CHANGE: add maxChoicesLength prop ([97431b9](https://github.com/pie-framework/pie-elements/commit/97431b9c3fbdafd84e040653c54d5f04bae16a1d))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## [3.3.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.3.2...@pie-element/explicit-constructed-response-controller@3.3.3) (2021-10-18)
|
|
84
|
+
|
|
85
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## [3.3.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.3.0...@pie-element/explicit-constructed-response-controller@3.3.2) (2021-08-05)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Bug Fixes
|
|
95
|
+
|
|
96
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# [3.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.2.16...@pie-element/explicit-constructed-response-controller@3.3.0) (2021-06-29)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Features
|
|
106
|
+
|
|
107
|
+
* Displayed a message when the item has one or more alternate answers - PD-167 ([#590](https://github.com/pie-framework/pie-elements/issues/590)) ([889d8b5](https://github.com/pie-framework/pie-elements/commit/889d8b578a915c997a95bd5cd4bdf18f53cc2b68))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
6
113
|
## [3.2.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@3.2.13...@pie-element/explicit-constructed-response-controller@3.2.16) (2021-03-03)
|
|
7
114
|
|
|
8
115
|
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _default = {
|
|
8
8
|
prompt: 'Which of these northern European countries are EU members?',
|
|
9
|
+
note: 'The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',
|
|
9
10
|
choiceMode: 'checkbox',
|
|
10
11
|
choicePrefix: 'numbers',
|
|
11
12
|
choices: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","choiceMode","choicePrefix","choices","value","label"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,4DADK;AAEbC,EAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["prompt","note","choiceMode","choicePrefix","choices","value","label"],"mappings":";;;;;;eAAe;AACbA,EAAAA,MAAM,EAAE,4DADK;AAEbC,EAAAA,IAAI,EAAE,0KAFO;AAGbC,EAAAA,UAAU,EAAE,UAHC;AAIbC,EAAAA,YAAY,EAAE,SAJD;AAKbC,EAAAA,OAAO,EAAE,CACP;AACEC,IAAAA,KAAK,EAAE,QADT;AAEEC,IAAAA,KAAK,EAAE;AAFT,GADO,EAKP;AACED,IAAAA,KAAK,EAAE,SADT;AAEEC,IAAAA,KAAK,EAAE;AAFT,GALO;AALI,C","sourcesContent":["export default {\n prompt: 'Which of these northern European countries are EU members?',\n note: 'The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',\n choiceMode: 'checkbox',\n choicePrefix: 'numbers',\n choices: [\n {\n value: 'sweden',\n label: 'Sweden',\n },\n {\n value: 'iceland',\n label: 'Iceland',\n },\n ],\n};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
CHANGED
|
@@ -5,12 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.getScore = exports.createCorrectResponseSession = void 0;
|
|
8
9
|
exports.model = model;
|
|
10
|
+
exports.normalize = void 0;
|
|
9
11
|
exports.outcome = outcome;
|
|
10
|
-
exports.
|
|
12
|
+
exports.validate = exports.prepareVal = exports.prepareChoice = void 0;
|
|
11
13
|
|
|
12
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
15
|
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
+
|
|
14
20
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
21
|
|
|
16
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -27,9 +33,9 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
27
33
|
|
|
28
34
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
29
35
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
37
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
39
|
|
|
34
40
|
var log = (0, _debug["default"])('explicit-constructed-response:controller');
|
|
35
41
|
|
|
@@ -63,6 +69,23 @@ var getFeedback = function getFeedback(value) {
|
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
return 'incorrect';
|
|
72
|
+
}; // also used in configure/src/markupUtils.js
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
var getAdjustedLength = function getAdjustedLength(length) {
|
|
76
|
+
if (length <= 2) {
|
|
77
|
+
return length + 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (length <= 4) {
|
|
81
|
+
return length + 3;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (length <= 6) {
|
|
85
|
+
return length + 4;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return length + 5;
|
|
66
89
|
};
|
|
67
90
|
|
|
68
91
|
var normalize = function normalize(question) {
|
|
@@ -86,7 +109,7 @@ exports.normalize = normalize;
|
|
|
86
109
|
function model(question, session, env) {
|
|
87
110
|
return new Promise( /*#__PURE__*/function () {
|
|
88
111
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve) {
|
|
89
|
-
var normalizedQuestion, defaultFeedback, _ref2, _ref2$value, value, preparChoiceFn, choices, feedback, out;
|
|
112
|
+
var normalizedQuestion, defaultFeedback, _ref2, _ref2$value, value, preparChoiceFn, choices, feedback, showNote, _normalizedQuestion$m, maxLengthPerChoice, maxLengthPerChoiceEnabled, undefinedLengths, out;
|
|
90
113
|
|
|
91
114
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
92
115
|
while (1) {
|
|
@@ -96,7 +119,7 @@ function model(question, session, env) {
|
|
|
96
119
|
// like: { label: 'test' }
|
|
97
120
|
if (question.choices) {
|
|
98
121
|
Object.keys(question.choices).forEach(function (key) {
|
|
99
|
-
question.choices[key] = question.choices[key].map(function (item, index) {
|
|
122
|
+
question.choices[key] = (question.choices[key] || []).map(function (item, index) {
|
|
100
123
|
if (!item.value) {
|
|
101
124
|
log('Choice does not contain "value" property, which is required.', item);
|
|
102
125
|
return _objectSpread({
|
|
@@ -133,6 +156,26 @@ function model(question, session, env) {
|
|
|
133
156
|
}, {});
|
|
134
157
|
}
|
|
135
158
|
|
|
159
|
+
showNote = false; // check if a choice has an alternate
|
|
160
|
+
|
|
161
|
+
Object.values(choices).forEach(function (choice) {
|
|
162
|
+
if (choice && choice.length > 1) {
|
|
163
|
+
showNote = true;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
_normalizedQuestion$m = normalizedQuestion.maxLengthPerChoice, maxLengthPerChoice = _normalizedQuestion$m === void 0 ? [] : _normalizedQuestion$m, maxLengthPerChoiceEnabled = normalizedQuestion.maxLengthPerChoiceEnabled;
|
|
167
|
+
undefinedLengths = !maxLengthPerChoice.length; // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
|
|
168
|
+
|
|
169
|
+
Object.values(choices).forEach(function (choice, index) {
|
|
170
|
+
var labelLengthsArr = (choice || []).map(function (choice) {
|
|
171
|
+
return (choice.label || '').length;
|
|
172
|
+
});
|
|
173
|
+
var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
|
|
174
|
+
|
|
175
|
+
if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
|
|
176
|
+
maxLengthPerChoice[index] = getAdjustedLength(length);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
136
179
|
out = {
|
|
137
180
|
disabled: env.mode !== 'gather',
|
|
138
181
|
mode: env.mode,
|
|
@@ -140,6 +183,13 @@ function model(question, session, env) {
|
|
|
140
183
|
markup: normalizedQuestion.markup,
|
|
141
184
|
choices: choices,
|
|
142
185
|
feedback: feedback,
|
|
186
|
+
env: env,
|
|
187
|
+
note: normalizedQuestion.note,
|
|
188
|
+
showNote: showNote,
|
|
189
|
+
maxLengthPerChoice: maxLengthPerChoice,
|
|
190
|
+
maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
|
|
191
|
+
displayType: normalizedQuestion.displayType,
|
|
192
|
+
playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,
|
|
143
193
|
responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined
|
|
144
194
|
};
|
|
145
195
|
|
|
@@ -153,7 +203,7 @@ function model(question, session, env) {
|
|
|
153
203
|
|
|
154
204
|
resolve(out);
|
|
155
205
|
|
|
156
|
-
case
|
|
206
|
+
case 16:
|
|
157
207
|
case "end":
|
|
158
208
|
return _context.stop();
|
|
159
209
|
}
|
|
@@ -250,4 +300,57 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
250
300
|
};
|
|
251
301
|
|
|
252
302
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
303
|
+
|
|
304
|
+
var validate = function validate() {
|
|
305
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
306
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
307
|
+
var choices = model.choices,
|
|
308
|
+
markup = model.markup;
|
|
309
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
310
|
+
var allChoicesErrors = {};
|
|
311
|
+
Object.entries(choices || {}).forEach(function (_ref4) {
|
|
312
|
+
var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
|
|
313
|
+
key = _ref5[0],
|
|
314
|
+
values = _ref5[1];
|
|
315
|
+
|
|
316
|
+
var reversedChoices = (0, _toConsumableArray2["default"])(values || []).reverse();
|
|
317
|
+
var choicesErrors = {};
|
|
318
|
+
reversedChoices.forEach(function (choice, index) {
|
|
319
|
+
var value = choice.value,
|
|
320
|
+
label = choice.label;
|
|
321
|
+
|
|
322
|
+
if (label === '' || label === '<div></div>') {
|
|
323
|
+
choicesErrors[value] = 'Content should not be empty.';
|
|
324
|
+
} else {
|
|
325
|
+
var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
|
|
326
|
+
return c.label === label;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
if (identicalAnswer) {
|
|
330
|
+
choicesErrors[value] = 'Content should be unique.';
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
if (!(0, _isEmpty["default"])(choicesErrors)) {
|
|
336
|
+
allChoicesErrors[key] = choicesErrors;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
var errors = {};
|
|
340
|
+
var nbOfResponseAreas = (markup.match(/\{\{(\d+)\}\}/g) || []).length;
|
|
341
|
+
|
|
342
|
+
if (nbOfResponseAreas > maxResponseAreas) {
|
|
343
|
+
errors.responseAreasError = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
|
|
344
|
+
} else if (nbOfResponseAreas < 1) {
|
|
345
|
+
errors.responseAreasError = 'There should be at least 1 response area defined.';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (!(0, _isEmpty["default"])(allChoicesErrors)) {
|
|
349
|
+
errors.choicesErrors = allChoicesErrors;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return errors;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
exports.validate = validate;
|
|
253
356
|
//# sourceMappingURL=index.js.map
|