Check that surveys are open before accepting a response
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Thanks-To: Kurogor <mahe.charpy@epita.fr> Thanks-To: Fumesover <albin.parou@epita.fr> Thanks-To: Sébastien Januszczak <sebastien.januszczak@epita.fr> Thanks-To: Clément Lanata <clement.lanata@epita.fr> Thanks-To: Alexandre Delorme <alexandre.delorme@epita.fr> Thanks-To: Pioupush <justin.puchelle@epita.fr>
This commit is contained in:
parent
dfcde910b2
commit
5c53d2eaea
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@ -15,6 +16,14 @@ func init() {
|
||||
return APIErrorResponse{err: err}
|
||||
}
|
||||
|
||||
// Check the survey is open
|
||||
now := time.Now()
|
||||
if now.Before(s.StartAvailability) {
|
||||
return APIErrorResponse{err: fmt.Errorf("Le questionnaire n'a pas encore commencé")}
|
||||
} else if now.After(s.EndAvailability) {
|
||||
return APIErrorResponse{err: fmt.Errorf("Le questionnaire n'est plus ouvert")}
|
||||
}
|
||||
|
||||
for _, response := range responses {
|
||||
if len(response.Answer) > 0 {
|
||||
if _, err := s.NewResponse(response.IdQuestion, u.Id, response.Answer); err != nil {
|
||||
|
Reference in New Issue
Block a user