anastasiaalt / quiz

Anastasia's Ruby on Rails Project
1 stars 0 forks source link

Submitting an Answer to a Question #6

Closed anastasiaalt closed 8 years ago

anastasiaalt commented 8 years ago

I wrote code for an Answer submission form very similar to the one I wrote with Matt for the quiz creation form. I am having an issue around missing an <% end %> somewhere in the form.

https://github.com/anastasiaalt/quiz/blob/master/app/views/submissions/_form.html.erb

When I go to the route, I get "syntax error, unexpected keyword_ensure, expecting keyword_end". I have played around with removing and adding <% end %> in the code and can't get away from this error.

I want to outline my thinking for this issue beyond this one error, as I suspect I am going to run into another one or ones as this was quite difficult for me to think through the logic and the syntax is difficult as well.

The ultimate answer to a question is going to be given when the user clicks a radio box at the end of the form to select the right option (or wrong option) after going into the nested form. Essentially, I get to the point of being able to select an available option that's attached to one particular question that's attached to one particular quiz that the student has selected, i.e. Submission--> quizzes--> quiz--> questions--> question-->options-->option . Logically, I am filtering down rather than creating from the top and choosing to add layers below as when I created a quiz. More on why I think this could be a problem at the bottom of this issue.

I see that the option the student will select is nested within the fieldset rather than attached to the new submission form. A submission is the product of a selected student_id and and a selected option_id that when selected by the student is recorded as either true or false depending on the :correct label for that option. I don't think (after fixing the erroneous <% end %> wherever it is that I cannot currently see) how I am attaching that boolean value of true or false for option to the new submission ultimately.

My other area of concern is in how I have created the permissions in the submissions controller.

https://github.com/anastasiaalt/quiz/blob/master/app/controllers/submissions_controller.rb

My thinking here is that in creating the quiz, I was drilling down from the top and choosing to provide more granularity (or not) with each successive choice, i.e. I chose to create a quiz and then a question and then possibly to give it some options. In the case of submission, I am really after the option and I am just sorting or narrowing to find that particular option to ultimately attach it to my submission. I start from a point of options and go up to the point of questions when I lay out the permissions for submissions whereas I started from a point of quiz and drilled down to the point of options with permissions for quizzes. Given the way I made my models and what belongs to versus has many, I wonder if this will be a problem somehow...

I could be overthinking this - likely - but I wonder if this means I think about the build up or drill down in the permissions differently as a result.

Avizacherman commented 8 years ago

Anastasia,

Sorry I didn't get to your last issue before you closed it, but I'm assuming you resolved it on your own. If not, let me know and I will go back are re-look at it.

I love your thought process, and especially being able to see it. You've given me a lot to look over and I want to make sure I consider it all fully before I give you some response and suggestions, so I may not get a response to most of this until the morning.

However, as to your missing end, I found where it's missing. There should be two in a row in the middle, because you're in a nested loop there of questions and options. Try adding that in and see if that works. It can get tricky sometimes finding those, especially in server-side templating, as you don't really get partial renders.

anastasiaalt commented 8 years ago

Hi. Yes, the second <% end %> worked!

In addition, I can successfully submit a form (this is truly miraculous and exciting to me!). However, as suspected, the submission does not receive an option id. This appears as nil when I look inside the rails console. So I am close, but I still need to get back to the primary form (the f. labels and fields) in order to submit a complete submission.