1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
27 lines
780 B
PHP
27 lines
780 B
PHP
<?php
|
|
/**
|
|
* GET /api/teacher/classes — alle Klassen der Lehrperson.
|
|
*/
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../../bootstrap.php';
|
|
|
|
v2_validate_method('GET');
|
|
$auth = v2_auth_require('teacher');
|
|
$teacherId = (int) ($auth['sub'] ?? 0);
|
|
|
|
$rows = v2_db_all("
|
|
SELECT c.id, c.name, c.school_year, c.join_code,
|
|
(SELECT COUNT(*) FROM students WHERE class_id = c.id AND deleted_at IS NULL) AS student_count
|
|
FROM classes c
|
|
WHERE c.teacher_id = :tid
|
|
ORDER BY c.created_at DESC
|
|
", [':tid' => $teacherId]);
|
|
|
|
v2_response_ok(['classes' => array_map(fn($r) => [
|
|
'id' => (int) $r['id'],
|
|
'name' => $r['name'],
|
|
'schoolYear' => $r['school_year'],
|
|
'joinCode' => $r['join_code'],
|
|
'studentCount' => (int) $r['student_count'],
|
|
], $rows)]);
|