@pie-element/image-cloze-association 5.15.3 → 5.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.15.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@5.15.3...@pie-element/image-cloze-association@5.15.4) (2024-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-3650, PD-3651, PD-3621, PD-3620, PD-2127,PD-3709, PD-3726, PD-3191 ([2ef6881](https://github.com/pie-framework/pie-elements/commit/2ef688118b9099c7338cbe88afcdeed228fae11e))
12
+ * **image-cloze-association:** filter out only the first found response PD-3718 ([0a54bfb](https://github.com/pie-framework/pie-elements/commit/0a54bfb503bc83e40d6d9ea1dbfaa4bdb4a498b2))
13
+ * **image-cloze-association:** use slice and findIndex for a clearer solution PD-3718 ([a0c9362](https://github.com/pie-framework/pie-elements/commit/a0c93628fa1518f817222ce0126ff09c47bc60ae))
14
+
15
+
16
+
17
+
18
+
6
19
  ## [5.15.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@5.15.2...@pie-element/image-cloze-association@5.15.3) (2024-05-07)
7
20
 
8
21
 
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.12.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@5.12.3...@pie-element/image-cloze-association-configure@5.12.4) (2024-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-3650, PD-3651, PD-3621, PD-3620, PD-2127,PD-3709, PD-3726, PD-3191 ([2ef6881](https://github.com/pie-framework/pie-elements/commit/2ef688118b9099c7338cbe88afcdeed228fae11e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [5.12.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@5.12.2...@pie-element/image-cloze-association-configure@5.12.3) (2024-05-07)
7
18
 
8
19
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association-configure",
3
3
  "private": true,
4
- "version": "5.12.3",
4
+ "version": "5.12.4",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
11
  "@pie-framework/pie-configure-events": "^1.3.0",
12
- "@pie-lib/pie-toolbox": "1.17.3",
12
+ "@pie-lib/pie-toolbox": "1.17.4",
13
13
  "debug": "^3.1.0",
14
14
  "prop-types": "^15.7.2",
15
15
  "react": "^16.8.6",
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.10.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@4.10.3...@pie-element/image-cloze-association-controller@4.10.4) (2024-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-3650, PD-3651, PD-3621, PD-3620, PD-2127,PD-3709, PD-3726, PD-3191 ([2ef6881](https://github.com/pie-framework/pie-elements/commit/2ef688118b9099c7338cbe88afcdeed228fae11e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [4.10.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@4.10.2...@pie-element/image-cloze-association-controller@4.10.3) (2024-05-07)
7
18
 
8
19
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association-controller",
3
3
  "private": true,
4
- "version": "4.10.3",
4
+ "version": "4.10.4",
5
5
  "description": "",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -11,7 +11,7 @@
11
11
  "main": "lib/index.js",
12
12
  "module": "src/index.js",
13
13
  "dependencies": {
14
- "@pie-lib/pie-toolbox": "1.17.3",
14
+ "@pie-lib/pie-toolbox": "1.17.4",
15
15
  "debug": "^4.1.1",
16
16
  "humps": "^2.0.1",
17
17
  "lodash": "^4.17.15"
package/lib/root.js CHANGED
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
10
  var _readOnlyError2 = _interopRequireDefault(require("@babel/runtime/helpers/readOnlyError"));
13
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
15
 
16
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -108,6 +108,12 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
108
108
  }
109
109
  });
110
110
  });
111
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "filterPossibleAnswers", function (possibleResponses, answer) {
112
+ var index = possibleResponses.findIndex(function (response) {
113
+ return response.value === answer.value;
114
+ });
115
+ return [].concat((0, _toConsumableArray2["default"])(possibleResponses.slice(0, index)), (0, _toConsumableArray2["default"])(possibleResponses.slice(index + 1)));
116
+ });
111
117
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleOnAnswerSelect", function (answer, responseContainerIndex) {
112
118
  var _this$props = _this.props,
113
119
  duplicateResponses = _this$props.model.duplicateResponses,
@@ -183,9 +189,7 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
183
189
  maxResponsePerZoneWarning: false,
184
190
  answers: answersToStore,
185
191
  possibleResponses: // for single response per container remove answer from possible responses
186
- duplicateResponses ? possibleResponses : possibleResponses.filter(function (response) {
187
- return response.value !== answer.value;
188
- })
192
+ duplicateResponses ? possibleResponses : _this.filterPossibleAnswers(possibleResponses, answer)
189
193
  });
190
194
 
191
195
  updateAnswer(answersToStore);
package/lib/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/root.jsx"],"names":["translator","Translator","generateId","Math","random","toString","substring","Date","getTime","styles","theme","main","color","text","backgroundColor","background","stimulus","fontSize","typography","teacherInstructions","marginBottom","spacing","unit","rationale","marginTop","ImageClozeAssociationComponent","props","draggingElement","setState","id","value","answer","responseContainerIndex","duplicateResponses","model","updateAnswer","state","answers","possibleResponses","maxResponsePerZone","answersToStore","filter","a","containerIndex","length","answersInThisContainer","answersInOtherContainers","b","shiftedItem","shift","maxResponsePerZoneWarning","Array","isArray","push","_","max","map","c","parseInt","isNaN","response","shouldNotPushInPossibleResponses","undefined","showCorrect","responseContainers","session","possibleResponsesWithIds","item","index","groupBy","grp","slice","flatMap","possibleResponsesFiltered","find","classes","disabled","image","responseCorrect","validation","prompt","showDashedBorder","mode","language","uiStyle","isEvaluateMode","showToggle","validResponse","correctAnswers","forEach","container","i","images","v","warningMessage","t","lng","count","answersToShow","hidden","visible","toggleCorrect","handleOnAnswerSelect","beginDrag","handleOnDragEnd","handleOnAnswerRemove","React","Component","WarningInfo","warning","margin","padding","display","alignItems","width","height","message","paddingLeft","userSelect","__html","propTypes","PropTypes","string","object","isRequired","func","defaultProps","StyledComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AALA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAOA,IAAME,UAAU,GAAG,SAAbA,UAAa;AAAA,SAAMC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC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;AAAA,MAAG3C,OAAH,SAAGA,OAAH;AAAA,MAAYyC,OAAZ,SAAYA,OAAZ;AAAA,sBACF,gCAAC,qCAAD,qBACE,gCAAC,mCAAD;AAAe,IAAA,UAAU,EAAE,IAA3B;AAAiC,IAAA,GAAG,EAAC,IAArC;AAA0C,IAAA,OAAO,EAAE;AAAnD,kBACE;AAAK,IAAA,GAAG,EAAC,OAAT;AAAiB,IAAA,SAAS,EAAEzC,OAAO,CAACkC;AAApC,kBACE,gCAAC,oBAAD;AAAe,IAAA,OAAO,EAAC,OAAvB;AAA+B,IAAA,KAAK,EAAC;AAArC,IADF,eAEE;AAAM,IAAA,SAAS,EAAElC,OAAO,CAACyC,OAAzB;AAAkC,IAAA,uBAAuB,EAAE;AAAEG,MAAAA,MAAM,EAAEH;AAAV;AAA3D,IAFF,CADF,CADF,CADE;AAAA,CApBgB,CAApB;AA+BAR,WAAW,CAACY,SAAZ,GAAwB;AACtBJ,EAAAA,OAAO,EAAEK,sBAAUC,MADG;AAEtB/C,EAAAA,OAAO,EAAE8C,sBAAUE,MAAV,CAAiBC;AAFJ,CAAxB;AAKAnG,8BAA8B,CAAC+F,SAA/B,GAA2C;AACzC7C,EAAAA,OAAO,EAAE8C,sBAAUE,MADsB;AAEzCzF,EAAAA,KAAK,EAAEuF,sBAAUE,MAAV,CAAiBC,UAFiB;AAGzC3D,EAAAA,OAAO,EAAEwD,sBAAUE,MAHsB;AAIzCxF,EAAAA,YAAY,EAAEsF,sBAAUI,IAAV,CAAeD;AAJY,CAA3C;AAOAnG,8BAA8B,CAACqG,YAA/B,GAA8C;AAC5CnD,EAAAA,OAAO,EAAE;AADmC,CAA9C;AAIA,IAAMoD,eAAe,GAAG,wBAAWtH,MAAX,EAAmBgB,8BAAnB,CAAxB;;eAEe,2BAAgBsG,eAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withDragContext } from '@pie-lib/pie-toolbox/drag';\nimport { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport { ShowRationale } from '@pie-lib/pie-toolbox/icons';\nimport { color, Collapsible, PreviewPrompt, hasText } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\nimport Image from './image-container';\nimport InteractiveSection from './interactive-section';\nimport PossibleResponses from './possible-responses';\nimport { getUnansweredAnswers, getAnswersCorrectness } from './utils-correctness';\nimport _ from 'lodash';\n\nconst generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n stimulus: {\n fontSize: theme.typography.fontSize,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n rationale: {\n marginTop: theme.spacing.unit * 2,\n }\n});\n\nclass ImageClozeAssociationComponent extends React.Component {\n constructor(props) {\n super(props);\n const {\n model: { possibleResponses, responseContainers, duplicateResponses, maxResponsePerZone },\n session,\n } = props;\n let { answers } = session || {};\n // set id for each possible response\n const possibleResponsesWithIds = (possibleResponses || []).map((item, index) => ({\n value: item,\n id: `${index}`,\n }));\n\n answers = _(answers || [])\n .groupBy('containerIndex')\n // keep only last maxResponsePerZone answers for each zone\n .map((grp) => grp.slice(-(maxResponsePerZone || 1)))\n .flatMap()\n // set id for each answer\n .map((answer, index) => ({ ...answer, id: `${index}` }))\n // return only answer which have a valid container index\n .filter((answer) => answer.containerIndex < responseContainers.length)\n .value();\n\n const possibleResponsesFiltered = possibleResponsesWithIds.filter(\n (response) => !answers.find((answer) => answer.value === response.value),\n );\n this.state = {\n answers: answers || [],\n draggingElement: { id: '', value: '' },\n possibleResponses: duplicateResponses ? possibleResponsesWithIds : possibleResponsesFiltered,\n // set id for each response containers\n responseContainers: (responseContainers || []).map((item, index) => ({\n index,\n ...item,\n id: `${index}`,\n })),\n maxResponsePerZone: maxResponsePerZone || 1,\n showCorrect: false,\n };\n }\n\n beginDrag = (draggingElement) => {\n this.setState({\n draggingElement,\n });\n };\n\n handleOnDragEnd = () => {\n this.setState({\n draggingElement: { id: '', value: '' },\n });\n };\n\n handleOnAnswerSelect = (answer, responseContainerIndex) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses, maxResponsePerZone } = this.state;\n let answersToStore;\n\n if (maxResponsePerZone === answers.filter((a) => a.containerIndex === responseContainerIndex).length) {\n const answersInThisContainer = answers.filter((a) => a.containerIndex === responseContainerIndex);\n const answersInOtherContainers = answers.filter((b) => b.containerIndex !== responseContainerIndex);\n\n const shiftedItem = answersInThisContainer[0];\n if (maxResponsePerZone === 1) {\n answersInThisContainer.shift(); // FIFO\n } else {\n this.setState({ maxResponsePerZoneWarning: true });\n return;\n }\n\n // if duplicates are not allowed, make sure to put the shifted value back in possible responses\n if (!duplicateResponses) {\n possibleResponses = Array.isArray(possibleResponses) ? possibleResponses : [];\n\n possibleResponses.push({\n ...shiftedItem,\n containerIndex: '',\n id: `${_.max(possibleResponses.map((c) => parseInt(c.id)).filter((id) => !isNaN(id))) + 1}`,\n });\n }\n\n // answers will be:\n // + shifted answers for the current container\n // + if duplicatesAllowed, all the other answers from other containers\n // else: all the answers from other containers that are not having the same value\n // + new answer\n answersToStore = [\n ...answersInThisContainer, // shifted\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answersInOtherContainers.filter((a) => (duplicateResponses ? true : a.value !== answer.value)), // un-shifted\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n } else {\n // answers will be:\n // + if duplicatesAllowed, all the other answers, except the one that was dragged\n // else: all the answers that are not having the same value\n // + new answer\n answersToStore = [\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answers.filter((a) => (duplicateResponses ? a.id !== answer.id : a.value !== answer.value)),\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n }\n\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n possibleResponses:\n // for single response per container remove answer from possible responses\n duplicateResponses\n ? possibleResponses\n : possibleResponses.filter((response) => response.value !== answer.value),\n });\n updateAnswer(answersToStore);\n };\n\n handleOnAnswerRemove = (answer) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses } = this.state;\n const answersToStore = answers.filter((a) => a.id !== answer.id);\n const shouldNotPushInPossibleResponses = answer.containerIndex === undefined; // don't duplicate possible responses\n\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n // push back into possible responses the removed answer if responses cannot be duplicated\n possibleResponses:\n duplicateResponses || shouldNotPushInPossibleResponses\n ? possibleResponses\n : [\n ...possibleResponses,\n {\n ...answer,\n containerIndex: undefined,\n },\n ],\n });\n updateAnswer(answersToStore);\n };\n\n toggleCorrect = (showCorrect) => this.setState({ showCorrect });\n\n render() {\n const {\n classes,\n model: {\n disabled,\n duplicateResponses,\n image,\n stimulus,\n responseCorrect,\n validation,\n teacherInstructions,\n prompt,\n showDashedBorder,\n mode,\n rationale,\n language,\n uiStyle = {},\n },\n } = this.props;\n const {\n answers,\n draggingElement,\n possibleResponses,\n responseContainers,\n maxResponsePerZone,\n maxResponsePerZoneWarning,\n showCorrect,\n } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showToggle = isEvaluateMode && !responseCorrect;\n\n const { validResponse } = validation || {};\n const correctAnswers = [];\n\n if (validResponse) {\n (validResponse.value || []).forEach((container, i) => {\n (container.images || []).forEach((v) => {\n correctAnswers.push({\n value: v,\n containerIndex: i,\n });\n });\n });\n }\n\n const warningMessage = translator.t('imageClozeAssociation.reachedLimit_other',\n { lng: language, count: maxResponsePerZone });\n\n let answersToShow =\n responseCorrect !== undefined ? getAnswersCorrectness(answers, validation, duplicateResponses) : answers;\n\n if (responseCorrect === false && maxResponsePerZone === 1) {\n answersToShow = [...answersToShow, ...getUnansweredAnswers(answersToShow, validation)];\n }\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n className={classes.teacherInstructions}\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n <PreviewPrompt prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n <PreviewPrompt className=\"prompt\" prompt={prompt} />\n\n <PreviewPrompt defaultClassName={classes.stimulus} prompt={stimulus} />\n\n <CorrectAnswerToggle show={showToggle} toggled={showCorrect} onToggle={this.toggleCorrect} language={language}/>\n\n {showCorrect && showToggle ? (\n <InteractiveSection responseCorrect={true} uiStyle={uiStyle}>\n <Image\n canDrag={false}\n answers={correctAnswers}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n </InteractiveSection>\n ) : (\n <InteractiveSection responseCorrect={responseCorrect} uiStyle={uiStyle}>\n <Image\n canDrag={!disabled}\n answers={answersToShow}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n\n {maxResponsePerZoneWarning && <WarningInfo message={warningMessage} />}\n\n <PossibleResponses\n canDrag={!disabled}\n data={possibleResponses}\n onAnswerRemove={this.handleOnAnswerRemove}\n onDragBegin={this.beginDrag}\n onDragEnd={this.handleOnDragEnd}\n />\n </InteractiveSection>\n )}\n\n {rationale && hasText(rationale) && (\n <Collapsible\n className={classes.rationale}\n labels={{\n hidden: 'Show Rationale',\n visible: 'Hide Rationale',\n }}\n >\n <PreviewPrompt prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nconst WarningInfo = withStyles((theme) => ({\n warning: {\n margin: `0 ${theme.spacing.unit * 2}px`,\n backgroundColor: '#dddddd',\n padding: theme.spacing.unit,\n display: 'flex',\n alignItems: 'center',\n width: 'fit-content',\n '& svg': {\n height: '30px',\n },\n '& h1': {\n padding: '0px',\n margin: '0px',\n },\n },\n message: {\n paddingLeft: theme.spacing.unit / 2,\n userSelect: 'none',\n },\n}))(({ classes, message }) => (\n <TransitionGroup>\n <CSSTransition classNames={'fb'} key=\"fb\" timeout={300}>\n <div key=\"panel\" className={classes.warning}>\n <ShowRationale iconSet=\"emoji\" shape=\"square\" />\n <span className={classes.message} dangerouslySetInnerHTML={{ __html: message }} />\n </div>\n </CSSTransition>\n </TransitionGroup>\n));\n\nWarningInfo.propTypes = {\n message: PropTypes.string,\n classes: PropTypes.object.isRequired,\n};\n\nImageClozeAssociationComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n session: PropTypes.object,\n updateAnswer: PropTypes.func.isRequired,\n};\n\nImageClozeAssociationComponent.defaultProps = {\n classes: {},\n};\n\nconst StyledComponent = withStyles(styles)(ImageClozeAssociationComponent);\n\nexport default withDragContext(StyledComponent);\n"],"file":"root.js"}
1
+ {"version":3,"sources":["../src/root.jsx"],"names":["translator","Translator","generateId","Math","random","toString","substring","Date","getTime","styles","theme","main","color","text","backgroundColor","background","stimulus","fontSize","typography","teacherInstructions","marginBottom","spacing","unit","rationale","marginTop","ImageClozeAssociationComponent","props","draggingElement","setState","id","value","possibleResponses","answer","index","findIndex","response","slice","responseContainerIndex","duplicateResponses","model","updateAnswer","state","answers","maxResponsePerZone","answersToStore","filter","a","containerIndex","length","answersInThisContainer","answersInOtherContainers","b","shiftedItem","shift","maxResponsePerZoneWarning","Array","isArray","push","_","max","map","c","parseInt","isNaN","filterPossibleAnswers","shouldNotPushInPossibleResponses","undefined","showCorrect","responseContainers","session","possibleResponsesWithIds","item","groupBy","grp","flatMap","possibleResponsesFiltered","find","classes","disabled","image","responseCorrect","validation","prompt","showDashedBorder","mode","language","uiStyle","isEvaluateMode","showToggle","validResponse","correctAnswers","forEach","container","i","images","v","warningMessage","t","lng","count","answersToShow","hidden","visible","toggleCorrect","handleOnAnswerSelect","beginDrag","handleOnDragEnd","handleOnAnswerRemove","React","Component","WarningInfo","warning","margin","padding","display","alignItems","width","height","message","paddingLeft","userSelect","__html","propTypes","PropTypes","string","object","isRequired","func","defaultProps","StyledComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AALA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAOA,IAAME,UAAU,GAAG,SAAbA,UAAa;AAAA,SAAMC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,SAA3B,CAAqC,CAArC,IAA0C,IAAIC,IAAJ,GAAWC,OAAX,GAAqBH,QAArB,CAA8B,EAA9B,CAAhD;AAAA,CAAnB;;AAEA,IAAMI,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,QAAQ,EAAEP,KAAK,CAACQ,UAAN,CAAiBD;AADnB,KALe;AAQzBE,IAAAA,mBAAmB,EAAE;AACnBC,MAAAA,YAAY,EAAEV,KAAK,CAACW,OAAN,CAAcC,IAAd,GAAqB;AADhB,KARI;AAWzBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAEd,KAAK,C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ApC,kBACE,gCAAC,oBAAD;AAAe,IAAA,OAAO,EAAC,OAAvB;AAA+B,IAAA,KAAK,EAAC;AAArC,IADF,eAEE;AAAM,IAAA,SAAS,EAAElC,OAAO,CAACyC,OAAzB;AAAkC,IAAA,uBAAuB,EAAE;AAAEG,MAAAA,MAAM,EAAEH;AAAV;AAA3D,IAFF,CADF,CADF,CADE;AAAA,CApBgB,CAApB;AA+BAR,WAAW,CAACY,SAAZ,GAAwB;AACtBJ,EAAAA,OAAO,EAAEK,sBAAUC,MADG;AAEtB/C,EAAAA,OAAO,EAAE8C,sBAAUE,MAAV,CAAiBC;AAFJ,CAAxB;AAKArG,8BAA8B,CAACiG,SAA/B,GAA2C;AACzC7C,EAAAA,OAAO,EAAE8C,sBAAUE,MADsB;AAEzCtF,EAAAA,KAAK,EAAEoF,sBAAUE,MAAV,CAAiBC,UAFiB;AAGzCzD,EAAAA,OAAO,EAAEsD,sBAAUE,MAHsB;AAIzCrF,EAAAA,YAAY,EAAEmF,sBAAUI,IAAV,CAAeD;AAJY,CAA3C;AAOArG,8BAA8B,CAACuG,YAA/B,GAA8C;AAC5CnD,EAAAA,OAAO,EAAE;AADmC,CAA9C;AAIA,IAAMoD,eAAe,GAAG,wBAAWxH,MAAX,EAAmBgB,8BAAnB,CAAxB;;eAEe,2BAAgBwG,eAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withDragContext } from '@pie-lib/pie-toolbox/drag';\nimport { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport { ShowRationale } from '@pie-lib/pie-toolbox/icons';\nimport { color, Collapsible, PreviewPrompt, hasText } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\nimport Image from './image-container';\nimport InteractiveSection from './interactive-section';\nimport PossibleResponses from './possible-responses';\nimport { getUnansweredAnswers, getAnswersCorrectness } from './utils-correctness';\nimport _ from 'lodash';\n\nconst generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n stimulus: {\n fontSize: theme.typography.fontSize,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n rationale: {\n marginTop: theme.spacing.unit * 2,\n }\n});\n\nclass ImageClozeAssociationComponent extends React.Component {\n constructor(props) {\n super(props);\n const {\n model: { possibleResponses, responseContainers, duplicateResponses, maxResponsePerZone },\n session,\n } = props;\n let { answers } = session || {};\n // set id for each possible response\n const possibleResponsesWithIds = (possibleResponses || []).map((item, index) => ({\n value: item,\n id: `${index}`,\n }));\n\n answers = _(answers || [])\n .groupBy('containerIndex')\n // keep only last maxResponsePerZone answers for each zone\n .map((grp) => grp.slice(-(maxResponsePerZone || 1)))\n .flatMap()\n // set id for each answer\n .map((answer, index) => ({ ...answer, id: `${index}` }))\n // return only answer which have a valid container index\n .filter((answer) => answer.containerIndex < responseContainers.length)\n .value();\n\n const possibleResponsesFiltered = possibleResponsesWithIds.filter(\n (response) => !answers.find((answer) => answer.value === response.value),\n );\n this.state = {\n answers: answers || [],\n draggingElement: { id: '', value: '' },\n possibleResponses: duplicateResponses ? possibleResponsesWithIds : possibleResponsesFiltered,\n // set id for each response containers\n responseContainers: (responseContainers || []).map((item, index) => ({\n index,\n ...item,\n id: `${index}`,\n })),\n maxResponsePerZone: maxResponsePerZone || 1,\n showCorrect: false,\n };\n }\n\n beginDrag = (draggingElement) => {\n this.setState({\n draggingElement,\n });\n };\n\n handleOnDragEnd = () => {\n this.setState({\n draggingElement: { id: '', value: '' },\n });\n };\n\n filterPossibleAnswers = (possibleResponses, answer) => {\n const index = possibleResponses.findIndex(response => response.value === answer.value);\n return [\n ...possibleResponses.slice(0, index), // Elements before the found item\n ...possibleResponses.slice(index + 1) // Elements after the found item\n ];\n };\n\n handleOnAnswerSelect = (answer, responseContainerIndex) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses, maxResponsePerZone } = this.state;\n let answersToStore;\n\n if (maxResponsePerZone === answers.filter((a) => a.containerIndex === responseContainerIndex).length) {\n const answersInThisContainer = answers.filter((a) => a.containerIndex === responseContainerIndex);\n const answersInOtherContainers = answers.filter((b) => b.containerIndex !== responseContainerIndex);\n\n const shiftedItem = answersInThisContainer[0];\n if (maxResponsePerZone === 1) {\n answersInThisContainer.shift(); // FIFO\n } else {\n this.setState({ maxResponsePerZoneWarning: true });\n return;\n }\n\n // if duplicates are not allowed, make sure to put the shifted value back in possible responses\n if (!duplicateResponses) {\n possibleResponses = Array.isArray(possibleResponses) ? possibleResponses : [];\n\n possibleResponses.push({\n ...shiftedItem,\n containerIndex: '',\n id: `${_.max(possibleResponses.map((c) => parseInt(c.id)).filter((id) => !isNaN(id))) + 1}`,\n });\n }\n\n // answers will be:\n // + shifted answers for the current container\n // + if duplicatesAllowed, all the other answers from other containers\n // else: all the answers from other containers that are not having the same value\n // + new answer\n answersToStore = [\n ...answersInThisContainer, // shifted\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answersInOtherContainers.filter((a) => (duplicateResponses ? true : a.value !== answer.value)), // un-shifted\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n } else {\n // answers will be:\n // + if duplicatesAllowed, all the other answers, except the one that was dragged\n // else: all the answers that are not having the same value\n // + new answer\n answersToStore = [\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answers.filter((a) => (duplicateResponses ? a.id !== answer.id : a.value !== answer.value)),\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n }\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n possibleResponses:\n // for single response per container remove answer from possible responses\n duplicateResponses\n ? possibleResponses\n : this.filterPossibleAnswers(possibleResponses, answer)\n });\n updateAnswer(answersToStore);\n };\n\n handleOnAnswerRemove = (answer) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses } = this.state;\n const answersToStore = answers.filter((a) => a.id !== answer.id);\n const shouldNotPushInPossibleResponses = answer.containerIndex === undefined; // don't duplicate possible responses\n\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n // push back into possible responses the removed answer if responses cannot be duplicated\n possibleResponses:\n duplicateResponses || shouldNotPushInPossibleResponses\n ? possibleResponses\n : [\n ...possibleResponses,\n {\n ...answer,\n containerIndex: undefined,\n },\n ],\n });\n updateAnswer(answersToStore);\n };\n\n toggleCorrect = (showCorrect) => this.setState({ showCorrect });\n\n render() {\n const {\n classes,\n model: {\n disabled,\n duplicateResponses,\n image,\n stimulus,\n responseCorrect,\n validation,\n teacherInstructions,\n prompt,\n showDashedBorder,\n mode,\n rationale,\n language,\n uiStyle = {},\n },\n } = this.props;\n const {\n answers,\n draggingElement,\n possibleResponses,\n responseContainers,\n maxResponsePerZone,\n maxResponsePerZoneWarning,\n showCorrect,\n } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showToggle = isEvaluateMode && !responseCorrect;\n\n const { validResponse } = validation || {};\n const correctAnswers = [];\n\n if (validResponse) {\n (validResponse.value || []).forEach((container, i) => {\n (container.images || []).forEach((v) => {\n correctAnswers.push({\n value: v,\n containerIndex: i,\n });\n });\n });\n }\n\n const warningMessage = translator.t('imageClozeAssociation.reachedLimit_other',\n { lng: language, count: maxResponsePerZone });\n\n let answersToShow =\n responseCorrect !== undefined ? getAnswersCorrectness(answers, validation, duplicateResponses) : answers;\n\n if (responseCorrect === false && maxResponsePerZone === 1) {\n answersToShow = [...answersToShow, ...getUnansweredAnswers(answersToShow, validation)];\n }\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n className={classes.teacherInstructions}\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n <PreviewPrompt prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n <PreviewPrompt className=\"prompt\" prompt={prompt} />\n\n <PreviewPrompt defaultClassName={classes.stimulus} prompt={stimulus} />\n\n <CorrectAnswerToggle show={showToggle} toggled={showCorrect} onToggle={this.toggleCorrect} language={language}/>\n\n {showCorrect && showToggle ? (\n <InteractiveSection responseCorrect={true} uiStyle={uiStyle}>\n <Image\n canDrag={false}\n answers={correctAnswers}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n </InteractiveSection>\n ) : (\n <InteractiveSection responseCorrect={responseCorrect} uiStyle={uiStyle}>\n <Image\n canDrag={!disabled}\n answers={answersToShow}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n\n {maxResponsePerZoneWarning && <WarningInfo message={warningMessage} />}\n\n <PossibleResponses\n canDrag={!disabled}\n data={possibleResponses}\n onAnswerRemove={this.handleOnAnswerRemove}\n onDragBegin={this.beginDrag}\n onDragEnd={this.handleOnDragEnd}\n />\n </InteractiveSection>\n )}\n\n {rationale && hasText(rationale) && (\n <Collapsible\n className={classes.rationale}\n labels={{\n hidden: 'Show Rationale',\n visible: 'Hide Rationale',\n }}\n >\n <PreviewPrompt prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nconst WarningInfo = withStyles((theme) => ({\n warning: {\n margin: `0 ${theme.spacing.unit * 2}px`,\n backgroundColor: '#dddddd',\n padding: theme.spacing.unit,\n display: 'flex',\n alignItems: 'center',\n width: 'fit-content',\n '& svg': {\n height: '30px',\n },\n '& h1': {\n padding: '0px',\n margin: '0px',\n },\n },\n message: {\n paddingLeft: theme.spacing.unit / 2,\n userSelect: 'none',\n },\n}))(({ classes, message }) => (\n <TransitionGroup>\n <CSSTransition classNames={'fb'} key=\"fb\" timeout={300}>\n <div key=\"panel\" className={classes.warning}>\n <ShowRationale iconSet=\"emoji\" shape=\"square\" />\n <span className={classes.message} dangerouslySetInnerHTML={{ __html: message }} />\n </div>\n </CSSTransition>\n </TransitionGroup>\n));\n\nWarningInfo.propTypes = {\n message: PropTypes.string,\n classes: PropTypes.object.isRequired,\n};\n\nImageClozeAssociationComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n session: PropTypes.object,\n updateAnswer: PropTypes.func.isRequired,\n};\n\nImageClozeAssociationComponent.defaultProps = {\n classes: {},\n};\n\nconst StyledComponent = withStyles(styles)(ImageClozeAssociationComponent);\n\nexport default withDragContext(StyledComponent);\n"],"file":"root.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association",
3
- "version": "5.15.3",
3
+ "version": "5.15.4",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -10,7 +10,7 @@
10
10
  "@material-ui/core": "^3.9.3",
11
11
  "@material-ui/icons": "^3.0.1",
12
12
  "@pie-framework/pie-player-events": "^0.1.0",
13
- "@pie-lib/pie-toolbox": "1.17.3",
13
+ "@pie-lib/pie-toolbox": "1.17.4",
14
14
  "classnames": "^2.2.6",
15
15
  "prop-types": "^15.6.1",
16
16
  "react": "^16.8.1",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "author": "pie framework developers",
20
20
  "license": "ISC",
21
- "gitHead": "c05a86593b64b6c7a7d48ff484cfa5a2a3ade3ea",
21
+ "gitHead": "512624fa52f5c653c74c32fa49c23af8c6d91c99",
22
22
  "scripts": {
23
23
  "postpublish": "../../scripts/postpublish"
24
24
  },
package/src/root.jsx CHANGED
@@ -88,6 +88,14 @@ class ImageClozeAssociationComponent extends React.Component {
88
88
  });
89
89
  };
90
90
 
91
+ filterPossibleAnswers = (possibleResponses, answer) => {
92
+ const index = possibleResponses.findIndex(response => response.value === answer.value);
93
+ return [
94
+ ...possibleResponses.slice(0, index), // Elements before the found item
95
+ ...possibleResponses.slice(index + 1) // Elements after the found item
96
+ ];
97
+ };
98
+
91
99
  handleOnAnswerSelect = (answer, responseContainerIndex) => {
92
100
  const {
93
101
  model: { duplicateResponses },
@@ -151,7 +159,6 @@ class ImageClozeAssociationComponent extends React.Component {
151
159
  },
152
160
  ];
153
161
  }
154
-
155
162
  this.setState({
156
163
  maxResponsePerZoneWarning: false,
157
164
  answers: answersToStore,
@@ -159,7 +166,7 @@ class ImageClozeAssociationComponent extends React.Component {
159
166
  // for single response per container remove answer from possible responses
160
167
  duplicateResponses
161
168
  ? possibleResponses
162
- : possibleResponses.filter((response) => response.value !== answer.value),
169
+ : this.filterPossibleAnswers(possibleResponses, answer)
163
170
  });
164
171
  updateAnswer(answersToStore);
165
172
  };