Don't readd the answer if unchanged
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8f49a49530
commit
cc4b10db42
18
responses.go
18
responses.go
@ -28,6 +28,15 @@ func init() {
|
|||||||
if !s.Shown && (s.Direct == nil || *s.Direct != response.IdQuestion) {
|
if !s.Shown && (s.Direct == nil || *s.Direct != response.IdQuestion) {
|
||||||
return APIErrorResponse{err: fmt.Errorf("Cette question n'est pas disponible")}
|
return APIErrorResponse{err: fmt.Errorf("Cette question n'est pas disponible")}
|
||||||
} else if len(response.Answer) > 0 {
|
} else if len(response.Answer) > 0 {
|
||||||
|
// Check if the response has changed
|
||||||
|
if response.Id != 0 {
|
||||||
|
if res, err := s.GetResponse(int(response.Id)); err == nil {
|
||||||
|
if res.IdUser == u.Id && res.Answer == response.Answer {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := s.NewResponse(response.IdQuestion, u.Id, response.Answer); err != nil {
|
if _, err := s.NewResponse(response.IdQuestion, u.Id, response.Answer); err != nil {
|
||||||
return APIErrorResponse{err: err}
|
return APIErrorResponse{err: err}
|
||||||
}
|
}
|
||||||
@ -50,6 +59,15 @@ func init() {
|
|||||||
|
|
||||||
for _, response := range responses {
|
for _, response := range responses {
|
||||||
if len(response.Answer) > 0 {
|
if len(response.Answer) > 0 {
|
||||||
|
// Check if the response has changed
|
||||||
|
if response.Id != 0 {
|
||||||
|
if res, err := s.GetResponse(int(response.Id)); err == nil {
|
||||||
|
if res.IdUser == u.Id && res.Answer == response.Answer {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := s.NewResponse(response.IdQuestion, u.Id, response.Answer); err != nil {
|
if _, err := s.NewResponse(response.IdQuestion, u.Id, response.Answer); err != nil {
|
||||||
return APIErrorResponse{err: err}
|
return APIErrorResponse{err: err}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
|
|
||||||
const res = [];
|
const res = [];
|
||||||
for (const r in responses) {
|
for (const r in responses) {
|
||||||
res.push({"id_question": responses[r].id_question, "value": String(responses[r].value)})
|
res.push({
|
||||||
|
"id": responses[r].id,
|
||||||
|
"id_question": responses[r].id_question,
|
||||||
|
"value": String(responses[r].value)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
survey.submitAnswers(res, id_user).then((response) => {
|
survey.submitAnswers(res, id_user).then((response) => {
|
||||||
|
Reference in New Issue
Block a user