Die Bedeutung von Session und Briefing so angepasst, dass sie Sinn ergibt.

This commit is contained in:
Jason Streifling 2024-01-02 10:56:17 +01:00
parent 2d07991c00
commit 9331035edd
11 changed files with 142 additions and 111 deletions

View File

@ -34,7 +34,8 @@ func HandleInternalLogin(db *data.DB, ss *[]*Session, cs chan<- *Session) http.H
if r.PostFormValue("login") == fmt.Sprint(i.ID) { if r.PostFormValue("login") == fmt.Sprint(i.ID) {
session := Session{ session := Session{
ID: uuid.New(), ID: uuid.New(),
Briefing: &data.Briefing{InstructorID: i.ID}, Instructor: *i,
Briefings: make([]*Briefing, 0),
} }
(*ss) = append((*ss), &session) (*ss) = append((*ss), &session)
cs <- &session cs <- &session
@ -69,16 +70,20 @@ func (s *Session) HandleSearch(db *data.DB) http.HandlerFunc {
} }
} }
func (s *Session) HandleNewBriefing() http.HandlerFunc { func (s *Session) HandleNewBriefing(cb chan<- *Briefing) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("templates/briefing.html")).ExecuteTemplate(w, "content", participantHTMLData{SessionID: s.ID}) briefing := Briefing{Briefing: &data.Briefing{InstructorID: s.Instructor.ID}}
s.Briefings = append(s.Briefings, &briefing)
cb <- &briefing
template.Must(template.ParseFiles("templates/briefing.html")).ExecuteTemplate(w, "content", participantHTMLData{BriefingID: briefing.ID})
} }
} }
func (s *Session) HandleNewParticipant(cp chan<- *BriefingParticipant) http.HandlerFunc { func (b *Briefing) HandleNewParticipant(cp chan<- *Participant) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var err error var err error
participant := BriefingParticipant{ participant := Participant{
Participant: new(data.Participant), Participant: new(data.Participant),
NoIncorrect: -1, NoIncorrect: -1,
AllowRetry: false, AllowRetry: false,
@ -89,38 +94,38 @@ func (s *Session) HandleNewParticipant(cp chan<- *BriefingParticipant) http.Hand
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err) log.Panicln(err)
} }
s.Participants = append(s.Participants, &participant) b.Participants = append(b.Participants, &participant)
cp <- &participant cp <- &participant
data := participantHTMLData{ data := participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: BriefingParticipant{Login: participant.Login}, Participant: Participant{Login: participant.Login},
} }
template.Must(template.ParseFiles("templates/briefing.html")).ExecuteTemplate(w, "new", data) template.Must(template.ParseFiles("templates/briefing.html")).ExecuteTemplate(w, "new", data)
} }
} }
func (s *Session) HandleBriefingForm(db *data.DB) http.HandlerFunc { func (b *Briefing) HandleBriefingForm(db *data.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
s.DateTime = time.Now().Format("2006-01-02 15:04:05") b.DateTime = time.Now().Format("2006-01-02 15:04:05")
s.Location = r.PostFormValue("location") b.Location = r.PostFormValue("location")
s.Document = r.PostFormValue("document") b.Document = r.PostFormValue("document")
s.AsOf = r.PostFormValue("as-of") b.AsOf = r.PostFormValue("as-of")
err := db.WriteBriefing(s.Briefing) err := db.WriteBriefing(b.Briefing)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err) log.Panicln(err)
} }
data := summaryHTMLData{ data := summaryHTMLData{
SessionID: s.ID, BriefingID: b.ID,
ParticipantsData: make([]participantHTMLData, len(s.Participants)), ParticipantsData: make([]participantHTMLData, len(b.Participants)),
} }
for i, p := range s.Participants { for i, p := range b.Participants {
data.ParticipantsData[i].SessionID = s.ID data.ParticipantsData[i].BriefingID = b.ID
data.ParticipantsData[i].BriefingParticipant = *p data.ParticipantsData[i].Participant = *p
} }
template.Must(template.ParseFiles("templates/summary.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/summary.html")).ExecuteTemplate(w, "content", data)
@ -129,11 +134,11 @@ func (s *Session) HandleBriefingForm(db *data.DB) http.HandlerFunc {
func HandleExternalLogin(ss *[]*Session) http.HandlerFunc { func HandleExternalLogin(ss *[]*Session) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
session, participant, loginCorrect := findCorrectLogin(r.PostFormValue("login"), ss) briefing, participant, loginCorrect := findCorrectLogin(r.PostFormValue("login"), ss)
if loginCorrect { if loginCorrect {
data := participantHTMLData{ data := participantHTMLData{
SessionID: session.ID, BriefingID: briefing.ID,
BriefingParticipant: BriefingParticipant{Login: participant.Login}, Participant: Participant{Login: participant.Login},
} }
template.Must(template.ParseFiles("templates/participant.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/participant.html")).ExecuteTemplate(w, "content", data)
@ -143,7 +148,7 @@ func HandleExternalLogin(ss *[]*Session) http.HandlerFunc {
} }
} }
func (s *Session) HandleParticipant(db *data.DB, p *BriefingParticipant) http.HandlerFunc { func (b *Briefing) HandleParticipant(db *data.DB, p *Participant) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login)) p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login))
p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login)) p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login))
@ -156,17 +161,17 @@ func (s *Session) HandleParticipant(db *data.DB, p *BriefingParticipant) http.Ha
} }
data := participantHTMLData{ data := participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: *p, Participant: *p,
} }
template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/video.html")).ExecuteTemplate(w, "content", data)
} }
} }
func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) http.HandlerFunc { func (b *Briefing) HandleAnswer(db *data.DB, p *Participant, i int64) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
if i < int64(len(s.Questions)) { if i < int64(len(b.Questions)) {
if err := handleGivenAnswer(p, i-1, r); err != nil { if err := handleGivenAnswer(p, i-1, r); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err) log.Panicln(err)
@ -174,11 +179,11 @@ func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) htt
data := questionHTMLData{ data := questionHTMLData{
participantHTMLData: participantHTMLData{ participantHTMLData: participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: BriefingParticipant{Login: p.Login}, Participant: Participant{Login: p.Login},
}, },
QuestionID: i + 1, QuestionID: i + 1,
Question: s.Questions[i], Question: b.Questions[i],
} }
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)
@ -189,7 +194,7 @@ func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) htt
} }
p.NoIncorrect = 0 p.NoIncorrect = 0
for i, q := range s.Questions { for i, q := range b.Questions {
if p.GivenAnswers[i] != q.Correct { if p.GivenAnswers[i] != q.Correct {
p.NoIncorrect++ p.NoIncorrect++
} }
@ -197,14 +202,14 @@ func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) htt
data := resultHTMLData{ data := resultHTMLData{
participantHTMLData: participantHTMLData{ participantHTMLData: participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: *p, Participant: *p,
}, },
Questions: makeResultQuestions(s.Questions, p.GivenAnswers), Questions: makeResultQuestions(b.Questions, p.GivenAnswers),
} }
if data.NoIncorrect == 0 { if data.NoIncorrect == 0 {
if err := db.WriteGivenAnswers(*s.Briefing, *p.Participant, s.Questions, p.GivenAnswers); err != nil { if err := db.WriteGivenAnswers(*b.Briefing, *p.Participant, b.Questions, p.GivenAnswers); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err) log.Panicln(err)
} }
@ -215,14 +220,14 @@ func (s *Session) HandleAnswer(db *data.DB, p *BriefingParticipant, i int64) htt
} }
} }
func (s *Session) HandleAllowRetry(p *BriefingParticipant) http.HandlerFunc { func (p *Participant) HandleAllowRetry() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
p.NoIncorrect = -1 p.NoIncorrect = -1
p.AllowRetry = true p.AllowRetry = true
} }
} }
func (s *Session) HandleRetry(p *BriefingParticipant, i *int) http.HandlerFunc { func (b *Briefing) HandleRetry(p *Participant, i *int) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
if p.AllowRetry { if p.AllowRetry {
p.AllowRetry = false p.AllowRetry = false
@ -230,21 +235,21 @@ func (s *Session) HandleRetry(p *BriefingParticipant, i *int) http.HandlerFunc {
data := questionHTMLData{ data := questionHTMLData{
participantHTMLData: participantHTMLData{ participantHTMLData: participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: BriefingParticipant{Login: p.Login}, Participant: Participant{Login: p.Login},
}, },
QuestionID: int64(*i + 1), QuestionID: int64(*i + 1),
Question: s.Questions[*i], Question: b.Questions[*i],
} }
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)
} else { } else {
data := resultHTMLData{ data := resultHTMLData{
participantHTMLData: participantHTMLData{ participantHTMLData: participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: *p, Participant: *p,
}, },
Questions: makeResultQuestions(s.Questions, p.GivenAnswers), Questions: makeResultQuestions(b.Questions, p.GivenAnswers),
} }
template.Must(template.ParseFiles("templates/result.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/result.html")).ExecuteTemplate(w, "content", data)
@ -252,32 +257,41 @@ func (s *Session) HandleRetry(p *BriefingParticipant, i *int) http.HandlerFunc {
} }
} }
func (s *Session) HandleRefresh(p *BriefingParticipant) http.HandlerFunc { func (b *Briefing) HandleRefresh(p *Participant) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
data := participantHTMLData{ data := participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: *p, Participant: *p,
} }
template.Must(template.ParseFiles("templates/summary.html")).ExecuteTemplate(w, "participant", data) template.Must(template.ParseFiles("templates/summary.html")).ExecuteTemplate(w, "participant", data)
} }
} }
func (s *Session) HandleBriefingDone() http.HandlerFunc { func (s *Session) HandleBriefingDone(db *data.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("templates/login.html")).ExecuteTemplate(w, "content", nil) data := tableHTMLData{SessionID: s.ID}
var err error
data.OTD, err = db.GetAllOverviewTableData()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Panicln(err)
}
template.Must(template.ParseFiles("templates/table.html")).ExecuteTemplate(w, "content", data)
} }
} }
func (s *Session) HandleEndOfVideo(p *BriefingParticipant) http.HandlerFunc { func (b *Briefing) HandleEndOfVideo(p *Participant) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
data := questionHTMLData{ data := questionHTMLData{
participantHTMLData: participantHTMLData{ participantHTMLData: participantHTMLData{
SessionID: s.ID, BriefingID: b.ID,
BriefingParticipant: BriefingParticipant{Login: p.Login}, Participant: Participant{Login: p.Login},
}, },
QuestionID: 1, QuestionID: 1,
Question: s.Questions[0], Question: b.Questions[0],
} }
template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data) template.Must(template.ParseFiles("templates/question.html")).ExecuteTemplate(w, "content", data)

View File

@ -33,11 +33,13 @@ func generateLogin() (string, error) {
return hex.EncodeToString(bs), nil return hex.EncodeToString(bs), nil
} }
func findCorrectLogin(l string, ss *[]*Session) (*Session, *BriefingParticipant, bool) { func findCorrectLogin(l string, ss *[]*Session) (*Briefing, *Participant, bool) {
for _, session := range *ss { for _, s := range *ss {
for _, p := range session.Participants { for _, b := range s.Briefings {
for _, p := range b.Participants {
if l == p.Login { if l == p.Login {
return session, p, true return b, p, true
}
} }
} }
} }
@ -56,7 +58,7 @@ func newParticipant(l string) (*data.Participant, error) {
return p, nil return p, nil
} }
func handleGivenAnswer(p *BriefingParticipant, i int64, r *http.Request) error { func handleGivenAnswer(p *Participant, i int64, r *http.Request) error {
answer, err := strconv.Atoi(r.PostFormValue("answer")) answer, err := strconv.Atoi(r.PostFormValue("answer"))
if err != nil { if err != nil {
return fmt.Errorf("error: handleGivenAnswer: strconv.Atoi(): %v", err) return fmt.Errorf("error: handleGivenAnswer: strconv.Atoi(): %v", err)
@ -94,7 +96,7 @@ func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestio
return questions return questions
} }
func (s *Session) getQuestions(db *data.DB) { func (b *Briefing) getQuestions(db *data.DB) {
questionIDs := make([]string, 4) questionIDs := make([]string, 4)
for i := 0; i < len(questionIDs); i++ { for i := 0; i < len(questionIDs); i++ {
@ -102,19 +104,19 @@ func (s *Session) getQuestions(db *data.DB) {
} }
var err error var err error
s.Questions, err = db.GetQuestions(questionIDs) b.Questions, err = db.GetQuestions(questionIDs)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
// TODO: ggf. weniger komplex durch Pointer machen // TODO: ggf. weniger komplex durch Pointer machen
for i := range s.Questions { for i := range b.Questions {
for j := range s.Questions[i].Answers { for j := range b.Questions[i].Answers {
if parts := strings.Split(s.Questions[i].Answers[j].Text, ":/"); parts[0] == "file" { if parts := strings.Split(b.Questions[i].Answers[j].Text, ":/"); parts[0] == "file" {
s.Questions[i].Answers[j].Text = parts[1] b.Questions[i].Answers[j].Text = parts[1]
s.Questions[i].Answers[j].IsImage = true b.Questions[i].Answers[j].IsImage = true
} else { } else {
s.Questions[i].Answers[j].IsImage = false b.Questions[i].Answers[j].IsImage = false
} }
} }
} }

View File

@ -22,8 +22,8 @@ type tableHTMLData struct {
} }
type participantHTMLData struct { type participantHTMLData struct {
SessionID uuid.UUID BriefingID int64
BriefingParticipant Participant
} }
type questionHTMLData struct { type questionHTMLData struct {
@ -51,6 +51,6 @@ type resultHTMLData struct {
} }
type summaryHTMLData struct { type summaryHTMLData struct {
SessionID uuid.UUID BriefingID int64
ParticipantsData []participantHTMLData ParticipantsData []participantHTMLData
} }

View File

@ -18,38 +18,47 @@ import (
"streifling.com/jason/sicherheitsunterweisung/packages/data" "streifling.com/jason/sicherheitsunterweisung/packages/data"
) )
func (mux *Mux) handleParticipants(db *data.DB, cp <-chan *BriefingParticipant, s *Session) {
for p := range cp {
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)))
}
mux.HandleFunc("/allow-retry/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/", s.HandleAllowRetry(p))
mux.HandleFunc("/retry/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/", s.HandleRetry(p, &i))
mux.HandleFunc("/refresh-summary/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(p.Login)+"/", s.HandleRefresh(p))
}
}
func NewMux() *Mux { func NewMux() *Mux {
return &Mux{ServeMux: http.NewServeMux()} return &Mux{ServeMux: http.NewServeMux()}
} }
func (mux *Mux) handleParticipants(db *data.DB, cp <-chan *Participant, b *Briefing) {
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))
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("/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))
}
}
func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing) {
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))
go mux.handleParticipants(db, participantChan, b)
}
}
func (mux *Mux) HandleSessions(db *data.DB, cs <-chan *Session, ss *[]*Session) { func (mux *Mux) HandleSessions(db *data.DB, cs <-chan *Session, ss *[]*Session) {
briefingChan := make(chan *Briefing)
for s := range cs { for s := range cs {
(*ss) = append((*ss), s) (*ss) = append((*ss), s)
participantChan := make(chan *BriefingParticipant)
s.getQuestions(db)
mux.HandleFunc("/search/"+fmt.Sprint(s.ID)+"/", s.HandleSearch(db)) mux.HandleFunc("/search/"+fmt.Sprint(s.ID)+"/", s.HandleSearch(db))
mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.ID)+"/", s.HandleNewBriefing()) mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.ID)+"/", s.HandleNewBriefing(briefingChan))
mux.HandleFunc("/new-participant/"+fmt.Sprint(s.ID)+"/", s.HandleNewParticipant(participantChan)) mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingDone(db))
mux.HandleFunc("/submit-form/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingForm(db))
mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingDone())
go mux.handleParticipants(db, participantChan, s) go mux.handleBriefings(db, briefingChan)
} }
} }

View File

@ -22,7 +22,7 @@ type Mux struct {
*http.ServeMux *http.ServeMux
} }
type BriefingParticipant struct { type Participant struct {
*data.Participant *data.Participant
Login string Login string
GivenAnswers []int GivenAnswers []int
@ -30,9 +30,15 @@ type BriefingParticipant struct {
AllowRetry bool AllowRetry bool
} }
type Session struct { type Briefing struct {
ID uuid.UUID ID int64
*data.Briefing *data.Briefing
Participants []*BriefingParticipant Participants []*Participant
Questions []data.Question Questions []data.Question
} }
type Session struct {
ID uuid.UUID
Instructor data.Instructor
Briefings []*Briefing
}

View File

@ -11,11 +11,11 @@
{{define "add-buttons"}} {{define "add-buttons"}}
<div id="briefing-buttons"> <div id="briefing-buttons">
<button type="button" hx-post="/new-participant/{{.SessionID}}/" hx-target="#briefing-buttons" hx-swap="outerHTML"> <button type="button" hx-post="/new-participant/{{.BriefingID}}/" hx-target="#briefing-buttons" hx-swap="outerHTML">
Neuer Teilnehmer Neuer Teilnehmer
</button> </button>
<button type="submit" hx-post="/submit-form/{{.SessionID}}/" hx-target="#content"> <button type="submit" hx-post="/submit-form/{{.BriefingID}}/" hx-target="#content">
Weiter Weiter
</button> </button>
</div> </div>

View File

@ -20,7 +20,7 @@
<label for="company-{{.Login}}">Firma</label> <label for="company-{{.Login}}">Firma</label>
<input type="text" name="company-{{.Login}}" id="company-{{.Login}}" /> <input type="text" name="company-{{.Login}}" id="company-{{.Login}}" />
<button type="button" hx-post="/submit-participant/{{.SessionID}}/{{.Login}}/" hx-target="#content"> <button type="button" hx-post="/submit-participant/{{.BriefingID}}/{{.Login}}/" hx-target="#content">
Fertig Fertig
</button> </button>
</form> </form>

View File

@ -29,7 +29,7 @@
<form> <form>
{{template "answers" .}} {{template "answers" .}}
<button hx-post="/submit-answer/{{.SessionID}}/{{.Login}}/{{.QuestionID}}/" hx-target="#content" type="submit"> <button hx-post="/submit-answer/{{.BriefingID}}/{{.Login}}/{{.QuestionID}}/" hx-target="#content" type="submit">
Weiter Weiter
</button> </button>
</form> </form>

View File

@ -28,7 +28,7 @@
<p>{{.BriefingParticipant.NoIncorrect}} Fehler</p> <p>{{.BriefingParticipant.NoIncorrect}} Fehler</p>
{{if gt .BriefingParticipant.NoIncorrect 0}} {{if gt .BriefingParticipant.NoIncorrect 0}}
<p>Bitte nachschulen lassen und anschließend wiederholen.</p> <p>Bitte nachschulen lassen und anschließend wiederholen.</p>
<button hx-post="/retry/{{.SessionID}}/{{.Login}}/" hx-target="#content" type="submit">Wiederholen</button> <button hx-post="/retry/{{.BriefingID}}/{{.Login}}/" hx-target="#content" type="submit">Wiederholen</button>
{{end}} {{end}}
{{range .Questions}} {{range .Questions}}
<p>{{.Text}}</p> <p>{{.Text}}</p>

View File

@ -10,12 +10,12 @@
--> -->
{{define "refresh"}} {{define "refresh"}}
<button hx-post="/refresh-summary/{{.SessionID}}/{{.Login}}/" hx-target="#id-{{.Login}}" <button hx-post="/refresh-summary/{{.BriefingID}}/{{.Login}}/" hx-target="#id-{{.Login}}"
type="button">Aktualisieren</button> type="button">Aktualisieren</button>
{{end}} {{end}}
{{define "retry"}} {{define "retry"}}
<button hx-post="/allow-retry/{{.SessionID}}/{{.Login}}/" hx-swap="delete" type="button">Wiederholen erlauben</button> <button hx-post="/allow-retry/{{.BriefingID}}/{{.Login}}/" hx-swap="delete" type="button">Wiederholen erlauben</button>
{{end}} {{end}}
{{define "participant"}} {{define "participant"}}
@ -40,7 +40,7 @@
{{end}} {{end}}
{{define "content"}} {{define "content"}}
<button hx-post="/briefing-done/{{.SessionID}}/" hx-target="#content" type="button">Beenden</button> <button hx-post="/briefing-done/{{.BriefingID}}/" hx-target="#content" type="button">Beenden</button>
{{range .ParticipantsData}} {{range .ParticipantsData}}
{{template "participant" .}} {{template "participant" .}}
{{end}} {{end}}

View File

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