feat: quiz, cheat sheets, admin modules - MC quiz, search, user mgmt, content import
Dieser Commit ist enthalten in:
Ursprung
03778e4bed
Commit
3cd865ccbc
6 geänderte Dateien mit 425 neuen und 0 gelöschten Zeilen
28
edu/api/cheatsheets.php
Normale Datei
28
edu/api/cheatsheets.php
Normale Datei
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
require_auth();
|
||||
|
||||
// GET /api/cheatsheets
|
||||
if (get_method() === 'GET' && empty($segments[1])) {
|
||||
$stmt = $pdo->query("SELECT id, slug, title, category FROM cheatsheets ORDER BY category, title");
|
||||
json_ok(['cheatsheets' => $stmt->fetchAll()]);
|
||||
}
|
||||
|
||||
// GET /api/cheatsheets/search?q=...
|
||||
if (get_method() === 'GET' && ($segments[1] ?? '') === 'search') {
|
||||
$q = get_param('q', '');
|
||||
if (mb_strlen($q) < 2) json_error('Mindestens 2 Zeichen');
|
||||
$stmt = $pdo->prepare("SELECT id, slug, title, category FROM cheatsheets WHERE content_md ILIKE :q OR title ILIKE :q ORDER BY title");
|
||||
$stmt->execute([':q' => '%' . $q . '%']);
|
||||
json_ok(['cheatsheets' => $stmt->fetchAll(), 'query' => $q]);
|
||||
}
|
||||
|
||||
// GET /api/cheatsheets/{slug}
|
||||
if (get_method() === 'GET' && !empty($segments[1])) {
|
||||
$stmt = $pdo->prepare("SELECT * FROM cheatsheets WHERE slug = :slug");
|
||||
$stmt->execute([':slug' => $segments[1]]);
|
||||
$sheet = $stmt->fetch();
|
||||
if (!$sheet) json_error('Cheat Sheet nicht gefunden', 404);
|
||||
json_ok(['cheatsheet' => $sheet]);
|
||||
}
|
||||
|
||||
json_error('Unbekannter Cheatsheet-Endpunkt', 404);
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren