@pie-element/match 4.7.2 → 4.7.3-next.1008
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 +184 -0
- package/configure/CHANGELOG.md +170 -0
- package/configure/lib/add-row.js +1 -1
- package/configure/lib/add-row.js.map +1 -1
- package/configure/lib/answer-config-block.js +151 -35
- package/configure/lib/answer-config-block.js.map +1 -1
- package/configure/lib/common.js +46 -0
- package/configure/lib/common.js.map +1 -0
- package/configure/lib/configure.js +49 -10
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +19 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +81 -31
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +4 -4
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/row.js +109 -21
- package/configure/lib/row.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/utils.js +11 -0
- package/controller/CHANGELOG.md +16 -0
- package/controller/lib/index.js +37 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +94 -0
- package/docs/config-schema.json.md +73 -1
- package/docs/demo/generate.js +1 -0
- package/docs/pie-schema.json +42 -0
- package/docs/pie-schema.json.md +35 -0
- package/lib/answer-grid.js +9 -10
- package/lib/answer-grid.js.map +1 -1
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/main.js +11 -17
- package/lib/main.js.map +1 -1
- package/package.json +5 -5
- package/module/configure.js +0 -1776
- package/module/controller.js +0 -21219
- package/module/demo.js +0 -75
- package/module/element.js +0 -591
- package/module/index.html +0 -16
- package/module/manifest.json +0 -10
package/module/demo.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import Configure from './configure.js';
|
|
2
|
-
import Element from './element.js';
|
|
3
|
-
import * as controller from './controller.js';
|
|
4
|
-
|
|
5
|
-
var model = (id, element) => ({
|
|
6
|
-
id,
|
|
7
|
-
element,
|
|
8
|
-
enableImages: true,
|
|
9
|
-
feedback: {
|
|
10
|
-
correct: {
|
|
11
|
-
type: 'none',
|
|
12
|
-
default: 'Correct'
|
|
13
|
-
},
|
|
14
|
-
partial: {
|
|
15
|
-
type: 'none',
|
|
16
|
-
default: 'Nearly'
|
|
17
|
-
},
|
|
18
|
-
incorrect: {
|
|
19
|
-
type: 'none',
|
|
20
|
-
default: 'Incorrect'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
headers: ['Column 1', 'Column 2', 'Column 3'],
|
|
24
|
-
layout: 3,
|
|
25
|
-
lockChoiceOrder: true,
|
|
26
|
-
partialScoring: false,
|
|
27
|
-
choiceMode: 'radio',
|
|
28
|
-
rows: [
|
|
29
|
-
{
|
|
30
|
-
id: 1,
|
|
31
|
-
title: 'Question Text 1',
|
|
32
|
-
values: [false, false]
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 2,
|
|
36
|
-
title: 'Question Text 2',
|
|
37
|
-
values: [false, false]
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: 3,
|
|
41
|
-
title: 'Question Text 3',
|
|
42
|
-
values: [false, false]
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 4,
|
|
46
|
-
title: 'Question Text 4',
|
|
47
|
-
values: [false, false]
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
promptEnabled: true,
|
|
51
|
-
prompt: 'Select correct answers.',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
var generate = {
|
|
55
|
-
model: model
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const { model: model$1 } = generate;
|
|
59
|
-
|
|
60
|
-
var config = {
|
|
61
|
-
elements: {
|
|
62
|
-
'match-element': '../..'
|
|
63
|
-
},
|
|
64
|
-
models: [model$1('1', 'match-element')]
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
//Note: demo-el is a custom element loaded in the markup.
|
|
68
|
-
customElements.whenDefined('demo-el').then(() => {
|
|
69
|
-
config.models.forEach(m => {
|
|
70
|
-
const de = document.createElement('demo-el');
|
|
71
|
-
document.body.appendChild(de);
|
|
72
|
-
de.def = { tagName: m.element, Element, Configure, controller };
|
|
73
|
-
de.model = m;
|
|
74
|
-
});
|
|
75
|
-
});
|
package/module/element.js
DELETED
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_pie_lib__correct_answer_toggle, _dll_react_dom, _dll_pie_framework__pie_player_events, _dll_pie_lib__math_rendering, _dll_lodash} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
|
|
2
|
-
function createCommonjsModule(fn, module) {
|
|
3
|
-
return (module = {
|
|
4
|
-
exports: {}
|
|
5
|
-
}, fn(module, module.exports), module.exports);
|
|
6
|
-
}
|
|
7
|
-
var classnames = createCommonjsModule(function (module) {
|
|
8
|
-
(function () {
|
|
9
|
-
var hasOwn = ({}).hasOwnProperty;
|
|
10
|
-
function classNames() {
|
|
11
|
-
var classes = [];
|
|
12
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
13
|
-
var arg = arguments[i];
|
|
14
|
-
if (!arg) continue;
|
|
15
|
-
var argType = typeof arg;
|
|
16
|
-
if (argType === 'string' || argType === 'number') {
|
|
17
|
-
classes.push(arg);
|
|
18
|
-
} else if (Array.isArray(arg) && arg.length) {
|
|
19
|
-
var inner = classNames.apply(null, arg);
|
|
20
|
-
if (inner) {
|
|
21
|
-
classes.push(inner);
|
|
22
|
-
}
|
|
23
|
-
} else if (argType === 'object') {
|
|
24
|
-
for (var key in arg) {
|
|
25
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
26
|
-
classes.push(key);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return classes.join(' ');
|
|
32
|
-
}
|
|
33
|
-
if (module.exports) {
|
|
34
|
-
classNames.default = classNames;
|
|
35
|
-
module.exports = classNames;
|
|
36
|
-
} else {
|
|
37
|
-
window.classNames = classNames;
|
|
38
|
-
}
|
|
39
|
-
})();
|
|
40
|
-
});
|
|
41
|
-
const React = _dll_react;
|
|
42
|
-
const PropTypes = _dll_prop_types;
|
|
43
|
-
const {Radio: Radio} = _dll_material_ui__core;
|
|
44
|
-
const {Checkbox: Checkbox} = _dll_material_ui__core;
|
|
45
|
-
const {Typography: Typography} = _dll_material_ui__core;
|
|
46
|
-
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
47
|
-
const {color: color} = _dll_pie_lib__render_ui;
|
|
48
|
-
const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/match/src/answer-grid.jsx";
|
|
49
|
-
class AnswerGrid extends React.Component {
|
|
50
|
-
constructor(...args) {
|
|
51
|
-
super(...args);
|
|
52
|
-
AnswerGrid.prototype.__init.call(this);
|
|
53
|
-
AnswerGrid.prototype.__init2.call(this);
|
|
54
|
-
AnswerGrid.prototype.__init3.call(this);
|
|
55
|
-
}
|
|
56
|
-
static __initStatic() {
|
|
57
|
-
this.propTypes = {
|
|
58
|
-
allowFeedback: PropTypes.bool.isRequired,
|
|
59
|
-
classes: PropTypes.object.isRequired,
|
|
60
|
-
correctAnswers: PropTypes.object,
|
|
61
|
-
view: PropTypes.bool.isRequired,
|
|
62
|
-
showCorrect: PropTypes.bool.isRequired,
|
|
63
|
-
disabled: PropTypes.bool.isRequired,
|
|
64
|
-
onAnswerChange: PropTypes.func.isRequired,
|
|
65
|
-
choiceMode: PropTypes.string.isRequired,
|
|
66
|
-
rows: PropTypes.array.isRequired,
|
|
67
|
-
headers: PropTypes.array.isRequired,
|
|
68
|
-
answers: PropTypes.object.isRequired
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
__init() {
|
|
72
|
-
this.onRowValueChange = (rowId, answerIndex) => event => {
|
|
73
|
-
const {onAnswerChange, choiceMode, answers} = this.props;
|
|
74
|
-
const newAnswers = {
|
|
75
|
-
...answers
|
|
76
|
-
};
|
|
77
|
-
if (choiceMode === 'radio') {
|
|
78
|
-
for (let i = 0; i < newAnswers[rowId].length; i++) {
|
|
79
|
-
newAnswers[rowId][i] = false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
newAnswers[rowId][answerIndex] = event.target.checked;
|
|
83
|
-
onAnswerChange(newAnswers);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
__init2() {
|
|
87
|
-
this.answerIsCorrect = (rowId, rowValue, rowValueIndex) => {
|
|
88
|
-
const {correctAnswers} = this.props;
|
|
89
|
-
return correctAnswers[rowId][rowValueIndex] === rowValue && rowValue === true;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
__init3() {
|
|
93
|
-
this.answerIsIncorrect = (rowId, rowValue, rowValueIndex) => {
|
|
94
|
-
const {correctAnswers} = this.props;
|
|
95
|
-
return correctAnswers[rowId][rowValueIndex] === true && rowValue === false || correctAnswers[rowId][rowValueIndex] === false && rowValue === true;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
render() {
|
|
99
|
-
const {allowFeedback, classes, showCorrect, headers, rows, choiceMode, answers, disabled, view} = this.props;
|
|
100
|
-
const Tag = choiceMode === 'radio' ? Radio : Checkbox;
|
|
101
|
-
if (!rows || rows.length === 0) {
|
|
102
|
-
return React.createElement('div', {
|
|
103
|
-
className: classes.controlsContainer,
|
|
104
|
-
__self: this,
|
|
105
|
-
__source: {
|
|
106
|
-
fileName: _jsxFileName,
|
|
107
|
-
lineNumber: 60
|
|
108
|
-
}
|
|
109
|
-
}, React.createElement(Typography, {
|
|
110
|
-
className: classes.empty,
|
|
111
|
-
component: "div",
|
|
112
|
-
__self: this,
|
|
113
|
-
__source: {
|
|
114
|
-
fileName: _jsxFileName,
|
|
115
|
-
lineNumber: 61
|
|
116
|
-
}
|
|
117
|
-
}, "There are currently no questions to show."));
|
|
118
|
-
}
|
|
119
|
-
return React.createElement('div', {
|
|
120
|
-
className: classes.controlsContainer,
|
|
121
|
-
__self: this,
|
|
122
|
-
__source: {
|
|
123
|
-
fileName: _jsxFileName,
|
|
124
|
-
lineNumber: 68
|
|
125
|
-
}
|
|
126
|
-
}, React.createElement('table', {
|
|
127
|
-
className: classes.table,
|
|
128
|
-
__self: this,
|
|
129
|
-
__source: {
|
|
130
|
-
fileName: _jsxFileName,
|
|
131
|
-
lineNumber: 69
|
|
132
|
-
}
|
|
133
|
-
}, React.createElement('colgroup', {
|
|
134
|
-
__self: this,
|
|
135
|
-
__source: {
|
|
136
|
-
fileName: _jsxFileName,
|
|
137
|
-
lineNumber: 70
|
|
138
|
-
}
|
|
139
|
-
}, headers.map((header, idx) => React.createElement('col', {
|
|
140
|
-
key: `col-${idx}`,
|
|
141
|
-
__self: this,
|
|
142
|
-
__source: {
|
|
143
|
-
fileName: _jsxFileName,
|
|
144
|
-
lineNumber: 71
|
|
145
|
-
}
|
|
146
|
-
}))), React.createElement('thead', {
|
|
147
|
-
__self: this,
|
|
148
|
-
__source: {
|
|
149
|
-
fileName: _jsxFileName,
|
|
150
|
-
lineNumber: 74
|
|
151
|
-
}
|
|
152
|
-
}, React.createElement('tr', {
|
|
153
|
-
__self: this,
|
|
154
|
-
__source: {
|
|
155
|
-
fileName: _jsxFileName,
|
|
156
|
-
lineNumber: 75
|
|
157
|
-
}
|
|
158
|
-
}, headers.map((header, idx) => React.createElement('th', {
|
|
159
|
-
className: classes.rowHeader,
|
|
160
|
-
key: `th-${idx}`,
|
|
161
|
-
'data-colno': `${idx}`,
|
|
162
|
-
scope: "row",
|
|
163
|
-
__self: this,
|
|
164
|
-
__source: {
|
|
165
|
-
fileName: _jsxFileName,
|
|
166
|
-
lineNumber: 77
|
|
167
|
-
}
|
|
168
|
-
}, React.createElement('div', {
|
|
169
|
-
className: classnames(classes.rowItem, {
|
|
170
|
-
[classes.questionText]: idx === 0
|
|
171
|
-
}),
|
|
172
|
-
dangerouslySetInnerHTML: {
|
|
173
|
-
__html: header
|
|
174
|
-
},
|
|
175
|
-
__self: this,
|
|
176
|
-
__source: {
|
|
177
|
-
fileName: _jsxFileName,
|
|
178
|
-
lineNumber: 83
|
|
179
|
-
}
|
|
180
|
-
}))))), rows.map((row, idx) => React.createElement('tbody', {
|
|
181
|
-
key: `row-${idx}`,
|
|
182
|
-
role: "group",
|
|
183
|
-
__self: this,
|
|
184
|
-
__source: {
|
|
185
|
-
fileName: _jsxFileName,
|
|
186
|
-
lineNumber: 93
|
|
187
|
-
}
|
|
188
|
-
}, React.createElement('tr', {
|
|
189
|
-
className: classes.separator,
|
|
190
|
-
__self: this,
|
|
191
|
-
__source: {
|
|
192
|
-
fileName: _jsxFileName,
|
|
193
|
-
lineNumber: 94
|
|
194
|
-
}
|
|
195
|
-
}, React.createElement('td', {
|
|
196
|
-
key: `td-title-${idx}`,
|
|
197
|
-
'data-colno': '0',
|
|
198
|
-
__self: this,
|
|
199
|
-
__source: {
|
|
200
|
-
fileName: _jsxFileName,
|
|
201
|
-
lineNumber: 95
|
|
202
|
-
}
|
|
203
|
-
}, React.createElement('div', {
|
|
204
|
-
className: classnames(classes.rowItem, classes.questionText),
|
|
205
|
-
dangerouslySetInnerHTML: {
|
|
206
|
-
__html: row.title
|
|
207
|
-
},
|
|
208
|
-
__self: this,
|
|
209
|
-
__source: {
|
|
210
|
-
fileName: _jsxFileName,
|
|
211
|
-
lineNumber: 99
|
|
212
|
-
}
|
|
213
|
-
})), answers[row.id].map((rowItem, answerIndex) => React.createElement('td', {
|
|
214
|
-
key: `td-${idx}-${answerIndex}`,
|
|
215
|
-
className: classes.column,
|
|
216
|
-
'data-colno': `${answerIndex + 1}`,
|
|
217
|
-
__self: this,
|
|
218
|
-
__source: {
|
|
219
|
-
fileName: _jsxFileName,
|
|
220
|
-
lineNumber: 106
|
|
221
|
-
}
|
|
222
|
-
}, React.createElement('div', {
|
|
223
|
-
className: classes.rowItem,
|
|
224
|
-
__self: this,
|
|
225
|
-
__source: {
|
|
226
|
-
fileName: _jsxFileName,
|
|
227
|
-
lineNumber: 111
|
|
228
|
-
}
|
|
229
|
-
}, React.createElement(Tag, {
|
|
230
|
-
className: classnames({
|
|
231
|
-
[classes.correct]: allowFeedback && (showCorrect && rowItem === true || disabled && !view && this.answerIsCorrect(row.id, rowItem, answerIndex)),
|
|
232
|
-
[classes.tag]: true,
|
|
233
|
-
[classes.checked]: rowItem === true,
|
|
234
|
-
[classes.tagDisabled]: disabled,
|
|
235
|
-
[classes.incorrect]: allowFeedback && disabled && !view && this.answerIsIncorrect(row.id, rowItem, answerIndex)
|
|
236
|
-
}),
|
|
237
|
-
disabled: disabled,
|
|
238
|
-
onChange: this.onRowValueChange(row.id, answerIndex),
|
|
239
|
-
checked: rowItem === true,
|
|
240
|
-
__self: this,
|
|
241
|
-
__source: {
|
|
242
|
-
fileName: _jsxFileName,
|
|
243
|
-
lineNumber: 112
|
|
244
|
-
}
|
|
245
|
-
})))))))));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
AnswerGrid.__initStatic();
|
|
249
|
-
const styles = theme => ({
|
|
250
|
-
controlsContainer: {
|
|
251
|
-
marginLeft: 'auto',
|
|
252
|
-
marginRight: 'auto',
|
|
253
|
-
marginTop: theme.spacing.unit,
|
|
254
|
-
marginBottom: theme.spacing.unit
|
|
255
|
-
},
|
|
256
|
-
column: {
|
|
257
|
-
padding: '10px 20px 0'
|
|
258
|
-
},
|
|
259
|
-
correct: {
|
|
260
|
-
color: `${color.correct()} !important`
|
|
261
|
-
},
|
|
262
|
-
incorrect: {
|
|
263
|
-
color: `${color.incorrect()} !important`
|
|
264
|
-
},
|
|
265
|
-
empty: {
|
|
266
|
-
margin: theme.spacing.unit * 2
|
|
267
|
-
},
|
|
268
|
-
rowContainer: {
|
|
269
|
-
display: 'flex',
|
|
270
|
-
alignItems: 'center'
|
|
271
|
-
},
|
|
272
|
-
rowHeader: {
|
|
273
|
-
padding: 0
|
|
274
|
-
},
|
|
275
|
-
rowItem: {
|
|
276
|
-
padding: '12px',
|
|
277
|
-
textAlign: 'center'
|
|
278
|
-
},
|
|
279
|
-
separator: {
|
|
280
|
-
border: 0,
|
|
281
|
-
borderTop: `2.5px solid ${color.primaryLight()}`,
|
|
282
|
-
width: '100%'
|
|
283
|
-
},
|
|
284
|
-
tag: {
|
|
285
|
-
color: color.text(),
|
|
286
|
-
'&:hover': {
|
|
287
|
-
color: color.primaryLight()
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
checked: {
|
|
291
|
-
color: `${color.primary()} !important`
|
|
292
|
-
},
|
|
293
|
-
tagDisabled: {
|
|
294
|
-
color: color.disabled(),
|
|
295
|
-
cursor: 'not-allowed !important',
|
|
296
|
-
pointerEvents: 'initial !important',
|
|
297
|
-
opacity: 0.7,
|
|
298
|
-
'&:hover': {
|
|
299
|
-
color: color.disabled()
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
table: {
|
|
303
|
-
color: color.text(),
|
|
304
|
-
backgroundColor: color.background(),
|
|
305
|
-
borderCollapse: 'collapse',
|
|
306
|
-
borderSpacing: 0,
|
|
307
|
-
marginBottom: 0
|
|
308
|
-
},
|
|
309
|
-
questionText: {
|
|
310
|
-
textAlign: 'left'
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
var AnswerGrid$1 = withStyles(styles)(AnswerGrid);
|
|
314
|
-
const React$1 = _dll_react;
|
|
315
|
-
const PropTypes$1 = _dll_prop_types;
|
|
316
|
-
const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
|
|
317
|
-
const {color: color$1} = _dll_pie_lib__render_ui;
|
|
318
|
-
const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
|
|
319
|
-
const {Feedback: Feedback} = _dll_pie_lib__render_ui;
|
|
320
|
-
const {hasText: hasText} = _dll_pie_lib__render_ui;
|
|
321
|
-
const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
|
|
322
|
-
const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/match/src/main.jsx";
|
|
323
|
-
class Main extends React$1.Component {
|
|
324
|
-
static __initStatic() {
|
|
325
|
-
this.propTypes = {
|
|
326
|
-
classes: PropTypes$1.object,
|
|
327
|
-
session: PropTypes$1.object.isRequired,
|
|
328
|
-
onSessionChange: PropTypes$1.func,
|
|
329
|
-
model: PropTypes$1.object.isRequired
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
constructor(props) {
|
|
333
|
-
super(props);
|
|
334
|
-
Main.prototype.__init.call(this);
|
|
335
|
-
Main.prototype.__init2.call(this);
|
|
336
|
-
Main.prototype.__init3.call(this);
|
|
337
|
-
Main.prototype.__init4.call(this);
|
|
338
|
-
Main.prototype.__init5.call(this);
|
|
339
|
-
this.state = {
|
|
340
|
-
session: {
|
|
341
|
-
...props.session,
|
|
342
|
-
answers: props.session && props.session.answers || this.generateAnswers(props.model)
|
|
343
|
-
},
|
|
344
|
-
showCorrect: false
|
|
345
|
-
};
|
|
346
|
-
this.callOnSessionChange();
|
|
347
|
-
}
|
|
348
|
-
__init() {
|
|
349
|
-
this.generateAnswers = model => {
|
|
350
|
-
const {config} = model;
|
|
351
|
-
const answers = {};
|
|
352
|
-
config.rows.forEach(row => {
|
|
353
|
-
answers[row.id] = new Array(config.layout - 1).fill(false);
|
|
354
|
-
});
|
|
355
|
-
return answers;
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
__init2() {
|
|
359
|
-
this.isAnswerRegenerationRequired = nextProps => {
|
|
360
|
-
let isRequired = false;
|
|
361
|
-
if (this.props.model.config.choiceMode !== nextProps.model.config.choiceMode) {
|
|
362
|
-
isRequired = true;
|
|
363
|
-
}
|
|
364
|
-
if (this.props.model.config.layout !== nextProps.model.config.layout) {
|
|
365
|
-
isRequired = true;
|
|
366
|
-
}
|
|
367
|
-
if (this.props.model.config.rows.length !== nextProps.model.config.rows.length || nextProps.session.answers && nextProps.model.config.rows.length !== Object.keys(nextProps.session.answers).length) {
|
|
368
|
-
isRequired = true;
|
|
369
|
-
}
|
|
370
|
-
return isRequired || !nextProps.session.answers;
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
374
|
-
const regenAnswers = this.isAnswerRegenerationRequired(nextProps);
|
|
375
|
-
this.setState(state => ({
|
|
376
|
-
session: {
|
|
377
|
-
...nextProps.session,
|
|
378
|
-
answers: regenAnswers ? this.generateAnswers(nextProps.model) : nextProps.session.answers
|
|
379
|
-
},
|
|
380
|
-
showCorrect: this.props.model.disabled && !nextProps.model.disabled && state.showCorrect ? false : state.showCorrect
|
|
381
|
-
}), () => {
|
|
382
|
-
if (regenAnswers) this.callOnSessionChange();
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
__init3() {
|
|
386
|
-
this.callOnSessionChange = () => {
|
|
387
|
-
const {onSessionChange} = this.props;
|
|
388
|
-
if (onSessionChange) {
|
|
389
|
-
onSessionChange(this.state.session);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
__init4() {
|
|
394
|
-
this.toggleShowCorrect = show => {
|
|
395
|
-
this.setState({
|
|
396
|
-
showCorrect: show
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
__init5() {
|
|
401
|
-
this.onAnswerChange = newAnswers => {
|
|
402
|
-
this.setState(state => ({
|
|
403
|
-
session: {
|
|
404
|
-
...state.session,
|
|
405
|
-
answers: newAnswers
|
|
406
|
-
}
|
|
407
|
-
}), this.callOnSessionChange);
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
render() {
|
|
411
|
-
const {model, classes} = this.props;
|
|
412
|
-
const {showCorrect, session} = this.state;
|
|
413
|
-
return React$1.createElement('div', {
|
|
414
|
-
className: classes.mainContainer,
|
|
415
|
-
__self: this,
|
|
416
|
-
__source: {
|
|
417
|
-
fileName: _jsxFileName$1,
|
|
418
|
-
lineNumber: 123
|
|
419
|
-
}
|
|
420
|
-
}, model.teacherInstructions && hasText(model.teacherInstructions) && React$1.createElement(Collapsible, {
|
|
421
|
-
labels: {
|
|
422
|
-
hidden: 'Show Teacher Instructions',
|
|
423
|
-
visible: 'Hide Teacher Instructions'
|
|
424
|
-
},
|
|
425
|
-
className: classes.collapsible,
|
|
426
|
-
__self: this,
|
|
427
|
-
__source: {
|
|
428
|
-
fileName: _jsxFileName$1,
|
|
429
|
-
lineNumber: 125
|
|
430
|
-
}
|
|
431
|
-
}, React$1.createElement('div', {
|
|
432
|
-
dangerouslySetInnerHTML: {
|
|
433
|
-
__html: model.teacherInstructions
|
|
434
|
-
},
|
|
435
|
-
__self: this,
|
|
436
|
-
__source: {
|
|
437
|
-
fileName: _jsxFileName$1,
|
|
438
|
-
lineNumber: 132
|
|
439
|
-
}
|
|
440
|
-
})), model.prompt && React$1.createElement('div', {
|
|
441
|
-
className: classes.prompt,
|
|
442
|
-
dangerouslySetInnerHTML: {
|
|
443
|
-
__html: model.prompt
|
|
444
|
-
},
|
|
445
|
-
__self: this,
|
|
446
|
-
__source: {
|
|
447
|
-
fileName: _jsxFileName$1,
|
|
448
|
-
lineNumber: 139
|
|
449
|
-
}
|
|
450
|
-
}), React$1.createElement('div', {
|
|
451
|
-
className: classes.main,
|
|
452
|
-
__self: this,
|
|
453
|
-
__source: {
|
|
454
|
-
fileName: _jsxFileName$1,
|
|
455
|
-
lineNumber: 145
|
|
456
|
-
}
|
|
457
|
-
}, React$1.createElement(CorrectAnswerToggle, {
|
|
458
|
-
className: classes.toggle,
|
|
459
|
-
show: model.correctness && model.correctness.correctness && model.correctness.correctness !== 'correct',
|
|
460
|
-
toggled: showCorrect,
|
|
461
|
-
onToggle: this.toggleShowCorrect,
|
|
462
|
-
__self: this,
|
|
463
|
-
__source: {
|
|
464
|
-
fileName: _jsxFileName$1,
|
|
465
|
-
lineNumber: 146
|
|
466
|
-
}
|
|
467
|
-
}), React$1.createElement(AnswerGrid$1, {
|
|
468
|
-
showCorrect: showCorrect,
|
|
469
|
-
allowFeedback: model.allowFeedback,
|
|
470
|
-
correctAnswers: model.correctResponse,
|
|
471
|
-
disabled: model.disabled,
|
|
472
|
-
view: model.view,
|
|
473
|
-
onAnswerChange: this.onAnswerChange,
|
|
474
|
-
choiceMode: model.config.choiceMode,
|
|
475
|
-
answers: showCorrect ? model.correctResponse : session.answers,
|
|
476
|
-
headers: model.config.headers,
|
|
477
|
-
rows: model.config.rows,
|
|
478
|
-
__self: this,
|
|
479
|
-
__source: {
|
|
480
|
-
fileName: _jsxFileName$1,
|
|
481
|
-
lineNumber: 156
|
|
482
|
-
}
|
|
483
|
-
})), model.rationale && hasText(model.rationale) && React$1.createElement(Collapsible, {
|
|
484
|
-
labels: {
|
|
485
|
-
hidden: 'Show Rationale',
|
|
486
|
-
visible: 'Hide Rationale'
|
|
487
|
-
},
|
|
488
|
-
className: classes.collapsible,
|
|
489
|
-
__self: this,
|
|
490
|
-
__source: {
|
|
491
|
-
fileName: _jsxFileName$1,
|
|
492
|
-
lineNumber: 170
|
|
493
|
-
}
|
|
494
|
-
}, React$1.createElement('div', {
|
|
495
|
-
dangerouslySetInnerHTML: {
|
|
496
|
-
__html: model.rationale
|
|
497
|
-
},
|
|
498
|
-
__self: this,
|
|
499
|
-
__source: {
|
|
500
|
-
fileName: _jsxFileName$1,
|
|
501
|
-
lineNumber: 174
|
|
502
|
-
}
|
|
503
|
-
})), model.feedback && React$1.createElement(Feedback, {
|
|
504
|
-
correctness: model.correctness.correctness,
|
|
505
|
-
feedback: model.feedback,
|
|
506
|
-
__self: this,
|
|
507
|
-
__source: {
|
|
508
|
-
fileName: _jsxFileName$1,
|
|
509
|
-
lineNumber: 178
|
|
510
|
-
}
|
|
511
|
-
}));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
Main.__initStatic();
|
|
515
|
-
const styles$1 = theme => ({
|
|
516
|
-
mainContainer: {
|
|
517
|
-
color: color$1.text(),
|
|
518
|
-
backgroundColor: color$1.background(),
|
|
519
|
-
display: 'flex',
|
|
520
|
-
flexDirection: 'column',
|
|
521
|
-
justifyContent: 'center'
|
|
522
|
-
},
|
|
523
|
-
main: {
|
|
524
|
-
width: '100%'
|
|
525
|
-
},
|
|
526
|
-
toggle: {
|
|
527
|
-
paddingBottom: theme.spacing.unit * 3
|
|
528
|
-
},
|
|
529
|
-
prompt: {
|
|
530
|
-
verticalAlign: 'middle',
|
|
531
|
-
marginBottom: theme.spacing.unit * 2
|
|
532
|
-
},
|
|
533
|
-
collapsible: {
|
|
534
|
-
paddingTop: theme.spacing.unit * 2,
|
|
535
|
-
paddingBottom: theme.spacing.unit * 2
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
var Main$1 = withStyles$1(styles$1)(Main);
|
|
539
|
-
const React$2 = _dll_react;
|
|
540
|
-
const ReactDOM = _dll_react_dom;
|
|
541
|
-
const {SessionChangedEvent: SessionChangedEvent} = _dll_pie_framework__pie_player_events;
|
|
542
|
-
const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
|
|
543
|
-
const {get: get} = _dll_lodash;
|
|
544
|
-
const isComplete = (session, model) => {
|
|
545
|
-
const rows = get(model, 'config.rows');
|
|
546
|
-
const ids = rows.map(r => r.id);
|
|
547
|
-
return ids.reduce((acc, id) => {
|
|
548
|
-
if (!acc) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
const arr = session.answers && session.answers[id];
|
|
552
|
-
const hasChoice = Array.isArray(arr) && arr.includes(true);
|
|
553
|
-
return hasChoice && acc;
|
|
554
|
-
}, true);
|
|
555
|
-
};
|
|
556
|
-
class Match extends HTMLElement {
|
|
557
|
-
constructor() {
|
|
558
|
-
super();
|
|
559
|
-
}
|
|
560
|
-
set model(m) {
|
|
561
|
-
this._model = m;
|
|
562
|
-
this._render();
|
|
563
|
-
}
|
|
564
|
-
set session(s) {
|
|
565
|
-
this._session = s;
|
|
566
|
-
this._render();
|
|
567
|
-
}
|
|
568
|
-
sessionChanged(s) {
|
|
569
|
-
this._session.answers = s.answers;
|
|
570
|
-
const complete = isComplete(this._session, this._model);
|
|
571
|
-
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), complete));
|
|
572
|
-
}
|
|
573
|
-
connectedCallback() {
|
|
574
|
-
this._render();
|
|
575
|
-
}
|
|
576
|
-
_render() {
|
|
577
|
-
if (!this._model || !this._session) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
const el = React$2.createElement(Main$1, {
|
|
581
|
-
model: this._model,
|
|
582
|
-
session: this._session,
|
|
583
|
-
onSessionChange: this.sessionChanged.bind(this)
|
|
584
|
-
});
|
|
585
|
-
ReactDOM.render(el, this, () => {
|
|
586
|
-
renderMath(this);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
export default Match;
|
|
591
|
-
export {Main$1 as Component, isComplete};
|
package/module/index.html
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<title>@pie-element/match@4.5.9</title>
|
|
6
|
-
<link
|
|
7
|
-
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
8
|
-
rel="stylesheet"
|
|
9
|
-
/>
|
|
10
|
-
<script
|
|
11
|
-
type="module"
|
|
12
|
-
src="https://unpkg.com/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
|
13
|
-
<script type="module" src="./demo.js"></script>
|
|
14
|
-
</head>
|
|
15
|
-
<body></body>
|
|
16
|
-
</html>
|