@webwriter/quiz 1.1.2 → 1.1.5

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 (112) hide show
  1. package/.github/workflows/publish.yml +8 -0
  2. package/LICENSE +6 -6
  3. package/custom.d.ts +175 -175
  4. package/dist/widgets/webwriter-choice-item.js +69 -205
  5. package/dist/widgets/webwriter-choice.js +99 -214
  6. package/dist/widgets/webwriter-cloze-gap.js +74 -213
  7. package/dist/widgets/webwriter-cloze.js +71 -204
  8. package/dist/widgets/webwriter-mark.js +72 -205
  9. package/dist/widgets/webwriter-order-item.js +68 -201
  10. package/dist/widgets/webwriter-order.js +99 -209
  11. package/dist/widgets/webwriter-pairing-item.js +57 -160
  12. package/dist/widgets/webwriter-pairing.js +69 -196
  13. package/dist/widgets/webwriter-quiz.js +72 -211
  14. package/dist/widgets/webwriter-speech.js +71 -204
  15. package/dist/widgets/webwriter-task-explainer.js +57 -160
  16. package/dist/widgets/webwriter-task-hint.js +55 -158
  17. package/dist/widgets/webwriter-task-prompt.js +61 -170
  18. package/dist/widgets/webwriter-task.js +80 -205
  19. package/dist/widgets/webwriter-text.js +94 -205
  20. package/lit-localize.json +14 -14
  21. package/localization/bg.xlf +72 -69
  22. package/localization/cs.xlf +72 -69
  23. package/localization/da.xlf +72 -69
  24. package/localization/de.xlf +77 -74
  25. package/localization/el.xlf +72 -69
  26. package/localization/es.xlf +72 -69
  27. package/localization/et.xlf +72 -69
  28. package/localization/fi.xlf +72 -69
  29. package/localization/fr.xlf +72 -69
  30. package/localization/generated/bg.ts +30 -29
  31. package/localization/generated/cs.ts +30 -29
  32. package/localization/generated/da.ts +30 -29
  33. package/localization/generated/de.ts +30 -29
  34. package/localization/generated/el.ts +30 -29
  35. package/localization/generated/es.ts +30 -29
  36. package/localization/generated/et.ts +30 -29
  37. package/localization/generated/fi.ts +30 -29
  38. package/localization/generated/fr.ts +30 -29
  39. package/localization/generated/hu.ts +30 -29
  40. package/localization/generated/id.ts +30 -29
  41. package/localization/generated/index.js +2 -2
  42. package/localization/generated/it.ts +30 -29
  43. package/localization/generated/ja.ts +30 -29
  44. package/localization/generated/ko.ts +30 -29
  45. package/localization/generated/locale-codes.js +79 -79
  46. package/localization/generated/lt.ts +30 -29
  47. package/localization/generated/lv.ts +30 -29
  48. package/localization/generated/nb.ts +30 -29
  49. package/localization/generated/nl.ts +30 -29
  50. package/localization/generated/pl.ts +30 -29
  51. package/localization/generated/pt-BR.ts +30 -29
  52. package/localization/generated/pt-PT.ts +30 -29
  53. package/localization/generated/ro.ts +30 -29
  54. package/localization/generated/ru.ts +30 -29
  55. package/localization/generated/sk.ts +30 -29
  56. package/localization/generated/sl.ts +30 -29
  57. package/localization/generated/sv.ts +30 -29
  58. package/localization/generated/tr.ts +30 -29
  59. package/localization/generated/uk.ts +30 -29
  60. package/localization/generated/zh-hans.ts +30 -29
  61. package/localization/hu.xlf +72 -69
  62. package/localization/id.xlf +72 -69
  63. package/localization/it.xlf +72 -69
  64. package/localization/ja.xlf +72 -69
  65. package/localization/ko.xlf +72 -69
  66. package/localization/lt.xlf +72 -69
  67. package/localization/lv.xlf +72 -69
  68. package/localization/nb.xlf +72 -69
  69. package/localization/nl.xlf +72 -69
  70. package/localization/pl.xlf +72 -69
  71. package/localization/pt-BR.xlf +72 -69
  72. package/localization/pt-PT.xlf +72 -69
  73. package/localization/ro.xlf +72 -69
  74. package/localization/ru.xlf +72 -69
  75. package/localization/sk.xlf +72 -69
  76. package/localization/sl.xlf +72 -69
  77. package/localization/sv.xlf +72 -69
  78. package/localization/tr.xlf +72 -69
  79. package/localization/uk.xlf +72 -69
  80. package/localization/zh-hans.xlf +72 -69
  81. package/package.json +4 -3
  82. package/src/lib/combobox.ts +455 -455
  83. package/src/lib/highlighter-fill.svg +5 -5
  84. package/src/snippets/Beispiel-Choice.html +57 -57
  85. package/src/snippets/Beispiel-Mark.html +13 -13
  86. package/src/snippets/Beispiel-Order.html +52 -52
  87. package/src/snippets/Beispiel-Text.html +20 -20
  88. package/src/snippets/choice.html +7 -7
  89. package/src/snippets/cloze.html +3 -3
  90. package/src/snippets/mark.html +3 -3
  91. package/src/snippets/order.html +7 -7
  92. package/src/snippets/pairing.html +9 -9
  93. package/src/snippets/speech.html +3 -3
  94. package/src/snippets/text.html +3 -3
  95. package/src/snippets/wordsearch.html +3 -3
  96. package/src/widgets/webwriter-choice-item.ts +256 -253
  97. package/src/widgets/webwriter-choice.ts +352 -336
  98. package/src/widgets/webwriter-cloze-gap.ts +215 -215
  99. package/src/widgets/webwriter-cloze.ts +135 -135
  100. package/src/widgets/webwriter-mark.ts +431 -431
  101. package/src/widgets/webwriter-order-item.ts +440 -440
  102. package/src/widgets/webwriter-order.ts +326 -309
  103. package/src/widgets/webwriter-pairing-item.ts +160 -160
  104. package/src/widgets/webwriter-pairing.ts +192 -192
  105. package/src/widgets/webwriter-quiz.ts +281 -281
  106. package/src/widgets/webwriter-speech.ts +272 -272
  107. package/src/widgets/webwriter-task-explainer.ts +42 -42
  108. package/src/widgets/webwriter-task-hint.ts +22 -22
  109. package/src/widgets/webwriter-task-prompt.ts +23 -23
  110. package/src/widgets/webwriter-task.ts +554 -546
  111. package/src/widgets/webwriter-text.ts +176 -155
  112. package/tsconfig.json +6 -6
@@ -1,156 +1,177 @@
1
- import {html, css, PropertyValues} from "lit"
2
- import {LitElementWw, option} from "@webwriter/lit"
3
- import {customElement, property, query} from "lit/decorators.js"
4
- import {ifDefined} from "lit/directives/if-defined.js"
5
-
6
- import SlTextarea from "@shoelace-style/shoelace/dist/components/textarea/textarea.component.js"
7
- import SlInput from "@shoelace-style/shoelace/dist/components/input/input.component.js"
8
- import "@shoelace-style/shoelace/dist/themes/light.css"
9
-
10
- import LOCALIZE from "../../localization/generated"
11
- import {msg} from "@lit/localize"
12
-
13
- declare global {interface HTMLElementTagNameMap {
14
- "webwriter-text": WebwriterText;
15
- }}
16
-
17
- @customElement("webwriter-text")
18
- export class WebwriterText extends LitElementWw {
19
-
20
- localize = LOCALIZE
21
-
22
- @property({type: String, attribute: true, reflect: true})
23
- @option({
24
- type: "select",
25
- label: {"en": "Type", "de": "Typ"},
26
- options: [
27
- {value: "long-text", label: {"en": "Long Text", "de": "Langer Text"}},
28
- {value: "text", label: {"en": "Short Text", "de": "Kurzer Text"}},
29
- {value: "number", label: {"en": "Number", "de": "Zahl"}},
30
- {value: "date", label: {"en": "Date", "de": "Datum"}},
31
- {value: "time", label: {"en": "Time", "de": "Uhrzeit"}},
32
- {value: "datetime-local", label: {"en": "Date & Time", "de": "Datum & Uhrzeit"}}
33
- ]
34
- })
35
- accessor type: "date" | "datetime-local" | "number" | "text" | "time" | "long-text" = "long-text"
36
-
37
- @property({type: String, attribute: true, reflect: true})
38
- @option()
39
- accessor placeholder: string
40
-
41
- @property({type: Boolean, attribute: true, reflect: true})
42
- @option({
43
- type: Boolean,
44
- label: {"en": "Ignore capitalization", "de": "Großschreibung ignorieren"},
45
- })
46
- accessor ignoreCase = false
47
-
48
- @property({type: Boolean, attribute: true, reflect: true})
49
- @option({
50
- type: Boolean,
51
- label: {"en": "show Solution", "de": "Lösung anzeigen"},
52
- })
53
- accessor showSolution = false
54
-
55
- @property({type: String, attribute: true, reflect: true})
56
- @option({
57
- label: {"en": "Message for wrong solution", "de": "Nachricht bei falscher Lösung"},
58
- })
59
- accessor wrongMessage: string
60
-
61
- @property({type: String, attribute: true, reflect: true})
62
- accessor value: string
63
-
64
- /*
65
- @property({type: Number, attribute: true, reflect: true})
66
- @option({type: Number})
67
- min: number
68
-
69
- @property({type: Number, attribute: true, reflect: true})
70
- @option({type: Number})
71
- max: number
72
-
73
- @property({type: Number, attribute: true, reflect: true})
74
- @option({type: Number})
75
- step: number
76
- */
77
-
78
- static scopedElements = {
79
- "sl-textarea": SlTextarea,
80
- "sl-input": SlInput
81
- }
82
-
83
- static styles = css`
84
- :host(:is([contenteditable=true], [contenteditable=""])) sl-textarea::part(textarea) {
85
- color: var(--sl-color-success-700);
86
- }
87
-
88
- sl-textarea {
89
- resize: vertical;
90
- overflow: hidden;
91
- min-height: 40px;
92
-
93
- &::part(form-control), &::part(form-control-input), &::part(base), &::part(textarea) {
94
- height: 100%;
95
- }
96
- }
97
-
98
- :is(sl-textarea, sl-input)[data-correct]::part(base) {
99
- background: var(--sl-color-success-200);
100
- }
101
-
102
- #solution {
103
- padding: 1rem;
104
- }
105
-
106
- #solution[data-correct] {
107
- background-color: var(--sl-color-success-200);
108
- }
109
-
110
- #solution:not([data-correct]) {
111
- background-color: var(--sl-color-danger-200);
112
- }
113
- `
114
-
115
- handleChange = (e: CustomEvent) => {
116
- const target = e.target as SlTextarea | SlInput
117
- if(this.isContentEditable) {
118
- this.solution = target.value?.trim()
119
- }
120
- else {
121
- this.value = target.value?.trim()
122
- }
123
- this.dispatchEvent(new CustomEvent("ww-answer-change", {
124
- detail: {value: target.value},
125
- bubbles: true,
126
- composed: true
127
- }))
128
- }
129
-
130
- @query("sl-textarea, sl-input")
131
- accessor input: SlTextarea | SlInput
132
-
133
- focus() {
134
- this.input.focus()
135
- }
136
-
137
- reset() {
138
- this.solution = undefined
139
- this.input.value = ""
140
- }
141
-
142
- reportSolution() {}
143
-
144
- @property({type: String, attribute: false, reflect: false})
145
- accessor solution: string
146
-
147
- render() {
148
- const correct = !this.ignoreCase ? this.solution && this.value?.trim() === this.solution : this.solution && this.value?.trim().toLowerCase() === this.solution.toLowerCase()
149
- const textarea = html`<sl-textarea ?data-correct=${correct} value=${this.isContentEditable? this.solution: this.value} placeholder=${this.placeholder} resize="none" @sl-change=${this.handleChange}></sl-textarea>`
150
- const input = html`<sl-input ?data-correct=${correct} value=${this.isContentEditable? this.solution: this.value} placeholder=${this.placeholder} type=${this.type} @sl-change=${this.handleChange}></sl-input>`
151
- return html`
152
- ${this.type === "long-text"? textarea: input}
153
- ${this.solution && !this.isContentEditable && !correct? html`<div id="solution" ?data-correct=${correct}>${this.showSolution?this.solution:html`<i>${this.wrongMessage}</i>`}</div>`: undefined}
154
- `
155
- }
1
+ import {html, css, PropertyValues, TemplateResult} from "lit"
2
+ import {LitElementWw, option} from "@webwriter/lit"
3
+ import {customElement, property, query} from "lit/decorators.js"
4
+ import {ifDefined} from "lit/directives/if-defined.js"
5
+
6
+ import SlTextarea from "@shoelace-style/shoelace/dist/components/textarea/textarea.component.js"
7
+ import SlInput from "@shoelace-style/shoelace/dist/components/input/input.component.js"
8
+ import "@shoelace-style/shoelace/dist/themes/light.css"
9
+
10
+ import LOCALIZE from "../../localization/generated"
11
+ import {msg} from "@lit/localize"
12
+
13
+ declare global {interface HTMLElementTagNameMap {
14
+ "webwriter-text": WebwriterText;
15
+ }}
16
+
17
+ @customElement("webwriter-text")
18
+ export class WebwriterText extends LitElementWw {
19
+
20
+ localize = LOCALIZE
21
+
22
+ @property({type: String, attribute: true, reflect: true})
23
+ @option({
24
+ type: "select",
25
+ label: {"en": "Type", "de": "Typ"},
26
+ options: [
27
+ {value: "long-text", label: {"en": "Long Text", "de": "Langer Text"}},
28
+ {value: "text", label: {"en": "Short Text", "de": "Kurzer Text"}},
29
+ {value: "number", label: {"en": "Number", "de": "Zahl"}},
30
+ {value: "date", label: {"en": "Date", "de": "Datum"}},
31
+ {value: "time", label: {"en": "Time", "de": "Uhrzeit"}},
32
+ {value: "datetime-local", label: {"en": "Date & Time", "de": "Datum & Uhrzeit"}}
33
+ ]
34
+ })
35
+ accessor type: "date" | "datetime-local" | "number" | "text" | "time" | "long-text" = "long-text"
36
+
37
+ @property({type: String, attribute: true, reflect: true})
38
+ @option()
39
+ accessor placeholder: string
40
+
41
+ @property({type: Boolean, attribute: true, reflect: true})
42
+ @option({
43
+ type: Boolean,
44
+ label: {"en": "free answer (ignores the other options)", "de": "Freitext (ignoriert andere Optionen)"},
45
+ })
46
+ accessor freeText = false
47
+
48
+ @property({type: Boolean, attribute: true, reflect: true})
49
+ @option({
50
+ type: Boolean,
51
+ label: {"en": "Ignore capitalization", "de": "Großschreibung ignorieren"},
52
+ })
53
+ accessor ignoreCase = false
54
+
55
+ @property({type: Boolean, attribute: true, reflect: true})
56
+ @option({
57
+ type: Boolean,
58
+ label: {"en": "show Solution", "de": "Lösung anzeigen"},
59
+ })
60
+ accessor showSolution = false
61
+
62
+ @property({type: String, attribute: true, reflect: true})
63
+ @option({
64
+ label: {"en": "Message for wrong solution", "de": "Nachricht bei falscher Lösung"},
65
+ })
66
+ accessor wrongMessage: string
67
+
68
+ @property({type: String, attribute: true, reflect: true})
69
+ accessor value: string
70
+
71
+ /*
72
+ @property({type: Number, attribute: true, reflect: true})
73
+ @option({type: Number})
74
+ min: number
75
+
76
+ @property({type: Number, attribute: true, reflect: true})
77
+ @option({type: Number})
78
+ max: number
79
+
80
+ @property({type: Number, attribute: true, reflect: true})
81
+ @option({type: Number})
82
+ step: number
83
+ */
84
+
85
+ static scopedElements = {
86
+ "sl-textarea": SlTextarea,
87
+ "sl-input": SlInput
88
+ }
89
+
90
+ static styles = css`
91
+ :host(:is([contenteditable=true], [contenteditable=""])) sl-textarea::part(textarea) {
92
+ color: var(--sl-color-success-700);
93
+ }
94
+
95
+ sl-textarea {
96
+ resize: vertical;
97
+ overflow: hidden;
98
+ min-height: 40px;
99
+
100
+ &::part(form-control), &::part(form-control-input), &::part(base), &::part(textarea) {
101
+ height: 100%;
102
+ }
103
+ }
104
+
105
+ :is(sl-textarea, sl-input)[data-correct]::part(base) {
106
+ background: var(--sl-color-success-200);
107
+ }
108
+
109
+ #solution {
110
+ padding: 1rem;
111
+ }
112
+
113
+ #solution[data-correct] {
114
+ background-color: var(--sl-color-success-200);
115
+ }
116
+
117
+ #solution:not([data-correct]) {
118
+ background-color: var(--sl-color-danger-200);
119
+ }
120
+ `
121
+
122
+ handleChange = (e: CustomEvent) => {
123
+ const target = e.target as SlTextarea | SlInput
124
+ if(this.isContentEditable) {
125
+ this.solution = target.value?.trim()
126
+ }
127
+ else {
128
+ this.value = target.value?.trim()
129
+ }
130
+ this.dispatchEvent(new CustomEvent("ww-answer-change", {
131
+ detail: {value: target.value},
132
+ bubbles: true,
133
+ composed: true
134
+ }))
135
+ }
136
+
137
+ @query("sl-textarea, sl-input")
138
+ accessor input: SlTextarea | SlInput
139
+
140
+ focus() {
141
+ this.input.focus()
142
+ }
143
+
144
+ reset() {
145
+ this.solution = undefined
146
+ if(!this.freeText){
147
+ this.input.value = ""
148
+ }
149
+
150
+
151
+ let inputElem: SlTextarea | SlInput = this.shadowRoot.getElementById("inputElem") as SlTextarea | SlInput
152
+ inputElem.disabled = false
153
+ }
154
+
155
+ reportSolution() {
156
+ let inputElem: SlTextarea | SlInput = this.shadowRoot.getElementById("inputElem") as SlTextarea | SlInput
157
+ inputElem.disabled = true
158
+ }
159
+
160
+ @property({type: String, attribute: false, reflect: false})
161
+ accessor solution: string
162
+
163
+ render() {
164
+ const correct = this.freeText ? this.value?.trim() != "" : !this.ignoreCase ? this.solution && this.value?.trim() ===
165
+ this.solution : this.solution && this.value?.trim().toLowerCase() === this.solution.toLowerCase()
166
+ if(this.freeText && correct){
167
+ this.solution = this.value
168
+ }
169
+ const textarea = html`<sl-textarea id="inputElem" ?data-correct=${correct && !(this.freeText)} value=${this.isContentEditable? this.solution: this.value} placeholder=${this.placeholder} resize="none" @sl-change=${this.handleChange}></sl-textarea>`
170
+ const input = html`<sl-input id="inputElem" ?data-correct=${correct} value=${this.isContentEditable? this.solution: this.value}
171
+ placeholder=${this.placeholder} type=${this.type} @sl-change=${this.handleChange}></sl-input>`
172
+ return html`
173
+ ${this.type === "long-text"? textarea: input}
174
+ ${this.solution && !this.isContentEditable && !correct? html`<div id="solution" ?data-correct=${correct}>${this.showSolution?this.solution:html`<i>${this.wrongMessage}</i>`}</div>`: undefined}
175
+ `
176
+ }
156
177
  }
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "moduleResolution": "Bundler",
5
- "module": "ES2022"
6
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "moduleResolution": "Bundler",
5
+ "module": "ES2022"
6
+ }
7
7
  }