fragments

package
v0.0.0-...-255846a Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttendedThisWeekStudentIDs

func AttendedThisWeekStudentIDs(gdb *gorm.DB, courseID uint, weekStart, endOfDay time.Time) map[uint]bool

AttendedThisWeekStudentIDs returns the student IDs with a participation record in the course between weekStart and endOfDay, regardless of which tutor logged it. One bulk query; used to render the weekly cap in the attendance lists.

func BuildJobsServiceError

func BuildJobsServiceError(err error) (string, string)

BuildJobsServiceError returns the card title and message for a build jobs query failure. A missing service is reported as not configured; anything else is reported as unreachable. Shared by the page and fragment handlers.

func BuildStatsServiceError

func BuildStatsServiceError(err error) (string, string)

BuildStatsServiceError returns the card title and message for a build stats query failure, mirroring BuildJobsServiceError.

func LoadBuildJob

func LoadBuildJob(client *grading.Client, id string) (grading.Job, string)

LoadBuildJob fetches one build job for the staff detail page and the builds overview modal. A non-empty reason describes why the job is unavailable: no id, no configured client, not found, or unreachable. Both entry points share this helper so they render the same notice for the same failure.

func LoadTutorPanelData

func LoadTutorPanelData(gdb *gorm.DB, courseID string) ([]db.Tutor, map[uint]int64, error)

LoadTutorPanelData loads the course's tutors (users preloaded) and the per-tutor student counts used by the tutor panel. Exported so the page handler can reuse it for the initial server-side render.

func MethodBadgeClass

func MethodBadgeClass(method string) string

MethodBadgeClass maps an HTTP method to a daisyUI badge colour.

func ResolveTutorID

func ResolveTutorID(tutors []db.Tutor, requested string) (uint, bool)

ResolveTutorID returns the selected tutor ID: the requested one when it belongs to the course, otherwise the first tutor by id. ok is false when the course has no tutors.

func TutorGroupsFragmentURL

func TutorGroupsFragmentURL(c db.Course, query string) string

TutorGroupsFragmentURL returns the main fragment URL plus the given groups-tab query string.

func TutorGroupsQuery

func TutorGroupsQuery(p TutorGroupsParams, extra map[string]string) string

TutorGroupsQuery builds the query string for groups-tab fragment requests: tab, selected tutor, both searches, and both page numbers. Empty searches are omitted so URLs stay short. extra adds or overrides single params.

func WarningsCount

func WarningsCount(ws []config.ConfigWarning, severities ...string) int

WarningsCount counts the warnings whose severity is in the given list. Used to count only warning and error severities, excluding info.

func WeekStartOfDay

func WeekStartOfDay(startOfDay time.Time) time.Time

WeekStartOfDay returns Monday 00:00 of the week containing startOfDay.

Types

type DashHealthData

type DashHealthData struct {
	Summary        health.Summary
	Checks         []health.Result
	LastSweep      time.Time
	Beszel         *health.BeszelSnapshot
	Errors24h      ForgejoErrorStats
	Warnings       []config.ConfigWarning
	ActiveWarnings int
	HasData        bool
}

DashHealthData carries the health-check snapshot, Beszel metrics and Forgejo error stats for the dashboard system panel. Every field stays empty when health is not configured or has not run yet. Warnings is the merged list of config and runtime warnings, activeWarnings counts only the warning and error severities.

type DashboardCourse

type DashboardCourse struct {
	ID           uint
	Name         string
	Semester     string
	AllowJoin    bool
	StudentCount int64
}

DashboardCourse is one course row shown on a dashboard, with its student count.

type DashboardData

type DashboardData struct {
	Stats           api.StatsResponse
	Config          *config.Config
	Now             time.Time
	CurrentSemester string
	Deadlines       []DashboardDeadline
	UngradedCount   int64
	CurrentCourses  []DashboardCourse
	Health          DashHealthData
}

DashboardData holds everything the admin dashboard renders: the aggregate stats, config-based health info, upcoming deadlines, the grading backlog and the courses of the current semester.

func LoadDashboardData

func LoadDashboardData(gdb *gorm.DB, stats api.StatsResponse, cfg *config.Config, healthRunner *health.Runner) DashboardData

LoadDashboardData assembles the admin dashboard data. Stats are computed by the caller (api.ComputeStats) so this loader only touches the database for the dashboard-specific queries. The health argument may be nil.

type DashboardDeadline

type DashboardDeadline struct {
	ExerciseID     uint
	ExerciseName   string
	CourseID       uint
	CourseName     string
	CourseSemester string
	End            time.Time
}

DashboardDeadline is one exercise deadline shown on a dashboard, with its course for context.

type ForgejoErrorSource

type ForgejoErrorSource struct {
	Source string
	Count  int64
}

ForgejoErrorSource is one call-site label with its error count.

type ForgejoErrorStats

type ForgejoErrorStats struct {
	Window        string
	Total         int64
	ServerErrors  int64
	NetworkErrors int64
	TopSources    []ForgejoErrorSource
}

ForgejoErrorStats aggregates Forgejo request outcomes over a time window.

func LoadForgejoErrorStats

func LoadForgejoErrorStats(gdb *gorm.DB, window string, since, now time.Time) ForgejoErrorStats

LoadForgejoErrorStats aggregates error counts for the forgejo_requests rows created within the given window ending at now. ServerErrors counts status codes >= 500, NetworkErrors counts rows with a transport error, and TopSources is the per-source error count, worst three first.

type Handler

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

Handler serves HTML fragments for htmx-driven page sections. Each method returns a templ component rendered as HTML, not a full page, just the swap target. Routes are registered under /admin/fragments.

func NewHandler

func NewHandler(a *app.App) *Handler

func (*Handler) AccountAPIKeyCreate

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

func (*Handler) AccountAPIKeyDelete

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

func (*Handler) AdminAPIKeyDelete

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

func (*Handler) AttendanceAddRowFragmentHandler

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

AttendanceAddRowFragmentHandler returns the attendance row for one student of the course so the tutor can mark them present. The row uses the guest flow: only the acting tutor's own participation row is read or modified, and an empty replacement of the search results is sent out-of-band so the same student cannot be added twice. When the student already attended the course this week with any tutor, the row is rendered with the cap badge and a disabled present button, so adding it is a no-op. Students of the tutor's own group are rejected because they are already listed.

func (*Handler) AttendanceAddSearchFragmentHandler

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

AttendanceAddSearchFragmentHandler returns the candidate list for the "add student" search on the manual attendance page. It matches students of the course by display name or short name (preferred_username) and excludes students already listed or already capped: the tutor's own group, and students who already attended the course this week with any tutor.

func (*Handler) AttendanceManageFragmentHandler

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

AttendanceManageFragmentHandler returns the attendance management body (search + student table) for htmx swap. Only students assigned to the calling tutor are shown.

func (*Handler) AttendanceToggleFragmentHandler

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

AttendanceToggleFragmentHandler handles POST /admin/fragments/attendance/toggle. Toggles a student's attendance or presented status for today. Returns the updated row HTML. Lookups and mutations are scoped to the acting tutor, so a participation row created by another tutor is never modified. A student can attend at most one tutorial per week per course regardless of tutor: before creating a new row, the handler checks for any participation of that student in the current week (Monday based) and refuses with a re-rendered row when one exists.

func (*Handler) AuditLogDetailFragmentHandler

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

AuditLogDetailFragmentHandler returns the modal body for a single audit log entry.

func (*Handler) AuditLogFragmentHandler

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

AuditLogFragmentHandler returns the #audit-log-table fragment for htmx swap.

func (*Handler) BuildJobDetailFragmentHandler

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

BuildJobDetailFragmentHandler returns the modal body for a single build job. The Detail button in the builds table loads it into #build_job_detail_body and opens the dialog. Failures render the unavailable notice with status 200 so the modal shows the reason instead of an empty body or a failed htmx swap.

func (*Handler) BuildJobsFragmentHandler

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

BuildJobsFragmentHandler returns the #builds-body fragment for htmx swap. Invalid filter values render an inline error in the table region with status 200 so htmx swaps it in; a missing or unreachable build service renders the warning card instead of an error, so the page stays navigable.

func (*Handler) BuildStatsFragmentHandler

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

BuildStatsFragmentHandler returns the #build-stats-body fragment for htmx swap. Invalid filter values render an inline error with status 200 so htmx swaps it in; a missing or unreachable build service renders the warning card instead of an error. The stats query covers every job matching the filters.

func (*Handler) CourseAccessFormHandler

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

CourseAccessFormHandler handles GET /admin/fragments/courses/:id/access. Returns the course access modal body for the course.

func (*Handler) CourseAccessGrantHandler

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

CourseAccessGrantHandler handles POST /admin/fragments/courses/:id/access. Gives the selected staff user access to the course; the Forgejo hook adds the user to the course tutors team. Idempotent: re-granting an existing pair is a no-op that still re-renders the modal body. Returns the refreshed modal body.

func (*Handler) CourseAccessRevokeHandler

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

CourseAccessRevokeHandler handles DELETE /admin/fragments/courses/:id/access/:userID. Removes a course access grant. A missing grant is reported as 404. Returns the refreshed modal body.

func (*Handler) CourseArchiveHandler

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

CourseArchiveHandler returns the archive-course confirmation modal body.

func (*Handler) CourseCreateHandler

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

CourseCreateHandler handles POST /admin/fragments/courses/new. Validates, creates the course, records audit, and returns the create form again (reset to empty) so the modal is ready for the next create. Fires course-saved so the table refreshes. On validation failure returns the form with errors populated and HTTP 422.

func (*Handler) CourseDeleteHandler

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

CourseDeleteHandler handles DELETE .../. Archives (soft-deletes) the course, fires course-saved, returns the refreshed table.

func (*Handler) CourseEditFormHandler

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

CourseEditFormHandler returns an edit-course form modal body, pre-filled with the course's current values.

func (*Handler) CourseNewFormHandler

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

CourseNewFormHandler returns an empty create-course form modal body.

func (*Handler) CoursePermanentDeleteFormHandler

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

CoursePermanentDeleteFormHandler returns the permanent-delete confirmation modal body.

func (*Handler) CoursePermanentDeleteHandler

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

CoursePermanentDeleteHandler handles DELETE .../permanent. Hard-deletes an already-archived course. Requires the confirm form field to match the course label. Fires course-saved, returns the refreshed table.

func (*Handler) CourseReposAddHandler

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

CourseReposAddHandler handles POST .../settings/course_repos/add. Parses the current form, appends an empty spec, re-renders the form.

func (*Handler) CourseReposRemoveHandler

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

CourseReposRemoveHandler handles POST .../settings/course_repos/remove. Parses the current form, removes the spec at remove_index, re-renders.

func (*Handler) CourseRestoreFormHandler

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

CourseRestoreFormHandler returns the restore-course confirmation modal body.

func (*Handler) CourseRestoreHandler

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

CourseRestoreHandler handles POST .../restore. Restores the course, fires course-saved, returns the refreshed table.

func (*Handler) CourseUpdateHandler

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

CourseUpdateHandler handles PUT /admin/fragments/courses/:id/edit. Validates, updates, records audit, returns the edit form refreshed. Fires course-saved so the table refreshes.

func (*Handler) CoursesFragmentHandler

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

CoursesFragmentHandler returns the #courses-table fragment for htmx swap. Triggered by filter changes, pagination, and the course-saved event. Staff see only the courses they own; admins see all.

func (*Handler) DashHealthRunAllHandler

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

DashHealthRunAllHandler runs every health check and returns the refreshed system panel. Fires HX-Trigger:dash-health-refresh so any sibling listeners pick up fresh data too.

func (*Handler) DashSystemFragmentHandler

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

DashSystemFragmentHandler returns the refreshed dashboard system panel. Triggered by the 60s panel poll, the dash-health-refresh event, and the panel's own refresh button.

func (*Handler) DashWarningsFragmentHandler

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

DashWarningsFragmentHandler returns the refreshed warnings banner at the top of the admin dashboard. Triggered by the 60s banner poll and the dash-health-refresh event fired by the system panel's run-all button. Renders an empty swap when there are no active warnings.

func (*Handler) ExerciseCreateHandler

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

ExerciseCreateHandler handles POST /admin/fragments/courses/:id/exercises/new.

func (*Handler) ExerciseDeleteFormHandler

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

ExerciseDeleteFormHandler returns the delete confirmation modal body.

func (*Handler) ExerciseDeleteHandler

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

ExerciseDeleteHandler handles DELETE /admin/fragments/exercises/:eid.

func (*Handler) ExerciseEditFormHandler

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

ExerciseEditFormHandler returns a pre-filled edit-exercise form modal body.

func (*Handler) ExerciseNewFormHandler

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

ExerciseNewFormHandler returns an empty create-exercise form modal body.

func (*Handler) ExerciseUpdateHandler

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

ExerciseUpdateHandler handles PUT /admin/fragments/exercises/:eid/edit.

func (*Handler) ExercisesAllFragmentHandler

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

ExercisesAllFragmentHandler returns the #exercises-all-table fragment (rows + pagination + empty state) for htmx swap. Triggered by filter changes and pagination. Staff see only exercises in courses they own; admins see all.

func (*Handler) ExercisesFragmentHandler

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

ExercisesFragmentHandler returns the #exercises-tree fragment for htmx swap.

func (*Handler) ForgejoRequestDetailFragmentHandler

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

ForgejoRequestDetailFragmentHandler returns the modal body for a single Forgejo request entry.

func (*Handler) ForgejoRequestsFragmentHandler

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

ForgejoRequestsFragmentHandler returns the #forgejo-requests-table fragment.

func (*Handler) HTTPRequestDetailFragmentHandler

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

HTTPRequestDetailFragmentHandler returns the modal body for a single inbound request entry.

func (*Handler) HTTPRequestsFragmentHandler

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

HTTPRequestsFragmentHandler returns the #http-requests-body fragment: the chart card plus the request table, so filtering and pagination refresh both together.

func (*Handler) HealthCheckRunHandler

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

HealthCheckRunHandler runs one health check by name and returns the refreshed table. Fires HX-Trigger:health-refresh so the Beszel and error cards pick up fresh data too.

func (*Handler) HealthChecksFragmentHandler

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

HealthChecksFragmentHandler returns the #health-checks table fragment. Triggered by the 30s poll and the health-refresh event.

func (*Handler) HealthErrorsFragmentHandler

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

HealthErrorsFragmentHandler returns the Forgejo error stats card content wrapper.

func (*Handler) HealthResourcesFragmentHandler

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

HealthResourcesFragmentHandler returns the Beszel card content wrapper. The wrapper itself carries the poll attributes, so it swaps itself out.

func (*Handler) HealthRunAllHandler

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

HealthRunAllHandler runs every health check and returns the refreshed table. Fires HX-Trigger:health-refresh like the single-check run.

func (*Handler) HealthScheduledTasksFragmentHandler

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

HealthScheduledTasksFragmentHandler returns the scheduled task card.

func (*Handler) OrphanOrgsConfirmHandler

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

OrphanOrgsConfirmHandler returns the force-delete confirmation modal body for the orgs selected via the checkboxes. Rejects protected orgs.

func (*Handler) OrphanOrgsForceDeleteHandler

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

OrphanOrgsForceDeleteHandler handles the confirmed force delete. Re-reads the current classification from the database so protected orgs cannot be deleted by a stale or hand-crafted form submission, runs the repo-then-org deletion for each selected org, records an audit entry, and returns the refreshed table with a per-org result summary.

func (*Handler) OrphanOrgsFragmentHandler

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

OrphanOrgsFragmentHandler returns the orphan orgs table fragment.

func (*Handler) SettingsBodyHandler

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

SettingsBodyHandler returns the settings page body with current setting values loaded.

func (*Handler) SettingsSaveHandler

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

SettingsSaveHandler handles PUT /admin/fragments/settings/:key. Saves the setting value, records audit, and returns the refreshed settings body.

func (*Handler) StudentRemoveHandler

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

StudentRemoveHandler handles DELETE .../students/:userID. Removes the student, returns the refreshed students modal body.

func (*Handler) StudentsFormHandler

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

StudentsFormHandler returns the students modal body for a course.

func (*Handler) TaskRunHandler

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

TaskRunHandler starts a task and returns the refreshed table.

func (*Handler) TasksFragmentHandler

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

TasksFragmentHandler returns the unified tasks table fragment.

func (*Handler) TutorAddTutorModalFragmentHandler

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

TutorAddTutorModalFragmentHandler returns the add-tutor modal body (the user filter form plus the initially empty results list) for htmx swap into the modal shell's body div. Triggered by the Add tutor button in the tutors tab.

func (*Handler) TutorAssignHandler

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

TutorAssignHandler handles POST /admin/fragments/courses/:id/tutors with user_id. Assigns the user as tutor and returns the refreshed user list (the normal swap target inside the add-tutor modal, with a success or error message) plus, out-of-band, the tutor list behind the modal re-rendered so the newly added tutor shows up there. Duplicates are tolerated (the tutor is already assigned).

func (*Handler) TutorAssignStudentsHandler

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

TutorAssignStudentsHandler handles POST /admin/fragments/courses/:id/tutor-assignment/assign. Form values: user_id (single user id, optional) or repeated student values (checkbox list, optional; user_id wins if both are present), plus the tutor target: bulk_tutor_id (bulk bar select) or row_tutor_id (per-row select) when the body carries target=students from the students table, otherwise tutor_id ("none" clears the assignment). The students-table UI names its selects differently from the tutor_id filter field that the filter form also sends, so the two never collide. Assigns or clears the tutor for the listed students and re-renders the main fragment with a success or error alert.

func (*Handler) TutorAssignmentFragmentHandler

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

TutorAssignmentFragmentHandler returns the main tutor-assignment fragment (tutor panel + tab bar + active tab content) for htmx swap. Triggered by tab switches and after mutations that re-render the whole view. Staff see only courses they own (enforced via manageCourseGuard).

When the request targets only the students table (filter form and pagination swap #students-table), only the table fragment is returned so the filter inputs keep focus and text while typing or paging.

func (*Handler) TutorAutoDistributeHandler

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

TutorAutoDistributeHandler handles POST /admin/fragments/courses/:id/tutor-assignment/auto-distribute. Distributes the unassigned students across the course's tutors and re-renders the main fragment with a success or error alert.

func (*Handler) TutorPanelFragmentHandler

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

TutorPanelFragmentHandler returns the tutor list fragment (TutorPanelList inside #tutors-panel) for htmx swap.

func (*Handler) TutorUnassignHandler

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

TutorUnassignHandler handles DELETE /admin/fragments/courses/:id/tutors/:userID. In one transaction the tutor's students are unassigned (tutor_id set to NULL) before the tutor row is deleted, mirroring the API layer. Returns the refreshed tutor list.

func (*Handler) UserDeleteSessionsFragmentHandler

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

UserDeleteSessionsFragmentHandler handles the "Force logout" button in the detail modal: deletes OIDC sessions, records audit, returns the refreshed modal body. Fires HX-Trigger:user-updated so the table re-fetches.

func (*Handler) UserDetailFragmentHandler

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

UserDetailFragmentHandler returns the modal body for a single user. The eye button in the table loads this into #user_detail_body and opens the dialog.

func (*Handler) UserDisplayNameFragmentHandler

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

UserDisplayNameFragmentHandler handles the display-name input in the detail modal: validates the submitted value, stores it in users.name, records audit, syncs the Forgejo full name, and returns the refreshed modal body. The IdP-provided users.oidc_name is never written here. An empty value clears the display name so rendering falls back to the IdP name.

func (*Handler) UserRoleFragmentHandler

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

UserRoleFragmentHandler handles the role <select> in the detail modal: updates the user's global role, records audit, returns the refreshed modal body. Fires HX-Trigger:user-updated so the table re-fetches. Rejects unknown role values.

func (*Handler) UserSearchHandler

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

UserSearchHandler returns the add-tutor modal's user list (filtered, paginated add-candidate list) for htmx swap. Triggered by the filter form's keyup/submit. Renders results only when at least one filter is non-empty; otherwise the hint text. Excludes users who are already tutors of the queried course (course_id query param).

func (*Handler) UsersFragmentHandler

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

UsersFragmentHandler returns the #users-table fragment (rows + pagination + empty state) for htmx swap. Triggered by filter changes, pagination, and the user-updated event (after a mutation in the detail modal).

type HealthPageData

type HealthPageData struct {
	Checks           []health.Result
	Summary          health.Summary
	Beszel           *health.BeszelSnapshot
	BeszelConfigured bool
	System           HealthSystemData
	Config           *config.Config
	Warnings         []config.ConfigWarning
	InternalKeyUses  map[string]time.Time
	ScheduledTasks   []tasks.Snapshot
	Errors1h         ForgejoErrorStats
	Errors24h        ForgejoErrorStats
}

HealthPageData holds everything the admin health page renders. The page handler assembles it once; the fragments re-fetch their own slices on each htmx poll.

type HealthSystemData

type HealthSystemData struct {
	GoVersion        string
	UptimeSec        int64
	ServerTime       time.Time
	Timezone         string
	DBHost           string
	DBPort           string
	DBName           string
	AdminEmail       string
	OIDCIssuer       string
	OIDCRedirect     string
	ForgejoURL       string
	ForgejoTLSVerify bool
	BuildAPIURL      string
	RetentionAudit   int
	RetentionReq     int
	RetentionHTTP    int
	GradingLookback  string
	SessionSecure    bool
	SessionSameSite  string
	ProdMode         bool
}

HealthSystemData describes the orchestration process plus the static configuration rows the page shows in the collapsed config card.

type OrphanOrgRow

type OrphanOrgRow struct {
	Name string
	// RepoCount is the number of repositories in the org.
	RepoCount int
	// Status classifies the org against the course table.
	Status forgejo.OrphanOrgStatus
}

OrphanOrgRow is one Forgejo org on the orphan-orgs admin page.

func LoadOrphanOrgRows

func LoadOrphanOrgRows(gdb *gorm.DB) ([]OrphanOrgRow, error)

LoadOrphanOrgRows lists all Forgejo orgs, classifies each against all courses (including soft-deleted ones), and fetches the repo count per org. Used by the page handler and the fragment handler.

func (OrphanOrgRow) Deletable

func (r OrphanOrgRow) Deletable() bool

Deletable reports whether this org may be force-deleted (no matching course, active or archived).

type StaffDashboardData

type StaffDashboardData struct {
	Stats         api.StaffStatsResponse
	Now           time.Time
	Deadlines     []DashboardDeadline
	UngradedCount int64
	Courses       []DashboardCourse
}

StaffDashboardData holds everything the staff dashboard renders: stats scoped to the caller, their deadlines and the courses they own.

func LoadStaffDashboardData

func LoadStaffDashboardData(gdb *gorm.DB, stats api.StaffStatsResponse, userID string) StaffDashboardData

LoadStaffDashboardData assembles the staff dashboard data for one staff member: their owned courses plus courses granted to them via course_accesses.

type TutorGroupsData

type TutorGroupsData struct {
	TutorID    uint
	Assigned   api.CourseStudentListResult
	Unassigned api.CourseStudentListResult
}

TutorGroupsData holds everything TutorGroupsTab renders: the resolved tutor plus the two paginated student lists.

func LoadTutorGroupsData

func LoadTutorGroupsData(gdb *gorm.DB, courseID uint, p TutorGroupsParams) (TutorGroupsData, error)

LoadTutorGroupsData loads the assigned list for the selected tutor and the unassigned pool for the groups tab. Assignments are sorted by student name; the unassigned pool keeps the API default order.

type TutorGroupsParams

type TutorGroupsParams struct {
	TutorID        uint
	QAssigned      string
	QUnassigned    string
	PageAssigned   int
	PageUnassigned int
}

TutorGroupsParams holds the tutor-groups-tab filter state: the selected tutor, the two search strings, and the independent pagination state of the assigned and unassigned lists. TutorID is 0 when no tutor is selected (only possible while the course has no tutors).

func ParseTutorGroupsParams

func ParseTutorGroupsParams(c *echo.Context) TutorGroupsParams

ParseTutorGroupsParams extracts the groups-tab params from the query string.

func TutorGroupsParamsFromPost

func TutorGroupsParamsFromPost(c *echo.Context) TutorGroupsParams

TutorGroupsParamsFromPost extracts the groups-tab params from an htmx POST body. It falls back to the URL query when the body does not carry the tab=groups marker (the groups assign buttons always include it).

func (TutorGroupsParams) TutorIDString

func (p TutorGroupsParams) TutorIDString() string

TutorIDString returns the selected tutor ID in its URL/form string form, or an empty string when unset.

Jump to

Keyboard shortcuts

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