Conflicts:

	vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb
This commit is contained in:
iCross 2013-05-20 17:16:06 +08:00
parent 531cee70d2
commit 7ba0977e16
8 changed files with 147 additions and 108 deletions

View File

@ -10,8 +10,12 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController
end end
def show def show
redirect_standalone panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do
@survey = ::Survey.find params[:id] @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 @questions = @survey.survey_questions.all
if @survey.jump_mode if @survey.jump_mode
@jumpable_questions = @questions.all.select{ |q| q.jumpable? && q.can_set_jump? } @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
end end
end
def update def update
@survey = ::Survey.find params[:id] @survey = ::Survey.find params[:id]

View File

@ -29,6 +29,9 @@ class Survey
field :jump_mode, :type => Boolean, :default => false 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 validates :title, :at_least_one => true
has_many :survey_questions, :autosave => true, :dependent => :destroy has_many :survey_questions, :autosave => true, :dependent => :destroy

View File

@ -18,6 +18,22 @@
</div> </div>
</div> </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>
<div id="post-body"> <div id="post-body">

View File

@ -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.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.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.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.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('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> <li><%= link_to t(:delete_), panel_survey_back_end_survey_path(survey), :confirm => t('sure?'), :method => :delete, :remote => true %></li>

View File

@ -6,7 +6,7 @@
<section> <section>
<div class="o-question"> <div class="o-question">
<div class="o-question-description"> <div class="o-question-description">
<%= t 'survey.results_count' %>: <%= @survey_questions.count %> <%= t 'survey.results_count' %>: <%= @survey.survey_answers.count %>
</div> </div>
<ol class="o-question-list"> <ol class="o-question-list">
<% @survey_questions.each do |question| %> <% @survey_questions.each do |question| %>

View File

@ -1,9 +1,7 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<h1><%= @survey.title %></h1>
<div>
<section>
<div class="o-question"> <div class="o-question">
<%= form_for :answer, :method => :put, :url => panel_survey_front_end_survey_path(@survey, :inner => true), :html => {:class => 'clear'} do |f| %> <%= 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"> <div class="o-question-description">
<%= @survey.description %> <%= @survey.description %>
</div> </div>
@ -11,7 +9,7 @@
<% @questions.each_with_index do |question, i| %> <% @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 %>"> <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 = 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" %> <%= f.label question.id, label, :class => "o-question-title" %>
<div class="o-question-description"> <div class="o-question-description">
<%= question.description %> <%= question.description %>
@ -22,41 +20,45 @@
<% when ::SurveyQuestion::Multiline %> <% when ::SurveyQuestion::Multiline %>
<%= f.text_area question.id, :rows => 5, :required => question.is_required %> <%= f.text_area question.id, :rows => 5, :required => question.is_required %>
<% when ::SurveyQuestion::Radio %> <% when ::SurveyQuestion::Radio %>
<ul class="o-question-group view-list">
<% question.survey_question_options.each do |option| %> <% question.survey_question_options.each do |option| %>
<p> <li>
<%= f.radio_button question.id, option.id %> <%= f.radio_button question.id, option.id %>
<%= f.label "#{question.id}_#{option.id}", option.name, :style => "display:inline" %> <%= f.label "#{question.id}_#{option.id}", option.name, :class => 'o-question-option' %>
</p> </li>
<% end %> <% end %>
<% if question.custom_option %> <% if question.custom_option %>
<p> <li>
<%= f.radio_button question.id, 'custom_option' %> <%= 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" %> <%= f.text_field "#{question.id}_custom_option" %>
</p> </li>
<% end %> <% end %>
</ul>
<% when ::SurveyQuestion::Check %> <% when ::SurveyQuestion::Check %>
<ul class="o-question-group view-list">
<%= f.fields_for "#{question.id}" do |cf| %> <%= f.fields_for "#{question.id}" do |cf| %>
<% question.survey_question_options.each do |option| %> <% question.survey_question_options.each do |option| %>
<p> <li>
<%= cf.check_box option.id %> <%= cf.check_box option.id %>
<%= cf.label option.id, option.name, :style => "display:inline" %> <%= cf.label option.id, option.name, :class => 'o-question-option' %>
</p> </li>
<% end %> <% end %>
<% if question.custom_option %> <% if question.custom_option %>
<p> <li>
<%= cf.check_box 'custom_option' %> <%= 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" %> <%= f.text_field "#{question.id}_custom_option" %>
</p> </li>
<% end %> <% end %>
<% end %> <% end %>
</ul>
<% when ::SurveyQuestion::Select %> <% when ::SurveyQuestion::Select %>
<% options = question.survey_question_options.collect {|o| [ o.name, o.id ] } %> <% options = question.survey_question_options.collect {|o| [ o.name, o.id ] } %>
<% if question.custom_option %> <% if question.custom_option %>
<% options.push [t('survey_question.use_custom_option'), 'custom_option'] %> <% options.push [t('survey_question.use_custom_option'), 'custom_option'] %>
<% end %> <% end %>
<%= f.select question.id, options %> <%= f.select question.id, options, {}, :class => 'o-question-group view-dropdown' %>
<% if question.custom_option %> <% if question.custom_option %>
<%= f.text_field "#{question.id}_custom_option", :class => 'custom_option' %> <%= f.text_field "#{question.id}_custom_option", :class => 'custom_option' %>
<% end %> <% end %>
@ -98,12 +100,18 @@
</div> </div>
<% end %> <% end %>
</div> </div>
</section>
</div>
<% content_for :page_stylesheets do %> <% content_for :page_stylesheets do %>
<link href='/assets/questionnaire.css' rel='stylesheet' type='text/css' /> <link href='/assets/questionnaire.css' rel='stylesheet' type='text/css' />
<% end %> <% end %>
<script type="text/javascript" src="/assets/jquery.form.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$('form.survey').ajaxForm({
beforeSubmit: function(a,f,o) {
o.dataType = 'script';
},
success: function(data) {
}
});
<% if @survey.jump_mode %> <% if @survey.jump_mode %>
var jump_tos_map = <%== @jump_tos_map.to_json %>; var jump_tos_map = <%== @jump_tos_map.to_json %>;
var $current_question = $('.question-item').eq(0); var $current_question = $('.question-item').eq(0);

View File

@ -36,6 +36,10 @@ en:
not_jump: Not Jump not_jump: Not Jump
jump_to_end: End of Survey jump_to_end: End of Survey
redirect: Redirect
redirect_mode: Redirect Mode
redirect_url: Redirect Url
must_answer: Must be Answered must_answer: Must be Answered
default_widget: default_widget:

View File

@ -37,6 +37,10 @@ zh_tw:
not_jump: 依據試卷列出所有問題數 not_jump: 依據試卷列出所有問題數
jump_to_end: 結束問題 jump_to_end: 結束問題
redirect: 問卷跳轉
redirect_mode: 設爲跳轉模式
redirect_url: 跳轉地址
must_answer: 必須回答這個問題 must_answer: 必須回答這個問題
default_widget: default_widget: