@pie-element/image-cloze-association 10.1.2-next.2 → 10.1.2

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.
Files changed (130) hide show
  1. package/CHANGELOG.json +437 -0
  2. package/CHANGELOG.md +1997 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +197 -0
  6. package/configure/CHANGELOG.md +1600 -0
  7. package/configure/lib/defaults.js +86 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/index.js +99 -0
  10. package/configure/lib/index.js.map +1 -0
  11. package/configure/lib/root.js +135 -0
  12. package/configure/lib/root.js.map +1 -0
  13. package/configure/package.json +23 -0
  14. package/configure/src/__tests__/index.test.js +155 -0
  15. package/configure/src/defaults.js +59 -0
  16. package/configure/src/index.js +114 -0
  17. package/configure/src/root.jsx +116 -0
  18. package/controller/CHANGELOG.json +137 -0
  19. package/controller/CHANGELOG.md +1149 -0
  20. package/controller/lib/defaults.js +14 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +304 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +70 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +19 -0
  27. package/controller/src/__tests__/index.test.js +711 -0
  28. package/controller/src/defaults.js +7 -0
  29. package/controller/src/index.js +322 -0
  30. package/controller/src/utils.js +72 -0
  31. package/docs/config-schema.json +1382 -0
  32. package/docs/config-schema.json.md +1021 -0
  33. package/docs/demo/config.js +8 -0
  34. package/docs/demo/generate.js +74 -0
  35. package/docs/demo/index.html +1 -0
  36. package/docs/demo/session.js +16 -0
  37. package/docs/pie-schema.json +1085 -0
  38. package/docs/pie-schema.json.md +810 -0
  39. package/lib/constants.js +12 -0
  40. package/lib/constants.js.map +1 -0
  41. package/lib/evaluation-icon.js +60 -0
  42. package/lib/evaluation-icon.js.map +1 -0
  43. package/lib/image-container.js +94 -0
  44. package/lib/image-container.js.map +1 -0
  45. package/lib/image-drop-target.js +130 -0
  46. package/lib/image-drop-target.js.map +1 -0
  47. package/lib/index.js +220 -0
  48. package/lib/index.js.map +1 -0
  49. package/lib/interactive-section.js +104 -0
  50. package/lib/interactive-section.js.map +1 -0
  51. package/lib/possible-response.js +161 -0
  52. package/lib/possible-response.js.map +1 -0
  53. package/lib/possible-responses.js +58 -0
  54. package/lib/possible-responses.js.map +1 -0
  55. package/lib/root.js +491 -0
  56. package/lib/root.js.map +1 -0
  57. package/lib/static-html-span.js +35 -0
  58. package/lib/static-html-span.js.map +1 -0
  59. package/lib/utils-correctness.js +89 -0
  60. package/lib/utils-correctness.js.map +1 -0
  61. package/package.json +21 -86
  62. package/src/__tests__/index.test.js +174 -0
  63. package/src/__tests__/root.test.jsx +99 -0
  64. package/src/__tests__/utils.test.js +207 -0
  65. package/src/constants.js +5 -0
  66. package/src/evaluation-icon.jsx +54 -0
  67. package/src/image-container.jsx +90 -0
  68. package/src/image-drop-target.jsx +140 -0
  69. package/src/index.js +245 -0
  70. package/src/interactive-section.jsx +94 -0
  71. package/src/possible-response.jsx +152 -0
  72. package/src/possible-responses.jsx +52 -0
  73. package/src/root.jsx +490 -0
  74. package/src/static-html-span.jsx +30 -0
  75. package/src/utils-correctness.js +95 -0
  76. package/configure.js +0 -2
  77. package/controller.js +0 -1
  78. package/dist/author/defaults.d.ts +0 -88
  79. package/dist/author/defaults.js +0 -58
  80. package/dist/author/index.d.ts +0 -34
  81. package/dist/author/index.js +0 -71
  82. package/dist/author/root.d.ts +0 -14
  83. package/dist/author/root.js +0 -80
  84. package/dist/browser/Check-DL1c-mLM.js +0 -10708
  85. package/dist/browser/Check-DL1c-mLM.js.map +0 -1
  86. package/dist/browser/author/index.js +0 -38597
  87. package/dist/browser/author/index.js.map +0 -1
  88. package/dist/browser/controller/index.js +0 -171
  89. package/dist/browser/controller/index.js.map +0 -1
  90. package/dist/browser/delivery/index.js +0 -2699
  91. package/dist/browser/delivery/index.js.map +0 -1
  92. package/dist/browser/dist-BphSS14E.js +0 -346
  93. package/dist/browser/dist-BphSS14E.js.map +0 -1
  94. package/dist/browser/humps-CZ4RCLab.js +0 -67
  95. package/dist/browser/humps-CZ4RCLab.js.map +0 -1
  96. package/dist/browser/image-cloze-association.css +0 -2
  97. package/dist/controller/defaults.d.ts +0 -16
  98. package/dist/controller/defaults.js +0 -10
  99. package/dist/controller/index.d.ts +0 -23
  100. package/dist/controller/index.js +0 -122
  101. package/dist/controller/utils.d.ts +0 -14
  102. package/dist/controller/utils.js +0 -36
  103. package/dist/delivery/constants.d.ts +0 -14
  104. package/dist/delivery/evaluation-icon.d.ts +0 -28
  105. package/dist/delivery/evaluation-icon.js +0 -38
  106. package/dist/delivery/image-container.d.ts +0 -13
  107. package/dist/delivery/image-container.js +0 -61
  108. package/dist/delivery/image-drop-target.d.ts +0 -45
  109. package/dist/delivery/image-drop-target.js +0 -90
  110. package/dist/delivery/index.d.ts +0 -20
  111. package/dist/delivery/index.js +0 -110
  112. package/dist/delivery/interactive-section.d.ts +0 -15
  113. package/dist/delivery/interactive-section.js +0 -72
  114. package/dist/delivery/possible-response.d.ts +0 -34
  115. package/dist/delivery/possible-response.js +0 -100
  116. package/dist/delivery/possible-responses.d.ts +0 -31
  117. package/dist/delivery/possible-responses.js +0 -41
  118. package/dist/delivery/root.d.ts +0 -21
  119. package/dist/delivery/root.js +0 -278
  120. package/dist/delivery/static-html-span.d.ts +0 -14
  121. package/dist/delivery/static-html-span.js +0 -22
  122. package/dist/delivery/utils-correctness.d.ts +0 -10
  123. package/dist/delivery/utils-correctness.js +0 -43
  124. package/dist/index.d.ts +0 -1
  125. package/dist/index.iife.d.ts +0 -8
  126. package/dist/index.iife.js +0 -152
  127. package/dist/index.js +0 -2
  128. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  129. package/dist/runtime-support.d.ts +0 -12
  130. package/dist/runtime-support.js +0 -12
@@ -0,0 +1,114 @@
1
+ import {
2
+ ModelUpdatedEvent,
3
+ DeleteImageEvent,
4
+ InsertImageEvent,
5
+ InsertSoundEvent,
6
+ DeleteSoundEvent,
7
+ } from '@pie-framework/pie-configure-events';
8
+
9
+ import React from 'react';
10
+ import { createRoot } from 'react-dom/client';
11
+ import debug from 'debug';
12
+
13
+ import Root from './root';
14
+ import sensibleDefaults from './defaults';
15
+
16
+ const log = debug('image-cloze-association:configure');
17
+
18
+ export default class ImageClozeAssociationConfigure extends HTMLElement {
19
+ static createDefaultModel = (model = {}) => ({
20
+ ...sensibleDefaults.model,
21
+ ...model,
22
+ });
23
+
24
+ constructor() {
25
+ super();
26
+ this._root = null;
27
+ this._model = ImageClozeAssociationConfigure.createDefaultModel();
28
+ this.onModelChanged = this.onModelChanged.bind(this);
29
+ this._configuration = sensibleDefaults.configuration;
30
+ }
31
+
32
+ set model(s) {
33
+ this._model = ImageClozeAssociationConfigure.createDefaultModel(s);
34
+ this._render();
35
+ }
36
+
37
+ set configuration(c) {
38
+ this._configuration = c;
39
+ this._render();
40
+ }
41
+
42
+ set disableSidePanel(s) {
43
+ this._disableSidePanel = s;
44
+ this._render();
45
+ }
46
+
47
+ dispatchModelUpdated(reset) {
48
+ const resetValue = !!reset;
49
+
50
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
51
+ }
52
+
53
+ onModelChanged(m, reset) {
54
+ this._model = m;
55
+ this.dispatchModelUpdated(reset);
56
+ this._render();
57
+ }
58
+
59
+ onConfigurationChanged(config) {
60
+ this._configuration = config;
61
+ this._render();
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param {done, progress, file} handler
67
+ */
68
+ insertImage(handler) {
69
+ this.dispatchEvent(new InsertImageEvent(handler));
70
+ }
71
+
72
+ onDeleteImage(src, done) {
73
+ this.dispatchEvent(new DeleteImageEvent(src, done));
74
+ }
75
+
76
+ insertSound(handler) {
77
+ this.dispatchEvent(new InsertSoundEvent(handler));
78
+ }
79
+
80
+ onDeleteSound(src, done) {
81
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
82
+ }
83
+
84
+ _render() {
85
+ log('_render');
86
+
87
+ let element = React.createElement(Root, {
88
+ disableSidePanel: this._disableSidePanel,
89
+ model: this._model,
90
+ configuration: this._configuration,
91
+ onModelChanged: this.onModelChanged.bind(this),
92
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
93
+ imageSupport: {
94
+ add: this.insertImage.bind(this),
95
+ delete: this.onDeleteImage.bind(this),
96
+ },
97
+ uploadSoundSupport: {
98
+ add: this.insertSound.bind(this),
99
+ delete: this.onDeleteSound.bind(this),
100
+ },
101
+ });
102
+
103
+ if (!this._root) {
104
+ this._root = createRoot(this);
105
+ }
106
+ this._root.render(element);
107
+ }
108
+
109
+ disconnectedCallback() {
110
+ if (this._root) {
111
+ this._root.unmount();
112
+ }
113
+ }
114
+ }
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { settings, layout, InputContainer } from '@pie-lib/config-ui';
4
+ import EditableHtml from '@pie-lib/editable-html-tip-tap';
5
+ import { styled } from '@mui/material/styles';
6
+
7
+ const { Panel, toggle, dropdown } = settings;
8
+
9
+ const StyledInputContainer = styled(InputContainer)(({ theme }) => ({
10
+ width: '100%',
11
+ paddingTop: theme.spacing(2),
12
+ marginBottom: theme.spacing(2),
13
+ }));
14
+
15
+ const ErrorText = styled('div')(({ theme }) => ({
16
+ fontSize: theme.typography.fontSize - 2,
17
+ color: theme.palette.error.main,
18
+ paddingTop: theme.spacing(1),
19
+ }));
20
+
21
+ export class Root extends React.Component {
22
+ onTeacherInstructionsChanged = (teacherInstructions) => {
23
+ this.props.onModelChanged({ ...this.props.model, teacherInstructions });
24
+ };
25
+
26
+ render() {
27
+ const { model, configuration, onModelChanged, onConfigurationChanged, imageSupport, uploadSoundSupport } =
28
+ this.props;
29
+ const {
30
+ baseInputConfiguration = {},
31
+ contentDimensions = {},
32
+ maxImageWidth = {},
33
+ maxImageHeight = {},
34
+ settingsPanelDisabled,
35
+ spellCheck = {},
36
+ teacherInstructions = {},
37
+ withRubric = {},
38
+ mathMlOptions = {},
39
+ language = {},
40
+ languageChoices = {},
41
+ } = configuration || {};
42
+ const { errors = {}, extraCSSRules, spellCheckEnabled } = model || {};
43
+ const { teacherInstructions: teacherInstructionsError } = errors;
44
+
45
+ const panelProperties = {
46
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
47
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
48
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label),
49
+ 'language.enabled': language.settings && toggle(language.label, true),
50
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),
51
+ };
52
+
53
+ const getPluginProps = (props = {}) => ({
54
+ ...baseInputConfiguration,
55
+ ...props,
56
+ });
57
+
58
+ return (
59
+ <layout.ConfigLayout
60
+ extraCSSRules={extraCSSRules}
61
+ dimensions={contentDimensions}
62
+ hideSettings={settingsPanelDisabled}
63
+ settings={
64
+ <Panel
65
+ model={model}
66
+ configuration={configuration}
67
+ onChangeModel={(model) => onModelChanged(model)}
68
+ onChangeConfiguration={(config) => onConfigurationChanged(config)}
69
+ groups={{
70
+ Properties: panelProperties,
71
+ }}
72
+ />
73
+ }
74
+ >
75
+ {model && model.teacherInstructionsEnabled && (
76
+ <StyledInputContainer label={teacherInstructions.label}>
77
+ <EditableHtml
78
+ markup={model.teacherInstructions || ''}
79
+ onChange={this.onTeacherInstructionsChanged}
80
+ imageSupport={imageSupport}
81
+ nonEmpty={false}
82
+ error={teacherInstructionsError}
83
+ spellCheck={spellCheckEnabled}
84
+ pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}
85
+ maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions}
86
+ maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions}
87
+ uploadSoundSupport={uploadSoundSupport}
88
+ languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
89
+ mathMlOptions={mathMlOptions}
90
+ />
91
+ {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}
92
+ </StyledInputContainer>
93
+ )}
94
+
95
+ <div>Image cloze association</div>
96
+ </layout.ConfigLayout>
97
+ );
98
+ }
99
+ }
100
+
101
+ Root.propTypes = {
102
+ onModelChanged: PropTypes.func,
103
+ onConfigurationChanged: PropTypes.func,
104
+ model: PropTypes.object.isRequired,
105
+ configuration: PropTypes.object.isRequired,
106
+ imageSupport: PropTypes.shape({
107
+ add: PropTypes.func.isRequired,
108
+ delete: PropTypes.func.isRequired,
109
+ }),
110
+ uploadSoundSupport: PropTypes.shape({
111
+ add: PropTypes.func.isRequired,
112
+ delete: PropTypes.func.isRequired,
113
+ }),
114
+ };
115
+
116
+ export default Root;
@@ -0,0 +1,137 @@
1
+ [
2
+ {
3
+ "type": "feat",
4
+ "scope": null,
5
+ "subject": "Added configuration, settings panel and support for teacher instructions.",
6
+ "merge": null,
7
+ "header": "feat: Added configuration, settings panel and support for teacher instructions.",
8
+ "body": null,
9
+ "footer": null,
10
+ "notes": [],
11
+ "hash": "b54170b24e397aa4fefd5eaa9a831c23455be7a9",
12
+ "gitTags": "",
13
+ "committerDate": "2019-07-09 00:10:49 +0300",
14
+ "isTagged": true,
15
+ "tag": "@pie-element/image-cloze-association-controller@1.1.0"
16
+ },
17
+ {
18
+ "type": "fix",
19
+ "scope": null,
20
+ "subject": "calculate correct partial when comes to duplicates and extra answers",
21
+ "merge": null,
22
+ "header": "fix: calculate correct partial when comes to duplicates and extra answers",
23
+ "body": null,
24
+ "footer": null,
25
+ "notes": [],
26
+ "hash": "a8b1677e48929c4027b090361f1200fffaca212b",
27
+ "gitTags": " (origin/sergiulucaci/ch1955/partial-scoring-fix)",
28
+ "committerDate": "2019-07-29 16:44:59 +0300",
29
+ "isTagged": true,
30
+ "tag": "@pie-element/image-cloze-association-controller@1.2.0"
31
+ },
32
+ {
33
+ "type": "feat",
34
+ "scope": null,
35
+ "subject": "support alternate correct answers",
36
+ "merge": null,
37
+ "header": "feat: support alternate correct answers",
38
+ "body": null,
39
+ "footer": null,
40
+ "notes": [],
41
+ "hash": "03b5ce0ad1db77ebfb86a0c3dcb0aaf02a0bbf5a",
42
+ "gitTags": " (origin/sergiulucaci/ch1955/ica-alternate-correct-answers)",
43
+ "committerDate": "2019-07-26 16:09:36 +0300",
44
+ "isTagged": true,
45
+ "tag": "@pie-element/image-cloze-association-controller@1.2.0"
46
+ },
47
+ {
48
+ "type": "feat",
49
+ "scope": null,
50
+ "subject": "Session null/empty check.",
51
+ "merge": null,
52
+ "header": "feat: Session null/empty check.",
53
+ "body": "Check for each interaction if: has outcome function, outcome function returns { score: 0, empty: true } if session null/empty/undefined, everywhere where session is used we handle if session is null/empty/undefined and test each function that uses session. [image-cloze-association, inline-choice, inline-dropdown]",
54
+ "footer": null,
55
+ "notes": [],
56
+ "hash": "35c2cab1f174e1ede63e9b68ae6c955d7ee12b82",
57
+ "gitTags": "",
58
+ "committerDate": "2019-08-25 15:44:31 +0300",
59
+ "isTagged": true,
60
+ "tag": "@pie-element/image-cloze-association-controller@1.3.0"
61
+ },
62
+ {
63
+ "type": "fix",
64
+ "scope": null,
65
+ "subject": "ch2766 fix unresolved promise (#366)",
66
+ "merge": null,
67
+ "header": "fix: ch2766 fix unresolved promise (#366)",
68
+ "body": "* fix: resolve null when instructor is not role\n\n* chore: typo\n\n* chore: correct response resolve, match interaction\n\n* chore: correct response unresolved\n\n* chore: categorize resolve correct response\n\n* fix: createCorrectResponseSession unresolved promise\n\n* fix: createCorrectResponseSession resolve promise\n\n* fix: createCorrectResponseSession resolve promise\n\n* fix: ch2776 resolve createCorrectResponse promise",
69
+ "footer": "* fix: Fixed createCorrectResponseSession and added tests for it. (#365)",
70
+ "notes": [],
71
+ "hash": "9057b7fd08e4f5b07e953a5acd053e1945df57f2",
72
+ "gitTags": " (origin/develop, origin/HEAD)",
73
+ "committerDate": "2019-10-16 15:50:55 -0400",
74
+ "isTagged": true,
75
+ "tag": "@pie-element/image-cloze-association-controller@3.0.1"
76
+ },
77
+ {
78
+ "type": "feat",
79
+ "scope": null,
80
+ "subject": "PIE-200 - add partialScoring",
81
+ "merge": null,
82
+ "header": "feat: PIE-200 - add partialScoring",
83
+ "body": null,
84
+ "footer": null,
85
+ "notes": [],
86
+ "hash": "4eb0b47230359f35513fc852ee95cd6845c4d156",
87
+ "gitTags": "",
88
+ "committerDate": "2019-12-06 12:22:05 +0000",
89
+ "isTagged": true,
90
+ "tag": "@pie-element/image-cloze-association-controller@3.1.0"
91
+ },
92
+ {
93
+ "type": "fix",
94
+ "scope": null,
95
+ "subject": "bump ui versions",
96
+ "merge": null,
97
+ "header": "fix: bump ui versions",
98
+ "body": null,
99
+ "footer": null,
100
+ "notes": [],
101
+ "hash": "5b9d99fe59c304bdd173c9336503eb558900d2a2",
102
+ "gitTags": "",
103
+ "committerDate": "2020-03-31 19:25:13 +0100",
104
+ "isTagged": true,
105
+ "tag": "@pie-element/image-cloze-association-controller@3.2.0"
106
+ },
107
+ {
108
+ "type": "fix",
109
+ "scope": null,
110
+ "subject": "bump all packages to avoid tag conflict",
111
+ "merge": null,
112
+ "header": "fix: bump all packages to avoid tag conflict",
113
+ "body": null,
114
+ "footer": null,
115
+ "notes": [],
116
+ "hash": "d9ec9a8689f0a391594b5e2f4ea958c6dc9f6d7b",
117
+ "gitTags": " (develop)",
118
+ "committerDate": "2020-04-10 20:01:37 +0100",
119
+ "isTagged": true,
120
+ "tag": "@pie-element/image-cloze-association-controller@3.2.1"
121
+ },
122
+ {
123
+ "type": "fix",
124
+ "scope": null,
125
+ "subject": "bump ui/lib versions",
126
+ "merge": null,
127
+ "header": "fix: bump ui/lib versions",
128
+ "body": null,
129
+ "footer": null,
130
+ "notes": [],
131
+ "hash": "3edb2321ebaefcaee70c3642aa6da8a50e8a99e5",
132
+ "gitTags": "",
133
+ "committerDate": "2020-04-14 15:36:44 +0100",
134
+ "isTagged": true,
135
+ "tag": "@pie-element/image-cloze-association-controller@3.2.3"
136
+ }
137
+ ]