@matinfo/vitepress-plugin-quiz 1.0.6 → 1.1.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.
|
@@ -1,509 +1,641 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
function
|
|
5
|
-
if (typeof document > "u" ||
|
|
6
|
-
const
|
|
7
|
-
if (document.getElementById(
|
|
8
|
-
|
|
1
|
+
import { defineComponent as te, computed as I, ref as M, inject as H, onUnmounted as ie, watch as Z, onMounted as le, openBlock as o, createElementBlock as a, normalizeClass as V, unref as x, createElementVNode as b, Fragment as q, renderList as N, toDisplayString as c, createTextVNode as O, createCommentVNode as P, withKeys as U, withModifiers as G, withDirectives as ue, vModelText as ce, provide as R, normalizeStyle as pe, renderSlot as de } from "vue";
|
|
2
|
+
const ve = ".quiz-progress-bar{position:sticky;top:var(--vp-nav-height, 64px);z-index:20;display:flex;align-items:center;gap:12px;margin:-20px -24px 24px;padding:12px 24px;background:var(--vp-c-bg);border-bottom:1px solid var(--vp-c-divider)}@media(max-width:959px){.quiz-progress-bar{top:calc(var(--vp-nav-height, 64px) - 16px)}}.quiz-progress-track{flex:1;height:8px;background:var(--vp-c-bg-soft);border-radius:4px;overflow:hidden}.quiz-progress-fill{height:100%;background:var(--vp-c-brand-1);border-radius:4px;transition:width .35s ease}.quiz-progress-fill.complete{background:var(--vp-c-green-1, #10b981)}.quiz-progress-label{font-size:13px;color:var(--vp-c-text-2);white-space:nowrap}.quiz-question{border:1px solid var(--vp-c-divider);border-radius:8px;padding:20px 24px;margin-bottom:16px;background:var(--vp-c-bg);transition:border-color .2s}.quiz-question-title{font-weight:600;font-size:15px;margin:0 0 6px;padding:0 5px;color:var(--vp-c-text-1);float:none;width:auto}.quiz-hint{font-size:13px;color:var(--vp-c-text-3);margin:0 0 10px;font-style:italic}.quiz-answers{list-style:none;padding:0;margin:0}.quiz-answer{display:flex;align-items:baseline;gap:10px;padding:8px 12px;margin:4px 0;border:1px solid transparent;border-radius:6px;cursor:pointer;transition:background-color .15s,border-color .15s;user-select:none;font-size:14px;color:var(--vp-c-text-1)}.quiz-answer:hover:not(.correct):not(.wrong):not(.missed){background:var(--vp-c-bg-soft)}.quiz-answer.selected{border-color:var(--vp-c-brand-1);background:var(--vp-c-brand-soft)}.quiz-answer.correct{border-color:var(--vp-c-green-1, #10b981);background:var(--vp-c-green-soft, rgba(16, 185, 129, .12));cursor:default}.quiz-answer.wrong{border-color:var(--vp-c-red-1, #ef4444);background:var(--vp-c-red-soft, rgba(239, 68, 68, .12));cursor:default}.quiz-answer.missed{border-color:var(--vp-c-yellow-1, #f59e0b);background:var(--vp-c-yellow-soft, rgba(245, 158, 11, .1));cursor:default}.validated .quiz-answer{pointer-events:none}.quiz-indicator{flex-shrink:0;width:18px;text-align:center;font-size:15px;line-height:1}.quiz-empty{color:var(--vp-c-text-3)}.quiz-check{color:var(--vp-c-brand-1)}.quiz-answer.correct .quiz-check{color:var(--vp-c-green-1, #10b981)}.quiz-answer.wrong .quiz-check{color:var(--vp-c-red-1, #ef4444)}.quiz-answer-text code{font-family:var(--vp-font-family-mono);font-size:13px;padding:1px 5px;border-radius:4px;background:var(--vp-c-bg-soft);color:var(--vp-c-text-1)}.quiz-explanation{margin-top:12px;padding:10px 14px;border-left:3px solid var(--vp-c-brand-1);background:var(--vp-c-bg-soft);border-radius:0 6px 6px 0;font-size:13px;color:var(--vp-c-text-2)}.quiz-actions{display:flex;flex-wrap:wrap;align-items:center;gap:16px;margin-top:24px;padding-top:20px;border-top:1px solid var(--vp-c-divider)}.quiz-btn{display:inline-flex;align-items:center;justify-content:center;padding:10px 28px;font-size:14px;font-weight:600;border:1px solid transparent;border-radius:8px;cursor:pointer;transition:opacity .2s,background .2s}.quiz-btn:disabled{opacity:.45;cursor:not-allowed}.quiz-btn-validate{background:var(--vp-c-brand-1);color:var(--vp-c-white, #fff)}.quiz-btn-validate:hover:not(:disabled){opacity:.88}.quiz-btn-reset{background:var(--vp-c-bg-soft);border-color:var(--vp-c-divider);color:var(--vp-c-text-1)}.quiz-btn-reset:hover{background:var(--vp-c-bg-mute)}.quiz-score{display:flex;align-items:baseline;gap:8px}.quiz-score-value{font-size:22px;font-weight:700;color:var(--vp-c-brand-1)}.quiz-score-label{font-size:14px;color:var(--vp-c-text-2)}.quiz-input-wrapper{margin-top:8px}.quiz-input{width:100%;max-width:400px;padding:8px 12px;font-size:14px;font-family:var(--vp-font-family-mono);border:1px solid var(--vp-c-divider);border-radius:6px;background:var(--vp-c-bg);color:var(--vp-c-text-1);outline:none;transition:border-color .15s}.quiz-input:focus{border-color:var(--vp-c-brand-1)}.quiz-input:disabled{cursor:not-allowed;opacity:.8}.quiz-input.correct{border-color:var(--vp-c-green-1, #10b981);background:var(--vp-c-green-soft, rgba(16, 185, 129, .12))}.quiz-input.wrong{border-color:var(--vp-c-red-1, #ef4444);background:var(--vp-c-red-soft, rgba(239, 68, 68, .12))}.quiz-expected{margin-top:6px;font-size:13px;color:var(--vp-c-text-2)}.quiz-expected code{font-family:var(--vp-font-family-mono);font-size:13px;padding:1px 5px;border-radius:4px;background:var(--vp-c-bg-soft);color:var(--vp-c-green-1, #10b981)}.quiz-association{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px 16px;align-items:start;margin-top:8px}.quiz-assoc-label{padding-top:8px;font-size:15px;color:var(--vp-c-text-1)}.quiz-assoc-select{width:100%;padding:8px 12px;font-size:14px;border:1px solid var(--vp-c-divider);border-radius:6px;background:var(--vp-c-bg);color:var(--vp-c-text-1);outline:none;transition:border-color .15s}.quiz-assoc-select:focus{border-color:var(--vp-c-brand-1)}.quiz-assoc-select:disabled{cursor:not-allowed;opacity:.8}.quiz-assoc-select.correct{border-color:var(--vp-c-green-1, #10b981);background:var(--vp-c-green-soft, rgba(16, 185, 129, .12))}.quiz-assoc-select.wrong{border-color:var(--vp-c-red-1, #ef4444);background:var(--vp-c-red-soft, rgba(239, 68, 68, .12))}@media(max-width:640px){.quiz-association{grid-template-columns:minmax(0,1fr);gap:4px}.quiz-assoc-label{padding-top:8px}.quiz-assoc-cell{margin-bottom:8px}}";
|
|
3
|
+
let W = !1;
|
|
4
|
+
function fe() {
|
|
5
|
+
if (typeof document > "u" || W) return;
|
|
6
|
+
const t = "vitepress-plugin-quiz-styles";
|
|
7
|
+
if (document.getElementById(t)) {
|
|
8
|
+
W = !0;
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const i = document.createElement("style");
|
|
12
|
+
i.id = t, i.textContent = ve, document.head.appendChild(i), W = !0;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const ge = /^:::quiz\s*$/, he = /^:::\s*$/, xe = /^([A-Za-z-]+):(.*)$/, be = /* @__PURE__ */ new Set([
|
|
15
15
|
"question",
|
|
16
16
|
"answer",
|
|
17
17
|
"answer-correct",
|
|
18
18
|
"answer-input",
|
|
19
|
+
"pair",
|
|
20
|
+
"distractor",
|
|
19
21
|
"explanation",
|
|
20
22
|
"explication",
|
|
21
23
|
"shuffle"
|
|
22
24
|
]);
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
|
|
25
|
+
function xt(t) {
|
|
26
|
+
const i = t.utils.escapeHtml;
|
|
27
|
+
t.block.ruler.before(
|
|
26
28
|
"fence",
|
|
27
29
|
"quiz",
|
|
28
|
-
(
|
|
30
|
+
(n, v, u, _) => ze(n, v, u, _, i),
|
|
29
31
|
{ alt: ["paragraph", "reference", "blockquote", "list"] }
|
|
30
|
-
),
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
`,
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
`,
|
|
32
|
+
), t.renderer.rules.quiz = (n, v) => n[v].content, t.core.ruler.push("quiz_page_wrap", (n) => {
|
|
33
|
+
if (!n.tokens.some((y) => y.type === "quiz")) return;
|
|
34
|
+
const u = new n.Token("html_block", "", 0);
|
|
35
|
+
u.content = `<QuizPage>
|
|
36
|
+
`, u.block = !0;
|
|
37
|
+
const _ = new n.Token("html_block", "", 0);
|
|
38
|
+
_.content = `</QuizPage>
|
|
39
|
+
`, _.block = !0, n.tokens.unshift(u), n.tokens.push(_);
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
if (
|
|
45
|
-
let
|
|
46
|
-
for (;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
|
|
42
|
+
function ze(t, i, n, v, u) {
|
|
43
|
+
if (t.sCount[i] - t.blkIndent >= 4) return !1;
|
|
44
|
+
const _ = t.bMarks[i] + t.tShift[i], y = t.eMarks[i], h = t.src.slice(_, y);
|
|
45
|
+
if (!ge.test(h)) return !1;
|
|
46
|
+
if (v) return !0;
|
|
47
|
+
let p = i + 1, A = !1;
|
|
48
|
+
for (; p < n; ) {
|
|
49
|
+
const g = t.bMarks[p] + t.tShift[p], $ = t.eMarks[p], f = t.src.slice(g, $);
|
|
50
|
+
if (he.test(f)) {
|
|
51
|
+
A = !0;
|
|
50
52
|
break;
|
|
51
53
|
}
|
|
52
|
-
|
|
54
|
+
p++;
|
|
53
55
|
}
|
|
54
|
-
if (!
|
|
55
|
-
const
|
|
56
|
-
for (let
|
|
57
|
-
const
|
|
58
|
-
|
|
56
|
+
if (!A) return !1;
|
|
57
|
+
const S = [];
|
|
58
|
+
for (let g = i + 1; g < p; g++) {
|
|
59
|
+
const $ = t.bMarks[g] + t.tShift[g], f = t.eMarks[g];
|
|
60
|
+
S.push(t.src.slice($, f));
|
|
59
61
|
}
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
`[vitepress-plugin-quiz] :quiz block at line ${
|
|
63
|
-
), !
|
|
62
|
+
const z = we(S);
|
|
63
|
+
if (z?.type === "choice" && !z.answers.some((g) => g.correct) && console.warn(
|
|
64
|
+
`[vitepress-plugin-quiz] :quiz block at line ${i + 1} has no 'answer-correct:'; it can never be answered correctly.`
|
|
65
|
+
), !z)
|
|
64
66
|
return console.warn(
|
|
65
|
-
`[vitepress-plugin-quiz] Ignored invalid :::quiz block at line ${
|
|
67
|
+
`[vitepress-plugin-quiz] Ignored invalid :::quiz block at line ${i + 1}: needs a 'question:' and at least one 'answer:'/'answer-correct:', 'answer-input:', or two 'pair: A => B' lines.`
|
|
66
68
|
), !1;
|
|
67
|
-
const
|
|
68
|
-
return
|
|
69
|
+
const w = t.push("quiz", "", 0);
|
|
70
|
+
return w.content = qe(z, u), w.map = [i, p + 1], w.block = !0, t.line = p + 1, !0;
|
|
69
71
|
}
|
|
70
|
-
function
|
|
71
|
-
let
|
|
72
|
-
const
|
|
73
|
-
let
|
|
74
|
-
const
|
|
75
|
-
let
|
|
76
|
-
for (const
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
|
|
72
|
+
function we(t) {
|
|
73
|
+
let i = "";
|
|
74
|
+
const n = [];
|
|
75
|
+
let v = "";
|
|
76
|
+
const u = [], _ = [], y = [];
|
|
77
|
+
let h = !1, p = null;
|
|
78
|
+
for (const A of t) {
|
|
79
|
+
const S = A.trim();
|
|
80
|
+
if (!S) continue;
|
|
81
|
+
const z = xe.exec(S), w = z?.[1].toLowerCase();
|
|
82
|
+
if (!z || !w || !be.has(w)) {
|
|
83
|
+
p?.(S);
|
|
82
84
|
continue;
|
|
83
85
|
}
|
|
84
|
-
const g =
|
|
85
|
-
switch (
|
|
86
|
+
const g = z[2].trim(), $ = (f, C) => f ? `${f} ${C}` : C;
|
|
87
|
+
switch (w) {
|
|
86
88
|
case "question":
|
|
87
|
-
|
|
89
|
+
i = g, p = (f) => i = $(i, f);
|
|
88
90
|
break;
|
|
89
91
|
case "answer-correct":
|
|
90
92
|
case "answer": {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
+
const f = { text: g, correct: w === "answer-correct" };
|
|
94
|
+
n.push(f), p = (C) => f.text = $(f.text, C);
|
|
93
95
|
break;
|
|
94
96
|
}
|
|
95
97
|
case "answer-input":
|
|
96
|
-
g &&
|
|
98
|
+
g && u.push(g), p = null;
|
|
99
|
+
break;
|
|
100
|
+
case "pair": {
|
|
101
|
+
let f = g.indexOf("=>"), C = 2;
|
|
102
|
+
if (f < 0 && (f = g.indexOf("-->"), C = 3), f < 0) {
|
|
103
|
+
console.warn(`[vitepress-plugin-quiz] Ignored 'pair:' without '=>' or '-->': "${g}"`), p = null;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
const l = {
|
|
107
|
+
left: g.slice(0, f).trim(),
|
|
108
|
+
right: g.slice(f + C).trim()
|
|
109
|
+
};
|
|
110
|
+
l.left && l.right && _.push(l), p = null;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case "distractor":
|
|
114
|
+
g && y.push(g), p = null;
|
|
97
115
|
break;
|
|
98
116
|
case "explanation":
|
|
99
117
|
case "explication":
|
|
100
|
-
|
|
118
|
+
v = g, p = (f) => v = $(v, f);
|
|
101
119
|
break;
|
|
102
120
|
case "shuffle":
|
|
103
|
-
|
|
121
|
+
h = g.toLowerCase() === "true", p = null;
|
|
104
122
|
break;
|
|
105
123
|
}
|
|
106
124
|
}
|
|
107
|
-
|
|
125
|
+
if (!i) return null;
|
|
126
|
+
if (u.length > 0)
|
|
127
|
+
return {
|
|
128
|
+
question: i,
|
|
129
|
+
type: "input",
|
|
130
|
+
answers: [],
|
|
131
|
+
expected: u,
|
|
132
|
+
pairs: [],
|
|
133
|
+
options: [],
|
|
134
|
+
explanation: v,
|
|
135
|
+
shuffle: !1
|
|
136
|
+
};
|
|
137
|
+
if (_.length >= 2) {
|
|
138
|
+
const A = [.../* @__PURE__ */ new Set([..._.map((S) => S.right), ...y])];
|
|
139
|
+
return {
|
|
140
|
+
question: i,
|
|
141
|
+
type: "association",
|
|
142
|
+
answers: [],
|
|
143
|
+
expected: [],
|
|
144
|
+
pairs: _,
|
|
145
|
+
options: A,
|
|
146
|
+
explanation: v,
|
|
147
|
+
shuffle: h
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return n.length === 0 ? null : {
|
|
151
|
+
question: i,
|
|
152
|
+
type: "choice",
|
|
153
|
+
answers: n,
|
|
154
|
+
expected: [],
|
|
155
|
+
pairs: [],
|
|
156
|
+
options: [],
|
|
157
|
+
explanation: v,
|
|
158
|
+
shuffle: h
|
|
159
|
+
};
|
|
108
160
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
return `<QuizQuestion data-quiz="${n
|
|
161
|
+
function qe(t, i) {
|
|
162
|
+
const n = JSON.stringify(t);
|
|
163
|
+
return `<QuizQuestion data-quiz="${i(n)}" />
|
|
112
164
|
`;
|
|
113
165
|
}
|
|
114
|
-
const
|
|
166
|
+
const X = {
|
|
115
167
|
en: {
|
|
116
168
|
answered: "answered",
|
|
117
169
|
validate: "Validate",
|
|
118
170
|
reset: "Restart",
|
|
119
|
-
correctAnswers: (
|
|
171
|
+
correctAnswers: (t) => `correct answer${t !== 1 ? "s" : ""}`,
|
|
120
172
|
multipleHint: "Multiple answers possible",
|
|
121
173
|
explanation: "Explanation: ",
|
|
122
174
|
inputHint: "Type your answer",
|
|
123
175
|
inputPlaceholder: "Your answer…",
|
|
124
|
-
expectedAnswer: "Expected answer:"
|
|
176
|
+
expectedAnswer: "Expected answer:",
|
|
177
|
+
associationHint: "Match each item with its answer",
|
|
178
|
+
associationPlaceholder: "Choose…"
|
|
125
179
|
},
|
|
126
180
|
fr: {
|
|
127
181
|
answered: "répondue(s)",
|
|
128
182
|
validate: "Valider",
|
|
129
183
|
reset: "Recommencer",
|
|
130
|
-
correctAnswers: (
|
|
184
|
+
correctAnswers: (t) => `réponse${t > 1 ? "s" : ""} correcte${t > 1 ? "s" : ""}`,
|
|
131
185
|
multipleHint: "Plusieurs réponses possibles",
|
|
132
186
|
explanation: "Explication : ",
|
|
133
187
|
inputHint: "Saisissez votre réponse",
|
|
134
188
|
inputPlaceholder: "Votre réponse…",
|
|
135
|
-
expectedAnswer: "Réponse attendue :"
|
|
189
|
+
expectedAnswer: "Réponse attendue :",
|
|
190
|
+
associationHint: "Associez chaque élément à sa réponse",
|
|
191
|
+
associationPlaceholder: "Choisir…"
|
|
136
192
|
},
|
|
137
193
|
de: {
|
|
138
194
|
answered: "beantwortet",
|
|
139
195
|
validate: "Überprüfen",
|
|
140
196
|
reset: "Neu starten",
|
|
141
|
-
correctAnswers: (
|
|
197
|
+
correctAnswers: (t) => `richtige Antwort${t !== 1 ? "en" : ""}`,
|
|
142
198
|
multipleHint: "Mehrere Antworten möglich",
|
|
143
199
|
explanation: "Erklärung:",
|
|
144
200
|
inputHint: "Geben Sie Ihre Antwort ein",
|
|
145
201
|
inputPlaceholder: "Ihre Antwort…",
|
|
146
|
-
expectedAnswer: "Erwartete Antwort:"
|
|
202
|
+
expectedAnswer: "Erwartete Antwort:",
|
|
203
|
+
associationHint: "Ordnen Sie jedem Element die passende Antwort zu",
|
|
204
|
+
associationPlaceholder: "Auswählen…"
|
|
147
205
|
},
|
|
148
206
|
it: {
|
|
149
207
|
answered: "risposta/e",
|
|
150
208
|
validate: "Verifica",
|
|
151
209
|
reset: "Ricominciare",
|
|
152
|
-
correctAnswers: (
|
|
210
|
+
correctAnswers: (t) => `rispost${t !== 1 ? "e corrette" : "a corretta"}`,
|
|
153
211
|
multipleHint: "Più risposte possibili",
|
|
154
212
|
explanation: "Spiegazione: ",
|
|
155
213
|
inputHint: "Digita la tua risposta",
|
|
156
214
|
inputPlaceholder: "La tua risposta…",
|
|
157
|
-
expectedAnswer: "Risposta attesa:"
|
|
215
|
+
expectedAnswer: "Risposta attesa:",
|
|
216
|
+
associationHint: "Abbina ogni elemento alla risposta corretta",
|
|
217
|
+
associationPlaceholder: "Scegli…"
|
|
158
218
|
},
|
|
159
219
|
es: {
|
|
160
220
|
answered: "respondida(s)",
|
|
161
221
|
validate: "Validar",
|
|
162
222
|
reset: "Reiniciar",
|
|
163
|
-
correctAnswers: (
|
|
223
|
+
correctAnswers: (t) => `respuesta${t !== 1 ? "s correctas" : " correcta"}`,
|
|
164
224
|
multipleHint: "Varias respuestas posibles",
|
|
165
225
|
explanation: "Explicación: ",
|
|
166
226
|
inputHint: "Escribe tu respuesta",
|
|
167
227
|
inputPlaceholder: "Tu respuesta…",
|
|
168
|
-
expectedAnswer: "Respuesta esperada:"
|
|
228
|
+
expectedAnswer: "Respuesta esperada:",
|
|
229
|
+
associationHint: "Asocia cada elemento con su respuesta",
|
|
230
|
+
associationPlaceholder: "Elegir…"
|
|
169
231
|
}
|
|
170
232
|
};
|
|
171
|
-
function
|
|
172
|
-
return
|
|
233
|
+
function me(t = "en") {
|
|
234
|
+
return X[t] ?? X.en;
|
|
173
235
|
}
|
|
174
|
-
function j(
|
|
175
|
-
const
|
|
176
|
-
let
|
|
177
|
-
for (; (
|
|
178
|
-
|
|
179
|
-
return
|
|
236
|
+
function j(t) {
|
|
237
|
+
const i = [], n = /(\*\*(?!\s)(.+?)\*\*)|(\*(?!\s)(.+?)(?<!\s)\*)|(`([^`]+)`)/g;
|
|
238
|
+
let v = 0, u;
|
|
239
|
+
for (; (u = n.exec(t)) !== null; )
|
|
240
|
+
u.index > v && i.push({ type: "text", value: t.slice(v, u.index) }), u[2] ? i.push({ type: "bold", value: u[2] }) : u[4] ? i.push({ type: "italic", value: u[4] }) : u[6] && i.push({ type: "code", value: u[6] }), v = n.lastIndex;
|
|
241
|
+
return v < t.length && i.push({ type: "text", value: t.slice(v) }), i;
|
|
180
242
|
}
|
|
181
|
-
function
|
|
182
|
-
return
|
|
243
|
+
function ee(t) {
|
|
244
|
+
return t.normalize("NFD").replace(/\p{M}/gu, "").trim().replace(/\s+/g, " ").toLowerCase();
|
|
183
245
|
}
|
|
184
|
-
const
|
|
246
|
+
const ye = ["aria-label"], ke = { class: "quiz-question-title" }, _e = { key: 0 }, Se = { key: 1 }, Ae = { key: 2 }, Ie = {
|
|
185
247
|
key: 0,
|
|
186
248
|
class: "quiz-hint"
|
|
187
|
-
},
|
|
249
|
+
}, $e = ["aria-multiselectable"], Ce = ["onClick", "aria-selected", "onKeydown"], Qe = {
|
|
188
250
|
class: "quiz-indicator",
|
|
189
251
|
"aria-hidden": "true"
|
|
190
|
-
},
|
|
252
|
+
}, Pe = {
|
|
191
253
|
key: 0,
|
|
192
254
|
class: "quiz-check"
|
|
193
|
-
},
|
|
255
|
+
}, Me = {
|
|
194
256
|
key: 1,
|
|
195
257
|
class: "quiz-empty"
|
|
196
|
-
},
|
|
258
|
+
}, Ee = {
|
|
197
259
|
key: 0,
|
|
198
260
|
class: "quiz-check"
|
|
199
|
-
},
|
|
261
|
+
}, He = {
|
|
200
262
|
key: 1,
|
|
201
263
|
class: "quiz-empty"
|
|
202
|
-
},
|
|
264
|
+
}, Ne = { class: "quiz-answer-text" }, Oe = { key: 0 }, Re = { key: 1 }, Ve = { key: 2 }, Te = { class: "quiz-hint" }, je = { class: "quiz-association" }, Ke = ["for"], Be = { key: 0 }, Je = { key: 1 }, De = { key: 2 }, Ue = { class: "quiz-assoc-cell" }, We = ["id", "value", "disabled", "onChange"], Ye = { value: "" }, Fe = ["value"], Le = {
|
|
203
265
|
key: 0,
|
|
204
266
|
class: "quiz-expected"
|
|
205
|
-
},
|
|
206
|
-
key:
|
|
267
|
+
}, Ze = { class: "quiz-hint" }, Ge = { class: "quiz-input-wrapper" }, Xe = ["disabled", "placeholder", "aria-label"], et = {
|
|
268
|
+
key: 0,
|
|
269
|
+
class: "quiz-expected"
|
|
270
|
+
}, tt = {
|
|
271
|
+
key: 3,
|
|
207
272
|
class: "quiz-explanation",
|
|
208
273
|
role: "note"
|
|
209
|
-
},
|
|
274
|
+
}, nt = { key: 0 }, rt = { key: 1 }, st = { key: 2 }, ot = /* @__PURE__ */ te({
|
|
210
275
|
__name: "QuizQuestion",
|
|
211
276
|
props: {
|
|
212
277
|
dataQuiz: { type: String, required: !0 }
|
|
213
278
|
},
|
|
214
|
-
setup(
|
|
215
|
-
const
|
|
279
|
+
setup(t) {
|
|
280
|
+
const i = t, n = I(() => {
|
|
216
281
|
try {
|
|
217
|
-
return JSON.parse(
|
|
282
|
+
return JSON.parse(i.dataQuiz);
|
|
218
283
|
} catch {
|
|
219
284
|
return null;
|
|
220
285
|
}
|
|
221
286
|
});
|
|
222
|
-
function
|
|
223
|
-
const
|
|
224
|
-
for (let
|
|
225
|
-
const
|
|
226
|
-
[
|
|
287
|
+
function v(r) {
|
|
288
|
+
const s = [...r];
|
|
289
|
+
for (let e = s.length - 1; e > 0; e--) {
|
|
290
|
+
const d = Math.floor(Math.random() * (e + 1));
|
|
291
|
+
[s[e], s[d]] = [s[d], s[e]];
|
|
292
|
+
}
|
|
293
|
+
return s;
|
|
294
|
+
}
|
|
295
|
+
const u = M([]);
|
|
296
|
+
function _() {
|
|
297
|
+
if (!n.value || n.value.type !== "choice") {
|
|
298
|
+
u.value = [];
|
|
299
|
+
return;
|
|
227
300
|
}
|
|
228
|
-
|
|
301
|
+
const r = n.value.answers.map((s, e) => ({ ...s, originalIndex: e }));
|
|
302
|
+
u.value = n.value.shuffle ? v(r) : r;
|
|
229
303
|
}
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
304
|
+
const y = I(() => n.value ? {
|
|
305
|
+
...n.value,
|
|
306
|
+
answers: u.value
|
|
307
|
+
} : null), h = I(() => n.value?.type === "input"), p = I(() => n.value?.type === "association"), A = I(
|
|
308
|
+
() => y.value && !h.value && !p.value ? y.value.answers.filter((r) => r.correct).length : 0
|
|
309
|
+
), S = I(() => A.value > 1), z = M(/* @__PURE__ */ new Set()), w = M([]), g = M([]);
|
|
310
|
+
function $() {
|
|
311
|
+
const r = n.value;
|
|
312
|
+
if (!r || r.type !== "association") {
|
|
313
|
+
w.value = [], g.value = [];
|
|
234
314
|
return;
|
|
235
315
|
}
|
|
236
|
-
|
|
237
|
-
s
|
|
316
|
+
w.value = r.pairs.map(() => null);
|
|
317
|
+
const s = r.options.map((e, d) => d);
|
|
318
|
+
g.value = r.shuffle ? v(s) : s;
|
|
238
319
|
}
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
), q = _(() => h.value > 1), x = M(/* @__PURE__ */ new Set()), g = M(""), S = C("quiz-register", null), l = C("quiz-validated", M(!1)), I = C("quiz-reset", M(0)), A = C("quiz-locale"), P = C("quiz-question-id", null), f = C("quiz-save-answer", null), b = C("quiz-get-answer", null), $ = P ? P() : null, J = _(() => v.value ? g.value.trim().length > 0 : x.value.size > 0), V = _(() => {
|
|
245
|
-
if (!d.value || !J.value) return !1;
|
|
246
|
-
if (v.value) {
|
|
247
|
-
const i = Y(g.value);
|
|
248
|
-
return r.value.expected.some((t) => i === Y(t));
|
|
320
|
+
const f = M(""), C = H("quiz-register", null), l = H("quiz-validated", M(!1)), k = H("quiz-reset", M(0)), Q = H("quiz-locale"), Y = H("quiz-question-id", null), T = H("quiz-save-answer", null), F = H("quiz-get-answer", null), E = Y ? Y() : null, L = I(() => p.value ? w.value.length > 0 && w.value.every((r) => r !== null) : h.value ? f.value.trim().length > 0 : z.value.size > 0), K = I(() => {
|
|
321
|
+
if (!y.value || !L.value) return !1;
|
|
322
|
+
if (h.value) {
|
|
323
|
+
const s = ee(f.value);
|
|
324
|
+
return n.value.expected.some((e) => s === ee(e));
|
|
249
325
|
}
|
|
250
|
-
|
|
251
|
-
|
|
326
|
+
if (p.value)
|
|
327
|
+
return n.value.pairs.every((s, e) => B(e));
|
|
328
|
+
const r = new Set(
|
|
329
|
+
n.value.answers.map((s, e) => s.correct ? e : -1).filter((s) => s >= 0)
|
|
252
330
|
);
|
|
253
|
-
if (
|
|
254
|
-
for (const
|
|
255
|
-
if (!
|
|
331
|
+
if (z.value.size !== r.size) return !1;
|
|
332
|
+
for (const s of z.value)
|
|
333
|
+
if (!r.has(s)) return !1;
|
|
256
334
|
return !0;
|
|
257
335
|
});
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
336
|
+
function B(r) {
|
|
337
|
+
const s = n.value, e = w.value[r];
|
|
338
|
+
return !s || e === null || e === void 0 ? !1 : s.options[e] === s.pairs[r].right;
|
|
339
|
+
}
|
|
340
|
+
if (C && n.value) {
|
|
341
|
+
const r = C({ answered: L, isCorrect: K });
|
|
342
|
+
ie(r);
|
|
261
343
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}),
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
if (
|
|
269
|
-
|
|
270
|
-
else if (
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
344
|
+
Z(k, () => {
|
|
345
|
+
z.value = /* @__PURE__ */ new Set(), f.value = "", _(), $();
|
|
346
|
+
}), le(() => {
|
|
347
|
+
if (_(), $(), F && E !== null) {
|
|
348
|
+
const r = F(E);
|
|
349
|
+
if (r) {
|
|
350
|
+
if (r.type === "input" && h.value && typeof r.input == "string")
|
|
351
|
+
f.value = r.input;
|
|
352
|
+
else if (r.type === "association" && p.value && Array.isArray(r.chosen)) {
|
|
353
|
+
const s = n.value?.options.length ?? 0;
|
|
354
|
+
w.value = w.value.map((e, d) => {
|
|
355
|
+
const m = r.chosen[d];
|
|
356
|
+
return typeof m == "number" && Number.isInteger(m) && m >= 0 && m < s ? m : null;
|
|
357
|
+
});
|
|
358
|
+
} else if (r.type === "choice" && !p.value && !h.value && Array.isArray(r.selected)) {
|
|
359
|
+
const s = n.value?.answers.length ?? 0;
|
|
360
|
+
z.value = new Set(
|
|
361
|
+
r.selected.filter((e) => Number.isInteger(e) && e >= 0 && e < s)
|
|
274
362
|
);
|
|
275
363
|
}
|
|
276
364
|
}
|
|
277
365
|
}
|
|
278
366
|
});
|
|
279
|
-
function
|
|
367
|
+
function ne(r, s) {
|
|
280
368
|
if (l.value) return;
|
|
281
|
-
const
|
|
282
|
-
|
|
369
|
+
const e = s.target.value, d = [...w.value];
|
|
370
|
+
d[r] = e === "" ? null : Number(e), w.value = d, D();
|
|
283
371
|
}
|
|
284
|
-
|
|
285
|
-
l.value
|
|
372
|
+
function J(r) {
|
|
373
|
+
if (l.value) return;
|
|
374
|
+
const s = new Set(z.value);
|
|
375
|
+
S.value ? s.has(r) ? s.delete(r) : s.add(r) : (s.clear(), s.add(r)), z.value = s, D();
|
|
376
|
+
}
|
|
377
|
+
Z(f, () => {
|
|
378
|
+
l.value || D();
|
|
286
379
|
});
|
|
287
|
-
function
|
|
288
|
-
!
|
|
380
|
+
function D() {
|
|
381
|
+
!T || E === null || (p.value ? T(E, { type: "association", chosen: [...w.value] }) : h.value ? T(E, { type: "input", input: f.value }) : T(E, { type: "choice", selected: [...z.value] }));
|
|
382
|
+
}
|
|
383
|
+
function re(r) {
|
|
384
|
+
const s = z.value.has(r.originalIndex);
|
|
385
|
+
return l.value ? r.correct && s ? "quiz-answer correct" : r.correct && !s ? "quiz-answer missed" : !r.correct && s ? "quiz-answer wrong" : "quiz-answer" : s ? "quiz-answer selected" : "quiz-answer";
|
|
289
386
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
return l.value ? u.correct && i ? "quiz-answer correct" : u.correct && !i ? "quiz-answer missed" : !u.correct && i ? "quiz-answer wrong" : "quiz-answer" : i ? "quiz-answer selected" : "quiz-answer";
|
|
387
|
+
function se(r) {
|
|
388
|
+
return l.value ? B(r) ? "quiz-assoc-select correct" : "quiz-assoc-select wrong" : "quiz-assoc-select";
|
|
293
389
|
}
|
|
294
|
-
const
|
|
295
|
-
return (
|
|
390
|
+
const oe = I(() => l.value ? K.value ? "quiz-input correct" : "quiz-input wrong" : "quiz-input");
|
|
391
|
+
return (r, s) => y.value ? (o(), a("fieldset", {
|
|
296
392
|
key: 0,
|
|
297
|
-
class:
|
|
298
|
-
"aria-label":
|
|
393
|
+
class: V(["quiz-question", { validated: x(l) }]),
|
|
394
|
+
"aria-label": y.value.question
|
|
299
395
|
}, [
|
|
300
|
-
|
|
301
|
-
(
|
|
302
|
-
|
|
303
|
-
|
|
396
|
+
b("legend", ke, [
|
|
397
|
+
(o(!0), a(q, null, N(x(j)(y.value.question), (e, d) => (o(), a(q, { key: d }, [
|
|
398
|
+
e.type === "bold" ? (o(), a("strong", _e, c(e.value), 1)) : e.type === "italic" ? (o(), a("em", Se, c(e.value), 1)) : e.type === "code" ? (o(), a("code", Ae, c(e.value), 1)) : (o(), a(q, { key: 3 }, [
|
|
399
|
+
O(c(e.value), 1)
|
|
304
400
|
], 64))
|
|
305
401
|
], 64))), 128))
|
|
306
402
|
]),
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
403
|
+
!h.value && !p.value ? (o(), a(q, { key: 0 }, [
|
|
404
|
+
S.value ? (o(), a("p", Ie, c(x(Q).multipleHint), 1)) : P("", !0),
|
|
405
|
+
b("ul", {
|
|
310
406
|
class: "quiz-answers",
|
|
311
407
|
role: "listbox",
|
|
312
|
-
"aria-multiselectable":
|
|
408
|
+
"aria-multiselectable": S.value
|
|
313
409
|
}, [
|
|
314
|
-
(
|
|
315
|
-
key:
|
|
316
|
-
class:
|
|
317
|
-
onClick: (
|
|
410
|
+
(o(!0), a(q, null, N(y.value.answers, (e) => (o(), a("li", {
|
|
411
|
+
key: e.originalIndex,
|
|
412
|
+
class: V(re(e)),
|
|
413
|
+
onClick: (d) => J(e.originalIndex),
|
|
318
414
|
role: "option",
|
|
319
|
-
"aria-selected":
|
|
415
|
+
"aria-selected": z.value.has(e.originalIndex),
|
|
320
416
|
tabindex: "0",
|
|
321
417
|
onKeydown: [
|
|
322
|
-
|
|
323
|
-
|
|
418
|
+
U((d) => J(e.originalIndex), ["enter"]),
|
|
419
|
+
U(G((d) => J(e.originalIndex), ["prevent"]), ["space"])
|
|
324
420
|
]
|
|
325
421
|
}, [
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
], 64)) : (
|
|
330
|
-
|
|
422
|
+
b("span", Qe, [
|
|
423
|
+
S.value ? (o(), a(q, { key: 0 }, [
|
|
424
|
+
z.value.has(e.originalIndex) ? (o(), a("span", Pe, "✓")) : (o(), a("span", Me, "☐"))
|
|
425
|
+
], 64)) : (o(), a(q, { key: 1 }, [
|
|
426
|
+
z.value.has(e.originalIndex) ? (o(), a("span", Ee, "●")) : (o(), a("span", He, "○"))
|
|
331
427
|
], 64))
|
|
332
428
|
]),
|
|
333
|
-
|
|
334
|
-
(
|
|
335
|
-
|
|
336
|
-
|
|
429
|
+
b("span", Ne, [
|
|
430
|
+
(o(!0), a(q, null, N(x(j)(e.text), (d, m) => (o(), a(q, { key: m }, [
|
|
431
|
+
d.type === "bold" ? (o(), a("strong", Oe, c(d.value), 1)) : d.type === "italic" ? (o(), a("em", Re, c(d.value), 1)) : d.type === "code" ? (o(), a("code", Ve, c(d.value), 1)) : (o(), a(q, { key: 3 }, [
|
|
432
|
+
O(c(d.value), 1)
|
|
337
433
|
], 64))
|
|
338
434
|
], 64))), 128))
|
|
339
435
|
])
|
|
340
|
-
], 42,
|
|
341
|
-
], 8,
|
|
342
|
-
], 64)),
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"
|
|
348
|
-
|
|
436
|
+
], 42, Ce))), 128))
|
|
437
|
+
], 8, $e)
|
|
438
|
+
], 64)) : P("", !0),
|
|
439
|
+
p.value && n.value ? (o(), a(q, { key: 1 }, [
|
|
440
|
+
b("p", Te, c(x(Q).associationHint), 1),
|
|
441
|
+
b("div", je, [
|
|
442
|
+
(o(!0), a(q, null, N(n.value.pairs, (e, d) => (o(), a(q, { key: d }, [
|
|
443
|
+
b("label", {
|
|
444
|
+
class: "quiz-assoc-label",
|
|
445
|
+
for: `quiz-assoc-${x(E)}-${d}`
|
|
446
|
+
}, [
|
|
447
|
+
(o(!0), a(q, null, N(x(j)(e.left), (m, ae) => (o(), a(q, { key: ae }, [
|
|
448
|
+
m.type === "bold" ? (o(), a("strong", Be, c(m.value), 1)) : m.type === "italic" ? (o(), a("em", Je, c(m.value), 1)) : m.type === "code" ? (o(), a("code", De, c(m.value), 1)) : (o(), a(q, { key: 3 }, [
|
|
449
|
+
O(c(m.value), 1)
|
|
450
|
+
], 64))
|
|
451
|
+
], 64))), 128))
|
|
452
|
+
], 8, Ke),
|
|
453
|
+
b("div", Ue, [
|
|
454
|
+
b("select", {
|
|
455
|
+
id: `quiz-assoc-${x(E)}-${d}`,
|
|
456
|
+
class: V(se(d)),
|
|
457
|
+
value: w.value[d] === null || w.value[d] === void 0 ? "" : String(w.value[d]),
|
|
458
|
+
disabled: x(l),
|
|
459
|
+
onChange: (m) => ne(d, m)
|
|
460
|
+
}, [
|
|
461
|
+
b("option", Ye, c(x(Q).associationPlaceholder), 1),
|
|
462
|
+
(o(!0), a(q, null, N(g.value, (m) => (o(), a("option", {
|
|
463
|
+
key: m,
|
|
464
|
+
value: String(m)
|
|
465
|
+
}, c(n.value.options[m]), 9, Fe))), 128))
|
|
466
|
+
], 42, We),
|
|
467
|
+
x(l) && !B(d) ? (o(), a("p", Le, [
|
|
468
|
+
O(c(x(Q).expectedAnswer) + " ", 1),
|
|
469
|
+
b("code", null, c(e.right), 1)
|
|
470
|
+
])) : P("", !0)
|
|
471
|
+
])
|
|
472
|
+
], 64))), 128))
|
|
473
|
+
])
|
|
474
|
+
], 64)) : P("", !0),
|
|
475
|
+
h.value && !p.value ? (o(), a(q, { key: 2 }, [
|
|
476
|
+
b("p", Ze, c(x(Q).inputHint), 1),
|
|
477
|
+
b("div", Ge, [
|
|
478
|
+
ue(b("input", {
|
|
479
|
+
"onUpdate:modelValue": s[0] || (s[0] = (e) => f.value = e),
|
|
480
|
+
class: V(oe.value),
|
|
349
481
|
type: "text",
|
|
350
|
-
disabled:
|
|
351
|
-
placeholder:
|
|
352
|
-
"aria-label":
|
|
482
|
+
disabled: x(l),
|
|
483
|
+
placeholder: x(Q).inputPlaceholder,
|
|
484
|
+
"aria-label": y.value.question,
|
|
353
485
|
autocomplete: "off",
|
|
354
486
|
spellcheck: "false",
|
|
355
|
-
onKeydown:
|
|
487
|
+
onKeydown: s[1] || (s[1] = U(G(() => {
|
|
356
488
|
}, ["prevent"]), ["enter"]))
|
|
357
|
-
}, null, 42,
|
|
358
|
-
[
|
|
489
|
+
}, null, 42, Xe), [
|
|
490
|
+
[ce, f.value]
|
|
359
491
|
]),
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
])) :
|
|
492
|
+
x(l) && !K.value ? (o(), a("p", et, [
|
|
493
|
+
O(c(x(Q).expectedAnswer) + " ", 1),
|
|
494
|
+
b("code", null, c(n.value?.expected[0]), 1)
|
|
495
|
+
])) : P("", !0)
|
|
364
496
|
])
|
|
365
|
-
], 64)) :
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
(
|
|
369
|
-
|
|
370
|
-
|
|
497
|
+
], 64)) : P("", !0),
|
|
498
|
+
x(l) && y.value.explanation ? (o(), a("div", tt, [
|
|
499
|
+
b("strong", null, c(x(Q).explanation), 1),
|
|
500
|
+
(o(!0), a(q, null, N(x(j)(y.value.explanation), (e, d) => (o(), a(q, { key: d }, [
|
|
501
|
+
e.type === "bold" ? (o(), a("strong", nt, c(e.value), 1)) : e.type === "italic" ? (o(), a("em", rt, c(e.value), 1)) : e.type === "code" ? (o(), a("code", st, c(e.value), 1)) : (o(), a(q, { key: 3 }, [
|
|
502
|
+
O(c(e.value), 1)
|
|
371
503
|
], 64))
|
|
372
504
|
], 64))), 128))
|
|
373
|
-
])) :
|
|
374
|
-
], 10,
|
|
505
|
+
])) : P("", !0)
|
|
506
|
+
], 10, ye)) : P("", !0);
|
|
375
507
|
}
|
|
376
|
-
}),
|
|
508
|
+
}), at = {
|
|
377
509
|
class: "quiz-page",
|
|
378
510
|
role: "region",
|
|
379
511
|
"aria-label": "Quiz"
|
|
380
|
-
},
|
|
512
|
+
}, it = ["aria-valuenow", "aria-valuemax", "aria-label"], lt = { class: "quiz-progress-track" }, ut = {
|
|
381
513
|
class: "quiz-progress-label",
|
|
382
514
|
"aria-live": "polite"
|
|
383
|
-
},
|
|
515
|
+
}, ct = { class: "quiz-actions" }, pt = ["disabled"], dt = ["aria-label"], vt = { class: "quiz-score-value" }, ft = { class: "quiz-score-label" }, gt = /* @__PURE__ */ te({
|
|
384
516
|
__name: "QuizPage",
|
|
385
|
-
setup(
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
let
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
})),
|
|
393
|
-
if (
|
|
517
|
+
setup(t) {
|
|
518
|
+
const i = H("quiz-locale"), n = M([]), v = M(!1), u = typeof window < "u" ? "quiz-state:" + window.location.pathname : "";
|
|
519
|
+
f();
|
|
520
|
+
let _ = 0;
|
|
521
|
+
R("quiz-validated", v), R("quiz-register", (l) => (n.value.push(l), () => {
|
|
522
|
+
const k = n.value.indexOf(l);
|
|
523
|
+
k >= 0 && n.value.splice(k, 1);
|
|
524
|
+
})), R("quiz-question-id", () => _++), R("quiz-save-answer", (l, k) => {
|
|
525
|
+
if (u)
|
|
394
526
|
try {
|
|
395
|
-
sessionStorage.setItem(
|
|
527
|
+
sessionStorage.setItem(u + ":q" + l, JSON.stringify(k));
|
|
396
528
|
} catch {
|
|
397
529
|
}
|
|
398
|
-
}),
|
|
399
|
-
if (!
|
|
530
|
+
}), R("quiz-get-answer", (l) => {
|
|
531
|
+
if (!u) return null;
|
|
400
532
|
try {
|
|
401
|
-
const
|
|
402
|
-
return
|
|
533
|
+
const k = sessionStorage.getItem(u + ":q" + l);
|
|
534
|
+
return k ? JSON.parse(k) : null;
|
|
403
535
|
} catch {
|
|
404
536
|
return null;
|
|
405
537
|
}
|
|
406
538
|
});
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
() =>
|
|
411
|
-
),
|
|
412
|
-
() =>
|
|
413
|
-
),
|
|
414
|
-
() =>
|
|
415
|
-
),
|
|
416
|
-
() =>
|
|
539
|
+
const y = M(0);
|
|
540
|
+
R("quiz-reset", y);
|
|
541
|
+
const h = I(() => n.value.length), p = I(
|
|
542
|
+
() => n.value.filter((l) => l.answered).length
|
|
543
|
+
), A = I(
|
|
544
|
+
() => n.value.filter((l) => l.isCorrect).length
|
|
545
|
+
), S = I(
|
|
546
|
+
() => h.value > 0 && p.value === h.value
|
|
547
|
+
), z = I(
|
|
548
|
+
() => h.value ? Math.round(p.value / h.value * 100) : 0
|
|
417
549
|
);
|
|
418
|
-
function
|
|
419
|
-
|
|
550
|
+
function w() {
|
|
551
|
+
v.value = !0, $();
|
|
420
552
|
}
|
|
421
|
-
function
|
|
422
|
-
|
|
553
|
+
function g() {
|
|
554
|
+
v.value = !1, y.value++, C();
|
|
423
555
|
}
|
|
424
|
-
function
|
|
425
|
-
if (
|
|
556
|
+
function $() {
|
|
557
|
+
if (u)
|
|
426
558
|
try {
|
|
427
|
-
const
|
|
428
|
-
sessionStorage.setItem(
|
|
559
|
+
const l = { validated: v.value, ts: Date.now() };
|
|
560
|
+
sessionStorage.setItem(u, JSON.stringify(l));
|
|
429
561
|
} catch {
|
|
430
562
|
}
|
|
431
563
|
}
|
|
432
|
-
function
|
|
433
|
-
if (
|
|
564
|
+
function f() {
|
|
565
|
+
if (u)
|
|
434
566
|
try {
|
|
435
|
-
const
|
|
436
|
-
if (!
|
|
437
|
-
const
|
|
438
|
-
|
|
567
|
+
const l = sessionStorage.getItem(u);
|
|
568
|
+
if (!l) return;
|
|
569
|
+
const k = JSON.parse(l);
|
|
570
|
+
k && k.validated && (v.value = !0);
|
|
439
571
|
} catch {
|
|
440
572
|
}
|
|
441
573
|
}
|
|
442
|
-
function
|
|
443
|
-
if (
|
|
574
|
+
function C() {
|
|
575
|
+
if (u)
|
|
444
576
|
try {
|
|
445
|
-
const
|
|
446
|
-
for (let
|
|
447
|
-
const
|
|
448
|
-
|
|
577
|
+
const l = [];
|
|
578
|
+
for (let k = 0; k < sessionStorage.length; k++) {
|
|
579
|
+
const Q = sessionStorage.key(k);
|
|
580
|
+
Q && Q.startsWith(u) && l.push(Q);
|
|
449
581
|
}
|
|
450
|
-
|
|
582
|
+
l.forEach((k) => sessionStorage.removeItem(k));
|
|
451
583
|
} catch {
|
|
452
584
|
}
|
|
453
585
|
}
|
|
454
|
-
return (
|
|
455
|
-
|
|
586
|
+
return (l, k) => (o(), a("div", at, [
|
|
587
|
+
b("div", {
|
|
456
588
|
class: "quiz-progress-bar",
|
|
457
589
|
role: "progressbar",
|
|
458
|
-
"aria-valuenow":
|
|
590
|
+
"aria-valuenow": p.value,
|
|
459
591
|
"aria-valuemin": 0,
|
|
460
|
-
"aria-valuemax":
|
|
461
|
-
"aria-label":
|
|
592
|
+
"aria-valuemax": h.value,
|
|
593
|
+
"aria-label": p.value + " / " + h.value + " " + x(i).answered
|
|
462
594
|
}, [
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
class:
|
|
466
|
-
style:
|
|
595
|
+
b("div", lt, [
|
|
596
|
+
b("div", {
|
|
597
|
+
class: V(["quiz-progress-fill", { complete: z.value === 100 }]),
|
|
598
|
+
style: pe({ width: z.value + "%" })
|
|
467
599
|
}, null, 6)
|
|
468
600
|
]),
|
|
469
|
-
|
|
470
|
-
], 8,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
601
|
+
b("span", ut, c(p.value) + " / " + c(h.value) + " " + c(x(i).answered), 1)
|
|
602
|
+
], 8, it),
|
|
603
|
+
de(l.$slots, "default"),
|
|
604
|
+
b("div", ct, [
|
|
605
|
+
v.value ? P("", !0) : (o(), a("button", {
|
|
474
606
|
key: 0,
|
|
475
607
|
class: "quiz-btn quiz-btn-validate",
|
|
476
|
-
disabled: !
|
|
477
|
-
onClick:
|
|
478
|
-
},
|
|
479
|
-
|
|
480
|
-
|
|
608
|
+
disabled: !S.value,
|
|
609
|
+
onClick: w
|
|
610
|
+
}, c(x(i).validate), 9, pt)),
|
|
611
|
+
v.value ? (o(), a(q, { key: 1 }, [
|
|
612
|
+
b("div", {
|
|
481
613
|
class: "quiz-score",
|
|
482
614
|
role: "status",
|
|
483
615
|
"aria-live": "polite",
|
|
484
|
-
"aria-label":
|
|
616
|
+
"aria-label": A.value + " / " + h.value + " " + x(i).correctAnswers(A.value)
|
|
485
617
|
}, [
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
], 8,
|
|
489
|
-
|
|
618
|
+
b("span", vt, c(A.value) + " / " + c(h.value), 1),
|
|
619
|
+
b("span", ft, c(x(i).correctAnswers(A.value)) + " (" + c(h.value ? Math.round(A.value / h.value * 100) : 0) + "%) ", 1)
|
|
620
|
+
], 8, dt),
|
|
621
|
+
b("button", {
|
|
490
622
|
class: "quiz-btn quiz-btn-reset",
|
|
491
|
-
onClick:
|
|
492
|
-
},
|
|
493
|
-
], 64)) :
|
|
623
|
+
onClick: g
|
|
624
|
+
}, c(x(i).reset), 1)
|
|
625
|
+
], 64)) : P("", !0)
|
|
494
626
|
])
|
|
495
627
|
]));
|
|
496
628
|
}
|
|
497
629
|
});
|
|
498
|
-
function
|
|
499
|
-
|
|
630
|
+
function bt(t, i = "en") {
|
|
631
|
+
fe(), t.provide("quiz-locale", me(i)), t.component("QuizQuestion", ot), t.component("QuizPage", gt);
|
|
500
632
|
}
|
|
501
633
|
export {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
634
|
+
gt as QuizPage,
|
|
635
|
+
ot as QuizQuestion,
|
|
636
|
+
bt as enhanceAppWithQuiz,
|
|
637
|
+
me as getLocale,
|
|
638
|
+
X as locales,
|
|
639
|
+
xt as quizMarkdownPlugin
|
|
508
640
|
};
|
|
509
641
|
//# sourceMappingURL=vitepress-plugin-quiz.js.map
|