<%= "#{@plan.title}" %>
<%= "----------------------------------------------------------\n" %>
<% if @show_coversheet %>
<%= @hash[:attribution].length > 1 ? _("Creators: ") : _('Creator:') %> <%= @hash[:attribution].join(', ') %>
<%= _("Affiliation: ") + @hash[:affiliation] %>
<% if @hash[:funder].present? %>
<%= _("Template: ") + @hash[:funder] %>
<% else %>
<%= _("Template: ") + @hash[:template] + @hash[:customizer] %>
<% end %>
<% if @plan.grant_number.present? %>
<%= _("Grant number: ") + @plan.grant_number %>
<% end %>
<% if @plan.description.present? %>
<%= _("Project abstract: ") %>
<%= "\t" + strip_tags(@plan.description) + "\n" %>
<% end %>
<%= _("Last modified: ") + l(@plan.updated_at.to_date, formats: :short) %>
<%= _("Copyright information:") %>
<%= "\t" + _(" The above plan creator(s) have agreed that others may use as much of the text of this plan as they would like in their own plans, and customise it as necessary. You do not need to credit the creator(s) as the source of the language used, but using any of the plan's text does not imply that the creator(s) endorse, or have any relationship to, your project or proposal") %>
<%= "----------------------------------------------------------\n" %>
<% end %>
<% @hash[:phases].each do |phase| %>
<%# Only render selected phase %>
<% if phase[:title] == @selected_phase.title %>
<%= (@hash[:phases].length > 1 ? "#{phase[:title]}" : "") %>
<% phase[:sections].each do |section| %>
<%# Only render if @show_sections_questions is true and either section not customised or section is customised and @show_custom_sections is true %>
<% if @show_sections_questions && (!section[:modifiable] || (@show_custom_sections && section[:modifiable])) %>
<%= "#{section[:title]}\n" %>
<% end %>
<% section[:questions].each do |question| %>
<%# Only render if @show_sections_questions is true and either section not customised or section is customised and @show_custom_sections is true %>
<% if @show_sections_questions && (!section[:modifiable] || (@show_custom_sections && section[:modifiable])) %>
<%# text in this case is an array to accomodate for option_based %>
<% if question[:text].respond_to?(:each) %>
<% question[:text].each do |txt| %>
<%= "#{strip_tags(txt.gsub(/<br\/?>/, '\n'))}\n" %>
<% end %>
<% else %>
<%= "#{strip_tags(question[:text][0].gsub(/<tr>(\s|<td>|<\/td>| )*(<\/tr>|<tr>)/,""))}\n" if question[:text].present? && question[:text][0].present? %>
<% end %>
<% end %>
<% answer = @plan.answer(question[:id], false) %>
<% blank = (answer.present? && answer.is_valid?) ? answer.text.gsub(/<\/?p>/, '').gsub(/<br\s?\/?>/, '\n').chomp.blank? : true %>
<% if blank && @show_unanswered %>
<%= " #{_("Question not answered.")}\n\n" %>
<% elsif !blank %>
<% if answer.question_options.length > 0 %>
<% answer.question_options.each do |opt| %>
<%= " #{opt.text}\n" %>
<% end %>
<% end %>
<%= " #{strip_tags(answer.text.gsub(/<\/?p>/, '').gsub(/<br\s?\/?>/, '\n').chomp)}\n\n" if answer.text.present? %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= "----------------------------------------------------------" %>
<%= _("A Data Management Plan created using %{application_name}") % { application_name: Rails.configuration.branding[:application][:name] } %>