I just wrapped up the intro course and am completing the exercise. I have a guess controller with a backing model that I’m persisting to the database (the idea being that it might be useful for tracking stats/progress).
Right now I only have the ability for a user to make a guess for a particular card. However, I’d like to have the functionality to allow the user to go through the entire deck, guess one card at a time, and then progress to the next card to guess again.
In video lesson 2 we used the array shuffle method to go through the entire deck; however that won’t work here because the state won’t transfer from web request to web request. So far, the options I’m considering are as follows:
- Store the IDs of the cards in the deck in an array as a session variable or cookie, shuffle it, and then pop off items as you progress through.
- Query the database for each new card to guess from based on some statistic, such as the card in the deck that has been guessed the least number of times, has been guessed incorrectly the most, was guessed further in the past, etc. With this method though, you may never know when you’ve gone through the entire deck.
Does anyone have suggestions on the best way to accomplish this?