Include works in allGrades
This commit is contained in:
parent
93b5857fa6
commit
a9bb758e99
5 changed files with 31 additions and 21 deletions
|
|
@ -342,7 +342,7 @@ func (s Survey) GetScore(u *User) (score *float64, err error) {
|
|||
if ok {
|
||||
score = v
|
||||
} else {
|
||||
err = DBQueryRow("SELECT SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? AND id_user=?", s.Id, u.Id).Scan(&score)
|
||||
err = DBQueryRow("SELECT SUM(score)/COUNT(*) FROM student_scores WHERE kind = 'survey' AND id=? AND id_user=?", s.Id, u.Id).Scan(&score)
|
||||
if score != nil {
|
||||
*score = *score / 5.0
|
||||
}
|
||||
|
|
@ -355,7 +355,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); errr != nil {
|
||||
if rows, errr := DBQuery("SELECT id_user, SUM(score)/COUNT(*) FROM student_scores WHERE kind = 'survey' AND id_survey=? GROUP BY id_user", s.Id); errr != nil {
|
||||
return nil, errr
|
||||
} else {
|
||||
defer rows.Close()
|
||||
|
|
|
|||
Reference in a new issue