Merge branch 'lukas/picked_ques' into development

This commit is contained in:
iCross 2013-06-07 18:48:06 +08:00
commit 57e1ef7bae
8 changed files with 38 additions and 1 deletions

View File

@ -17,6 +17,8 @@ class SurveyQuestion
# allow custom answer option
field :custom_option, :type => Boolean
field :sequence, :type => Integer, :default => 0
belongs_to :survey
embeds_many :survey_question_options
embeds_many :survey_question_radiogroups
@ -24,6 +26,8 @@ class SurveyQuestion
accepts_nested_attributes_for :survey_question_options, :allow_destroy => true
accepts_nested_attributes_for :survey_question_radiogroups, :allow_destroy => true
default_scope asc(:sequence)
def jumpable?
case type
when SurveyQuestion::Radio, SurveyQuestion::Select

View File

@ -103,7 +103,31 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "survey_form" %>
<script>
var refresh_sequence_input = function() {
var sequence = 0;
$('.sequence input').each(function(){
sequence += 1;
$(this).val(sequence);
});
}
$(document).ready(function() {
$('.sequence .move-up').bind('click', function(){
$survey_question_item = $(this).parents('.survey_question_item')
$prev = $survey_question_item.prev();
$survey_question_item.insertBefore($prev);
refresh_sequence_input();
return false;
});
$('.sequence .move-down').bind('click', function(){
$survey_question_item = $(this).parents('.survey_question_item')
$next = $survey_question_item.next();
$survey_question_item.insertAfter($next);
refresh_sequence_input();
return false;
});
refresh_sequence_input();
$('#add_survey_question a.add').live('click', function(){
var new_id = $(this).prev().attr('value');

View File

@ -0,0 +1 @@
alert("<%= @survey_answer_error %>");

View File

@ -0,0 +1,2 @@
alert("<%= t('survey.answer_success')%>");
window.location.href = "<%= root_path %>";

View File

@ -0,0 +1 @@
<%= render 'answer_error' %>

View File

@ -0,0 +1 @@
<%= render 'answer_success' %>

View File

@ -53,6 +53,7 @@ en:
survey_question:
title: Question
description: Description
sequence: Sequence
type: Type
is_required: Is Required
required: Required
@ -74,3 +75,5 @@ en:
move_up: Move up
move_down: Move down

View File

@ -55,6 +55,7 @@ zh_tw:
survey_question:
title: 題目
description: 說明
sequence: 順序
type: 作答方式
is_required: 設為必填
required: 必填