<commit_before><!-- 
  **Project: DMPRoadmap
  **Description: This block sets up the type of question, its guidance.
  **Arguments transferred: an instance of "question"
  **Copyright: Digital Curation Centre and University of California Curation Center
-->

<div class="question-div">
  <!--question format-->
  <%
     answers = question.plan_answers(plan.id)
     if answers.present?
       answer = answers.first
     else
       answer = Answer.new
     end
     question_id = question.id
     q_format = question.question_format
   %>

  <div id="question-form-<%= question_id %>" class="question-form">
    <%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, method: "put", :remote => true do |f| %>
      <%= f.inputs do %>
        <%= f.input :id, :as => :hidden, :input_html => { :value => answer.id } %>
        <%= f.input :plan_id, :as => :hidden, :input_html => { :value => @plan.id } %>
        <%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %>
        <%= f.input :question_id, :as => :hidden, :input_html => { :value => question_id, :class => "question_id" } %>
        <%= f.hidden_field :lock_version, id: "answer_lock_version-#{question_id}" %>

        <!-- Question text -->
        <!-- need 'raw' to stop formtastic f.*ing up the formatastic formatting -->
        <%= raw question.text %>

        <!--Suggested answer area-->
        <% if question.suggested_answers.any? %>
          <% suggested_answer = question.suggested_answers.first %>
          <% if suggested_answer.text.present? %>   <!-- could be present but empty -->
            <div class="suggested-answer-div">
              <span class="suggested-answer-intro">
                <% if suggested_answer.is_example? then %>
                  <%= _('Example of answer')%>
                <%else%>
                  <%= _('Suggested answer')%>
                <%end%>
              </span>

              <div class="suggested-answer-border">
                <p class="suggested-answer">
                  <%= raw suggested_answer.text %>
                </p>
              </div>
            </div>
          <% end %>
        <% end %>

        <!-- used for optimistic locking where a conflict is detected -->
        <div id="answer_notice_<%=question_id%>" class="answer_notice"></div>

        <!-- if the question has multiple choices pull out the options -->
        <% if question.option_based? %>
          <% options = question.options.order("number") %>

          <!-- work through the various format options -->
          <% if q_format.checkbox? %>
            <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %>
          <% elsif q_format.multiselectbox? %>
            <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %>
          <% elsif q_format.radiobuttons? %>
            <ol class="choices-group">
              <% options.each do |op| %>
                <li class= "choices-group">
                  <% if answer.option_ids[0] == op.id then%>
                    <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> 
                  <%else%>
                    <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> 
                  <% end %>
               <%= raw op.text %> </li>
              <% end %>
            </ol>
          <% elsif q_format.dropdown? %>
            <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %>
          <% end %>


          <!-- Comment text area for the multiple choice answers-->
          <% if question.option_comment_display == true %>
            <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %>
            <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %>
          <%end%>
        <% end %>  <!-- if multiple choice -->

        <% if q_format.textfield? %><commit_msg>fixed issue with question.options reference DMPRoadmap/roadmap#249<commit_after><!-- 
  **Project: DMPRoadmap
  **Description: This block sets up the type of question, its guidance.
  **Arguments transferred: an instance of "question"
  **Copyright: Digital Curation Centre and University of California Curation Center
-->

<div class="question-div">
  <!--question format-->
  <%
     answers = question.plan_answers(plan.id)
     if answers.present?
       answer = answers.first
     else
       answer = Answer.new
     end
     question_id = question.id
     q_format = question.question_format
   %>

  <div id="question-form-<%= question_id %>" class="question-form">
    <%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, method: "put", :remote => true do |f| %>
      <%= f.inputs do %>
        <%= f.input :id, :as => :hidden, :input_html => { :value => answer.id } %>
        <%= f.input :plan_id, :as => :hidden, :input_html => { :value => @plan.id } %>
        <%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %>
        <%= f.input :question_id, :as => :hidden, :input_html => { :value => question_id, :class => "question_id" } %>
        <%= f.hidden_field :lock_version, id: "answer_lock_version-#{question_id}" %>

        <!-- Question text -->
        <!-- need 'raw' to stop formtastic f.*ing up the formatastic formatting -->
        <%= raw question.text %>

        <!--Suggested answer area-->
        <% if question.suggested_answers.any? %>
          <% suggested_answer = question.suggested_answers.first %>
          <% if suggested_answer.text.present? %>   <!-- could be present but empty -->
            <div class="suggested-answer-div">
              <span class="suggested-answer-intro">
                <% if suggested_answer.is_example? then %>
                  <%= _('Example of answer')%>
                <%else%>
                  <%= _('Suggested answer')%>
                <%end%>
              </span>

              <div class="suggested-answer-border">
                <p class="suggested-answer">
                  <%= raw suggested_answer.text %>
                </p>
              </div>
            </div>
          <% end %>
        <% end %>

        <!-- used for optimistic locking where a conflict is detected -->
        <div id="answer_notice_<%=question_id%>" class="answer_notice"></div>

        <!-- if the question has multiple choices pull out the options -->
        <% if question.option_based? %>
          <% options = question.question_options.order("number") %>

          <!-- work through the various format options -->
          <% if q_format.checkbox? %>
            <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %>
          <% elsif q_format.multiselectbox? %>
            <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %>
          <% elsif q_format.radiobuttons? %>
            <ol class="choices-group">
              <% options.each do |op| %>
                <li class= "choices-group">
                  <% if answer.option_ids[0] == op.id then%>
                    <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> 
                  <%else%>
                    <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> 
                  <% end %>
               <%= raw op.text %> </li>
              <% end %>
            </ol>
          <% elsif q_format.dropdown? %>
            <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %>
          <% end %>


          <!-- Comment text area for the multiple choice answers-->
          <% if question.option_comment_display == true %>
            <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %>
            <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %>
          <%end%>
        <% end %>  <!-- if multiple choice -->

        <% if q_format.textfield? %>
{'fraction_non_alphanumeric': 0.17265258215962442, 'fraction_numerical': 0.0005868544600938967, 'mean_word_length': 2.08731884057971, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 221, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962667', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2447, 'n_words': 585}