plexams.go

command module
v1.243.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: BSD-3-Clause Imports: 6 Imported by: ? 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.

README

GoDoc Go Report Card

plexams.go

plexams.go is a GraphQL/REST server for planning university exams (Prüfungsplanung) at HM (Hochschule München, FK07). It imports exam and teacher data from the ZPA system and student registration/conflict data from Primuss, connects them, and helps schedule exams, assign rooms and plan invigilations (Aufsichten).

It is the backend for plexams.gui and is driven entirely through that GUI. Most domain terminology and log messages are in German.

The former Cobra CLI has been removed: all functionality is now exposed as GraphQL queries/mutations/subscriptions or REST endpoints and driven from the GUI. It remains a single-user, local tool (no auth, localhost-only CORS).

Architecture

Layers, each its own package, wired together in bootstrap/ + main.go:

  • bootstrap/ — server entrypoint. main.go calls bootstrap.Serve(), which parses the three flags, loads config and constructs the central *plexams.Plexams instance, then starts the server. (Replaced the former Cobra cmd/ package.)
  • plexams/ — business logic. Almost all domain operations are methods on *Plexams, grouped by concern across many files.
  • db/ — MongoDB persistence (mongo-driver). Each semester is its own MongoDB database (named e.g. 2026-SS); rooms and NTAs live in a shared plexams database.
  • zpa/ — HTTP client for the external ZPA REST API.
  • graph/ — GraphQL API generated by gqlgen.

See CLAUDE.md for more detail on the internals.

Prerequisites

  • Go (see go.mod for the required version)
  • A running MongoDB instance
  • Access to the ZPA and Primuss systems (credentials in the config)

Build, test, lint

go build -o plexams.go .         # build the binary
go test ./...                    # run all tests
go vet ./...
golangci-lint-v2 run             # the linter used in CI/pre-commit
go generate ./...                # regenerate gqlgen code after editing *.graphqls

Install the pre-commit hooks once (gofmt, go vet, golangci-lint-v2, gitleaks):

pre-commit install

Configuration

Config is loaded via viper from a single file .plexams.yaml (in . or $HOME), which may optionally pin the semester (e.g. 2026-SS). There is no per-semester <semester>.yaml anymore — the per-semester config lives in the database and is edited through the GUI.

Key sections consumed by the code:

Section Purpose
semester optional pin of the active semester, e.g. 2026-SS (else auto-selected from the DB)
db.uri, db.database MongoDB connection
zpa.* baseurl, username, password/token, fk07programs, oldprograms
smtp.* mail server + testmail (dry-run recipient)
jira.* on-prem Jira (jira.cc.hm.edu) integration: baseurl, token (PAT), project (default key FK07PP); url feeds the jiraURL email helper
planer.* name/email of the planner (bootstrap/fallback; lives in DB)
operator.* name/email of the local operator running this instance; stamped onto the mutation_log (audit "who did what"). Local per planner, never in DB
server.* port, allowedorigins

The per-semester planning config (from/until, slots, forbiddenDays, emails, MUC.DAI slots) is not in the YAML — it lives in the DB (semester_config_input) and is edited through the GUI.

The only command-line surface is three flags: -v/--verbose, --db-uri, --semester. --semester optionally pins a workspace; without it the active workspace is auto-selected from the DB (and can be switched at runtime from the GUI via the setSemester mutation).

Secrets (ZPA token/password, SMTP password, Jira PAT) live in the config file, not in the DB. Keep the file out of version control.

Running

plexams.go is a server only — it has no subcommands anymore. Running it starts the GraphQL/REST server that plexams.gui talks to (GraphQL playground at /, queries/mutations at POST /query, subscriptions over websocket, and REST up/download routes on the same router; default CORS/origin allows localhost:5173/8080/3000):

plexams.go

Everything the old CLI did is now a GraphQL query/mutation/subscription or a REST endpoint, driven from the GUI.

Planning workflow

A typical semester runs roughly in this order, all from the GUI:

  1. Create the semester (createSemester mutation) and fill in the per-semester config.
  2. Import from ZPA — the importExamsFromZPA / importTeachersFromZPA / importInvigilatorRequirementsFromZPA subscriptions.
  3. Select exams to plan and add constraints.
  4. Import from Primuss (upload the Sammellisten ZIP to /upload/primuss-zip) and connect the exams, then generate the assembled exams and student regs (generatePreparation / generateAssembledExams / generateStudentRegs).
  5. Schedule — place exams (setExamTime), check with the validateConflicts / validateConstraints subscriptions.
  6. Rooms — assign rooms (assignRoomsForExams subscription); request building-management rooms (see below).
  7. Validate & upload — run the validate* subscriptions, then upload with uploadExamsToZPA (…WithRooms/WithInvigilators); publish the plan and send the announcement emails.
  8. Invigilations — collect requirements, generate the invigilation plan (assignInvigilations subscription), validate, and send the published-invigilations emails.
Building-management room requests

Some rooms must be requested externally: T-building rooms via Anny, the others via the Gebäudemanagement (building management). The management requests are managed in the DB (collection room_requests, per semester):

  1. Dry run: the roomRequestsPreview query shows which rooms would be requested for which exams — read-only, changes nothing.
  2. Apply once (applyRoomRequestsPreview mutation): writes the requests; it refuses to overwrite existing ones unless forced, so an already-approved set is not lost. Add extras with addRoomRequest, extend a request (e.g. for an NTA) with updateRoomRequestTime.
  3. Approve / deactivate individual requests as the management responds.
  4. Send the request email: the sendEmailRoomRequests subscription (with run: false for a dry run to smtp.testmail). Requires semesterConfig.emails.roomManagement.

Stored time ranges include a 15-minute buffer before and after the exam for setup and teardown.

API surface

The full surface is the GraphQL schema in graph/*.graphqls (queries, mutations, and LogLine-streaming subscriptions for imports, generation, validation, emails and ZPA upload) plus the REST routes registered in graph/server.go:

Route Purpose
POST /upload/primuss-zip, /upload/email-attachment(s-zip) Primuss Sammellisten ZIP, email-attachment uploads
POST /upload/jira-attachment attach an uploaded file (PDF/CSV) to a Jira issue (multipart: key, file)
GET /download/planned-rooms.json planned rooms export (for external cover-page generation)
GET /download/pdf/{kind} draft/plan PDFs (exams-to-plan, constraints, draft-fk08/fk10/exahm/muc.dai/fs/lba-rep, same-module-name; draft-si returns a ZIP)
GET /download/csv/{kind} draft CSVs (draft?program=…, exahm, lba-repeater)
GET /download/ics/{program} per-program exam calendar (ICS)
`GET/POST /download upload/semester-dump.zip, /dataset, /dataset-csv, /my-inputs-csv.zip`

Emails and ZPA upload run as subscriptions with a run/dryRun argument; with run: false/dryRun: true they only mail the smtp.testmail recipient / do not upload.

Optimization algorithms

The invigilation planning (simulated annealing) and the SEB/EXaHM pre-planning (DSATUR + SA repair) are documented in docs/algorithmen.md (German).

GraphQL / code generation

The GraphQL layer is generated by gqlgen (gqlgen.yml). Edit the schema in graph/*.graphqls, then run go generate ./.... Do not hand-edit the generated files (graph/generated/generated.go, graph/model/models_gen.go, the resolver signatures in graph/*.resolvers.go). Hand-written model types live alongside the generated ones in graph/model/ and are autobound.

License

BSD 3-Clause License — see LICENSE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package bootstrap wires up the plexams GraphQL server: it loads the lean bootstrap config (.plexams.yaml, credentials, db.uri), resolves/pins the active semester, constructs the *plexams.Plexams instance and starts the HTTP/GraphQL server.
Package bootstrap wires up the plexams GraphQL server: it loads the lean bootstrap config (.plexams.yaml, credentials, db.uri), resolves/pins the active semester, constructs the *plexams.Plexams instance and starts the HTTP/GraphQL server.
internal
mongotest
Package mongotest provides an ephemeral MongoDB for integration tests.
Package mongotest provides an ephemeral MongoDB for integration tests.
Package jira is a small HTTP client for an on-prem Jira Data Center/Server instance (e.g.
Package jira is a small HTTP client for an on-prem Jira Data Center/Server instance (e.g.
anny
Package anny integrates the Anny room-booking system (anny.eu): it fetches the bookings from the Anny API, stores them, and answers queries about them and about the personalization configuration that decides which bookings are "ours".
Package anny integrates the Anny room-booking system (anny.eu): it fetches the bookings from the Anny API, stores them, and answers queries about them and about the personalization configuration that decides which bookings are "ours".
conflictcalc
Package conflictcalc holds the pure schedule-conflict math: normalising an ancode pair into a stable key, ranking a conflict's proximity (how close in time two of a student's exams ended up), classifying two placed exams by their absolute times and durations, and diffing a freshly generated conflict list against the saved one.
Package conflictcalc holds the pure schedule-conflict math: normalising an ancode pair into a stable key, ranking a conflict's proximity (how close in time two of a student's exams ended up), classifying two placed exams by their absolute times and durations, and diffing a freshly generated conflict list against the saved one.
csvgen
Package csvgen builds the CSV export rows from already-fetched planning data.
Package csvgen builds the CSV export rows from already-fetched planning data.
email
Package email is the email rendering toolkit: it turns a Markdown body template plus data into the plain-text and HTML parts of a mail, wrapped in the shared layout, and manages the DB-backed, editable per-template overrides.
Package email is the email rendering toolkit: it turns a Markdown body template plus data into the plain-text and HTML parts of a mail, wrapped in the shared layout, and manages the DB-backed, editable per-template overrides.
examplan
Package examplan generates the exam schedule (Terminplan): it assigns every exam (unit) to a time slot on top of the generic simulated-annealing core in plexams/optimize.
Package examplan generates the exam schedule (Terminplan): it assigns every exam (unit) to a time slot on top of the generic simulated-annealing core in plexams/optimize.
invigcalc
Package invigcalc computes the fair distribution of invigilation duties: given the total invigilation minutes to cover and each invigilator's factor and already-credited contributions, it derives the per-invigilator target minutes (factor-weighted, with largest-remainder rounding so the targets sum exactly to the work) and the per-invigilator todo summary.
Package invigcalc computes the fair distribution of invigilation duties: given the total invigilation minutes to cover and each invigilator's factor and already-credited contributions, it derives the per-invigilator target minutes (factor-weighted, with largest-remainder rounding so the targets sum exactly to the work) and the per-invigilator todo summary.
invigplan
Package invigplan contains the pure (DB- and ZPA-free) domain model and the hard/soft constraints used to plan invigilations (Aufsichten) automatically.
Package invigplan contains the pure (DB- and ZPA-free) domain model and the hard/soft constraints used to plan invigilations (Aufsichten) automatically.
mucdai
Package mucdai holds the pure MUC.DAI CSV import parsing: turning a raw CSV export (of varying encoding and delimiter) into db.MucDaiExam records grouped by program.
Package mucdai holds the pure MUC.DAI CSV import parsing: turning a raw CSV export (of varying encoding and delimiter) into db.MucDaiExam records grouped by program.
optimize
Package optimize is a generic simulated-annealing engine shared by the schedule generators (exam schedule, pre-plan, invigilations).
Package optimize is a generic simulated-annealing engine shared by the schedule generators (exam schedule, pre-plan, invigilations).
pdfgen
Package pdfgen renders the planning PDFs (maroto documents) from already-fetched data.
Package pdfgen renders the planning PDFs (maroto documents) from already-fetched data.
planstate
Package planstate is the generic planning-state engine: a 1-safe condition/event Petri net where each condition is a milestone that can be set automatically (Mark) or by hand (SetCondition), and a condition with a gate locks the matching generation while it is set.
Package planstate is the generic planning-state engine: a 1-safe condition/event Petri net where each condition is a milestone that can be set automatically (Mark) or by hand (SetCondition), and a condition with a gate locks the matching generation while it is set.
preplancalc
Package preplancalc holds the pure room-capacity math of the SEB/EXaHM pre-planning: which rooms cover a slot's seat demand for a kind (honouring per-exam room restrictions), how many seats a room set provides, which rooms still need to be booked, and the per-program clashes within a slot.
Package preplancalc holds the pure room-capacity math of the SEB/EXaHM pre-planning: which rooms cover a slot's seat demand for a kind (honouring per-exam room restrictions), how many seats a room set provides, which rooms still need to be booked, and the per-program clashes within a slot.
primuss
Package primuss imports the Primuss "Sammellisten" data from the XLSX files (student registrations, exams, planning counts, conflicts) into the raw per-program collections, with change detection on re-import.
Package primuss imports the Primuss "Sammellisten" data from the XLSX files (student registrations, exams, planning counts, conflicts) into the raw per-program collections, with change detection on re-import.
repeatcalc
Package repeatcalc holds the pure study-group-semester repeat heuristic: reading the semester number out of a study-group code and deciding whether an exam is (likely) a repeat for a student.
Package repeatcalc holds the pure study-group-semester repeat heuristic: reading the semester number out of a study-group code and deciding whether an exam is (likely) a repeat for a student.
roomcalc
Package roomcalc holds the pure room-seat math of the room preparation: whether a room satisfies an exam's room constraints (EXaHM/SEB/Lab/socket/allowed-rooms feature matching), the required free-seat buffer for an exam, and the free seats an exam currently has across its rooms.
Package roomcalc holds the pure room-seat math of the room preparation: whether a room satisfies an exam's room constraints (EXaHM/SEB/Lab/socket/allowed-rooms feature matching), the required free-seat buffer for an exam, and the free seats an exam currently has across its rooms.
rooms
Package rooms holds the stateful per-slot room-allocation machine that assigns concrete rooms to the exams planned in a slot.
Package rooms holds the stateful per-slot room-allocation machine that assigns concrete rooms to the exams planned in a slot.
zpaimport
Package zpaimport holds the pure decision logic of the ZPA import: diffing a fresh import against the previous DB state into a SyncLogEntry plus human-readable report lines, classifying a ZPA exam for the automatic to-plan pre-selection, and computing the new to-plan / not-to-plan sets.
Package zpaimport holds the pure decision logic of the ZPA import: diffing a fresh import against the previous DB state into a SyncLogEntry plus human-readable report lines, classifying a ZPA exam for the automatic to-plan pre-selection, and computing the new to-plan / not-to-plan sets.

Jump to

Keyboard shortcuts

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