@pie-element/fraction-model 2.0.2-next.9 → 2.1.1-beta

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.
@@ -20,7 +20,7 @@ Indicates the selected response sector for model value
20
20
 
21
21
  The title prompt of the item
22
22
 
23
- # `question` (string, required)
23
+ # `prompt` (string, required)
24
24
 
25
25
  The question prompt or item stem
26
26
 
@@ -78,9 +78,555 @@ The html Element tag name
78
78
 
79
79
  The schema defines the following additional types:
80
80
 
81
+ ## `EditableHtmlConfigureProp` (object)
82
+
83
+ Properties of the `EditableHtmlConfigureProp` object:
84
+
85
+ ### `math` (object)
86
+
87
+ Properties of the `math` object:
88
+
89
+ #### `disabled` (boolean)
90
+
91
+ Indicates if the plugin is disabled or not
92
+
93
+ ### `audio` (object)
94
+
95
+ Properties of the `audio` object:
96
+
97
+ #### `disabled` (boolean)
98
+
99
+ Indicates if the plugin is disabled or not
100
+
101
+ ### `video` (object)
102
+
103
+ Properties of the `video` object:
104
+
105
+ #### `disabled` (boolean)
106
+
107
+ Indicates if the plugin is disabled or not
108
+
109
+ ### `image` (object)
110
+
111
+ Properties of the `image` object:
112
+
113
+ #### `disabled` (boolean)
114
+
115
+ Indicates if the plugin is disabled or not
116
+
117
+ ### `customPlugins` (array)
118
+
119
+ An array of objects that determine custom plugins.
120
+ A custom plugin is an object which determines how the button will look like (icon) and the event name that will be triggered when button gets pressed (event).
121
+ Example can be found at https://github.com/pie-framework/pie-lib/blob/develop/packages/demo/pages/editable-html.js#L425.
122
+
123
+ The object is an array with all elements of the type `object`.
124
+
125
+ The array object has the following properties:
126
+
127
+ #### `event` (string, required)
128
+
129
+ The name of the custom event. It needs to be valid (only letters, numbers and "_" can be used).
130
+ PIE will emit the event prefixed with "PIE-".
131
+ Eg: event = 'client_custom_event_A' => the emitted event will be "PIE-client_custom_event_A"
132
+
133
+ #### `iconAlt` (string, required)
134
+
135
+ The alt for the custom button icon
136
+
137
+ #### `iconType` (string, required)
138
+
139
+ The icon type.
140
+ Currently, only "SVG" is supported.
141
+
142
+ #### `icon` (string, required)
143
+
144
+ The icon string. Currently, only "SVG" is supported, so it needs to be a valid svg.
145
+
146
+ ### `blockquote` (object)
147
+
148
+ Properties of the `blockquote` object:
149
+
150
+ #### `disabled` (boolean)
151
+
152
+ Indicates if the plugin is disabled or not
153
+
154
+ ### `h3` (object)
155
+
156
+ Properties of the `h3` object:
157
+
158
+ #### `disabled` (boolean)
159
+
160
+ Indicates if the plugin is disabled or not
161
+
162
+ ### `characters` (object)
163
+
164
+ Properties of the `characters` object:
165
+
166
+ #### `disabled` (boolean)
167
+
168
+ Indicates if the plugin is disabled or not
169
+
170
+ ### `bold` (object)
171
+
172
+ Properties of the `bold` object:
173
+
174
+ #### `disabled` (boolean)
175
+
176
+ Indicates if the plugin is disabled or not
177
+
178
+ ### `html` (object)
179
+
180
+ Properties of the `html` object:
181
+
182
+ #### `disabled` (boolean)
183
+
184
+ Indicates if the plugin is disabled or not
185
+
186
+ ### `italic` (object)
187
+
188
+ Properties of the `italic` object:
189
+
190
+ #### `disabled` (boolean)
191
+
192
+ Indicates if the plugin is disabled or not
193
+
194
+ ### `ol_list` (object)
195
+
196
+ Properties of the `ol_list` object:
197
+
198
+ #### `disabled` (boolean)
199
+
200
+ Indicates if the plugin is disabled or not
201
+
202
+ ### `redo` (object)
203
+
204
+ Properties of the `redo` object:
205
+
206
+ #### `disabled` (boolean)
207
+
208
+ Indicates if the plugin is disabled or not
209
+
210
+ ### `strikethrough` (object)
211
+
212
+ Properties of the `strikethrough` object:
213
+
214
+ #### `disabled` (boolean)
215
+
216
+ Indicates if the plugin is disabled or not
217
+
218
+ ### `sub` (object)
219
+
220
+ Properties of the `sub` object:
221
+
222
+ #### `disabled` (boolean)
223
+
224
+ Indicates if the plugin is disabled or not
225
+
226
+ ### `sup` (object)
227
+
228
+ Properties of the `sup` object:
229
+
230
+ #### `disabled` (boolean)
231
+
232
+ Indicates if the plugin is disabled or not
233
+
234
+ ### `table` (object)
235
+
236
+ Properties of the `table` object:
237
+
238
+ #### `disabled` (boolean)
239
+
240
+ Indicates if the plugin is disabled or not
241
+
242
+ ### `ul_list` (object)
243
+
244
+ Properties of the `ul_list` object:
245
+
246
+ #### `disabled` (boolean)
247
+
248
+ Indicates if the plugin is disabled or not
249
+
250
+ ### `underline` (object)
251
+
252
+ Properties of the `underline` object:
253
+
254
+ #### `disabled` (boolean)
255
+
256
+ Indicates if the plugin is disabled or not
257
+
258
+ ### `undo` (object)
259
+
260
+ Properties of the `undo` object:
261
+
262
+ #### `disabled` (boolean)
263
+
264
+ Indicates if the plugin is disabled or not
265
+
266
+ ## `EditableHtmlButtonConfigure` (object)
267
+
268
+ Properties of the `EditableHtmlButtonConfigure` object:
269
+
270
+ ### `disabled` (boolean)
271
+
272
+ Indicates if the plugin is disabled or not
273
+
274
+ ## `CustomPlugin` (object)
275
+
276
+ Properties of the `CustomPlugin` object:
277
+
278
+ ### `event` (string, required)
279
+
280
+ The name of the custom event. It needs to be valid (only letters, numbers and "_" can be used).
281
+ PIE will emit the event prefixed with "PIE-".
282
+ Eg: event = 'client_custom_event_A' => the emitted event will be "PIE-client_custom_event_A"
283
+
284
+ ### `iconAlt` (string, required)
285
+
286
+ The alt for the custom button icon
287
+
288
+ ### `iconType` (string, required)
289
+
290
+ The icon type.
291
+ Currently, only "SVG" is supported.
292
+
293
+ ### `icon` (string, required)
294
+
295
+ The icon string. Currently, only "SVG" is supported, so it needs to be a valid svg.
296
+
297
+ ## `EditableHtmlPluginConfigure` (object)
298
+
299
+ Properties of the `EditableHtmlPluginConfigure` object:
300
+
301
+ ### `inputConfiguration` (object)
302
+
303
+ Properties of the `inputConfiguration` object:
304
+
305
+ #### `math` (object)
306
+
307
+ Properties of the `math` object:
308
+
309
+ ##### `disabled` (boolean)
310
+
311
+ Indicates if the plugin is disabled or not
312
+
313
+ #### `audio` (object)
314
+
315
+ Properties of the `audio` object:
316
+
317
+ ##### `disabled` (boolean)
318
+
319
+ Indicates if the plugin is disabled or not
320
+
321
+ #### `video` (object)
322
+
323
+ Properties of the `video` object:
324
+
325
+ ##### `disabled` (boolean)
326
+
327
+ Indicates if the plugin is disabled or not
328
+
329
+ #### `image` (object)
330
+
331
+ Properties of the `image` object:
332
+
333
+ ##### `disabled` (boolean)
334
+
335
+ Indicates if the plugin is disabled or not
336
+
337
+ #### `customPlugins` (array)
338
+
339
+ An array of objects that determine custom plugins.
340
+ A custom plugin is an object which determines how the button will look like (icon) and the event name that will be triggered when button gets pressed (event).
341
+ Example can be found at https://github.com/pie-framework/pie-lib/blob/develop/packages/demo/pages/editable-html.js#L425.
342
+
343
+ The object is an array with all elements of the type `object`.
344
+
345
+ The array object has the following properties:
346
+
347
+ ##### `event` (string, required)
348
+
349
+ The name of the custom event. It needs to be valid (only letters, numbers and "_" can be used).
350
+ PIE will emit the event prefixed with "PIE-".
351
+ Eg: event = 'client_custom_event_A' => the emitted event will be "PIE-client_custom_event_A"
352
+
353
+ ##### `iconAlt` (string, required)
354
+
355
+ The alt for the custom button icon
356
+
357
+ ##### `iconType` (string, required)
358
+
359
+ The icon type.
360
+ Currently, only "SVG" is supported.
361
+
362
+ ##### `icon` (string, required)
363
+
364
+ The icon string. Currently, only "SVG" is supported, so it needs to be a valid svg.
365
+
366
+ #### `blockquote` (object)
367
+
368
+ Properties of the `blockquote` object:
369
+
370
+ ##### `disabled` (boolean)
371
+
372
+ Indicates if the plugin is disabled or not
373
+
374
+ #### `h3` (object)
375
+
376
+ Properties of the `h3` object:
377
+
378
+ ##### `disabled` (boolean)
379
+
380
+ Indicates if the plugin is disabled or not
381
+
382
+ #### `characters` (object)
383
+
384
+ Properties of the `characters` object:
385
+
386
+ ##### `disabled` (boolean)
387
+
388
+ Indicates if the plugin is disabled or not
389
+
390
+ #### `bold` (object)
391
+
392
+ Properties of the `bold` object:
393
+
394
+ ##### `disabled` (boolean)
395
+
396
+ Indicates if the plugin is disabled or not
397
+
398
+ #### `html` (object)
399
+
400
+ Properties of the `html` object:
401
+
402
+ ##### `disabled` (boolean)
403
+
404
+ Indicates if the plugin is disabled or not
405
+
406
+ #### `italic` (object)
407
+
408
+ Properties of the `italic` object:
409
+
410
+ ##### `disabled` (boolean)
411
+
412
+ Indicates if the plugin is disabled or not
413
+
414
+ #### `ol_list` (object)
415
+
416
+ Properties of the `ol_list` object:
417
+
418
+ ##### `disabled` (boolean)
419
+
420
+ Indicates if the plugin is disabled or not
421
+
422
+ #### `redo` (object)
423
+
424
+ Properties of the `redo` object:
425
+
426
+ ##### `disabled` (boolean)
427
+
428
+ Indicates if the plugin is disabled or not
429
+
430
+ #### `strikethrough` (object)
431
+
432
+ Properties of the `strikethrough` object:
433
+
434
+ ##### `disabled` (boolean)
435
+
436
+ Indicates if the plugin is disabled or not
437
+
438
+ #### `sub` (object)
439
+
440
+ Properties of the `sub` object:
441
+
442
+ ##### `disabled` (boolean)
443
+
444
+ Indicates if the plugin is disabled or not
445
+
446
+ #### `sup` (object)
447
+
448
+ Properties of the `sup` object:
449
+
450
+ ##### `disabled` (boolean)
451
+
452
+ Indicates if the plugin is disabled or not
453
+
454
+ #### `table` (object)
455
+
456
+ Properties of the `table` object:
457
+
458
+ ##### `disabled` (boolean)
459
+
460
+ Indicates if the plugin is disabled or not
461
+
462
+ #### `ul_list` (object)
463
+
464
+ Properties of the `ul_list` object:
465
+
466
+ ##### `disabled` (boolean)
467
+
468
+ Indicates if the plugin is disabled or not
469
+
470
+ #### `underline` (object)
471
+
472
+ Properties of the `underline` object:
473
+
474
+ ##### `disabled` (boolean)
475
+
476
+ Indicates if the plugin is disabled or not
477
+
478
+ #### `undo` (object)
479
+
480
+ Properties of the `undo` object:
481
+
482
+ ##### `disabled` (boolean)
483
+
484
+ Indicates if the plugin is disabled or not
485
+
486
+ ### `settings` (boolean)
487
+
488
+ Indicates if the item has to be displayed in the Settings Panel
489
+
490
+ ### `label` (string)
491
+
492
+ Indicates the label for the item that has to be displayed in the Settings Panel
493
+
494
+ ## `FractionModelOptionsConfigure` (object)
495
+
496
+ Properties of the `FractionModelOptionsConfigure` object:
497
+
498
+ ### `maxOfModel` (object)
499
+
500
+ Properties of the `maxOfModel` object:
501
+
502
+ #### `min` (number)
503
+
504
+ Indicates the min value for number model
505
+
506
+ #### `max` (number)
507
+
508
+ Indicates the max value for number model
509
+
510
+ #### `default` (number)
511
+
512
+ Indicates the default value for number model
513
+
514
+ ### `partsPerModel` (object)
515
+
516
+ Properties of the `partsPerModel` object:
517
+
518
+ #### `min` (number)
519
+
520
+ Indicates the min value for number model
521
+
522
+ #### `max` (number)
523
+
524
+ Indicates the max value for number model
525
+
526
+ #### `default` (number)
527
+
528
+ Indicates the default value for number model
529
+
530
+ ### `modelTypeChoices` (array)
531
+
532
+ Indicates the model types of item
533
+
534
+ The object is an array with all elements of the type `object`.
535
+
536
+ The array object has the following properties:
537
+
538
+ #### `value` (string, required)
539
+
540
+ Indicates the value for model choice
541
+
542
+ #### `label` (string, required)
543
+
544
+ Indicates the label for model choice
545
+
546
+ ## `ModelConfig` (object)
547
+
548
+ Properties of the `ModelConfig` object:
549
+
550
+ ### `min` (number)
551
+
552
+ Indicates the min value for number model
553
+
554
+ ### `max` (number)
555
+
556
+ Indicates the max value for number model
557
+
558
+ ### `default` (number)
559
+
560
+ Indicates the default value for number model
561
+
562
+ ## `ChoiceConfig` (object)
563
+
564
+ Properties of the `ChoiceConfig` object:
565
+
566
+ ### `value` (string, required)
567
+
568
+ Indicates the value for model choice
569
+
570
+ ### `label` (string, required)
571
+
572
+ Indicates the label for model choice
573
+
574
+ ## `ConfigureMathMLProp` (object)
575
+
576
+ Properties of the `ConfigureMathMLProp` object:
577
+
578
+ ### `mmlOutput` (number)
579
+
580
+ Indicates if model should have mathML output instead of latex
581
+
582
+ ### `mmlEditing` (number)
583
+
584
+ Indicates if mathML that's already in model should be editable
585
+
586
+ ## `ConfigurePropWithEnabled` (object)
587
+
588
+ Properties of the `ConfigurePropWithEnabled` object:
589
+
590
+ ### `enabled` (boolean)
591
+
592
+ Indicates the value of the item if it affects config-ui
593
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
594
+
595
+ ### `settings` (boolean)
596
+
597
+ Indicates if the item has to be displayed in the Settings Panel
598
+
599
+ ### `label` (string)
600
+
601
+ Indicates the label for the item that has to be displayed in the Settings Panel
602
+
603
+ ## `ConfigureLanguageOptionsProp` (object)
604
+
605
+ Properties of the `ConfigureLanguageOptionsProp` object:
606
+
607
+ ### `value` (string, required)
608
+
609
+ Value of the language option
610
+
611
+ ### `label` (string, required)
612
+
613
+ Label of the language option
614
+
615
+ ## `ConfigureProp` (object)
616
+
617
+ Properties of the `ConfigureProp` object:
618
+
619
+ ### `settings` (boolean)
620
+
621
+ Indicates if the item has to be displayed in the Settings Panel
622
+
623
+ ### `label` (string)
624
+
625
+ Indicates the label for the item that has to be displayed in the Settings Panel
626
+
81
627
  ## `ResponseObject` (object)
82
628
 
83
- Model for the
629
+ Model for the @pie-elements/fraction-model
84
630
 
85
631
  Properties of the `ResponseObject` object:
86
632
 
@@ -54,13 +54,26 @@ var AnswerFraction = /*#__PURE__*/function (_React$Component) {
54
54
  _this = _super.call.apply(_super, [this].concat(args));
55
55
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onValueChange", function (key) {
56
56
  return function (event) {
57
+ var _event$target;
58
+
59
+ var value = parseInt(event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
57
60
  var _this$props = _this.props,
61
+ model = _this$props.model,
58
62
  onAnswerChange = _this$props.onAnswerChange,
59
63
  answers = _this$props.answers;
60
64
 
61
65
  var newAnswers = _objectSpread({}, answers);
62
66
 
63
- newAnswers[key] = parseInt(event.target.value);
67
+ var min = 1;
68
+ var max = key === 'noOfModel' ? model.maxModelSelected : 9;
69
+
70
+ if (value > max) {
71
+ value = max;
72
+ } else if (value < min) {
73
+ value = min;
74
+ }
75
+
76
+ newAnswers[key] = value;
64
77
  onAnswerChange(newAnswers);
65
78
  };
66
79
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/answer-fraction.jsx"],"names":["AnswerFraction","key","event","props","onAnswerChange","answers","newAnswers","parseInt","target","value","model","classes","showCorrect","disabled","allowedStudentConfig","groupInline","group","inputLabel","textField","min","max","maxModelSelected","onValueChange","noOfModel","partsPerModel","React","Component","PropTypes","object","isRequired","bool","func","styles","alignItems","display","gap","margin","marginBottom","width","maxHeight","height","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,c;;;;;;;;;;;;;;;sGAeK,UAACC,GAAD;AAAA,aAAS,UAACC,KAAD,EAAW;AAClC,0BAAoC,MAAKC,KAAzC;AAAA,YAAQC,cAAR,eAAQA,cAAR;AAAA,YAAwBC,OAAxB,eAAwBA,OAAxB;;AACA,YAAMC,UAAU,qBAAQD,OAAR,CAAhB;;AAEAC,QAAAA,UAAU,CAACL,GAAD,CAAV,GAAkBM,QAAQ,CAACL,KAAK,CAACM,MAAN,CAAaC,KAAd,CAA1B;AACAL,QAAAA,cAAc,CAACE,UAAD,CAAd;AACD,OANe;AAAA,K;;;;;;WAQhB,kBAAS;AACP,yBAA2D,KAAKH,KAAhE;AAAA,UAAQO,KAAR,gBAAQA,KAAR;AAAA,UAAeC,OAAf,gBAAeA,OAAf;AAAA,UAAwBC,WAAxB,gBAAwBA,WAAxB;AAAA,UAAqCP,OAArC,gBAAqCA,OAArC;AAAA,UAA8CQ,QAA9C,gBAA8CA,QAA9C;AAEA,0BACE,6CACGH,KAAK,CAACI,oBAAN,iBACC;AAAK,QAAA,SAAS,EAAEH,OAAO,CAACI;AAAxB,sBACE;AAAK,QAAA,SAAS,EAAEJ,OAAO,CAACK;AAAxB,sBACE;AAAO,QAAA,OAAO,EAAE,0BAAhB;AAA4C,QAAA,SAAS,EAAEL,OAAO,CAACM;AAA/D,4BADF,eAIE,gCAAC,eAAD;AACE,QAAA,SAAS,EAAE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AAAA,QAAQ,EAAEc,sBAAUG,IAAV,CAAeD,UAHR;AAIjBjB,EAAAA,WAAW,EAAEe,sBAAUG,IAAV,CAAeD,UAJX;AAKjBzB,EAAAA,cAAc,EAAEuB,sBAAUI,IAAV,CAAeF,UALd;AAMjBxB,EAAAA,OAAO,EAAEsB,sBAAUC,MAAV,CAAiBC;AANT,C;;AAoErB,IAAMG,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBjB,IAAAA,WAAW,EAAE;AACXkB,MAAAA,UAAU,EAAE,QADD;AAEXC,MAAAA,OAAO,EAAE,MAFE;AAGXC,MAAAA,GAAG,EAAE;AAHM,KADO;AAMpBnB,IAAAA,KAAK,EAAE;AACLoB,MAAAA,MAAM,EAAE;AADH,KANa;AASpBnB,IAAAA,UAAU,EAAE;AACViB,MAAAA,OAAO,EAAE,OADC;AAEVG,MAAAA,YAAY,EAAE;AAFJ,KATQ;AAapBnB,IAAAA,SAAS,EAAE;AACToB,MAAAA,KAAK,EAAE,OADE;AAETC,MAAAA,SAAS,EAAE,MAFF;AAGT,wCAAkC;AAChCC,QAAAA,MAAM,EAAE,EADwB;AAEhCC,QAAAA,QAAQ,EAAE;AAFsB;AAHzB;AAbS,GAAP;AAAA,CAAf;;eAuBe,wBAAWT,MAAX,EAAmBhC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { TextField } from '@material-ui/core';\n\nexport class AnswerFraction extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n onAnswerChange: PropTypes.func.isRequired,\n answers: PropTypes.object.isRequired,\n };\n\n /**\n * Function to trigger when value change from number selection\n * @param {string} key contains event change object\n * @returns updated answer change object\n */\n onValueChange = (key) => (event) => {\n const { onAnswerChange, answers } = this.props;\n const newAnswers = { ...answers };\n\n newAnswers[key] = parseInt(event.target.value);\n onAnswerChange(newAnswers);\n };\n\n render() {\n const { model, classes, showCorrect, answers, disabled } = this.props;\n\n return (\n <div>\n {model.allowedStudentConfig && (\n <div className={classes.groupInline}>\n <div className={classes.group}>\n <label htmlFor={'preview_number-of-models'} className={classes.inputLabel}>\n Number of Models\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_number-of-models\"\n inputProps={{ min: 1, max: model.maxModelSelected }}\n name=\"preview_number-of-models\"\n onChange={this.onValueChange('noOfModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.maxModelSelected : answers.noOfModel}\n />\n </div>\n <div className={classes.group}>\n <label htmlFor={'preview_parts-per-model'} className={classes.inputLabel}>\n Parts per Model\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_parts-per-model\"\n inputProps={{ min: 1, max: 9 }}\n name=\"preview_parts-per-model\"\n onChange={this.onValueChange('partsPerModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.partsPerModel : answers.partsPerModel}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n}\n\nconst styles = () => ({\n groupInline: {\n alignItems: 'center',\n display: 'flex',\n gap: '20px',\n },\n group: {\n margin: '12px 0',\n },\n inputLabel: {\n display: 'block',\n marginBottom: '4px',\n },\n textField: {\n width: '120px',\n maxHeight: '40px',\n '& [class^=\"MuiInputBase-root\"]': {\n height: 40,\n fontSize: '14px',\n },\n },\n});\n\nexport default withStyles(styles)(AnswerFraction);\n"],"file":"answer-fraction.js"}
1
+ {"version":3,"sources":["../src/answer-fraction.jsx"],"names":["AnswerFraction","key","event","value","parseInt","target","props","model","onAnswerChange","answers","newAnswers","min","max","maxModelSelected","classes","showCorrect","disabled","allowedStudentConfig","groupInline","group","inputLabel","textField","onValueChange","noOfModel","partsPerModel","React","Component","PropTypes","object","isRequired","bool","func","styles","alignItems","display","gap","margin","marginBottom","width","maxHeight","height","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AA,KAAK,EAAEoB,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBb,EAAAA,QAAQ,EAAEW,sBAAUG,IAAV,CAAeD,UAHR;AAIjBd,EAAAA,WAAW,EAAEY,sBAAUG,IAAV,CAAeD,UAJX;AAKjBrB,EAAAA,cAAc,EAAEmB,sBAAUI,IAAV,CAAeF,UALd;AAMjBpB,EAAAA,OAAO,EAAEkB,sBAAUC,MAAV,CAAiBC;AANT,C;;AA2ErB,IAAMG,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBd,IAAAA,WAAW,EAAE;AACXe,MAAAA,UAAU,EAAE,QADD;AAEXC,MAAAA,OAAO,EAAE,MAFE;AAGXC,MAAAA,GAAG,EAAE;AAHM,KADO;AAMpBhB,IAAAA,KAAK,EAAE;AACLiB,MAAAA,MAAM,EAAE;AADH,KANa;AASpBhB,IAAAA,UAAU,EAAE;AACVc,MAAAA,OAAO,EAAE,OADC;AAEVG,MAAAA,YAAY,EAAE;AAFJ,KATQ;AAapBhB,IAAAA,SAAS,EAAE;AACTiB,MAAAA,KAAK,EAAE,OADE;AAETC,MAAAA,SAAS,EAAE,MAFF;AAGT,wCAAkC;AAChCC,QAAAA,MAAM,EAAE,EADwB;AAEhCC,QAAAA,QAAQ,EAAE;AAFsB;AAHzB;AAbS,GAAP;AAAA,CAAf;;eAuBe,wBAAWT,MAAX,EAAmBhC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { TextField } from '@material-ui/core';\n\nexport class AnswerFraction extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disabled: PropTypes.bool.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n onAnswerChange: PropTypes.func.isRequired,\n answers: PropTypes.object.isRequired,\n };\n\n /**\n * Function to trigger when value change from number selection\n * @param {string} key contains event change object\n * @returns updated answer change object\n */\n onValueChange = (key) => (event) => {\n let value = parseInt(event?.target?.value);\n const { model, onAnswerChange, answers } = this.props;\n const newAnswers = { ...answers };\n const min = 1;\n const max = (key === 'noOfModel') ? model.maxModelSelected : 9;\n if(value > max) {\n value = max;\n } else if(value < min) {\n value = min;\n }\n newAnswers[key] = value;\n onAnswerChange(newAnswers);\n };\n\n render() {\n const { model, classes, showCorrect, answers, disabled } = this.props;\n\n return (\n <div>\n {model.allowedStudentConfig && (\n <div className={classes.groupInline}>\n <div className={classes.group}>\n <label htmlFor={'preview_number-of-models'} className={classes.inputLabel}>\n Number of Models\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_number-of-models\"\n inputProps={{ min: 1, max: model.maxModelSelected }}\n name=\"preview_number-of-models\"\n onChange={this.onValueChange('noOfModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.maxModelSelected : answers.noOfModel}\n />\n </div>\n <div className={classes.group}>\n <label htmlFor={'preview_parts-per-model'} className={classes.inputLabel}>\n Parts per Model\n </label>\n <TextField\n className={classes.textField}\n id=\"preview_parts-per-model\"\n inputProps={{ min: 1, max: 9 }}\n name=\"preview_parts-per-model\"\n onChange={this.onValueChange('partsPerModel')}\n type=\"number\"\n variant=\"outlined\"\n disabled={disabled}\n value={showCorrect ? model.partsPerModel : answers.partsPerModel}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n}\n\nconst styles = () => ({\n groupInline: {\n alignItems: 'center',\n display: 'flex',\n gap: '20px',\n },\n group: {\n margin: '12px 0',\n },\n inputLabel: {\n display: 'block',\n marginBottom: '4px',\n },\n textField: {\n width: '120px',\n maxHeight: '40px',\n '& [class^=\"MuiInputBase-root\"]': {\n height: 40,\n fontSize: '14px',\n },\n },\n});\n\nexport default withStyles(styles)(AnswerFraction);\n"],"file":"answer-fraction.js"}
@@ -270,11 +270,12 @@ var FractionModelChart = function FractionModelChart(props) {
270
270
  className: classes.barChartParentDiv
271
271
  }, barItems);
272
272
  };
273
+
274
+ var pieChartRef = (0, _react.useRef)(null);
273
275
  /*
274
276
  * Function to create and return pie fraction model
275
277
  * */
276
278
 
277
-
278
279
  var getPieFractionModel = function getPieFractionModel() {
279
280
  var parentData = []; // Generate data for pie chart
280
281
 
@@ -325,6 +326,7 @@ var FractionModelChart = function FractionModelChart(props) {
325
326
  }))));
326
327
  });
327
328
  return /*#__PURE__*/_react["default"].createElement("div", {
329
+ ref: pieChartRef,
328
330
  className: classes.pieChartParentDiv
329
331
  }, pieItems);
330
332
  }; //Render bar or pie models as per model type
@@ -333,6 +335,19 @@ var FractionModelChart = function FractionModelChart(props) {
333
335
  if (modelType === 'bar') {
334
336
  return getBarFractionModel();
335
337
  } else if (modelType === 'pie') {
338
+ //Remove the last sector line of pie chart if parts per model is 1
339
+ (0, _react.useEffect)(function () {
340
+ if (pieChartRef !== null && pieChartRef !== void 0 && pieChartRef.current && partsPerModel === 1) {
341
+ var paths = pieChartRef.current.querySelectorAll('path');
342
+
343
+ if (paths.length > 0) {
344
+ paths.forEach(function (path) {
345
+ var d = path.getAttribute('d');
346
+ path.setAttribute('d', d.replaceAll('L 100,100', ''));
347
+ });
348
+ }
349
+ }
350
+ }, []);
336
351
  return getPieFractionModel();
337
352
  }
338
353
  };