@pie-element/inline-dropdown 4.7.1-beta.0 → 4.7.1-beta.1

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.
@@ -1 +0,0 @@
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","fontFamily","fontSize","typography","lineHeight","color","marginRight","rationaleLabel","display","whiteSpace","rationaleChoices","marginTop","panelDetails","flexContainer","alignItems","tooltip","maxWidth","errorText","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","prepareVal","html","tmp","value","textContent","innerText","Main","warning","open","newVal","props","onModelChanged","model","onModelChange","rationale","index","choice","indexOfChoice","choices","findIndex","elem","label","splice","teacherInstructions","slateMarkup","callback","setState","onClose","onConfirm","respAreaChoices","state","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","existingRespAreaChoices","obj","key","newRespAreaChoices","shouldWarn","newChoices","length","find","c","correct","remove","maxResponseAreaChoices","configuration","undefined","r","map","parseInt","filter","val","isNaN","push","respIndex","selectedIndex","nProps","newState","domNode","ReactDOM","findDOMNode","classes","onConfigurationChanged","imageSupport","uploadSoundSupport","choiceRationale","lockChoiceOrder","maxResponseAreas","maxImageWidth","maxImageHeight","partialScoring","settingsPanelDisabled","spellCheck","withRubric","choiceRationaleEnabled","errors","promptEnabled","rationaleEnabled","spellCheckEnabled","teacherInstructionsEnabled","toolbarEditorPosition","responseAreasError","responseAreaChoicesError","defaultImageMaxWidth","defaultImageMaxHeight","renderChoiceRationale","Object","keys","__html","onChoiceRationaleChanged","toolbarOpts","position","validationMessage","panelSettings","panelProperties","rubricEnabled","Settings","Properties","onTeacherInstructionsChanged","language","onPromptChanged","onRationaleChanged","ALL_PLUGINS","ref","window","editorRef","type","options","duplicates","respAreaToolbar","node","nodePath","editor","onToolbarDone","onAddChoice","onCheck","onRemoveChoice","data","onSelectChoice","onChange","onBlur","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAQA,MAAR,GAA0BC,kBAA1B,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAA0BD,kBAA1B,CAAgBC,KAAhB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,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,KADW;AAMzBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANiB;AAUzBO,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,KAViB;AAkBzBC,IAAAA,MAAM,EAAE;AACNH,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAD3B,KAlBiB;AAqBzBO,IAAAA,mBAAmB,EAAE;AACnBJ,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CADd;AAEn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ableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\nimport { AlertDialog, InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEqual from 'lodash/isEqual';\nimport isUndefined from 'lodash/isUndefined';\nimport isEmpty from 'lodash/isEmpty';\nimport reduce from 'lodash/reduce';\nimport max from 'lodash/max';\nimport { withStyles } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport ExpansionPanel from '@material-ui/core/ExpansionPanel';\nimport ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';\nimport ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Info from '@material-ui/icons/Info';\nimport InlineDropdownToolbar from './inline-dropdown-toolbar';\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 fontFamily: 'Cerebri Sans',\n fontSize: theme.typography.fontSize + 2,\n lineHeight: '19px',\n color: '#495B8F',\n marginRight: theme.spacing.unit,\n },\n rationaleLabel: {\n display: 'flex',\n whiteSpace: 'break-spaces',\n },\n rationaleChoices: {\n marginTop: theme.spacing.unit * 2,\n },\n panelDetails: {\n display: 'block',\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center',\n marginBottom: theme.spacing.unit,\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});\n\nconst createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\n div.innerHTML = (htmlString || '').trim();\n\n return div;\n};\n\nconst prepareVal = (html) => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\n};\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.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 = (callback) => {\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 } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, callback);\n },\n },\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 let shouldWarn = false;\n\n allRespAreas.forEach((el, index) => {\n const newChoices = existingRespAreaChoices[el.dataset.index] || [];\n\n if (newChoices.length < 2 || !newChoices.find((c) => c.correct)) {\n el.remove();\n shouldWarn = true;\n } else {\n newRespAreaChoices[index] = existingRespAreaChoices[el.dataset.index] || [];\n el.dataset.index = index;\n }\n });\n\n if (shouldWarn) {\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 } });\n },\n onConfirm: () => {\n this.setState({ warning: { open: false } }, () =>\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n }),\n );\n },\n },\n });\n } else {\n this.onModelChange({\n choices: cloneDeep(newRespAreaChoices),\n slateMarkup: domMarkup.innerHTML,\n });\n }\n };\n\n onAddChoice = (index, label) => {\n const { respAreaChoices } = this.state;\n const { maxResponseAreaChoices } = this.props.configuration;\n\n if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {\n this.setState({\n warning: {\n open: true,\n text: `There are only ${maxResponseAreaChoices} answers allowed per choice.`,\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\n if (!respAreaChoices[index]) {\n respAreaChoices[index] = [];\n }\n\n if ((respAreaChoices[index] || []).find((r) => prepareVal(r.label) === prepareVal(label))) {\n this.setState({\n warning: {\n open: true,\n text: 'Duplicate answers are not allowed.',\n onClose: undefined,\n onConfirm: () => {\n this.setState({ warning: { open: false } });\n },\n },\n });\n\n return;\n }\n\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 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 { classes, model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n choiceRationale = {},\n lockChoiceOrder = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n partialScoring = {},\n prompt = {},\n rationale = {},\n settingsPanelDisabled,\n spellCheck = {},\n teacherInstructions = {},\n withRubric = {},\n } = configuration || {};\n const {\n choiceRationaleEnabled,\n choices,\n errors,\n promptEnabled,\n rationaleEnabled,\n spellCheckEnabled,\n teacherInstructionsEnabled,\n toolbarEditorPosition,\n } = model || {};\n const { responseAreasError, responseAreaChoicesError } = 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 <div key={key} className={classes.rationaleChoices}>\n <ExpansionPanel>\n <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>\n <Typography className={classes.text}>{`Rationale for response area #${index + 1}`}</Typography>\n </ExpansionPanelSummary>\n\n <ExpansionPanelDetails className={classes.panelDetails}>\n {(choices[key] || []).map((choice) => (\n <InputContainer\n key={choice.label}\n label={\n <span\n className={classes.rationaleLabel}\n dangerouslySetInnerHTML={{\n __html: `${rationale.label} for ${choice.label} (${choice.correct ? 'correct' : 'incorrect'})`,\n }}\n />\n }\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={choice.rationale || ''}\n spellCheck={spellCheckEnabled}\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 />\n </InputContainer>\n ))}\n </ExpansionPanelDetails>\n </ExpansionPanel>\n </div>\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 };\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\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 {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\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'} />\n </Tooltip>\n </div>\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n ref={(ref) => {\n window.editorRef = ref;\n }}\n responseAreaProps={{\n type: 'inline-dropdown',\n options: {\n duplicates: true,\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, nodePath, editor, onToolbarDone) => {\n const { respAreaChoices } = this.state;\n\n return () => (\n <InlineDropdownToolbar\n onAddChoice={this.onAddChoice}\n onCheck={this.onCheck}\n onRemoveChoice={(index) => this.onRemoveChoice(node.data.index, index)}\n onSelectChoice={(index) => this.onSelectChoice(node.data.index, index)}\n editor={editor}\n node={node}\n nodePath={nodePath}\n onToolbarDone={onToolbarDone}\n choices={respAreaChoices[node.data.index]}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n />\n );\n },\n }}\n spellCheck={spellCheckEnabled}\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 {responseAreaChoicesError && <div className={classes.errorText}>{responseAreaChoicesError}</div>}\n\n <br />\n {choiceRationaleEnabled && renderChoiceRationale()}\n\n <AlertDialog\n open={warning.open}\n title=\"Warning\"\n text={warning.text}\n onClose={warning.onClose}\n onConfirm={warning.onConfirm}\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,70 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.removeUnwantedCharacters = exports.processMarkup = exports.createSlateMarkup = exports.createElementFromHTML = void 0;
9
-
10
- var _escape = _interopRequireDefault(require("lodash/escape"));
11
-
12
- // do not remove \t from \times, \triangle, \tan, \theta or \therefore
13
- var tSymbols = 'imes|riangle|an|heta|herefore'; // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
14
-
15
- var nSymbols = 'throot|parallel|cong|approx|eq|e|sim'; // match all \t and \n that are not part of math symbols that starts with \t or \n
16
-
17
- var matchTabAndNewLine = new RegExp("(\\t(?!".concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
18
-
19
- var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
20
- return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
21
- };
22
-
23
- exports.removeUnwantedCharacters = removeUnwantedCharacters;
24
-
25
- var createElementFromHTML = function createElementFromHTML(htmlString) {
26
- var div = document.createElement('div');
27
- div.innerHTML = htmlString.trim();
28
- return div;
29
- };
30
-
31
- exports.createElementFromHTML = createElementFromHTML;
32
-
33
- var processMarkup = function processMarkup(markup) {
34
- var newMarkup = removeUnwantedCharacters(markup);
35
- var slateMarkup = createElementFromHTML(newMarkup);
36
- slateMarkup.querySelectorAll('[data-type="inline_dropdown"]').forEach(function (s) {
37
- s.replaceWith("{{".concat(s.dataset.index, "}}"));
38
- });
39
- return slateMarkup.innerHTML;
40
- };
41
-
42
- exports.processMarkup = processMarkup;
43
- var REGEX = /\{\{(\d+)\}\}/g;
44
-
45
- var createSlateMarkup = function createSlateMarkup(markup, choices) {
46
- var newMarkup = removeUnwantedCharacters(markup);
47
-
48
- var createSelect = function createSelect(index) {
49
- var correctChoice = choices[index] && choices[index].find(function (c) {
50
- return c.correct;
51
- });
52
-
53
- if (!correctChoice || !correctChoice.value) {
54
- correctChoice = {
55
- id: '',
56
- value: '',
57
- label: ''
58
- };
59
- }
60
-
61
- return "<span data-type=\"inline_dropdown\" data-index=\"".concat(index, "\" data-value=\"").concat((0, _escape["default"])(correctChoice.label), "\"></span>");
62
- };
63
-
64
- return newMarkup.replace(REGEX, function (match, g) {
65
- return createSelect(g);
66
- });
67
- };
68
-
69
- exports.createSlateMarkup = createSlateMarkup;
70
- //# sourceMappingURL=markupUtils.js.map
@@ -1 +0,0 @@
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","querySelectorAll","forEach","s","replaceWith","dataset","index","REGEX","createSlateMarkup","choices","createSelect","correctChoice","find","c","correct","value","id","label","match","g"],"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,wBAAw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AI,CAACH,aAAD,IAAkB,CAACA,aAAa,CAACI,KAArC,EAA4C;AAC1CJ,MAAAA,aAAa,GAAG;AACdK,QAAAA,EAAE,EAAE,EADU;AAEdD,QAAAA,KAAK,EAAE,EAFO;AAGdE,QAAAA,KAAK,EAAE;AAHO,OAAhB;AAKD;;AAED,sEAAwDX,KAAxD,6BAA8E,wBAC5EK,aAAa,CAACM,KAD8D,CAA9E;AAGD,GAdD;;AAgBA,SAAOlB,SAAS,CAACT,OAAV,CAAkBiB,KAAlB,EAAyB,UAACW,KAAD,EAAQC,CAAR,EAAc;AAC5C,WAAOT,YAAY,CAACS,CAAD,CAAnB;AACD,GAFM,CAAP;AAGD,CArBM","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\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"],"file":"markupUtils.js"}
@@ -1,17 +0,0 @@
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
- maxResponseAreaChoices = config.maxResponseAreaChoices;
11
- var responseAreasMessage = '\nThere should be at least 1 ' + (maxResponseAreas ? "and at most ".concat(maxResponseAreas, " ") : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.' + (maxResponseAreaChoices ? "\nThere should be at most ".concat(maxResponseAreaChoices, " choices defined per response area.") : '');
12
- var message = 'Validation requirements:' + responseAreasMessage;
13
- return message;
14
- };
15
-
16
- exports.generateValidationMessage = generateValidationMessage;
17
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["generateValidationMessage","config","maxResponseAreas","maxResponseAreaChoices","responseAreasMessage","message"],"mappings":";;;;;;;AAAO,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,MAAD,EAAY;AACnD,MAAQC,gBAAR,GAAqDD,MAArD,CAAQC,gBAAR;AAAA,MAA0BC,sBAA1B,GAAqDF,MAArD,CAA0BE,sBAA1B;AAEA,MAAMC,oBAAoB,GACxB,mCACCF,gBAAgB,yBAAkBA,gBAAlB,SAAwC,EADzD,IAEA,eAFA,IAGCA,gBAAgB,GAAG,GAAH,GAAS,EAH1B,IAIA,WAJA,IAKCC,sBAAsB,uCACUA,sBADV,2CAEnB,EAPJ,CADF;AAUA,MAAME,OAAO,GAAG,6BAA6BD,oBAA7C;AAEA,SAAOC,OAAP;AACD,CAhBM","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"],"file":"utils.js"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _default = {
8
- choices: {}
9
- };
10
- exports["default"] = _default;
11
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/defaults.js"],"names":["choices"],"mappings":";;;;;;eAAe;AACbA,EAAAA,OAAO,EAAE;AADI,C","sourcesContent":["export default {\n choices: {},\n};\n"],"file":"defaults.js"}
@@ -1,345 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getScore = exports.createCorrectResponseSession = void 0;
9
- exports.model = model;
10
- exports.normalize = void 0;
11
- exports.outcome = outcome;
12
- exports.validate = void 0;
13
-
14
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
-
16
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
-
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
- var _map = _interopRequireDefault(require("lodash/map"));
21
-
22
- var _reduce = _interopRequireDefault(require("lodash/reduce"));
23
-
24
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
25
-
26
- var _controllerUtils = require("@pie-lib/controller-utils");
27
-
28
- var _utils = require("./utils");
29
-
30
- 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
-
32
- 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
-
34
- var getFeedback = function getFeedback(correct) {
35
- if (correct) {
36
- return 'correct';
37
- }
38
-
39
- return 'incorrect';
40
- };
41
-
42
- var normalize = function normalize(question) {
43
- return _objectSpread({
44
- promptEnabled: true,
45
- rationaleEnabled: true,
46
- teacherInstructionsEnabled: true,
47
- studentInstructionsEnabled: true,
48
- choiceRationaleEnabled: true
49
- }, question);
50
- };
51
- /**
52
- *
53
- * @param {*} question
54
- * @param {*} session
55
- * @param {*} env
56
- * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
57
- */
58
-
59
-
60
- exports.normalize = normalize;
61
-
62
- function model(question, session, env, updateSession) {
63
- return new Promise( /*#__PURE__*/function () {
64
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve) {
65
- var normalizedQuestion, _ref2, _ref2$value, value, choices, feedback, allCorrectResponses, respAreaLength, correctResponses, _loop, i, _ret, lockChoiceOrder, keys, _i, key, teacherInstructions, rationale, choicesWillNullRationales, out;
66
-
67
- return _regenerator["default"].wrap(function _callee$(_context) {
68
- while (1) {
69
- switch (_context.prev = _context.next) {
70
- case 0:
71
- normalizedQuestion = normalize(question);
72
- _ref2 = session || {}, _ref2$value = _ref2.value, value = _ref2$value === void 0 ? {} : _ref2$value;
73
- choices = (0, _reduce["default"])(normalizedQuestion.choices, function (obj, area, key) {
74
- obj[key] = (0, _map["default"])(area, function (choice) {
75
- return choice;
76
- });
77
- return obj;
78
- }, {});
79
- feedback = {};
80
-
81
- if (!(env.mode === 'evaluate')) {
82
- _context.next = 17;
83
- break;
84
- }
85
-
86
- allCorrectResponses = (0, _utils.getAllCorrectResponses)(normalizedQuestion);
87
- respAreaLength = Object.keys(allCorrectResponses).length;
88
- correctResponses = 0;
89
-
90
- _loop = function _loop(i) {
91
- var result = (0, _reduce["default"])(allCorrectResponses, function (obj, choices, key) {
92
- var answer = value && value[key] || '';
93
- var correctChoice = choices[i] || '';
94
- var isCorrect = answer && correctChoice && correctChoice === answer;
95
- obj.feedback[key] = getFeedback(isCorrect);
96
-
97
- if (isCorrect) {
98
- obj.correctResponses += 1;
99
- }
100
-
101
- return obj;
102
- }, {
103
- correctResponses: 0,
104
- feedback: {}
105
- });
106
-
107
- if (result.correctResponses >= correctResponses) {
108
- correctResponses = result.correctResponses;
109
- feedback = result.feedback;
110
- }
111
-
112
- if (result.correctResponses === respAreaLength) {
113
- return "break";
114
- }
115
- };
116
-
117
- i = 0;
118
-
119
- case 10:
120
- if (!(i < respAreaLength)) {
121
- _context.next = 17;
122
- break;
123
- }
124
-
125
- _ret = _loop(i);
126
-
127
- if (!(_ret === "break")) {
128
- _context.next = 14;
129
- break;
130
- }
131
-
132
- return _context.abrupt("break", 17);
133
-
134
- case 14:
135
- i++;
136
- _context.next = 10;
137
- break;
138
-
139
- case 17:
140
- lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
141
-
142
- if (lockChoiceOrder) {
143
- _context.next = 29;
144
- break;
145
- }
146
-
147
- keys = Object.keys(choices);
148
- _i = 0;
149
-
150
- case 21:
151
- if (!(_i < keys.length)) {
152
- _context.next = 29;
153
- break;
154
- }
155
-
156
- key = keys[_i];
157
- _context.next = 25;
158
- return (0, _controllerUtils.getShuffledChoices)(choices[key], session, updateSession, 'value');
159
-
160
- case 25:
161
- choices[key] = _context.sent;
162
-
163
- case 26:
164
- _i++;
165
- _context.next = 21;
166
- break;
167
-
168
- case 29:
169
- teacherInstructions = null;
170
- rationale = null;
171
- choicesWillNullRationales = (Object.keys(choices) || []).reduce(function (acc, currentValue) {
172
- acc[currentValue] = (choices[currentValue] || []).map(function (choice) {
173
- return _objectSpread(_objectSpread({}, choice), {}, {
174
- rationale: null
175
- });
176
- });
177
- return acc;
178
- }, {});
179
-
180
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
181
- rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
182
- teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
183
- choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;
184
- } else {
185
- rationale = null;
186
- teacherInstructions = null;
187
- choices = choicesWillNullRationales;
188
- }
189
-
190
- out = {
191
- disabled: env.mode !== 'gather',
192
- mode: env.mode,
193
- prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
194
- displayType: normalizedQuestion.displayType,
195
- markup: normalizedQuestion.markup,
196
- choices: choices,
197
- feedback: feedback,
198
- responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
199
- rationale: rationale,
200
- teacherInstructions: teacherInstructions
201
- };
202
- resolve(out);
203
-
204
- case 35:
205
- case "end":
206
- return _context.stop();
207
- }
208
- }
209
- }, _callee);
210
- }));
211
-
212
- return function (_x) {
213
- return _ref.apply(this, arguments);
214
- };
215
- }());
216
- }
217
-
218
- var getScore = function getScore(config, session) {
219
- var _ref3 = session || {},
220
- _ref3$value = _ref3.value,
221
- value = _ref3$value === void 0 ? {} : _ref3$value;
222
-
223
- var maxScore = config && config.choices ? Object.keys(config.choices).length : 0;
224
- var allCorrectResponses = (0, _utils.getAllCorrectResponses)(config);
225
- var correctCount = 0;
226
-
227
- var _loop2 = function _loop2(i) {
228
- var result = (0, _reduce["default"])(allCorrectResponses, function (total, choices, key) {
229
- var answer = value && value[key] || '';
230
- var correctChoice = choices[i] || '';
231
-
232
- if (correctChoice && answer && correctChoice === answer) {
233
- return total;
234
- }
235
-
236
- return total - 1;
237
- }, maxScore);
238
-
239
- if (result > correctCount) {
240
- correctCount = result;
241
- }
242
-
243
- if (result === maxScore) {
244
- return "break";
245
- }
246
- };
247
-
248
- for (var i = 0; i < maxScore; i++) {
249
- var _ret2 = _loop2(i);
250
-
251
- if (_ret2 === "break") break;
252
- }
253
-
254
- var str = (correctCount / maxScore).toFixed(2);
255
- return parseFloat(str);
256
- };
257
- /**
258
- *
259
- * The score is partial by default for checkbox mode, allOrNothing for radio mode.
260
- * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =
261
- * false. the value in `env` will override the value in `model`.
262
- * @param {Object} model - the main model
263
- * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)
264
- * @param {*} session
265
- * @param {Object} env
266
- * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides
267
- * `model.partialScoring`.
268
- */
269
-
270
-
271
- exports.getScore = getScore;
272
-
273
- function outcome(model, session) {
274
- var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
275
- return new Promise(function (resolve) {
276
- if (!session || (0, _isEmpty["default"])(session)) {
277
- resolve({
278
- score: 0,
279
- empty: true
280
- });
281
- }
282
-
283
- var partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
284
-
285
- var score = getScore(model, session);
286
- resolve({
287
- score: partialScoringEnabled ? score : Math.floor(score),
288
- empty: false
289
- });
290
- });
291
- }
292
-
293
- var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
294
- return new Promise(function (resolve) {
295
- if (env.mode !== 'evaluate' && env.role === 'instructor') {
296
- var choices = question.choices;
297
- var _value = {};
298
-
299
- if (choices) {
300
- Object.keys(choices).forEach(function (key, i) {
301
- var correctChoices = choices[key] && choices[key].filter(function (c) {
302
- return c.correct;
303
- });
304
- _value[i] = correctChoices && correctChoices[0].value;
305
- });
306
- }
307
-
308
- resolve({
309
- id: '1',
310
- value: _value
311
- });
312
- } else {
313
- resolve(null);
314
- }
315
- });
316
- };
317
-
318
- exports.createCorrectResponseSession = createCorrectResponseSession;
319
-
320
- var validate = function validate() {
321
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
322
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
323
- var markup = model.markup,
324
- choices = model.choices;
325
- var maxResponseAreas = config.maxResponseAreas,
326
- maxResponseAreaChoices = config.maxResponseAreaChoices;
327
- var errors = {};
328
- var nbOfResponseAreas = ((markup || '').match(/\{\{(\d+)\}\}/g) || []).length;
329
-
330
- if (nbOfResponseAreas > maxResponseAreas) {
331
- errors.responseAreasError = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
332
- } else if (nbOfResponseAreas < 1) {
333
- errors.responseAreasError = 'There should be defined at least 1 response area.';
334
- }
335
-
336
- (Object.keys(choices) || []).forEach(function (choiceKey) {
337
- if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {
338
- errors.responseAreaChoicesError = "No more than ".concat(maxResponseAreaChoices, " choices per response area should be defined.");
339
- }
340
- });
341
- return errors;
342
- };
343
-
344
- exports.validate = validate;
345
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["getFeedback","correct","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","choiceRationaleEnabled","model","session","env","updateSession","Promise","resolve","normalizedQuestion","value","choices","obj","area","key","choice","feedback","mode","allCorrectResponses","respAreaLength","Object","keys","length","correctResponses","i","result","answer","correctChoice","isCorrect","lockChoiceOrder","teacherInstructions","rationale","choicesWillNullRationales","reduce","acc","currentValue","map","role","out","disabled","prompt","displayType","markup","responseCorrect","getScore","undefined","config","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","score","empty","partialScoringEnabled","partialScoring","enabled","Math","floor","createCorrectResponseSession","forEach","correctChoices","filter","c","id","validate","maxResponseAreas","maxResponseAreaChoices","errors","nbOfResponseAreas","match","responseAreasError","choiceKey","responseAreaChoicesError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,OAAD,EAAa;AAC/B,MAAIA,OAAJ,EAAa;AACX,WAAO,SAAP;AACD;;AAED,SAAO,WAAP;AACD,CAND;;AAQO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD;AAAA;AACvBC,IAAAA,aAAa,EAAE,IADQ;AAEvBC,IAAAA,gBAAgB,EAAE,IAFK;AAGvBC,IAAAA,0BAA0B,EAAE,IAHL;AAIvBC,IAAAA,0BAA0B,EAAE,IAJL;AAKvBC,IAAAA,sBAAsB,EAAE;AALD,KAMpBL,QANoB;AAAA,CAAlB;AASP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASM,KAAT,CAAeN,QAAf,EAAyBO,OAAzB,EAAkCC,GAAlC,EAAuCC,aAAvC,EAAsD;AAC3D,SAAO,IAAIC,OAAJ;AAAA,6FAAY,iBAAOC,OAAP;AAAA;;AAAA;AAAA;AAAA;AAAA;AACXC,cAAAA,kBADW,GACUb,SAAS,CAACC,QAAD,CADnB;AAAA,sBAEMO,OAAO,IAAI,EAFjB,sBAETM,KAFS,EAETA,KAFS,4BAED,EAFC;AAGbC,cAAAA,OAHa,GAGH,wBACZF,kBAAkB,CAACE,OADP,EAEZ,UAACC,GAAD,EAAMC,IAAN,EAAYC,GAAZ,EAAoB;AAClBF,gBAAAA,GAAG,CAACE,GA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G,iBAAiB,GAAG,CAAxB,EAA2B;AAChCD,IAAAA,MAAM,CAACG,kBAAP,GAA4B,mDAA5B;AACD;;AAED,GAACrD,MAAM,CAACC,IAAP,CAAYV,OAAZ,KAAwB,EAAzB,EAA6BmD,OAA7B,CAAqC,UAACY,SAAD,EAAe;AAClD,QAAI/D,OAAO,CAAC+D,SAAD,CAAP,IAAsB/D,OAAO,CAAC+D,SAAD,CAAP,CAAmBpD,MAAnB,GAA4B+C,sBAAtD,EAA8E;AAC5EC,MAAAA,MAAM,CAACK,wBAAP,0BAAkDN,sBAAlD;AACD;AACF,GAJD;AAMA,SAAOC,MAAP;AACD,CApBM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport isEmpty from 'lodash/isEmpty';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\n\nimport { getAllCorrectResponses } from './utils';\n\nconst getFeedback = (correct) => {\n if (correct) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = (question) => ({\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n choiceRationaleEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const { value = {} } = session || {};\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, (choice) => choice);\n\n return obj;\n },\n {},\n );\n\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n const respAreaLength = Object.keys(allCorrectResponses).length;\n let correctResponses = 0;\n\n for (let i = 0; i < respAreaLength; i++) {\n const result = reduce(\n allCorrectResponses,\n (obj, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n const isCorrect = answer && correctChoice && correctChoice === answer;\n\n obj.feedback[key] = getFeedback(isCorrect);\n\n if (isCorrect) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (result.correctResponses >= correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n\n if (result.correctResponses === respAreaLength) {\n break;\n }\n }\n }\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n const keys = Object.keys(choices);\n let i;\n\n for (i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n choices[key] = await getShuffledChoices(choices[key], session, updateSession, 'value');\n }\n }\n\n let teacherInstructions = null;\n let rationale = null;\n\n const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => {\n acc[currentValue] = (choices[currentValue] || []).map((choice) => ({\n ...choice,\n rationale: null,\n }));\n\n return acc;\n }, {});\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n\n choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales;\n } else {\n rationale = null;\n teacherInstructions = null;\n choices = choicesWillNullRationales;\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n displayType: normalizedQuestion.displayType,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,\n rationale,\n teacherInstructions,\n };\n\n resolve(out);\n });\n}\n\nexport const getScore = (config, session) => {\n const { value = {} } = session || {};\n const maxScore = config && config.choices ? Object.keys(config.choices).length : 0;\n const allCorrectResponses = getAllCorrectResponses(config);\n let correctCount = 0;\n\n for (let i = 0; i < maxScore; i++) {\n const result = reduce(\n allCorrectResponses,\n (total, choices, key) => {\n const answer = (value && value[key]) || '';\n const correctChoice = choices[i] || '';\n\n if (correctChoice && answer && correctChoice === answer) {\n return total;\n }\n\n return total - 1;\n },\n maxScore,\n );\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = (correctCount / maxScore).toFixed(2);\n\n return parseFloat(str);\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({\n score: partialScoringEnabled ? score : Math.floor(score),\n empty: false,\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n if (choices) {\n Object.keys(choices).forEach((key, i) => {\n const correctChoices = choices[key] && choices[key].filter((c) => c.correct);\n\n value[i] = correctChoices && correctChoices[0].value;\n });\n }\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { markup, choices } = model;\n const { maxResponseAreas, maxResponseAreaChoices } = config;\n const errors = {};\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be defined at least 1 response area.';\n }\n\n (Object.keys(choices) || []).forEach((choiceKey) => {\n if (choices[choiceKey] && choices[choiceKey].length > maxResponseAreaChoices) {\n errors.responseAreaChoicesError = `No more than ${maxResponseAreaChoices} choices per response area should be defined.`;\n }\n });\n\n return errors;\n};\n"],"file":"index.js"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getAllCorrectResponses = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _forEach = _interopRequireDefault(require("lodash/forEach"));
13
-
14
- var getAllCorrectResponses = function getAllCorrectResponses(_ref) {
15
- var choices = _ref.choices,
16
- alternateResponse = _ref.alternateResponse;
17
- alternateResponse = alternateResponse || {};
18
- var correctAnswers = {};
19
- (0, _forEach["default"])(choices, function (respArea, key) {
20
- if (!correctAnswers[key]) {
21
- correctAnswers[key] = [];
22
- }
23
-
24
- if (respArea) {
25
- respArea.forEach(function (choice) {
26
- if (choice.correct) {
27
- correctAnswers[key].push(choice.value);
28
-
29
- if (alternateResponse[key]) {
30
- correctAnswers[key] = [].concat((0, _toConsumableArray2["default"])(correctAnswers[key]), (0, _toConsumableArray2["default"])(alternateResponse[key]));
31
- }
32
- }
33
- });
34
- }
35
- });
36
- return correctAnswers;
37
- };
38
-
39
- exports.getAllCorrectResponses = getAllCorrectResponses;
40
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["getAllCorrectResponses","choices","alternateResponse","correctAnswers","respArea","key","forEach","choice","correct","push","value"],"mappings":";;;;;;;;;;;AAAA;;AAEO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,OAAoC;AAAA,MAAjCC,OAAiC,QAAjCA,OAAiC;AAAA,MAAxBC,iBAAwB,QAAxBA,iBAAwB;AACxEA,EAAAA,iBAAiB,GAAGA,iBAAiB,IAAI,EAAzC;AACA,MAAMC,cAAc,GAAG,EAAvB;AAEA,2BAAQF,OAAR,EAAiB,UAACG,QAAD,EAAWC,GAAX,EAAmB;AAClC,QAAI,CAACF,cAAc,CAACE,GAAD,CAAnB,EAA0B;AACxBF,MAAAA,cAAc,CAACE,GAAD,CAAd,GAAsB,EAAtB;AACD;;AAED,QAAID,QAAJ,EAAc;AACZA,MAAAA,QAAQ,CAACE,OAAT,CAAiB,UAACC,MAAD,EAAY;AAC3B,YAAIA,MAAM,CAACC,OAAX,EAAoB;AAClBL,UAAAA,cAAc,CAACE,GAAD,CAAd,CAAoBI,IAApB,CAAyBF,MAAM,CAACG,KAAhC;;AAEA,cAAIR,iBAAiB,CAACG,GAAD,CAArB,EAA4B;AAC1BF,YAAAA,cAAc,CAACE,GAAD,CAAd,iDAA0BF,cAAc,CAACE,GAAD,CAAxC,uCAAkDH,iBAAiB,CAACG,GAAD,CAAnE;AACD;AACF;AACF,OARD;AASD;AACF,GAhBD;AAkBA,SAAOF,cAAP;AACD,CAvBM","sourcesContent":["import forEach from 'lodash/forEach';\n\nexport const getAllCorrectResponses = ({ choices, alternateResponse }) => {\n alternateResponse = alternateResponse || {};\n const correctAnswers = {};\n\n forEach(choices, (respArea, key) => {\n if (!correctAnswers[key]) {\n correctAnswers[key] = [];\n }\n\n if (respArea) {\n respArea.forEach((choice) => {\n if (choice.correct) {\n correctAnswers[key].push(choice.value);\n\n if (alternateResponse[key]) {\n correctAnswers[key] = [...correctAnswers[key], ...alternateResponse[key]];\n }\n }\n });\n }\n });\n\n return correctAnswers;\n};\n"],"file":"utils.js"}