WIP teilnahme

This commit is contained in:
2025-07-11 10:22:39 +02:00
parent e5637d4929
commit 3dc185b667
5 changed files with 120 additions and 48 deletions

View File

@@ -267,7 +267,7 @@ class UserController{
$currentUser = $this->db->getUserById($userId);
if(!$currentUser){
throw new \Exception("User nicht gefunden");
new \Blog\Library\ErrorMsg("User nicht gefunden");
}
$validData = [
@@ -296,7 +296,7 @@ class UserController{
$currentUser = $this->db->getUserById($userId);
if (!$currentUser) {
throw new \Exception('User nicht gefunden');
new \Blog\Library\ErrorMsg('User nicht gefunden');
}
$submitted = [
@@ -388,5 +388,20 @@ class UserController{
}
public function enroll() {
$courseId = $_POST['id'] ?? null;
$userId = $_SESSION['user_id'] ?? null;
if ($userId === null) {
new \Blog\Library\ErrorMsg("Nicht eingeloggt.");
}
if ($courseId === null) {
new \Blog\Library\ErrorMsg("Kein Kurs ausgewählt");
}
$this->db->enroll($courseId, $userId);
$this->view->setDoMethodName("showEnrollmentConfirmation");
}
}