diff --git a/app/helpers/plans_helper.rb b/app/helpers/plans_helper.rb index a3db40d..d8d893b 100644 --- a/app/helpers/plans_helper.rb +++ b/app/helpers/plans_helper.rb @@ -48,9 +48,13 @@ return hash[:phases].many? ? "#{plan.title} - #{phase[:title]}" : plan.title end - def display_questions_and_section_headings(section, show_sections_questions, show_custom_sections) - # Return true if show_sections_questions is true and either section not customised, or section is customised - # and show_custom_sections is true - return show_sections_questions && (!section[:modifiable] || (show_custom_sections && section[:modifiable])) + def display_questions_and_section_headings(customization, section, show_sections_questions, show_custom_sections) + display = false + if show_sections_questions + display = !customization + display ||= customization && !section[:modifiable] + display ||= customization && section[:modifiable] && show_custom_sections + end + return display end end diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index dac15c3..94f3b58 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -75,7 +75,7 @@ .joins(phases: { sections: { questions: :question_format } }) .where(id: self.template_id) .order('sections.number', 'questions.number').first - + hash[:customization] = template.customization_of.present? hash[:title] = self.title hash[:answers] = self.answers diff --git a/app/views/shared/export/_plan.erb b/app/views/shared/export/_plan.erb index 43c7022..14051b6 100644 --- a/app/views/shared/export/_plan.erb +++ b/app/views/shared/export/_plan.erb @@ -24,7 +24,7 @@

<%= download_plan_page_title(@plan, phase, @hash) %>


<% phase[:sections].each do |section| %> - <% if display_questions_and_section_headings(section, @show_sections_questions, @show_custom_sections) %> + <% if display_questions_and_section_headings(@hash[:customization], section, @show_sections_questions, @show_custom_sections) %>

<%= section[:title] %>

<% section[:questions].each do |question| %> diff --git a/app/views/shared/export/_plan_txt.erb b/app/views/shared/export/_plan_txt.erb index ed05921..9516063 100644 --- a/app/views/shared/export/_plan_txt.erb +++ b/app/views/shared/export/_plan_txt.erb @@ -26,7 +26,7 @@ <% if phase[:title] == @selected_phase.title %> <%= (@hash[:phases].many? ? "#{phase[:title]}" : "") %> <% phase[:sections].each do |section| %> - <% if display_questions_and_section_headings(section, @show_sections_questions, @show_custom_sections) %> + <% if display_questions_and_section_headings(@hash[:customization], section, @show_sections_questions, @show_custom_sections) %> <%= "#{section[:title]}\n" %> <% section[:questions].each do |question| %> @@ -56,4 +56,4 @@ <% end %> <% end %> <%= "----------------------------------------------------------" %> -<%= _("A Data Management Plan created using %{application_name}") % { application_name: Rails.configuration.branding[:application][:name] } %> \ No newline at end of file +<%= _("A Data Management Plan created using %{application_name}") % { application_name: Rails.configuration.branding[:application][:name] } %>