fix survey_b result and export value ( float )

This commit is contained in:
Spen 2013-10-15 11:13:15 +08:00
parent c9a235c802
commit ffac0654a7
2 changed files with 9 additions and 7 deletions

View File

@ -184,7 +184,7 @@
<td><%= t('survey_b.no_data') %></td> <td><%= t('survey_b.no_data') %></td>
<% @tcount = @tcount + @results[i_key]['count'] %> <% @tcount = @tcount + @results[i_key]['count'] %>
<% else %> <% else %>
<td><%= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %></td> <td><%= sprintf("%.2f", ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %></td>
<% @tcount = @tcount + (( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %> <% @tcount = @tcount + (( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %>
<% end %> <% end %>
<% end %> <% end %>
@ -198,7 +198,7 @@
<td><%= t('survey_b.no_data') %></td> <td><%= t('survey_b.no_data') %></td>
<% @tcount = @tcount + @results[i_key]['count'] %> <% @tcount = @tcount + @results[i_key]['count'] %>
<% else %> <% else %>
<td><%= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %></td> <td><%= sprintf("%.2f", ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %></td>
<% @tcount = @tcount + ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %> <% @tcount = @tcount + ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %>
<% end %> <% end %>
<% end %> <% end %>
@ -223,7 +223,7 @@
<td><%= t('survey_b.no_data') %></td> <td><%= t('survey_b.no_data') %></td>
<% @tcount = @tcount + @results[i_key]['count'] %> <% @tcount = @tcount + @results[i_key]['count'] %>
<% else %> <% else %>
<td><%= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %></td> <td><%= sprintf("%.2f", ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f )) %></td>
<% @tcount = @tcount + ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ) %> <% @tcount = @tcount + ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ) %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -30,14 +30,16 @@
<% if @results[i_key]['count'] == 0 %> <% if @results[i_key]['count'] == 0 %>
<%= t('survey_b.no_data') %> <%= t('survey_b.no_data') %>
<% else %> <% else %>
<%= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %> <%= sprintf("%.2f", ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %>
<%#= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %>
<% end %> <% end %>
</td> </td>
<td> <td>
<% if @results[i_key]['count'] == 0 %> <% if @results[i_key]['count'] == 0 %>
<%= t('survey_b.no_data') %> <%= t('survey_b.no_data') %>
<% else %> <% else %>
<%= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %> <%= sprintf("%.2f", ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %>
<%#= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %>
<% end %> <% end %>
</td> </td>
<td> <td>
@ -48,7 +50,8 @@
<% if @results[i_key]['count'] == 0 %> <% if @results[i_key]['count'] == 0 %>
<%= t('survey_b.no_data') %> <%= t('survey_b.no_data') %>
<% else %> <% else %>
<%= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %> <%= sprintf("%.2f", ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f )) %>
<%#= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
@ -92,7 +95,6 @@
//bar //bar
var data_bar_<%= item %> = google.visualization.arrayToDataTable([ var data_bar_<%= item %> = google.visualization.arrayToDataTable([
['<%= t("survey_b.#{item}_label") %>', '%'], ['<%= t("survey_b.#{item}_label") %>', '%'],
<% @results[item].each do |institution, count| %> <% @results[item].each do |institution, count| %>