@webwriter/quiz 1.1.2 → 1.1.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.
@@ -5845,9 +5845,14 @@ var WebwriterChoice = class extends (_a2 = LitElementWw, _mode_dec = [n5({ type:
5845
5845
  })], _randomOrder_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({
5846
5846
  type: Boolean,
5847
5847
  label: { "en": "Random Choice Order", "de": "Zuf\xE4llige Reihenfolge" }
5848
- })], _showSolution_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({
5849
- type: Boolean,
5850
- label: { "en": "show Solution", "de": "L\xF6sung anzeigen" }
5848
+ })], _showSolution_dec = [n5({ type: String, attribute: true, reflect: true }), option({
5849
+ type: "select",
5850
+ label: { "de": "L\xF6sung anzeigen", "en": "Show solution" },
5851
+ options: [
5852
+ { value: "right", label: { "en": "Right answers", "de": "Korrekte Antworten" } },
5853
+ { value: "both", label: { "en": "all (indicator)", "de": "Alle (Indikator)" } },
5854
+ { value: "full", label: { "en": "all (conclusive)", "de": "Alle (vollst\xE4ndig)" } }
5855
+ ]
5851
5856
  })], _slotEl_dec = [e6("slot")], _addItem_dec = [action()], _items_dec = [o6()], _value_dec = [n5({ type: Array, attribute: false })], _itemsSlotEl_dec = [e6("#items-slot")], _a2) {
5852
5857
  constructor() {
5853
5858
  super(...arguments);
@@ -5855,7 +5860,7 @@ var WebwriterChoice = class extends (_a2 = LitElementWw, _mode_dec = [n5({ type:
5855
5860
  __publicField(this, "localize", generated_default);
5856
5861
  __privateAdd(this, _mode, __runInitializers(_init2, 8, this, "single")), __runInitializers(_init2, 11, this);
5857
5862
  __privateAdd(this, _randomOrder, __runInitializers(_init2, 12, this, false)), __runInitializers(_init2, 15, this);
5858
- __privateAdd(this, _showSolution, __runInitializers(_init2, 16, this, false)), __runInitializers(_init2, 19, this);
5863
+ __privateAdd(this, _showSolution, __runInitializers(_init2, 16, this, "right")), __runInitializers(_init2, 19, this);
5859
5864
  __privateAdd(this, _slotEl, __runInitializers(_init2, 20, this)), __runInitializers(_init2, 23, this);
5860
5865
  __privateAdd(this, _items, __runInitializers(_init2, 24, this)), __runInitializers(_init2, 27, this);
5861
5866
  __privateAdd(this, _value, []);
@@ -5889,6 +5894,7 @@ var WebwriterChoice = class extends (_a2 = LitElementWw, _mode_dec = [n5({ type:
5889
5894
  this.items.forEach((item) => value.includes(item.id) ? item.valid = true : null);
5890
5895
  }
5891
5896
  reportSolution() {
5897
+ console.log(this.solution, this.items);
5892
5898
  let itemActive = false;
5893
5899
  this.items.forEach((item) => {
5894
5900
  itemActive = itemActive || item.active;
@@ -5905,24 +5911,36 @@ var WebwriterChoice = class extends (_a2 = LitElementWw, _mode_dec = [n5({ type:
5905
5911
  this.items.forEach((item) => item.valid = true);
5906
5912
  return;
5907
5913
  }
5914
+ let wrongSolution = false;
5908
5915
  this.items.forEach(
5909
5916
  (item) => {
5917
+ console.log(!(item.active === item.valid), item.active, item.valid);
5910
5918
  item.valid = (this.solution ?? []).includes(item.id);
5911
- if (item.active != item.valid && !this.showSolution) {
5912
- this.items.forEach((item2) => {
5913
- item2.showSolution = false;
5914
- });
5919
+ if (item.active != item.valid) {
5920
+ wrongSolution = true;
5921
+ if (this.showSolution != "full") {
5922
+ this.items.forEach((item2) => {
5923
+ item2.showSolution = false;
5924
+ });
5925
+ }
5915
5926
  }
5916
5927
  item.style.pointerEvents = "none";
5917
5928
  }
5918
5929
  );
5930
+ if (wrongSolution) {
5931
+ if (this.showSolution != "right") {
5932
+ this.style.backgroundColor = "#F9B5C4";
5933
+ }
5934
+ } else {
5935
+ this.style.backgroundColor = "#BCE194";
5936
+ }
5919
5937
  }
5920
5938
  reset() {
5921
5939
  this.items.forEach((item) => {
5922
5940
  item.valid = void 0;
5923
5941
  item.active = false;
5924
5942
  item.showSolution = true;
5925
- item.style.pointerEvents = "auto";
5943
+ item.style.pointerEvents = "auto", this.style.backgroundColor = "";
5926
5944
  });
5927
5945
  this.shuffleItems();
5928
5946
  }
@@ -4585,15 +4585,20 @@ var WebwriterOrder = class extends (_a2 = LitElementWw, _layout_dec = [n5({ type
4585
4585
  { value: "list", label: { "en": "List" } },
4586
4586
  { value: "tiles", label: { "en": "Tiles" } }
4587
4587
  ]
4588
- })], _hideOrderButtons_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({ type: Boolean, label: { "en": "Hide order buttons", "de": "Pfeile zum Verschieben verstecken" } })], _showSolution_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({
4589
- type: Boolean,
4590
- label: { "en": "show Solution", "de": "L\xF6sung anzeigen" }
4588
+ })], _hideOrderButtons_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({ type: Boolean, label: { "en": "Hide order buttons", "de": "Pfeile zum Verschieben verstecken" } })], _showSolution_dec = [n5({ type: String, attribute: true, reflect: true }), option({
4589
+ type: "select",
4590
+ label: { "de": "L\xF6sung anzeigen", "en": "Show solution" },
4591
+ options: [
4592
+ { value: "right", label: { "en": "Right answers", "de": "Korrekte Antworten" } },
4593
+ { value: "both", label: { "en": "all (indicator)", "de": "Alle (Indikator)" } },
4594
+ { value: "full", label: { "en": "all (conclusive)", "de": "Alle (vollst\xE4ndig)" } }
4595
+ ]
4591
4596
  })], _itemsSlot_dec = [e6("#items-slot")], _items_dec = [o6()], _solution_dec = [n5({ attribute: false })], _a2) {
4592
4597
  constructor() {
4593
4598
  super(...arguments);
4594
4599
  __runInitializers(_init2, 5, this);
4595
4600
  __publicField(this, "localize", generated_default);
4596
- __privateAdd(this, _showSolution, __runInitializers(_init2, 8, this, false)), __runInitializers(_init2, 11, this);
4601
+ __privateAdd(this, _showSolution, __runInitializers(_init2, 8, this, "right")), __runInitializers(_init2, 11, this);
4597
4602
  __publicField(this, "observer");
4598
4603
  __publicField(this, "orderSheet", new CSSStyleSheet());
4599
4604
  __publicField(this, "clearDropPreviews", () => {
@@ -4702,14 +4707,23 @@ var WebwriterOrder = class extends (_a2 = LitElementWw, _layout_dec = [n5({ type
4702
4707
  }
4703
4708
  reportSolution() {
4704
4709
  this.solution.forEach((id, i7) => this.querySelector(`#${id}`).validOrder = i7);
4705
- if (!this.showSolution) {
4706
- this.items.forEach((item) => {
4707
- if (this.items.indexOf(item) != this.solution.indexOf(item.id)) {
4710
+ let wrongSolution = false;
4711
+ this.items.forEach((item) => {
4712
+ if (this.items.indexOf(item) != this.solution.indexOf(item.id)) {
4713
+ wrongSolution = true;
4714
+ if (this.showSolution != "full") {
4708
4715
  this.items.forEach((i7) => {
4709
4716
  i7.showSolution = false;
4710
4717
  });
4711
4718
  }
4712
- });
4719
+ }
4720
+ });
4721
+ if (wrongSolution) {
4722
+ if (this.showSolution != "right") {
4723
+ this.style.backgroundColor = "#F9B5C4";
4724
+ }
4725
+ } else {
4726
+ this.style.backgroundColor = "#BCE194";
4713
4727
  }
4714
4728
  this.items.forEach((item) => {
4715
4729
  item.style.pointerEvents = "none";
@@ -4717,6 +4731,7 @@ var WebwriterOrder = class extends (_a2 = LitElementWw, _layout_dec = [n5({ type
4717
4731
  }
4718
4732
  reset() {
4719
4733
  this.solution = void 0;
4734
+ this.style.backgroundColor = "";
4720
4735
  this.shuffleItems();
4721
4736
  this.items.forEach((item) => {
4722
4737
  item.style.pointerEvents = "auto";
@@ -4728,9 +4743,11 @@ var WebwriterOrder = class extends (_a2 = LitElementWw, _layout_dec = [n5({ type
4728
4743
  render() {
4729
4744
  return x`
4730
4745
  <slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
4731
- <sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
4746
+ ${this.hasAttribute("contenteditable") ? x`
4747
+ <sl-button size="small" id="add-option" @click=${() => this.addItem()}>
4732
4748
  <sl-icon src=${plus_default}></sl-icon><span>${msg("Add Option")}</span>
4733
4749
  </sl-button>
4750
+ ` : ""}
4734
4751
  `;
4735
4752
  }
4736
4753
  };
@@ -4817,11 +4834,11 @@ __publicField(WebwriterOrder, "styles", i`
4817
4834
  align-items: center;
4818
4835
  justify-content: center;
4819
4836
  }
4820
-
4821
-
4837
+ // broken for some reason o.O
4838
+ /*
4822
4839
  :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
4823
4840
  display: none;
4824
- }
4841
+ } */
4825
4842
  `);
4826
4843
  __runInitializers(_init2, 1, WebwriterOrder);
4827
4844
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webwriter/quiz",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Add interactive tasks (multiple choice, order, free text, highlighting, or speech input). Make a quiz out of multiple tasks.",
5
5
  "keywords": [
6
6
  "webwriter-widget",
@@ -72,12 +72,17 @@ export class WebwriterChoice extends LitElementWw {
72
72
  })
73
73
  accessor randomOrder = false
74
74
 
75
- @property({type: Boolean, attribute: true, reflect: true})
75
+ @property({type: String, attribute: true, reflect: true})
76
76
  @option({
77
- type: Boolean,
78
- label: {"en": "show Solution", "de": "Lösung anzeigen"},
77
+ type: "select",
78
+ label: {"de": "Lösung anzeigen", "en": "Show solution"},
79
+ options: [
80
+ {value: "right", label: {"en": "Right answers", "de": "Korrekte Antworten"}},
81
+ {value: "both", label: {"en": "all (indicator)", "de": "Alle (Indikator)"}},
82
+ {value: "full", label: {"en": "all (conclusive)", "de": "Alle (vollständig)"}}
83
+ ],
79
84
  })
80
- accessor showSolution = false
85
+ accessor showSolution = "right"
81
86
 
82
87
  get solution() {
83
88
  const validIDs = this.items.filter(item => item.valid).map(item => item.id)
@@ -90,7 +95,7 @@ export class WebwriterChoice extends LitElementWw {
90
95
 
91
96
 
92
97
  reportSolution() {
93
-
98
+ console.log(this.solution, this.items)
94
99
  let itemActive: boolean = false
95
100
  this.items.forEach(item => {itemActive = itemActive || item.active})
96
101
  if(!itemActive){
@@ -101,21 +106,32 @@ export class WebwriterChoice extends LitElementWw {
101
106
  this.items.forEach(item => item.valid = true)
102
107
  return
103
108
  }
109
+ let wrongSolution: boolean = false
104
110
  this.items.forEach(item => {
111
+ console.log(!(item.active === item.valid), item.active, item.valid)
105
112
  item.valid = (this.solution ?? []).includes(item.id)
106
- if(item.active != item.valid && !this.showSolution){
107
- this.items.forEach(item => {
108
- item.showSolution = false
109
- })
113
+ if(item.active != item.valid){
114
+ wrongSolution = true
115
+ if(this.showSolution != "full"){
116
+ this.items.forEach(item => {
117
+ item.showSolution = false
118
+ })
119
+ }
110
120
  }
111
121
  item.style.pointerEvents = "none"
112
122
  }
113
123
  )
114
-
124
+ if(wrongSolution){
125
+ if(this.showSolution != "right"){
126
+ this.style.backgroundColor = "#F9B5C4"
127
+ }
128
+ }else{
129
+ this.style.backgroundColor = "#BCE194"
130
+ }
115
131
  }
116
132
 
117
133
  reset() {
118
- this.items.forEach(item => {item.valid = undefined; item.active = false; item.showSolution = true; item.style.pointerEvents = "auto"})
134
+ this.items.forEach(item => {item.valid = undefined; item.active = false; item.showSolution = true; item.style.pointerEvents = "auto", this.style.backgroundColor = ""})
119
135
  this.shuffleItems()
120
136
  }
121
137
 
@@ -103,11 +103,11 @@ export class WebwriterOrder extends LitElementWw {
103
103
  align-items: center;
104
104
  justify-content: center;
105
105
  }
106
-
107
-
106
+ // broken for some reason o.O
107
+ /*
108
108
  :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
109
109
  display: none;
110
- }
110
+ } */
111
111
  `
112
112
 
113
113
  get layout(): "list" | "tiles" {
@@ -137,12 +137,17 @@ export class WebwriterOrder extends LitElementWw {
137
137
  this.items.forEach(item => item.hideOrderButtons = value)
138
138
  }
139
139
 
140
- @property({type: Boolean, attribute: true, reflect: true})
140
+ @property({type: String, attribute: true, reflect: true})
141
141
  @option({
142
- type: Boolean,
143
- label: {"en": "show Solution", "de": "Lösung anzeigen"},
142
+ type: "select",
143
+ label: {"de": "Lösung anzeigen", "en": "Show solution"},
144
+ options: [
145
+ {value: "right", label: {"en": "Right answers", "de": "Korrekte Antworten"}},
146
+ {value: "both", label: {"en": "all (indicator)", "de": "Alle (Indikator)"}},
147
+ {value: "full", label: {"en": "all (conclusive)", "de": "Alle (vollständig)"}}
148
+ ],
144
149
  })
145
- accessor showSolution = false
150
+ accessor showSolution = "right"
146
151
 
147
152
  observer: MutationObserver
148
153
 
@@ -273,14 +278,23 @@ export class WebwriterOrder extends LitElementWw {
273
278
 
274
279
  reportSolution() {
275
280
  this.solution.forEach((id, i) => (this.querySelector(`#${id}`) as any).validOrder = i)
276
- if(!this.showSolution){
277
- this.items.forEach(item => {
278
- if(this.items.indexOf(item) != this.solution.indexOf(item.id)){
281
+ let wrongSolution: boolean = false
282
+ this.items.forEach(item => {
283
+ if(this.items.indexOf(item) != this.solution.indexOf(item.id)){
284
+ wrongSolution = true
285
+ if(this.showSolution != "full"){
279
286
  this.items.forEach(i => {
280
287
  i.showSolution = false
281
288
  })
282
289
  }
283
- })
290
+ }
291
+ })
292
+ if(wrongSolution){
293
+ if(this.showSolution != "right"){
294
+ this.style.backgroundColor = "#F9B5C4"
295
+ }
296
+ }else{
297
+ this.style.backgroundColor = "#BCE194"
284
298
  }
285
299
  this.items.forEach(item=>{
286
300
  item.style.pointerEvents="none"
@@ -289,6 +303,7 @@ export class WebwriterOrder extends LitElementWw {
289
303
 
290
304
  reset() {
291
305
  this.solution = undefined
306
+ this.style.backgroundColor = ""
292
307
  this.shuffleItems()
293
308
  this.items.forEach(item=>{
294
309
  item.style.pointerEvents="auto"
@@ -302,9 +317,11 @@ export class WebwriterOrder extends LitElementWw {
302
317
  render() {
303
318
  return html`
304
319
  <slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
305
- <sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
320
+ ${this.hasAttribute("contenteditable")?html`
321
+ <sl-button size="small" id="add-option" @click=${() => this.addItem()}>
306
322
  <sl-icon src=${IconPlus}></sl-icon><span>${msg("Add Option")}</span>
307
323
  </sl-button>
324
+ `:""}
308
325
  `
309
326
  }
310
327
  }