feat: Add new data-manager service for professor and module management and a new frontend application with i18n and a professor dashboard.

This commit is contained in:
Elmar Kresse
2025-11-22 20:20:00 +01:00
parent 48926233d5
commit 34ad90d50d
19 changed files with 769 additions and 68 deletions

View File

@@ -0,0 +1,29 @@
package professor
import (
"net/http"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
)
func RegisterRoutes(se *core.ServeEvent, service *ProfessorService) {
se.Router.GET("/api/professor/modules", func(e *core.RequestEvent) error {
record := e.Auth
if record == nil {
return apis.NewForbiddenError("Only authenticated users can access this endpoint", nil)
}
email := record.GetString("email")
if email == "" {
return apis.NewBadRequestError("User has no email", nil)
}
modules, err := service.GetModulesForProfessor(email)
if err != nil {
return apis.NewBadRequestError("Failed to fetch modules", err)
}
return e.JSON(http.StatusOK, modules)
}).Bind(apis.RequireAuth())
}