🗃️ gathers random questions on each call
Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
91b027a64d
commit
35545070a9
1 changed files with 9 additions and 6 deletions
|
@ -44,12 +44,15 @@ func GetUserQuestions(respondentID int) ([]UserQuestions, error) {
|
|||
log.Fatalf("Error connecting to the database: %v\n", err)
|
||||
}
|
||||
|
||||
getQuestionsStatement := `SELECT DISTINCT s.SpørsmålID, s.tekst
|
||||
getQuestionsStatement := `
|
||||
SELECT s.SpørsmålID, s.tekst
|
||||
FROM Spørsmål s
|
||||
LEFT JOIN Spørsmålsvar ss ON s.spørsmålID = ss.spørsmålID
|
||||
LEFT JOIN SvarVurdering sv ON ss.svarID = sv.svarID AND sv.respondentID = $1
|
||||
WHERE sv.vurderingID IS NULL
|
||||
LIMIT 5`
|
||||
ORDER BY RANDOM()
|
||||
LIMIT 5;
|
||||
`
|
||||
|
||||
stmt, err := db.Prepare(getQuestionsStatement)
|
||||
if err != nil {
|
||||
|
|
Reference in a new issue