All threads / How to model and integrate a rails mutliple choice quiz?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to model and integrate a rails mutliple choice quiz?

johny kopparapu asked in Rails

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

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.