#container -@survey.items.each do |item| %h3=item.title -if item.questions_type == 1 %table %tr %th oui %th non %th nr %th non + nr %tr %td =oui = item.question_sets.where(:boolean_content => true).count %td =non = item.question_sets.where(:boolean_content => false).count %td =nr = item.question_sets.count - non - oui %td =nuls = nr + non %tr %td =per_oui = number_to_percentage (oui*100.00)/(oui+nuls), :precision => 1 %td =per_non = number_to_percentage (non*100.00)/(oui+nuls), :precision => 1 %td =per_nr = number_to_percentage (nr*100.00)/(oui+nuls), :precision => 1 %td =number_to_percentage (nuls*100.00)/(oui+nuls), :precision => 1 -r = rand 99999 -chart_data = [{:name => "oui", :y => oui, :per => per_oui},{:name => "non", :y => non, :per => per_non} ,{:name => "non répondu", :y => nr, :per => per_nr} ] %script $(document).ready(function() { charts.push(new Highcharts.Chart( =raw 'getChartConfig("'+r.to_s+'", "'+item.title+'", '+chart_data.to_json+')' )) }); %div.chart{:id => r.to_s} -if item.questions_type == 2 %table.large -count = 0 -item.question_sets.each do |question| -if question.content? %tr %td=simple_format question.content -else -count = count+1 %tr %td non répondu : =count ( =per_nr = number_to_percentage (count*100.00)/(@survey.nbr_responses), :precision => 1 ) -r = rand 99999 -chart_data = "['répondu',#{(((@survey.nbr_responses-count)*100.00)/(@survey.nbr_responses)).round(1)}],['non répondu', #{((count*100.00)/(@survey.nbr_responses)).round(1)}]" -chart_data = [{:name => "répondu", :y => (@survey.nbr_responses-count), :per => number_to_percentage(((@survey.nbr_responses-count)*100.00)/(@survey.nbr_responses), :precision => 1)} ,{:name => "non répondu", :y => count, :per => per_nr} ] %script $(document).ready(function() { charts.push(new Highcharts.Chart( =raw 'getChartConfig("'+r.to_s+'", "'+item.title+'", '+chart_data.to_json+')' )) }); %div.chart{:id => r.to_s} -if item.questions_type == 3 -#chart_data = "['oui',#{oui}],['non',#{non}],['non répondu', #{nr}]" -chart_data = [] -categories = [] %table -item.answers.each do |answer| %tr %td=answer.label_text %td =tot = answer.answer_sets.where(:is_checked => true).count %td=per = number_to_percentage (tot*100.00)/(@survey.nbr_responses), :precision => 1 -categories << answer.label_text -chart_data << {:name => answer.label_text, :y => tot, :per => per.to_s} -count = 0 -item.question_sets.each do |qs| -if qs.answer_sets.where(:is_checked => false).count == item.answers.count -count = count+1 %tr %td non répondu %td=count %td=per = number_to_percentage (count*100.00)/(@survey.nbr_responses), :precision => 1 -categories << "non répondu" -chart_data << {:name => "non répondu", :y => count, :per => per.to_s} -if item.answers.where(:field_type => 2).count > 0 -np = 0 -item.answers.where(:field_type => 2).each do |a| %h4 Réponses personnalisées pour " =a.label_text " %table.large -a.answer_sets.where(:is_checked => true).each do |a| -if a.content? %tr %td{:colspan => 3}=a.content -else -np = np +1 %tr %td Non précisé %td=np %td=number_to_percentage (np*100.00)/(a.answer_sets.where(:is_checked => true).count), :precision => 1 -r = rand 99999 %script $(document).ready(function() { =raw 'chartbar("'+r.to_s+'", '+chart_data.to_json+', '+categories.to_s+', "'+item.title+'");' }); .bar_chart{:id => r} -if item.questions_type == 4 -#chart_data = "['oui',#{oui}],['non',#{non}],['non répondu', #{nr}]" -chart_data = [] -categories = [] %table -item.answers.each do |answer| %tr %td=answer.label_text %td =tot = item.question_sets.where(:content => answer.label_text).count %td=per = number_to_percentage (tot*100.00)/(@survey.nbr_responses), :precision => 1 -categories << answer.label_text -chart_data << {:name => answer.label_text, :y => tot, :per => per.to_s} %tr %td non répondu %td=count = item.question_sets.where(:content => nil).count %td=per = number_to_percentage (count*100.00)/(@survey.nbr_responses), :precision => 1 -categories << "non répondu" -chart_data << {:name => "non répondu", :y => count, :per => per.to_s} -if item.answers.where(:field_type => 2).count > 0 -np = 0 -item.answers.where(:field_type => 2).each do |a| %h4 Réponses personnalisées pour " =a.label_text " %table.large -a.answer_sets.where(:is_checked => true).each do |a| -if a.content? %tr %td{:colspan => 3}=a.content -else -np = np +1 %tr %td Non précisé %td=np %td=number_to_percentage (np*100.00)/(a.answer_sets.where(:is_checked => true).count), :precision => 1 -r = rand 99999 %script $(document).ready(function() { -if item.answers.count > 4 =raw 'chartbar("'+r.to_s+'", '+chart_data.to_json+', '+categories.to_s+', "'+item.title+'");' -else charts.push(new Highcharts.Chart( =raw 'getChartConfig("'+r.to_s+'", "'+item.title+'", '+chart_data.to_json+')' )); }); .bar_chart{:id => r} .break