@webwriter/quiz 1.0.10 → 1.1.1

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 (103) hide show
  1. package/LICENSE +6 -6
  2. package/custom.d.ts +175 -175
  3. package/dist/widgets/webwriter-choice-item.js +10 -7
  4. package/dist/widgets/webwriter-choice.js +39 -6
  5. package/dist/widgets/webwriter-order-item.js +14 -11
  6. package/dist/widgets/webwriter-order.js +30 -4
  7. package/dist/widgets/webwriter-quiz.js +2 -1
  8. package/dist/widgets/webwriter-text.js +26 -9
  9. package/lit-localize.json +14 -14
  10. package/localization/bg.xlf +69 -69
  11. package/localization/cs.xlf +69 -69
  12. package/localization/da.xlf +69 -69
  13. package/localization/de.xlf +74 -74
  14. package/localization/el.xlf +69 -69
  15. package/localization/es.xlf +69 -69
  16. package/localization/et.xlf +69 -69
  17. package/localization/fi.xlf +69 -69
  18. package/localization/fr.xlf +69 -69
  19. package/localization/generated/bg.ts +29 -29
  20. package/localization/generated/cs.ts +29 -29
  21. package/localization/generated/da.ts +29 -29
  22. package/localization/generated/de.ts +29 -29
  23. package/localization/generated/el.ts +29 -29
  24. package/localization/generated/es.ts +29 -29
  25. package/localization/generated/et.ts +29 -29
  26. package/localization/generated/fi.ts +29 -29
  27. package/localization/generated/fr.ts +29 -29
  28. package/localization/generated/hu.ts +29 -29
  29. package/localization/generated/id.ts +29 -29
  30. package/localization/generated/index.js +2 -2
  31. package/localization/generated/it.ts +29 -29
  32. package/localization/generated/ja.ts +29 -29
  33. package/localization/generated/ko.ts +29 -29
  34. package/localization/generated/locale-codes.js +79 -79
  35. package/localization/generated/lt.ts +29 -29
  36. package/localization/generated/lv.ts +29 -29
  37. package/localization/generated/nb.ts +29 -29
  38. package/localization/generated/nl.ts +29 -29
  39. package/localization/generated/pl.ts +29 -29
  40. package/localization/generated/pt-BR.ts +29 -29
  41. package/localization/generated/pt-PT.ts +29 -29
  42. package/localization/generated/ro.ts +29 -29
  43. package/localization/generated/ru.ts +29 -29
  44. package/localization/generated/sk.ts +29 -29
  45. package/localization/generated/sl.ts +29 -29
  46. package/localization/generated/sv.ts +29 -29
  47. package/localization/generated/tr.ts +29 -29
  48. package/localization/generated/uk.ts +29 -29
  49. package/localization/generated/zh-hans.ts +29 -29
  50. package/localization/hu.xlf +69 -69
  51. package/localization/id.xlf +69 -69
  52. package/localization/it.xlf +69 -69
  53. package/localization/ja.xlf +69 -69
  54. package/localization/ko.xlf +69 -69
  55. package/localization/lt.xlf +69 -69
  56. package/localization/lv.xlf +69 -69
  57. package/localization/nb.xlf +69 -69
  58. package/localization/nl.xlf +69 -69
  59. package/localization/pl.xlf +69 -69
  60. package/localization/pt-BR.xlf +69 -69
  61. package/localization/pt-PT.xlf +69 -69
  62. package/localization/ro.xlf +69 -69
  63. package/localization/ru.xlf +69 -69
  64. package/localization/sk.xlf +69 -69
  65. package/localization/sl.xlf +69 -69
  66. package/localization/sv.xlf +69 -69
  67. package/localization/tr.xlf +69 -69
  68. package/localization/uk.xlf +69 -69
  69. package/localization/zh-hans.xlf +69 -69
  70. package/package.json +7 -2
  71. package/src/lib/combobox.ts +455 -455
  72. package/src/lib/highlighter-fill.svg +5 -5
  73. package/src/snippets/Beispiel-Choice.html +57 -57
  74. package/src/snippets/Beispiel-Mark.html +13 -13
  75. package/src/snippets/Beispiel-Order.html +52 -52
  76. package/src/snippets/Beispiel-Text.html +20 -20
  77. package/src/snippets/blank.html +1 -0
  78. package/src/snippets/choice.html +7 -7
  79. package/src/snippets/cloze.html +3 -3
  80. package/src/snippets/mark.html +3 -3
  81. package/src/snippets/order.html +7 -7
  82. package/src/snippets/pairing.html +9 -9
  83. package/src/snippets/speech.html +3 -3
  84. package/src/snippets/text.html +3 -3
  85. package/src/snippets/wordsearch.html +3 -3
  86. package/src/widgets/webwriter-choice-item.ts +253 -250
  87. package/src/widgets/webwriter-choice.ts +339 -314
  88. package/src/widgets/webwriter-cloze-gap.ts +215 -215
  89. package/src/widgets/webwriter-cloze.ts +135 -135
  90. package/src/widgets/webwriter-mark.ts +431 -431
  91. package/src/widgets/webwriter-order-item.ts +440 -437
  92. package/src/widgets/webwriter-order.ts +311 -284
  93. package/src/widgets/webwriter-pairing-item.ts +160 -160
  94. package/src/widgets/webwriter-pairing.ts +192 -192
  95. package/src/widgets/webwriter-quiz.ts +282 -281
  96. package/src/widgets/webwriter-speech.ts +272 -272
  97. package/src/widgets/webwriter-task-explainer.ts +42 -42
  98. package/src/widgets/webwriter-task-hint.ts +22 -22
  99. package/src/widgets/webwriter-task-prompt.ts +23 -23
  100. package/src/widgets/webwriter-task.ts +546 -546
  101. package/src/widgets/webwriter-text.ts +155 -135
  102. package/tsconfig.json +6 -6
  103. package/.env +0 -1
@@ -1,285 +1,312 @@
1
- import {css, html, PropertyValues} from "lit"
2
- import {LitElementWw, option} from "@webwriter/lit"
3
- import {customElement, property, query, queryAssignedElements} from "lit/decorators.js"
4
-
5
- import SlButton from "@shoelace-style/shoelace/dist/components/button/button.component.js"
6
- import SlIcon from "@shoelace-style/shoelace/dist/components/icon/icon.component.js"
7
- import "@shoelace-style/shoelace/dist/themes/light.css"
8
- import { Sortable } from "@shopify/draggable"
9
- import IconPlus from "bootstrap-icons/icons/plus.svg"
10
-
11
- import { WebwriterOrderItem } from "./webwriter-order-item"
12
- import { ifDefined } from "lit/directives/if-defined.js"
13
-
14
- import LOCALIZE from "../../localization/generated"
15
- import {msg} from "@lit/localize"
16
-
17
- export function shuffle<T>(a: T[]) {
18
- for (let i = a.length - 1; i > 0; i--) {
19
- const j = Math.floor(Math.random() * (i + 1));
20
- [a[i], a[j]] = [a[j], a[i]];
21
- }
22
- return a;
23
- }
24
-
25
- declare global {interface HTMLElementTagNameMap {
26
- "webwriter-order": WebwriterOrder;
27
- }}
28
-
29
- @customElement("webwriter-order")
30
- export class WebwriterOrder extends LitElementWw {
31
-
32
- localize = LOCALIZE
33
-
34
- static scopedElements = {
35
- "sl-button": SlButton,
36
- "sl-icon": SlIcon
37
- }
38
-
39
- static styles = css`
40
- :host {
41
- display: flex !important;
42
- flex-direction: column;
43
- align-items: flex-start;
44
- counter-reset: orderItem;
45
- gap: 2px;
46
- }
47
-
48
- :host([layout=tiles]) {
49
- flex-direction: row;
50
- flex-wrap: wrap;
51
- gap: 15px;
52
- }
53
-
54
- :host(:is([contenteditable=true], [contenteditable=""])) {
55
- --text-color: var(--sl-color-success-700);
56
- }
57
-
58
- :host ::slotted(*::part(counter)) {
59
- counter-increment: orderItem;
60
- content: counter(orderItem) '. ';
61
- cursor: move;
62
- text-align: right;
63
- padding-right: 0.5em;
64
- min-width: 1.5em;
65
- color: var(--text-color, auto);
66
- }
67
-
68
- sl-button::part(label) {
69
- padding: 0;
70
- display: flex;
71
- flex-direction: row;
72
- align-items: center;
73
- }
74
-
75
- sl-button::part(base) {
76
- border: none;
77
- background: transparent;
78
- }
79
-
80
- sl-icon {
81
- width: 19px;
82
- height: 19px;
83
- padding: var(--sl-spacing-x-small);
84
- padding-left: 0;
85
- }
86
-
87
- #add-option {
88
- order: 2147483647;
89
- }
90
-
91
- #add-option:not(:hover)::part(base) {
92
- color: darkgray;
93
- }
94
-
95
- :host([layout=tiles]) #add-option {
96
- width: 125px;
97
- height: 125px;
98
- overflow: hidden;
99
- border: 2px solid var(--sl-color-gray-300);
100
- border-radius: 5px;
101
- padding: 5px;
102
- display: flex;
103
- align-items: center;
104
- justify-content: center;
105
- }
106
-
107
-
108
- :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
109
- display: none;
110
- }
111
- `
112
-
113
- get layout(): "list" | "tiles" {
114
- return this.children?.item(0)?.getAttribute("layout") as any ?? "list"
115
- }
116
-
117
- @property({type: String, attribute: true, reflect: true}) //@ts-ignore
118
- @option({
119
- type: "select",
120
- options: [
121
- {value: "list", label: {"en": "List"}},
122
- {value: "tiles", label: {"en": "Tiles"}}
123
- ]
124
- })
125
- set layout(value) {
126
- this.querySelectorAll("webwriter-order-item").forEach(el => el.setAttribute("layout", value))
127
- this.requestUpdate("layout")
128
- }
129
-
130
- get hideOrderButtons() {
131
- return !!this.items[0]?.hideOrderButtons
132
- }
133
-
134
- @property({type: Boolean, attribute: true, reflect: true}) //@ts-ignore
135
- @option({type: Boolean, label: {_: "Hide order buttons"}})
136
- set hideOrderButtons(value: boolean) {
137
- this.items.forEach(item => item.hideOrderButtons = value)
138
- }
139
-
140
-
141
- observer: MutationObserver
142
-
143
- connectedCallback() {
144
- super.connectedCallback()
145
- this.addEventListener("ww-moveup", this.handleMove)
146
- this.addEventListener("ww-movedown", this.handleMove)
147
- this.addEventListener("ww-moveto", this.handleMove)
148
- this.observer = new MutationObserver(() => {
149
- this.items.forEach(item => item.requestUpdate())
150
- if(this.isContentEditable) {
151
- this.solution = this.items.map(item => item.id)
152
- }
153
- this.clearDropPreviews()
154
- })
155
- this.observer.observe(this, {childList: true})
156
- // this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.orderSheet]
157
- }
158
-
159
- serializedCallback() {
160
- this.shuffleItems()
161
- }
162
-
163
- disconnectedCallback(): void {
164
- super.disconnectedCallback()
165
- this.observer?.disconnect()
166
- this.observer = undefined
167
- }
168
-
169
- orderSheet = new CSSStyleSheet()
170
-
171
- addItem() {
172
- const orderItem = this.ownerDocument.createElement("webwriter-order-item")
173
- const p = this.ownerDocument.createElement("p")
174
- orderItem.appendChild(p)
175
- orderItem.setAttribute("layout", this.layout)
176
- this.append(orderItem)
177
- this.solution = [...this.#solution, orderItem.id]
178
- this.ownerDocument.getSelection().setBaseAndExtent(p, 0, p, 0)
179
- }
180
-
181
- shuffleItems() {
182
- const n = this.items.length
183
- const nums = shuffle([...(new Array(n)).keys()])
184
- this.innerHTML = nums.map(i => this.children.item(i).outerHTML).join("")
185
- }
186
-
187
- clearDropPreviews = () => {
188
- this.items.forEach(item => item.dropPreview = undefined)
189
- }
190
-
191
- @query("#items-slot")
192
- accessor itemsSlot: HTMLSlotElement
193
-
194
- @queryAssignedElements()
195
- accessor items: WebwriterOrderItem[]
196
-
197
- handleKeyDown(e: KeyboardEvent) {
198
- if(e.key == "ArrowDown") {
199
- e.stopPropagation()
200
- e.preventDefault()
201
- }
202
- else if(e.key === "ArrowUp") {
203
- e.stopPropagation()
204
- e.preventDefault()
205
- }
206
- }
207
-
208
- /*
209
- If contenteditable: Reorder solution -> Triggers orderSheet change
210
- If not contenteditable: Reorder value -> Triggers orderSheet change
211
- */
212
-
213
- moveChild(elem: HTMLElement, i: number) {
214
- /*
215
- let items = this.items.map(el => el !== elem? el: undefined)
216
- items.splice(i, 0, elem as WebwriterOrderItem)
217
- items = items.filter(child => child)
218
- this.replaceChildren(...items)
219
- this.items.forEach(item => item.requestUpdate())*/
220
- if(i === 0) {
221
- this.insertAdjacentElement("afterbegin", elem)
222
- }
223
- else if(i < this.items.length) {
224
- this.items[i].insertAdjacentElement("beforebegin", elem)
225
- }
226
- else {
227
- this.insertAdjacentElement("beforeend", elem)
228
- }
229
- }
230
-
231
- handleMove = (e: CustomEvent) => {
232
- const elem = e.target as HTMLElement
233
- const children = Array.from(this.children)
234
- const pos = children.indexOf(elem)
235
- let i: number
236
- if(e.type === "ww-moveup") {
237
- i = Math.max(0, pos - 1)
238
- }
239
- else if(e.type === "ww-movedown") {
240
- i = Math.min(children.length, pos + 2)
241
-
242
- }
243
- else if(e.type === "ww-moveto") {
244
- i = e.detail.i
245
- }
246
- this.moveChild(elem, i)
247
- }
248
-
249
-
250
- #solution: string[] = []
251
-
252
- get solution() {
253
- return this.#solution?.length? this.#solution: undefined
254
- }
255
-
256
- @property({attribute: false})
257
- set solution(value: string[]) {
258
- this.#solution = value
259
- if(value) {
260
- this.dispatchEvent(new CustomEvent("ww-answer-change", {
261
- bubbles: true,
262
- composed: true
263
- }))
264
- }
265
- }
266
-
267
-
268
- reportSolution() {
269
- this.solution.forEach((id, i) => (this.querySelector(`#${id}`) as any).validOrder = i)
270
- }
271
-
272
- reset() {
273
- this.solution = undefined
274
- this.shuffleItems()
275
- }
276
-
277
- render() {
278
- return html`
279
- <slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
280
- <sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
281
- <sl-icon src=${IconPlus}></sl-icon><span>${msg("Add Option")}</span>
282
- </sl-button>
283
- `
284
- }
1
+ import {css, html, PropertyValues} from "lit"
2
+ import {LitElementWw, option} from "@webwriter/lit"
3
+ import {customElement, property, query, queryAssignedElements} from "lit/decorators.js"
4
+
5
+ import SlButton from "@shoelace-style/shoelace/dist/components/button/button.component.js"
6
+ import SlIcon from "@shoelace-style/shoelace/dist/components/icon/icon.component.js"
7
+ import "@shoelace-style/shoelace/dist/themes/light.css"
8
+ import { Sortable } from "@shopify/draggable"
9
+ import IconPlus from "bootstrap-icons/icons/plus.svg"
10
+
11
+ import { WebwriterOrderItem } from "./webwriter-order-item"
12
+ import { ifDefined } from "lit/directives/if-defined.js"
13
+
14
+ import LOCALIZE from "../../localization/generated"
15
+ import {msg} from "@lit/localize"
16
+
17
+ export function shuffle<T>(a: T[]) {
18
+ for (let i = a.length - 1; i > 0; i--) {
19
+ const j = Math.floor(Math.random() * (i + 1));
20
+ [a[i], a[j]] = [a[j], a[i]];
21
+ }
22
+ return a;
23
+ }
24
+
25
+ declare global {interface HTMLElementTagNameMap {
26
+ "webwriter-order": WebwriterOrder;
27
+ }}
28
+
29
+ @customElement("webwriter-order")
30
+ export class WebwriterOrder extends LitElementWw {
31
+
32
+ localize = LOCALIZE
33
+
34
+ static scopedElements = {
35
+ "sl-button": SlButton,
36
+ "sl-icon": SlIcon
37
+ }
38
+
39
+ static styles = css`
40
+ :host {
41
+ display: flex !important;
42
+ flex-direction: column;
43
+ align-items: flex-start;
44
+ counter-reset: orderItem;
45
+ gap: 2px;
46
+ }
47
+
48
+ :host([layout=tiles]) {
49
+ flex-direction: row;
50
+ flex-wrap: wrap;
51
+ gap: 15px;
52
+ }
53
+
54
+ :host(:is([contenteditable=true], [contenteditable=""])) {
55
+ --text-color: var(--sl-color-success-700);
56
+ }
57
+
58
+ :host ::slotted(*::part(counter)) {
59
+ counter-increment: orderItem;
60
+ content: counter(orderItem) '. ';
61
+ cursor: move;
62
+ text-align: right;
63
+ padding-right: 0.5em;
64
+ min-width: 1.5em;
65
+ color: var(--text-color, auto);
66
+ }
67
+
68
+ sl-button::part(label) {
69
+ padding: 0;
70
+ display: flex;
71
+ flex-direction: row;
72
+ align-items: center;
73
+ }
74
+
75
+ sl-button::part(base) {
76
+ border: none;
77
+ background: transparent;
78
+ }
79
+
80
+ sl-icon {
81
+ width: 19px;
82
+ height: 19px;
83
+ padding: var(--sl-spacing-x-small);
84
+ padding-left: 0;
85
+ }
86
+
87
+ #add-option {
88
+ order: 2147483647;
89
+ }
90
+
91
+ #add-option:not(:hover)::part(base) {
92
+ color: darkgray;
93
+ }
94
+
95
+ :host([layout=tiles]) #add-option {
96
+ width: 125px;
97
+ height: 125px;
98
+ overflow: hidden;
99
+ border: 2px solid var(--sl-color-gray-300);
100
+ border-radius: 5px;
101
+ padding: 5px;
102
+ display: flex;
103
+ align-items: center;
104
+ justify-content: center;
105
+ }
106
+
107
+
108
+ :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
109
+ display: none;
110
+ }
111
+ `
112
+
113
+ get layout(): "list" | "tiles" {
114
+ return this.children?.item(0)?.getAttribute("layout") as any ?? "list"
115
+ }
116
+
117
+ @property({type: String, attribute: true, reflect: true}) //@ts-ignore
118
+ @option({
119
+ type: "select",
120
+ options: [
121
+ {value: "list", label: {"en": "List"}},
122
+ {value: "tiles", label: {"en": "Tiles"}}
123
+ ]
124
+ })
125
+ set layout(value) {
126
+ this.querySelectorAll("webwriter-order-item").forEach(el => el.setAttribute("layout", value))
127
+ this.requestUpdate("layout")
128
+ }
129
+
130
+ get hideOrderButtons() {
131
+ return !!this.items[0]?.hideOrderButtons
132
+ }
133
+
134
+ @property({type: Boolean, attribute: true, reflect: true}) //@ts-ignore
135
+ @option({type: Boolean, label: {"en": "Hide order buttons", "de": "Pfeile zum Verschieben verstecken"}})
136
+ set hideOrderButtons(value: boolean) {
137
+ this.items.forEach(item => item.hideOrderButtons = value)
138
+ }
139
+
140
+ @property({type: Boolean, attribute: true, reflect: true})
141
+ @option({
142
+ type: Boolean,
143
+ label: {"en": "show Solution", "de": "Lösung anzeigen"},
144
+ })
145
+ accessor showSolution = true
146
+
147
+ observer: MutationObserver
148
+
149
+ connectedCallback() {
150
+ super.connectedCallback()
151
+ this.addEventListener("ww-moveup", this.handleMove)
152
+ this.addEventListener("ww-movedown", this.handleMove)
153
+ this.addEventListener("ww-moveto", this.handleMove)
154
+ this.observer = new MutationObserver(() => {
155
+ this.items.forEach(item => item.requestUpdate())
156
+ if(this.isContentEditable) {
157
+ this.solution = this.items.map(item => item.id)
158
+ }
159
+ this.clearDropPreviews()
160
+ })
161
+ this.observer.observe(this, {childList: true})
162
+ // this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.orderSheet]
163
+ }
164
+
165
+ serializedCallback() {
166
+ this.shuffleItems()
167
+ }
168
+
169
+ disconnectedCallback(): void {
170
+ super.disconnectedCallback()
171
+ this.observer?.disconnect()
172
+ this.observer = undefined
173
+ }
174
+
175
+ orderSheet = new CSSStyleSheet()
176
+
177
+ addItem() {
178
+ const orderItem = this.ownerDocument.createElement("webwriter-order-item")
179
+ const p = this.ownerDocument.createElement("p")
180
+ orderItem.appendChild(p)
181
+ orderItem.setAttribute("layout", this.layout)
182
+ this.append(orderItem)
183
+ this.solution = [...this.#solution, orderItem.id]
184
+ this.ownerDocument.getSelection().setBaseAndExtent(p, 0, p, 0)
185
+ }
186
+
187
+ shuffleItems() {
188
+ const n = this.items.length
189
+ const nums = shuffle([...(new Array(n)).keys()])
190
+ this.innerHTML = nums.map(i => this.children.item(i).outerHTML).join("")
191
+ }
192
+
193
+ clearDropPreviews = () => {
194
+ this.items.forEach(item => item.dropPreview = undefined)
195
+ }
196
+
197
+ @query("#items-slot")
198
+ accessor itemsSlot: HTMLSlotElement
199
+
200
+ @queryAssignedElements()
201
+ accessor items: WebwriterOrderItem[]
202
+
203
+ handleKeyDown(e: KeyboardEvent) {
204
+ if(e.key == "ArrowDown") {
205
+ e.stopPropagation()
206
+ e.preventDefault()
207
+ }
208
+ else if(e.key === "ArrowUp") {
209
+ e.stopPropagation()
210
+ e.preventDefault()
211
+ }
212
+ }
213
+
214
+ /*
215
+ If contenteditable: Reorder solution -> Triggers orderSheet change
216
+ If not contenteditable: Reorder value -> Triggers orderSheet change
217
+ */
218
+
219
+ moveChild(elem: HTMLElement, i: number) {
220
+ /*
221
+ let items = this.items.map(el => el !== elem? el: undefined)
222
+ items.splice(i, 0, elem as WebwriterOrderItem)
223
+ items = items.filter(child => child)
224
+ this.replaceChildren(...items)
225
+ this.items.forEach(item => item.requestUpdate())*/
226
+ if(i === 0) {
227
+ this.insertAdjacentElement("afterbegin", elem)
228
+ }
229
+ else if(i < this.items.length) {
230
+ this.items[i].insertAdjacentElement("beforebegin", elem)
231
+ }
232
+ else {
233
+ this.insertAdjacentElement("beforeend", elem)
234
+ }
235
+ }
236
+
237
+ handleMove = (e: CustomEvent) => {
238
+ const elem = e.target as HTMLElement
239
+ const children = Array.from(this.children)
240
+ const pos = children.indexOf(elem)
241
+ let i: number
242
+ if(e.type === "ww-moveup") {
243
+ i = Math.max(0, pos - 1)
244
+ }
245
+ else if(e.type === "ww-movedown") {
246
+ i = Math.min(children.length, pos + 2)
247
+
248
+ }
249
+ else if(e.type === "ww-moveto") {
250
+ i = e.detail.i
251
+ }
252
+ this.moveChild(elem, i)
253
+ }
254
+
255
+
256
+ #solution: string[] = []
257
+
258
+ get solution() {
259
+ return this.#solution?.length? this.#solution: undefined
260
+ }
261
+
262
+ @property({attribute: false})
263
+ set solution(value: string[]) {
264
+ this.#solution = value
265
+ if(value) {
266
+ this.dispatchEvent(new CustomEvent("ww-answer-change", {
267
+ bubbles: true,
268
+ composed: true
269
+ }))
270
+ }
271
+ }
272
+
273
+
274
+ reportSolution() {
275
+ console.log(this.solution, this.items)
276
+ this.solution.forEach((id, i) => (this.querySelector(`#${id}`) as any).validOrder = i)
277
+ if(!this.showSolution){
278
+ this.items.forEach(item => {
279
+ console.log(item.validOrder, this.solution.indexOf(item.id))
280
+ if(this.items.indexOf(item) != this.solution.indexOf(item.id)){
281
+ this.items.forEach(i => {
282
+ i.showSolution = false
283
+ })
284
+ }
285
+ })
286
+ }
287
+ this.items.forEach(item=>{
288
+ item.style.pointerEvents="none"
289
+ })
290
+ }
291
+
292
+ reset() {
293
+ this.solution = undefined
294
+ this.shuffleItems()
295
+ this.items.forEach(item=>{
296
+ item.style.pointerEvents="auto"
297
+ })
298
+ }
299
+
300
+ protected firstUpdated(_changedProperties: PropertyValues): void {
301
+ this.showSolution = this.showSolution
302
+ }
303
+
304
+ render() {
305
+ return html`
306
+ <slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
307
+ <sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
308
+ <sl-icon src=${IconPlus}></sl-icon><span>${msg("Add Option")}</span>
309
+ </sl-button>
310
+ `
311
+ }
285
312
  }