Drop score cache when score is updated for a student
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
cc4b10db42
commit
ab1b6dbd39
16
responses.go
16
responses.go
@ -127,6 +127,14 @@ func init() {
|
||||
now := time.Now()
|
||||
new.IdCorrector = &u.Id
|
||||
new.TimeScored = &now
|
||||
|
||||
if _, ok := _score_cache[current.IdUser]; ok {
|
||||
if surveyId, err := current.GetSurveyId(); err == nil {
|
||||
if _, ok = _score_cache[current.IdUser][surveyId]; ok {
|
||||
delete(_score_cache[current.IdUser], surveyId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new.Id = current.Id
|
||||
@ -279,6 +287,14 @@ func (s *Survey) NewResponse(id_question int64, id_user int64, response string)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Response) GetSurveyId() (int64, error) {
|
||||
if q, err := getQuestion(int(r.IdQuestion)); err != nil {
|
||||
return 0, err
|
||||
} else {
|
||||
return q.IdSurvey, err
|
||||
}
|
||||
}
|
||||
|
||||
func (r Response) Update() (Response, error) {
|
||||
_, err := DBExec("UPDATE survey_responses SET id_question = ?, id_user = ?, answer = ?, time_submit = ?, score = ?, score_explanation = ?, id_corrector = ?, time_scored = ? WHERE id_response = ?", r.IdQuestion, r.IdUser, r.Answer, r.TimeSubmit, r.Score, r.ScoreExplaination, r.IdCorrector, r.TimeScored, r.Id)
|
||||
return r, err
|
||||
|
Reference in New Issue
Block a user