@webwriter/quiz 1.0.2 → 1.0.4
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.
- package/LICENSE +6 -6
- package/custom.d.ts +175 -175
- package/dist/widgets/webwriter-choice-item.js +3257 -59
- package/dist/widgets/webwriter-choice.js +4941 -79
- package/dist/widgets/webwriter-cloze-gap.js +4092 -179
- package/dist/widgets/webwriter-cloze.js +2415 -36
- package/dist/widgets/webwriter-mark.js +2471 -61
- package/dist/widgets/webwriter-order-item.js +2447 -68
- package/dist/widgets/webwriter-order.js +4990 -135
- package/dist/widgets/webwriter-pairing-item.js +1581 -48
- package/dist/widgets/webwriter-pairing.js +3686 -72
- package/dist/widgets/webwriter-quiz.js +6938 -76
- package/dist/widgets/webwriter-speech.js +6265 -76
- package/dist/widgets/webwriter-task-explainer.js +1564 -31
- package/dist/widgets/webwriter-task-hint.js +1523 -28
- package/dist/widgets/webwriter-task-prompt.js +1586 -29
- package/dist/widgets/webwriter-task.js +7132 -101
- package/dist/widgets/webwriter-text.js +4044 -54
- package/package.json +200 -200
- package/src/lib/combobox.ts +455 -455
- package/src/snippets/choice.html +7 -7
- package/src/snippets/cloze.html +3 -3
- package/src/snippets/mark.html +3 -3
- package/src/snippets/order.html +7 -7
- package/src/snippets/pairing.html +9 -9
- package/src/snippets/speech.html +3 -3
- package/src/snippets/text.html +3 -3
- package/src/snippets/wordsearch.html +3 -3
- package/src/widgets/webwriter-choice-item.ts +250 -250
- package/src/widgets/webwriter-choice.ts +309 -309
- package/src/widgets/webwriter-cloze-gap.ts +216 -216
- package/src/widgets/webwriter-cloze.ts +135 -135
- package/src/widgets/webwriter-mark.ts +434 -434
- package/src/widgets/webwriter-order-item.ts +444 -444
- package/src/widgets/webwriter-order.ts +272 -272
- package/src/widgets/webwriter-pairing-item.ts +155 -155
- package/src/widgets/webwriter-pairing.ts +187 -187
- package/src/widgets/webwriter-quiz.ts +280 -280
- package/src/widgets/webwriter-speech.ts +267 -267
- package/src/widgets/webwriter-task-explainer.ts +37 -37
- package/src/widgets/webwriter-task-hint.ts +16 -16
- package/src/widgets/webwriter-task-prompt.ts +17 -17
- package/src/widgets/webwriter-task.ts +543 -543
- package/src/widgets/webwriter-text.ts +130 -130
- package/tsconfig.json +6 -6
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import {html, css} 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
|
-
declare global {interface HTMLElementTagNameMap {
|
|
11
|
-
"webwriter-text": WebwriterText;
|
|
12
|
-
}}
|
|
13
|
-
|
|
14
|
-
@customElement("webwriter-text")
|
|
15
|
-
export class WebwriterText extends LitElementWw {
|
|
16
|
-
|
|
17
|
-
@property({type: String, attribute: true, reflect: true})
|
|
18
|
-
@option({
|
|
19
|
-
type: "select",
|
|
20
|
-
label: {"en": "Type", "de": "Typ"},
|
|
21
|
-
options: [
|
|
22
|
-
{value: "long-text", label: {"en": "Long Text", "de": "Langer Text"}},
|
|
23
|
-
{value: "text", label: {"en": "Short Text", "de": "Kurzer Text"}},
|
|
24
|
-
{value: "number", label: {"en": "Number", "de": "Zahl"}},
|
|
25
|
-
{value: "date", label: {"en": "Date", "de": "Datum"}},
|
|
26
|
-
{value: "time", label: {"en": "Time", "de": "Uhrzeit"}},
|
|
27
|
-
{value: "datetime-local", label: {"en": "Date & Time", "de": "Datum & Uhrzeit"}}
|
|
28
|
-
]
|
|
29
|
-
})
|
|
30
|
-
accessor type: "date" | "datetime-local" | "number" | "text" | "time" | "long-text" = "long-text"
|
|
31
|
-
|
|
32
|
-
@property({type: String, attribute: true, reflect: true})
|
|
33
|
-
@option()
|
|
34
|
-
accessor placeholder: string
|
|
35
|
-
|
|
36
|
-
@property({type: String, attribute: true, reflect: true})
|
|
37
|
-
accessor value: string
|
|
38
|
-
|
|
39
|
-
/*
|
|
40
|
-
@property({type: Number, attribute: true, reflect: true})
|
|
41
|
-
@option({type: Number})
|
|
42
|
-
min: number
|
|
43
|
-
|
|
44
|
-
@property({type: Number, attribute: true, reflect: true})
|
|
45
|
-
@option({type: Number})
|
|
46
|
-
max: number
|
|
47
|
-
|
|
48
|
-
@property({type: Number, attribute: true, reflect: true})
|
|
49
|
-
@option({type: Number})
|
|
50
|
-
step: number
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
static scopedElements = {
|
|
54
|
-
"sl-textarea": SlTextarea,
|
|
55
|
-
"sl-input": SlInput
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static styles = css`
|
|
59
|
-
:host(:is([contenteditable=true], [contenteditable=""])) sl-textarea::part(textarea) {
|
|
60
|
-
color: var(--sl-color-success-700);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
sl-textarea {
|
|
64
|
-
resize: vertical;
|
|
65
|
-
overflow: hidden;
|
|
66
|
-
min-height: 40px;
|
|
67
|
-
|
|
68
|
-
&::part(form-control), &::part(form-control-input), &::part(base), &::part(textarea) {
|
|
69
|
-
height: 100%;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:is(sl-textarea, sl-input)[data-correct]::part(base) {
|
|
74
|
-
background: var(--sl-color-success-200);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#solution {
|
|
78
|
-
padding: 1rem;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
#solution[data-correct] {
|
|
82
|
-
background: var(--sl-color-success-200);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
#solution:not([data-correct]) {
|
|
86
|
-
background: var(--sl-color-danger-200);
|
|
87
|
-
}
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
handleChange = (e: CustomEvent) => {
|
|
91
|
-
const target = e.target as SlTextarea | SlInput
|
|
92
|
-
if(this.isContentEditable) {
|
|
93
|
-
this.solution = target.value?.trim()
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this.value = target.value?.trim()
|
|
97
|
-
}
|
|
98
|
-
this.dispatchEvent(new CustomEvent("ww-answer-change", {
|
|
99
|
-
detail: {value: target.value},
|
|
100
|
-
bubbles: true,
|
|
101
|
-
composed: true
|
|
102
|
-
}))
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@query("sl-textarea, sl-input")
|
|
106
|
-
accessor input: SlTextarea | SlInput
|
|
107
|
-
|
|
108
|
-
focus() {
|
|
109
|
-
this.input.focus()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
reset() {
|
|
113
|
-
this.solution = undefined
|
|
114
|
-
this.input.value = ""
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
reportSolution() {}
|
|
118
|
-
|
|
119
|
-
@property({type: String, attribute: false, reflect: false})
|
|
120
|
-
accessor solution: string
|
|
121
|
-
|
|
122
|
-
render() {
|
|
123
|
-
const correct = this.solution && this.value?.trim() === this.solution
|
|
124
|
-
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>`
|
|
125
|
-
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>`
|
|
126
|
-
return html`
|
|
127
|
-
${this.type === "long-text"? textarea: input}
|
|
128
|
-
${this.solution && !this.isContentEditable && !correct? html`<div id="solution" ?data-correct=${correct}>${this.solution}</div>`: undefined}
|
|
129
|
-
`
|
|
130
|
-
}
|
|
1
|
+
import {html, css} 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
|
+
declare global {interface HTMLElementTagNameMap {
|
|
11
|
+
"webwriter-text": WebwriterText;
|
|
12
|
+
}}
|
|
13
|
+
|
|
14
|
+
@customElement("webwriter-text")
|
|
15
|
+
export class WebwriterText extends LitElementWw {
|
|
16
|
+
|
|
17
|
+
@property({type: String, attribute: true, reflect: true})
|
|
18
|
+
@option({
|
|
19
|
+
type: "select",
|
|
20
|
+
label: {"en": "Type", "de": "Typ"},
|
|
21
|
+
options: [
|
|
22
|
+
{value: "long-text", label: {"en": "Long Text", "de": "Langer Text"}},
|
|
23
|
+
{value: "text", label: {"en": "Short Text", "de": "Kurzer Text"}},
|
|
24
|
+
{value: "number", label: {"en": "Number", "de": "Zahl"}},
|
|
25
|
+
{value: "date", label: {"en": "Date", "de": "Datum"}},
|
|
26
|
+
{value: "time", label: {"en": "Time", "de": "Uhrzeit"}},
|
|
27
|
+
{value: "datetime-local", label: {"en": "Date & Time", "de": "Datum & Uhrzeit"}}
|
|
28
|
+
]
|
|
29
|
+
})
|
|
30
|
+
accessor type: "date" | "datetime-local" | "number" | "text" | "time" | "long-text" = "long-text"
|
|
31
|
+
|
|
32
|
+
@property({type: String, attribute: true, reflect: true})
|
|
33
|
+
@option()
|
|
34
|
+
accessor placeholder: string
|
|
35
|
+
|
|
36
|
+
@property({type: String, attribute: true, reflect: true})
|
|
37
|
+
accessor value: string
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
@property({type: Number, attribute: true, reflect: true})
|
|
41
|
+
@option({type: Number})
|
|
42
|
+
min: number
|
|
43
|
+
|
|
44
|
+
@property({type: Number, attribute: true, reflect: true})
|
|
45
|
+
@option({type: Number})
|
|
46
|
+
max: number
|
|
47
|
+
|
|
48
|
+
@property({type: Number, attribute: true, reflect: true})
|
|
49
|
+
@option({type: Number})
|
|
50
|
+
step: number
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
static scopedElements = {
|
|
54
|
+
"sl-textarea": SlTextarea,
|
|
55
|
+
"sl-input": SlInput
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static styles = css`
|
|
59
|
+
:host(:is([contenteditable=true], [contenteditable=""])) sl-textarea::part(textarea) {
|
|
60
|
+
color: var(--sl-color-success-700);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
sl-textarea {
|
|
64
|
+
resize: vertical;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
min-height: 40px;
|
|
67
|
+
|
|
68
|
+
&::part(form-control), &::part(form-control-input), &::part(base), &::part(textarea) {
|
|
69
|
+
height: 100%;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:is(sl-textarea, sl-input)[data-correct]::part(base) {
|
|
74
|
+
background: var(--sl-color-success-200);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#solution {
|
|
78
|
+
padding: 1rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#solution[data-correct] {
|
|
82
|
+
background: var(--sl-color-success-200);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#solution:not([data-correct]) {
|
|
86
|
+
background: var(--sl-color-danger-200);
|
|
87
|
+
}
|
|
88
|
+
`
|
|
89
|
+
|
|
90
|
+
handleChange = (e: CustomEvent) => {
|
|
91
|
+
const target = e.target as SlTextarea | SlInput
|
|
92
|
+
if(this.isContentEditable) {
|
|
93
|
+
this.solution = target.value?.trim()
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.value = target.value?.trim()
|
|
97
|
+
}
|
|
98
|
+
this.dispatchEvent(new CustomEvent("ww-answer-change", {
|
|
99
|
+
detail: {value: target.value},
|
|
100
|
+
bubbles: true,
|
|
101
|
+
composed: true
|
|
102
|
+
}))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@query("sl-textarea, sl-input")
|
|
106
|
+
accessor input: SlTextarea | SlInput
|
|
107
|
+
|
|
108
|
+
focus() {
|
|
109
|
+
this.input.focus()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
reset() {
|
|
113
|
+
this.solution = undefined
|
|
114
|
+
this.input.value = ""
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
reportSolution() {}
|
|
118
|
+
|
|
119
|
+
@property({type: String, attribute: false, reflect: false})
|
|
120
|
+
accessor solution: string
|
|
121
|
+
|
|
122
|
+
render() {
|
|
123
|
+
const correct = this.solution && this.value?.trim() === this.solution
|
|
124
|
+
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>`
|
|
125
|
+
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>`
|
|
126
|
+
return html`
|
|
127
|
+
${this.type === "long-text"? textarea: input}
|
|
128
|
+
${this.solution && !this.isContentEditable && !correct? html`<div id="solution" ?data-correct=${correct}>${this.solution}</div>`: undefined}
|
|
129
|
+
`
|
|
130
|
+
}
|
|
131
131
|
}
|
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
|
}
|