@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 CHANGED
@@ -81,8 +81,24 @@ question: What CSS property controls text color?
81
81
  answer-input: color
82
82
  explanation: The `color` property sets the foreground text colour.
83
83
  :::
84
+
85
+ :::quiz
86
+ question: Match each language to its category
87
+ pair: TypeScript => Compiled
88
+ pair: Python => Interpreted
89
+ pair: HTML => Markup
90
+ distractor: Query language
91
+ :::
84
92
  ```
85
93
 
94
+ ### Syntax notes
95
+
96
+ - Association: two or more `pair: Item => Match` (or `pair: Item --> Match`) lines render one drop-down per item; options are derived from the right-hand values (plus optional `distractor:` lines). All rows must match for a correct answer.
97
+ - Keys are case-insensitive (`Question:`, `ANSWER-CORRECT:`).
98
+ - Values can span several lines: any line that is not a known key continues the previous `question`, `answer`/`answer-correct` or `explanation`.
99
+ - Fill-in-the-blank answers are lenient: capitals, accents, surrounding and repeated spaces are ignored (`reseau` matches `Réseau`). Repeat `answer-input:` to accept several variants.
100
+ - Invalid blocks (no question, no answers) and choice quizzes without `answer-correct` log a build-time warning with the line number.
101
+
86
102
  ---
87
103
 
88
104
  ## Documentation
@@ -3,11 +3,17 @@ export interface QuizAnswer {
3
3
  correct: boolean;
4
4
  originalIndex?: number;
5
5
  }
6
+ export interface QuizPair {
7
+ left: string;
8
+ right: string;
9
+ }
6
10
  export interface QuizData {
7
11
  question: string;
8
- type: "choice" | "input";
12
+ type: "choice" | "input" | "association";
9
13
  answers: QuizAnswer[];
10
14
  expected: string[];
15
+ pairs: QuizPair[];
16
+ options: string[];
11
17
  explanation: string;
12
18
  shuffle: boolean;
13
19
  }
@@ -21,6 +27,8 @@ export interface QuizLocale {
21
27
  inputHint: string;
22
28
  inputPlaceholder: string;
23
29
  expectedAnswer: string;
30
+ associationHint: string;
31
+ associationPlaceholder: string;
24
32
  }
25
33
  export interface QuizState {
26
34
  answered: boolean;
@@ -34,4 +42,8 @@ export interface SavedInputAnswer {
34
42
  type: "input";
35
43
  input: string;
36
44
  }
37
- export type SavedAnswer = SavedChoiceAnswer | SavedInputAnswer;
45
+ export interface SavedAssociationAnswer {
46
+ type: "association";
47
+ chosen: (number | null)[];
48
+ }
49
+ export type SavedAnswer = SavedChoiceAnswer | SavedInputAnswer | SavedAssociationAnswer;
@@ -10,3 +10,8 @@ export type RichPart = {
10
10
  * Used for question titles, answer text, and explanations.
11
11
  */
12
12
  export declare function parseRichText(text: string): RichPart[];
13
+ /**
14
+ * Normalise a typed answer for lenient comparison: case-insensitive,
15
+ * accent-insensitive ("Réseau" == "reseau"), trimmed, whitespace collapsed.
16
+ */
17
+ export declare function normalizeInput(text: string): string;