% # encoding: utf-8 %>
<%
data = action_data
@survey = data["survey"]
@questions = data["questions"]
@jump_tos_map = data["jump_tos_map"]
@answers = data["answers"]
answer_present = data['answer_present']
@redirect_url = data["redirect_url"]
%>
<% if @survey.needs_login && current_user.nil? %>
<% elsif answer_present %>
<% end %>
<% if !@redirect_url.blank? %>
<% else %>
<% unless @survey.deadline && Time.now > @survey.deadline %>
<%= form_for :answer, :method => :put, :url => survey_path(@survey), :html => {:class => 'survey clear'} do |f| %>
<%= @survey.title %>
<%= @survey.description %>
<% @questions.each_with_index do |question, i| %>
-
<% label = question.title %>
<% if question.is_required %>
(*)
<% end %>
<%= f.label question.id, label, :class => "o-question-title" %>
<% if !question.description.blank? %>
<%= question.description %>
<% end %>
<% case question.type %>
<% when SurveyQuestion::Oneline %>
<%= f.text_field question.id, :required => question.is_required %>
<% when SurveyQuestion::Multiline %>
<%= f.text_area question.id, :rows => 5, :required => question.is_required %>
<% when SurveyQuestion::Radio %>
<% question.survey_question_options.each do |option| %>
-
<%= f.radio_button question.id, option.id %>
<%= f.label "#{question.id}_#{option.id}", option.name, :class => 'o-question-option' %>
<% end %>
<% if question.custom_option %>
-
<%= f.radio_button question.id, 'custom_option' %>
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %>
<%= f.text_field "#{question.id}_custom_option" %>
<% end %>
<% when SurveyQuestion::Check %>
<%= f.fields_for "#{question.id}" do |cf| %>
<% question.survey_question_options.each do |option| %>
-
<%= cf.check_box option.id %>
<%= cf.label option.id, option.name, :class => 'o-question-option' %>
<% end %>
<% if question.custom_option %>
-
<%= cf.check_box 'custom_option' %>
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %>
<%= f.text_field "#{question.id}_custom_option" %>
<% end %>
<% end %>
<% when SurveyQuestion::Select %>
<% options = question.survey_question_options.collect {|o| [ o.name, o.id ] } %>
<% if question.custom_option %>
<% options.push [t('survey_question.use_custom_option'), 'custom_option'] %>
<% end %>
<%= f.select question.id, options, {}, :class => 'o-question-group view-dropdown' %>
<% if question.custom_option %>
<%= f.text_field "#{question.id}_custom_option", :class => 'custom_option' %>
<% end %>
<% when SurveyQuestion::Radiogroup %>
<%= f.fields_for "#{question.id}" do |rgf| %>
|
<% question.survey_question_radiogroups.each do |radiogroup| %>
<%= radiogroup.name %>
|
<% end %>
<% question.survey_question_options.each_with_index do |option, j| %>
>
<%= option.name %>
|
<% question.survey_question_radiogroups.each do |radiogroup| %>
<%= rgf.radio_button option.id, radiogroup.id %>
|
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= f.submit t('submit'), :class => 'survey-submit' %>
<% end %>
<%= stylesheet_link_tag "questionnaire" %>
<%= javascript_include_tag "lib/jquery.form"%>
<% else %>
the end
<% end %>
<% end %>