From c1fa004384fb79d3939014233edee80792f0380f Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 6 Jan 2024 08:20:31 +0100 Subject: [PATCH] =?UTF-8?q?participant.go=20aufger=C3=A4umt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/session/participant.go | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/session/participant.go b/packages/session/participant.go index 1318328..71d1335 100644 --- a/packages/session/participant.go +++ b/packages/session/participant.go @@ -29,27 +29,6 @@ type Participant struct { AllowRetry bool } -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)) - p.Company = r.PostFormValue("company-" + fmt.Sprint(p.Login)) - - err := db.WriteParticipant(p.Participant) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - log.Panicln(err) - } - - data := participantHTMLData{ - BriefingID: b.UUID, - Participant: *p, - } - - template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data) - } -} - func handleGivenAnswer(p *Participant, i int64, r *http.Request) error { answer, err := strconv.Atoi(r.PostFormValue("answer")) if err != nil { @@ -88,6 +67,27 @@ func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestio return questions } +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)) + p.Company = r.PostFormValue("company-" + fmt.Sprint(p.Login)) + + err := db.WriteParticipant(p.Participant) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + log.Panicln(err) + } + + data := participantHTMLData{ + BriefingID: b.UUID, + Participant: *p, + } + + template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data) + } +} + 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)) {