@pie-element/ebsr 14.2.2-next.5 → 14.2.3

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 (100) hide show
  1. package/CHANGELOG.json +1547 -0
  2. package/CHANGELOG.md +2297 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +62 -0
  5. package/configure/CHANGELOG.json +992 -0
  6. package/configure/CHANGELOG.md +2160 -0
  7. package/configure/lib/defaults.js +229 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/index.js +154 -0
  10. package/configure/lib/index.js.map +1 -0
  11. package/configure/lib/main.js +222 -0
  12. package/configure/lib/main.js.map +1 -0
  13. package/configure/package.json +23 -0
  14. package/configure/src/__tests__/index.test.js +492 -0
  15. package/configure/src/defaults.js +173 -0
  16. package/configure/src/index.js +174 -0
  17. package/configure/src/main.jsx +235 -0
  18. package/controller/CHANGELOG.json +552 -0
  19. package/controller/CHANGELOG.md +1286 -0
  20. package/controller/lib/defaults.js +31 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +448 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +18 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +18 -0
  27. package/controller/src/__tests__/index.test.js +591 -0
  28. package/controller/src/__tests__/utils.test.js +48 -0
  29. package/controller/src/defaults.js +25 -0
  30. package/controller/src/index.js +442 -0
  31. package/controller/src/utils.js +18 -0
  32. package/docs/config-schema.json +5787 -0
  33. package/docs/config-schema.json.md +4278 -0
  34. package/docs/demo/config.js +8 -0
  35. package/docs/demo/generate.js +52 -0
  36. package/docs/demo/index.html +2 -0
  37. package/docs/demo/session.js +14 -0
  38. package/docs/pie-schema.json +2911 -0
  39. package/docs/pie-schema.json.md +2142 -0
  40. package/ebsr.png +0 -0
  41. package/lib/index.js +207 -0
  42. package/lib/index.js.map +1 -0
  43. package/lib/print.js +186 -0
  44. package/lib/print.js.map +1 -0
  45. package/module/configure.js +1 -0
  46. package/module/controller.js +5664 -0
  47. package/module/demo.js +77 -0
  48. package/module/element.js +1 -0
  49. package/module/index.html +21 -0
  50. package/module/manifest.json +14 -0
  51. package/module/print-demo.js +115 -0
  52. package/module/print.html +18 -0
  53. package/module/print.js +1 -0
  54. package/package.json +19 -88
  55. package/src/__tests__/index.test.js +129 -0
  56. package/src/index.js +222 -0
  57. package/src/print.js +207 -0
  58. package/configure.js +0 -2
  59. package/controller.js +0 -1
  60. package/dist/author/defaults.d.ts +0 -348
  61. package/dist/author/defaults.js +0 -161
  62. package/dist/author/index.d.ts +0 -34
  63. package/dist/author/index.js +0 -80
  64. package/dist/author/main.d.ts +0 -23
  65. package/dist/author/main.js +0 -123
  66. package/dist/browser/author/index.js +0 -45985
  67. package/dist/browser/author/index.js.map +0 -1
  68. package/dist/browser/controller/index.js +0 -257
  69. package/dist/browser/controller/index.js.map +0 -1
  70. package/dist/browser/delivery/index.js +0 -133
  71. package/dist/browser/delivery/index.js.map +0 -1
  72. package/dist/browser/delivery-BVQ60bNy.js +0 -1282
  73. package/dist/browser/delivery-BVQ60bNy.js.map +0 -1
  74. package/dist/browser/dist-BcIm7NXG.js +0 -111
  75. package/dist/browser/dist-BcIm7NXG.js.map +0 -1
  76. package/dist/browser/dist-D9ARZhQk.js +0 -1426
  77. package/dist/browser/dist-D9ARZhQk.js.map +0 -1
  78. package/dist/browser/ebsr.css +0 -2
  79. package/dist/browser/print/index.js +0 -107
  80. package/dist/browser/print/index.js.map +0 -1
  81. package/dist/browser/private-tags-DHmoD865.js +0 -9579
  82. package/dist/browser/private-tags-DHmoD865.js.map +0 -1
  83. package/dist/controller/defaults.d.ts +0 -15
  84. package/dist/controller/defaults.js +0 -26
  85. package/dist/controller/index.d.ts +0 -42
  86. package/dist/controller/index.js +0 -185
  87. package/dist/controller/utils.d.ts +0 -10
  88. package/dist/controller/utils.js +0 -8
  89. package/dist/delivery/index.d.ts +0 -26
  90. package/dist/delivery/index.js +0 -133
  91. package/dist/index.d.ts +0 -1
  92. package/dist/index.iife.d.ts +0 -8
  93. package/dist/index.iife.js +0 -165
  94. package/dist/index.js +0 -2
  95. package/dist/print/index.d.ts +0 -25
  96. package/dist/print/index.js +0 -107
  97. package/dist/private-tags.d.ts +0 -2
  98. package/dist/private-tags.js +0 -3
  99. package/dist/runtime-support.d.ts +0 -12
  100. package/dist/runtime-support.js +0 -12
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_styles","Panel","toggle","radio","dropdown","settings","PartLabel","styled","theme","paddingBottom","spacing","Divider","flex","height","Main","React","Component","constructor","args","_defineProperty2","default","choices","correctFound","map","choice","correct","model","key","onModelChanged","props","partA","choiceMode","removeExtraChoices","partB","render","configuration","onConfigurationChanged","partLabelType","modelPartA","modelPartB","extraCSSRules","contentDimensions","partialScoring","settingsPanelDisabled","scoringType","language","languageChoices","generalConfiguration","feedback","feedbackA","choiceModeA","choicePrefix","choicePrefixA","lockChoiceOrder","lockChoiceOrderA","prompt","promptA","teacherInstructions","teacherInstructionsA","studentInstructions","studentInstructionsA","choicesLayout","choicesLayoutA","gridColumns","gridColumnsA","rationale","rationaleA","spellCheck","spellCheckA","feedbackB","choiceModeB","choicePrefixB","lockChoiceOrderB","promptB","teacherInstructionsB","studentInstructionsB","choicesLayoutB","gridColumnsB","rationaleB","spellCheckB","type","typeIsNumber","firstPart","secondPart","nrOfColumnsAvailable","length","Array","from","_","i","panelSettings","partLabels","label","enabled","options","panelSettingsPartA","panelPropertiesPartA","panelSettingsPartB","panelPropertiesPartB","createElement","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onChangeConfiguration","groups","id","ref","_model","errors","exports","PropTypes","object","func","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { settings, layout } from '@pie-lib/config-ui';\nimport { styled } from '@mui/material/styles';\n\nconst { Panel, toggle, radio, dropdown } = settings;\n\nconst PartLabel = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n}));\n\nconst Divider = styled('div')(({ theme }) => ({\n flex: 1,\n height: theme.spacing(2.5),\n}));\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object,\n model: PropTypes.object,\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func,\n };\n\n removeExtraChoices = (choices) => {\n let correctFound = false;\n\n return (choices || []).map((choice) => {\n if (correctFound) {\n choice.correct = false;\n\n return choice;\n }\n\n if (choice.correct) {\n correctFound = true;\n }\n\n return choice;\n });\n };\n\n onModelChanged = (model, key) => {\n const { onModelChanged } = this.props;\n\n if (key === 'partA.choiceMode' && model.partA.choiceMode === 'radio') {\n model.partA.choices = this.removeExtraChoices(model.partA.choices);\n\n return onModelChanged(model, true);\n }\n\n if (key === 'partB.choiceMode' && model.partB.choiceMode === 'radio') {\n model.partB.choices = this.removeExtraChoices(model.partB.choices);\n\n return onModelChanged(model, true);\n }\n\n return onModelChanged(model);\n };\n\n render() {\n const { model, configuration, onConfigurationChanged } = this.props;\n const { partLabelType, partA: modelPartA, partB: modelPartB, extraCSSRules } = model;\n const {\n contentDimensions = {},\n partA = {},\n partB = {},\n partialScoring = {},\n settingsPanelDisabled,\n scoringType = {},\n language = {},\n languageChoices = {},\n ...generalConfiguration\n } = configuration;\n const {\n feedback: feedbackA = {},\n choiceMode: choiceModeA = {},\n choicePrefix: choicePrefixA = {},\n lockChoiceOrder: lockChoiceOrderA = {},\n prompt: promptA = {},\n teacherInstructions: teacherInstructionsA = {},\n studentInstructions: studentInstructionsA = {},\n choicesLayout: choicesLayoutA = {},\n gridColumns: gridColumnsA = {},\n rationale: rationaleA = {},\n spellCheck: spellCheckA = {},\n } = partA || {};\n const {\n feedback: feedbackB = {},\n choiceMode: choiceModeB = {},\n choicePrefix: choicePrefixB = {},\n lockChoiceOrder: lockChoiceOrderB = {},\n prompt: promptB = {},\n teacherInstructions: teacherInstructionsB = {},\n studentInstructions: studentInstructionsB = {},\n choicesLayout: choicesLayoutB = {},\n gridColumns: gridColumnsB = {},\n rationale: rationaleB = {},\n spellCheck: spellCheckB = {},\n } = partB || {};\n\n const type = partLabelType || 'Numbers';\n const typeIsNumber = type === 'Numbers';\n const firstPart = `Part ${typeIsNumber ? '1' : 'A'}`;\n const secondPart = `Part ${typeIsNumber ? '2' : 'B'}`;\n const nrOfColumnsAvailable = {\n partA:\n modelPartA.choices && modelPartA.choices.length\n ? Array.from({ length: modelPartA.choices.length }, (_, i) => `${i + 1}`)\n : [],\n partB:\n modelPartB.choices && modelPartB.choices.length\n ? Array.from({ length: modelPartB.choices.length }, (_, i) => `${i + 1}`)\n : [],\n };\n\n const panelSettings = {\n partLabels: generalConfiguration.partLabels.settings && toggle(generalConfiguration.partLabels.label),\n partLabelType: model.partLabels && dropdown('', ['Numbers', 'Letters']),\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelSettingsPartA = {\n 'partA.choiceMode': choiceModeA.settings && radio(choiceModeA.label, ['checkbox', 'radio']),\n 'partA.choicePrefix': choicePrefixA.settings && radio(choicePrefixA.label, ['numbers', 'letters']),\n 'partA.lockChoiceOrder': lockChoiceOrderA.settings && toggle(lockChoiceOrderA.label),\n 'partA.choicesLayout':\n choicesLayoutA.settings && dropdown(choicesLayoutA.label, ['vertical', 'grid', 'horizontal']),\n 'partA.gridColumns':\n choicesLayoutA.settings &&\n modelPartA.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partA.length > 0 &&\n dropdown(gridColumnsA.label, nrOfColumnsAvailable.partA),\n };\n const panelPropertiesPartA = {\n 'partA.feedbackEnabled': feedbackA.settings && toggle(feedbackA.label),\n 'partA.promptEnabled': promptA.settings && toggle(promptA.label),\n 'partA.teacherInstructionsEnabled': teacherInstructionsA.settings && toggle(teacherInstructionsA.label),\n 'partA.studentInstructionsEnabled': studentInstructionsA.settings && toggle(studentInstructionsA.label),\n 'partA.rationaleEnabled': rationaleA.settings && toggle(rationaleA.label),\n 'partA.spellCheckEnabled': spellCheckA.settings && toggle(spellCheckA.label),\n };\n\n const panelSettingsPartB = {\n 'partB.choiceMode': choiceModeB.settings && radio(choiceModeB.label, ['checkbox', 'radio']),\n 'partB.choicePrefix': choicePrefixB.settings && radio(choicePrefixB.label, ['numbers', 'letters']),\n 'partB.lockChoiceOrder': lockChoiceOrderB.settings && toggle(lockChoiceOrderB.label),\n 'partB.choicesLayout':\n choicesLayoutB.settings && dropdown(choicesLayoutB.label, ['vertical', 'grid', 'horizontal']),\n 'partB.gridColumns':\n choicesLayoutB.settings &&\n modelPartB.choicesLayout === 'grid' &&\n nrOfColumnsAvailable.partB.length > 0 &&\n dropdown(gridColumnsB.label, nrOfColumnsAvailable.partB),\n };\n const panelPropertiesPartB = {\n 'partB.feedbackEnabled': feedbackB.settings && toggle(feedbackB.label),\n 'partB.promptEnabled': promptB.settings && toggle(promptB.label),\n 'partB.teacherInstructionsEnabled': teacherInstructionsB.settings && toggle(teacherInstructionsB.label),\n 'partB.studentInstructionsEnabled': studentInstructionsB.settings && toggle(studentInstructionsB.label),\n 'partB.rationaleEnabled': rationaleB.settings && toggle(rationaleB.label),\n 'partB.spellCheckEnabled': spellCheckB.settings && toggle(spellCheckB.label),\n };\n\n return (\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n onChangeModel={this.onModelChanged}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings for both': panelSettings,\n [`Settings ${firstPart}`]: panelSettingsPartA,\n [`Properties ${firstPart}`]: panelPropertiesPartA,\n [`Settings ${secondPart}`]: panelSettingsPartB,\n [`Properties ${secondPart}`]: panelPropertiesPartB,\n }}\n />\n }\n >\n {model.partLabels && <PartLabel>{firstPart}</PartLabel>}\n <ebsr-multiple-choice-configure\n id=\"A\"\n key=\"partA\"\n ref={(ref) => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partA = ref;\n this.partA._model = {\n ...this.props.model.partA,\n errors: (this.props.model.errors && this.props.model.errors.partA) || {},\n };\n this.partA.configuration = {\n ...partA,\n ...generalConfiguration,\n };\n }\n }}\n />\n\n <Divider />\n\n {model.partLabels && <PartLabel>{secondPart}</PartLabel>}\n <ebsr-multiple-choice-configure\n id=\"B\"\n key=\"partB\"\n ref={(ref) => {\n if (ref) {\n // do not use destructuring to get model from props\n this.partB = ref;\n this.partB._model = {\n ...this.props.model.partB,\n errors: (this.props.model.errors && this.props.model.errors.partB) || {},\n };\n this.partB.configuration = {\n ...partB,\n ...generalConfiguration,\n };\n }\n }}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAM;EAAEI,KAAK;EAAEC,MAAM;EAAEC,KAAK;EAAEC;AAAS,CAAC,GAAGC,kBAAQ;AAEnD,MAAMC,SAAS,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC9CC,aAAa,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,MAAMC,OAAO,GAAG,IAAAJ,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5CI,IAAI,EAAE,CAAC;EACPC,MAAM,EAAEL,KAAK,CAACE,OAAO,CAAC,GAAG;AAC3B,CAAC,CAAC,CAAC;AAEI,MAAMI,IAAI,SAASC,cAAK,CAACC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,IAAI,CAAChF,KAAK,CAACH,KAAK,CAACO,KAAK;YACzB6E,MAAM,EAAG,IAAI,CAACjF,KAAK,CAACH,KAAK,CAACoF,MAAM,IAAI,IAAI,CAACjF,KAAK,CAACH,KAAK,CAACoF,MAAM,CAAC7E,KAAK,IAAK,CAAC;UACzE,CAAC;UACD,IAAI,CAACA,KAAK,CAACE,aAAa,GAAG;YACzB,GAAGF,KAAK;YACR,GAAGc;UACL,CAAC;QACH;MACF;IAAE,CACH,CACkB,CAAC;EAE1B;AACF;AAACgE,OAAA,CAAAjG,IAAA,GAAAA,IAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EAxNYN,IAAI,eACI;EACjBqB,aAAa,EAAE6E,kBAAS,CAACC,MAAM;EAC/BvF,KAAK,EAAEsF,kBAAS,CAACC,MAAM;EACvBrF,cAAc,EAAEoF,kBAAS,CAACE,IAAI;EAC9B9E,sBAAsB,EAAE4E,kBAAS,CAACE;AACpC,CAAC;AAAA,IAAAC,QAAA,GAAAJ,OAAA,CAAA3F,OAAA,GAoNYN,IAAI","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@pie-element/ebsr-configure",
3
+ "private": true,
4
+ "version": "13.1.3",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "author": "",
9
+ "dependencies": {
10
+ "@emotion/react": "^11.14.0",
11
+ "@emotion/style": "^0.8.0",
12
+ "@mui/icons-material": "^7.3.4",
13
+ "@mui/material": "^7.3.4",
14
+ "@pie-element/multiple-choice": "^13.3.0",
15
+ "@pie-framework/pie-configure-events": "^1.2.0",
16
+ "@pie-lib/config-ui": "13.0.7",
17
+ "lodash-es": "^4.17.23",
18
+ "prop-types": "^15.8.1",
19
+ "react": "18.3.1",
20
+ "react-dom": "18.3.1"
21
+ },
22
+ "license": "ISC"
23
+ }
@@ -0,0 +1,492 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { ThemeProvider, createTheme } from '@mui/material/styles';
4
+ import { ModelUpdatedEvent } from '@pie-framework/pie-configure-events';
5
+ import { choiceUtils as utils } from '@pie-lib/config-ui';
6
+ import { createRoot } from 'react-dom/client';
7
+ import defaults from '../defaults';
8
+ import { Main } from '../main';
9
+ import EbsrConfigure from '../index';
10
+
11
+ const mockRender = jest.fn();
12
+ const mockUnmount = jest.fn();
13
+ jest.mock('react-dom/client', () => ({
14
+ createRoot: jest.fn(() => ({
15
+ render: mockRender,
16
+ unmount: mockUnmount,
17
+ })),
18
+ }));
19
+
20
+ jest.mock('@pie-framework/pie-configure-events', () => ({
21
+ ModelUpdatedEvent: class ModelUpdatedEvent {
22
+ constructor(update) {
23
+ this.update = update;
24
+ this.preventDefault = jest.fn();
25
+ this.stopImmediatePropagation = jest.fn();
26
+ }
27
+ },
28
+ }));
29
+
30
+ jest.mock('@pie-lib/config-ui', () => ({
31
+ choiceUtils: {
32
+ firstAvailableIndex: jest.fn(),
33
+ },
34
+ settings: {
35
+ Panel: (props) => <div data-testid="settings-panel" {...props} />,
36
+ toggle: jest.fn(),
37
+ radio: jest.fn(),
38
+ dropdown: jest.fn(),
39
+ },
40
+ layout: {
41
+ ConfigLayout: (props) => <div data-testid="config-layout">{props.children}</div>,
42
+ },
43
+ }));
44
+
45
+ jest.mock('@pie-element/multiple-choice/configure/lib', () => (class MockConfigure {}));
46
+
47
+ const theme = createTheme();
48
+
49
+ const PART_A = 'partA';
50
+ const PART_B = 'partB';
51
+
52
+ const createDefaultModel = (model, newModel = {}) => ({
53
+ ...model,
54
+ ...newModel,
55
+ partA: {
56
+ ...model.partA,
57
+ ...newModel.partA,
58
+ },
59
+ partB: {
60
+ ...model.partB,
61
+ ...newModel.partB,
62
+ },
63
+ });
64
+
65
+ const model = createDefaultModel(defaults.model, {
66
+ partA: {
67
+ choiceMode: 'radio',
68
+ choices: [
69
+ {
70
+ value: 'yellow',
71
+ label: 'Yellow',
72
+ correct: true,
73
+ feedback: {
74
+ type: 'custom',
75
+ value: 'foo',
76
+ },
77
+ },
78
+ {
79
+ value: 'green',
80
+ label: 'Green',
81
+ feedback: {
82
+ type: 'default',
83
+ },
84
+ },
85
+ ],
86
+ choicePrefix: 'numbers',
87
+ prompt: `prompt ${PART_A}`,
88
+ errors: {},
89
+ },
90
+ partB: {
91
+ choiceMode: 'radio',
92
+ choices: [
93
+ {
94
+ value: 'orange',
95
+ label: 'Orange',
96
+ correct: true,
97
+ feedback: {
98
+ type: 'custom',
99
+ value: 'foo',
100
+ },
101
+ },
102
+ {
103
+ value: 'purple',
104
+ label: 'Purple',
105
+ feedback: {
106
+ type: 'default',
107
+ },
108
+ },
109
+ ],
110
+ choicePrefix: 'numbers',
111
+ prompt: `prompt ${PART_B}`,
112
+ errors: {},
113
+ },
114
+ });
115
+
116
+ describe('index', () => {
117
+ let Def;
118
+ let el;
119
+ let onModelChanged = jest.fn();
120
+ let onConfigurationChanged = jest.fn();
121
+
122
+ beforeAll(() => {
123
+ Def = require('../index').default;
124
+
125
+ // Register the custom element if not already registered
126
+ if (!customElements.get('ebsr-configure')) {
127
+ customElements.define('ebsr-configure', Def);
128
+ }
129
+ });
130
+
131
+ beforeEach(() => {
132
+ jest.clearAllMocks();
133
+ el = document.createElement('ebsr-configure');
134
+ el.model = model;
135
+ el.configuration = defaults.configuration;
136
+ el.onModelChanged = onModelChanged;
137
+ el.onConfigurationChanged = onConfigurationChanged;
138
+ el.connectedCallback();
139
+ el.dispatchEvent = el.onModelUpdated;
140
+ });
141
+
142
+ describe('set model', () => {
143
+ it('calls ReactDOM.render', () => {
144
+ el.model = model;
145
+
146
+ expect(el._model).toEqual(model);
147
+ expect(createRoot).toHaveBeenCalled();
148
+ expect(mockRender).toHaveBeenCalled();
149
+ });
150
+
151
+ it('should have set the model for partA and partB', () => {
152
+ const { container } = render(
153
+ <ThemeProvider theme={theme}>
154
+ <Main
155
+ classes={{}}
156
+ model={el._model}
157
+ configuration={defaults.configuration}
158
+ onConfigurationChanged={el.onConfigurationChanged}
159
+ onModelChanged={el.onModelChanged}
160
+ />
161
+ </ThemeProvider>
162
+ );
163
+
164
+ expect(container).toBeInTheDocument();
165
+ expect(el._model.partA).toEqual(model.partA);
166
+ expect(el._model.partB).toEqual(model.partB);
167
+ });
168
+ });
169
+
170
+ describe('set configuration', () => {
171
+ it('calls ReactDOM.render', () => {
172
+ el.configuration = defaults.configuration;
173
+
174
+ expect(createRoot).toHaveBeenCalled();
175
+ expect(mockRender).toHaveBeenCalled();
176
+ });
177
+
178
+ it('should have set the configuration for partA and partB', () => {
179
+ const { container } = render(
180
+ <ThemeProvider theme={theme}>
181
+ <Main
182
+ classes={{}}
183
+ model={el._model}
184
+ configuration={defaults.configuration}
185
+ onConfigurationChanged={el.onConfigurationChanged}
186
+ onModelChanged={el.onModelChanged}
187
+ />
188
+ </ThemeProvider>
189
+ );
190
+
191
+ expect(container).toBeInTheDocument();
192
+ });
193
+ });
194
+
195
+ const assertOnModelUpdated = (label, key, updatedPart, expected) => {
196
+ it(label, () => {
197
+ const event = new ModelUpdatedEvent(updatedPart, false);
198
+
199
+ el.dispatchEvent({
200
+ ...event,
201
+ target: {
202
+ getAttribute: jest.fn().mockReturnValue(key),
203
+ },
204
+ });
205
+
206
+ expect(createRoot).toBeCalled();
207
+ expect(mockRender).toBeCalled();
208
+ expect(el._model[`part${key}`]).toEqual(expected);
209
+ });
210
+ };
211
+
212
+ describe('onModelUpdated', () => {
213
+ assertOnModelUpdated('dispatching MODEL_UPDATED updates model.partA', 'A', { updatedA: true }, { updatedA: true });
214
+ assertOnModelUpdated('dispatching MODEL_UPDATED updates model.partB', 'B', { updatedB: true }, { updatedB: true });
215
+
216
+ assertOnModelUpdated(
217
+ 'dispatching MODEL_UPDATED with update undefined does not update model.partA',
218
+ 'A',
219
+ undefined,
220
+ createDefaultModel(model).partA,
221
+ );
222
+ assertOnModelUpdated(
223
+ 'dispatching MODEL_UPDATED with update undefined does not update model.partB',
224
+ 'B',
225
+ undefined,
226
+ createDefaultModel(model).partB,
227
+ );
228
+ });
229
+
230
+ const assertPartUpdate = (label, key, updatedModel) => {
231
+ it(`${key} - ${label}`, () => {
232
+ // Simulate the onModelChanged call for the specific part
233
+ const event = new ModelUpdatedEvent(updatedModel, false);
234
+
235
+ el.dispatchEvent({
236
+ ...event,
237
+ target: {
238
+ getAttribute: jest.fn().mockReturnValue(key === 'partA' ? 'A' : 'B'),
239
+ },
240
+ });
241
+
242
+ expect(el._model[key]).toEqual(updatedModel);
243
+ expect(createRoot).toBeCalled();
244
+ expect(mockRender).toBeCalled();
245
+ });
246
+ };
247
+
248
+ describe('part update', () => {
249
+ assertPartUpdate('Dispatching Model Updated Event will update Teacher Instructions', 'partA', {
250
+ ...model.partA,
251
+ teacherInstructions: 'Part A Teacher Instructions',
252
+ });
253
+ assertPartUpdate('Dispatching Model Updated Event will update Teacher Instructions', 'partB', {
254
+ ...model.partB,
255
+ teacherInstructions: 'Part B Teacher Instructions',
256
+ });
257
+ assertPartUpdate('Dispatching Model Updated Event will update Prompt', 'partA', {
258
+ ...model.partA,
259
+ prompt: 'Prompt A',
260
+ });
261
+ assertPartUpdate('Dispatching Model Updated Event will update Prompt', 'partB', {
262
+ ...model.partA,
263
+ prompt: 'Prompt B',
264
+ });
265
+
266
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - ADD CHOICE', 'partA', {
267
+ ...model.partA,
268
+ choices: [
269
+ ...model.partA.choices,
270
+ {
271
+ label: 'label',
272
+ value: utils.firstAvailableIndex(
273
+ model.partA.choices.map((c) => c.value),
274
+ 0,
275
+ ),
276
+ feedback: {
277
+ type: 'none',
278
+ },
279
+ },
280
+ ],
281
+ });
282
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - ADD CHOICE', 'partB', {
283
+ ...model.partB,
284
+ choices: [
285
+ ...model.partB.choices,
286
+ {
287
+ label: 'label',
288
+ value: utils.firstAvailableIndex(
289
+ model.partB.choices.map((c) => c.value),
290
+ 0,
291
+ ),
292
+ feedback: {
293
+ type: 'none',
294
+ },
295
+ },
296
+ ],
297
+ });
298
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - REMOVE CHOICE', 'partA', {
299
+ ...model.partA,
300
+ choices: model.partA.choices.splice(0, 2),
301
+ });
302
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - REMOVE CHOICE', 'partB', {
303
+ ...model.partB,
304
+ choices: model.partB.choices.splice(0, 2),
305
+ });
306
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - CHANGE CHOICE', 'partA', {
307
+ ...model.partA,
308
+ choices: model.partA.choices.splice(1, 1, {
309
+ correct: true,
310
+ value: 'green',
311
+ label: (value) => value.charAt(0).toUpperCase() + value.slice(1),
312
+ feedback: {
313
+ type: 'none',
314
+ value: '',
315
+ },
316
+ }),
317
+ });
318
+ assertPartUpdate('Dispatching Model Updated Event will update Choices - CHANGE CHOICE', 'partB', {
319
+ ...model.partB,
320
+ choices: model.partB.choices.splice(1, 1, {
321
+ correct: true,
322
+ value: 'green',
323
+ label: (value) => value.charAt(0).toUpperCase() + value.slice(1),
324
+ feedback: {
325
+ type: 'none',
326
+ value: '',
327
+ },
328
+ }),
329
+ });
330
+
331
+ assertPartUpdate('Dispatching Model Updated Event will update Choices', 'partA', { ...model.partA, choices: [] });
332
+ assertPartUpdate('Dispatching Model Updated Event will update Choices', 'partB', { ...model.partB, choices: [] });
333
+ });
334
+ });
335
+
336
+ describe('main', () => {
337
+ let Def;
338
+ let el;
339
+
340
+ beforeAll(() => {
341
+ Def = require('../index').default;
342
+
343
+ // Register the custom element if not already registered
344
+ if (!customElements.get('ebsr-configure')) {
345
+ customElements.define('ebsr-configure', Def);
346
+ }
347
+ });
348
+
349
+ beforeEach(() => {
350
+ jest.clearAllMocks();
351
+ el = document.createElement('ebsr-configure');
352
+ el.model = model;
353
+ el.configuration = defaults.configuration;
354
+ el.dispatchEvent = el.onModelUpdated;
355
+ });
356
+
357
+ const assertOnModelChanged = (label, updatedModel, expected) => {
358
+ it(label, () => {
359
+ el.onModelChanged(updatedModel);
360
+
361
+ expect(el._model).toEqual(createDefaultModel(model, expected));
362
+ });
363
+ };
364
+
365
+ describe('onModelChanged', () => {
366
+ assertOnModelChanged('does not change the model', {}, model);
367
+ assertOnModelChanged(
368
+ 'changes partA - checkbox',
369
+ {
370
+ partA: {
371
+ choiceMode: 'checkbox',
372
+ },
373
+ },
374
+ {
375
+ ...model,
376
+ partA: {
377
+ choiceMode: 'checkbox',
378
+ },
379
+ },
380
+ );
381
+ assertOnModelChanged(
382
+ 'changes partA - choicePrefix',
383
+ {
384
+ partA: {
385
+ choicePrefix: 'numbers',
386
+ },
387
+ },
388
+ {
389
+ ...model,
390
+ partA: {
391
+ choicePrefix: 'numbers',
392
+ },
393
+ },
394
+ );
395
+ assertOnModelChanged(
396
+ 'changes partA - partialScoring',
397
+ {
398
+ partialScoring: false,
399
+ },
400
+ {
401
+ ...model,
402
+ partialScoring: false,
403
+ },
404
+ );
405
+ assertOnModelChanged(
406
+ 'changes partA - lockChoiceOrder',
407
+ {
408
+ partA: {
409
+ lockChoiceOrder: true,
410
+ },
411
+ },
412
+ {
413
+ ...model,
414
+ partA: {
415
+ lockChoiceOrder: true,
416
+ },
417
+ },
418
+ );
419
+ assertOnModelChanged(
420
+ 'changes partA - scoringType',
421
+ {
422
+ scoringType: 'auto',
423
+ },
424
+ {
425
+ ...model,
426
+ scoringType: 'auto',
427
+ },
428
+ );
429
+ assertOnModelChanged(
430
+ 'changes partB - checkbox',
431
+ {
432
+ partB: {
433
+ choiceMode: 'checkbox',
434
+ },
435
+ },
436
+ {
437
+ ...model,
438
+ partB: {
439
+ choiceMode: 'checkbox',
440
+ },
441
+ },
442
+ );
443
+ assertOnModelChanged(
444
+ 'changes partB - choicePrefix',
445
+ {
446
+ partB: {
447
+ choicePrefix: 'numbers',
448
+ },
449
+ },
450
+ {
451
+ ...model,
452
+ partB: {
453
+ choicePrefix: 'numbers',
454
+ },
455
+ },
456
+ );
457
+ assertOnModelChanged(
458
+ 'changes partB - partialScoring',
459
+ {
460
+ partialScoring: false,
461
+ },
462
+ {
463
+ ...model,
464
+ partialScoring: false,
465
+ },
466
+ );
467
+ assertOnModelChanged(
468
+ 'changes partB - lockChoiceOrder',
469
+ {
470
+ partB: {
471
+ lockChoiceOrder: true,
472
+ },
473
+ },
474
+ {
475
+ ...model,
476
+ partB: {
477
+ lockChoiceOrder: true,
478
+ },
479
+ },
480
+ );
481
+ assertOnModelChanged(
482
+ 'changes partB - scoringType',
483
+ {
484
+ scoringType: 'auto',
485
+ },
486
+ {
487
+ ...model,
488
+ scoringType: 'auto',
489
+ },
490
+ );
491
+ });
492
+ });