diff --git a/packages/data/dbFuncs.go b/packages/data/dbFuncs.go index 221b0dc..5cf80cf 100644 --- a/packages/data/dbFuncs.go +++ b/packages/data/dbFuncs.go @@ -280,20 +280,12 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) { // TODO: not scalable questions := make([]Question, 0) for rows.Next() { - q := Question{} - a1 := Answer{ID: 1} - a2 := Answer{ID: 2} - a3 := Answer{ID: 3} - a4 := Answer{ID: 4} + q := Question{Answers: make([]Answer, 4)} - if err := rows.Scan(&q.ID, &q.Text, &a1.Text, &a2.Text, &a3.Text, &a4.Text, &q.Correct); err != nil { + if err := rows.Scan(&q.ID, &q.Text, &q.Answers[0], &q.Answers[1], &q.Answers[2], &q.Answers[3], &q.Correct); err != nil { return nil, fmt.Errorf("error: *DB.GetQuestions: rows.Scan(): %v", err) } - q.Answers = append(q.Answers, a1) - q.Answers = append(q.Answers, a2) - q.Answers = append(q.Answers, a3) - q.Answers = append(q.Answers, a4) questions = append(questions, q) }