Comments (9)
Hi @OneDivZero I guess that you are not using the new version of the Survey. Currently we just build a new attempt per question, i.e you only see the question once in a form.
Answering to your last question, we just fixed the issue. You are right, we only catch on the controller the first question. The main problem was that every question must have a unique identifier.
<!-- Question 1 has identifier 0 -->
<input id="survey_attempt_answers_attributes_0_option_id"
name="survey_attempt[answers_attributes][0][option_id]" type="checkbox" value="1"/>
<!-- Question 2 has identifier 1 -->
<input id="survey_attempt_answers_attributes_1_option_id"
name="survey_attempt[answers_attributes][1][option_id]" type="checkbox" value="1"/>
Thanks again for the reporting! Doing that help us to improve the Survey gem for everyone!
from survey.
@OneDivZero was talking about handle multiple options for one question. At the moment it doesn't work
My form - I'm selecting 2 options for first questions
and in params I should have 2 options but got only one
from survey.
Hi jakubowiczj, wel'll look into it and get back to you.
from survey.
Any hotfixes for this issue?
from survey.
I was able to come up with a workaround that doesn't use the builder and just build out the input tags myself, based on the incorrect markup generated.
<%= form_for [:quizzes, @attempt] do |f| %>
<ul>
<% @assignment.survey.questions.each_with_index do |question, index| %>
<li>
<p><%= question.text %></p>
<input type="hidden" name="survey_attempt[answers_attributes][<%= index %>][question_id]" value="<%= question.id %>" />
<% question.options.each do |option| %>
<input type="checkbox" value="<%= option.id %>" name="survey_attempt[answers_attributes][<%= index %>][option_id]" />
<%= option.text %> <br />
<% end -%>
</li>
<% end -%>
</ul>
<%= f.submit "Submit" %>
<% end -%>
from survey.
hi, i'm a rails newbie and i'm trying to get survey working. here's where i'm confused: in attempts_controller.rb, in the create function, we make a new attempt with @survey.attempts.new(param[:attempt]). This is confusing to me because when i inspect it in the debugger at this point, param doesn't contain a key called "attempt" -- it does contain "survey_attempt", from alex's fix to issue #5. but the structure of that data doesn't match up with the structure of attempt.rb -- "answers_attributes", etc.
not sure if this has anything to do with it, but the end result is that when i go through the form i've created using the route contests/attempts/new, it allows me to submit and records the attempt itself to the db, but doesn't record any answers.
please stop me if i'm missing something obvious!
from survey.
Got it working. The crux is an extraneous [] in the name field of check_box_tag in the _form.html.erb. I removed that and made it a radio_button_tag instead and it works fine -- but with no multiple value selection, obviously.
I think the way accepts_nested_attributes_for is used in the model structure of answer, attempt, and option means that the incoming params are expected to have single question ids mapped to single option ids -- not to an array of option ids, which is what the existing _form.html.erb produces.
from survey.
Hi @brw12, you were right about the parameter key wrongly passed to the attempt object. Your solution with the radio button works, but surveys can have more than one correct answer per question. We are working to fix this, (currently we have a solution in this branch #10 if you want to look). Thanks for the notice.
from survey.
Thanks for the reply, this is helping me understand both rails and git
better!
-Ben
917 254 1578
On Dec 7, 2013 6:42 AM, "Alexandre Quiterio" [email protected]
wrote:
Hi @brw12 https://github.com/brw12, you were right about the parameter
key wrongly passed to the attempt object. Your solution with the radio
button works, but surveys can have more than one correct answer per
question. We are working to fix this, (currently we have a solution in this
branch #10 #10 if you
want to look). Thanks for the notice.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-30053222
.
from survey.
Related Issues (20)
- ActiveModel::ForbiddenAttributesError HOT 3
- Attach a Survey to a parent Model HOT 1
- Survey response types HOT 3
- Migration fails HOT 1
- link_to_function in the helper is deprecated in Rails 4. HOT 4
- Mongoid HOT 2
- Add support for simple_form
- DB Migration Error HOT 3
- rails generate survey rails_admin exception HOT 3
- Conditional questions
- ragarding creating a quiz app in rails
- ragarding creating a quiz app in rails
- Plain generation not creating routes HOT 1
- config/locales/en.yml has mispelling in suveys_controller #create and #update actions
- Routes are not generated
- Add support to require specific questions prior to form submit
- strong parameters for active admin HOT 1
- undefined method in the form
- Rails 5 Support HOT 11
- Is there a easy way to Add free text answer field? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from survey.