Abspielen eines Unterweisungsvideos eingebaut

This commit is contained in:
Jason Streifling 2023-11-02 18:25:28 +01:00
parent 0041276fb4
commit 2d07991c00
5 changed files with 28 additions and 9 deletions

1
.gitignore vendored
View File

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

View File

@ -155,16 +155,12 @@ func (s *Session) HandleParticipant(db *data.DB, p *BriefingParticipant) http.Ha
log.Panicln(err)
}
data := questionHTMLData{
participantHTMLData: participantHTMLData{
SessionID: s.ID,
BriefingParticipant: BriefingParticipant{Login: p.Login},
},
QuestionID: 1,
Question: s.Questions[0],
data := participantHTMLData{
SessionID: s.ID,
BriefingParticipant: *p,
}
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)
template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data)
}
}
@ -272,3 +268,18 @@ 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 makeHTMLQuestions(sq []data.Question, givenAnswers []int) []resultQuestion {
func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestion {
questions := make([]resultQuestion, len(sq))
for i, q := range sq {
questions[i].Text = q.Text

View File

@ -23,6 +23,7 @@ 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)))

6
templates/video.html Normal file
View File

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