{
  "_comment_for_llm": "This is a guide + prompt template for generating learning cards for the YAWL app. Read the schema, study the examples, then generate cards as instructed.",

  "llm_instructions": {
    "task": "Generate learning flashcards in the JSON format described below.",
    "output_format": "Return ONLY a valid JSON object matching the structure shown in 'import_structure'. No prose, no markdown fences.",
    "rules": [
      "Every card MUST have all required fields: type, prompt, explanation, difficulty, is_public, title",
      "LaTeX is supported in prompt and explanation: use $...$ for inline math, $$...$$ for display math",
      "difficulty must be exactly one of: 'beginner', 'intermediate', 'advanced'",
      "title is almost always null unless you want a label shown above the card",
      "explanation is shown AFTER the user answers — use it to explain WHY the answer is correct",
      "is_public should always be true unless told otherwise",
      "Shuffle choices mentally — do not always put the correct answer first",
      "Use diverse card types — do not generate only multiple_choice"
    ]
  },

  "import_structure": {
    "_comment": "This is the exact structure your output must follow",
    "version": "1.0",
    "exported_at": "2026-01-01T00:00:00.000000Z",
    "user": { "id": 1, "username": "admin" },
    "topics": [
      {
        "title": "Your Topic Title",
        "slug": "your-topic-slug",
        "description": "Short description of the topic",
        "icon": "⊗",
        "order_index": 0,
        "is_public": true,
        "subtopics": [
          {
            "title": "Your Subtopic Title",
            "slug": "your-subtopic-slug",
            "description": "Short description",
            "difficulty": "intermediate",
            "estimated_minutes": null,
            "order_index": 0,
            "is_public": true,
            "cards": ["... card objects go here, see CARD_TYPE_REFERENCE below ..."]
          }
        ]
      }
    ]
  },

  "card_type_reference": {
    "_comment": "One fully worked example of every supported card type. Copy the structure, fill in your content.",

    "multiple_choice": {
      "_description": "4 options, exactly one correct. Choices are shuffled on each render. Supports LaTeX.",
      "type": "multiple_choice",
      "title": null,
      "prompt": "Was ist $\\frac{d}{dx} e^x$?",
      "explanation": "$e^x$ ist die einzige Funktion, die ihre eigene Ableitung ist. Allgemein: $\\frac{d}{dx}e^{f(x)} = f'(x)\\cdot e^{f(x)}$.",
      "payload_json": {
        "choices": ["$e^x - 1$", "$x \\cdot e^{x-1}$", "$e^x$", "$0$"]
      },
      "solution_json": {
        "correct_index": 2
      },
      "difficulty": "beginner",
      "is_public": true
    },

    "true_false": {
      "_description": "Two big buttons: True / False. Instantly reveals result on tap.",
      "type": "true_false",
      "title": null,
      "prompt": "Die Determinante einer orthogonalen Matrix ist immer $\\pm 1$.",
      "explanation": "Ja: Fuer orthogonale $Q$ gilt $Q^T Q = I$, also $\\det(Q^T)\\det(Q) = 1$, d.h. $\\det(Q)^2 = 1$, also $\\det(Q) = \\pm 1$.",
      "payload_json": {
        "display_mode": "buttons"
      },
      "solution_json": {
        "correct": true
      },
      "difficulty": "intermediate",
      "is_public": true
    },

    "numeric_input": {
      "_description": "User types a number. Accepted if |input - answer| <= tolerance. Specify unit and decimal_places.",
      "type": "numeric_input",
      "title": null,
      "prompt": "Wie viele Dimensionen hat der Loesungsraum von $Ax=0$, wenn $A$ eine $3\\times 5$-Matrix mit Rang 3 ist?",
      "explanation": "Dimensionssatz: $\\dim(\\ker A) = n - \\text{Rang}(A) = 5 - 3 = 2$.",
      "payload_json": {
        "unit": "",
        "decimal_places": 0
      },
      "solution_json": {
        "answer": 2,
        "tolerance": 0
      },
      "difficulty": "intermediate",
      "is_public": true
    },

    "latex_input": {
      "_description": "User types LaTeX. Live KaTeX preview while typing. Checked for mathematical equivalence.",
      "type": "latex_input",
      "title": null,
      "prompt": "Schreibe die Ableitung von $\\sin(x)$ in LaTeX:\n$\\frac{d}{dx}\\sin(x) = \\_\\_$",
      "explanation": "$\\frac{d}{dx}\\sin(x) = \\cos(x)$. Merke: $\\frac{d}{dx}\\cos(x) = -\\sin(x)$.",
      "payload_json": {},
      "solution_json": {
        "expected": "\\cos(x)"
      },
      "difficulty": "beginner",
      "is_public": true
    },

    "matching_pairs": {
      "_description": "Two columns, tap to pair them. Right column is shuffled. correct_pairs: [[left_index, right_index], ...] in the ORDER they appear in 'pairs'.",
      "type": "matching_pairs",
      "title": null,
      "prompt": "Ordne den Integrationsmethoden ihre Anwendungsfaelle zu:",
      "explanation": "Jede Integrationsmethode hat ihren Spezialfall: Substitution fuer Kettenregel-Umkehr, partiell fuer Produkte, Partialbruch fuer rationale Funktionen, partiell per Formel bei einfachen Potenzen.",
      "payload_json": {
        "pairs": [
          { "left": "Substitution $u = g(x)$", "right": "Integrand enthaelt $g'(x)\\cdot f(g(x))$" },
          { "left": "Partielle Integration", "right": "Integrand ist Produkt zweier Funktionen" },
          { "left": "Partialbruchzerlegung", "right": "Integrand ist eine rationale Funktion" },
          { "left": "$\\int x^n dx$", "right": "$\\frac{x^{n+1}}{n+1} + C$" }
        ]
      },
      "solution_json": {
        "correct_pairs": [[0, 0], [1, 1], [2, 2], [3, 3]]
      },
      "difficulty": "intermediate",
      "is_public": true
    },

    "equation_token_builder": {
      "_description": "Duolingo-style token builder. The student assembles an equation by tapping tokens from a shuffled pool. Tokens can be reused if they appear multiple times in correct_sequence. Tokens that do NOT appear in correct_sequence are decoys. All token text is rendered as LaTeX.",
      "_payload_notes": {
        "tokens": "Array of token objects. Each token has a stable 'id' (e.g. 't1') and a 'latex' string. IDs must be unique. Decoy tokens are simply tokens whose id never appears in correct_sequence.",
        "shuffle_tokens": "Always set to true — the pool is shuffled on each render.",
        "allow_duplicate_usage": "Always set to true — the pool generates as many copies of a token as it appears in correct_sequence."
      },
      "_solution_notes": {
        "correct_sequence": "Ordered array of token IDs. May repeat IDs. The student's placed sequence must match this exactly."
      },
      "type": "equation_token_builder",
      "title": null,
      "prompt": "Stelle die zeitabhaengige Schroedinger-Gleichung zusammen:",
      "explanation": "Die zeitabhaengige Schroedinger-Gleichung $i\\hbar \\partial_t \\Psi = \\hat{H} \\Psi$ beschreibt die Zeitentwicklung des Quantenzustands $\\Psi$. Links steht der Zeitentwicklungsoperator, rechts der Hamiltonoperator.",
      "payload_json": {
        "tokens": [
          { "id": "t1", "latex": "i\\hbar" },
          { "id": "t2", "latex": "\\partial_t" },
          { "id": "t3", "latex": "\\Psi" },
          { "id": "t4", "latex": "=" },
          { "id": "t5", "latex": "\\hat{H}" },
          { "id": "d1", "latex": "\\nabla^2" },
          { "id": "d2", "latex": "\\partial_x" },
          { "id": "d3", "latex": "\\hbar^2" }
        ],
        "shuffle_tokens": true,
        "allow_duplicate_usage": true
      },
      "solution_json": {
        "correct_sequence": ["t1", "t2", "t3", "t4", "t5", "t3"]
      },
      "_correct_sequence_explained": "i\\hbar · ∂t · Ψ = Ĥ · Ψ  — note Ψ (t3) appears twice; d1/d2/d3 are decoys",
      "difficulty": "intermediate",
      "is_public": true
    },

    "explanation_card": {
      "_description": "Pure reading content — no answer required. User taps 'Got it' to advance. Use for theory, formulas, definitions.",
      "type": "explanation_card",
      "title": "Wichtige Formel",
      "prompt": "Euler'sche Identitaet",
      "explanation": null,
      "payload_json": {
        "content": "Die schoenste Formel der Mathematik verbindet fuenf fundamentale Konstanten:\n\n$$e^{i\\pi} + 1 = 0$$\n\nSie folgt aus der Euler-Formel $e^{i\\theta} = \\cos\\theta + i\\sin\\theta$ fuer $\\theta = \\pi$:\n$$e^{i\\pi} = \\cos\\pi + i\\sin\\pi = -1 + 0 = -1$$",
        "image_url": null
      },
      "solution_json": {},
      "difficulty": "beginner",
      "is_public": true
    }
  },

  "tips": [
    "Generate at least 10-15 cards per subtopic for a useful study session",
    "Mix easy and hard cards — use 'beginner' for definitions, 'advanced' for derivations",
    "matching_pairs works best with exactly 4 pairs",
    "For numeric_input with exact integer answers, set tolerance to 0",
    "For numeric_input with floating point answers (e.g. 3.14), set tolerance to 0.01 or similar",
    "explanation_card is great for introducing a new concept before asking questions about it",
    "In multiple_choice, correct_index refers to the position in the 'choices' array (0-based)",
    "Avoid trivially obvious wrong answers — distractors should be plausible misconceptions",
    "LaTeX in choices for multiple_choice is fully supported",
    "The slug must be URL-safe: lowercase, hyphens only, no spaces or special characters",
    "For equation_token_builder: token IDs must be stable strings (e.g. 't1', 't2'). Tokens not in correct_sequence are automatic decoys — no separate decoy list needed.",
    "For equation_token_builder: if a token appears N times in correct_sequence, generate N pool copies automatically. Always set allow_duplicate_usage: true.",
    "For equation_token_builder: use 2-4 decoy tokens that look plausible (e.g. similar LaTeX symbols or operators that are wrong in context). Too many decoys make the card too hard.",
    "For equation_token_builder: the prompt should be phrased as a question or task ('Assemble...', 'Write...', 'Reconstruct...'). The explanation should show the correct equation rendered with context."
  ]
}