survey/app/views/admin/surveys/answer_set.html.erb

121 lines
3.0 KiB
Plaintext

<% content_for :page_specific_css do %>
<style>
.answer-set .title{
margin-bottom: 15px;
}
.answer-set .title i{
margin-right: 10px;
}
.answer-set .set{
height: 100%;
width: 100%;
padding: 15px 0px;
}
.set {
color: #7E7D7D;
}
.set .qa{
padding: 15px 10px;
margin-bottom: 10px;
background-color: #fff;
}
.set .qa .init{
margin-right: 5px;
width: 30px;
border-right: 3px solid #7E7D7D;
display: inline-block;
font-weight: bold;
vertical-align: top;
}
.set .question{
font-size: 16px;
border-bottom: 1px solid #cecece;
padding-bottom: 5px;
}
.set .answer{
font-size: 16px;
padding-top: 5px;
word-break: break-all;
}
.set .radiogroup{
display: inline-block;
}
</style>
<% end %>
<% SurveysHelper.set_locale(I18n.locale) %>
<div class="answer-set">
<div class="title">
<h3><%= @survey.title %></h3>
<% if !@user.nil? %>
<h5><i class="icon icons-user"></i><%= @user.name %></h5>
<% end %>
</div>
<div class="set">
<% if @survey_answer.consent_used %>
<div class="qa" style="font-size: 1.5em;">
<%= t('survey.consent_to_be_used_for_research') %>
</div>
<% end %>
<% @survey.survey_questions.each_with_index do |sq, index| %>
<div class="qa">
<div class="question">
<span class="init">Q<%= (index + 1).to_s %></span> <%= sq.title %>
</div>
<div class="answer">
<span class="init">A</span>
<% case sq.type %>
<% when SurveyQuestion::Radio, SurveyQuestion::Select %>
<%= SurveysHelper.parse_value(@survey_answer[sq.id.to_s]) %>
<% when SurveyQuestion::Check %>
<%= SurveysHelper.parse_checkbox_value_html(@survey_answer[sq.id.to_s]) %>
<% when SurveyQuestion::Radiogroup %>
<div class="radiogroup">
<% sq.survey_question_options.each do |sqo| %>
<% if !@survey_answer[sq.id.to_s].nil? %>
<% if sq.custom_option_each_option %>
<%= @survey_answer[sq.id.to_s]["#{sqo.id}_custom_group_field"].blank? ? sqo.name : @survey_answer[sq.id.to_s]["#{sqo.id}_custom_group_field"] %> :
<% else %>
<%= sqo.name %> :
<% end %>
<%= SurveysHelper.parse_value(@survey_answer[sq.id.to_s][sqo.id.to_s]) %> <br />
<% end %>
<% end %>
<% if sq.custom_option_new_option %>
<%= sq.custom_option_title %> <%= @survey_answer[sq.id.to_s]['custom_option'] %>
<% end %>
</div>
<% when SurveyQuestion::Oneline, SurveyQuestion::Multiline %>
<%= @survey_answer[sq.id.to_s] rescue "" %>
<% when SurveyQuestion::DoubleLevelOption %>
<span style="display: inline-block;">
<%= @survey_answer[sq.id.to_s].collect{|v| SurveysHelper.parse_double_level_value(v,sq.custom_option_title.to_s)}.join('<br>').html_safe %>
</span>
<% end %>
</div>
</div>
<% end %>
</div>
<% if can_edit_or_delete?(@survey) %>
<div class="action">
<a href="/admin/surveys/<%= @survey.id.to_s %>/answer_sets" class="btn btn-primary">Back to answer sets</a>
</div>
<% end %>
</div>