AutoCommit Don Jul 30 14:03:07 CEST 2015
This commit is contained in:
@@ -14,6 +14,7 @@ class Survey::Question < ActiveRecord::Base
|
|||||||
|
|
||||||
def do_answer(choice_ids, user)
|
def do_answer(choice_ids, user)
|
||||||
cid=choice_ids.map{|c|c.to_i}
|
cid=choice_ids.map{|c|c.to_i}
|
||||||
|
unless cid.empty?
|
||||||
Survey::Answer.where(user_id: user.id, choice_id: self.choice_ids).delete_all
|
Survey::Answer.where(user_id: user.id, choice_id: self.choice_ids).delete_all
|
||||||
cid.each do |c|
|
cid.each do |c|
|
||||||
if self.choice_ids.include?(c)
|
if self.choice_ids.include?(c)
|
||||||
@@ -22,5 +23,6 @@ class Survey::Question < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
<div style="background:red"><b><%= answeredquestion.title%></b>
|
<div style="background:red"><b><%= answeredquestion.title%></b>
|
||||||
<% answeredquestion.choices.each do |c| %>
|
<ul>
|
||||||
<%= c.to_s %><%= answeredquestion.answers.where(choice_id: c.id).count %>n
|
<% answeredquestion.choices.each do |c| %>
|
||||||
<% end %>
|
<li>
|
||||||
|
<%= c.to_s %><%= answeredquestion.answers.where(choice_id: c.id).count %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div style="background:red"><b><%= question.title%></b>
|
<div style="background:red"><b><%= question.title%></b>
|
||||||
<%= semantic_form_for question, url: answer_survey_question_path do |f| %>
|
<%= semantic_form_for question, url: answer_survey_question_path do |f| %>
|
||||||
<%= f.input :selected, as: :check_boxes, collection: question.choices, label: false %>
|
<%= f.input :selected, as: :check_boxes, collection: question.choices, label: false %>
|
||||||
|
<%= f.input :selected, as: :radio, collection: question.choices, label: false %>
|
||||||
<%= f.action :submit, :as => :input %>
|
<%= f.action :submit, :as => :input %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user