Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Brandon Barrette
Brandon Barrette
20,485 Points

Quizzes Grading in RoR app

So I'm working on adding quizzes to my app and have already successfully set up the models and controller to add quizzes, questions, and answers.

My models are Quiz, Question, Answer (Questions belong to quiz, and have many answers)

Now I want my users to be able to take the quiz and this is where I am running into trouble. I tried using sessions to store the question id value I am on, but am running into errors with Cookie Overflow.

Has anyone attempted something like this? Or know of a good resource to attempt to do this?

I'm planning on having 2 other models, a user_answers model which stores the responses from the user and a quiz_result model which stores the final score.

Any guidance or ideas is greatly appreciated!

1 Answer

Steve Christie
Steve Christie
9,509 Points

I wouldn't think you would need to use sessions. In the view, your form_for would add the answers to params. If you link to your code, it might be easier to help.

Brandon Barrette
Brandon Barrette
20,485 Points

So I did get it working using sessions by only storing the ids (I had accidentally stored the entire question array in the session and caused the overflow there).

My main concern is knowing which question to go to next. If I don't store the question id in a session, how does the controller know which question to display next?

I have it working, but I don't think it's quite as robust as it could be.