So, I am developing a kind of Quiz game, the game will have a question on the screen and below 4 buttons, which will be filled with 1 right answer and 3 wrong answers. Simple right? I'm trying to use the following rawQuery() to load 4 answers, all of them must be random, except the right answer that has to appear.
SQLite:
myCursor = db.rawQuery("SELECT * FROM Answers WHERE QuestionID = 3 ORDER BY RANDOM() LIMIT 4", null);
So, QuestionID is the field that is specifying which question is being displayed to load the proper answers. I'll need to have a lot of answers so that the player can't memorise them. Is something like this pseudo-code possible?
myCursor = db.rawQuery("SELECT * FROM Answers WHERE QuestionID = 3 ORDER BY RANDOM('WHERE RightWrong = 1 LIMIT 1') LIMIT 4", null);
RightWrong is the field that tells if it's the right answer or not (inside the DB), it's an INT, if it is set to 1 then it is the correct answer.
I'm using SQLiteAssetHelper with SQLite DB Browser.
Aucun commentaire:
Enregistrer un commentaire