@matinfo/vitepress-plugin-quiz 1.0.4 → 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.
- package/README.md +16 -0
- package/dist/src/types/quiz.d.ts +14 -2
- package/dist/src/utils.d.ts +5 -0
- package/dist/vitepress-plugin-quiz.js +457 -267
- package/dist/vitepress-plugin-quiz.js.map +1 -1
- package/dist/vitepress-plugin-quiz.umd.cjs +4 -4
- package/dist/vitepress-plugin-quiz.umd.cjs.map +1 -1
- package/package.json +29 -21
- package/dist/src/__tests__/locales.test.d.ts +0 -1
- package/dist/src/__tests__/mdPlugin.test.d.ts +0 -1
- package/dist/src/__tests__/richText.test.d.ts +0 -1
|
@@ -1,451 +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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const ge = /^:::quiz\s*$/, he = /^:::\s*$/, xe = /^([A-Za-z-]+):(.*)$/, be = /* @__PURE__ */ new Set([
|
|
15
|
+
"question",
|
|
16
|
+
"answer",
|
|
17
|
+
"answer-correct",
|
|
18
|
+
"answer-input",
|
|
19
|
+
"pair",
|
|
20
|
+
"distractor",
|
|
21
|
+
"explanation",
|
|
22
|
+
"explication",
|
|
23
|
+
"shuffle"
|
|
24
|
+
]);
|
|
25
|
+
function xt(t) {
|
|
26
|
+
const i = t.utils.escapeHtml;
|
|
27
|
+
t.block.ruler.before(
|
|
18
28
|
"fence",
|
|
19
29
|
"quiz",
|
|
20
|
-
(
|
|
30
|
+
(n, v, u, _) => ze(n, v, u, _, i),
|
|
21
31
|
{ alt: ["paragraph", "reference", "blockquote", "list"] }
|
|
22
|
-
),
|
|
23
|
-
if (!
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
`,
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
`,
|
|
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(_);
|
|
30
40
|
});
|
|
31
41
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|
|
41
52
|
break;
|
|
42
53
|
}
|
|
43
|
-
|
|
54
|
+
p++;
|
|
44
55
|
}
|
|
45
|
-
if (!
|
|
46
|
-
const
|
|
47
|
-
for (let
|
|
48
|
-
const
|
|
49
|
-
|
|
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));
|
|
50
61
|
}
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
|
|
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)
|
|
66
|
+
return console.warn(
|
|
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.`
|
|
68
|
+
), !1;
|
|
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;
|
|
55
71
|
}
|
|
56
|
-
function
|
|
57
|
-
let
|
|
58
|
-
const r = [];
|
|
59
|
-
let u = "";
|
|
72
|
+
function we(t) {
|
|
73
|
+
let i = "";
|
|
60
74
|
const n = [];
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const g = z[2].trim(), $ = (f, C) => f ? `${f} ${C}` : C;
|
|
87
|
+
switch (w) {
|
|
88
|
+
case "question":
|
|
89
|
+
i = g, p = (f) => i = $(i, f);
|
|
90
|
+
break;
|
|
91
|
+
case "answer-correct":
|
|
92
|
+
case "answer": {
|
|
93
|
+
const f = { text: g, correct: w === "answer-correct" };
|
|
94
|
+
n.push(f), p = (C) => f.text = $(f.text, C);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "answer-input":
|
|
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;
|
|
115
|
+
break;
|
|
116
|
+
case "explanation":
|
|
117
|
+
case "explication":
|
|
118
|
+
v = g, p = (f) => v = $(v, f);
|
|
119
|
+
break;
|
|
120
|
+
case "shuffle":
|
|
121
|
+
h = g.toLowerCase() === "true", p = null;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
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
|
+
};
|
|
65
149
|
}
|
|
66
|
-
return
|
|
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
|
+
};
|
|
67
160
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
return `<QuizQuestion data-quiz="${
|
|
161
|
+
function qe(t, i) {
|
|
162
|
+
const n = JSON.stringify(t);
|
|
163
|
+
return `<QuizQuestion data-quiz="${i(n)}" />
|
|
71
164
|
`;
|
|
72
165
|
}
|
|
73
|
-
const
|
|
166
|
+
const X = {
|
|
74
167
|
en: {
|
|
75
168
|
answered: "answered",
|
|
76
169
|
validate: "Validate",
|
|
77
170
|
reset: "Restart",
|
|
78
|
-
correctAnswers: (
|
|
171
|
+
correctAnswers: (t) => `correct answer${t !== 1 ? "s" : ""}`,
|
|
79
172
|
multipleHint: "Multiple answers possible",
|
|
80
173
|
explanation: "Explanation: ",
|
|
81
174
|
inputHint: "Type your answer",
|
|
82
175
|
inputPlaceholder: "Your answer…",
|
|
83
|
-
expectedAnswer: "Expected answer:"
|
|
176
|
+
expectedAnswer: "Expected answer:",
|
|
177
|
+
associationHint: "Match each item with its answer",
|
|
178
|
+
associationPlaceholder: "Choose…"
|
|
84
179
|
},
|
|
85
180
|
fr: {
|
|
86
181
|
answered: "répondue(s)",
|
|
87
182
|
validate: "Valider",
|
|
88
183
|
reset: "Recommencer",
|
|
89
|
-
correctAnswers: (
|
|
184
|
+
correctAnswers: (t) => `réponse${t > 1 ? "s" : ""} correcte${t > 1 ? "s" : ""}`,
|
|
90
185
|
multipleHint: "Plusieurs réponses possibles",
|
|
91
186
|
explanation: "Explication : ",
|
|
92
187
|
inputHint: "Saisissez votre réponse",
|
|
93
188
|
inputPlaceholder: "Votre réponse…",
|
|
94
|
-
expectedAnswer: "Réponse attendue :"
|
|
189
|
+
expectedAnswer: "Réponse attendue :",
|
|
190
|
+
associationHint: "Associez chaque élément à sa réponse",
|
|
191
|
+
associationPlaceholder: "Choisir…"
|
|
95
192
|
},
|
|
96
193
|
de: {
|
|
97
194
|
answered: "beantwortet",
|
|
98
195
|
validate: "Überprüfen",
|
|
99
196
|
reset: "Neu starten",
|
|
100
|
-
correctAnswers: (
|
|
197
|
+
correctAnswers: (t) => `richtige Antwort${t !== 1 ? "en" : ""}`,
|
|
101
198
|
multipleHint: "Mehrere Antworten möglich",
|
|
102
199
|
explanation: "Erklärung:",
|
|
103
200
|
inputHint: "Geben Sie Ihre Antwort ein",
|
|
104
201
|
inputPlaceholder: "Ihre Antwort…",
|
|
105
|
-
expectedAnswer: "Erwartete Antwort:"
|
|
202
|
+
expectedAnswer: "Erwartete Antwort:",
|
|
203
|
+
associationHint: "Ordnen Sie jedem Element die passende Antwort zu",
|
|
204
|
+
associationPlaceholder: "Auswählen…"
|
|
106
205
|
},
|
|
107
206
|
it: {
|
|
108
207
|
answered: "risposta/e",
|
|
109
208
|
validate: "Verifica",
|
|
110
209
|
reset: "Ricominciare",
|
|
111
|
-
correctAnswers: (
|
|
210
|
+
correctAnswers: (t) => `rispost${t !== 1 ? "e corrette" : "a corretta"}`,
|
|
112
211
|
multipleHint: "Più risposte possibili",
|
|
113
212
|
explanation: "Spiegazione: ",
|
|
114
213
|
inputHint: "Digita la tua risposta",
|
|
115
214
|
inputPlaceholder: "La tua risposta…",
|
|
116
|
-
expectedAnswer: "Risposta attesa:"
|
|
215
|
+
expectedAnswer: "Risposta attesa:",
|
|
216
|
+
associationHint: "Abbina ogni elemento alla risposta corretta",
|
|
217
|
+
associationPlaceholder: "Scegli…"
|
|
117
218
|
},
|
|
118
219
|
es: {
|
|
119
220
|
answered: "respondida(s)",
|
|
120
221
|
validate: "Validar",
|
|
121
222
|
reset: "Reiniciar",
|
|
122
|
-
correctAnswers: (
|
|
223
|
+
correctAnswers: (t) => `respuesta${t !== 1 ? "s correctas" : " correcta"}`,
|
|
123
224
|
multipleHint: "Varias respuestas posibles",
|
|
124
225
|
explanation: "Explicación: ",
|
|
125
226
|
inputHint: "Escribe tu respuesta",
|
|
126
227
|
inputPlaceholder: "Tu respuesta…",
|
|
127
|
-
expectedAnswer: "Respuesta esperada:"
|
|
228
|
+
expectedAnswer: "Respuesta esperada:",
|
|
229
|
+
associationHint: "Asocia cada elemento con su respuesta",
|
|
230
|
+
associationPlaceholder: "Elegir…"
|
|
128
231
|
}
|
|
129
232
|
};
|
|
130
|
-
function
|
|
131
|
-
return
|
|
233
|
+
function me(t = "en") {
|
|
234
|
+
return X[t] ?? X.en;
|
|
235
|
+
}
|
|
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;
|
|
132
242
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
let u = 0, n;
|
|
136
|
-
for (; (n = r.exec(e)) !== null; )
|
|
137
|
-
n.index > u && t.push({ type: "text", value: e.slice(u, n.index) }), n[2] ? t.push({ type: "bold", value: n[2] }) : n[4] ? t.push({ type: "italic", value: n[4] }) : n[6] && t.push({ type: "code", value: n[6] }), u = r.lastIndex;
|
|
138
|
-
return u < e.length && t.push({ type: "text", value: e.slice(u) }), t;
|
|
243
|
+
function ee(t) {
|
|
244
|
+
return t.normalize("NFD").replace(/\p{M}/gu, "").trim().replace(/\s+/g, " ").toLowerCase();
|
|
139
245
|
}
|
|
140
|
-
const
|
|
246
|
+
const ye = ["aria-label"], ke = { class: "quiz-question-title" }, _e = { key: 0 }, Se = { key: 1 }, Ae = { key: 2 }, Ie = {
|
|
141
247
|
key: 0,
|
|
142
248
|
class: "quiz-hint"
|
|
143
|
-
},
|
|
249
|
+
}, $e = ["aria-multiselectable"], Ce = ["onClick", "aria-selected", "onKeydown"], Qe = {
|
|
144
250
|
class: "quiz-indicator",
|
|
145
251
|
"aria-hidden": "true"
|
|
146
|
-
},
|
|
252
|
+
}, Pe = {
|
|
147
253
|
key: 0,
|
|
148
254
|
class: "quiz-check"
|
|
149
|
-
},
|
|
255
|
+
}, Me = {
|
|
150
256
|
key: 1,
|
|
151
257
|
class: "quiz-empty"
|
|
152
|
-
},
|
|
258
|
+
}, Ee = {
|
|
153
259
|
key: 0,
|
|
154
260
|
class: "quiz-check"
|
|
155
|
-
},
|
|
261
|
+
}, He = {
|
|
156
262
|
key: 1,
|
|
157
263
|
class: "quiz-empty"
|
|
158
|
-
},
|
|
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 = {
|
|
159
265
|
key: 0,
|
|
160
266
|
class: "quiz-expected"
|
|
161
|
-
},
|
|
162
|
-
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,
|
|
163
272
|
class: "quiz-explanation",
|
|
164
273
|
role: "note"
|
|
165
|
-
},
|
|
274
|
+
}, nt = { key: 0 }, rt = { key: 1 }, st = { key: 2 }, ot = /* @__PURE__ */ te({
|
|
166
275
|
__name: "QuizQuestion",
|
|
167
276
|
props: {
|
|
168
277
|
dataQuiz: { type: String, required: !0 }
|
|
169
278
|
},
|
|
170
|
-
setup(
|
|
171
|
-
const
|
|
279
|
+
setup(t) {
|
|
280
|
+
const i = t, n = I(() => {
|
|
172
281
|
try {
|
|
173
|
-
return JSON.parse(
|
|
282
|
+
return JSON.parse(i.dataQuiz);
|
|
174
283
|
} catch {
|
|
175
284
|
return null;
|
|
176
285
|
}
|
|
177
286
|
});
|
|
178
|
-
function
|
|
179
|
-
const
|
|
180
|
-
for (let
|
|
181
|
-
const
|
|
182
|
-
[
|
|
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]];
|
|
183
292
|
}
|
|
184
|
-
return
|
|
293
|
+
return s;
|
|
185
294
|
}
|
|
186
|
-
const
|
|
187
|
-
function
|
|
188
|
-
if (!
|
|
189
|
-
|
|
295
|
+
const u = M([]);
|
|
296
|
+
function _() {
|
|
297
|
+
if (!n.value || n.value.type !== "choice") {
|
|
298
|
+
u.value = [];
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const r = n.value.answers.map((s, e) => ({ ...s, originalIndex: e }));
|
|
302
|
+
u.value = n.value.shuffle ? v(r) : r;
|
|
303
|
+
}
|
|
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 = [];
|
|
190
314
|
return;
|
|
191
315
|
}
|
|
192
|
-
|
|
193
|
-
|
|
316
|
+
w.value = r.pairs.map(() => null);
|
|
317
|
+
const s = r.options.map((e, d) => d);
|
|
318
|
+
g.value = r.shuffle ? v(s) : s;
|
|
194
319
|
}
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
), k = _(() => x.value > 1), f = M(/* @__PURE__ */ new Set()), m = M(""), C = $("quiz-register", null), h = $("quiz-validated", M(!1)), P = $("quiz-reset", M(0)), S = $("quiz-locale"), H = $("quiz-question-id", null), d = $("quiz-save-answer", null), b = $("quiz-get-answer", null), Q = H ? H() : null, B = _(() => i.value ? m.value.trim().length > 0 : f.value.size > 0), T = _(() => {
|
|
201
|
-
if (!v.value || !B.value) return !1;
|
|
202
|
-
if (i.value) {
|
|
203
|
-
const l = m.value.trim().toLowerCase();
|
|
204
|
-
return r.value.expected.some((s) => l === s.trim().toLowerCase());
|
|
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));
|
|
205
325
|
}
|
|
206
|
-
|
|
207
|
-
|
|
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)
|
|
208
330
|
);
|
|
209
|
-
if (
|
|
210
|
-
for (const
|
|
211
|
-
if (!
|
|
331
|
+
if (z.value.size !== r.size) return !1;
|
|
332
|
+
for (const s of z.value)
|
|
333
|
+
if (!r.has(s)) return !1;
|
|
212
334
|
return !0;
|
|
213
335
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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);
|
|
343
|
+
}
|
|
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)
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
220
365
|
}
|
|
221
366
|
});
|
|
222
|
-
function
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
|
|
367
|
+
function ne(r, s) {
|
|
368
|
+
if (l.value) return;
|
|
369
|
+
const e = s.target.value, d = [...w.value];
|
|
370
|
+
d[r] = e === "" ? null : Number(e), w.value = d, D();
|
|
371
|
+
}
|
|
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();
|
|
226
376
|
}
|
|
227
|
-
|
|
228
|
-
|
|
377
|
+
Z(f, () => {
|
|
378
|
+
l.value || D();
|
|
229
379
|
});
|
|
230
|
-
function
|
|
231
|
-
!
|
|
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";
|
|
232
386
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
return f.value.has(p) ? "quiz-answer selected" : "quiz-answer";
|
|
236
|
-
const l = v.value.answers[p], s = f.value.has(p);
|
|
237
|
-
return l.correct && s ? "quiz-answer correct" : l.correct && !s ? "quiz-answer missed" : !l.correct && s ? "quiz-answer wrong" : "quiz-answer";
|
|
387
|
+
function se(r) {
|
|
388
|
+
return l.value ? B(r) ? "quiz-assoc-select correct" : "quiz-assoc-select wrong" : "quiz-assoc-select";
|
|
238
389
|
}
|
|
239
|
-
const
|
|
240
|
-
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", {
|
|
241
392
|
key: 0,
|
|
242
|
-
class:
|
|
243
|
-
"aria-label":
|
|
393
|
+
class: V(["quiz-question", { validated: x(l) }]),
|
|
394
|
+
"aria-label": y.value.question
|
|
244
395
|
}, [
|
|
245
|
-
|
|
246
|
-
(
|
|
247
|
-
|
|
248
|
-
|
|
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)
|
|
249
400
|
], 64))
|
|
250
401
|
], 64))), 128))
|
|
251
402
|
]),
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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", {
|
|
255
406
|
class: "quiz-answers",
|
|
256
407
|
role: "listbox",
|
|
257
|
-
"aria-multiselectable":
|
|
408
|
+
"aria-multiselectable": S.value
|
|
258
409
|
}, [
|
|
259
|
-
(
|
|
260
|
-
key:
|
|
261
|
-
class:
|
|
262
|
-
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),
|
|
263
414
|
role: "option",
|
|
264
|
-
"aria-selected":
|
|
415
|
+
"aria-selected": z.value.has(e.originalIndex),
|
|
265
416
|
tabindex: "0",
|
|
266
417
|
onKeydown: [
|
|
267
|
-
|
|
268
|
-
|
|
418
|
+
U((d) => J(e.originalIndex), ["enter"]),
|
|
419
|
+
U(G((d) => J(e.originalIndex), ["prevent"]), ["space"])
|
|
269
420
|
]
|
|
270
421
|
}, [
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
], 64)) : (
|
|
275
|
-
|
|
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, "○"))
|
|
276
427
|
], 64))
|
|
277
428
|
]),
|
|
278
|
-
|
|
279
|
-
(
|
|
280
|
-
|
|
281
|
-
|
|
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)
|
|
282
433
|
], 64))
|
|
283
434
|
], 64))), 128))
|
|
284
435
|
])
|
|
285
|
-
], 42,
|
|
286
|
-
], 8,
|
|
287
|
-
], 64)),
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
"
|
|
293
|
-
|
|
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),
|
|
294
481
|
type: "text",
|
|
295
|
-
disabled:
|
|
296
|
-
placeholder:
|
|
297
|
-
"aria-label":
|
|
482
|
+
disabled: x(l),
|
|
483
|
+
placeholder: x(Q).inputPlaceholder,
|
|
484
|
+
"aria-label": y.value.question,
|
|
298
485
|
autocomplete: "off",
|
|
299
486
|
spellcheck: "false",
|
|
300
|
-
onKeydown:
|
|
487
|
+
onKeydown: s[1] || (s[1] = U(G(() => {
|
|
301
488
|
}, ["prevent"]), ["enter"]))
|
|
302
|
-
}, null, 42,
|
|
303
|
-
[
|
|
489
|
+
}, null, 42, Xe), [
|
|
490
|
+
[ce, f.value]
|
|
304
491
|
]),
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
])) :
|
|
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)
|
|
309
496
|
])
|
|
310
|
-
], 64)) :
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
(
|
|
314
|
-
|
|
315
|
-
|
|
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)
|
|
316
503
|
], 64))
|
|
317
504
|
], 64))), 128))
|
|
318
|
-
])) :
|
|
319
|
-
], 10,
|
|
505
|
+
])) : P("", !0)
|
|
506
|
+
], 10, ye)) : P("", !0);
|
|
320
507
|
}
|
|
321
|
-
}),
|
|
508
|
+
}), at = {
|
|
322
509
|
class: "quiz-page",
|
|
323
510
|
role: "region",
|
|
324
511
|
"aria-label": "Quiz"
|
|
325
|
-
},
|
|
512
|
+
}, it = ["aria-valuenow", "aria-valuemax", "aria-label"], lt = { class: "quiz-progress-track" }, ut = {
|
|
326
513
|
class: "quiz-progress-label",
|
|
327
514
|
"aria-live": "polite"
|
|
328
|
-
},
|
|
515
|
+
}, ct = { class: "quiz-actions" }, pt = ["disabled"], dt = ["aria-label"], vt = { class: "quiz-score-value" }, ft = { class: "quiz-score-label" }, gt = /* @__PURE__ */ te({
|
|
329
516
|
__name: "QuizPage",
|
|
330
|
-
setup(
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
let
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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)
|
|
338
526
|
try {
|
|
339
|
-
sessionStorage.setItem(
|
|
527
|
+
sessionStorage.setItem(u + ":q" + l, JSON.stringify(k));
|
|
340
528
|
} catch {
|
|
341
529
|
}
|
|
342
|
-
}),
|
|
343
|
-
if (!
|
|
530
|
+
}), R("quiz-get-answer", (l) => {
|
|
531
|
+
if (!u) return null;
|
|
344
532
|
try {
|
|
345
|
-
const
|
|
346
|
-
return
|
|
533
|
+
const k = sessionStorage.getItem(u + ":q" + l);
|
|
534
|
+
return k ? JSON.parse(k) : null;
|
|
347
535
|
} catch {
|
|
348
536
|
return null;
|
|
349
537
|
}
|
|
350
538
|
});
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
() =>
|
|
355
|
-
),
|
|
356
|
-
() =>
|
|
357
|
-
),
|
|
358
|
-
() =>
|
|
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
|
|
359
549
|
);
|
|
360
|
-
function
|
|
361
|
-
|
|
550
|
+
function w() {
|
|
551
|
+
v.value = !0, $();
|
|
362
552
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
553
|
+
function g() {
|
|
554
|
+
v.value = !1, y.value++, C();
|
|
365
555
|
}
|
|
366
|
-
function
|
|
367
|
-
if (
|
|
556
|
+
function $() {
|
|
557
|
+
if (u)
|
|
368
558
|
try {
|
|
369
|
-
const
|
|
370
|
-
sessionStorage.setItem(
|
|
559
|
+
const l = { validated: v.value, ts: Date.now() };
|
|
560
|
+
sessionStorage.setItem(u, JSON.stringify(l));
|
|
371
561
|
} catch {
|
|
372
562
|
}
|
|
373
563
|
}
|
|
374
|
-
function
|
|
375
|
-
if (
|
|
564
|
+
function f() {
|
|
565
|
+
if (u)
|
|
376
566
|
try {
|
|
377
|
-
const
|
|
378
|
-
if (!
|
|
379
|
-
const
|
|
380
|
-
|
|
567
|
+
const l = sessionStorage.getItem(u);
|
|
568
|
+
if (!l) return;
|
|
569
|
+
const k = JSON.parse(l);
|
|
570
|
+
k && k.validated && (v.value = !0);
|
|
381
571
|
} catch {
|
|
382
572
|
}
|
|
383
573
|
}
|
|
384
|
-
function
|
|
385
|
-
if (
|
|
574
|
+
function C() {
|
|
575
|
+
if (u)
|
|
386
576
|
try {
|
|
387
|
-
const
|
|
388
|
-
for (let
|
|
389
|
-
const Q = sessionStorage.key(
|
|
390
|
-
Q && Q.startsWith(
|
|
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);
|
|
391
581
|
}
|
|
392
|
-
|
|
582
|
+
l.forEach((k) => sessionStorage.removeItem(k));
|
|
393
583
|
} catch {
|
|
394
584
|
}
|
|
395
585
|
}
|
|
396
|
-
return (
|
|
397
|
-
|
|
586
|
+
return (l, k) => (o(), a("div", at, [
|
|
587
|
+
b("div", {
|
|
398
588
|
class: "quiz-progress-bar",
|
|
399
589
|
role: "progressbar",
|
|
400
|
-
"aria-valuenow":
|
|
590
|
+
"aria-valuenow": p.value,
|
|
401
591
|
"aria-valuemin": 0,
|
|
402
|
-
"aria-valuemax":
|
|
403
|
-
"aria-label":
|
|
592
|
+
"aria-valuemax": h.value,
|
|
593
|
+
"aria-label": p.value + " / " + h.value + " " + x(i).answered
|
|
404
594
|
}, [
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
class:
|
|
408
|
-
style:
|
|
595
|
+
b("div", lt, [
|
|
596
|
+
b("div", {
|
|
597
|
+
class: V(["quiz-progress-fill", { complete: z.value === 100 }]),
|
|
598
|
+
style: pe({ width: z.value + "%" })
|
|
409
599
|
}, null, 6)
|
|
410
600
|
]),
|
|
411
|
-
|
|
412
|
-
], 8,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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", {
|
|
416
606
|
key: 0,
|
|
417
607
|
class: "quiz-btn quiz-btn-validate",
|
|
418
|
-
disabled: !
|
|
419
|
-
onClick:
|
|
420
|
-
}, c(
|
|
421
|
-
|
|
422
|
-
|
|
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", {
|
|
423
613
|
class: "quiz-score",
|
|
424
614
|
role: "status",
|
|
425
615
|
"aria-live": "polite",
|
|
426
|
-
"aria-label":
|
|
616
|
+
"aria-label": A.value + " / " + h.value + " " + x(i).correctAnswers(A.value)
|
|
427
617
|
}, [
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
], 8,
|
|
431
|
-
|
|
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", {
|
|
432
622
|
class: "quiz-btn quiz-btn-reset",
|
|
433
|
-
onClick:
|
|
434
|
-
}, c(
|
|
435
|
-
], 64)) :
|
|
623
|
+
onClick: g
|
|
624
|
+
}, c(x(i).reset), 1)
|
|
625
|
+
], 64)) : P("", !0)
|
|
436
626
|
])
|
|
437
627
|
]));
|
|
438
628
|
}
|
|
439
629
|
});
|
|
440
|
-
function
|
|
441
|
-
|
|
630
|
+
function bt(t, i = "en") {
|
|
631
|
+
fe(), t.provide("quiz-locale", me(i)), t.component("QuizQuestion", ot), t.component("QuizPage", gt);
|
|
442
632
|
}
|
|
443
633
|
export {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
634
|
+
gt as QuizPage,
|
|
635
|
+
ot as QuizQuestion,
|
|
636
|
+
bt as enhanceAppWithQuiz,
|
|
637
|
+
me as getLocale,
|
|
638
|
+
X as locales,
|
|
639
|
+
xt as quizMarkdownPlugin
|
|
450
640
|
};
|
|
451
641
|
//# sourceMappingURL=vitepress-plugin-quiz.js.map
|