Newer
Older
dmpopidor / app / views / branded / shared / export / _export_by_research_output.erb
<%# locals: { research_outputs, sections  } %>
<% research_outputs.each do |research_output| %>
  <% show_research_output_content = @show_unanswered || (!@show_unanswered && !research_output.get_answers_for_section(section[:id]).empty?) %>
  <% research_output_default_and_alone = research_output.is_default && research_outputs.length == 1 %>
  <% if !research_output_default_and_alone && 
        show_research_output_content %>
    <div class="research-output">
      <h2><%= research_output[:abbreviation] %> : <%= research_output[:fullname] %></h2>
  <% end %>
    <% sections.each do |section| %>
      <% section_has_common_answers = research_output.get_main().has_common_answers?(section[:id]) %>
      <% if @show_sections_questions %>
        <br>
        <h3><%= section[:title] %></h3>
        <br>
      <% end %>
      <% section[:questions].each do |question| %>
        <% answer = section_has_common_answers ? 
              @plan.answer(question[:id], false, research_output.get_main().id) : 
              @plan.answer(question[:id], false, research_output[:id]) %>
        <% blank = answer.present? ? answer.is_blank? : true %>
        <% options = answer.present? ? answer.question_options : [] %>
          <%  unless @show_unanswered == false && blank  %>
            <div class="question">
              <% if !@public_plan && @show_sections_questions%>
              <p>
                <%# Hack: for DOCX export - otherwise, bold highlighting of question inconsistent. %>
                <% if local_assigns[:export_format] && export_format == 'docx' %>
                  <strong><h4><%=  sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %></h4></strong>
                <% else %>
                  <div class="bold"><h4><%=  sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %></h4></div>
                <% end %>
                <br>
              </p>
              <br>
              <% end %>
              <%# case where question has not been answered sufficiently to display%>
              <% if @show_unanswered && (answer.blank? || (options.blank? && blank))%>
              <br>
              <p><%= _('Question not answered.') -%></p>
              <br><br>
              <br />
              <% else %>

              <%# case where Question has options %>
              <% if options.any? %>
                <ul>
                <% options.each do |opt| %>
                  <li><%= opt.text %></li>
                <% end %>
                </ul>
              <% end %>
              <%# case for RDA answer display %>
              <% if question[:format].rda_metadata? && !blank %>
                <% ah = answer.answer_hash %>
                <% if ah['standards'].present? %>
                <ul>
                  <% ah['standards'].each do |id, title| %>
                  <li><%= title %></li>
                  <% end %>
                </ul>
                <% end %>
                <p><%= sanitize ah['text'] %></p>
                <br>
              <%# case for displaying comments OR text %>
              <% elsif !blank %>
                <%= sanitize answer.text %>
                <br>
              <% end %>
              <br />
              <% end %>
            </div>
          <% end %>
        <% end %> <!-- questions.each -->

    <% end %>

  <% if !research_output_default_and_alone && 
        show_research_output_content %>
  </div> <!-- .research_output -->
  <% end %>

<% end %>