Newer
Older
dmpopidor / app / views / templates / _edit_annotations.html.erb
<!--
**Project: DMPRoadmap
**Description: This block displays editing a question, its guidance, and options when multiple choice is selected
in the admin interface.
**Arguments transferred: an instance of 'question'
**Copyright: Digital Curation Centre and California Digital Library
-->

<%= form_for(question, url: admin_update_question_path(question), html: { method: :put}) do |f| %>
<div class="question-div">
  <table class="dmp_details_table phase">
    <%= f.hidden_field :id,{ class: "quest_id" } %>
    <!--Question number -->
    <tr>
      <td class="first_template"><%= _('Question number')%></td>
      <td><%= question.number %>
        <div class="border_bottom"></div>
      </td>
    </tr>

    <!--Question text -->
    <tr>
      <td class="first_template"><%= _('Question text')%></td>
      <td><%= raw question.text %>
        </br>
        <div class="answer-readonly">
          <% q_format = question.question_format %>
          <% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || q_format.title == _('Radio buttons') || q_format.title == _('Dropdown') %>
            <ul class='options'>
            <% if question.question_options.is_a? QuestionOption  %>
              <li>- <%= question.question_options.text %></li>
            <% else %>
              <% if !question.question_options.to_a.nil? %>
                <% question.question_options.to_a.sort_by{|op| op['number']}.each do |o| %>
                  <li>- <%= o.text %></li>
                <% end %>
              <% end %>
            <% end %>
            </ul>
          <% end %>
        </div>
      </td>
    </tr>

    <!-- Suggested answer or Example-->
    <tr>
      <td class="first_template"><%= _('example answer')%></td>
      <td>
        <div class="div_left_icon">
          <% annotations = question.annotations.where(org_id: current_user.org_id).where(type: Annotation.types[:example_answer]).order(:created_at).first %>
          <% if annotations.nil? %>
            <% annotations = question.annotations.build %>
          <% end %>
          <%= f.fields_for :annotations, annotation do |s|%>
            <%= s.hidden_field :org_id, value: current_user.org.id %>
            <ul>
              <li><%= s.text_area :text, rows: 5, 'data-toggle': 'tooltip', title: _('You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted.') %></li>
            </ul>
          <% end %>
        </div>
        <div class="clearfix"></div>
        <div class="border_bottom"></div>
      </td>
    </tr>

    <!-- Guidance for Question -->
    <tr>
      <td class="first_template"><%= _('Guidance')%></td>
      <td>
        <div class="div_left_icon" data-toggle="tooltip" title="<%= _("Enter specific guidance to accompany this question. If you have guidance by themes too, this will be pulled in based on your selections below so it's best not to duplicate too much text.") %>">
          <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %>
        </div>
        <div class="clearfix"></div>
        <div class="border_bottom"></div>
      </td>
    </tr>
  </table>
  <br />
  <!-- submit buttons -->
  <div class="move_2_right">
    <%= f.submit _('Save'), class: "btn btn-primary", role:"button" %>
    <% if !question.section.phase.template.published? %>
      <%= link_to _('Delete'), admin_destroy_question_path(question_id: question.id),
                  confirm: _("You are about to delete '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary", role:"button"%>
    <% end %>
    <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
    <%= link_to _('Cancel'), "#", class: "btn cancel cancel_edit_question", role:"button" %>
  </div>
</div>


<!--guidance block -->
<%= render partial: "guidances/guidance_display", locals: {question: question} %>
<% end %>