|
|
|
@ -26,25 +26,25 @@ 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.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleParticipant(db, p))
|
|
|
|
|
mux.HandleFunc("/end-video/"+fmt.Sprint(b.ID)+"/"+fmt.Sprint(p.Login)+"/", b.HandleEndOfVideo(p))
|
|
|
|
|
mux.HandleFunc("/submit-participant/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleParticipant(db, b, p))
|
|
|
|
|
mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleEndOfVideo(b, 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("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", HandleAnswer(db, b, 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))
|
|
|
|
|
mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleAllowRetry(p))
|
|
|
|
|
mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleRetry(b, p, &i))
|
|
|
|
|
mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", HandleRefresh(b, p))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing) {
|
|
|
|
|
func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing, s *Session) {
|
|
|
|
|
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))
|
|
|
|
|
mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", HandleNewParticipant(b, participantChan))
|
|
|
|
|
mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", HandleBriefingForm(db, s, b))
|
|
|
|
|
|
|
|
|
|
go mux.handleParticipants(db, participantChan, b)
|
|
|
|
|
}
|
|
|
|
@ -55,10 +55,10 @@ 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.ID)+"/", s.HandleSearch(db))
|
|
|
|
|
mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.ID)+"/", s.HandleNewBriefing(briefingChan))
|
|
|
|
|
mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingDone(db))
|
|
|
|
|
mux.HandleFunc("/search/"+fmt.Sprint(s.UUID)+"/", HandleSearch(db, s))
|
|
|
|
|
mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", HandleNewBriefing(s, briefingChan))
|
|
|
|
|
mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", HandleBriefingDone(db, s))
|
|
|
|
|
|
|
|
|
|
go mux.handleBriefings(db, briefingChan)
|
|
|
|
|
go mux.handleBriefings(db, briefingChan, s)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|