Compare commits

..

No commits in common. "2d07991c0099584eebaa63c16340b9d4b90bba09" and "404e079343b818470be8a86522b22a80f317f72a" have entirely different histories.

5 changed files with 11 additions and 30 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
tmp
test.sql
static/test.jpg
static/test.mp4

View File

@ -155,12 +155,16 @@ func (s *Session) HandleParticipant(db *data.DB, p *BriefingParticipant) http.Ha
log.Panicln(err)
}
data := participantHTMLData{
data := questionHTMLData{
participantHTMLData: participantHTMLData{
SessionID: s.ID,
BriefingParticipant: *p,
BriefingParticipant: BriefingParticipant{Login: p.Login},
},
QuestionID: 1,
Question: s.Questions[0],
}
template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data)
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)
}
}
@ -200,7 +204,7 @@ func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) htt
SessionID: s.ID,
BriefingParticipant: *p,
},
Questions: makeResultQuestions(s.Questions, p.GivenAnswers),
Questions: makeHTMLQuestions(s.Questions, p.GivenAnswers),
}
if data.NoIncorrect == 0 {
@ -244,7 +248,7 @@ func (s *Session) HandleRetry(p *BriefingParticipant, i *int) http.HandlerFunc {
SessionID: s.ID,
BriefingParticipant: *p,
},
Questions: makeResultQuestions(s.Questions, p.GivenAnswers),
Questions: makeHTMLQuestions(s.Questions, p.GivenAnswers),
}
template.Must(template.ParseFiles("templates/result.html")).ExecuteTemplate(w, "content", data)
@ -268,18 +272,3 @@ func (s *Session) HandleBriefingDone() http.HandlerFunc {
template.Must(template.ParseFiles("templates/login.html")).ExecuteTemplate(w, "content", nil)
}
}
func (s *Session) HandleEndOfVideo(p *BriefingParticipant) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
data := questionHTMLData{
participantHTMLData: participantHTMLData{
SessionID: s.ID,
BriefingParticipant: BriefingParticipant{Login: p.Login},
},
QuestionID: 1,
Question: s.Questions[0],
}
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)
}
}

View File

@ -66,7 +66,7 @@ func handleGivenAnswer(p *BriefingParticipant, i int64, r *http.Request) error {
return nil
}
func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestion {
func makeHTMLQuestions(sq []data.Question, givenAnswers []int) []resultQuestion {
questions := make([]resultQuestion, len(sq))
for i, q := range sq {
questions[i].Text = q.Text

View File

@ -23,7 +23,6 @@ func (mux *Mux) handleParticipants(db *data.DB, cp <-chan *BriefingParticipant,
p.GivenAnswers = make([]int, len(s.Questions))
mux.HandleFunc("/submit-participant/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/", s.HandleParticipant(db, p))
mux.HandleFunc("/end-video/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/", s.HandleEndOfVideo(p))
var i int
for i = range s.Questions {
mux.HandleFunc("/submit-answer/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", s.HandleAnswer(db, p, int64(i+1)))

View File

@ -1,6 +0,0 @@
{{define "content"}}
<video src="/static/test.mp4">Test</video>
<button hx-post="/end-video/{{.SessionID}}/{{.Login}}/" hx-target="#content" type="button">
Weiter
</button>
{{end}}