From 59e1016123483c2ac32e7c7f52c3abebeebf9016 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 6 Jan 2024 17:14:15 +0100 Subject: [PATCH] =?UTF-8?q?Alle=20Methode=20privat=20gemacht,=20bei=20dene?= =?UTF-8?q?n=20es=20m=C3=B6glich=20ist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/server/briefing.go | 4 ++-- packages/server/mux.go | 22 +++++++++++----------- packages/server/participant.go | 12 ++++++------ packages/server/session.go | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/server/briefing.go b/packages/server/briefing.go index 9254bbb..a622291 100644 --- a/packages/server/briefing.go +++ b/packages/server/briefing.go @@ -41,7 +41,7 @@ func generateLogin() (string, error) { return hex.EncodeToString(bs), nil } -func (b *Briefing) HandleNewParticipant(cp chan<- *Participant) http.HandlerFunc { +func (b *Briefing) handleNewParticipant(cp chan<- *Participant) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var err error participant := Participant{ @@ -67,7 +67,7 @@ func (b *Briefing) HandleNewParticipant(cp chan<- *Participant) http.HandlerFunc } } -func (b *Briefing) HandleBriefingForm(db *data.DB, s *Session) http.HandlerFunc { +func (b *Briefing) handleBriefingForm(db *data.DB, s *Session) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { b.DateTime = time.Now().Format("2006-01-02 15:04:05") b.Location = r.PostFormValue("location") diff --git a/packages/server/mux.go b/packages/server/mux.go index 95dcf7f..52594b4 100644 --- a/packages/server/mux.go +++ b/packages/server/mux.go @@ -32,15 +32,15 @@ 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.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleParticipant(db, b)) - mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleEndOfVideo(b)) + mux.HandleFunc("/submit-participant/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleParticipant(db, b)) + mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleEndOfVideo(b)) var i int for i = range b.Questions { - mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", p.HandleAnswer(db, b, int64(i+1))) + mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", p.handleAnswer(db, b, int64(i+1))) } - mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleAllowRetry()) - mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleRetry(b, &i)) - mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleRefresh(b)) + mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleAllowRetry()) + mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleRetry(b, &i)) + mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleRefresh(b)) } } @@ -74,8 +74,8 @@ func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing, s *Session) { for b := range cb { getQuestions(db, b) - mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", b.HandleNewParticipant(participantChan)) - mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", b.HandleBriefingForm(db, s)) + mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", b.handleNewParticipant(participantChan)) + mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", b.handleBriefingForm(db, s)) go mux.handleParticipants(db, participantChan, b) } @@ -86,9 +86,9 @@ 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.UUID)+"/", s.HandleSearch(db)) - mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", s.HandleNewBriefing(briefingChan)) - mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", s.HandleBriefingDone(db)) + mux.HandleFunc("/search/"+fmt.Sprint(s.UUID)+"/", s.handleSearch(db)) + mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", s.handleNewBriefing(briefingChan)) + mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", s.handleBriefingDone(db)) go mux.handleBriefings(db, briefingChan, s) } diff --git a/packages/server/participant.go b/packages/server/participant.go index 06637c6..a18e7a0 100644 --- a/packages/server/participant.go +++ b/packages/server/participant.go @@ -67,7 +67,7 @@ func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestio return questions } -func (p *Participant) HandleParticipant(db *data.DB, b *Briefing) http.HandlerFunc { +func (p *Participant) handleParticipant(db *data.DB, b *Briefing) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login)) p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login)) @@ -88,7 +88,7 @@ func (p *Participant) HandleParticipant(db *data.DB, b *Briefing) http.HandlerFu } } -func (p *Participant) HandleAnswer(db *data.DB, b *Briefing, i int64) http.HandlerFunc { +func (p *Participant) handleAnswer(db *data.DB, b *Briefing, i int64) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if i < int64(len(b.Questions)) { if err := handleGivenAnswer(p, i-1, r); err != nil { @@ -139,14 +139,14 @@ func (p *Participant) HandleAnswer(db *data.DB, b *Briefing, i int64) http.Handl } } -func (p *Participant) HandleAllowRetry() http.HandlerFunc { +func (p *Participant) handleAllowRetry() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { p.NoIncorrect = -1 p.AllowRetry = true } } -func (p *Participant) HandleRetry(b *Briefing, i *int) http.HandlerFunc { +func (p *Participant) handleRetry(b *Briefing, i *int) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if p.AllowRetry { p.AllowRetry = false @@ -176,7 +176,7 @@ func (p *Participant) HandleRetry(b *Briefing, i *int) http.HandlerFunc { } } -func (p *Participant) HandleRefresh(b *Briefing) http.HandlerFunc { +func (p *Participant) handleRefresh(b *Briefing) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { data := participantHTMLData{ BriefingID: b.UUID, @@ -187,7 +187,7 @@ func (p *Participant) HandleRefresh(b *Briefing) http.HandlerFunc { } } -func (p *Participant) HandleEndOfVideo(b *Briefing) http.HandlerFunc { +func (p *Participant) handleEndOfVideo(b *Briefing) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { data := questionHTMLData{ participantHTMLData: participantHTMLData{ diff --git a/packages/server/session.go b/packages/server/session.go index 21691de..ea9eec9 100644 --- a/packages/server/session.go +++ b/packages/server/session.go @@ -26,7 +26,7 @@ type Session struct { Briefings []*Briefing } -func (s *Session) HandleSearch(db *data.DB) http.HandlerFunc { +func (s *Session) handleSearch(db *data.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var err error data := tableHTMLData{} @@ -41,7 +41,7 @@ func (s *Session) HandleSearch(db *data.DB) http.HandlerFunc { } } -func (s *Session) HandleNewBriefing(cb chan<- *Briefing) http.HandlerFunc { +func (s *Session) handleNewBriefing(cb chan<- *Briefing) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { briefing := Briefing{Briefing: &data.Briefing{InstructorID: s.Instructor.ID}, UUID: uuid.New()} s.Briefings = append(s.Briefings, &briefing) @@ -51,7 +51,7 @@ func (s *Session) HandleNewBriefing(cb chan<- *Briefing) http.HandlerFunc { } } -func (s *Session) HandleBriefingDone(db *data.DB) http.HandlerFunc { +func (s *Session) handleBriefingDone(db *data.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { data := tableHTMLData{SessionID: s.UUID} var err error