AutoCommit Don Jul 30 02:03:02 CEST 2015
This commit is contained in:
@@ -13,10 +13,11 @@ class Survey::Question < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def do_answer(choice_ids, user)
|
def do_answer(choice_ids, user)
|
||||||
self.answers.where(user_id: user.id).each {|a| a.delete}
|
cid=choice_ids.map{|c|c.to_i}
|
||||||
choice_ids.each do |c|
|
Survey::Answer.where(user_id: user.id, choice_id: self.choice_ids).delete_all
|
||||||
|
cid.each do |c|
|
||||||
if self.choice_ids.include?(c)
|
if self.choice_ids.include?(c)
|
||||||
a=Survey::Answer.new(user_id: user.id, choice_id: c)
|
a=Survey::Answer.new(user_id: user.id, choice_id: c.to_i)
|
||||||
a.save
|
a.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div style="background:red"><b><%= answeredquestion.title%></b>
|
<div style="background:red"><b><%= answeredquestion.title%></b>
|
||||||
<% answeredquestion.choices.each do |c| %>
|
<% answeredquestion.choices.each do |c| %>
|
||||||
<%= c.to_s %><%= answeredquestion.answers.where(choice_id: c.id).count %>
|
<%= c.to_s %><%= answeredquestion.answers.where(choice_id: c.id).count %>n
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<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 %>
|
<%= f.input :selected, as: :check_boxes, collection: question.choices, label: false %>
|
||||||
<%= f.actions do %>
|
|
||||||
<%= f.action :submit, :as => :input %>
|
<%= f.action :submit, :as => :input %>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
<p>
|
<p>
|
||||||
<b>Text:</b>
|
<b>Text:</b>
|
||||||
<%= @survey_question.text %>
|
<%= @survey_question.text %>
|
||||||
|
</p><p>
|
||||||
|
<%= params.to_yaml %>
|
||||||
</p>
|
</p>
|
||||||
|
<%= params[:survey_question][:selected].map{|c|c.to_i}.to_yaml %>
|
||||||
<p>
|
<p>
|
||||||
<b>Typ:</b>
|
<b>Typ:</b>
|
||||||
<%= @survey_question.typ %>
|
<%= @survey_question.typ %>
|
||||||
|
|||||||
Reference in New Issue
Block a user