Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

How to model and integrate a rails mutliple choice quiz?

Rails • Asked by johny kopparapu

I am trying to make a little app where users can sign up, login, and be able to view and interact with questions for educational purposes.

I can visualize everything, but I'm having trouble translating that into actual code.

I know that a question model will have

Question Title - as a string or text

Question Answer 1 - as a string or text

Question Answer 2 - as a string or text

Question Answer 3 - as a string or text

Question Answer 4 - as a string or text

Question CORRECT ANSWER 5 - as a string or text

Naturally, I know the strong_params will have to accept these attributes (parameters?) as well.

How can I make a model where the new-question.html.erb form will pass an array of 5 options, with the ability to mark one as correct? On top of this, I would like to shuffle or randomize the answer choices on each page load.

Any help or guidance would be helpful. Michael Hartl's tutorial is great, but I'm not sure if i'm missing things from it or things aren't clicking.

Thank you @ Tekslate

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.