forked from bofh/fetsite
AutoCommit Fre Jul 31 11:03:07 CEST 2015
This commit is contained in:
8
app/views/survey/choices/_choice.html.erb
Normal file
8
app/views/survey/choices/_choice.html.erb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<%=
|
||||||
|
value=(current_user.id.nil?)? false : choice.answers.where(user_id: current_user.id).count>0
|
||||||
|
cstyle=(value) ? "true" :"false"
|
||||||
|
link_to ((value)? fa_icon("arrow-right"): "")+choice.text, answer_survey_question_path(choice.question, params: {survey_question: {selected: [choice.id]}})
|
||||||
|
|
||||||
|
#url_for({controller: obj.class.name.tableize,action: :flag, flag: flag, value: !value, theme: nil, locale: nil, id: obj.id}), remote: true, class:("flag-"+cstyle +" flag-"+flag + "-"+cstyle ), id: obj.flaglinkid(flag)
|
||||||
|
%>
|
||||||
|
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<div style="background:red"><b><%= answeredquestion.title%></b>
|
<div style="background:red"><b><%= answeredquestion.title%></b>
|
||||||
|
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 50).to_s%>px; margin: 0 auto">
|
||||||
<ul>
|
<ul>
|
||||||
<% answeredquestion.choices.each do |c| %>
|
<% answeredquestion.choices.each do |c| %>
|
||||||
<li>
|
<li>
|
||||||
<%= c.to_s %><%= answeredquestion.answers.where(choice_id: c.id).count %>
|
<%= c.to_s %>: <%= answeredquestion.answers.where(choice_id: c.id).count %> votes
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#container_question_<%= answeredquestion.id %>').highcharts({
|
$('#container_question_<%= answeredquestion.id %>').highcharts({
|
||||||
@@ -21,10 +23,13 @@ $(function () {
|
|||||||
text: '<%= answeredquestion.text %>'
|
text: '<%= answeredquestion.text %>'
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
categories: [<%= raw(answeredquestion.choices.map{|c| "'"+c.text+"'"}.join(",")) %>],
|
categories: [<%= raw(answeredquestion.choices.map{|c| "'"+escape_javascript(ff_icon("ffi1-good2"))+c.text+"'"}.join(",")) %>],
|
||||||
title: {
|
title: {
|
||||||
text: null
|
text: null
|
||||||
}
|
},
|
||||||
|
labels: {
|
||||||
|
useHTML: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
min: 0,
|
min: 0,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<div style="background:red"><b><%= question.title%></b>
|
<% if current_user.nil? %>
|
||||||
<%= form_for question, url: answer_survey_question_path do |f| %>
|
<%= render partial: "answeredquestion", object: question %>
|
||||||
<%= f.check_box :selected, {as: :check_boxes, collection: question.choices, label: false}, ["1"] %>
|
<% else %>
|
||||||
|
<div style="background:red"><b><%= question.title%></b>
|
||||||
<%= f.action :submit, :as => :input %>
|
<ul>
|
||||||
|
<% question.choices.each do |c| %>
|
||||||
<% end %>
|
<li><%= render c %></li>
|
||||||
|
<% end %>
|
||||||
</div>
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
namespace :survey do
|
namespace :survey do
|
||||||
resources :questions do
|
resources :questions do
|
||||||
member do
|
member do
|
||||||
|
get :answer
|
||||||
put :answer
|
put :answer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user