feat: BreakPilot PWA - Full codebase (clean push without large binaries)
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
This commit is contained in:
109
klausur-service/backend/routes/exams.py
Normal file
109
klausur-service/backend/routes/exams.py
Normal file
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
Klausur-Service Exam Routes
|
||||
|
||||
CRUD endpoints for Klausuren.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
|
||||
from models.exam import Klausur
|
||||
from models.requests import KlausurCreate, KlausurUpdate
|
||||
from services.auth_service import get_current_user
|
||||
import storage
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/v1/klausuren")
|
||||
async def list_klausuren(request: Request):
|
||||
"""List all Klausuren for current teacher."""
|
||||
user = get_current_user(request)
|
||||
user_klausuren = [
|
||||
k.to_dict() for k in storage.klausuren_db.values()
|
||||
if k.teacher_id == user["user_id"]
|
||||
]
|
||||
return user_klausuren
|
||||
|
||||
|
||||
@router.post("/api/v1/klausuren")
|
||||
async def create_klausur(data: KlausurCreate, request: Request):
|
||||
"""Create a new Klausur."""
|
||||
user = get_current_user(request)
|
||||
|
||||
klausur = Klausur(
|
||||
id=str(uuid.uuid4()),
|
||||
title=data.title,
|
||||
subject=data.subject,
|
||||
modus=data.modus,
|
||||
class_id=data.class_id,
|
||||
year=data.year,
|
||||
semester=data.semester,
|
||||
erwartungshorizont=None,
|
||||
students=[],
|
||||
created_at=datetime.now(timezone.utc),
|
||||
teacher_id=user["user_id"]
|
||||
)
|
||||
|
||||
storage.klausuren_db[klausur.id] = klausur
|
||||
return klausur.to_dict()
|
||||
|
||||
|
||||
@router.get("/api/v1/klausuren/{klausur_id}")
|
||||
async def get_klausur(klausur_id: str, request: Request):
|
||||
"""Get a specific Klausur."""
|
||||
user = get_current_user(request)
|
||||
|
||||
if klausur_id not in storage.klausuren_db:
|
||||
raise HTTPException(status_code=404, detail="Klausur not found")
|
||||
|
||||
klausur = storage.klausuren_db[klausur_id]
|
||||
if klausur.teacher_id != user["user_id"] and user.get("role") != "admin":
|
||||
raise HTTPException(status_code=403, detail="Access denied")
|
||||
|
||||
return klausur.to_dict()
|
||||
|
||||
|
||||
@router.put("/api/v1/klausuren/{klausur_id}")
|
||||
async def update_klausur(klausur_id: str, data: KlausurUpdate, request: Request):
|
||||
"""Update a Klausur."""
|
||||
user = get_current_user(request)
|
||||
|
||||
if klausur_id not in storage.klausuren_db:
|
||||
raise HTTPException(status_code=404, detail="Klausur not found")
|
||||
|
||||
klausur = storage.klausuren_db[klausur_id]
|
||||
if klausur.teacher_id != user["user_id"] and user.get("role") != "admin":
|
||||
raise HTTPException(status_code=403, detail="Access denied")
|
||||
|
||||
if data.title:
|
||||
klausur.title = data.title
|
||||
if data.subject:
|
||||
klausur.subject = data.subject
|
||||
if data.erwartungshorizont:
|
||||
klausur.erwartungshorizont = data.erwartungshorizont
|
||||
|
||||
return klausur.to_dict()
|
||||
|
||||
|
||||
@router.delete("/api/v1/klausuren/{klausur_id}")
|
||||
async def delete_klausur(klausur_id: str, request: Request):
|
||||
"""Delete a Klausur and all associated student work."""
|
||||
user = get_current_user(request)
|
||||
|
||||
if klausur_id not in storage.klausuren_db:
|
||||
raise HTTPException(status_code=404, detail="Klausur not found")
|
||||
|
||||
klausur = storage.klausuren_db[klausur_id]
|
||||
if klausur.teacher_id != user["user_id"] and user.get("role") != "admin":
|
||||
raise HTTPException(status_code=403, detail="Access denied")
|
||||
|
||||
# Remove student records
|
||||
for student in klausur.students:
|
||||
if student.id in storage.students_db:
|
||||
del storage.students_db[student.id]
|
||||
|
||||
del storage.klausuren_db[klausur_id]
|
||||
return {"success": True}
|
||||
Reference in New Issue
Block a user