Reputation: 25
I have coded a battleships game and I am now trying to make it so that before the user can guess the position of the ships they must get a maths question correct. I then want the difficult of the questions being asked to adapt with the ability of the user. I believe that the best way to do this is by creating a table of math questions arranged in columns of difficulty. For example the first question will be a random question from column 5; if the user gets it correct then the next question will be asked from column 6, and if incorrect from column 4. I have never created a database before and I need help on how to do it.
Upvotes: 0
Views: 36
Reputation: 9639
Create a table called Question with the following columns:
By making Difficulty a column, you do not need to have multiple columns of questions. This is an example of database "normalization". It allows you to run a query like this:
select Name, Text, ExpectedAnswer from Question where Difficulty = 'Hard'
You also need to have some way of not repeating questions. For example, keep a list of questions you have already asked, then you can use the query:
select Name, Text, ExpectedAnswer from Question where Difficulty = 'Hard' and Name not in listOfPreviouslyAskedQuestions.
You will need to work out how to pass listOfPreviouslyAskedQuestions into the database query.
Upvotes: 1