<%- if ['question_pages', 'question_sheets', 'elements'].include?(controller.controller_name) -%>
<%- else -%> <% headers = question_grid_with_total.cols.to_s.split(';') %> <% if headers.detect {|h| h.strip.present?} %> <%- headers.each do |header| -%> <%- end -%> <% end %> <%- col_count = 0 question_grid_with_total.elements.each do |element| -%> <%- col_count += 1 if col_count % question_grid_with_total.num_cols == 0 && element != question_grid_with_total.elements.last then col_count = 0 -%><%- end -%> <%- end -%> <%- while col_count < question_grid_with_total.num_cols do col_count += 1-%> <%- end unless col_count == 0-%> <%- if question_grid_with_total.total_cols.present? -%> <%- total_cols = question_grid_with_total.total_cols.split(',').collect(&:to_i) (question_grid_with_total.num_cols - 1).times do |i| if total_cols.include?(i + 2) -%> <% else %> <% end %> <%- end -%> <%- end -%>
<%= header || ' ' %>
<% grid_el = @elements.to_a.find {|el| el.id == element.id} %> <%= render :partial => 'answer_pages/element', :object => grid_el, :locals => {:in_grid => true, :col => col_count} if grid_el %>
 
Total <%= text_field_tag "total_#{question_grid_with_total.id}_#{i + 1}", '', :class => 'text validate-number', :readonly => true %>  
<%- end -%>