diff --git a/packages/data/dbFuncs.go b/packages/data/dbFuncs.go index 0a980c9..df89078 100644 --- a/packages/data/dbFuncs.go +++ b/packages/data/dbFuncs.go @@ -301,7 +301,7 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) { } func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) { - answers := make([]int, 0) + answers := make([]int, len(sq)) query := ` SELECT given_answer FROM given_answers @@ -311,7 +311,7 @@ func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) { question_id = ? ` - for _, q := range sq { + for i, q := range sq { var answer int row := db.QueryRow(query, bid, pid, q.ID) @@ -319,7 +319,7 @@ func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) { return nil, fmt.Errorf("error: *DB.GetGivenAnswers: row.Scan(): %v", err) } - answers = append(answers, answer) + answers[i] = answer } return answers, nil