Can display corrections in live sessions
This commit is contained in:
parent
99441d54f3
commit
89f61d1046
4 changed files with 47 additions and 9 deletions
21
direct.go
21
direct.go
|
|
@ -101,6 +101,7 @@ func msgCurrentState(survey *Survey) (msg WSMessage) {
|
|||
msg = WSMessage{
|
||||
Action: "new_question",
|
||||
QuestionId: survey.Direct,
|
||||
Corrected: survey.Corrected,
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
@ -152,6 +153,7 @@ type WSMessage struct {
|
|||
Stats map[string]interface{} `json:"stats,omitempty"`
|
||||
UserId *int64 `json:"user,omitempty"`
|
||||
Response string `json:"value,omitempty"`
|
||||
Corrected bool `json:"corrected,omitempty"`
|
||||
Timer uint `json:"timer,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -274,15 +276,26 @@ func SurveyWSAdmin(c *gin.Context) {
|
|||
if *survey.Direct != 0 {
|
||||
var z int64 = 0
|
||||
survey.Direct = &z
|
||||
survey.Corrected = false
|
||||
survey.Update()
|
||||
}
|
||||
go func() {
|
||||
go func(corrected bool) {
|
||||
time.Sleep(time.Duration(OffsetQuestionTimer+v.Timer) * time.Millisecond)
|
||||
survey.WSWriteAll(WSMessage{Action: "pause"})
|
||||
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
||||
}()
|
||||
|
||||
if corrected {
|
||||
survey.Corrected = v.Corrected
|
||||
survey.Update()
|
||||
|
||||
survey.WSWriteAll(WSMessage{Action: "new_question", QuestionId: v.QuestionId, Corrected: true})
|
||||
} else {
|
||||
survey.WSWriteAll(WSMessage{Action: "pause"})
|
||||
WSAdminWriteAll(WSMessage{Action: "pause", SurveyId: &survey.Id})
|
||||
}
|
||||
}(v.Corrected)
|
||||
v.Corrected = false
|
||||
} else {
|
||||
survey.Direct = v.QuestionId
|
||||
survey.Corrected = v.Corrected
|
||||
}
|
||||
_, err = survey.Update()
|
||||
if err != nil {
|
||||
|
|
|
|||
Reference in a new issue