@pie-element/drag-in-the-blank 9.0.0-next.43 → 9.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/index.js +6 -6
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +0 -1
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +2 -3
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/package.json +8 -8
- package/controller/lib/index.js +2 -2
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +3 -5
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +3 -3
- package/package.json +12 -9
package/configure/lib/index.js
CHANGED
|
@@ -12,8 +12,8 @@ var _client = require("react-dom/client");
|
|
|
12
12
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
13
13
|
var _main = _interopRequireDefault(require("./main"));
|
|
14
14
|
var _debug = _interopRequireDefault(require("debug"));
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var _lodashEs = require("lodash-es");
|
|
16
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
17
17
|
var _markupUtils = require("./markupUtils");
|
|
18
18
|
const log = (0, _debug.default)('multiple-choice:configure');
|
|
19
19
|
class DragInTheBlank extends HTMLElement {
|
|
@@ -21,20 +21,20 @@ class DragInTheBlank extends HTMLElement {
|
|
|
21
21
|
super();
|
|
22
22
|
this._root = null;
|
|
23
23
|
this._model = DragInTheBlank.prepareModel();
|
|
24
|
-
this._configuration =
|
|
24
|
+
this._configuration = _defaults.default.configuration;
|
|
25
25
|
this.onModelChanged = this.onModelChanged.bind(this);
|
|
26
26
|
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
27
27
|
}
|
|
28
28
|
set model(m) {
|
|
29
29
|
const formModel = {
|
|
30
30
|
...m,
|
|
31
|
-
markup: `<div>${m.markup ||
|
|
31
|
+
markup: `<div>${m.markup || _defaults.default.model.markup}</div>`
|
|
32
32
|
};
|
|
33
33
|
this._model = DragInTheBlank.prepareModel(formModel);
|
|
34
34
|
this._render();
|
|
35
35
|
}
|
|
36
36
|
set configuration(c) {
|
|
37
|
-
const newConfiguration = (0,
|
|
37
|
+
const newConfiguration = (0, _lodashEs.defaults)(c, _defaults.default.configuration);
|
|
38
38
|
this._configuration = newConfiguration;
|
|
39
39
|
|
|
40
40
|
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
@@ -129,7 +129,7 @@ class DragInTheBlank extends HTMLElement {
|
|
|
129
129
|
exports.default = DragInTheBlank;
|
|
130
130
|
(0, _defineProperty2.default)(DragInTheBlank, "prepareModel", (model = {}) => {
|
|
131
131
|
const joinedObj = {
|
|
132
|
-
...
|
|
132
|
+
..._defaults.default.model,
|
|
133
133
|
...model
|
|
134
134
|
};
|
|
135
135
|
const slateMarkup = model.slateMarkup || (0, _markupUtils.createSlateMarkup)(joinedObj.markup, joinedObj.choices, joinedObj.correctResponse);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_mathRendering","_main","_debug","_defaults","_defaults2","_markupUtils","log","debug","DragInTheBlank","HTMLElement","constructor","_root","_model","prepareModel","_configuration","sensibleDefaults","configuration","onModelChanged","bind","onConfigurationChanged","model","m","formModel","markup","_render","c","newConfiguration","defaults","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","disableSidePanel","s","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","createRoot","render","setTimeout","renderMath","disconnectedCallback","unmount","exports","default","_defineProperty2","joinedObj","slateMarkup","createSlateMarkup","choices","correctResponse","processedMarkup","processMarkup"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport Main from './main';\nimport debug from 'debug';\nimport defaults from 'lodash/defaults';\n\nimport sensibleDefaults from './defaults';\nimport { processMarkup, createSlateMarkup } from './markupUtils';\n\nconst log = debug('multiple-choice:configure');\n\nexport default class DragInTheBlank extends HTMLElement {\n static prepareModel = (model = {}) => {\n const joinedObj = {\n ...sensibleDefaults.model,\n ...model,\n };\n const slateMarkup =\n model.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.choices, joinedObj.correctResponse);\n const processedMarkup = processMarkup(slateMarkup);\n\n return {\n ...joinedObj,\n slateMarkup,\n markup: processedMarkup.markup,\n correctResponse: processedMarkup.correctResponse,\n };\n };\n\n constructor() {\n super();\n this._root = null;\n this._model = DragInTheBlank.prepareModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(m) {\n const formModel = {\n ...m,\n markup: `<div>${m.markup || sensibleDefaults.model.markup}</div>`,\n };\n\n this._model = DragInTheBlank.prepareModel(formModel);\n this._render();\n }\n\n set configuration(c) {\n const newConfiguration = defaults(c, sensibleDefaults.configuration);\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = DragInTheBlank.prepareModel(m);\n this._render();\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n\n setTimeout(() => {\n renderMath(this);\n }, 0);\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,c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ZC,WAAW;IACXrD,MAAM,EAAEyD,eAAe,CAACzD,MAAM;IAC9BwD,eAAe,EAAEC,eAAe,CAACD;EACnC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_mathRendering","_main","_debug","_lodashEs","_defaults","_markupUtils","log","debug","DragInTheBlank","HTMLElement","constructor","_root","_model","prepareModel","_configuration","sensibleDefaults","configuration","onModelChanged","bind","onConfigurationChanged","model","m","formModel","markup","_render","c","newConfiguration","defaults","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","disableSidePanel","s","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","createRoot","render","setTimeout","renderMath","disconnectedCallback","unmount","exports","default","_defineProperty2","joinedObj","slateMarkup","createSlateMarkup","choices","correctResponse","processedMarkup","processMarkup"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport Main from './main';\nimport debug from 'debug';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\nimport { processMarkup, createSlateMarkup } from './markupUtils';\n\nconst log = debug('multiple-choice:configure');\n\nexport default class DragInTheBlank extends HTMLElement {\n static prepareModel = (model = {}) => {\n const joinedObj = {\n ...sensibleDefaults.model,\n ...model,\n };\n const slateMarkup =\n model.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.choices, joinedObj.correctResponse);\n const processedMarkup = processMarkup(slateMarkup);\n\n return {\n ...joinedObj,\n slateMarkup,\n markup: processedMarkup.markup,\n correctResponse: processedMarkup.correctResponse,\n };\n };\n\n constructor() {\n super();\n this._root = null;\n this._model = DragInTheBlank.prepareModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(m) {\n const formModel = {\n ...m,\n markup: `<div>${m.markup || sensibleDefaults.model.markup}</div>`,\n };\n\n this._model = DragInTheBlank.prepareModel(formModel);\n this._render();\n }\n\n set configuration(c) {\n const newConfiguration = defaults(c, sensibleDefaults.configuration);\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = DragInTheBlank.prepareModel(m);\n this._render();\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n\n setTimeout(() => {\n renderMath(this);\n }, 0);\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,SAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAEA,MAAMU,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE/B,MAAMC,cAAc,SAASC,WAAW,CAAC;EAkBtDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,MAAM,GAAGJ,cAAc,CAACK,YAAY,CAAC,CAAC;IAC3C,IAAI,CAACC,cAAc,GA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ACwD,MAAM,CAACT,OAAO,CAAC;IAE1BU,UAAU,CAAC,MAAM;MACf,IAAAC,yBAAU,EAAC,IAAI,CAAC;IAClB,CAAC,EAAE,CAAC,CAAC;EACP;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAAC3D,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAAC4D,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAjE,cAAA;AAAA,IAAAkE,gBAAA,CAAAD,OAAA,EAjJoBjE,cAAc,kBACX,CAACY,KAAK,GAAG,CAAC,CAAC,KAAK;EACpC,MAAMuD,SAAS,GAAG;IAChB,GAAG5D,iBAAgB,CAACK,KAAK;IACzB,GAAGA;EACL,CAAC;EACD,MAAMwD,WAAW,GACfxD,KAAK,CAACwD,WAAW,IAAI,IAAAC,8BAAiB,EAACF,SAAS,CAACpD,MAAM,EAAEoD,SAAS,CAACG,OAAO,EAAEH,SAAS,CAACI,eAAe,CAAC;EACxG,MAAMC,eAAe,GAAG,IAAAC,0BAAa,EAACL,WAAW,CAAC;EAElD,OAAO;IACL,GAAGD,SAAS;IACZC,WAAW;IACXrD,MAAM,EAAEyD,eAAe,CAACzD,MAAM;IAC9BwD,eAAe,EAAEC,eAAe,CAACD;EACnC,CAAC;AACH,CAAC","ignoreList":[]}
|
package/configure/lib/main.js
CHANGED
|
@@ -18,7 +18,6 @@ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
|
18
18
|
var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
|
|
19
19
|
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
20
20
|
var _core = require("@dnd-kit/core");
|
|
21
|
-
var _modifiers = require("@dnd-kit/modifiers");
|
|
22
21
|
var _choice = _interopRequireDefault(require("./choice"));
|
|
23
22
|
var _choices = _interopRequireDefault(require("./choices"));
|
|
24
23
|
var _markupUtils = require("./markupUtils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_renderUi","_drag","_mathRendering","_styles","_Typography","_Info","_Tooltip","_core","_modifiers","_choice","_choices","_markupUtils","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DragPreviewWrapper","React","Component","constructor","args","_defineProperty2","createRef","componentDidMount","setTimeout","containerRef","current","renderMath","componentDidUpdate","render","createElement","ref","props","children","dropdown","toggle","Panel","settings","StyledInputContainer","styled","InputContainer","theme","width","paddingTop","spacing","marginBottom","StyledMarkup","minHeight","paddingBottom","StyledText","Typography","fontSize","typography","StyledTooltip","Tooltip","whiteSpace","maxWidth","ErrorText","color","palette","error","main","FlexContainer","display","alignItems","Main","activeDragItem","newVal","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","correctResponse","markup","createSlateMarkup","markupRef","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","addChoice","baseInputConfiguration","contentDimensions","duplicates","partialScoring","lockChoiceOrder","choicesPosition","spellCheck","settingsPanelDisabled","maxChoices","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","language","languageChoices","maxLength","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","spellCheckEnabled","toolbarEditorPosition","errors","extraCSSRules","choicesError","correctResponseError","promptError","rationaleError","responseAreasError","teacherInstructionsError","validationMessage","generateValidationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","enabled","options","panelProperties","rubricEnabled","getPluginProps","assign","onDragEnd","active","over","drag","data","type","markupBounds","getBoundingClientRect","dropX","rect","translated","x","dropY","y","isOutsideMarkup","left","right","top","bottom","onRemove","setState","drop","onDrop","onDragStart","event","renderDragOverlay","state","value","choice","find","c","id","DragProvider","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onModelChange","onChangeConfiguration","groups","Settings","Properties","onChange","onTeacherInstructionsChanged","nonEmpty","pluginProps","inputConfiguration","languageCharactersProps","onPromptChanged","disableUnderline","component","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","activePlugins","ALL_PLUGINS","responseAreaProps","onMarkupChanged","disableImageAlignmentButtons","onResponsesChanged","onRationaleChanged","DragOverlay","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { layout, settings } from '@pie-lib/config-ui';\nimport { InputContainer } from '@pie-lib/render-ui';\nimport { DragProvider } from '@pie-lib/drag';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\nimport { DragOverlay } from '@dnd-kit/core';\nimport { restrictToFirstScrollableAncestor } from '@dnd-kit/modifiers';\n\nimport Choice from './choice';\nimport Choices from './choices';\nimport { createSlateMarkup } from './markupUtils';\nimport { generateValidationMessage } from '../utils';\n\nclass DragPreviewWrapper extends React.Component {\n containerRef = React.createRef();\n\n componentDidMount() {\n // Render math in the drag preview after it mounts\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n componentDidUpdate() {\n // Re-render math when the drag preview updates\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n render() {\n return <div ref={this.containerRef}>{this.props.children}</div>;\n }\n}\n\nconst { dropdown, toggle, Panel } = settings;\n\nconst StyledInputContainer = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst StyledMarkup = styled('div')(({ theme }) => ({\n minHeight: '235px',\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(2),\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '235px',\n },\n}));\n\nconst StyledText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {\n activeDragItem: null,\n };\n\n constructor(props) {\n super(props);\n this.markupRef = React.createRef();\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 this.props.onModelChanged({\n ...this.props.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 const {\n model: { correctResponse, markup },\n } = this.props;\n const slateMarkup = createSlateMarkup(markup, choices, correctResponse);\n\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup,\n choices,\n });\n };\n\n render() {\n const { model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n addChoice = {},\n baseInputConfiguration = {},\n contentDimensions = {},\n duplicates = {},\n prompt = {},\n partialScoring = {},\n lockChoiceOrder = {},\n rationale = {},\n teacherInstructions = {},\n choicesPosition = {},\n spellCheck = {},\n settingsPanelDisabled,\n maxChoices,\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n maxLength = {},\n } = configuration || {};\n const {\n rationaleEnabled,\n promptEnabled,\n teacherInstructionsEnabled,\n spellCheckEnabled,\n toolbarEditorPosition,\n errors,\n extraCSSRules,\n } = model || {};\n\n const {\n choicesError,\n correctResponseError,\n prompt: promptError,\n rationale: rationaleError,\n responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n duplicates: duplicates.settings && toggle(duplicates.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n choicesPosition: choicesPosition.settings && dropdown(choicesPosition.label, ['above', 'below', 'left', 'right']),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n const getPluginProps = (props) => {\n return Object.assign(\n {\n ...baseInputConfiguration,\n },\n props || {},\n );\n };\n\n\n const onDragEnd = ({ active, over }) => {\n // check if item was placed as a correct answer and then dropped outside of StyledMarkup component\n if (active && !over) {\n const drag = active.data.current;\n\n if (drag && drag.type === 'drag-in-the-blank-placed-choice') {\n if (this.markupRef.current) {\n const markupBounds = this.markupRef.current.getBoundingClientRect();\n const dropX = active.rect.current.translated?.x || 0;\n const dropY = active.rect.current.translated?.y || 0;\n\n const isOutsideMarkup = (\n dropX < markupBounds.left ||\n dropX > markupBounds.right ||\n dropY < markupBounds.top ||\n dropY > markupBounds.bottom\n );\n\n if (isOutsideMarkup && drag.onRemove && typeof drag.onRemove === 'function') {\n drag.onRemove(drag);\n }\n }\n }\n }\n\n if (!active || !over) {\n this.setState({\n activeDragItem: null,\n });\n return;\n }\n\n const drag = active.data.current;\n const drop = over.data.current;\n\n if (drop && typeof drop.onDrop === \"function\") {\n drop.onDrop(drag, drop);\n return;\n }\n\n if (drag && typeof drag.onDrop === \"function\") {\n drag.onDrop(drag, drop);\n }\n\n this.setState({\n activeDragItem: null,\n });\n };\n\n const onDragStart = (event) => {\n const { active } = event;\n\n if (active?.data?.current) {\n this.setState({\n activeDragItem: active.data.current,\n });\n }\n };\n\n const renderDragOverlay = () => {\n const { activeDragItem } = this.state;\n const { model } = this.props;\n\n if (!activeDragItem) return null;\n\n if ((activeDragItem.type === 'drag-in-the-blank-choice' || activeDragItem.type === 'drag-in-the-blank-placed-choice') && activeDragItem.value) {\n const choice = model.choices?.find(c => c.id === activeDragItem.value.id);\n\n if (!choice) return null;\n\n return <Choice choice={choice} />;\n }\n };\n\n return (\n <DragProvider onDragEnd={onDragEnd} onDragStart={onDragStart}>\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <StyledInputContainer label={teacherInstructions.label}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {promptEnabled && (\n <StyledInputContainer label={prompt.label}>\n <EditableHtml\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {promptError && <ErrorText>{promptError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n <FlexContainer>\n <StyledText component={'div'}>\n Define Template, Choices, and Correct Responses\n </StyledText>\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />\n </StyledTooltip>\n </FlexContainer>\n\n <StyledMarkup ref={this.markupRef}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n responseAreaProps={{\n type: 'drag-in-the-blank',\n options: {\n duplicates: model.duplicates,\n },\n maxResponseAreas: maxResponseAreas,\n }}\n pluginProps={getPluginProps()}\n markup={model.slateMarkup}\n onChange={this.onMarkupChanged}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n nonEmpty={false}\n disableUnderline\n error={responseAreasError || correctResponseError}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledMarkup>\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n {correctResponseError && <ErrorText>{correctResponseError}</ErrorText>}\n\n <Choices\n model={model}\n imageSupport={imageSupport}\n duplicates={model.duplicates}\n error={choicesError}\n onChange={this.onResponsesChanged}\n toolbarOpts={toolbarOpts}\n maxChoices={maxChoices}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n pluginProps={getPluginProps(addChoice?.inputConfiguration)}\n maxImageWidth={(maxImageWidth && maxImageWidth.choice) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.choice) || defaultImageMaxHeight}\n maxLength={maxLength}\n />\n\n {rationaleEnabled && (\n <StyledInputContainer label={rationale.label}>\n <EditableHtml\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {rationaleError && <ErrorText>{rationaleError}</ErrorText>}\n </StyledInputContainer>\n )}\n </layout.ConfigLayout>\n <DragO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,kBAAkB,EAAEA,kBAAmB;MACvC8F,uBAAuB,EAAE,CAAC;QAAE9E,QAAQ,EAAE;MAAU,CAAC,EAAE;QAAEA,QAAQ,EAAE;MAAU,CAAC,CAAE;MAC5ED,aAAa,EAAEA;IAAc,CAC9B,CAAC,EACDc,cAAc,iBAAItI,MAAA,CAAA8B,OAAA,CAAAuB,aAAA,CAAC2B,SAAS,QAAEsD,cAA0B,CACrC,CAEL,CAAC,eACtBtI,MAAA,CAAA8B,OAAA,CAAAuB,aAAA,CAACvC,KAAA,CAAA0M,WAAW,qBACVxN,MAAA,CAAA8B,OAAA,CAAAuB,aAAA,CAACd,kBAAkB,QAChByI,iBAAiB,CAAC,CACD,CACT,CACD,CAAC;EAEnB;AACF;AAACyC,OAAA,CAAAjI,IAAA,GAAAA,IAAA;AAAA,IAAA5C,gBAAA,CAAAd,OAAA,EApXY0D,IAAI,eACI;EACjBc,aAAa,EAAEoH,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1ChI,KAAK,EAAE8H,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCC,gBAAgB,EAAEH,kBAAS,CAACI,IAAI;EAChCnI,cAAc,EAAE+H,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzCrH,sBAAsB,EAAEmH,kBAAS,CAACK,IAAI,CAACH,UAAU;EACjDpH,YAAY,EAAEkH,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFnH,kBAAkB,EAAEiH,kBAAS,CAACC;AAChC,CAAC;AAAA,IAAAQ,QAAA,GAAAV,OAAA,CAAA3L,OAAA,GA0WY0D,IAAI","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_renderUi","_drag","_mathRendering","_styles","_Typography","_Info","_Tooltip","_core","_choice","_choices","_markupUtils","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DragPreviewWrapper","React","Component","constructor","args","_defineProperty2","createRef","componentDidMount","setTimeout","containerRef","current","renderMath","componentDidUpdate","render","createElement","ref","props","children","dropdown","toggle","Panel","settings","StyledInputContainer","styled","InputContainer","theme","width","paddingTop","spacing","marginBottom","StyledMarkup","minHeight","paddingBottom","StyledText","Typography","fontSize","typography","StyledTooltip","Tooltip","whiteSpace","maxWidth","ErrorText","color","palette","error","main","FlexContainer","display","alignItems","Main","activeDragItem","newVal","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","correctResponse","markup","createSlateMarkup","markupRef","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","addChoice","baseInputConfiguration","contentDimensions","duplicates","partialScoring","lockChoiceOrder","choicesPosition","spellCheck","settingsPanelDisabled","maxChoices","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","language","languageChoices","maxLength","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","spellCheckEnabled","toolbarEditorPosition","errors","extraCSSRules","choicesError","correctResponseError","promptError","rationaleError","responseAreasError","teacherInstructionsError","validationMessage","generateValidationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","enabled","options","panelProperties","rubricEnabled","getPluginProps","assign","onDragEnd","active","over","drag","data","type","markupBounds","getBoundingClientRect","dropX","rect","translated","x","dropY","y","isOutsideMarkup","left","right","top","bottom","onRemove","setState","drop","onDrop","onDragStart","event","renderDragOverlay","state","value","choice","find","c","id","DragProvider","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onModelChange","onChangeConfiguration","groups","Settings","Properties","onChange","onTeacherInstructionsChanged","nonEmpty","pluginProps","inputConfiguration","languageCharactersProps","onPromptChanged","disableUnderline","component","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","activePlugins","ALL_PLUGINS","responseAreaProps","onMarkupChanged","disableImageAlignmentButtons","onResponsesChanged","onRationaleChanged","DragOverlay","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { layout, settings } from '@pie-lib/config-ui';\nimport { InputContainer } from '@pie-lib/render-ui';\nimport { DragProvider } from '@pie-lib/drag';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\nimport { DragOverlay } from '@dnd-kit/core';\n\nimport Choice from './choice';\nimport Choices from './choices';\nimport { createSlateMarkup } from './markupUtils';\nimport { generateValidationMessage } from '../utils';\n\nclass DragPreviewWrapper extends React.Component {\n containerRef = React.createRef();\n\n componentDidMount() {\n // Render math in the drag preview after it mounts\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n componentDidUpdate() {\n // Re-render math when the drag preview updates\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n render() {\n return <div ref={this.containerRef}>{this.props.children}</div>;\n }\n}\n\nconst { dropdown, toggle, Panel } = settings;\n\nconst StyledInputContainer = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst StyledMarkup = styled('div')(({ theme }) => ({\n minHeight: '235px',\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(2),\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '235px',\n },\n}));\n\nconst StyledText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {\n activeDragItem: null,\n };\n\n constructor(props) {\n super(props);\n this.markupRef = React.createRef();\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 this.props.onModelChanged({\n ...this.props.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 const {\n model: { correctResponse, markup },\n } = this.props;\n const slateMarkup = createSlateMarkup(markup, choices, correctResponse);\n\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup,\n choices,\n });\n };\n\n render() {\n const { model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n addChoice = {},\n baseInputConfiguration = {},\n contentDimensions = {},\n duplicates = {},\n prompt = {},\n partialScoring = {},\n lockChoiceOrder = {},\n rationale = {},\n teacherInstructions = {},\n choicesPosition = {},\n spellCheck = {},\n settingsPanelDisabled,\n maxChoices,\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n maxLength = {},\n } = configuration || {};\n const {\n rationaleEnabled,\n promptEnabled,\n teacherInstructionsEnabled,\n spellCheckEnabled,\n toolbarEditorPosition,\n errors,\n extraCSSRules,\n } = model || {};\n\n const {\n choicesError,\n correctResponseError,\n prompt: promptError,\n rationale: rationaleError,\n responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n duplicates: duplicates.settings && toggle(duplicates.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n choicesPosition: choicesPosition.settings && dropdown(choicesPosition.label, ['above', 'below', 'left', 'right']),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n const getPluginProps = (props) => {\n return Object.assign(\n {\n ...baseInputConfiguration,\n },\n props || {},\n );\n };\n\n\n const onDragEnd = ({ active, over }) => {\n // check if item was placed as a correct answer and then dropped outside of StyledMarkup component\n if (active && !over) {\n const drag = active.data.current;\n\n if (drag && drag.type === 'drag-in-the-blank-placed-choice') {\n if (this.markupRef.current) {\n const markupBounds = this.markupRef.current.getBoundingClientRect();\n const dropX = active.rect.current.translated?.x || 0;\n const dropY = active.rect.current.translated?.y || 0;\n\n const isOutsideMarkup = (\n dropX < markupBounds.left ||\n dropX > markupBounds.right ||\n dropY < markupBounds.top ||\n dropY > markupBounds.bottom\n );\n\n if (isOutsideMarkup && drag.onRemove && typeof drag.onRemove === 'function') {\n drag.onRemove(drag);\n }\n }\n }\n }\n\n if (!active || !over) {\n this.setState({\n activeDragItem: null,\n });\n return;\n }\n\n const drag = active.data.current;\n const drop = over.data.current;\n\n if (drop && typeof drop.onDrop === \"function\") {\n drop.onDrop(drag, drop);\n return;\n }\n\n if (drag && typeof drag.onDrop === \"function\") {\n drag.onDrop(drag, drop);\n }\n\n this.setState({\n activeDragItem: null,\n });\n };\n\n const onDragStart = (event) => {\n const { active } = event;\n\n if (active?.data?.current) {\n this.setState({\n activeDragItem: active.data.current,\n });\n }\n };\n\n const renderDragOverlay = () => {\n const { activeDragItem } = this.state;\n const { model } = this.props;\n\n if (!activeDragItem) return null;\n\n if ((activeDragItem.type === 'drag-in-the-blank-choice' || activeDragItem.type === 'drag-in-the-blank-placed-choice') && activeDragItem.value) {\n const choice = model.choices?.find(c => c.id === activeDragItem.value.id);\n\n if (!choice) return null;\n\n return <Choice choice={choice} />;\n }\n };\n\n return (\n <DragProvider onDragEnd={onDragEnd} onDragStart={onDragStart}>\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <StyledInputContainer label={teacherInstructions.label}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {promptEnabled && (\n <StyledInputContainer label={prompt.label}>\n <EditableHtml\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {promptError && <ErrorText>{promptError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n <FlexContainer>\n <StyledText component={'div'}>\n Define Template, Choices, and Correct Responses\n </StyledText>\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />\n </StyledTooltip>\n </FlexContainer>\n\n <StyledMarkup ref={this.markupRef}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n responseAreaProps={{\n type: 'drag-in-the-blank',\n options: {\n duplicates: model.duplicates,\n },\n maxResponseAreas: maxResponseAreas,\n }}\n pluginProps={getPluginProps()}\n markup={model.slateMarkup}\n onChange={this.onMarkupChanged}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n nonEmpty={false}\n disableUnderline\n error={responseAreasError || correctResponseError}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledMarkup>\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n {correctResponseError && <ErrorText>{correctResponseError}</ErrorText>}\n\n <Choices\n model={model}\n imageSupport={imageSupport}\n duplicates={model.duplicates}\n error={choicesError}\n onChange={this.onResponsesChanged}\n toolbarOpts={toolbarOpts}\n maxChoices={maxChoices}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n pluginProps={getPluginProps(addChoice?.inputConfiguration)}\n maxImageWidth={(maxImageWidth && maxImageWidth.choice) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.choice) || defaultImageMaxHeight}\n maxLength={maxLength}\n />\n\n {rationaleEnabled && (\n <StyledInputContainer label={rationale.label}>\n <EditableHtml\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {rationaleError && <ErrorText>{rationaleError}</ErrorText>}\n </StyledInputContainer>\n )}\n </layout.ConfigLayout>\n <DragOverlay>\n <DragPreviewWrapper>\n {renderDragOverlay()}\n </DragPreviewWrapper>\n </DragOverlay>\n </DragProvider>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC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AuB,aAAA,CAAC2B,SAAS,QAAEsD,cAA0B,CACrC,CAEL,CAAC,eACtBrI,MAAA,CAAA6B,OAAA,CAAAuB,aAAA,CAACtC,KAAA,CAAAyM,WAAW,qBACVvN,MAAA,CAAA6B,OAAA,CAAAuB,aAAA,CAACd,kBAAkB,QAChByI,iBAAiB,CAAC,CACD,CACT,CACD,CAAC;EAEnB;AACF;AAACyC,OAAA,CAAAjI,IAAA,GAAAA,IAAA;AAAA,IAAA5C,gBAAA,CAAAd,OAAA,EApXY0D,IAAI,eACI;EACjBc,aAAa,EAAEoH,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1ChI,KAAK,EAAE8H,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCC,gBAAgB,EAAEH,kBAAS,CAACI,IAAI;EAChCnI,cAAc,EAAE+H,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzCrH,sBAAsB,EAAEmH,kBAAS,CAACK,IAAI,CAACH,UAAU;EACjDpH,YAAY,EAAEkH,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFnH,kBAAkB,EAAEiH,kBAAS,CAACC;AAChC,CAAC;AAAA,IAAAQ,QAAA,GAAAV,OAAA,CAAA3L,OAAA,GA0WY0D,IAAI","ignoreList":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.removeUnwantedCharacters = exports.processMarkup = exports.createSlateMarkup = exports.createElementFromHTML = exports.choiceIsEmpty = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
9
8
|
const createElementFromHTML = htmlString => {
|
|
10
9
|
const div = document.createElement('div');
|
|
11
10
|
div.innerHTML = htmlString.trim();
|
|
@@ -60,7 +59,7 @@ const createSlateMarkup = (markup, choices, correctResponse) => {
|
|
|
60
59
|
value: ''
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
|
-
return `<span data-type="drag_in_the_blank" data-index="${index++}" data-id="${correctChoice.id}" data-value="${(0,
|
|
62
|
+
return `<span data-type="drag_in_the_blank" data-index="${index++}" data-id="${correctChoice.id}" data-value="${(0, _lodashEs.escape)(correctChoice.value)}"></span>`;
|
|
64
63
|
});
|
|
65
64
|
};
|
|
66
65
|
exports.createSlateMarkup = createSlateMarkup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markupUtils.js","names":["
|
|
1
|
+
{"version":3,"file":"markupUtils.js","names":["_lodashEs","require","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","exports","tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","processMarkup","newMarkup","slateMarkup","choices","index","querySelectorAll","forEach","s","value","dataset","push","id","replaceWith","correctResponse","reduce","obj","c","undefined","REGEX","createSlateMarkup","match","g","correctId","correctChoice","find","escape","choiceIsEmpty","choice","domEl","Array","from","tagName","childNodes","length","remove","newString"],"sources":["../src/markupUtils.js"],"sourcesContent":["import { escape } from 'lodash-es';\n\nexport const createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\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 processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup);\n const slateMarkup = createElementFromHTML(newMarkup);\n const choices = [];\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"drag_in_the_blank\"]').forEach((s) => {\n let value = s.dataset.value && s.dataset.value.replace(/ /g, ' ').trim();\n\n if (!value) {\n value = '';\n }\n\n choices.push({\n value,\n id: s.dataset.id,\n });\n\n s.replaceWith(`{{${index++}}}`);\n });\n\n return {\n markup: slateMarkup.innerHTML,\n choices: choices,\n correctResponse: choices.reduce((obj, c, index) => {\n obj[index] = (c.id !== undefined && c.id) || '';\n\n return obj;\n }, {}),\n };\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices, correctResponse) => {\n const newMarkup = removeUnwantedCharacters(markup);\n let index = 0;\n\n return newMarkup.replace(REGEX, (match, g) => {\n const correctId = correctResponse[g];\n let correctChoice = choices.find((c) => c.id === correctId);\n\n if (!correctChoice || !correctChoice.value) {\n correctChoice = {\n id: '',\n value: '',\n };\n }\n\n return `<span data-type=\"drag_in_the_blank\" data-index=\"${index++}\" data-id=\"${\n correctChoice.id\n }\" data-value=\"${escape(correctChoice.value)}\"></span>`;\n });\n};\n\nexport const choiceIsEmpty = (choice) => {\n if (choice) {\n const { value = '' } = choice;\n const domEl = createElementFromHTML(value);\n\n Array.from(domEl.querySelectorAll('*')).forEach((domEl) => {\n if (domEl.tagName !== 'IMG' && domEl.childNodes.length === 0) {\n domEl.remove();\n }\n });\n\n const newString = domEl.innerHTML.trim();\n\n return newString === '';\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,GAAIC,UAAU,I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ChB,OAAA,CAAA2B,iBAAA,GAAAA,iBAAA;AAEK,MAAMO,aAAa,GAAIC,MAAM,IAAK;EACvC,IAAIA,MAAM,EAAE;IACV,MAAM;MAAEnB,KAAK,GAAG;IAAG,CAAC,GAAGmB,MAAM;IAC7B,MAAMC,KAAK,GAAG3C,qBAAqB,CAACuB,KAAK,CAAC;IAE1CqB,KAAK,CAACC,IAAI,CAACF,KAAK,CAACvB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAACC,OAAO,CAAEsB,KAAK,IAAK;MACzD,IAAIA,KAAK,CAACG,OAAO,KAAK,KAAK,IAAIH,KAAK,CAACI,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;QAC5DL,KAAK,CAACM,MAAM,CAAC,CAAC;MAChB;IACF,CAAC,CAAC;IAEF,MAAMC,SAAS,GAAGP,KAAK,CAACtC,SAAS,CAACC,IAAI,CAAC,CAAC;IAExC,OAAO4C,SAAS,KAAK,EAAE;EACzB;EAEA,OAAO,KAAK;AACd,CAAC;AAAC3C,OAAA,CAAAkC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/drag-in-the-blank-configure",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0-next.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"@mui/icons-material": "^7.3.4",
|
|
13
13
|
"@mui/material": "^7.3.4",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
-
"@pie-lib/config-ui": "12.1.1-next.
|
|
16
|
-
"@pie-lib/drag": "3.1.1-next.
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "1.1.1-next.
|
|
18
|
-
"@pie-lib/math-rendering": "4.1.1-next.
|
|
15
|
+
"@pie-lib/config-ui": "12.1.1-next.3",
|
|
16
|
+
"@pie-lib/drag": "3.1.1-next.1",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.3",
|
|
18
|
+
"@pie-lib/math-rendering": "4.1.1-next.1",
|
|
19
19
|
"debug": "^4.1.1",
|
|
20
|
-
"lodash": "^4.17.
|
|
20
|
+
"lodash-es": "^4.17.23",
|
|
21
21
|
"prop-types": "^15.6.2",
|
|
22
|
-
"react": "18.
|
|
23
|
-
"react-dom": "18.
|
|
22
|
+
"react": "18.3.1",
|
|
23
|
+
"react-dom": "18.3.1"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/controller/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.model = model;
|
|
|
9
9
|
exports.normalize = void 0;
|
|
10
10
|
exports.outcome = outcome;
|
|
11
11
|
exports.validate = void 0;
|
|
12
|
-
var
|
|
12
|
+
var _lodashEs = require("lodash-es");
|
|
13
13
|
var _utils = require("./utils");
|
|
14
14
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
15
15
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
@@ -134,7 +134,7 @@ function outcome(model, session, env = {}) {
|
|
|
134
134
|
const score = getScore(model, session);
|
|
135
135
|
resolve({
|
|
136
136
|
score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
|
|
137
|
-
empty: !session || (0,
|
|
137
|
+
empty: !session || (0, _lodashEs.isEmpty)(session)
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_isEmpty","_interopRequireDefault","require","_utils","_controllerUtils","_defaults","normalize","question","defaults","exports","model","session","env","updateSession","normalizedQuestion","feedback","mode","responses","getAllCorrectResponses","allCorrectResponses","possibleResponses","numberOfPossibleResponses","correctResponses","undefined","value","i","result","Object","keys","reduce","obj","key","choices","answer","filter","choice","choiceIsEmpty","lockChoiceOrder","lockChoices","getShuffledChoices","responseAreasToBeFilled","values","correctResponse","length","shouldIncludeCorrectResponse","out","prompt","promptEnabled","disabled","responseCorrect","getScore","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","config","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","Promise","resolve","partialScoringEnabled","partialScoring","enabled","score","empty","isEmpty","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","markup","minChoices","maxChoices","maxResponseAreas","errors","forEach","field","required","nbOfResponseAreas","match","nbOfChoices","emptyResponseAreas","response","correctResponseError","responseAreasError","choicesError"],"sources":["../src/index.js"],"sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { getAllCorrectResponses, choiceIsEmpty } from './utils';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\nexport const normalize = (question) => ({\n ...defaults,\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const responses = getAllCorrectResponses(normalizedQuestion) || {};\n const allCorrectResponses = responses.possibleResponses;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctResponses = undefined;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce(\n (obj, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n obj.feedback[key] = choices[i] === answer;\n\n if (obj.feedback[key]) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (correctResponses === undefined || result.correctResponses > correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n }\n }\n\n let choices = normalizedQuestion.choices && normalizedQuestion.choices.filter((choice) => !choiceIsEmpty(choice));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n // we don't need to check for fewer areas to be filled in the alternateResponses\n // because the alternates are an option in the default correct response (for scoring)\n const responseAreasToBeFilled = Object.values(normalizedQuestion.correctResponse || {}).filter(\n (value) => !!value,\n ).length;\n\n const shouldIncludeCorrectResponse = env.mode === 'evaluate';\n\n const out = {\n ...normalizedQuestion,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choices,\n feedback,\n mode: env.mode,\n disabled: env.mode !== 'gather',\n responseCorrect: shouldIncludeCorrectResponse ? getScore(normalizedQuestion, session) === 1 : undefined,\n correctResponse: shouldIncludeCorrectResponse ? normalizedQuestion.correctResponse : undefined,\n responseAreasToBeFilled,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n const responses = getAllCorrectResponses(config);\n const allCorrectResponses = responses.possibleResponses;\n const maxScore = Object.keys(config.correctResponse).length;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctCount = 0;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce((total, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n if (choices[i] === answer) {\n return total;\n }\n\n return total - 1;\n }, maxScore);\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\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 const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({\n score: partialScoringEnabled ? score : score === 1 ? 1 : 0,\n empty: !session || isEmpty(session),\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n value: question.correctResponse,\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, correctResponse, markup } = model;\n const { minChoices = 2, maxChoices, maxResponseAreas } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n const nbOfChoices = (choices || []).length;\n const emptyResponseAreas = Object.values(correctResponse)?.filter((response) => !response);\n\n if (emptyResponseAreas.length) {\n errors.correctResponseError = 'There should be a choice defined for each response area.';\n }\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 at least 1 response area defined.';\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} tokens defined.`;\n } else if (nbOfChoices > maxChoices) {\n errors.choicesError = `No more than ${maxChoices} tokens should be defined.`;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEO,MAAMI,SAAS,GAAIC,QAAQ,KAAM;EACtC,GAAGC,iBAAQ;EACX,GAAGD;AACL,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AANAE,OAAA,CAAAH,SAAA,GAAAA,SAAA;AAOO,eAAeI,KAAKA,CAACH,QAAQ,EAAEI,OAAO,EAAEC,GAAG,EAAEC,aAAa,EAAE;EACjE,MAAMC,kBAAkB,GAAGR,SAAS,CAACC,QAAQ,CAAC;EAC9C,IAAIQ,QAAQ,GAAG,CAAC,CAAC;EAEjB,IAAIH,GAAG,CAACI,IAAI,KAAK,UAAU,EAAE;IAC3B,MAAMC,SAAS,GAAG,IAAAC,6BAAsB,EAACJ,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClE,MAAMK,mBAAmB,GAAGF,SAAS,CAACG,iBAAiB;IACvD,MAAMC,yBAAyB,GAAGJ,SAAS,CAACI,yBAAyB,IAAI,CAAC;IAC1E,IAAIC,gBAAgB,GAAGC,SAAS;IAChC,MAAM;MAAEC;IAAM,CAAC,GAAGb,OAAO,IAAI,CAAC,CAAC;IAE/B,KAAK,IAAIc,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,yBAAyB,EAAEI,CAAC,EAAE,EAAE;MAClD,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACT,mBAAmB,CAAC,CAACU,MAAM,CACpD,CAACC,GAAG,EAAEC,GAAG,KAAK;QACZ,MAAMC,OAAO,GAAGb,mBAAmB,CAACY,GAAG,CAAC;QACxC,MAAME,MAAM,GAAIT,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AK,IAAK;IAChE,IAAI9B,MAAM,CAAC8B,KAAK,CAAC,EAAEC,QAAQ,IAAI,CAACV,UAAU,CAACnE,KAAK,CAAC4E,KAAK,CAAC,CAAC,EAAE;MACxDF,MAAM,CAACE,KAAK,CAAC,GAAG,yBAAyB;IAC3C;EACF,CAAC,CAAC;EAEF,MAAME,iBAAiB,GAAG,CAAC,CAACR,MAAM,IAAI,EAAE,EAAES,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE9C,MAAM;EAC/E,MAAM+C,WAAW,GAAG,CAAC1D,OAAO,IAAI,EAAE,EAAEW,MAAM;EAC1C,MAAMgD,kBAAkB,GAAGhE,MAAM,CAACc,MAAM,CAACC,eAAe,CAAC,EAAER,MAAM,CAAE0D,QAAQ,IAAK,CAACA,QAAQ,CAAC;EAE1F,IAAID,kBAAkB,CAAChD,MAAM,EAAE;IAC7ByC,MAAM,CAACS,oBAAoB,GAAG,0DAA0D;EAC1F;EAEA,IAAIL,iBAAiB,GAAGL,gBAAgB,EAAE;IACxCC,MAAM,CAACU,kBAAkB,GAAG,gBAAgBX,gBAAgB,oCAAoC;EAClG,CAAC,MAAM,IAAIK,iBAAiB,GAAG,CAAC,EAAE;IAChCJ,MAAM,CAACU,kBAAkB,GAAG,mDAAmD;EACjF;EAEA,IAAIJ,WAAW,GAAGT,UAAU,EAAE;IAC5BG,MAAM,CAACW,YAAY,GAAG,4BAA4Bd,UAAU,kBAAkB;EAChF,CAAC,MAAM,IAAIS,WAAW,GAAGR,UAAU,EAAE;IACnCE,MAAM,CAACW,YAAY,GAAG,gBAAgBb,UAAU,4BAA4B;EAC9E;EAEA,OAAOE,MAAM;AACf,CAAC;AAAC3E,OAAA,CAAAsE,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodashEs","require","_utils","_controllerUtils","_defaults","_interopRequireDefault","normalize","question","defaults","exports","model","session","env","updateSession","normalizedQuestion","feedback","mode","responses","getAllCorrectResponses","allCorrectResponses","possibleResponses","numberOfPossibleResponses","correctResponses","undefined","value","i","result","Object","keys","reduce","obj","key","choices","answer","filter","choice","choiceIsEmpty","lockChoiceOrder","lockChoices","getShuffledChoices","responseAreasToBeFilled","values","correctResponse","length","shouldIncludeCorrectResponse","out","prompt","promptEnabled","disabled","responseCorrect","getScore","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","config","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","Promise","resolve","partialScoringEnabled","partialScoring","enabled","score","empty","isEmpty","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","markup","minChoices","maxChoices","maxResponseAreas","errors","forEach","field","required","nbOfResponseAreas","match","nbOfChoices","emptyResponseAreas","response","correctResponseError","responseAreasError","choicesError"],"sources":["../src/index.js"],"sourcesContent":["import { isEmpty } from 'lodash-es';\nimport { getAllCorrectResponses, choiceIsEmpty } from './utils';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\nexport const normalize = (question) => ({\n ...defaults,\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const responses = getAllCorrectResponses(normalizedQuestion) || {};\n const allCorrectResponses = responses.possibleResponses;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctResponses = undefined;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce(\n (obj, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n obj.feedback[key] = choices[i] === answer;\n\n if (obj.feedback[key]) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (correctResponses === undefined || result.correctResponses > correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n }\n }\n\n let choices = normalizedQuestion.choices && normalizedQuestion.choices.filter((choice) => !choiceIsEmpty(choice));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n // we don't need to check for fewer areas to be filled in the alternateResponses\n // because the alternates are an option in the default correct response (for scoring)\n const responseAreasToBeFilled = Object.values(normalizedQuestion.correctResponse || {}).filter(\n (value) => !!value,\n ).length;\n\n const shouldIncludeCorrectResponse = env.mode === 'evaluate';\n\n const out = {\n ...normalizedQuestion,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choices,\n feedback,\n mode: env.mode,\n disabled: env.mode !== 'gather',\n responseCorrect: shouldIncludeCorrectResponse ? getScore(normalizedQuestion, session) === 1 : undefined,\n correctResponse: shouldIncludeCorrectResponse ? normalizedQuestion.correctResponse : undefined,\n responseAreasToBeFilled,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n const responses = getAllCorrectResponses(config);\n const allCorrectResponses = responses.possibleResponses;\n const maxScore = Object.keys(config.correctResponse).length;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctCount = 0;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce((total, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n if (choices[i] === answer) {\n return total;\n }\n\n return total - 1;\n }, maxScore);\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\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 const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({\n score: partialScoringEnabled ? score : score === 1 ? 1 : 0,\n empty: !session || isEmpty(session),\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n value: question.correctResponse,\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, correctResponse, markup } = model;\n const { minChoices = 2, maxChoices, maxResponseAreas } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n const nbOfChoices = (choices || []).length;\n const emptyResponseAreas = Object.values(correctResponse)?.filter((response) => !response);\n\n if (emptyResponseAreas.length) {\n errors.correctResponseError = 'There should be a choice defined for each response area.';\n }\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 at least 1 response area defined.';\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} tokens defined.`;\n } else if (nbOfChoices > maxChoices) {\n errors.choicesError = `No more than ${maxChoices} tokens should be defined.`;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEO,MAAMK,SAAS,GAAIC,QAAQ,KAAM;EACtC,GAAGC,iBAAQ;EACX,GAAGD;AACL,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AANAE,OAAA,CAAAH,SAAA,GAAAA,SAAA;AAOO,eAAeI,KAAKA,CAACH,QAAQ,EAAEI,OAAO,EAAEC,GAAG,EAAEC,aAAa,EAAE;EACjE,MAAMC,kBAAkB,GAAGR,SAAS,CAACC,QAAQ,CAAC;EAC9C,IAAIQ,QAAQ,GAAG,CAAC,CAAC;EAEjB,IAAIH,GAAG,CAACI,IAAI,KAAK,UAAU,EAAE;IAC3B,MAAMC,SAAS,GAAG,IAAAC,6BAAsB,EAACJ,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClE,MAAMK,mBAAmB,GAAGF,SAAS,CAACG,iBAAiB;IACvD,MAAMC,yBAAyB,GAAGJ,SAAS,CAACI,yBAAyB,IAAI,CAAC;IAC1E,IAAIC,gBAAgB,GAAGC,SAAS;IAChC,MAAM;MAAEC;IAAM,CAAC,GAAGb,OAAO,IAAI,CAAC,CAAC;IAE/B,KAAK,IAAIc,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,yBAAyB,EAAEI,CAAC,EAAE,EAAE;MAClD,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACT,mBAAmB,CAAC,C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/utils.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.getAllCorrectResponses = exports.choiceIsEmpty = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _reduce = _interopRequireDefault(require("lodash/reduce"));
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
10
8
|
const replaceHtmlRegex = /<(?!img)[^>]*>?/gm;
|
|
11
9
|
const getAllCorrectResponses = ({
|
|
12
10
|
correctResponse,
|
|
13
11
|
alternateResponses
|
|
14
12
|
}) => {
|
|
15
|
-
return (0,
|
|
13
|
+
return (0, _lodashEs.reduce)(correctResponse || {}, (obj, val, key) => {
|
|
16
14
|
obj.possibleResponses[key] = [val];
|
|
17
15
|
if (alternateResponses && alternateResponses[key]) {
|
|
18
|
-
obj.possibleResponses[key] = [...obj.possibleResponses[key], ...(0,
|
|
16
|
+
obj.possibleResponses[key] = [...obj.possibleResponses[key], ...(0, _lodashEs.cloneDeep)(alternateResponses[key])];
|
|
19
17
|
}
|
|
20
18
|
if (obj.numberOfPossibleResponses === undefined || obj.numberOfPossibleResponses > obj.possibleResponses[key].length) {
|
|
21
19
|
obj.numberOfPossibleResponses = obj.possibleResponses[key].length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_lodashEs","require","replaceHtmlRegex","getAllCorrectResponses","correctResponse","alternateResponses","reduce","obj","val","key","possibleResponses","cloneDeep","numberOfPossibleResponses","undefined","length","exports","choiceIsEmpty","choice","value","withoutEmptyTags","replace","trim"],"sources":["../src/utils.js"],"sourcesContent":["import { cloneDeep, reduce } from 'lodash-es';\n\nconst replaceHtmlRegex = /<(?!img)[^>]*>?/gm;\n\nexport const getAllCorrectResponses = ({ correctResponse, alternateResponses }) => {\n return reduce(\n correctResponse || {},\n (obj, val, key) => {\n obj.possibleResponses[key] = [val];\n\n if (alternateResponses && alternateResponses[key]) {\n obj.possibleResponses[key] = [...obj.possibleResponses[key], ...cloneDeep(alternateResponses[key])];\n }\n\n if (\n obj.numberOfPossibleResponses === undefined ||\n obj.numberOfPossibleResponses > obj.possibleResponses[key].length\n ) {\n obj.numberOfPossibleResponses = obj.possibleResponses[key].length;\n }\n\n return obj;\n },\n {\n possibleResponses: {},\n numberOfPossibleResponses: undefined,\n },\n );\n};\n\nexport const choiceIsEmpty = (choice) => {\n if (choice) {\n const { value = '' } = choice;\n const withoutEmptyTags = value.replace(replaceHtmlRegex, '') || '';\n\n return withoutEmptyTags.trim() === '';\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,MAAMC,gBAAgB,GAAG,mBAAmB;AAErC,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC,eAAe;EAAEC;AAAmB,CAAC,KAAK;EACjF,OAAO,IAAAC,gBAAM,EACXF,eAAe,IAAI,CAAC,CAAC,EACrB,CAACG,GAAG,EAAEC,GAAG,EAAEC,GAAG,KAAK;IACjBF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,GAAG,CAACD,GAAG,CAAC;IAElC,IAAIH,kBAAkB,IAAIA,kBAAkB,CAACI,GAAG,CAAC,EAAE;MACjDF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,GAAG,CAAC,GAAGF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,EAAE,GAAG,IAAAE,mBAAS,EAACN,kBAAkB,CAACI,GAAG,CAAC,CAAC,CAAC;IACrG;IAEA,IACEF,GAAG,CAACK,yBAAyB,KAAKC,SAAS,IAC3CN,GAAG,CAACK,yBAAyB,GAAGL,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,CAACK,MAAM,EACjE;MACAP,GAAG,CAACK,yBAAyB,GAAGL,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,CAACK,MAAM;IACnE;IAEA,OAAOP,GAAG;EACZ,CAAC,EACD;IACEG,iBAAiB,EAAE,CAAC,CAAC;IACrBE,yBAAyB,EAAEC;EAC7B,CACF,CAAC;AACH,CAAC;AAACE,OAAA,CAAAZ,sBAAA,GAAAA,sBAAA;AAEK,MAAMa,aAAa,GAAIC,MAAM,IAAK;EACvC,IAAIA,MAAM,EAAE;IACV,MAAM;MAAEC,KAAK,GAAG;IAAG,CAAC,GAAGD,MAAM;IAC7B,MAAME,gBAAgB,GAAGD,KAAK,CAACE,OAAO,CAAClB,gBAAgB,EAAE,EAAE,CAAC,IAAI,EAAE;IAElE,OAAOiB,gBAAgB,CAACE,IAAI,CAAC,CAAC,KAAK,EAAE;EACvC;EAEA,OAAO,KAAK;AACd,CAAC;AAACN,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/controller/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/drag-in-the-blank-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.1.0-next.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@pie-lib/controller-utils": "1.1.1-next.
|
|
11
|
+
"@pie-lib/controller-utils": "1.1.1-next.1",
|
|
12
12
|
"debug": "^4.1.1",
|
|
13
|
-
"lodash": "^4.17.
|
|
13
|
+
"lodash-es": "^4.17.23",
|
|
14
14
|
"type-of": "^2.0.1"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/drag-in-the-blank",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/pie-framework/pie-elements"
|
|
6
|
+
},
|
|
3
7
|
"publishConfig": {
|
|
4
8
|
"access": "public"
|
|
5
9
|
},
|
|
6
|
-
"
|
|
7
|
-
"version": "9.0.0-next.43+4249fa78f",
|
|
10
|
+
"version": "9.1.0-next.0+20d879b",
|
|
8
11
|
"description": "",
|
|
9
12
|
"scripts": {
|
|
10
13
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -15,19 +18,19 @@
|
|
|
15
18
|
"@mui/icons-material": "^7.3.4",
|
|
16
19
|
"@mui/material": "^7.3.4",
|
|
17
20
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
18
|
-
"@pie-lib/correct-answer-toggle": "3.1.1-next.
|
|
19
|
-
"@pie-lib/drag": "3.1.1-next.
|
|
20
|
-
"@pie-lib/mask-markup": "2.1.1-next.
|
|
21
|
-
"@pie-lib/math-rendering": "4.1.1-next.
|
|
22
|
-
"@pie-lib/render-ui": "5.1.1-next.
|
|
23
|
-
"lodash": "^4.17.
|
|
21
|
+
"@pie-lib/correct-answer-toggle": "3.1.1-next.1",
|
|
22
|
+
"@pie-lib/drag": "3.1.1-next.1",
|
|
23
|
+
"@pie-lib/mask-markup": "2.1.1-next.3",
|
|
24
|
+
"@pie-lib/math-rendering": "4.1.1-next.1",
|
|
25
|
+
"@pie-lib/render-ui": "5.1.1-next.1",
|
|
26
|
+
"lodash-es": "^4.17.23",
|
|
24
27
|
"prop-types": "^15.6.1",
|
|
25
28
|
"react": "18.3.1",
|
|
26
29
|
"react-dom": "18.3.1"
|
|
27
30
|
},
|
|
28
31
|
"author": "",
|
|
29
32
|
"license": "ISC",
|
|
30
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "20d879b8b8fa74decf5028d860d54cd09cbdf051",
|
|
31
34
|
"main": "lib/index.js",
|
|
32
35
|
"module": "src/index.js"
|
|
33
36
|
}
|