diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index e4c03ea..7e51188 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -80,9 +80,8 @@ end def sections - phase_id = self.phase_id ||= self.plan.template.phases.first.id # Use the first phase if none was specified - sections = Phase.find(phase_id).sections - sections.sort_by(&:number) + self.phase_id ||= self.plan.template.phases.first.id + Section.where({phase_id: phase_id}).order(:number) end def questions_for_section(section_id) @@ -167,7 +166,7 @@ end private - + # Returns an Array of question_ids for the exported settings stored for a plan def questions question_settings = self.settings(:export).fields[:questions] @questions ||= if question_settings.present? diff --git a/app/views/plans/export.html.erb b/app/views/plans/export.html.erb index 6f51388..27a6b1b 100644 --- a/app/views/plans/export.html.erb +++ b/app/views/plans/export.html.erb @@ -29,24 +29,25 @@ <% end %> <% @exported_plan.sections.each do |section| %> -
| <%= _('Questions')%> | -<%= _('Answers')%> | -
|---|
| <%= _('Questions')%> | +<%= _('Answers')%> | +
|---|---|
|
- <%= raw question.text %> |
<% answer = @plan.answer(question.id, false) %>
- <% if answer.nil? then %>
+ <% if answer.nil? %>
<%= _('Question not answered') %> <% else %> <% q_format = question.question_format %> @@ -56,19 +57,20 @@ |