Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions cmd/cache.go

This file was deleted.

35 changes: 0 additions & 35 deletions cmd/generate.go

This file was deleted.

48 changes: 7 additions & 41 deletions cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ var (
Use: "plan",
Short: "plan [subcommand]",
Long: `Manipulate the plan.
pre-plan-exam ancode day slot --- move [ancode] to [day number] [slot number]
pre-plan-room ancode roomname [mtknr/reserve] --- plan [room name] for [ancode]
move-to ancode day slot --- move [ancode] to [day number] [slot number]
change-room ancode oldroom newroom --- change room for [ancode] from [oldroom] to [newroom]
lock-exam ancode --- lock exam to slot
unlock-exam ancode --- unlock / allow moving
remove-unlocked --- remove all unlocked exam groups from the plan
lock --- lock the whole plan`,
pre-plan-exam ancode day slot --- move [ancode] to [day number] [slot number]
pre-plan-room ancode roomname [mtknr/reserve] --- plan [room name] for [ancode]
move-to ancode day slot --- move [ancode] to [day number] [slot number]
change-room ancode oldroom newroom --- change room for [ancode] from [oldroom] to [newroom]
lock-exam ancode --- lock exam to slot
unlock-exam ancode --- unlock / allow moving
lock --- lock the whole plan`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
plexams := initPlexamsConfig()
Expand Down Expand Up @@ -76,31 +75,6 @@ var (
fmt.Printf("successfully moved exam %d to (%d,%d)\n", ancode, day, slot)
}

// case "pre-move-to":
// if len(args) < 4 {
// log.Fatal("need ancode, day and slot number")
// }
// ancode, err := strconv.Atoi(args[1])
// if err != nil {
// log.Fatalf("cannot convert %s to int", args[1])
// }
// day, err := strconv.Atoi(args[2])
// if err != nil {
// log.Fatalf("cannot convert %s to int", args[2])
// }
// slot, err := strconv.Atoi(args[3])
// if err != nil {
// log.Fatalf("cannot convert %s to int", args[3])
// }
// success, err := plexams.PreAddExamToSlot(context.Background(), ancode, day, slot)
// if err != nil {
// fmt.Printf("error: %v\n", err)
// os.Exit(1)
// }
// if success {
// fmt.Printf("successfully moved exam %d to (%d,%d)\n", ancode, day, slot)
// }

case "pre-plan-room":
if len(args) < 3 {
log.Fatal("need ancode and room name and optional mtknr/reserve")
Expand Down Expand Up @@ -199,14 +173,6 @@ var (
exam.Ancode, exam.ZpaExam.MainExamer, exam.ZpaExam.Module, planEntry.DayNumber, planEntry.SlotNumber)
}

case "remove-unlocked":
count, err := plexams.RemoveUnlockedExamGroupsFromPlan(context.Background())
if err != nil {
log.Fatalf("error %v", err)
os.Exit(1)
}
fmt.Printf("successfully deleted %d unlocked exam groups from the plan\n", count)

case "lock":
err := plexams.LockPlan(context.Background())
if err != nil {
Expand Down
23 changes: 8 additions & 15 deletions cmd/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,15 @@ var (
Use: "prepare",
Short: "prepare [subcommand]",
Long: `Prepare collections.
connected-exams --- prepare connected exams --- step 1
connect-exam ancode program --- connect an unconnected exam --- step 1,5

connected-exams --- prepare connected exams
connect-exam ancode program --- connect an unconnected exam
add-mucdai-exam program primuss-ancode --- add an external add-mucdai-exam exam

generated-exams --- generate exams from connected-exams, external-exams and primuss-data --- step 2

studentregs --- regs per exam & regs per student (needs connected-exams) --- step 2

For planning rooms:

rooms-for-slots --- prepare rooms which are allowed to use
rooms-for-exams --- rooms for exams

self-invigilations --- set main examer as invigilator if possible
invigilator-todos --- cache snapshot
generated-exams --- generate exams from connected-exams and primuss-data
studentregs --- regs per exam & regs per student (needs connected-exams)
rooms-for-slots --- prepare rooms which are allowed to use
rooms-for-exams --- rooms for exams
self-invigilations --- set main examer as invigilator if possible
invigilator-todos --- cache snapshot
`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 0 additions & 6 deletions cmd/primuss.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ var primussCmd = &cobra.Command{
for i, conflict := range newConflicts.Conflicts {
fmt.Printf(" %3d. conflict %d (%d students)\n", i+1, conflict.AnCode, conflict.NumberOfStuds)
}
// 6. log changes
err = plexams.Log(ctx, fmt.Sprintf("successfully changed primuss exam ancode from %s/%d to %s/%d",
program, from, program, to), "")
if err != nil {
log.Fatalf("error while trying to log the change: %v", err)
}

case "rm-studentreg":
if len(args) < 4 {
Expand Down
19 changes: 9 additions & 10 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ var (
Use: "validate",
Short: "validate [subcommand] [-s <seconds>]",
Long: `Validate the plan.
all --- guess what :-)
conflicts --- check conflicts for each student
constraints --- check if constraints hold
db --- data base entries
rooms --- check room constraints
zpa --- check if the plan on ZPA is the same here
invigilator-reqs
invigilator-slots

-s <seconds> --- sleep <seconds> and validate again`,
all --- guess what :-)
conflicts --- check conflicts for each student
constraints --- check if constraints hold
db --- data base entries
rooms --- check room constraints
zpa --- check if the plan on ZPA is the same here
invigilator-reqs. --- check if invigilator requirements are met
invigilator-slots --- check if invigilator slots are okay
`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
plexams := initPlexamsConfig()
Expand Down
25 changes: 7 additions & 18 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,27 @@ import (
type CollectionName string

const (
collectionNameSemesterConfig = "semester_config"
collectionConstraints = "constraints"
collectionNameExamGroups = "exam_groups"
collectionNameAdditionalExams = "additional_exams"
collectionNameExternalExams = "external_exams"
collectionNameConnectedExams = "connected_exams"
collectionNameExamsWithRegs = "exams_with_regs"
collectionNameNTAs = "nta"
collectionNamePlan = "plan"
collectionNamePlanBackup = "plan_backup"

collectionStudentRegsPerAncodePlanned = "studentregs_per_ancode_planned"
collectionStudentRegsPerAncodeAll = "studentregs_per_ancode_all"
collectionNameSemesterConfig = "semester_config"
collectionConstraints = "constraints"
collectionNameConnectedExams = "connected_exams"
collectionNameNTAs = "nta"
collectionNamePlan = "plan"
collectionNamePlanBackup = "plan_backup"

collectionStudentRegsPerStudentPlanned = "studentregs_per_student_planned"
collectionStudentRegsPerStudentAll = "studentregs_per_student_all"

collectionAll = "zpaexams"
collectionToPlan = "zpaexamsToPlan"
collectionNonZpaExams = "non_zpaexams"

collectionPrimussAncodes = "primuss_ancodes"

collectionExamsInPlan = "exams_in_plan" // Deprecated: rm me

collectionCachedExams = "cached_exams" // ?
collectionGeneratedExams = "generated_exams"

collectionGlobalRooms = "rooms"
collectionRoomsForSlots = "rooms_for_slots"
collectionRoomsPrePlanned = "rooms_pre_planned"
collectionRoomsPlanned = "rooms_planned"
collectionRoomsForExams = "rooms_for_exams" // Deprecated: ?

collectionInvigilatorRequirements = "invigilator_requirements"
collectionInvigilatorTodos = "invigilator_todos"
Expand Down
14 changes: 1 addition & 13 deletions db/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,7 @@
}
defer cur.Close(ctx) //nolint:errcheck

// TODO: replace all cur.Next with cur.All
for cur.Next(ctx) {
var constraint model.Constraints

err := cur.Decode(&constraint)
if err != nil {
log.Error().Err(err).Str("semester", db.semester).Str("collection", collectionConstraints).Interface("cur", cur).
Msg("Cannot decode to additional exam")
return constraints, err
}

constraints = append(constraints, &constraint)
}
cur.All(ctx, &constraints)

Check failure on line 330 in db/constraints.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `cur.All` is not checked (errcheck)

if err := cur.Err(); err != nil {
log.Error().Err(err).Str("semester", db.semester).Str("collection", collectionConstraints).Msg("Cursor returned error")
Expand Down
3 changes: 0 additions & 3 deletions db/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
)

// TODO: Alles berechnen, keine ExamGroups etc. erstellen und speichern, sondern immer on-the-fly.
// Ziel: NTAs nachträglich problemlos einpflegen etc.

func (db *DB) AllSemesterNames() ([]*model.Semester, error) {
dbs, err := db.Client.ListDatabaseNames(context.Background(),
bson.D{primitive.E{
Expand Down
Loading
Loading