From 632f47609228fc47e58c140e85a91419aca6c341 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 20 Sep 2022 00:28:44 +0200 Subject: [PATCH] Fix undefined variable errr --- grades.go | 6 +++--- surveys.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grades.go b/grades.go index 0540df9..33818e1 100644 --- a/grades.go +++ b/grades.go @@ -66,7 +66,7 @@ func declareAPIAuthGradesRoutes(router *gin.RouterGroup) { } func GetAllGrades() (scores map[int64]map[int64]*float64, err error) { - if rows, errr := DBQuery("SELECT id_user, id_survey, SUM(score)/COUNT(*) FROM student_scores GROUP BY id_user, id_survey"); err != nil { + if rows, errr := DBQuery("SELECT id_user, id_survey, SUM(score)/COUNT(*) FROM student_scores GROUP BY id_user, id_survey"); errr != nil { return nil, errr } else { defer rows.Close() @@ -97,7 +97,7 @@ func GetAllGrades() (scores map[int64]map[int64]*float64, err error) { } func (s Survey) GetGrades() (scores map[int64]*float64, err error) { - if rows, errr := DBQuery("SELECT id_question, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_question", s.Id); err != nil { + if rows, errr := DBQuery("SELECT id_question, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_question", s.Id); errr != nil { return nil, errr } else { defer rows.Close() @@ -122,7 +122,7 @@ func (s Survey) GetGrades() (scores map[int64]*float64, err error) { } func (s Survey) GetUserGrades(u *User) (scores map[int64]*float64, err error) { - if rows, errr := DBQuery("SELECT id_question, MAX(score) FROM student_scores WHERE id_survey=? AND id_user = ? GROUP BY id_question", s.Id, u.Id); err != nil { + if rows, errr := DBQuery("SELECT id_question, MAX(score) FROM student_scores WHERE id_survey=? AND id_user = ? GROUP BY id_question", s.Id, u.Id); errr != nil { return nil, errr } else { defer rows.Close() diff --git a/surveys.go b/surveys.go index d5091f5..48df3eb 100644 --- a/surveys.go +++ b/surveys.go @@ -302,7 +302,7 @@ func (s Survey) GetScore(u *User) (score *float64, err error) { } func (s Survey) GetScores() (scores map[int64]*float64, err error) { - if rows, errr := DBQuery("SELECT id_user, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_user", s.Id); err != nil { + if rows, errr := DBQuery("SELECT id_user, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_user", s.Id); errr != nil { return nil, errr } else { defer rows.Close()