Newer
Older
dmpopidor / app / views / dmptemplates / _edit_question.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 University of California Curation Center
-->

<%= form_for(question, :url => admin_updatequestion_dmptemplate_path(question), :html => { :method => :put}) do |f| %>
<div class="question-div">
	<table class="dmp_details_table phase">
			<!--Question number -->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.question_number_label")%></td>
				<td><%= f.number_field :number, :in => 1..50, :class => "number_field has-tooltip", "data-toggle" => "tooltip", "title" => t("org_admin.questions.number_help_text") %>
					<div class="border_bottom"></div>
				</td>
			</tr>

			<!--Question text -->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.question_text_label")%></td>
				<td><%= f.text_area :text, :rows => "5" %>
					<div class="border_bottom"></div>
				</td>
			</tr>

			<!-- Question format -->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.answer_format_label")%></td>
				<td><div id="ques-<%= question.id %>-format" class="ques_format">
						<div class="div_left_icon">
							<%= f.hidden_field :id,{ :class => "quest_id" } %>
							<%= f.select :question_format_id, 
								options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, question.question_format_id), 
								{},	:id => "#{question.id}-select-format"%>
						</div>
						<div class="div_right_icon">
							<%= link_to( image_tag("help_button.png"), "#", :class => "question_format_popover", :rel => "popover", "data-html" => "true",  "data-content" => t("org_admin.questions.question_format_help_text_html"))%>
						</div>

					</div>

					<!--display form to enter option from checkbox/radio button/ dropdown/ multi select box-->
					<div id="options-<%= question.id %>" style="display:none;" class="ques_format_option">
						<table class="options_table">
							<thead>
								<tr>
									<th nowrap class="small"><%= t("org_admin.option_order_label")%></th>
									<th nowrap class="medium"><%= t("org_admin.option_text_label")%></th>
									<th nowrap class="small"><%= t("org_admin.option_default_label")%></th>
									<th nowrap class="small"><%= link_to( image_tag("help_button.png"), "#", :class => "question_options_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_options_help_text_html"))%></th>	
								</tr>
							</thead>
							<tbody class="options_tbody">
								<% if question.options.count == 0 then %>
									<% 2.times {question.options.build } %>

								<%end%>
                                <% i = 0 %>
								<% question.options.to_a.sort_by{|op| op["number"]}.each do |options_q|%>
									<%= f.fields_for :options, options_q do |op|%>
                                        <% i = i + 1%>
                                        <% options_q.number = i %>
										<%= render "option_fields", :f => op %>
   									<%end%>
								<%end%>	
								
							</tbody>
						</table>

						<a href="#" class="add-option"><%= t("org_admin.add_option_label") %></a>

                        <div class="clearfix"></div>
                        <!--display for selecting comment box when multiple choice is being used-->
                        <%= f.check_box :option_comment_display, :as => :check_boxes%><%= f.label t("org_admin.questions.option_comment_display_checkbox"), :class => "checkbox inline"%>
					</div>
					<div class="clearfix"></div>
					<!--display for default value for text field label-->
					<div id='default-text-field-<%= question.id %>' style="display:none;" class="ques_format">
						<div>
							<%= t("org_admin.questions.default_answer_label")%>
						</div>
					</div>
					<div class="clearfix"></div>
					<!--display for default value for text area label -->
					<div id="default-text-area-<%= question.id %>" style="display:none;" class="ques_format">
						<div >
							<%= t("org_admin.questions.default_answer_label")%>
						</div>
					</div>
					<div class="clearfix"></div>
					<div id="default-value-field-<%= question.id %>" style="display:none;" class="ques_format">
						<div class="div_left_icon">
							<%= text_area_tag("question-default-value-#{question.id}", question.default_value, class: "tinymce") %>
						</div>
						<div class="div_right_icon">
							<%= link_to( image_tag("help_button.png"), "#", :class => "default_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.default_answer_help_text_html"))%>
						</div>
					</div>
					<div class="add_space"></div>
					<div class="clearfix"></div>
					<div class="border_bottom"></div>
				</td>
			</tr>

			<!-- Suggested answer or Example-->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.suggested_or_example_answer_label")%></td>
				<td><div class="div_left_icon">
					<% suggested_answer = question.suggested_answers.find_by_organisation_id(current_user.organisation.id) %>
					<% if suggested_answer.nil? then %>
						 <% suggested_answer = question.suggested_answers.build %>
					<%end%>
					<%= f.fields_for :suggested_answers, suggested_answer do |s|%>
						<%= s.hidden_field :organisation_id, :value => current_user.organisation.id %>
						<ul>
							<li><%= s.select :is_example, {t("org_admin.questions.example_answer_label") => true, t("org_admin.questions.suggested_answer_label") => false} %></li>
							<li><%= s.text_area :text, :rows => 5 %>
							</li>
						</ul>
					<%end%>
					</div>
					<div class="div_right_icon">
						<%= link_to( image_tag("help_button.png"), "#", :class => "suggested_answer_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.suggested_answer_help_text_html"))%>
					</div>
					<div class="clearfix"></div>
					<div class="border_bottom"></div>
				</td>
			</tr>
			<!-- Guidance for Question -->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.guidance_label")%></td>
				<td><div class="div_left_icon">
						<%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %>
					</div>
					<div class="div_right_icon">
						<%= link_to( image_tag("help_button.png"), "#", :class => "question_guidance_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_guidance_help_text_html"))%>
					</div>
					<div class="clearfix"></div>
					<div class="border_bottom"></div>
				</td>
			</tr>
			<!-- Themes -->
			<tr>
				<td class="first_template"><%= t("org_admin.questions.themes_label")%></td>
				<td><div class="div_left_icon">
						<%= f.collection_select(:theme_ids,
							Theme.all.order("title"),
							:id, :title, {:prompt => false, :include_blank => "None"}, {:multiple => true})%>
					</div>
					<div class="div_right_icon">
						<%= link_to( image_tag("help_button.png"), "#", :class => "question_themes_popover", :rel => "popover", "data-html" => "true", "data-content" => t("org_admin.questions.question_themes_help_text_html"))%>
					</div>
				</td>
			</tr>
		</table>
		<br />
		<!-- submit buttons -->
		<div class="move_2_right">
			<%= f.submit t("helpers.submit.save"), :class => "btn btn-primary" %>
			<% if !question.section.version.published? then%>
				<%= link_to t("helpers.submit.delete"), admin_destroyquestion_dmptemplate_path(:question_id => question.id),
				:confirm => t("org_admin.questions.delete_message", :question_text => question.text ), :method => :delete, :class => "btn btn-primary"%>
			<%end%>	
			<%= hidden_field_tag :question_id, question.id, :class => "question_id" %>
			<%= link_to t("helpers.submit.cancel"), "#", :class => "btn cancel cancel_edit_question" %>
		</div>
	</div>	


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