@@ -299,7 +299,7 @@ OUTER:
299299}
300300
301301func (p * Plexams ) DraftExahmPDF (ctx context.Context , outfile string ) error {
302- m := pdf .NewMaroto (consts .Portrait , consts .A4 )
302+ m := pdf .NewMaroto (consts .Landscape , consts .A4 )
303303 m .SetPageMargins (10 , 15 , 10 )
304304
305305 m .RegisterFooter (func () {
@@ -350,7 +350,7 @@ func (p *Plexams) DraftExahmPDF(ctx context.Context, outfile string) error {
350350 })
351351 })
352352
353- p .tableForExahm (ctx , m , false )
353+ // p.tableForExahm(ctx, m, false)
354354 p .tableForExahm (ctx , m , true )
355355
356356 err := m .OutputFileAndClose (outfile )
@@ -362,7 +362,7 @@ func (p *Plexams) DraftExahmPDF(ctx context.Context, outfile string) error {
362362}
363363
364364func (p * Plexams ) tableForExahm (ctx context.Context , m pdf.Maroto , sortByDate bool ) {
365- header := []string {"AnCode" , "Modul" , "Prüfender" , "Termin" , "Plätze" }
365+ header := []string {"AnCode" , "Modul" , "Prüfender" , "Termin" , "Plätze" , "Räume" }
366366
367367 text := "Prüfungen mit EXaHM/SEB, sortiert nach AnCode"
368368 if sortByDate {
@@ -404,23 +404,54 @@ func (p *Plexams) tableForExahm(ctx context.Context, m pdf.Maroto, sortByDate bo
404404 if exams [j ].PlanEntry == nil {
405405 return true
406406 }
407- return exams [i ].PlanEntry .DayNumber < exams [j ].PlanEntry .DayNumber ||
408- (exams [i ].PlanEntry .DayNumber == exams [j ].PlanEntry .DayNumber &&
409- exams [i ].PlanEntry .SlotNumber < exams [j ].PlanEntry .SlotNumber )
407+ if exams [i ].PlanEntry .DayNumber != exams [j ].PlanEntry .DayNumber {
408+ return exams [i ].PlanEntry .DayNumber < exams [j ].PlanEntry .DayNumber
409+ }
410+ if exams [i ].PlanEntry .SlotNumber != exams [j ].PlanEntry .SlotNumber {
411+ return exams [i ].PlanEntry .SlotNumber < exams [j ].PlanEntry .SlotNumber
412+ }
413+ return exams [i ].Ancode < exams [j ].Ancode
410414 })
411415 }
412416
413417 for _ , exam := range exams {
414- if exam .PlanEntry == nil {
415- contents = append (contents ,
416- []string {strconv .Itoa (exam .Ancode ), exam .ZpaExam .Module , exam .ZpaExam .MainExamer ,
417- "fehlt noch" , strconv .Itoa (exam .StudentRegsCount )})
418- } else {
418+ planEntry := "fehlt noch"
419+ if exam .PlanEntry != nil {
419420 starttime := p .getSlotTime (exam .PlanEntry .DayNumber , exam .PlanEntry .SlotNumber )
420- contents = append (contents ,
421- []string {strconv .Itoa (exam .Ancode ), exam .ZpaExam .Module , exam .ZpaExam .MainExamer ,
422- r .Replace (starttime .Local ().Format ("Mon. 02.01.06, 15:04 Uhr" )), strconv .Itoa (exam .StudentRegsCount )})
421+ planEntry = r .Replace (starttime .Local ().Format ("Mon. 02.01.06, 15:04 Uhr" ))
422+ }
423+
424+ rooms := "fehlen noch"
425+ if len (exam .PlannedRooms ) > 0 {
426+ var builder strings.Builder
427+ for i , room := range exam .PlannedRooms {
428+ if i != 0 {
429+ builder .WriteString (", " )
430+ }
431+ builder .WriteString (room .RoomName )
432+ }
433+ rooms = builder .String ()
434+ } else {
435+ prePlannedRooms , err := p .PrePlannedRoomsForExam (ctx , exam .Ancode )
436+ if err != nil {
437+ log .Error ().Err (err ).Int ("ancode" , exam .Ancode ).
438+ Msg ("error while trying to get preplanned rooms" )
439+ }
440+ if len (prePlannedRooms ) > 0 {
441+ var builder strings.Builder
442+ for i , room := range prePlannedRooms {
443+ if i != 0 {
444+ builder .WriteString (", " )
445+ }
446+ builder .WriteString (room .RoomName )
447+ }
448+ rooms = builder .String ()
449+ }
423450 }
451+
452+ contents = append (contents ,
453+ []string {strconv .Itoa (exam .Ancode ), exam .ZpaExam .Module , exam .ZpaExam .MainExamer ,
454+ planEntry , strconv .Itoa (exam .StudentRegsCount ), rooms })
424455 }
425456
426457 grayColor := color.Color {
@@ -432,11 +463,11 @@ func (p *Plexams) tableForExahm(ctx context.Context, m pdf.Maroto, sortByDate bo
432463 m .TableList (header , contents , props.TableList {
433464 HeaderProp : props.TableListContent {
434465 Size : 11 ,
435- GridSizes : []uint {1 , 5 , 2 , 3 , 1 },
466+ GridSizes : []uint {1 , 4 , 2 , 3 , 1 , 1 },
436467 },
437468 ContentProp : props.TableListContent {
438469 Size : 11 ,
439- GridSizes : []uint {1 , 5 , 2 , 3 , 1 },
470+ GridSizes : []uint {1 , 4 , 2 , 3 , 1 , 1 },
440471 },
441472 Align : consts .Left ,
442473 AlternatedBackground : & grayColor ,
0 commit comments