diff --git a/direct.go b/direct.go index 67b6196..36ee796 100644 --- a/direct.go +++ b/direct.go @@ -303,13 +303,11 @@ func SurveyWSAdmin(c *gin.Context) { if survey, err := getSurvey(sid); err != nil { log.Println("Unable to retrieve survey:", err) } else { + survey.Direct = v.QuestionId if v.Timer > 0 { - if *survey.Direct != 0 { - var z int64 = 0 - survey.Direct = &z - survey.Corrected = false - survey.Update() - } + survey.Corrected = false + survey.Update() + go func(corrected bool) { time.Sleep(time.Duration(OffsetQuestionTimer+v.Timer) * time.Millisecond) @@ -319,13 +317,16 @@ func SurveyWSAdmin(c *gin.Context) { survey.WSWriteAll(WSMessage{Action: "new_question", QuestionId: v.QuestionId, Corrected: true, Corrections: getCorrectionString(*v.QuestionId)}) } else { + var z int64 = 0 + survey.Direct = &z + survey.Update() + 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 if v.Corrected { v.Corrections = getCorrectionString(*v.QuestionId)