@pie-element/ebsr 9.8.1-next.1 → 9.9.0

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.
@@ -326,6 +326,10 @@ Properties of the `image` object:
326
326
 
327
327
  Indicates if the plugin is disabled or not
328
328
 
329
+ #### `required` (boolean)
330
+
331
+ Indicates if the item is required and the value cannot be empty
332
+
329
333
  #### `settings` (boolean)
330
334
 
331
335
  Indicates if the item has to be displayed in the Settings Panel
@@ -390,6 +394,10 @@ Properties of the `image` object:
390
394
 
391
395
  Indicates if the plugin is disabled or not
392
396
 
397
+ #### `required` (boolean)
398
+
399
+ Indicates if the item is required and the value cannot be empty
400
+
393
401
  #### `settings` (boolean)
394
402
 
395
403
  Indicates if the item has to be displayed in the Settings Panel
@@ -450,6 +458,10 @@ Properties of the `image` object:
450
458
 
451
459
  Indicates if the plugin is disabled or not
452
460
 
461
+ #### `required` (boolean)
462
+
463
+ Indicates if the item is required and the value cannot be empty
464
+
453
465
  #### `settings` (boolean)
454
466
 
455
467
  Indicates if the item has to be displayed in the Settings Panel
@@ -638,9 +650,9 @@ Indicates if the item has to be displayed in the Settings Panel
638
650
 
639
651
  Indicates the label for the item that has to be displayed in the Settings Panel
640
652
 
641
- ## `EditableHtmlPluginConfigure` (object)
653
+ ## `EditableHtmlPluginConfigureRequired` (object)
642
654
 
643
- Properties of the `EditableHtmlPluginConfigure` object:
655
+ Properties of the `EditableHtmlPluginConfigureRequired` object:
644
656
 
645
657
  ### `inputConfiguration` (object)
646
658
 
@@ -678,6 +690,10 @@ Properties of the `image` object:
678
690
 
679
691
  Indicates if the plugin is disabled or not
680
692
 
693
+ ### `required` (boolean)
694
+
695
+ Indicates if the item is required and the value cannot be empty
696
+
681
697
  ### `settings` (boolean)
682
698
 
683
699
  Indicates if the item has to be displayed in the Settings Panel
@@ -762,6 +778,54 @@ Indicates if model should have mathML output instead of latex
762
778
 
763
779
  Indicates if mathML that's already in model should be editable
764
780
 
781
+ ## `EditableHtmlPluginConfigure` (object)
782
+
783
+ Properties of the `EditableHtmlPluginConfigure` object:
784
+
785
+ ### `inputConfiguration` (object)
786
+
787
+ Properties of the `inputConfiguration` object:
788
+
789
+ #### `math` (object)
790
+
791
+ Properties of the `math` object:
792
+
793
+ ##### `disabled` (boolean)
794
+
795
+ Indicates if the plugin is disabled or not
796
+
797
+ #### `audio` (object)
798
+
799
+ Properties of the `audio` object:
800
+
801
+ ##### `disabled` (boolean)
802
+
803
+ Indicates if the plugin is disabled or not
804
+
805
+ #### `video` (object)
806
+
807
+ Properties of the `video` object:
808
+
809
+ ##### `disabled` (boolean)
810
+
811
+ Indicates if the plugin is disabled or not
812
+
813
+ #### `image` (object)
814
+
815
+ Properties of the `image` object:
816
+
817
+ ##### `disabled` (boolean)
818
+
819
+ Indicates if the plugin is disabled or not
820
+
821
+ ### `settings` (boolean)
822
+
823
+ Indicates if the item has to be displayed in the Settings Panel
824
+
825
+ ### `label` (string)
826
+
827
+ Indicates the label for the item that has to be displayed in the Settings Panel
828
+
765
829
  ## `Part` (object)
766
830
 
767
831
  Properties of the `Part` object:
@@ -5742,7 +5742,8 @@ const defaultConfig = {
5742
5742
  image: {
5743
5743
  disabled: false
5744
5744
  }
5745
- }
5745
+ },
5746
+ required: false
5746
5747
  },
5747
5748
  rationale: {
5748
5749
  settings: true,
@@ -5757,7 +5758,8 @@ const defaultConfig = {
5757
5758
  image: {
5758
5759
  disabled: false
5759
5760
  }
5760
- }
5761
+ },
5762
+ required: false
5761
5763
  },
5762
5764
  settingsPanelDisabled: true,
5763
5765
  studentInstructions: {
@@ -5777,7 +5779,8 @@ const defaultConfig = {
5777
5779
  image: {
5778
5780
  disabled: false
5779
5781
  }
5780
- }
5782
+ },
5783
+ required: false
5781
5784
  },
5782
5785
  choicesLayout: {
5783
5786
  settings: false,
@@ -23960,21 +23960,32 @@ const createCorrectResponseSession = (question, env) => {
23960
23960
  });
23961
23961
  };
23962
23962
 
23963
+ // remove all html tags except img and iframe
23964
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
23965
+
23963
23966
  const validatePart = (model = {}, config = {}) => {
23964
23967
  const { choices } = model;
23965
23968
  const { minAnswerChoices = 2, maxAnswerChoices } = config;
23966
23969
  const reversedChoices = [...(choices || [])].reverse();
23970
+ const errors = {};
23967
23971
  const choicesErrors = {};
23972
+ const rationaleErrors = {};
23968
23973
  let hasCorrectResponse = false;
23969
23974
 
23975
+ ['teacherInstructions', 'prompt'].forEach((field) => {
23976
+ if (config[field]?.required && !getContent(model[field])) {
23977
+ errors[field] = 'This field is required.';
23978
+ }
23979
+ });
23980
+
23970
23981
  reversedChoices.forEach((choice, index) => {
23971
- const { correct, value, label } = choice;
23982
+ const { correct, value, label, rationale } = choice;
23972
23983
 
23973
23984
  if (correct) {
23974
23985
  hasCorrectResponse = true;
23975
23986
  }
23976
23987
 
23977
- if (label === '' || label === '<div></div>') {
23988
+ if (!getContent(label)) {
23978
23989
  choicesErrors[value] = 'Content should not be empty.';
23979
23990
  } else {
23980
23991
  const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);
@@ -23983,23 +23994,30 @@ const validatePart = (model = {}, config = {}) => {
23983
23994
  choicesErrors[value] = 'Content should be unique.';
23984
23995
  }
23985
23996
  }
23997
+
23998
+ if (config.rationale?.required && !getContent(rationale)) {
23999
+ rationaleErrors[value] = 'This field is required.';
24000
+ }
23986
24001
  });
23987
24002
 
23988
- const errors = {};
23989
24003
  const nbOfChoices = (choices || []).length;
23990
24004
 
23991
24005
  if (nbOfChoices < minAnswerChoices) {
23992
- errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;
24006
+ errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
23993
24007
  } else if (nbOfChoices > maxAnswerChoices) {
23994
- errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
24008
+ errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
23995
24009
  }
23996
24010
 
23997
24011
  if (!hasCorrectResponse) {
23998
- errors.correctResponseError = 'No correct response defined.';
24012
+ errors.correctResponse = 'No correct response defined.';
23999
24013
  }
24000
24014
 
24001
24015
  if (!isEmpty_1(choicesErrors)) {
24002
- errors.choicesErrors = choicesErrors;
24016
+ errors.choices = choicesErrors;
24017
+ }
24018
+
24019
+ if (!isEmpty_1(rationaleErrors)) {
24020
+ errors.rationale = rationaleErrors;
24003
24021
  }
24004
24022
 
24005
24023
  return errors;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@pie-element/ebsr",
3
- "version": "9.8.1-next.1+2a706d799",
3
+ "version": "9.9.0",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "dependencies": {
10
- "@pie-element/multiple-choice": "^8.10.1-next.1+2a706d799",
10
+ "@pie-element/multiple-choice": "^8.11.0",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
12
  "classnames": "^2.2.5",
13
13
  "debug": "^4.1.1",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "author": "pie framework developers",
17
17
  "license": "ISC",
18
- "gitHead": "2a706d799bb000c60b7a77a790de9dc66345ebf5",
18
+ "gitHead": "31b9a687dba71627ef2724e4176e00ba61a5de17",
19
19
  "scripts": {
20
20
  "postpublish": "../../scripts/postpublish"
21
21
  },