api

package
v0.0.0-...-1974716 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	BuildStatusQueued  = "queued"
	BuildStatusRunning = "running"
	BuildStatusSuccess = "success"
	BuildStatusFailure = "failure"
	BuildStatusError   = "error"
	BuildStatusSkipped = "skipped"
)

Build chart status keys. They match the build service's job statuses.

View Source
const CLIMinVersionSettingKey = "cli_min_version"

CLIMinVersionSettingKey is the settings key for the minimum CLI version.

View Source
const CustomHTTPRequestRange = "custom"

CustomHTTPRequestRange is the range value reported when the window is pinned by an explicit since/until bound instead of a preset.

View Source
const DefaultHTTPRequestRange = "7d"

DefaultHTTPRequestRange is the timeframe used when the query pins neither a range nor a custom since/until bound. It matches the chart's historical default window.

View Source
const OrchestrationBotUsername = "orchestration-bot"

OrchestrationBotUsername is the forgejo login of the "orchestration-bot" account. The bot creates every course org and repo on the owner's behalf.

Variables

View Source
var (
	// ErrParticipationExerciseNotFound reports an exercise id that does not
	// exist.
	ErrParticipationExerciseNotFound = errors.New("exercise not found")
	// ErrParticipationCourseMismatch reports an exercise that belongs to a
	// different course than the student.
	ErrParticipationCourseMismatch = errors.New("exercise must belong to the same course as the student")
	// ErrParticipationNoChanges reports an update without editable fields.
	ErrParticipationNoChanges = errors.New("no fields to update")
	// ErrParticipationStudentRequired reports a missing student user id.
	ErrParticipationStudentRequired = errors.New("student_user_id is required")
	// ErrParticipationStudentNotFound reports a student not enrolled in the
	// exercise's course.
	ErrParticipationStudentNotFound = errors.New("student is not enrolled in the exercise's course")
	// ErrParticipationTutorRequired reports that no tutor was supplied and the
	// student has no assigned tutor.
	ErrParticipationTutorRequired = errors.New("student has no assigned tutor; provide tutor_id")
	// ErrParticipationTutorNotFound reports a tutor not assigned to the
	// exercise's course.
	ErrParticipationTutorNotFound = errors.New("tutor is not assigned to the exercise's course")
	// ErrParticipationDuplicate reports an existing attendance row for the
	// student and exercise.
	ErrParticipationDuplicate = errors.New("attendance already exists for this exercise")
)
View Source
var (
	ErrTutorNotFound    = errors.New("tutor not found in this course")
	ErrTutorWrongCourse = errors.New("tutor does not belong to this course")
)

ErrTutorNotFound and ErrTutorWrongCourse are returned by the tutor assignment helpers when the tutor id does not exist or belongs to a different course. API handlers map both to 400, the UI to 422.

View Source
var ErrInvalidBuildJobParams = errors.New("invalid build job filter")

ErrInvalidBuildJobParams marks a rejected build jobs filter. Callers map it to a 422 on the JSON API and a 400 on the page.

View Source
var ErrInvalidParticipationFilter = errors.New("presented must be true or false")

ErrInvalidParticipationFilter reports an unparsable presented filter.

View Source
var ErrNoCourseTutors = errors.New("course has no tutors")

ErrNoCourseTutors is returned by AutoDistributeStudents when the course has no tutors to distribute students to.

View Source
var ErrNoTutorialWindow = errors.New("no tutorial window for this date")

ErrNoTutorialWindow reports that a date does not fall into any exercise's tutorial window.

View Source
var HTTPRequestRanges = []HTTPRequestRange{
	{Value: "7d", Label: "Last 7 days (default)", Width: 7 * 24 * time.Hour},
	{Value: "1h", Label: "Last hour", Width: time.Hour},
	{Value: "6h", Label: "Last 6 hours", Width: 6 * time.Hour},
	{Value: "12h", Label: "Last 12 hours", Width: 12 * time.Hour},
	{Value: "24h", Label: "Last 24 hours", Width: 24 * time.Hour},
	{Value: "30d", Label: "Last 30 days", Width: 30 * 24 * time.Hour},
}

HTTPRequestRanges lists the selectable timeframes. The default comes first because the shared FilterForm Reset button selects the first option of every select, so the first entry has to be the server-side default.

Functions

func AdminAuditLogFacets

func AdminAuditLogFacets(gdb *gorm.DB) (actions, resources []string, err error)

AdminAuditLogFacets returns distinct action and resource values present in the audit log, used to populate filter dropdowns.

func AdminForgejoRequestFacets

func AdminForgejoRequestFacets(gdb *gorm.DB) (sources, methods []string, err error)

AdminForgejoRequestFacets returns distinct source and method values present in the Forgejo request log.

func AdminGetAuditLog

func AdminGetAuditLog(gdb *gorm.DB, id string) (db.AuditLog, error)

AdminGetAuditLog fetches a single audit log entry by ID.

func AdminGetCourse

func AdminGetCourse(gdb *gorm.DB, id string) (db.Course, error)

AdminGetCourse fetches a single course by ID (including archived courses via Unscoped, since the admin UI needs to show archived courses too).

func AdminGetForgejoRequest

func AdminGetForgejoRequest(gdb *gorm.DB, id string) (db.ForgejoRequest, error)

AdminGetForgejoRequest fetches a single Forgejo request by ID.

func AdminGetHTTPRequest

func AdminGetHTTPRequest(gdb *gorm.DB, id string) (db.HTTPRequest, error)

AdminGetHTTPRequest fetches a single inbound HTTP request by ID.

func AdminHTTPRequestFacets

func AdminHTTPRequestFacets(gdb *gorm.DB) (methods []string, err error)

AdminHTTPRequestFacets returns the distinct method values currently present in the request log, used to populate the method filter dropdown.

func AdminListStudents

func AdminListStudents(gdb *gorm.DB, courseID string) ([]db.Student, error)

AdminListStudents fetches students for a course with users preloaded.

func AdminListTutors

func AdminListTutors(gdb *gorm.DB, courseID string) ([]db.Tutor, error)

AdminListTutors fetches tutors for a course with users preloaded.

func AssignStudentsTutor

func AssignStudentsTutor(gdb *gorm.DB, courseID uint, userIDs []string, tutorID *uint) (int, error)

AssignStudentsTutor assigns or clears the tutor for multiple students of a course in one transaction. User ids without a matching student row in the course are skipped. The tutor must belong to the course (ErrTutorNotFound/ErrTutorWrongCourse). Returns the number of updated student rows.

func AutoDistributeStudents

func AutoDistributeStudents(gdb *gorm.DB, courseID uint) (assigned int, tutors int, err error)

AutoDistributeStudents distributes the unassigned students of a course evenly across the course's tutors. Existing assignments are kept; counts start from the currently assigned students. Each unassigned student (in id order) goes to the tutor with the lowest current count, ties broken by the lower tutor id. Everything runs in one transaction. Returns the number of updated student rows and the number of tutors considered.

func BuildJobUsers

func BuildJobUsers(gdb *gorm.DB, jobs []grading.Job) (map[string]db.User, error)

BuildJobUsers resolves the distinct student logins of a page of jobs to orchestration users. Logins without a current user are absent from the map, so the table can mark them as historical. A lookup failure is returned to the caller, which renders the unavailable card instead of mislabelling every row.

func CanManageCourse

func CanManageCourse(gdb *gorm.DB, c *echo.Context, courseID any) bool

CanManageCourse reports whether the caller may manage the course identified by courseID. Admins always may; staff may for courses they own and for courses an admin granted them via course_accesses. Used by handlers (e.g. HTML fragments) that operate on a course by id and need a boolean guard rather than a query scope.

func CourseAccessScope

func CourseAccessScope(c *echo.Context) func(*gorm.DB) *gorm.DB

CourseAccessScope returns a GORM scope that filters courses based on the caller's role for *read* access. Admins see everything. Staff see joinable courses plus the courses they own. Everyone else (students and unauthenticated callers) sees only courses with allow_join = true.

func CourseGrantCounts

func CourseGrantCounts(gdb *gorm.DB, courseIDs []uint) map[uint]int64

CourseGrantCounts returns the number of course_accesses grants per course id for the given course ids. Missing ids map to no entry (zero count).

func CourseManageScope

func CourseManageScope(c *echo.Context) func(*gorm.DB) *gorm.DB

CourseManageScope returns a GORM scope that restricts course queries to the courses the caller may *manage* (edit, delete, assign tutors/students, grade). Admins may manage every course; staff may manage the courses they own plus the ones an admin granted them via course_accesses; everyone else matches nothing. Applied to mutating course endpoints so a staff member acting on someone else's course gets a 404 rather than silently touching it.

func CourseVisibilityScope

func CourseVisibilityScope(ownerID string, isAdmin bool) func(*gorm.DB) *gorm.DB

CourseVisibilityScope restricts a query to the courses the caller may see: all courses for admins, owned and granted courses for staff. It expects the courses table to be present in the query, either as the primary table or through a join.

func CreateAPIKey

func CreateAPIKey(gdb *gorm.DB, userID, name string) (db.ApiKey, string, error)

CreateAPIKey generates a new API key for the given user, stores the hash, and returns the model + the plaintext key (only visible at creation time). Keys expire after 1 year.

func CreateParticipation

func CreateParticipation(gdb *gorm.DB, body ParticipationCreateBody) (db.TutorialParticipation, error)

CreateParticipation creates one manual attendance row. The student must be enrolled in the exercise's course, the tutor must belong to that course, and the student may not already have attendance for the exercise.

func DeleteAPIKey

func DeleteAPIKey(gdb *gorm.DB, userID string, keyID uint) error

DeleteAPIKey deletes an API key, scoped to the given user.

func DeleteParticipation

func DeleteParticipation(gdb *gorm.DB, id string) error

DeleteParticipation removes one participation row.

func EchoContext

func EchoContext(ctx context.Context) *echo.Context

EchoContext returns the echo context for the current huma request. Register injects it before the handler runs so handlers can build echo-context dependent GORM scopes and record audit entries. Returns nil when the handler is invoked outside of a registered operation (tests).

func ExerciseForDate

func ExerciseForDate(gdb *gorm.DB, courseID uint, date time.Time) (*db.Exercise, time.Time, time.Time, error)

ExerciseForDate returns the exercise whose tutorial window contains date, together with the window, or ErrNoTutorialWindow. Exercises are ordered by deadline, so the next exercise is the next deadline. The window start is inclusive and the end exclusive, so a date on the next deadline belongs to the next exercise.

func ExerciseIDForDate

func ExerciseIDForDate(exercises []db.Exercise, date time.Time) *uint

ExerciseIDForDate returns the exercise whose tutorial window contains date from an already loaded, deadline-ordered exercise slice.

func ExerciseTutorialWindow

func ExerciseTutorialWindow(gdb *gorm.DB, exercise db.Exercise) (start, end time.Time, ok bool, err error)

ExerciseTutorialWindow returns the derived tutorial window for one exercise in its course, or ok=false when the exercise has no usable window.

func FetchCLIVersions

func FetchCLIVersions() []string

FetchCLIVersions fetches the available hopper-cli release versions from PyPI and returns them sorted descending (newest first) with a "v" prefix. Returns nil if PyPI is unreachable or the response cannot be parsed.

func GetParticipation

func GetParticipation(gdb *gorm.DB, id string) (db.TutorialParticipation, error)

GetParticipation loads one participation with its student, course, exercise, and tutor. A missing row returns gorm.ErrRecordNotFound.

func HTTPRequestBucketLabel

func HTTPRequestBucketLabel(bucket string) (string, bool)

HTTPRequestBucketLabel returns the caption noun for a chart bucket key. The boolean is false for unknown keys.

func HTTPRequestRangeLabel

func HTTPRequestRangeLabel(value string) string

HTTPRequestRangeLabel returns the UI label of a timeframe value, or the empty string for unknown values.

func HTTPRequestRangeValue

func HTTPRequestRangeValue(p HTTPRequestListParams) string

HTTPRequestRangeValue returns the timeframe a filter form should show as selected. A custom since/until bound wins over the preset, so the select never claims a preset while the list and chart show a custom window.

func HTTPRequestRangeWidth

func HTTPRequestRangeWidth(value string) (time.Duration, bool)

HTTPRequestRangeWidth returns the width of a selectable timeframe. The boolean is false for unknown values, which resolve like the default range.

func HasCourseAccess

func HasCourseAccess(gdb *gorm.DB, courseID uint, userID string) bool

HasCourseAccess reports whether userID holds an admin-granted course access (a course_accesses row) for courseID. It says nothing about ownership, admin rights, or tutor slots; combine it with the other checks where those matter. Used by the per-record guards that bypass CanManageCourse (e.g. grade and tutor-assignment lookups).

func IsTutorAssigned

func IsTutorAssigned(gdb *gorm.DB, courseID, userID string) (bool, error)

IsTutorAssigned returns true if userID is a tutor of courseID.

func ListAPIKeys

func ListAPIKeys(gdb *gorm.DB, userID string) ([]db.ApiKey, error)

ListAPIKeys returns all API keys for the given user, newest first.

func ListExercisesForCourse

func ListExercisesForCourse(gdb *gorm.DB, courseID uint) ([]db.Exercise, error)

ListExercisesForCourse returns every exercise defined in a course, ordered by start date. Exported so tests and in-process callers can reuse the query without going through HTTP.

func LoadCLIMinVersion

func LoadCLIMinVersion(gdb *gorm.DB) string

LoadCLIMinVersion reads the cli_min_version setting from the database, returning the stored value (with a "v" prefix if missing) or an empty string when the setting does not exist.

func Register

func Register[I, O any](h *Huma, op huma.Operation, handler func(context.Context, *I) (*O, error), mw ...echo.MiddlewareFunc)

Register registers a huma operation with echo middleware applied as operation-level huma middleware, keeping route registration a one-liner:

api.Register(h, op, handler, a.Auth.RequireStaff())

The echo context of the current request is injected into the handler context and can be retrieved with EchoContext.

func ResolveUserID

func ResolveUserID(gdb *gorm.DB, identifier string) (string, error)

ResolveUserID resolves an arbitrary identifier to the canonical user PK (OIDC sub). Tries id, then preferred_username (case-insensitive), then student_id. Returns gorm.ErrRecordNotFound if nothing matches.

func RunTask

func RunTask(c *echo.Context, manager *tasks.Manager, gdb *gorm.DB, name string) error

RunTask starts the named task asynchronously. It returns an HTTP error for a missing task, an already-running task, or a scheduler that is shutting down. Records an audit entry on an accepted start. Exported for the HTML fragment handlers.

func SetStudentTutor

func SetStudentTutor(gdb *gorm.DB, courseID uint, userID string, tutorID *uint) (*db.Student, error)

SetStudentTutor sets or clears the tutor of a single student in a course. userID is the enrolled student's user id; a nil tutorID clears the assignment. The student row must exist in the course (gorm.ErrRecordNotFound) and the tutor must belong to the course (ErrTutorNotFound/ErrTutorWrongCourse). Returns the updated student row with the user preloaded.

func SettingAccessScope

func SettingAccessScope(c *echo.Context) func(*gorm.DB) *gorm.DB

SettingAccessScope returns a GORM scope that filters settings by the caller's access level. Unauthenticated callers see only "public" entries. Regular authenticated users see "public" + "authed". Admins see everything.

func TutorialWindow

func TutorialWindow(ex db.Exercise, next *db.Exercise) (start, end time.Time, ok bool)

TutorialWindow returns the tutorial window for ex. By default the window is [ex.End, next.End). TutorialStart and TutorialEnd override either edge. The last exercise has no next deadline, so it needs TutorialEnd to get a window at all.

func UpdateParticipation

func UpdateParticipation(gdb *gorm.DB, id string, exerciseID *uint, presented *bool) (db.TutorialParticipation, error)

UpdateParticipation updates the exercise link and presented flag of one participation. An exercise id must exist and belong to the student's course; a nil exercise id leaves the link unchanged, while 0 clears it.

func UserReadScope

func UserReadScope(c *echo.Context) func(*gorm.DB) *gorm.DB

UserReadScope returns a GORM scope that restricts a users query to the rows the caller is allowed to *read*. Admins see everyone. Any other authenticated caller sees:

  • themselves;
  • (as course owner or granted staff) every student and tutor enrolled in a course they own or hold a course_accesses grant for;
  • (as a course tutor) every student assigned to a tutor slot they hold.

The ownership branches are harmless for callers who own no courses and hold no tutor slots - their subqueries simply match nothing - so no role branch is needed beyond the admin short-circuit. Applied to the read endpoints so a staff member or tutor gets a scoped view instead of the whole user table, and a 404 (not a 403) for anyone outside their reach.

The whole predicate is a single grouped OR so it AND-combines cleanly with any search/filter scopes the list handler layers on top.

func UsersByForgejoUsernames

func UsersByForgejoUsernames(gdb *gorm.DB, logins []string) (map[string]db.User, error)

UsersByForgejoUsernames resolves Forgejo logins to orchestration users by preferred_username, case-insensitively. The returned map is keyed by the lower-cased login. Logins without a matching user are absent from the map.

func ValidExerciseName

func ValidExerciseName(name string) bool

ValidExerciseName reports whether the name is safe to use as a literal top-level directory name in student git repos. It matches the course name rules and implicitly blocks path separators, ".." and whitespace.

func ValidateBuildJobListParams

func ValidateBuildJobListParams(p BuildJobListParams) error

ValidateBuildJobListParams rejects filter values the build service would reject, so a bad request fails at the orchestration boundary instead of being misreported as an unreachable build service.

func WithEchoContext

func WithEchoContext(ctx context.Context, c *echo.Context) context.Context

WithEchoContext attaches the echo context to ctx. Plain echo handlers pass their request context through this so data functions can resolve the authenticated caller with EchoContext.

Types

type AssignTutorBody

type AssignTutorBody struct {
	UserID      string `json:"user_id"`
	Description string `json:"description" required:"false"`
}

AssignTutorBody is the body for POST /courses/{id}/tutors.

type AuditLogFacets

type AuditLogFacets struct {
	Actions   []string `json:"actions"`
	Resources []string `json:"resources"`
}

AuditLogFacets is the response body of GET /audit-log/facets. Each field carries the distinct values currently present in the audit_logs table for the matching column, sorted ascending. Clients use it to populate filter dropdowns so we don't have to hardcode the list of actions in the UI every time a new audit call-site is added on the backend.

type AuditLogFacetsInput

type AuditLogFacetsInput struct{}

AuditLogFacetsInput has no request parameters.

type AuditLogFacetsOutput

type AuditLogFacetsOutput struct {
	Body AuditLogFacets
}

AuditLogFacetsOutput holds the response body for AuditLogFacets.

type AuditLogGetInput

type AuditLogGetInput struct {
	ID string `path:"id"`
}

AuditLogGetInput holds the request parameters for AuditLogGet.

type AuditLogGetOutput

type AuditLogGetOutput struct {
	Body db.AuditLog
}

AuditLogGetOutput holds the response body for AuditLogGet.

type AuditLogListInput

type AuditLogListInput struct {
	AuditLogListQuery
}

AuditLogListInput holds the request parameters for AuditLogList.

type AuditLogListOutput

type AuditLogListOutput struct {
	Body query.PaginatedResponse[db.AuditLog]
}

AuditLogListOutput holds the response body for AuditLogList.

type AuditLogListParams

type AuditLogListParams struct {
	Search     string
	Action     string
	Resource   string
	ActorID    string
	ResourceID string
	Since      string
	Until      string
	SortBy     string
	SortDir    string
	Page       int
	PageSize   int
}

AuditLogListParams holds the filter/sort/pagination inputs for the audit log list. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

func ParseAuditLogListParams

func ParseAuditLogListParams(c *echo.Context) AuditLogListParams

ParseAuditLogListParams extracts AuditLogListParams from query string.

type AuditLogListQuery

type AuditLogListQuery struct {
	Search     string `query:"search" required:"false"`
	Action     string `query:"action" required:"false"`
	Resource   string `query:"resource" required:"false"`
	ActorID    string `query:"actor_id" required:"false"`
	ResourceID string `query:"resource_id" required:"false"`
	Since      string `query:"since" required:"false"`
	Until      string `query:"until" required:"false"`
	SortBy     string `query:"sort_by" required:"false"`
	SortDir    string `query:"sort_dir" required:"false"`
	Page       int    `query:"page" default:"1"`
	PageSize   int    `query:"page_size" default:"25"`
}

AuditLogListQuery holds the filter/sort/pagination inputs for GET /audit-log. The query/default tags drive huma's request binding; the values are mapped into AuditLogListParams for the shared AdminListAuditLog query path.

type AuditLogListResult

type AuditLogListResult struct {
	Items      []db.AuditLog
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

AuditLogListResult holds the paginated result of an audit log list query.

func AdminListAuditLog

func AdminListAuditLog(gdb *gorm.DB, p AuditLogListParams, loc *time.Location) (AuditLogListResult, error)

AdminListAuditLog runs the audit log list query with filters, sort, and pagination. Used by both the JSON API handler and the HTML fragment handler, one query path, two response formats. loc is the app timezone, used to interpret zone-less since/until filter values.

type AutoDistributeResult

type AutoDistributeResult struct {
	Assigned int `json:"assigned"`
	Tutors   int `json:"tutors"`
}

AutoDistributeResult is the response body of the auto distribution.

type BuildChartExercise

type BuildChartExercise struct {
	Exercise    string  `json:"exercise"`
	Total       int64   `json:"total"`
	Failed      int64   `json:"failed"`
	FailureRate float64 `json:"failure_rate"`
}

BuildChartExercise is one bar of the failure-rate chart. FailureRate is Failed/Total in [0,1].

type BuildChartSeries

type BuildChartSeries struct {
	Status string  `json:"status"`
	Counts []int64 `json:"counts"`
}

BuildChartSeries is one status series of the jobs-per-day chart. Counts is aligned with BuildJobChart.Days.

type BuildChartStatus

type BuildChartStatus struct {
	Status string `json:"status"`
	Count  int64  `json:"count"`
}

BuildChartStatus is one slice of the status distribution chart.

type BuildJobChart

type BuildJobChart struct {
	Total         int64                `json:"total"`
	Days          []string             `json:"days"`
	Series        []BuildChartSeries   `json:"series"`
	Statuses      []BuildChartStatus   `json:"statuses"`
	Exercises     []BuildChartExercise `json:"exercises"`
	Since         string               `json:"since,omitempty"`
	Until         string               `json:"until,omitempty"`
	DaysTruncated bool                 `json:"days_truncated"`
}

BuildJobChart is the chart payload embedded in the builds page. Days holds the day labels, Series holds one count slice per status, Statuses holds the totals for the distribution chart, and Exercises holds the failure ranking. The charts are built from the build service's aggregates, so they cover every job matching the page filters rather than one page of rows.

func AdminBuildJobStats

func AdminBuildJobStats(ctx context.Context, gdb *gorm.DB, buildClient *grading.Client, p BuildJobListParams) (BuildJobChart, error)

AdminBuildJobStats runs the aggregate query behind the build charts. It applies the same filters and course scope as the list, but ignores pagination and sorting. The charts therefore cover every job matching the filters, not one page of rows. Day buckets use the app timezone.

func NewBuildJobChart

func NewBuildJobChart(stats grading.JobStats) BuildJobChart

NewBuildJobChart shapes the build service aggregates into the chart payload. Days keep the service order (day ascending). Each status series is zero-filled against those days, and statuses follow buildStatusOrder so the legend stays stable. Unknown statuses are appended in alphabetical order.

type BuildJobListInput

type BuildJobListInput struct {
	BuildJobListQuery
}

BuildJobListInput holds the request parameters for BuildJobsList.

type BuildJobListOutput

type BuildJobListOutput struct {
	Body BuildJobListResponse
}

BuildJobListOutput holds the response body for BuildJobsList.

type BuildJobListParams

type BuildJobListParams struct {
	User      string
	CourseUID string
	Exercise  string
	Kind      string
	Statuses  []string
	Since     string
	Until     string
	Page      int
	PageSize  int
	SortBy    string
	SortDir   string
	// AllTime disables the default creation-time window, so the query
	// covers every job instead of the last 30 days.
	AllTime bool
	// Timezone interprets zone-less since/until values submitted by the
	// date picker. Callers set it to the app timezone; nil falls back to
	// time.Local.
	Timezone *time.Location
}

BuildJobListParams holds the filter/sort/pagination inputs for the build jobs overview. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

User is free text matched against orchestration users (name, oidc_name, email, student_id, preferred_username). Since build jobs carry the historical Forgejo login, the filter resolves current users to their preferred_username values and also passes an unmatched exact login through.

func ParseBuildJobListParams

func ParseBuildJobListParams(c *echo.Context) BuildJobListParams

ParseBuildJobListParams extracts BuildJobListParams from the query string.

type BuildJobListQuery

type BuildJobListQuery struct {
	User      string   `query:"user" required:"false"`
	Student   string   `query:"student" required:"false"`
	CourseUID string   `query:"course_uid" required:"false"`
	Exercise  string   `query:"exercise" required:"false"`
	Kind      string   `query:"kind" required:"false"`
	Status    []string `query:"status" required:"false"`
	Since     string   `query:"since" required:"false"`
	Until     string   `query:"until" required:"false"`
	Page      int      `query:"page" default:"1"`
	PageSize  int      `query:"page_size" default:"25"`
	SortBy    string   `query:"sort_by" required:"false"`
	SortDir   string   `query:"sort_dir" required:"false"`
	Range     string   `query:"range" required:"false"`
}

BuildJobListQuery holds the request parameters for BuildJobsList. The query/default tags drive huma's request binding; the values are mapped into BuildJobListParams for the shared AdminListBuildJobs query path.

type BuildJobListResponse

type BuildJobListResponse struct {
	grading.JobList
	Truncated bool   `json:"truncated"`
	Notice    string `json:"notice"`
}

BuildJobListResponse mirrors the build service's JobList envelope and adds the orchestration-side user-resolution truncation notice, which the build service does not know about.

type BuildJobListResult

type BuildJobListResult struct {
	Items      []grading.Job
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
	Truncated  bool
	Notice     string
}

BuildJobListResult holds the paginated result of a build job list query. Truncated and Notice explain a capped user resolution so the page can tell the operator that only part of the matching logins was used.

func AdminListBuildJobs

func AdminListBuildJobs(ctx context.Context, gdb *gorm.DB, buildClient *grading.Client, p BuildJobListParams) (BuildJobListResult, error)

AdminListBuildJobs runs the build jobs overview query. It resolves the user filter to Forgejo logins, applies the caller's course scope, and fetches one page from the build service. The build service owns the job data; this function only decides which logins and courses the caller may see.

Admins see every course. Staff are restricted to the courses they own or hold a course_accesses grant on. An empty scope returns an empty result without calling the build service. The All Time range drops any since/until values so the date pickers cannot make it inert.

type BulkAssignTutorBody

type BulkAssignTutorBody struct {
	UserIDs []string `json:"user_ids" required:"true"`
	TutorID *uint    `json:"tutor_id" required:"false"`
}

BulkAssignTutorBody is the body for POST /courses/{id}/students/tutor. An absent or null tutor_id clears the assignment for all listed users.

type BulkAssignTutorResult

type BulkAssignTutorResult struct {
	Assigned int `json:"assigned"`
}

BulkAssignTutorResult is the response body of the bulk tutor assignment.

type CLIVersionInput

type CLIVersionInput struct{}

CLIVersionInput holds the request parameters for CLIVersion (none).

type CLIVersionOutput

type CLIVersionOutput struct {
	Body cliVersionResponse
}

CLIVersionOutput holds the response body for CLIVersion.

type ChartsCSVOutput

type ChartsCSVOutput struct {
	ContentType        string `header:"Content-Type"`
	ContentDisposition string `header:"Content-Disposition"`
	Body               []byte
}

ChartsCSVOutput holds the response for ChartsCSV. The headers are bound via huma's output header fields so the raw CSV body keeps its content type.

type ChartsInput

type ChartsInput struct {
	CourseID uint64 `query:"course_id" required:"false"`
}

ChartsInput holds the request parameters for Charts and ChartsCSV.

type ChartsOutput

type ChartsOutput struct {
	Body ChartsResponse
}

ChartsOutput holds the response body for Charts.

type ChartsResponse

type ChartsResponse struct {
	UsersByFaculty        []LabelCount       `json:"users_by_faculty"`
	RegistrationsOverTime []TimeSeriesPoint  `json:"registrations_over_time"`
	LoginsByDay           []TimeSeriesPoint  `json:"logins_by_day"`
	LoginsByHour          []LabelCount       `json:"logins_by_hour"`
	LoginsByWeekday       []LabelCount       `json:"logins_by_weekday"`
	AuditActivityOverTime []TimeSeries       `json:"audit_activity_over_time"`
	ForgejoOverTime       []ForgejoTimePoint `json:"forgejo_over_time"`
	CoursesPerSemester    []LabelCount       `json:"courses_per_semester"`
	StudentsPerTutor      []LabelCount       `json:"students_per_tutor"`
	GradeDistPerExercise  []GradeBucket      `json:"grade_distribution_per_exercise"`
	AvgScorePerExercise   []LabelCount       `json:"average_score_per_exercise"`
	GradedVsUngraded      []GradedUngraded   `json:"graded_vs_ungraded_per_exercise"`
	GradesByWeek          []TimeSeriesPoint  `json:"grades_by_week"`
	AttendancePerWeek     []TimeSeriesPoint  `json:"attendance_per_week"`
	PresentedVsAttended   []LabelCount       `json:"presented_vs_attended"`
	EnrollmentsByFaculty  []LabelCount       `json:"enrollments_by_faculty"`
}

ChartsResponse contains all chart datasets for the stats page.

type CourseAccessForCourseGrantInput

type CourseAccessForCourseGrantInput struct {
	ID   string `path:"id"`
	User string `path:"user"`
}

CourseAccessForCourseGrantInput holds the request parameters for CourseAccessForCourseGrant.

type CourseAccessForCourseGrantOutput

type CourseAccessForCourseGrantOutput struct {
	Body CourseAccessOut
}

CourseAccessForCourseGrantOutput holds the response body for CourseAccessForCourseGrant.

type CourseAccessForCourseListInput

type CourseAccessForCourseListInput struct {
	ID string `path:"id"`
}

CourseAccessForCourseListInput holds the request parameters for CourseAccessForCourseList.

type CourseAccessForCourseListOutput

type CourseAccessForCourseListOutput struct {
	Body []CourseAccessOut
}

CourseAccessForCourseListOutput holds the response body for CourseAccessForCourseList.

type CourseAccessForCourseRevokeInput

type CourseAccessForCourseRevokeInput struct {
	ID   string `path:"id"`
	User string `path:"user"`
}

CourseAccessForCourseRevokeInput holds the request parameters for CourseAccessForCourseRevoke.

type CourseAccessForCourseRevokeOutput

type CourseAccessForCourseRevokeOutput struct {
	Status int
}

CourseAccessForCourseRevokeOutput holds the response status for CourseAccessForCourseRevoke.

type CourseAccessOut

type CourseAccessOut struct {
	ID        uint   `json:"id"`
	CourseID  uint   `json:"course_id"`
	UserID    string `json:"user_id"`
	GrantedBy string `json:"granted_by"`
}

CourseAccessOut is the public shape of a course_accesses grant.

type CourseBody

type CourseBody struct {
	Name         string `json:"name"`
	Semester     string `json:"semester"`
	DisplayName  string `json:"display_name" required:"false"`
	Website      string `json:"website" required:"false"`
	BuilderImage string `json:"builder_image" required:"false"`
	GraderImage  string `json:"grader_image" required:"false"`
	AllowPush    bool   `json:"allow_push" required:"false"`
	AllowJoin    bool   `json:"allow_join" required:"false"`
	// PassPercent and PassBasis configure the Studienleistung threshold.
	PassPercent float64 `json:"pass_percent" required:"false"`
	PassBasis   string  `json:"pass_basis" required:"false"`
	RepoAccess  string  `json:"repo_access" required:"false"`
	OwnerID     string  `json:"owner_id" required:"false"`
}

CourseBody is the request body for creating and updating courses. The id and timestamp fields are server-managed and not part of the payload. owner_id is accepted on create (admins may set it) and ignored on update.

type CourseBrief

type CourseBrief struct {
	ID          uint   `json:"id"`
	Name        string `json:"name"`
	Semester    string `json:"semester"`
	DisplayName string `json:"display_name"`
}

CourseBrief is a minimal representation of a course for the admin UI.

func ManagedCourses

func ManagedCourses(gdb *gorm.DB, ownerID string, isAdmin bool) []CourseBrief

ManagedCourses returns the courses the caller may manage, for filter dropdowns: all courses for admins, owned and granted courses for staff.

func VisibleCourses

func VisibleCourses(gdb *gorm.DB, ownerID string, isAdmin bool) []CourseBrief

VisibleCourses returns the courses the caller can see, for filter dropdowns: all courses for admins, owned and granted courses for staff.

type CourseListQuery

type CourseListQuery struct {
	Search    string `query:"search" required:"false"`
	AllowJoin string `query:"allow_join" required:"false"`
	AllowPush string `query:"allow_push" required:"false"`
	Archived  string `query:"archived" required:"false"`
	Name      string `query:"name" required:"false"`
	Display   string `query:"display_name" required:"false"`
	Semester  string `query:"semester" required:"false"`
	SortBy    string `query:"sort_by" required:"false"`
	SortDir   string `query:"sort_dir" required:"false"`
	Page      int    `query:"page" default:"1"`
	PageSize  int    `query:"page_size" default:"25"`
}

CourseListQuery holds the filter/sort/pagination inputs for GET /courses. The query/default tags drive huma's request binding; the values are mapped into CoursesListParams for the shared AdminListCourses query path. The boolean filters are strings because huma does not support pointer query parameters; boolParam converts them below.

type CourseStudentBuilds

type CourseStudentBuilds struct {
	Builds []StudentBuild `json:"builds"`
}

CourseStudentBuilds is the build status summary for one student in one course. It only contains the latest build job per exercise, so a later successful build clears an older failure.

type CourseStudentBuildsInput

type CourseStudentBuildsInput struct {
	CourseSlug string `path:"courseSlug"`
	User       string `path:"user"`
}

CourseStudentBuildsInput holds the request parameters for CourseStudentBuilds.

type CourseStudentBuildsOutput

type CourseStudentBuildsOutput struct {
	Body CourseStudentBuilds
}

CourseStudentBuildsOutput holds the response body for CourseStudentBuilds.

type CourseStudentGradesInput

type CourseStudentGradesInput struct {
	CourseSlug string `path:"courseSlug"`
	User       string `path:"user"`
}

CourseStudentGradesInput holds the request parameters for CourseStudentGrades. The course is addressed by its UID (Semester + "-" + Name, the Forgejo org name) and the student by a user reference: ID, Forgejo username, or me/mine/my.

type CourseStudentGradesOutput

type CourseStudentGradesOutput struct {
	Body []GradeItem
}

CourseStudentGradesOutput holds the response body for CourseStudentGrades.

type CourseStudentListParams

type CourseStudentListParams struct {
	Search   string
	TutorID  string
	SortBy   string
	SortDir  string
	Page     int
	PageSize int
}

CourseStudentListParams holds the filter/sort/pagination inputs for the course students list. Shared by the huma handler and any other caller of ListCourseStudents.

func CourseStudentListParamsFromPost

func CourseStudentListParamsFromPost(c *echo.Context) CourseStudentListParams

courseStudentListParamsFromPost builds the params from an htmx POST body that included the filter form (#students-filters): the tab field marks the body as carrying filter state. The bulk_tutor_id and row_tutor_id fields are the assignment targets and are never read as filters; a GET query fallback covers clients that posted without the filter form.

func ParseCourseStudentListParams

func ParseCourseStudentListParams(c *echo.Context) CourseStudentListParams

ParseCourseStudentListParams extracts CourseStudentListParams from the query string, following the same pattern as ParseUsersAdminListParams.

type CourseStudentListQuery

type CourseStudentListQuery struct {
	Search   string `query:"search" required:"false"`
	TutorID  string `query:"tutor_id" required:"false"`
	SortBy   string `query:"sort_by" required:"false"`
	SortDir  string `query:"sort_dir" required:"false"`
	Page     int    `query:"page" default:"1"`
	PageSize int    `query:"page_size" default:"25"`
}

CourseStudentListQuery holds the pagination and filter inputs for the course students list endpoint. The query/default tags drive huma's request binding; the values are mapped into CourseStudentListParams for the shared ListCourseStudents query path.

type CourseStudentListResult

type CourseStudentListResult struct {
	Items      []StudentOut
	Page       int
	PageSize   int
	TotalItems int64
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

CourseStudentListResult holds the paginated result of a course students list query.

func ListCourseStudents

func ListCourseStudents(gdb *gorm.DB, courseID uint, params CourseStudentListParams) (CourseStudentListResult, error)

ListCourseStudents runs the course students list query for one course and returns enriched items with pagination metadata. Raw joins are used so the search and sort fields can come from the users and tutors tables; students whose user row is soft-deleted still appear (their User brief is nil). Email is filled from the preloaded user map; empty for soft-deleted users.

type CourseStudentPoints

type CourseStudentPoints struct {
	Exercises        []GradeItem     `json:"exercises"`
	Tutorial         TutorialPoints  `json:"tutorial"`
	Total            PointsTotal     `json:"total"`
	Studienleistung  Studienleistung `json:"studienleistung"`
	PendingExercises int             `json:"pending_exercises"`
}

CourseStudentPoints is the repo page points summary for one student in one course. Exercises contains every exercise, including future ones, so the per-folder grading column can still render countdowns. Total only counts exercises whose deadline has passed.

type CourseStudentPointsInput

type CourseStudentPointsInput struct {
	CourseSlug string `path:"courseSlug"`
	User       string `path:"user"`
}

CourseStudentPointsInput holds the request parameters for CourseStudentPoints. The course is addressed by its UID and the student by a user reference: ID, Forgejo username, or me/mine/my.

type CourseStudentPointsOutput

type CourseStudentPointsOutput struct {
	Body CourseStudentPoints
}

CourseStudentPointsOutput holds the response body for CourseStudentPoints.

type CourseTutorListQuery

type CourseTutorListQuery struct {
	SortBy   string `query:"sort_by" required:"false" sort:"id,created_at" default_sort:"id asc"`
	SortDir  string `query:"sort_dir" required:"false"`
	Page     int    `query:"page" default:"1"`
	PageSize int    `query:"page_size" default:"25"`
}

CourseTutorListQuery holds the pagination inputs for the course tutors list endpoint. The query/default tags drive huma's request binding; the sort/default_sort tags are ignored by huma and consumed by query.Scopes.

type CoursesCreateInput

type CoursesCreateInput struct {
	Body CourseBody
}

type CoursesCreateOutput

type CoursesCreateOutput struct {
	Body db.Course
}

CoursesCreateOutput holds the response body for CoursesCreate.

type CoursesDeleteInput

type CoursesDeleteInput struct {
	ID string `path:"id"`
}

type CoursesDeleteOutput

type CoursesDeleteOutput struct {
	Status int
}

CoursesDeleteOutput holds the response status for CoursesDelete.

type CoursesGetInput

type CoursesGetInput struct {
	ID string `path:"id"`
}

CoursesGetInput holds the request parameters for CoursesGet.

type CoursesGetOutput

type CoursesGetOutput struct {
	Body db.Course
}

CoursesGetOutput holds the response body for CoursesGet.

type CoursesHardDeleteInput

type CoursesHardDeleteInput struct {
	ID string `path:"id"`
}

type CoursesHardDeleteOutput

type CoursesHardDeleteOutput struct {
	Status int
}

CoursesHardDeleteOutput holds the response status for CoursesHardDelete.

type CoursesJoinInput

type CoursesJoinInput struct {
	ID string `path:"id"`
}

CoursesJoinInput holds the request parameters for CoursesJoin.

type CoursesJoinOutput

type CoursesJoinOutput struct {
	Body db.Student
}

CoursesJoinOutput holds the response body for CoursesJoin.

type CoursesListInput

type CoursesListInput struct {
	CourseListQuery
}

CoursesListInput holds the request parameters for CoursesList.

type CoursesListOutput

type CoursesListOutput struct {
	Body query.PaginatedResponse[db.Course]
}

CoursesListOutput holds the response body for CoursesList.

type CoursesListParams

type CoursesListParams struct {
	Search    string
	AllowJoin *bool
	AllowPush *bool
	Archived  *bool
	Name      string
	Display   string
	Semester  string
	SortBy    string
	SortDir   string
	Page      int
	PageSize  int
}

CoursesListParams holds the filter/sort/pagination inputs for the admin courses list. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

func ParseCoursesListParams

func ParseCoursesListParams(c *echo.Context) CoursesListParams

ParseCoursesListParams extracts CoursesListParams from query string. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

type CoursesListResult

type CoursesListResult struct {
	Items      []db.Course
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

CoursesListResult holds the paginated result of an admin courses list query.

func AdminListCourses

func AdminListCourses(gdb *gorm.DB, p CoursesListParams) (CoursesListResult, error)

AdminListCourses runs the courses list query with filters, sort, and pagination. Used by both the JSON API handler and the HTML fragment handler, one query path, two response formats. Always returns both active and archived courses (use Archived to filter).

type CoursesPaletteSearchInput

type CoursesPaletteSearchInput struct {
	Q string `query:"q" required:"false" maxLength:"128"`
}

CoursesPaletteSearchInput holds the query for CoursesPaletteSearch.

type CoursesPaletteSearchOutput

type CoursesPaletteSearchOutput struct {
	Body []PaletteCourse
}

CoursesPaletteSearchOutput holds the response body for CoursesPaletteSearch.

type CoursesRestoreInput

type CoursesRestoreInput struct {
	ID string `path:"id"`
}

type CoursesRestoreOutput

type CoursesRestoreOutput struct {
	Body db.Course
}

CoursesRestoreOutput holds the response body for CoursesRestore.

type CoursesStudentsAssignTutorBulkInput

type CoursesStudentsAssignTutorBulkInput struct {
	ID   string `path:"id"`
	Body BulkAssignTutorBody
}

CoursesStudentsAssignTutorBulkInput holds the request parameters for CoursesStudentsAssignTutorBulk.

type CoursesStudentsAssignTutorBulkOutput

type CoursesStudentsAssignTutorBulkOutput struct {
	Body BulkAssignTutorResult
}

CoursesStudentsAssignTutorBulkOutput holds the response body for CoursesStudentsAssignTutorBulk.

type CoursesStudentsAutoDistributeInput

type CoursesStudentsAutoDistributeInput struct {
	ID string `path:"id"`
}

CoursesStudentsAutoDistributeInput holds the request parameters for CoursesStudentsAutoDistribute.

type CoursesStudentsAutoDistributeOutput

type CoursesStudentsAutoDistributeOutput struct {
	Body AutoDistributeResult
}

CoursesStudentsAutoDistributeOutput holds the response body for CoursesStudentsAutoDistribute.

type CoursesStudentsEnrollInput

type CoursesStudentsEnrollInput struct {
	ID   string `path:"id"`
	Body EnrollStudentBody
}

CoursesStudentsEnrollInput holds the request parameters for CoursesStudentsEnroll.

type CoursesStudentsEnrollOutput

type CoursesStudentsEnrollOutput struct {
	Body StudentOut
}

CoursesStudentsEnrollOutput holds the response body for CoursesStudentsEnroll.

type CoursesStudentsListInput

type CoursesStudentsListInput struct {
	ID string `path:"id"`
	CourseStudentListQuery
}

CoursesStudentsListInput holds the request parameters for CoursesStudentsList.

type CoursesStudentsListOutput

type CoursesStudentsListOutput struct {
	Body query.PaginatedResponse[StudentOut]
}

CoursesStudentsListOutput holds the response body for CoursesStudentsList.

type CoursesStudentsSetTutorInput

type CoursesStudentsSetTutorInput struct {
	ID   string `path:"id"`
	User string `path:"user"`
	Body SetStudentTutorBody
}

CoursesStudentsSetTutorInput holds the request parameters for CoursesStudentsSetTutor.

type CoursesStudentsSetTutorOutput

type CoursesStudentsSetTutorOutput struct {
	Body StudentOut
}

CoursesStudentsSetTutorOutput holds the response body for CoursesStudentsSetTutor.

type CoursesStudentsUnassignInput

type CoursesStudentsUnassignInput struct {
	ID   string `path:"id"`
	User string `path:"user"`
}

CoursesStudentsUnassignInput holds the request parameters for CoursesStudentsUnassign.

type CoursesStudentsUnassignOutput

type CoursesStudentsUnassignOutput struct {
	Status int
}

CoursesStudentsUnassignOutput holds the response status for CoursesStudentsUnassign.

type CoursesTutorForUserInput

type CoursesTutorForUserInput struct {
	CourseID string `path:"course_id"`
	User     string `path:"user"`
}

CoursesTutorForUserInput holds the request parameters for CoursesTutorForUser.

type CoursesTutorForUserOutput

type CoursesTutorForUserOutput struct {
	Body TutorAssignmentOut
}

CoursesTutorForUserOutput holds the response body for CoursesTutorForUser.

type CoursesTutorStudentsInput

type CoursesTutorStudentsInput struct {
	ID      string `path:"id"`
	TutorID string `path:"tutor_id"`
}

CoursesTutorStudentsInput holds the request parameters for CoursesTutorStudents.

type CoursesTutorStudentsOutput

type CoursesTutorStudentsOutput struct {
	Body []StudentOut
}

CoursesTutorStudentsOutput holds the response body for CoursesTutorStudents.

type CoursesTutorsAssignInput

type CoursesTutorsAssignInput struct {
	ID   string `path:"id"`
	Body AssignTutorBody
}

CoursesTutorsAssignInput holds the request parameters for CoursesTutorsAssign.

type CoursesTutorsAssignOutput

type CoursesTutorsAssignOutput struct {
	Body TutorOut
}

CoursesTutorsAssignOutput holds the response body for CoursesTutorsAssign.

type CoursesTutorsListInput

type CoursesTutorsListInput struct {
	ID string `path:"id"`
	CourseTutorListQuery
}

CoursesTutorsListInput holds the request parameters for CoursesTutorsList.

type CoursesTutorsListOutput

type CoursesTutorsListOutput struct {
	Body query.PaginatedResponse[TutorOut]
}

CoursesTutorsListOutput holds the response body for CoursesTutorsList.

type CoursesTutorsUnassignInput

type CoursesTutorsUnassignInput struct {
	ID   string `path:"id"`
	User string `path:"user"`
}

CoursesTutorsUnassignInput holds the request parameters for CoursesTutorsUnassign.

type CoursesTutorsUnassignOutput

type CoursesTutorsUnassignOutput struct {
	Status int
}

CoursesTutorsUnassignOutput holds the response status for CoursesTutorsUnassign.

type CoursesUpdateInput

type CoursesUpdateInput struct {
	ID   string `path:"id"`
	Body CourseBody
}

type CoursesUpdateOutput

type CoursesUpdateOutput struct {
	Body db.Course
}

CoursesUpdateOutput holds the response body for CoursesUpdate.

type CreateUserBody

type CreateUserBody struct {
	Email string `json:"email" required:"false"`
	Name  string `json:"name"`
	// OidcName carries the IdP-provided name. Imports use it so a legal
	// name does not become the admin-managed display name. Unlike the update
	// path this body is mapped field by field, not through query.BodyMap.
	OidcName          string  `json:"oidc_name" required:"false"`
	Subject           string  `json:"subject" required:"false"`
	PreferredUsername string  `json:"preferred_username" required:"false"`
	StudentID         string  `json:"student_id" required:"false"`
	AccountType       string  `json:"account_type" required:"false"`
	Faculty           string  `json:"faculty" required:"false"`
	EnrolledSubject   string  `json:"enrolled_subject" required:"false"`
	ExtraClaims       string  `json:"extra_claims" required:"false"`
	Role              db.Role `json:"role" required:"false"`
}

CreateUserBody is the request body for creating a user. The id and the timestamp fields are server-managed and not part of the payload.

type EnrollStudentBody

type EnrollStudentBody struct {
	UserID string `json:"user_id"`
}

EnrollStudentBody is the body for POST /courses/{id}/students.

type ExerciseBody

type ExerciseBody struct {
	Name           string     `json:"name"`
	Start          time.Time  `json:"start"`
	End            time.Time  `json:"end"`
	Points         *float64   `json:"points" required:"false"`
	TutorialPoints *float64   `json:"tutorial_points" required:"false"`
	TutorialStart  *time.Time `json:"tutorial_start" required:"false"`
	TutorialEnd    *time.Time `json:"tutorial_end" required:"false"`
}

ExerciseBody is the request body for creating and updating exercises. All fields are always submitted, matching the admin UI form which sends the full set on every save.

type ExerciseOut

type ExerciseOut struct {
	ID             uint       `json:"id"`
	Name           string     `json:"name"`
	Start          time.Time  `json:"start"`
	End            time.Time  `json:"end"`
	Points         *float64   `json:"points"`
	TutorialPoints *float64   `json:"tutorial_points"`
	TutorialStart  *time.Time `json:"tutorial_start"`
	TutorialEnd    *time.Time `json:"tutorial_end"`
	CourseID       uint       `json:"course_id"`
}

ExerciseOut is the public shape of an exercise returned by the build/ grading lookup endpoint. It mirrors the subset of db.Exercise that an external consumer (the build/grading service) needs to decide whether a build is eligible and to pick a pre-deadline commit. It is a separate type from db.Exercise so we never accidentally leak internal fields.

type ExercisesCreateInput

type ExercisesCreateInput struct {
	ID   string `path:"id"`
	Body ExerciseBody
}

ExercisesCreateInput holds the request parameters for ExercisesCreate.

type ExercisesCreateOutput

type ExercisesCreateOutput struct {
	Body db.Exercise
}

ExercisesCreateOutput holds the response body for ExercisesCreate.

type ExercisesDeleteInput

type ExercisesDeleteInput struct {
	ID  string `path:"id"`
	EID string `path:"eid"`
}

ExercisesDeleteInput holds the request parameters for ExercisesDelete.

type ExercisesDeleteOutput

type ExercisesDeleteOutput struct {
	Status int
}

ExercisesDeleteOutput holds the response status for ExercisesDelete.

type ExercisesListInput

type ExercisesListInput struct {
	ID string `path:"id"`
}

ExercisesListInput holds the request parameters for ExercisesList.

type ExercisesListOutput

type ExercisesListOutput struct {
	Body []ExerciseOut
}

ExercisesListOutput holds the response body for ExercisesList.

type ExercisesPaletteSearchInput

type ExercisesPaletteSearchInput struct {
	Q string `query:"q" required:"false" maxLength:"128"`
}

ExercisesPaletteSearchInput holds the query for ExercisesPaletteSearch.

type ExercisesPaletteSearchOutput

type ExercisesPaletteSearchOutput struct {
	Body []PaletteExercise
}

ExercisesPaletteSearchOutput holds the response body for ExercisesPaletteSearch.

type ExercisesUpdateInput

type ExercisesUpdateInput struct {
	ID   string `path:"id"`
	EID  string `path:"eid"`
	Body ExerciseBody
}

ExercisesUpdateInput holds the request parameters for ExercisesUpdate.

type ExercisesUpdateOutput

type ExercisesUpdateOutput struct {
	Body db.Exercise
}

ExercisesUpdateOutput holds the response body for ExercisesUpdate.

type ForgejoRequestFacets

type ForgejoRequestFacets struct {
	Sources []string `json:"sources"`
	Methods []string `json:"methods"`
}

ForgejoRequestFacets is the response body of GET /forgejo-requests/facets. Each field carries the distinct values currently present in the forgejo_requests table, sorted ascending; the UI uses them to populate filter dropdowns.

type ForgejoRequestListParams

type ForgejoRequestListParams struct {
	Search    string
	Source    string
	Method    string
	MinStatus string
	MaxStatus string
	Since     string
	Until     string
	SortBy    string
	SortDir   string
	Page      int
	PageSize  int
}

ForgejoRequestListParams holds the filter/sort/pagination inputs for the Forgejo request log list. Shared by the JSON API handler, the HTML fragment handler, and the page handler.

func ParseForgejoRequestListParams

func ParseForgejoRequestListParams(c *echo.Context) ForgejoRequestListParams

ParseForgejoRequestListParams extracts ForgejoRequestListParams from query string.

type ForgejoRequestListQuery

type ForgejoRequestListQuery struct {
	Search    string `query:"search" required:"false"`
	Source    string `query:"source" required:"false"`
	Method    string `query:"method" required:"false"`
	MinStatus string `query:"min_status" required:"false"`
	MaxStatus string `query:"max_status" required:"false"`
	Since     string `query:"since" required:"false"`
	Until     string `query:"until" required:"false"`
	SortBy    string `query:"sort_by" required:"false"`
	SortDir   string `query:"sort_dir" required:"false"`
	Page      int    `query:"page" default:"1"`
	PageSize  int    `query:"page_size" default:"25"`
}

ForgejoRequestListQuery holds the filter/sort/pagination inputs for GET /forgejo-requests. The query/default tags drive huma's request binding; the values are mapped into ForgejoRequestListParams for the shared AdminListForgejoRequests query path.

type ForgejoRequestListResult

type ForgejoRequestListResult struct {
	Items      []db.ForgejoRequest
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

ForgejoRequestListResult holds the paginated result of a Forgejo request list query.

func AdminListForgejoRequests

func AdminListForgejoRequests(gdb *gorm.DB, p ForgejoRequestListParams, loc *time.Location) (ForgejoRequestListResult, error)

AdminListForgejoRequests runs the Forgejo request list query with filters, sort, and pagination. Used by both the JSON API handler and the HTML fragment handler.

type ForgejoRequestsFacetsInput

type ForgejoRequestsFacetsInput struct{}

ForgejoRequestsFacetsInput has no request parameters.

type ForgejoRequestsFacetsOutput

type ForgejoRequestsFacetsOutput struct {
	Body ForgejoRequestFacets
}

ForgejoRequestsFacetsOutput holds the response body for ForgejoRequestsFacets.

type ForgejoRequestsListInput

type ForgejoRequestsListInput struct {
	ForgejoRequestListQuery
}

ForgejoRequestsListInput holds the request parameters for ForgejoRequestsList.

type ForgejoRequestsListOutput

type ForgejoRequestsListOutput struct {
	Body query.PaginatedResponse[db.ForgejoRequest]
}

ForgejoRequestsListOutput holds the response body for ForgejoRequestsList.

type ForgejoTimePoint

type ForgejoTimePoint struct {
	Date       string `json:"date"`
	Success    int64  `json:"success"`
	Error      int64  `json:"error"`
	AvgLatency int64  `json:"avg_latency_ms"`
}

ForgejoTimePoint combines request counts and latency for a single day.

type GradeBucket

type GradeBucket struct {
	Exercise string `json:"exercise"`
	Bucket   string `json:"bucket"`
	Count    int64  `json:"count"`
}

GradeBucket is one bucket of the grade-distribution histogram for an exercise.

type GradeItem

type GradeItem struct {
	ExerciseName string   `json:"exercise_name"`
	CourseName   string   `json:"course_name"`
	CourseSlug   string   `json:"course_slug"`
	CourseID     uint     `json:"course_id"`
	ExerciseID   uint     `json:"exercise_id"`
	Points       *float64 `json:"points"`
	MaxPoints    *float64 `json:"max_points"`
	// TutorialPoints is the exercise's tutorial maximum. TutorialAttended
	// reports whether the student attended that exercise's tutorial.
	TutorialPoints   *float64   `json:"tutorial_points"`
	TutorialAttended bool       `json:"tutorial_attended"`
	GradedAt         *time.Time `json:"graded_at"`
	Start            time.Time  `json:"start"`
	End              time.Time  `json:"end"`
}

GradeItem is one exercise entry for the /users/{user}/grades overview. Unlike RecentGradeItem it also covers exercises that have not been graded yet (no student_exercises row, or one with NULL points): for those points and graded_at are null. Start/End are the exercise's time window so the frontend can render countdowns to the deadline.

type GradedUngraded

type GradedUngraded struct {
	Exercise string `json:"exercise"`
	Graded   int64  `json:"graded"`
	Ungraded int64  `json:"ungraded"`
}

GradedUngraded pairs graded and ungraded counts for a single exercise.

type HTTPRequestChart

type HTTPRequestChart struct {
	Range  string                  `json:"range"`
	Bucket string                  `json:"bucket"`
	Since  string                  `json:"since"`
	Until  string                  `json:"until"`
	Points []HTTPRequestChartPoint `json:"points"`
}

HTTPRequestChart is the time series backing the inbound request chart. Range is the resolved timeframe ("1h" ... "30d", or "custom" when pinned by an explicit since/until bound) and Bucket is the aggregation granularity chosen from the width of that window, so a short window does not collapse into a single bar.

func AdminHTTPRequestChart

func AdminHTTPRequestChart(gdb *gorm.DB, p HTTPRequestListParams, loc *time.Location, now time.Time) (HTTPRequestChart, error)

AdminHTTPRequestChart aggregates the filtered requests into a time series of status classes plus latency. The chart applies the same non-time filters as the list and the same resolved window, so the graph always matches the table.

type HTTPRequestChartPoint

type HTTPRequestChartPoint struct {
	Bucket       string `json:"bucket"`
	Success      int64  `json:"success"`      // 2xx
	Redirect     int64  `json:"redirect"`     // 3xx
	ClientError  int64  `json:"client_error"` // 4xx
	ServerError  int64  `json:"server_error"` // 5xx
	Other        int64  `json:"other"`        // anything outside 2xx-5xx
	AvgLatencyMS int64  `json:"avg_latency_ms"`
	MaxLatencyMS int64  `json:"max_latency_ms"`
}

HTTPRequestChartPoint is one time bucket of the inbound request chart. The status classes are disjoint and cover every recorded status code, and the latency values are the mean and maximum over the bucket.

type HTTPRequestFacets

type HTTPRequestFacets struct {
	Methods []string `json:"methods"`
}

HTTPRequestFacets is the response body of GET /http-requests/facets.

type HTTPRequestGetInput

type HTTPRequestGetInput struct {
	ID string `path:"id"`
}

HTTPRequestGetInput holds the request parameters for HTTPRequestGet.

type HTTPRequestGetOutput

type HTTPRequestGetOutput struct {
	Body db.HTTPRequest
}

HTTPRequestGetOutput holds the response body for HTTPRequestGet.

type HTTPRequestListParams

type HTTPRequestListParams struct {
	Search      string
	Method      string
	Path        string
	StatusClass string // 2xx, 3xx, 4xx, 5xx, or other
	MinStatus   string
	MaxStatus   string
	Range       string // timeframe preset: 1h, 6h, 12h, 24h, 7d, or 30d
	Since       string
	Until       string
	SortBy      string
	SortDir     string
	Page        int
	PageSize    int
}

HTTPRequestListParams holds the filter/sort/pagination inputs for the inbound HTTP request log list. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

func ParseHTTPRequestListParams

func ParseHTTPRequestListParams(c *echo.Context) HTTPRequestListParams

ParseHTTPRequestListParams extracts HTTPRequestListParams from the query string.

type HTTPRequestListQuery

type HTTPRequestListQuery struct {
	Search      string `query:"search" required:"false"`
	Method      string `query:"method" required:"false"`
	Path        string `query:"path" required:"false"`
	StatusClass string `query:"status_class" required:"false"`
	MinStatus   string `query:"min_status" required:"false"`
	MaxStatus   string `query:"max_status" required:"false"`
	Range       string `` /* 172-byte string literal not displayed */
	Since       string `query:"since" required:"false"`
	Until       string `query:"until" required:"false"`
	SortBy      string `query:"sort_by" required:"false"`
	SortDir     string `query:"sort_dir" required:"false"`
	Page        int    `query:"page" default:"1"`
	PageSize    int    `query:"page_size" default:"25"`
}

HTTPRequestListQuery holds the filter/sort/pagination inputs for GET /http-requests. The query/default tags drive huma's request binding; the values are mapped into HTTPRequestListParams for the shared AdminListHTTPRequests query path.

type HTTPRequestListResult

type HTTPRequestListResult struct {
	Items      []HTTPRequestSummary
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

HTTPRequestListResult holds the paginated result of an HTTP request list query.

func AdminListHTTPRequests

func AdminListHTTPRequests(gdb *gorm.DB, p HTTPRequestListParams, loc *time.Location, now time.Time) (HTTPRequestListResult, error)

AdminListHTTPRequests runs the HTTP request list query with filters, sort, and pagination. Used by both the JSON API handler and the HTML fragment handler. loc is the app timezone, used to interpret zone-less since/until filter values. The same resolved window as the chart is applied, so the table and the graph always cover the same period.

type HTTPRequestRange

type HTTPRequestRange struct {
	Value string // query value, e.g. "1h"
	Label string // UI label, e.g. "Last hour"
	Width time.Duration
}

HTTPRequestRange is one selectable timeframe for the inbound request log. The window is anchored on now and covers Width, so the list and the chart always describe the same period.

type HTTPRequestSummary

type HTTPRequestSummary struct {
	ID         uint      `json:"id"`
	CreatedAt  time.Time `json:"created_at"`
	Method     string    `json:"method"`
	Path       string    `json:"path"`
	StatusCode int       `json:"status_code"`
	DurationMS int64     `json:"duration_ms"`
	IP         string    `json:"ip"`
	UserAgent  string    `json:"user_agent"`
	UserID     string    `json:"user_id"`
	UserEmail  string    `json:"user_email"`
	Role       string    `json:"role"`
}

HTTPRequestSummary is the metadata view of an inbound request, used by the list API, the admin page, and the htmx table fragment. The captured 5xx detail (bodies) is deliberately absent so a list response can never carry one; the detail endpoint returns the full row.

type HTTPRequestWindow

type HTTPRequestWindow struct {
	Range  string // preset value, or "custom" when pinned by since/until
	Since  time.Time
	Until  time.Time
	Bucket string
}

HTTPRequestWindow is the resolved time window shared by the request log list and its chart, plus the aggregation granularity chosen for the chart.

func ResolveHTTPRequestWindow

func ResolveHTTPRequestWindow(p HTTPRequestListParams, loc *time.Location, now time.Time) HTTPRequestWindow

ResolveHTTPRequestWindow resolves the window and bucket for a set of request log filters. The range preset (or the default when it is unset or unknown) sets the window width; an explicit since or until bound overrides the corresponding preset bound, which is the "custom range" mode of the filter form. A reversed or degenerate window falls back to the default width so the chart cannot end up empty because of a bad bound.

type HTTPRequestsChartInput

type HTTPRequestsChartInput struct {
	HTTPRequestsChartQuery
}

HTTPRequestsChartInput holds the request parameters for HTTPRequestsChart.

type HTTPRequestsChartOutput

type HTTPRequestsChartOutput struct {
	Body HTTPRequestChart
}

HTTPRequestsChartOutput holds the response body for HTTPRequestsChart.

type HTTPRequestsChartQuery

type HTTPRequestsChartQuery struct {
	Search      string `query:"search" required:"false"`
	Method      string `query:"method" required:"false"`
	Path        string `query:"path" required:"false"`
	StatusClass string `query:"status_class" required:"false"`
	MinStatus   string `query:"min_status" required:"false"`
	MaxStatus   string `query:"max_status" required:"false"`
	Range       string `` /* 172-byte string literal not displayed */
	Since       string `query:"since" required:"false"`
	Until       string `query:"until" required:"false"`
}

HTTPRequestsChartQuery holds the filter inputs for the chart endpoint. It carries the same filters as the list so the chart matches the table.

type HTTPRequestsFacetsInput

type HTTPRequestsFacetsInput struct{}

HTTPRequestsFacetsInput has no request parameters.

type HTTPRequestsFacetsOutput

type HTTPRequestsFacetsOutput struct {
	Body HTTPRequestFacets
}

HTTPRequestsFacetsOutput holds the response body for HTTPRequestsFacets.

type HTTPRequestsListInput

type HTTPRequestsListInput struct {
	HTTPRequestListQuery
}

HTTPRequestsListInput holds the request parameters for HTTPRequestsList.

type HTTPRequestsListOutput

type HTTPRequestsListOutput struct {
	Body query.PaginatedResponse[HTTPRequestSummary]
}

HTTPRequestsListOutput holds the response body for HTTPRequestsList.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(a *app.App, hu *Huma) *Handler

func (*Handler) AttendanceHandler

func (h *Handler) AttendanceHandler(c *echo.Context) error

AttendanceHandler handles POST /api/attendance. A tutor scans a student's QR code (which encodes the student's user ID); this logs a TutorialParticipation record for today. The caller must be a tutor of the given course.

A student can attend at most one tutorial per exercise, no matter which tutor logged the participation. The acting tutor's own row for today is updated idempotently instead of creating a second one. Students enrolled in the course but assigned to a different tutor (or no tutor) are "guests"; the flag only marks the tutor group, the per-exercise cap applies to every student. Students not enrolled in the course at all are rejected.

func (*Handler) AuditLogFacets

func (h *Handler) AuditLogFacets(ctx context.Context, input *AuditLogFacetsInput) (*AuditLogFacetsOutput, error)

AuditLogFacets returns the distinct action and resource values currently present in the audit log, used to populate filter dropdowns (admin only).

func (*Handler) AuditLogGet

func (h *Handler) AuditLogGet(ctx context.Context, input *AuditLogGetInput) (*AuditLogGetOutput, error)

AuditLogGet returns a single audit log entry by ID (admin only).

func (*Handler) AuditLogList

func (h *Handler) AuditLogList(ctx context.Context, input *AuditLogListInput) (*AuditLogListOutput, error)

AuditLogList returns a paginated list of audit log entries, newest first, filterable by action, resource, actor and time range (admin only).

func (*Handler) BuildJobsList

func (h *Handler) BuildJobsList(ctx context.Context, input *BuildJobListInput) (*BuildJobListOutput, error)

BuildJobsList returns a filtered, paginated list of build jobs (admin only). Admins see every course. The user filter resolves orchestration users to their current Forgejo logins, so builds of renamed users stay under their historical login.

func (*Handler) CLIVersion

func (h *Handler) CLIVersion(ctx context.Context, input *CLIVersionInput) (*CLIVersionOutput, error)

CLIVersion returns the minimum required hopper-cli version from the "cli_min_version" setting. Public endpoint; no authentication required.

func (*Handler) Charts

func (h *Handler) Charts(ctx context.Context, input *ChartsInput) (*ChartsOutput, error)

Charts returns all chart datasets (overview, per-course, cross-dimensional) as JSON. When course_id is present and non-zero, per-course charts filter to that course; overview and cross-dimensional charts are always unfiltered.

func (*Handler) ChartsCSV

func (h *Handler) ChartsCSV(ctx context.Context, input *ChartsInput) (*ChartsCSVOutput, error)

ChartsCSV returns a CSV file containing all chart datasets, one section per chart separated by a blank line. When course_id is present and non-zero, per-course charts filter to that course.

func (*Handler) CourseAccessForCourseGrant

func (h *Handler) CourseAccessForCourseGrant(ctx context.Context, input *CourseAccessForCourseGrantInput) (*CourseAccessForCourseGrantOutput, error)

CourseAccessForCourseGrant grants a staff user full manage rights on the course (admin only). Re-granting an existing pair returns the existing grant unchanged (idempotent).

func (*Handler) CourseAccessForCourseList

func (h *Handler) CourseAccessForCourseList(ctx context.Context, input *CourseAccessForCourseListInput) (*CourseAccessForCourseListOutput, error)

CourseAccessForCourseList returns the course access grants on a course (admin only).

func (*Handler) CourseAccessForCourseRevoke

func (h *Handler) CourseAccessForCourseRevoke(ctx context.Context, input *CourseAccessForCourseRevokeInput) (*CourseAccessForCourseRevokeOutput, error)

CourseAccessForCourseRevoke revokes a course access grant (admin only).

func (*Handler) CourseStudentBuilds

func (h *Handler) CourseStudentBuilds(ctx context.Context, input *CourseStudentBuildsInput) (*CourseStudentBuildsOutput, error)

CourseStudentBuilds returns the latest build job per exercise for one student. The warning decision is made here so the repo page only renders it and the hide rule stays testable. A missing build service or a build service error degrades to an empty list, never to a false warning.

func (*Handler) CourseStudentGrades

func (h *Handler) CourseStudentGrades(ctx context.Context, input *CourseStudentGradesInput) (*CourseStudentGradesOutput, error)

CourseStudentGrades returns all exercises of one course for one student, including ungraded ones (points and graded_at are null for those), with the same item shape as UsersGrades. The course is resolved by its UID and the student by user reference. Access is limited to the student themselves and course staff (course owner, admins, tutors of that course); anyone else signed in gets 403, unknown courses or students 404.

func (*Handler) CourseStudentPoints

func (h *Handler) CourseStudentPoints(ctx context.Context, input *CourseStudentPointsInput) (*CourseStudentPointsOutput, error)

CourseStudentPoints returns the points summary for one student in one course. The exercise list is the same shape as CourseStudentGrades, so the repo page can render the per-folder column and the course summary from one response.

func (*Handler) CoursesCreate

func (h *Handler) CoursesCreate(ctx context.Context, input *CoursesCreateInput) (*CoursesCreateOutput, error)

CoursesCreate creates a new course (staff only).

func (*Handler) CoursesDelete

func (h *Handler) CoursesDelete(ctx context.Context, input *CoursesDeleteInput) (*CoursesDeleteOutput, error)

CoursesDelete deletes a course by ID (soft delete, staff only).

func (*Handler) CoursesGet

func (h *Handler) CoursesGet(ctx context.Context, input *CoursesGetInput) (*CoursesGetOutput, error)

CoursesGet returns a single course by ID. Non-admin users see only joinable courses.

func (*Handler) CoursesHardDelete

func (h *Handler) CoursesHardDelete(ctx context.Context, input *CoursesHardDeleteInput) (*CoursesHardDeleteOutput, error)

CoursesHardDelete permanently removes an archived course and all of its data from the database. Only courses that are already soft-deleted (archived) can be hard-deleted (admin only).

func (*Handler) CoursesJoin

func (h *Handler) CoursesJoin(ctx context.Context, input *CoursesJoinInput) (*CoursesJoinOutput, error)

CoursesJoin enrolls the authenticated user as a student in the given course. The course must have allow_join enabled. When Forgejo is configured, the user is required to have an account on the Forgejo instance (the local part of their email is used as the username); otherwise the request is rejected with 409.

func (*Handler) CoursesList

func (h *Handler) CoursesList(ctx context.Context, input *CoursesListInput) (*CoursesListOutput, error)

CoursesList returns a paginated list of courses. Non-admin users see only joinable courses.

func (*Handler) CoursesPaletteSearch

func (h *Handler) CoursesPaletteSearch(ctx context.Context, input *CoursesPaletteSearchInput) (*CoursesPaletteSearchOutput, error)

CoursesPaletteSearch returns up to 8 visible courses matching q.

func (*Handler) CoursesRestore

func (h *Handler) CoursesRestore(ctx context.Context, input *CoursesRestoreInput) (*CoursesRestoreOutput, error)

CoursesRestore restores a soft-deleted (archived) course by clearing its deleted_at (staff only).

func (*Handler) CoursesStudentsAssignTutorBulk

func (h *Handler) CoursesStudentsAssignTutorBulk(ctx context.Context, input *CoursesStudentsAssignTutorBulkInput) (*CoursesStudentsAssignTutorBulkOutput, error)

CoursesStudentsAssignTutorBulk assigns or clears the tutor for multiple students of a course in one transaction (staff only). User ids without a matching student row in the course are skipped. Returns the number of student rows updated.

func (*Handler) CoursesStudentsAutoDistribute

func (h *Handler) CoursesStudentsAutoDistribute(ctx context.Context, input *CoursesStudentsAutoDistributeInput) (*CoursesStudentsAutoDistributeOutput, error)

CoursesStudentsAutoDistribute evenly distributes the unassigned students of a course across its tutors (staff only). Existing assignments are kept.

func (*Handler) CoursesStudentsEnroll

func (h *Handler) CoursesStudentsEnroll(ctx context.Context, input *CoursesStudentsEnrollInput) (*CoursesStudentsEnrollOutput, error)

CoursesStudentsEnroll enrolls an existing user as a student in the given course (staff only). The caller must be able to manage the course. Unlike the self-service join endpoint there is no Forgejo user precheck: the student sync hook tolerates missing Forgejo users and the sync cron retries once the user logs in to Forgejo.

func (*Handler) CoursesStudentsList

func (h *Handler) CoursesStudentsList(ctx context.Context, input *CoursesStudentsListInput) (*CoursesStudentsListOutput, error)

CoursesStudentsList returns a paginated list of students enrolled in a specific course. Only callers who may manage the course get access.

func (*Handler) CoursesStudentsSetTutor

func (h *Handler) CoursesStudentsSetTutor(ctx context.Context, input *CoursesStudentsSetTutorInput) (*CoursesStudentsSetTutorOutput, error)

CoursesStudentsSetTutor sets or clears the tutor of a single student in a course (staff only). An absent or null tutor_id clears the assignment.

func (*Handler) CoursesStudentsUnassign

func (h *Handler) CoursesStudentsUnassign(ctx context.Context, input *CoursesStudentsUnassignInput) (*CoursesStudentsUnassignOutput, error)

CoursesStudentsUnassign removes a user's enrollment from the given course (staff only).

func (*Handler) CoursesTutorForUser

func (h *Handler) CoursesTutorForUser(ctx context.Context, input *CoursesTutorForUserInput) (*CoursesTutorForUserOutput, error)

CoursesTutorForUser returns the tutor assigned to the given user in the course. Only the user themselves and course staff (course owner, admins, tutors of the course) may look it up; anyone else signed in gets 403. The course is addressed by its numeric ID or its UID.

func (*Handler) CoursesTutorStudents

func (h *Handler) CoursesTutorStudents(ctx context.Context, input *CoursesTutorStudentsInput) (*CoursesTutorStudentsOutput, error)

CoursesTutorStudents returns the students assigned to one tutor in a course. The tutor reference accepts a user ID, a Forgejo username, or the self aliases. The caller may read the list when they are that tutor, an admin, or a manager of the course.

func (*Handler) CoursesTutorsAssign

func (h *Handler) CoursesTutorsAssign(ctx context.Context, input *CoursesTutorsAssignInput) (*CoursesTutorsAssignOutput, error)

CoursesTutorsAssign assigns an existing user as a tutor of the given course (staff only).

func (*Handler) CoursesTutorsList

func (h *Handler) CoursesTutorsList(ctx context.Context, input *CoursesTutorsListInput) (*CoursesTutorsListOutput, error)

CoursesTutorsList returns a paginated list of tutors assigned to a specific course. Only callers who may manage the course get access.

func (*Handler) CoursesTutorsUnassign

func (h *Handler) CoursesTutorsUnassign(ctx context.Context, input *CoursesTutorsUnassignInput) (*CoursesTutorsUnassignOutput, error)

CoursesTutorsUnassign removes a user as a tutor of the given course (staff only). In the same transaction the tutor's assigned students are unassigned (tutor_id set to NULL) before the tutor row is deleted, so no student row depends on the removed tutor afterwards.

func (*Handler) CoursesUpdate

func (h *Handler) CoursesUpdate(ctx context.Context, input *CoursesUpdateInput) (*CoursesUpdateOutput, error)

CoursesUpdate updates an existing course by ID. Staff may only update the courses they own.

func (*Handler) ExercisesCreate

func (h *Handler) ExercisesCreate(ctx context.Context, input *ExercisesCreateInput) (*ExercisesCreateOutput, error)

ExercisesCreate creates a new exercise in a course (staff only). The caller must be able to manage the course, mirroring the admin UI fragment handler that creates exercises.

func (*Handler) ExercisesDelete

func (h *Handler) ExercisesDelete(ctx context.Context, input *ExercisesDeleteInput) (*ExercisesDeleteOutput, error)

ExercisesDelete removes an exercise by ID within a course (staff only). Exercise has no soft delete, so this is a hard delete; the student exercise rows cascade via the FK. No Forgejo sync runs on delete: the exercise folders stay in the repos since students may have pushed work.

func (*Handler) ExercisesList

func (h *Handler) ExercisesList(ctx context.Context, input *ExercisesListInput) (*ExercisesListOutput, error)

ExercisesList returns the exercises defined in a course, ordered by start date. Used by the build/grading service to resolve exercise deadlines without duplicating the exercise table. Reachable by any authenticated user, but the handler only returns data to staff-level roles (system, admin, staff), the stack-internal key of the build/grading service, holders of a course access grant, tutors of the course, and enrolled students of the course.

func (*Handler) ExercisesPaletteSearch

func (h *Handler) ExercisesPaletteSearch(ctx context.Context, input *ExercisesPaletteSearchInput) (*ExercisesPaletteSearchOutput, error)

ExercisesPaletteSearch returns up to 8 visible exercises matching q.

func (*Handler) ExercisesUpdate

func (h *Handler) ExercisesUpdate(ctx context.Context, input *ExercisesUpdateInput) (*ExercisesUpdateOutput, error)

ExercisesUpdate updates an exercise by ID within a course (staff only). The body is a full update: name, start, end, and points are all replaced, matching the admin UI edit form which submits every field.

func (*Handler) ForgejoRequestsFacets

func (h *Handler) ForgejoRequestsFacets(ctx context.Context, input *ForgejoRequestsFacetsInput) (*ForgejoRequestsFacetsOutput, error)

ForgejoRequestsFacets returns the distinct source and method values currently present in the Forgejo request log, used to populate filter dropdowns (admin only).

func (*Handler) ForgejoRequestsList

func (h *Handler) ForgejoRequestsList(ctx context.Context, input *ForgejoRequestsListInput) (*ForgejoRequestsListOutput, error)

ForgejoRequestsList returns a paginated list of every outgoing Forgejo HTTP request the orchestrator has made (most recent first), with full request and response envelopes (admin only).

func (*Handler) GitPostRecieveHandler

func (h *Handler) GitPostRecieveHandler(c *echo.Context) error

func (*Handler) GitPreRecieveHandler

func (h *Handler) GitPreRecieveHandler(c *echo.Context) error

func (*Handler) HTTPRequestGet

func (h *Handler) HTTPRequestGet(ctx context.Context, input *HTTPRequestGetInput) (*HTTPRequestGetOutput, error)

HTTPRequestGet returns a single inbound HTTP request by ID, including the captured request and response bodies for a 5xx response. Bodies are capped at 8 KiB, only captured for textual content types, and have credential-shaped values redacted; headers, cookies, and query strings are never stored (admin only).

func (*Handler) HTTPRequestsChart

func (h *Handler) HTTPRequestsChart(ctx context.Context, input *HTTPRequestsChartInput) (*HTTPRequestsChartOutput, error)

HTTPRequestsChart returns the filtered inbound requests as a time series of status classes plus latency, for the admin chart (admin only).

func (*Handler) HTTPRequestsFacets

func (h *Handler) HTTPRequestsFacets(ctx context.Context, input *HTTPRequestsFacetsInput) (*HTTPRequestsFacetsOutput, error)

HTTPRequestsFacets returns the distinct method values currently present in the request log, used to populate the method filter dropdown (admin only).

func (*Handler) HTTPRequestsList

func (h *Handler) HTTPRequestsList(ctx context.Context, input *HTTPRequestsListInput) (*HTTPRequestsListOutput, error)

HTTPRequestsList returns a paginated list of every inbound HTTP request the orchestration server has served (most recent first), with the final status code, duration, client address, user agent, and authenticated user. Captured 5xx bodies are not part of the list; HTTPRequestGet returns them (admin only).

func (*Handler) HealthCheckRun

func (h *Handler) HealthCheckRun(ctx context.Context, input *HealthCheckRunInput) (*HealthCheckRunOutput, error)

HealthCheckRun triggers a single health check by name and returns the fresh result. Records an audit entry on success.

func (*Handler) HealthStatus

func (h *Handler) HealthStatus(ctx context.Context, input *HealthStatusInput) (*HealthStatusOutput, error)

HealthStatus returns the latest results of all health checks, the summary counts, the current Beszel metrics snapshot, and process system info.

func (*Handler) ParticipationsCreate

func (h *Handler) ParticipationsCreate(ctx context.Context, input *ParticipationsCreateInput) (*ParticipationsCreateOutput, error)

ParticipationsCreate creates one manual tutorial participation. Admin only.

func (*Handler) ParticipationsDelete

func (h *Handler) ParticipationsDelete(ctx context.Context, input *ParticipationsDeleteInput) (*ParticipationsDeleteOutput, error)

ParticipationsDelete removes one tutorial participation. Admin only.

func (*Handler) ParticipationsGet

func (h *Handler) ParticipationsGet(ctx context.Context, input *ParticipationsGetInput) (*ParticipationsGetOutput, error)

ParticipationsGet returns one tutorial participation by ID.

func (*Handler) ParticipationsList

func (h *Handler) ParticipationsList(ctx context.Context, input *ParticipationsListInput) (*ParticipationsListOutput, error)

ParticipationsList returns one filtered page of tutorial participations, newest first. Only admins reach this handler; the route enforces it.

func (*Handler) ParticipationsUpdate

func (h *Handler) ParticipationsUpdate(ctx context.Context, input *ParticipationsUpdateInput) (*ParticipationsUpdateOutput, error)

ParticipationsUpdate updates the exercise_id and presented flag of one participation. The exercise must belong to the same course as the student, so a link cannot cross courses.

func (*Handler) SettingsCreate

func (h *Handler) SettingsCreate(ctx context.Context, input *SettingsCreateInput) (*SettingsCreateOutput, error)

SettingsCreate creates a new setting (admin only).

func (*Handler) SettingsDelete

func (h *Handler) SettingsDelete(ctx context.Context, input *SettingsDeleteInput) (*SettingsDeleteOutput, error)

SettingsDelete deletes a setting by key (admin only).

func (*Handler) SettingsGet

func (h *Handler) SettingsGet(ctx context.Context, input *SettingsGetInput) (*SettingsGetOutput, error)

SettingsGet returns a single setting by key if visible to the caller.

func (*Handler) SettingsList

func (h *Handler) SettingsList(ctx context.Context, input *SettingsListInput) (*SettingsListOutput, error)

SettingsList returns a paginated list of settings visible to the caller.

func (*Handler) SettingsPaletteSearch

func (h *Handler) SettingsPaletteSearch(ctx context.Context, input *SettingsPaletteSearchInput) (*SettingsPaletteSearchOutput, error)

SettingsPaletteSearch returns the settings matching q for the admin command palette. An empty q returns every entry.

func (*Handler) SettingsUpdate

func (h *Handler) SettingsUpdate(ctx context.Context, input *SettingsUpdateInput) (*SettingsUpdateOutput, error)

SettingsUpdate updates an existing setting by key (admin only).

func (*Handler) Stats

func (h *Handler) Stats(ctx context.Context, input *StatsInput) (*StatsOutput, error)

Stats returns the aggregate dashboard statistics (admin only).

func (*Handler) TaskGet

func (h *Handler) TaskGet(ctx context.Context, input *TaskGetInput) (*TaskGetOutput, error)

TaskGet returns details for a single registered task.

func (*Handler) TaskList

func (h *Handler) TaskList(ctx context.Context, input *TaskListInput) (*TaskListOutput, error)

TaskList returns every registered task with its schedule and run state.

func (*Handler) TaskRun

func (h *Handler) TaskRun(ctx context.Context, input *TaskRunInput) (*TaskRunOutput, error)

TaskRun starts a task asynchronously and returns its current snapshot. A conflict means the task is already running; a shutdown returns 503.

func (*Handler) TasksPaletteSearch

func (h *Handler) TasksPaletteSearch(ctx context.Context, input *TasksPaletteSearchInput) (*TasksPaletteSearchOutput, error)

TasksPaletteSearch returns the tasks matching q for the admin command palette. An empty q returns every entry.

func (*Handler) UsersAdminList

func (h *Handler) UsersAdminList(ctx context.Context, input *UsersAdminListInput) (*UsersAdminListOutput, error)

UsersAdminList returns a paginated list of users with their session count, last login, recent sessions, and course relationships (admin only).

func (*Handler) UsersCourseRepos

func (h *Handler) UsersCourseRepos(ctx context.Context, input *UsersCourseReposInput) (*UsersCourseReposOutput, error)

UsersCourseRepos returns the courses and course repositories the target user can access, as seen by the caller. The target may be an ID, a Forgejo username, or me/mine/my. Admins see every course and repository; staff see the courses they manage and, as course tutors, their assigned students; callers without such a relation only see themselves.

func (*Handler) UsersCourses

func (h *Handler) UsersCourses(ctx context.Context, input *UsersCoursesInput) (*UsersCoursesOutput, error)

UsersCourses returns the courses in which the authenticated user is a student or a tutor. Each entry carries a `role` field ("student" or "tutor") so the caller can pick the right action. Archived (soft-deleted) courses are excluded.

func (*Handler) UsersCreate

func (h *Handler) UsersCreate(ctx context.Context, input *UsersCreateInput) (*UsersCreateOutput, error)

UsersCreate creates a new user (admin only).

func (*Handler) UsersDelete

func (h *Handler) UsersDelete(ctx context.Context, input *UsersDeleteInput) (*UsersDeleteOutput, error)

UsersDelete deletes a user by ID or username (admin only). Self aliases are rejected on mutations.

func (*Handler) UsersDeleteSessions

func (h *Handler) UsersDeleteSessions(ctx context.Context, input *UsersDeleteSessionsInput) (*UsersDeleteSessionsOutput, error)

UsersDeleteSessions deletes all active OIDC sessions for the specified user, forcing them to re-authenticate on their next request (admin only). Self aliases are rejected on mutations.

func (*Handler) UsersGet

func (h *Handler) UsersGet(ctx context.Context, input *UsersGetInput) (*UsersGetOutput, error)

UsersGet returns a single user by ID or Forgejo username. The self aliases me, mine, and my resolve to the caller. Non-admin callers may only read users they are related to (staff: members of their courses; tutors: their assigned students; anyone: themselves); others get 404.

func (*Handler) UsersGrades

func (h *Handler) UsersGrades(ctx context.Context, input *UsersGradesInput) (*UsersGradesOutput, error)

UsersGrades returns all exercises of the courses the authenticated user is enrolled in as a student, including ungraded ones (points and graded_at are null for those). Items are ordered by course name, then by exercise start, end, and name.

func (*Handler) UsersList

func (h *Handler) UsersList(ctx context.Context, input *UsersListInput) (*UsersListOutput, error)

UsersList returns a paginated list of users matching the requested filters. Non-admin callers only see users they are related to: staff see the students and tutors of the courses they own, tutors see their assigned students, and everyone always sees themselves.

func (*Handler) UsersPaletteSearch

func (h *Handler) UsersPaletteSearch(ctx context.Context, input *UsersPaletteSearchInput) (*UsersPaletteSearchOutput, error)

UsersPaletteSearch returns up to 8 users matching q that the caller may read. The command palette uses it for its dynamic user section.

func (*Handler) UsersParticipations

func (h *Handler) UsersParticipations(ctx context.Context, input *UsersParticipationsInput) (*UsersParticipationsOutput, error)

UsersParticipations returns the tutorial participations of the authenticated user across all courses they are enrolled in as a student, ordered by date, newest first. Participations have no course of their own; the course comes via the student row the participation belongs to, so a user enrolled in multiple courses gets entries from all of them. A user without enrollments gets an empty list.

func (*Handler) UsersRecentGrades

func (h *Handler) UsersRecentGrades(ctx context.Context, input *UsersRecentGradesInput) (*UsersRecentGradesOutput, error)

UsersRecentGrades returns the 5 most recently graded exercises for the authenticated user.

func (*Handler) UsersRepairRepos

func (h *Handler) UsersRepairRepos(ctx context.Context, input *UsersRepairReposInput) (*UsersRepairReposOutput, error)

UsersRepairRepos schedules a repair of every Forgejo resource for the target user (repos, collaborators, teams, exercise folders) across all their enrollments. The target may be the caller or, for admins, another user. The Forgejo calls run in a detached goroutine; the handler only answers immediately.

The cooldown stamp (users.last_repo_sync) is written only when a repair actually ran to completion, so users without enrollments and users whose Forgejo account does not exist yet never consume the cooldown and get a real repair on a later call.

func (*Handler) UsersUpdate

func (h *Handler) UsersUpdate(ctx context.Context, input *UsersUpdateInput) (*UsersUpdateOutput, error)

UsersUpdate updates an existing user by ID or username (admin only). Self aliases are rejected on mutations.

type HealthBeszelContainer

type HealthBeszelContainer struct {
	Name       string  `json:"name"`
	CPUPercent float64 `json:"cpu_percent"`
	MemMB      float64 `json:"mem_mb"`
	NetUpMBs   float64 `json:"net_up_mbs"`
	NetDownMBs float64 `json:"net_down_mbs"`
}

HealthBeszelContainer is one container's resource usage from Beszel.

type HealthBeszelInfo

type HealthBeszelInfo struct {
	HostStatus    string                  `json:"host_status"`
	HostUptimeSec float64                 `json:"host_uptime_sec"`
	AgentVersion  string                  `json:"agent_version"`
	LastHeartbeat time.Time               `json:"last_heartbeat"`
	CPUPercent    float64                 `json:"cpu_percent"`
	MemUsedGB     float64                 `json:"mem_used_gb"`
	MemTotalGB    float64                 `json:"mem_total_gb"`
	MemPercent    float64                 `json:"mem_percent"`
	DiskUsedGB    float64                 `json:"disk_used_gb"`
	DiskTotalGB   float64                 `json:"disk_total_gb"`
	DiskPercent   float64                 `json:"disk_percent"`
	LoadAvg       [3]float64              `json:"load_avg"`
	NetUpMBs      float64                 `json:"net_up_mbs"`
	NetDownMBs    float64                 `json:"net_down_mbs"`
	Containers    []HealthBeszelContainer `json:"containers"`
}

HealthBeszelInfo mirrors health.BeszelSnapshot in JSON-friendly form.

type HealthCheckItem

type HealthCheckItem struct {
	Name                string         `json:"name"`
	Group               string         `json:"group"`
	Status              string         `json:"status"`
	Message             string         `json:"message"`
	LatencyMS           int64          `json:"latency_ms"`
	ConsecutiveFailures int            `json:"consecutive_failures"`
	CheckedAt           time.Time      `json:"checked_at"`
	Detail              map[string]any `json:"detail,omitempty"`
}

HealthCheckItem is the API view of one health check's latest result.

type HealthCheckRunInput

type HealthCheckRunInput struct {
	Name string `path:"name"`
}

HealthCheckRunInput holds the request parameters for HealthCheckRun.

type HealthCheckRunOutput

type HealthCheckRunOutput struct {
	Body HealthCheckItem
}

HealthCheckRunOutput holds the response body for HealthCheckRun.

type HealthStatusInput

type HealthStatusInput struct{}

HealthStatusInput holds the request parameters for HealthStatus (none).

type HealthStatusOutput

type HealthStatusOutput struct {
	Body struct {
		Checks      []HealthCheckItem      `json:"checks"`
		Summary     HealthSummary          `json:"summary"`
		Beszel      *HealthBeszelInfo      `json:"beszel"`
		System      HealthSystemInfo       `json:"system"`
		Warnings    []config.ConfigWarning `json:"warnings"`
		GeneratedAt time.Time              `json:"generated_at"`
	}
}

HealthStatusOutput holds the response body for HealthStatus.

type HealthSummary

type HealthSummary struct {
	Total   int `json:"total"`
	OK      int `json:"ok"`
	Warn    int `json:"warn"`
	Fail    int `json:"fail"`
	Unknown int `json:"unknown"`
}

HealthSummary counts the latest results by status.

type HealthSystemInfo

type HealthSystemInfo struct {
	GoVersion string    `json:"go_version"`
	UptimeSec int64     `json:"uptime_sec"`
	StartedAt time.Time `json:"started_at"`
}

HealthSystemInfo describes the orchestration process itself.

type Huma

type Huma struct {
	API huma.API
	// contains filtered or unexported fields
}

Huma holds the huma API mounted on the shared echo instance.

func NewHuma

func NewHuma(e *echo.Echo, meta config.APIConfig) *Huma

NewHuma builds the huma API on top of the given echo instance. The API metadata comes from the resolved config (API_HOST, API_TERMS, API_SUPPORT_* env vars, read once at startup). Huma serves the generated spec itself at /api/openapi.json and /api/openapi.yaml and the docs UI at /api/docs. The schema endpoint is disabled because the spec embeds all schemas.

func (*Huma) UseAuth

func (h *Huma) UseAuth(mw ...echo.MiddlewareFunc) huma.Middlewares

UseAuth converts echo middleware (a.Auth.Require, RequireStaff, ...) into huma middleware for one operation. The middleware runs against the unwrapped echo context; if it short-circuits with an error, the error is rendered by echo's existing error handler unchanged and the huma handler is never invoked.

type LabelCount

type LabelCount struct {
	Label string `json:"label"`
	Count int64  `json:"count"`
}

LabelCount is a generic label/count pair for categorical chart data.

type MyCourseItem

type MyCourseItem struct {
	db.Course
	Role string `json:"role"` // "student" or "tutor"
}

MyCourseItem pairs a full course with the role the current user has in it (student or tutor). Used by /users/{user}/courses so the dashboard template can render the right action per role.

type PaletteCourse

type PaletteCourse struct {
	ID       uint   `json:"id"`
	UID      string `json:"uid"`
	Name     string `json:"name"`
	Semester string `json:"semester"`
}

PaletteCourse is the minimal course shape returned by the command palette course search. UID is the Forgejo-style identifier, e.g. "2026WS-eidp".

func SearchCoursesForPalette

func SearchCoursesForPalette(gdb *gorm.DB, search, ownerID string, isAdmin bool, limit int) ([]PaletteCourse, error)

SearchCoursesForPalette returns up to limit courses matching search that the caller may see. Admins see every course; staff see owned and granted courses, matching VisibleCourses.

type PaletteExercise

type PaletteExercise struct {
	ID        uint   `json:"id"`
	Name      string `json:"name"`
	CourseID  uint   `json:"course_id"`
	CourseUID string `json:"course_uid"`
}

PaletteExercise is the minimal exercise shape returned by the command palette exercise search.

func SearchExercisesForPalette

func SearchExercisesForPalette(gdb *gorm.DB, search, ownerID string, isAdmin bool, limit int) ([]PaletteExercise, error)

SearchExercisesForPalette returns up to limit exercises matching search that the caller may see through their visible courses. Each query term may match the exercise name or the course name, semester, or uid, so "eidp count" finds the exercise named count in the eidp course.

type PaletteSetting

type PaletteSetting struct {
	Key         string `json:"key"`
	Label       string `json:"label"`
	Description string `json:"description"`
	Href        string `json:"href"`
}

PaletteSetting is one settings entry in the admin command palette. Href points at the matching card on the settings page so the palette can jump to it.

func PaletteSettings

func PaletteSettings() []PaletteSetting

PaletteSettings returns the settings the Settings page edits. The settings table can hold other keys, but only these have a card and a save form.

func SearchSettingsForPalette

func SearchSettingsForPalette(search string) []PaletteSetting

SearchSettingsForPalette returns the settings matching search. An empty search returns every entry.

type PaletteTask

type PaletteTask struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Scheduled   bool   `json:"scheduled"`
	Schedule    string `json:"schedule"`
}

PaletteTask is one admin command palette entry for a task.

func SearchTasksForPalette

func SearchTasksForPalette(list []tasks.Snapshot, search string) []PaletteTask

SearchTasksForPalette returns the tasks matching search. An empty search returns every entry because the admin palette shows the full list on open. Tasks match on name, description, schedule label, and schedule kind.

type PaletteUser

type PaletteUser struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	PreferredUsername string `json:"preferred_username"`
	Email             string `json:"email"`
}

PaletteUser is the minimal user shape returned by the command palette search. Name is the resolved display name, so the palette does not need to know about the display-name fallbacks.

func SearchUsersForPalette

func SearchUsersForPalette(gdb *gorm.DB, search string, scope func(*gorm.DB) *gorm.DB, limit int) ([]PaletteUser, error)

SearchUsersForPalette returns up to limit users matching search that are visible through scope. The caller supplies UserReadScope so admins see every user and staff only see users they may read. An empty search returns no rows; the palette does not call the endpoint without a query.

type ParticipationAdminItem

type ParticipationAdminItem struct {
	ID            uint      `json:"id"`
	Date          time.Time `json:"date"`
	Presented     bool      `json:"presented"`
	StudentID     *uint     `json:"student_id"`
	StudentUserID string    `json:"student_user_id"`
	StudentName   string    `json:"student_name"`
	TutorID       uint      `json:"tutor_id"`
	TutorUserID   string    `json:"tutor_user_id"`
	TutorName     string    `json:"tutor_name"`
	CourseID      uint      `json:"course_id"`
	CourseUID     string    `json:"course_uid"`
	ExerciseID    *uint     `json:"exercise_id"`
	ExerciseName  string    `json:"exercise_name"`
	Guest         bool      `json:"guest"`
}

ParticipationAdminItem is the admin view of one tutorial participation. It carries the student and course so a client can match an unlinked row without additional lookups.

func GetParticipationItem

func GetParticipationItem(gdb *gorm.DB, id string) (ParticipationAdminItem, error)

GetParticipationItem loads one participation in the admin shape.

type ParticipationCreateBody

type ParticipationCreateBody struct {
	StudentUserID string    `json:"student_user_id" required:"true"`
	ExerciseID    uint      `json:"exercise_id" required:"true"`
	TutorID       uint      `json:"tutor_id" required:"false"`
	Date          time.Time `json:"date" required:"false"`
	Presented     bool      `json:"presented" required:"false"`
}

ParticipationCreateBody is the admin create body for one attendance row.

type ParticipationItem

type ParticipationItem struct {
	Date       time.Time   `json:"date"`
	Presented  bool        `json:"presented"`
	Guest      bool        `json:"guest"`
	CourseID   uint        `json:"course_id"`
	CourseName string      `json:"course_name"`
	CourseSlug string      `json:"course_slug"`
	Tutor      *TutorBrief `json:"tutor"`
}

ParticipationItem is one tutorial attendance entry for the /users/{user}/participations overview. Tutor is the tutor whose session the attendance was recorded in; Guest is true when that tutor is not the student's own assigned tutor (including when the student has no assigned tutor), i.e. they attended another tutor's session as a guest.

type ParticipationListResult

type ParticipationListResult struct {
	Items      []ParticipationAdminItem
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

ParticipationListResult holds the paginated result of an attendance list query. Shared by the JSON API handler, the admin page handler, and the htmx table fragment.

func ListParticipations

func ListParticipations(gdb *gorm.DB, p ParticipationsListInput, ownerID string, isAdmin bool) (ParticipationListResult, error)

ListParticipations returns one filtered page of tutorial participations, newest first. Admins see every course; staff see the courses they own or hold a grant on. Shared by the JSON API handler, the admin page handler, and the htmx table fragment so all three paths agree on filters, scoping, and ordering.

type ParticipationUpdateBody

type ParticipationUpdateBody struct {
	ExerciseID *uint `json:"exercise_id" required:"false"`
	Presented  *bool `json:"presented" required:"false"`
}

ParticipationUpdateBody is the admin update body. Date is immutable because it is the tutorial session itself; exercise_id and presented are editable.

type ParticipationsCreateInput

type ParticipationsCreateInput struct {
	Body ParticipationCreateBody
}

ParticipationsCreateInput holds the request body for ParticipationsCreate.

type ParticipationsCreateOutput

type ParticipationsCreateOutput struct {
	Body ParticipationAdminItem
}

ParticipationsCreateOutput holds the response body for ParticipationsCreate.

type ParticipationsDeleteInput

type ParticipationsDeleteInput struct {
	ID string `path:"id"`
}

ParticipationsDeleteInput holds the request parameters for ParticipationsDelete.

type ParticipationsDeleteOutput

type ParticipationsDeleteOutput struct {
	Status int
}

ParticipationsDeleteOutput holds the response body for ParticipationsDelete.

type ParticipationsGetInput

type ParticipationsGetInput struct {
	ID string `path:"id"`
}

ParticipationsGetInput holds the request parameters for ParticipationsGet.

type ParticipationsGetOutput

type ParticipationsGetOutput struct {
	Body ParticipationAdminItem
}

ParticipationsGetOutput holds the response body for ParticipationsGet.

type ParticipationsListInput

type ParticipationsListInput struct {
	CourseID      uint   `query:"course_id" required:"false"`
	Student       string `query:"student" required:"false"`
	StudentUserID string `query:"student_user_id" required:"false"`
	ExerciseID    uint   `query:"exercise_id" required:"false"`
	Unmatched     bool   `query:"unmatched" required:"false"`
	Presented     string `query:"presented" required:"false"`
	Page          int    `query:"page" default:"1"`
	PageSize      int    `query:"page_size" default:"50"`
}

ParticipationsListInput holds the filter and pagination parameters for the admin participation list.

func ParseParticipationsListParams

func ParseParticipationsListParams(c *echo.Context) ParticipationsListInput

ParseParticipationsListParams extracts the attendance list filter and pagination params from the query string. Shared by the JSON API handler, the admin page handler, and the htmx table fragment.

type ParticipationsListOutput

type ParticipationsListOutput struct {
	Body query.PaginatedResponse[ParticipationAdminItem]
}

ParticipationsListOutput holds the response body for ParticipationsList.

type ParticipationsUpdateInput

type ParticipationsUpdateInput struct {
	ID   string `path:"id"`
	Body ParticipationUpdateBody
}

ParticipationsUpdateInput holds the request parameters for ParticipationsUpdate.

type ParticipationsUpdateOutput

type ParticipationsUpdateOutput struct {
	Body ParticipationAdminItem
}

ParticipationsUpdateOutput holds the response body for ParticipationsUpdate.

type PointsTotal

type PointsTotal struct {
	Points            float64 `json:"points"`
	MaxPoints         float64 `json:"max_points"`
	Percent           *int    `json:"percent"`
	ExercisePoints    float64 `json:"exercise_points"`
	ExerciseMaxPoints float64 `json:"exercise_max_points"`
	TutorialPoints    float64 `json:"tutorial_points"`
	TutorialMaxPoints float64 `json:"tutorial_max_points"`
}

PointsTotal is the combined exercise and tutorial score. Only exercises whose deadline has passed contribute. Percent is nil when no maximum is configured, so callers never divide by zero.

type RecentGradeItem

type RecentGradeItem struct {
	ExerciseName string    `json:"exercise_name"`
	CourseName   string    `json:"course_name"`
	CourseSlug   string    `json:"course_slug"`
	CourseID     uint      `json:"course_id"`
	Points       *float64  `json:"points"`
	MaxPoints    *float64  `json:"max_points"`
	GradedAt     time.Time `json:"graded_at"`
}

RecentGradeItem is a grade record for the dashboard "Recently Graded" list.

type SemesterCount

type SemesterCount struct {
	Semester string `json:"semester"`
	Count    int64  `json:"count"`
}

SemesterCount pairs a semester identifier with the number of courses in it.

type SessionBrief

type SessionBrief struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

SessionBrief is a minimal representation of an OIDC session for the admin UI.

type SetStudentTutorBody

type SetStudentTutorBody struct {
	TutorID *uint `json:"tutor_id" required:"false"`
}

SetStudentTutorBody is the body for PUT /courses/{id}/students/{userID}/tutor. An absent or null tutor_id clears the assignment.

type SettingBody

type SettingBody struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Type   string `json:"type" required:"false"`
	Access string `json:"access" required:"false"`
}

SettingBody is the request body for creating and updating settings. Timestamps are server-managed and not part of the payload.

type SettingListQuery

type SettingListQuery struct {
	Key      string `query:"key" required:"false" filter:"key"`
	Type     string `query:"type" required:"false" filter:"type"`
	Access   string `query:"access" required:"false" filter:"access"`
	Search   string `query:"search" required:"false" search:"key,value"`
	SortBy   string `query:"sort_by" required:"false" sort:"key,access,created_at,updated_at"`
	SortDir  string `query:"sort_dir" required:"false"`
	Page     int    `query:"page" default:"1"`
	PageSize int    `query:"page_size" default:"25"`
}

SettingListQuery holds the filter/sort/pagination inputs for GET /settings. The query/default tags drive huma's request binding; the filter/search/sort tags are ignored by huma and consumed by query.Scopes.

type SettingsCreateInput

type SettingsCreateInput struct {
	Body SettingBody
}

SettingsCreateInput holds the request parameters for SettingsCreate.

type SettingsCreateOutput

type SettingsCreateOutput struct {
	Body db.Setting
}

SettingsCreateOutput holds the response body for SettingsCreate.

type SettingsDeleteInput

type SettingsDeleteInput struct {
	Key string `path:"key"`
}

SettingsDeleteInput holds the request parameters for SettingsDelete.

type SettingsDeleteOutput

type SettingsDeleteOutput struct {
	Status int
}

SettingsDeleteOutput holds the response status for SettingsDelete.

type SettingsGetInput

type SettingsGetInput struct {
	Key string `path:"key"`
}

SettingsGetInput holds the request parameters for SettingsGet.

type SettingsGetOutput

type SettingsGetOutput struct {
	Body db.Setting
}

SettingsGetOutput holds the response body for SettingsGet.

type SettingsListInput

type SettingsListInput struct {
	SettingListQuery
}

SettingsListInput holds the request parameters for SettingsList.

type SettingsListOutput

type SettingsListOutput struct {
	Body query.PaginatedResponse[db.Setting]
}

SettingsListOutput holds the response body for SettingsList.

type SettingsPaletteSearchInput

type SettingsPaletteSearchInput struct {
	Q string `query:"q" required:"false" maxLength:"128"`
}

SettingsPaletteSearchInput holds the query for SettingsPaletteSearch.

type SettingsPaletteSearchOutput

type SettingsPaletteSearchOutput struct {
	Body []PaletteSetting
}

SettingsPaletteSearchOutput holds the response body for SettingsPaletteSearch.

type SettingsUpdateInput

type SettingsUpdateInput struct {
	Key  string `path:"key"`
	Body SettingBody
}

SettingsUpdateInput holds the request parameters for SettingsUpdate.

type SettingsUpdateOutput

type SettingsUpdateOutput struct {
	Body db.Setting
}

SettingsUpdateOutput holds the response body for SettingsUpdate.

type StaffStatsResponse

type StaffStatsResponse struct {
	MyCourses         int64           `json:"my_courses"`
	JoinableCourses   int64           `json:"joinable_courses"`
	ArchivedCourses   int64           `json:"archived_courses"`
	SemesterBreakdown []SemesterCount `json:"semester_breakdown"`
	MyStudents        int64           `json:"my_students"`
	MyTutors          int64           `json:"my_tutors"`
	MyExercises       int64           `json:"my_exercises"`
}

StaffStatsResponse holds dashboard stats scoped to a single staff member.

func ComputeStaffStats

func ComputeStaffStats(gdb *gorm.DB, userID string) StaffStatsResponse

ComputeStaffStats aggregates dashboard statistics scoped to the courses owned by the given user ID or granted to them via course_accesses.

type StatsInput

type StatsInput struct{}

StatsInput holds the request parameters for Stats (none).

type StatsOutput

type StatsOutput struct {
	Body StatsResponse
}

StatsOutput holds the response body for Stats.

type StatsResponse

type StatsResponse struct {
	TotalUsers        int64           `json:"total_users"`
	StaffUsers        int64           `json:"total_staff"`
	AdminUsers        int64           `json:"admin_users"`
	TotalCourses      int64           `json:"total_courses"`
	JoinableCourses   int64           `json:"joinable_courses"`
	ArchivedCourses   int64           `json:"archived_courses"`
	TotalStudents     int64           `json:"total_students"`
	TotalTutors       int64           `json:"total_tutors"`
	TotalAuditLogs    int64           `json:"total_audit_logs"`
	TotalExercises    int64           `json:"total_exercises"`
	ActiveSessions    int64           `json:"active_sessions"`
	TotalTasks        int64           `json:"total_tasks"`
	ScheduledTasks    int64           `json:"scheduled_tasks"`
	OrphanOrgs        int64           `json:"orphan_orgs"`
	SemesterBreakdown []SemesterCount `json:"semester_breakdown"`
}

StatsResponse is the response body of GET /stats. It aggregates counts across the major tables and includes a Forgejo orphan-org count when the Forgejo client is configured.

func ComputeStats

func ComputeStats(gdb *gorm.DB, manager *tasks.Manager) StatsResponse

ComputeStats aggregates dashboard statistics. Exported so the HTML fragment handler (which has *app.App but not *api.Handler) can call it. The orphan-org count needs the Forgejo client, which is a package-level singleton, so this function has no receiver.

type StudentBuild

type StudentBuild struct {
	Exercise    string    `json:"exercise"`
	Status      string    `json:"status"`
	JobID       uint      `json:"job_id"`
	Warning     string    `json:"warning"`
	FailedSteps []string  `json:"failed_steps"`
	Deadline    time.Time `json:"deadline"`
}

StudentBuild is one exercise's latest build state on the student repo page. Warning is empty, "zero" for a failed build before the deadline, or "error" when the build could not run. It never carries points: the builder reports pass/fail, not a score.

type StudentOut

type StudentOut struct {
	ID             uint       `json:"id"`
	Matrikelnummer *int       `json:"matrikelnummer"`
	CourseID       uint       `json:"course_id"`
	UserID         string     `json:"user_id"`
	TutorID        *uint      `json:"tutor_id"`
	User           *UserBrief `json:"user,omitempty"`
	// Email is only populated by ListCourseStudents, which is reachable
	// exclusively by callers who may manage the course. Other constructors
	// (studentsToOut, the set-tutor handler) leave it empty, keeping the
	// tutor-facing endpoints trimmed to the UserBrief identity fields.
	Email string      `json:"email,omitempty"`
	Tutor *TutorBrief `json:"tutor,omitempty"`
}

StudentOut is the public shape of a course-student row. It mirrors the flat db.Student fields and embeds the preloaded user as a trimmed UserBrief. db.Student.User is tagged json:"-" in the model (repo-wide convention to avoid serialization loops), so the DTO carries the user explicitly and controls exactly which user fields leave the API.

type Studienleistung

type Studienleistung struct {
	PassPoints  float64 `json:"pass_points"`
	PassPercent float64 `json:"pass_percent"`
	PassBasis   string  `json:"pass_basis"`
	Passed      bool    `json:"passed"`
}

Studienleistung is the pass status derived from the configured threshold. It never stores a score; the points are the same exercise and tutorial points returned in Total.

type TaskGetInput

type TaskGetInput struct {
	Name string `path:"name"`
}

TaskGetInput holds the request parameters for TaskGet.

type TaskGetOutput

type TaskGetOutput struct {
	Body tasks.Snapshot
}

TaskGetOutput holds the response body for TaskGet.

type TaskListInput

type TaskListInput struct{}

TaskListInput holds the request parameters for TaskList (none).

type TaskListOutput

type TaskListOutput struct {
	Body []tasks.Snapshot
}

TaskListOutput holds the response body for TaskList.

type TaskRunInput

type TaskRunInput struct {
	Name string `path:"name"`
}

TaskRunInput holds the request parameters for TaskRun.

type TaskRunOutput

type TaskRunOutput struct {
	Body tasks.Snapshot
}

TaskRunOutput holds the response body for TaskRun.

type TasksPaletteSearchInput

type TasksPaletteSearchInput struct {
	Q string `query:"q" required:"false" maxLength:"128"`
}

TasksPaletteSearchInput holds the query for TasksPaletteSearch.

type TasksPaletteSearchOutput

type TasksPaletteSearchOutput struct {
	Body []PaletteTask
}

TasksPaletteSearchOutput holds the response body for TasksPaletteSearch.

type TimeSeries

type TimeSeries struct {
	Label  string            `json:"label"`
	Points []TimeSeriesPoint `json:"points"`
}

TimeSeries is a named series of time-series points.

type TimeSeriesPoint

type TimeSeriesPoint struct {
	Date  string `json:"date"`
	Count int64  `json:"count"`
}

TimeSeriesPoint is a single point in a time series.

type TutorAssignmentBrief

type TutorAssignmentBrief struct {
	Name              string `json:"name"`
	PreferredUsername string `json:"preferred_username"`
	Email             string `json:"email"`
}

TutorAssignmentBrief is the trimmed tutor identity returned by the tutor-assignment lookup endpoints. Name may be empty (the client falls back to preferred_username then). Email is included so clients can show a mailto link to the tutor.

type TutorAssignmentOut

type TutorAssignmentOut struct {
	Tutor *TutorAssignmentBrief `json:"tutor"`
}

TutorAssignmentOut is the response body of the tutor-assignment lookup endpoints. Tutor is null when the user has no students row in the course, no assigned tutor, or the tutor's user record is missing; the client hides the label then.

type TutorBrief

type TutorBrief struct {
	ID     uint   `json:"id"`
	UserID string `json:"user_id"`
	Name   string `json:"name"`
}

TutorBrief is a trimmed tutor representation for course-student list endpoints. Name is the tutor's user name (empty when the user is not loaded or soft-deleted).

type TutorOut

type TutorOut struct {
	ID           uint       `json:"id"`
	Description  string     `json:"description"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	CourseID     uint       `json:"course_id"`
	UserID       string     `json:"user_id"`
	StudentCount int64      `json:"student_count"`
	User         *UserBrief `json:"user,omitempty"`
}

TutorOut is the public shape of a course-tutor row. It mirrors the flat db.Tutor fields and embeds the preloaded user as a trimmed UserBrief. db.Tutor.User is tagged json:"-" in the model (repo-wide convention to avoid serialization loops), so the DTO carries the user explicitly and controls exactly which user fields leave the API.

type TutorUserSearchResult

type TutorUserSearchResult struct {
	Items      []db.User
	Page       int
	PageSize   int
	TotalItems int64
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

TutorUserSearchResult holds the paginated result of the tutor-assignment user search.

func SearchUsersForTutorAssignment

func SearchUsersForTutorAssignment(gdb *gorm.DB, search, matrikelnummer string, page, pageSize int, courseID uint) (TutorUserSearchResult, error)

SearchUsersForTutorAssignment returns a paginated list of users matching the search string (ILIKE on name, email, student_id, and preferred_username, mirroring AdminListUsers) and the matrikelnummer filter (ILIKE on student_id), excluding users who are already tutors of courseID. Used by the tutor-assignment page's user list so already-assigned tutors do not show up as add candidates.

type TutorialPoints

type TutorialPoints struct {
	Attended      int     `json:"attended"`
	Total         int     `json:"total"`
	Points        float64 `json:"points"`
	MaxPoints     float64 `json:"max_points"`
	Presentations int     `json:"presentations"`
}

TutorialPoints is the tutorial part of the course points summary. Attended and Total count exercises with tutorial points, not attendance rows.

type UpdateUserBody

type UpdateUserBody struct {
	Subject           string  `json:"subject" required:"false"`
	PreferredUsername string  `json:"preferred_username" required:"false"`
	StudentID         string  `json:"student_id" required:"false"`
	AccountType       string  `json:"account_type" required:"false"`
	Faculty           string  `json:"faculty" required:"false"`
	EnrolledSubject   string  `json:"enrolled_subject" required:"false"`
	Role              db.Role `json:"role" required:"false"`
}

UpdateUserBody is the request body for updating a user. name, email, and extra_claims are excluded because the update path never writes them. name is now the admin-managed display name and is intentionally only editable through the /admin/fragments/users/:id/display-name fragment route: query.BodyMap marshals the whole body, so declaring name here would blank the stored name on every partial update. subject is still accepted so the identity-uniqueness check sees the same values the handler checks, but it is omitted from the update payload.

type UserAdminItem

type UserAdminItem struct {
	db.User `json:"user"`

	SessionCount int            `json:"session_count"`
	LastLogin    *time.Time     `json:"last_login"`
	Sessions     []SessionBrief `json:"sessions"`

	OwnedCourses    []CourseBrief `json:"owned_courses"`
	TutoredCourses  []CourseBrief `json:"tutored_courses"`
	EnrolledCourses []CourseBrief `json:"enrolled_courses"`
	GrantedCourses  []CourseBrief `json:"granted_courses"`

	APIKeys []db.ApiKey `json:"api_keys"`

	Grades []RecentGradeItem `json:"grades"`

	IsProtectedAdmin bool `json:"is_protected_admin"`
}

UserAdminItem is the full user representation for the admin users page, including session and course relationship data.

func AdminGetUser

func AdminGetUser(gdb *gorm.DB, id string) (UserAdminItem, error)

AdminGetUser fetches a single user with sessions and course relationships for the admin detail modal. Returns the enriched UserAdminItem.

func ScopedGetUser

func ScopedGetUser(gdb *gorm.DB, ownerID, targetUserID string) (UserAdminItem, error)

ScopedGetUser fetches a single user if they are within the caller's scope (self, a student/tutor in a course the caller owns or was granted via course_accesses, or a student assigned to a tutor slot the caller holds). Returns gorm.ErrRecordNotFound if the target is out of scope.

type UserBrief

type UserBrief struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	PreferredUsername string `json:"preferred_username"`
}

UserBrief is a trimmed user representation that is safe to embed in list endpoints reachable by non-admin staff (e.g. tutors viewing their students). It exposes only identity fields; email, OIDC subject, student ID (matrikelnummer), account type, faculty, enrolled subject, raw extra claims, and the global role are intentionally omitted.

func (UserBrief) ResolvedName

func (u UserBrief) ResolvedName() string

ResolvedName returns the name to render for the brief. Name is already the resolved display name when the brief was built from a db.User; the preferred username covers briefs built without one.

type UserCourseItem

type UserCourseItem struct {
	CourseBrief
	Roles []string         `json:"roles"`
	Repos []UserCourseRepo `json:"repos"`
}

UserCourseItem pairs a course with the roles the profile user holds in it and the repositories that user can access. Used by the Forgejo profile page.

type UserCourseRepo

type UserCourseRepo struct {
	Name string `json:"name"`
	Path string `json:"path"`
	// Kind distinguishes the per-student repo ("personal") and the two shared
	// repos with a special label ("tutors", "forum") from ordinary course
	// repos ("course").
	Kind string `json:"kind"`
}

UserCourseRepo is one Forgejo repository the profile user can access in a course. Path is the full repository path below the Forgejo web root ("<semester>-<name>/<repo>"), so the template can link to it without knowing the course repo naming rules.

type UserListQuery

type UserListQuery struct {
	ID        string `query:"id" required:"false" filter:"id"`
	Email     string `query:"email" required:"false" filter:"email"`
	Subject   string `query:"subject" required:"false" filter:"subject"`
	StudentID string `query:"student_id" required:"false" filter:"student_id"`
	Role      string `query:"role" required:"false" filter:"role"`
	Search    string `query:"search" required:"false" search:"name,oidc_name,email"`
	SortBy    string `query:"sort_by" required:"false" sort:"id,name,email,created_at,updated_at,student_id,role" default_sort:"created_at desc"`
	SortDir   string `query:"sort_dir" required:"false"`
	Page      int    `query:"page" default:"1"`
	PageSize  int    `query:"page_size" default:"25"`
}

UserListQuery holds the filter and pagination inputs for GET /users. The query/default tags drive huma's request binding; the filter/search/sort tags are ignored by huma and consumed by query.Scopes.

type UsersAdminListInput

type UsersAdminListInput struct {
	UsersAdminListQuery
}

UsersAdminListInput holds the request parameters for UsersAdminList.

type UsersAdminListOutput

type UsersAdminListOutput struct {
	Body query.PaginatedResponse[UserAdminItem]
}

UsersAdminListOutput holds the response body for UsersAdminList.

type UsersAdminListParams

type UsersAdminListParams struct {
	Search         string
	Role           string
	Matrikelnummer string
	Tutor          bool
	SortBy         string
	SortDir        string
	Page           int
	PageSize       int
}

UsersAdminListParams holds the filter/sort/pagination inputs for the admin users list. Shared by the JSON API handler and the HTML fragment handler.

func ParseUsersAdminListParams

func ParseUsersAdminListParams(c *echo.Context) UsersAdminListParams

ParseUsersAdminListParams extracts UsersAdminListParams from query string. Shared by the JSON API handler, the HTML fragment handler, and the page handler so all three paths agree on how params are read.

type UsersAdminListQuery

type UsersAdminListQuery struct {
	Search         string `query:"search" required:"false"`
	Role           string `query:"role" required:"false"`
	Matrikelnummer string `query:"matrikelnummer" required:"false"`
	Tutor          bool   `query:"tutor" required:"false"`
	SortBy         string `query:"sort_by" required:"false"`
	SortDir        string `query:"sort_dir" required:"false"`
	Page           int    `query:"page" default:"1"`
	PageSize       int    `query:"page_size" default:"25"`
}

UsersAdminListQuery holds the filter/sort/pagination inputs for the admin users list. The query/default tags drive huma's request binding; the values are mapped into UsersAdminListParams for the shared AdminListUsers query path.

type UsersAdminListResult

type UsersAdminListResult struct {
	Items      []UserAdminItem
	Total      int64
	Page       int
	PageSize   int
	TotalPages int
	HasNext    bool
	HasPrev    bool
}

UsersAdminListResult holds the paginated result of an admin users list query.

func AdminListUsers

func AdminListUsers(gdb *gorm.DB, p UsersAdminListParams) (UsersAdminListResult, error)

AdminListUsers runs the admin users list query and returns enriched items with pagination metadata. Used by both the JSON API handler and the HTML fragment handler: one query path, two response formats.

func ScopedListUsers

func ScopedListUsers(gdb *gorm.DB, p UsersAdminListParams, ownerID string) (UsersAdminListResult, error)

ScopedListUsers runs the admin users list query but restricts results to users visible to the given staff member: themselves, plus students and tutors of courses they own or were granted via course_accesses. Used by staff-scoped fragment handlers.

type UsersCourseReposInput

type UsersCourseReposInput struct {
	User string `path:"user"`
}

UsersCourseReposInput holds the request parameters for UsersCourseRepos.

type UsersCourseReposOutput

type UsersCourseReposOutput struct {
	Body []UserCourseItem
}

UsersCourseReposOutput holds the response body for UsersCourseRepos.

type UsersCoursesInput

type UsersCoursesInput struct {
	User string `path:"user"`
}

UsersCoursesInput holds the request parameters for UsersCourses.

type UsersCoursesOutput

type UsersCoursesOutput struct {
	Body []MyCourseItem
}

UsersCoursesOutput holds the response body for UsersCourses.

type UsersCreateInput

type UsersCreateInput struct {
	Body CreateUserBody
}

UsersCreateInput holds the request parameters for UsersCreate.

type UsersCreateOutput

type UsersCreateOutput struct {
	Body db.User
}

UsersCreateOutput holds the response body for UsersCreate.

type UsersDeleteInput

type UsersDeleteInput struct {
	User string `path:"user"`
}

UsersDeleteInput holds the request parameters for UsersDelete.

type UsersDeleteOutput

type UsersDeleteOutput struct {
	Status int
}

UsersDeleteOutput holds the response status for UsersDelete.

type UsersDeleteSessionsInput

type UsersDeleteSessionsInput struct {
	User string `path:"user"`
}

UsersDeleteSessionsInput holds the request parameters for UsersDeleteSessions.

type UsersDeleteSessionsOutput

type UsersDeleteSessionsOutput struct {
	Body struct {
		DeletedCount int64 `json:"deleted_count"`
	}
}

UsersDeleteSessionsOutput holds the response body for UsersDeleteSessions.

type UsersGetInput

type UsersGetInput struct {
	User string `path:"user"`
}

UsersGetInput holds the request parameters for UsersGet.

type UsersGetOutput

type UsersGetOutput struct {
	Body db.User
}

UsersGetOutput holds the response body for UsersGet.

type UsersGradesInput

type UsersGradesInput struct {
	User string `path:"user"`
}

UsersGradesInput holds the request parameters for UsersGrades (none).

type UsersGradesOutput

type UsersGradesOutput struct {
	Body []GradeItem
}

UsersGradesOutput holds the response body for UsersGrades.

type UsersListInput

type UsersListInput struct {
	UserListQuery
}

UsersListInput holds the request parameters for UsersList.

type UsersListOutput

type UsersListOutput struct {
	Body query.PaginatedResponse[db.User]
}

UsersListOutput holds the response body for UsersList.

type UsersPaletteSearchInput

type UsersPaletteSearchInput struct {
	Q string `query:"q" required:"false" maxLength:"128"`
}

UsersPaletteSearchInput holds the query for UsersPaletteSearch.

type UsersPaletteSearchOutput

type UsersPaletteSearchOutput struct {
	Body []PaletteUser
}

UsersPaletteSearchOutput holds the response body for UsersPaletteSearch.

type UsersParticipationsInput

type UsersParticipationsInput struct {
	User string `path:"user"`
}

UsersParticipationsInput holds the request parameters for UsersParticipations (none).

type UsersParticipationsOutput

type UsersParticipationsOutput struct {
	Body []ParticipationItem
}

UsersParticipationsOutput holds the response body for UsersParticipations.

type UsersRecentGradesInput

type UsersRecentGradesInput struct {
	User string `path:"user"`
}

UsersRecentGradesInput holds the request parameters for UsersRecentGrades (none).

type UsersRecentGradesOutput

type UsersRecentGradesOutput struct {
	Body []RecentGradeItem
}

UsersRecentGradesOutput holds the response body for UsersRecentGrades.

type UsersRepairReposInput

type UsersRepairReposInput struct {
	User string `path:"user"`
}

UsersRepairReposInput holds the request parameters for UsersRepairRepos.

type UsersRepairReposOutput

type UsersRepairReposOutput struct {
	Body UsersRepairReposResult
}

UsersRepairReposOutput holds the response body for UsersRepairRepos.

type UsersRepairReposResult

type UsersRepairReposResult struct {
	Status string `json:"status"`
}

UsersRepairReposResult reports what the request triggered. "scheduled" means a repair goroutine was started, "cooldown" means the user was repaired recently and the request was answered without Forgejo work, "in_progress" means another repair for this user is currently running, and "disabled" means Forgejo is not configured.

type UsersUpdateInput

type UsersUpdateInput struct {
	User string `path:"user"`
	Body UpdateUserBody
}

UsersUpdateInput holds the request parameters for UsersUpdate.

type UsersUpdateOutput

type UsersUpdateOutput struct {
	Body db.User
}

UsersUpdateOutput holds the response body for UsersUpdate.

Directories

Path Synopsis
Package query provides tag-driven request binding, GORM scopes, pagination, and data access helpers for the API layer.
Package query provides tag-driven request binding, GORM scopes, pagination, and data access helpers for the API layer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL