Alle Methode privat gemacht, bei denen es möglich ist.
This commit is contained in:
		@@ -41,7 +41,7 @@ func generateLogin() (string, error) {
 | 
			
		||||
	return hex.EncodeToString(bs), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *Briefing) HandleNewParticipant(cp chan<- *Participant) http.HandlerFunc {
 | 
			
		||||
func (b *Briefing) handleNewParticipant(cp chan<- *Participant) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		var err error
 | 
			
		||||
		participant := Participant{
 | 
			
		||||
@@ -67,7 +67,7 @@ func (b *Briefing) HandleNewParticipant(cp chan<- *Participant) http.HandlerFunc
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *Briefing) HandleBriefingForm(db *data.DB, s *Session) http.HandlerFunc {
 | 
			
		||||
func (b *Briefing) handleBriefingForm(db *data.DB, s *Session) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		b.DateTime = time.Now().Format("2006-01-02 15:04:05")
 | 
			
		||||
		b.Location = r.PostFormValue("location")
 | 
			
		||||
 
 | 
			
		||||
@@ -32,15 +32,15 @@ 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.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleParticipant(db, b))
 | 
			
		||||
		mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleEndOfVideo(b))
 | 
			
		||||
		mux.HandleFunc("/submit-participant/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleParticipant(db, b))
 | 
			
		||||
		mux.HandleFunc("/end-video/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleEndOfVideo(b))
 | 
			
		||||
		var i int
 | 
			
		||||
		for i = range b.Questions {
 | 
			
		||||
			mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", p.HandleAnswer(db, b, int64(i+1)))
 | 
			
		||||
			mux.HandleFunc("/submit-answer/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/"+fmt.Sprint(i+1)+"/", p.handleAnswer(db, b, int64(i+1)))
 | 
			
		||||
		}
 | 
			
		||||
		mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleAllowRetry())
 | 
			
		||||
		mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleRetry(b, &i))
 | 
			
		||||
		mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.HandleRefresh(b))
 | 
			
		||||
		mux.HandleFunc("/allow-retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleAllowRetry())
 | 
			
		||||
		mux.HandleFunc("/retry/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleRetry(b, &i))
 | 
			
		||||
		mux.HandleFunc("/refresh-summary/"+fmt.Sprint(b.UUID)+"/"+fmt.Sprint(p.Login)+"/", p.handleRefresh(b))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -74,8 +74,8 @@ func (mux *Mux) handleBriefings(db *data.DB, cb <-chan *Briefing, s *Session) {
 | 
			
		||||
	for b := range cb {
 | 
			
		||||
		getQuestions(db, b)
 | 
			
		||||
 | 
			
		||||
		mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", b.HandleNewParticipant(participantChan))
 | 
			
		||||
		mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", b.HandleBriefingForm(db, s))
 | 
			
		||||
		mux.HandleFunc("/new-participant/"+fmt.Sprint(b.UUID)+"/", b.handleNewParticipant(participantChan))
 | 
			
		||||
		mux.HandleFunc("/submit-form/"+fmt.Sprint(b.UUID)+"/", b.handleBriefingForm(db, s))
 | 
			
		||||
 | 
			
		||||
		go mux.handleParticipants(db, participantChan, b)
 | 
			
		||||
	}
 | 
			
		||||
@@ -86,9 +86,9 @@ 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.UUID)+"/", s.HandleSearch(db))
 | 
			
		||||
		mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", s.HandleNewBriefing(briefingChan))
 | 
			
		||||
		mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", s.HandleBriefingDone(db))
 | 
			
		||||
		mux.HandleFunc("/search/"+fmt.Sprint(s.UUID)+"/", s.handleSearch(db))
 | 
			
		||||
		mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.UUID)+"/", s.handleNewBriefing(briefingChan))
 | 
			
		||||
		mux.HandleFunc("/briefing-done/"+fmt.Sprint(s.UUID)+"/", s.handleBriefingDone(db))
 | 
			
		||||
 | 
			
		||||
		go mux.handleBriefings(db, briefingChan, s)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ func makeResultQuestions(sq []data.Question, givenAnswers []int) []resultQuestio
 | 
			
		||||
	return questions
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleParticipant(db *data.DB, b *Briefing) http.HandlerFunc {
 | 
			
		||||
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))
 | 
			
		||||
@@ -88,7 +88,7 @@ func (p *Participant) HandleParticipant(db *data.DB, b *Briefing) http.HandlerFu
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleAnswer(db *data.DB, b *Briefing, i int64) http.HandlerFunc {
 | 
			
		||||
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)) {
 | 
			
		||||
			if err := handleGivenAnswer(p, i-1, r); err != nil {
 | 
			
		||||
@@ -139,14 +139,14 @@ func (p *Participant) HandleAnswer(db *data.DB, b *Briefing, i int64) http.Handl
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleAllowRetry() http.HandlerFunc {
 | 
			
		||||
func (p *Participant) handleAllowRetry() http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		p.NoIncorrect = -1
 | 
			
		||||
		p.AllowRetry = true
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleRetry(b *Briefing, i *int) http.HandlerFunc {
 | 
			
		||||
func (p *Participant) handleRetry(b *Briefing, i *int) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		if p.AllowRetry {
 | 
			
		||||
			p.AllowRetry = false
 | 
			
		||||
@@ -176,7 +176,7 @@ func (p *Participant) HandleRetry(b *Briefing, i *int) http.HandlerFunc {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleRefresh(b *Briefing) http.HandlerFunc {
 | 
			
		||||
func (p *Participant) handleRefresh(b *Briefing) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		data := participantHTMLData{
 | 
			
		||||
			BriefingID:  b.UUID,
 | 
			
		||||
@@ -187,7 +187,7 @@ func (p *Participant) HandleRefresh(b *Briefing) http.HandlerFunc {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Participant) HandleEndOfVideo(b *Briefing) http.HandlerFunc {
 | 
			
		||||
func (p *Participant) handleEndOfVideo(b *Briefing) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		data := questionHTMLData{
 | 
			
		||||
			participantHTMLData: participantHTMLData{
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ type Session struct {
 | 
			
		||||
	Briefings  []*Briefing
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Session) HandleSearch(db *data.DB) http.HandlerFunc {
 | 
			
		||||
func (s *Session) handleSearch(db *data.DB) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		var err error
 | 
			
		||||
		data := tableHTMLData{}
 | 
			
		||||
@@ -41,7 +41,7 @@ func (s *Session) HandleSearch(db *data.DB) http.HandlerFunc {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Session) HandleNewBriefing(cb chan<- *Briefing) http.HandlerFunc {
 | 
			
		||||
func (s *Session) handleNewBriefing(cb chan<- *Briefing) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		briefing := Briefing{Briefing: &data.Briefing{InstructorID: s.Instructor.ID}, UUID: uuid.New()}
 | 
			
		||||
		s.Briefings = append(s.Briefings, &briefing)
 | 
			
		||||
@@ -51,7 +51,7 @@ func (s *Session) HandleNewBriefing(cb chan<- *Briefing) http.HandlerFunc {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Session) HandleBriefingDone(db *data.DB) http.HandlerFunc {
 | 
			
		||||
func (s *Session) handleBriefingDone(db *data.DB) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		data := tableHTMLData{SessionID: s.UUID}
 | 
			
		||||
		var err error
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user