From 0fe1d822e2e5324ad8a3699635c414e6335d6fb0 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 6 Jan 2024 07:38:37 +0100 Subject: [PATCH] =?UTF-8?q?Von=20Methoden=20f=C3=BCr=20handlerFuncs=20wegg?= =?UTF-8?q?egangen,=20solange=20ich=20da=20kein=20vern=C3=BCnftiges=20Konz?= =?UTF-8?q?ept=20habe.=20Au=C3=9Ferdem=20Bug=20behoben.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/session/htmlStructs.go | 5 +++-- packages/session/muxFuncs.go | 26 +++++++++++++------------- packages/session/sessionStructs.go | 4 ++-- templates/summary.html | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/session/htmlStructs.go b/packages/session/htmlStructs.go index c28ccd6..f79d11f 100644 --- a/packages/session/htmlStructs.go +++ b/packages/session/htmlStructs.go @@ -22,7 +22,7 @@ type tableHTMLData struct { } type participantHTMLData struct { - BriefingID int64 + BriefingID uuid.UUID Participant } @@ -51,6 +51,7 @@ type resultHTMLData struct { } type summaryHTMLData struct { - BriefingID int64 + SessionID uuid.UUID + BriefingID uuid.UUID ParticipantsData []participantHTMLData } diff --git a/packages/session/muxFuncs.go b/packages/session/muxFuncs.go index d2572c9..d287a77 100644 --- a/packages/session/muxFuncs.go +++ b/packages/session/muxFuncs.go @@ -26,25 +26,25 @@ func (mux *Mux) handleParticipants(db *data.DB, cp <-chan *Participant, b *Brief for p := range cp { p.GivenAnswers = make([]int, len(b.Questions)) - mux.HandleFunc("/submit-participant/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleParticipant(db, p)) - mux.HandleFunc("/end-video/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleEndOfVideo(p)) + mux.HandleFunc("/submit-participant/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleParticipant(db, b, p)) + mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleEndOfVideo(b, p)) var i int for i = range b.Questions { - mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", b.HandleAnswer(db, p, int64(i+1))) + mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", HandleAnswer(db, b, p, int64(i+1))) } - mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleAllowRetry()) - mux.HandleFunc("/retry/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleRetry(p, &i)) - mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleRefresh(p)) + mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleAllowRetry(p)) + mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleRetry(b, p, &i)) + mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleRefresh(b, p)) } } -func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing) { +func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing, s *Session) { participantChan := make(chan *Participant) for b := range cb { b.getQuestions(db) - mux.HandleFunc("/new-participant/"+fmt.Sprint(b.ID)+"/", b.HandleNewParticipant(participantChan)) - mux.HandleFunc("/submit-form/"+fmt.Sprint(b.ID)+"/", b.HandleBriefingForm(db)) + mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", HandleNewParticipant(b, participantChan)) + mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", HandleBriefingForm(db, s, b)) go mux.handleParticipants(db, participantChan, b) } @@ -55,10 +55,10 @@ func (mux *Mux) HandleSessions(db *data.DB, cs <-chan *Session, ss *[]*Session) for s := range cs { (*ss) = append((*ss), s) - mux.HandleFunc("/search/"+fmt.Sprint(s.ID)+"/", s.HandleSearch(db)) - mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.ID)+"/", s.HandleNewBriefing(briefingChan)) - mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingDone(db)) + mux.HandleFunc("/search/"+fmt.Sprint(s.UUID)+"/", HandleSearch(db, s)) + mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", HandleNewBriefing(s, briefingChan)) + mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", HandleBriefingDone(db, s)) - go mux.handleBriefings(db, briefingChan) + go mux.handleBriefings(db, briefingChan, s) } } diff --git a/packages/session/sessionStructs.go b/packages/session/sessionStructs.go index 17fc8f8..11c1602 100644 --- a/packages/session/sessionStructs.go +++ b/packages/session/sessionStructs.go @@ -31,14 +31,14 @@ type Participant struct { } type Briefing struct { - ID int64 *data.Briefing + UUID uuid.UUID Participants []*Participant Questions []data.Question } type Session struct { - ID uuid.UUID + UUID uuid.UUID Instructor data.Instructor Briefings []*Briefing } diff --git a/templates/summary.html b/templates/summary.html index 94f960a..85d7796 100644 --- a/templates/summary.html +++ b/templates/summary.html @@ -40,7 +40,7 @@ {{end}} {{define "content"}} - + {{range .ParticipantsData}} {{template "participant" .}} {{end}}