stuff
Conflicts: vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb
This commit is contained in:
parent
531cee70d2
commit
7ba0977e16
|
@ -10,8 +10,12 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController
|
|||
end
|
||||
|
||||
def show
|
||||
redirect_standalone panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do
|
||||
@survey = ::Survey.find params[:id]
|
||||
if @survey.redirect_mode
|
||||
@redirect_url = @survey.redirect_url
|
||||
render :redirect_standalone
|
||||
else
|
||||
redirect_standalone panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do
|
||||
@questions = @survey.survey_questions.all
|
||||
if @survey.jump_mode
|
||||
@jumpable_questions = @questions.all.select{ |q| q.jumpable? && q.can_set_jump? }
|
||||
|
@ -20,6 +24,7 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@survey = ::Survey.find params[:id]
|
||||
|
|
|
@ -29,6 +29,9 @@ class Survey
|
|||
|
||||
field :jump_mode, :type => Boolean, :default => false
|
||||
|
||||
field :redirect_mode, :type => Boolean, :default => false
|
||||
field :redirect_url, :type => String
|
||||
|
||||
validates :title, :at_least_one => true
|
||||
|
||||
has_many :survey_questions, :autosave => true, :dependent => :destroy
|
||||
|
|
|
@ -18,6 +18,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="widget-redirect" class="widget-box widget-size-300">
|
||||
<div class="widget-action clear tip">
|
||||
<a href="#" class="action"><i class="icon-exclamation-sign icon-white"></i></a>
|
||||
</div>
|
||||
<h3 class="widget-title"><i class="icons-calendar"></i><%= t('survey.redirect') %></h3>
|
||||
<div class="widget-content clear">
|
||||
<div class="control-group">
|
||||
<%= f.label :redirect_mode, t('survey.redirect_mode')%>
|
||||
<%= f.check_box :redirect_mode %>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<%= f.label :redirect_url, t('survey.redirect_url') %>
|
||||
<%= f.text_field :redirect_url %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="post-body">
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<li><%= link_to t('survey.duplicate_it'), duplicate_it_panel_survey_back_end_survey_path(survey, :page => params[:page]) %></li>
|
||||
<li><%= link_to t('survey.jump'), jump_panel_survey_back_end_survey_path(survey, :page => params[:page]) %></li>
|
||||
<li><%= link_to t('survey.set_answers'), set_answers_panel_survey_back_end_survey_path(survey, :page => params[:page]) %></li>
|
||||
<li><%= link_to t('survey.answers_list'), panel_survey_back_end_survey_answers_path(survey, :page => params[:page]) %></li>
|
||||
<li><%= link_to t('survey.export_csv'), export_panel_survey_back_end_survey_path(survey, :format => :csv), :target => '_blank' %></li>
|
||||
<li><%= link_to t('survey.chart'), result_panel_survey_front_end_survey_path(survey, :force_chart => true, :standalone => true), :target => '_blank' %></li>
|
||||
<li><%= link_to t(:delete_), panel_survey_back_end_survey_path(survey), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<section>
|
||||
<div class="o-question">
|
||||
<div class="o-question-description">
|
||||
<%= t 'survey.results_count' %>: <%= @survey_questions.count %>
|
||||
<%= t 'survey.results_count' %>: <%= @survey.survey_answers.count %>
|
||||
</div>
|
||||
<ol class="o-question-list">
|
||||
<% @survey_questions.each do |question| %>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<% # encoding: utf-8 %>
|
||||
<h1><%= @survey.title %></h1>
|
||||
<div>
|
||||
<section>
|
||||
<div class="o-question">
|
||||
<%= form_for :answer, :method => :put, :url => panel_survey_front_end_survey_path(@survey, :inner => true), :html => {:class => 'clear'} do |f| %>
|
||||
<div class="o-question">
|
||||
<%= form_for :answer, :method => :put, :url => panel_survey_front_end_survey_path(@survey, :standalone => true), :html => {:class => 'survey clear'} do |f| %>
|
||||
<h3 class="o-question-topic"><%= @survey.title %></h3>
|
||||
<div class="o-question-description">
|
||||
<%= @survey.description %>
|
||||
</div>
|
||||
|
@ -11,7 +9,7 @@
|
|||
<% @questions.each_with_index do |question, i| %>
|
||||
<li class="question-item question-<%= question.id.to_s %> hide" data-index="<%= i %>" data-type="<%= question.type%>" data-custom="<%= question.custom_option.to_s %>">
|
||||
<% label = question.title %>
|
||||
<% label += ' (' + t('survey_question.required') + ')' if question.is_required %>
|
||||
<% label += ' (*)' if question.is_required %>
|
||||
<%= f.label question.id, label, :class => "o-question-title" %>
|
||||
<div class="o-question-description">
|
||||
<%= question.description %>
|
||||
|
@ -22,41 +20,45 @@
|
|||
<% when ::SurveyQuestion::Multiline %>
|
||||
<%= f.text_area question.id, :rows => 5, :required => question.is_required %>
|
||||
<% when ::SurveyQuestion::Radio %>
|
||||
<ul class="o-question-group view-list">
|
||||
<% question.survey_question_options.each do |option| %>
|
||||
<p>
|
||||
<li>
|
||||
<%= f.radio_button question.id, option.id %>
|
||||
<%= f.label "#{question.id}_#{option.id}", option.name, :style => "display:inline" %>
|
||||
</p>
|
||||
<%= f.label "#{question.id}_#{option.id}", option.name, :class => 'o-question-option' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if question.custom_option %>
|
||||
<p>
|
||||
<li>
|
||||
<%= f.radio_button question.id, 'custom_option' %>
|
||||
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :style => "display:inline" %>
|
||||
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %>
|
||||
<%= f.text_field "#{question.id}_custom_option" %>
|
||||
</p>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% when ::SurveyQuestion::Check %>
|
||||
<ul class="o-question-group view-list">
|
||||
<%= f.fields_for "#{question.id}" do |cf| %>
|
||||
<% question.survey_question_options.each do |option| %>
|
||||
<p>
|
||||
<li>
|
||||
<%= cf.check_box option.id %>
|
||||
<%= cf.label option.id, option.name, :style => "display:inline" %>
|
||||
</p>
|
||||
<%= cf.label option.id, option.name, :class => 'o-question-option' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if question.custom_option %>
|
||||
<p>
|
||||
<li>
|
||||
<%= cf.check_box 'custom_option' %>
|
||||
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :style => "display:inline" %>
|
||||
<%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %>
|
||||
<%= f.text_field "#{question.id}_custom_option" %>
|
||||
</p>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% 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 %>
|
||||
<%= 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 %>
|
||||
|
@ -97,13 +99,19 @@
|
|||
<%= f.submit t('submit'), :class => 'survey-submit' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% content_for :page_stylesheets do %>
|
||||
<link href='/assets/questionnaire.css' rel='stylesheet' type='text/css' />
|
||||
<% end %>
|
||||
<script type="text/javascript" src="/assets/jquery.form.js"></script>
|
||||
<script type="text/javascript">
|
||||
$('form.survey').ajaxForm({
|
||||
beforeSubmit: function(a,f,o) {
|
||||
o.dataType = 'script';
|
||||
},
|
||||
success: function(data) {
|
||||
}
|
||||
});
|
||||
<% if @survey.jump_mode %>
|
||||
var jump_tos_map = <%== @jump_tos_map.to_json %>;
|
||||
var $current_question = $('.question-item').eq(0);
|
||||
|
|
|
@ -36,6 +36,10 @@ en:
|
|||
not_jump: Not Jump
|
||||
jump_to_end: End of Survey
|
||||
|
||||
redirect: Redirect
|
||||
redirect_mode: Redirect Mode
|
||||
redirect_url: Redirect Url
|
||||
|
||||
must_answer: Must be Answered
|
||||
|
||||
default_widget:
|
||||
|
|
|
@ -37,6 +37,10 @@ zh_tw:
|
|||
not_jump: 依據試卷列出所有問題數
|
||||
jump_to_end: 結束問題
|
||||
|
||||
redirect: 問卷跳轉
|
||||
redirect_mode: 設爲跳轉模式
|
||||
redirect_url: 跳轉地址
|
||||
|
||||
must_answer: 必須回答這個問題
|
||||
|
||||
default_widget:
|
||||
|
|
Loading…
Reference in New Issue