surveyor 0.18.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/CHANGELOG +12 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/app/helpers/surveyor_helper.rb +40 -22
- data/app/views/layouts/surveyor_default.html.erb +0 -1
- data/app/views/partials/_answer.html.haml +19 -58
- data/app/views/partials/_dependents.html.haml +5 -0
- data/app/views/partials/_question.html.haml +24 -72
- data/app/views/partials/_question_group.html.haml +30 -39
- data/app/views/partials/_section.html.haml +10 -11
- data/app/views/partials/_section_menu.html.haml +5 -0
- data/app/views/surveyor/edit.html.haml +13 -25
- data/app/views/surveyor/new.html.haml +6 -3
- data/features/{redcap.feature → redcap_parser.feature} +0 -0
- data/features/step_definitions/parser_steps.rb +71 -0
- data/features/step_definitions/surveyor_steps.rb +8 -78
- data/features/support/paths.rb +2 -0
- data/features/surveyor.feature +30 -168
- data/features/surveyor_parser.feature +157 -0
- data/generators/surveyor/surveyor_generator.rb +2 -1
- data/generators/surveyor/templates/assets/images/next.gif +0 -0
- data/generators/surveyor/templates/assets/images/prev.gif +0 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.surveyor.js +46 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.tools.min.js +204 -0
- data/generators/surveyor/templates/assets/stylesheets/dateinput.css +149 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +84 -226
- data/generators/surveyor/templates/migrate/add_default_value_to_answers.rb +9 -0
- data/lib/formtastic/surveyor_builder.rb +83 -0
- data/lib/surveyor.rb +5 -0
- data/lib/surveyor/models/answer_methods.rb +8 -3
- data/lib/surveyor/models/question_group_methods.rb +1 -1
- data/lib/surveyor/models/question_methods.rb +6 -2
- data/lib/surveyor/models/response_methods.rb +2 -12
- data/lib/surveyor/models/response_set_methods.rb +25 -71
- data/lib/surveyor/surveyor_controller_methods.rb +29 -28
- data/lib/tasks/surveyor_tasks.rake +1 -15
- data/spec/controllers/surveyor_controller_spec.rb +40 -8
- data/spec/helpers/surveyor_helper_spec.rb +53 -0
- data/spec/models/answer_spec.rb +14 -9
- data/spec/models/dependency_condition_spec.rb +56 -61
- data/spec/models/question_group_spec.rb +3 -3
- data/spec/models/question_spec.rb +10 -0
- data/spec/models/response_set_spec.rb +72 -62
- data/surveyor.gemspec +21 -58
- data/testbed/Gemfile +1 -0
- metadata +34 -60
- data/app/helpers/survey_form_builder.rb +0 -37
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +0 -201
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +0 -3549
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +0 -7616
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +0 -637
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +0 -40
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +0 -71
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +0 -851
- data/spec/views/surveyor/show.html.haml_spec.rb +0 -32
- data/uninstall.rb +0 -1
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
0.19.0
|
|
2
|
+
|
|
3
|
+
* reload to correctly calculate dependencies
|
|
4
|
+
* date picker. closes #58
|
|
5
|
+
* hide section menu for fewer than three sections
|
|
6
|
+
* cleaning up features from merge
|
|
7
|
+
* correcing spec to reject blank radio responses. fixing response set spec
|
|
8
|
+
* modifications for repeaters and response groups
|
|
9
|
+
* merge formtastic
|
|
10
|
+
* default value for pick none answers. closes #103.
|
|
11
|
+
* view changes and updates.
|
|
12
|
+
|
|
1
13
|
0.18.2
|
|
2
14
|
|
|
3
15
|
* redcap text and string answers. closes #99
|
data/Rakefile
CHANGED
|
@@ -11,6 +11,7 @@ begin
|
|
|
11
11
|
gem.authors = ["Brian Chamberlain", "Mark Yoon"]
|
|
12
12
|
gem.add_dependency 'haml'
|
|
13
13
|
gem.add_dependency 'fastercsv'
|
|
14
|
+
gem.add_dependency 'formtastic'
|
|
14
15
|
gem.add_development_dependency "yard", ">= 0"
|
|
15
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
|
16
17
|
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.19.0
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
module SurveyorHelper
|
|
2
|
-
|
|
3
2
|
# Layout: stylsheets and javascripts
|
|
4
3
|
def surveyor_includes
|
|
5
4
|
surveyor_stylsheets + surveyor_javascripts
|
|
6
5
|
end
|
|
7
6
|
def surveyor_stylsheets
|
|
8
|
-
stylesheet_link_tag 'surveyor/reset', 'surveyor', 'surveyor
|
|
7
|
+
stylesheet_link_tag 'surveyor/reset', 'surveyor/dateinput', 'surveyor'
|
|
9
8
|
end
|
|
10
9
|
def surveyor_javascripts
|
|
11
|
-
javascript_include_tag 'surveyor/jquery
|
|
10
|
+
javascript_include_tag 'surveyor/jquery.tools.min', 'surveyor/jquery.surveyor'
|
|
11
|
+
end
|
|
12
|
+
# Helper for displaying warning/notice/error flash messages
|
|
13
|
+
def flash_messages(types)
|
|
14
|
+
types.map{|type| content_tag(:div, "#{flash[type]}".html_safe, :class => type.to_s)}.join.html_safe
|
|
12
15
|
end
|
|
13
|
-
|
|
14
16
|
# Section: dependencies, menu, previous and next
|
|
15
17
|
def dependency_explanation_helper(question,response_set)
|
|
16
18
|
# Attempts to explain why this dependent question needs to be answered by referenced the dependent question and users response
|
|
@@ -25,35 +27,51 @@ module SurveyorHelper
|
|
|
25
27
|
submit_tag(section.title, :name => "section[#{section.id}]")
|
|
26
28
|
end
|
|
27
29
|
def previous_section
|
|
28
|
-
#
|
|
29
|
-
# refactored to use copy in memory instead of making extra db calls
|
|
30
|
+
# use copy in memory instead of making extra db calls
|
|
30
31
|
submit_tag(t('surveyor.previous_section'), :name => "section[#{@sections[@sections.index(@section)-1].id}]") unless @sections.first == @section
|
|
31
32
|
end
|
|
32
33
|
def next_section
|
|
33
|
-
#
|
|
34
|
-
# refactored to use copy in memory instead of making extra db calls
|
|
34
|
+
# use copy in memory instead of making extra db calls
|
|
35
35
|
@sections.last == @section ? submit_tag(t('surveyor.click_here_to_finish'), :name => "finish") : submit_tag(t('surveyor.next_section'), :name => "section[#{@sections[@sections.index(@section)+1].id}]")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# Questions
|
|
39
|
-
def
|
|
39
|
+
def q_text(obj)
|
|
40
40
|
@n ||= 0
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{:prefix => text.split("|")[0].blank? ? " " : text.split("|")[0], :postfix => text.split("|")[1] || " "}
|
|
45
|
-
end
|
|
46
|
-
def question_help_helper(question)
|
|
47
|
-
question.help_text.blank? ? "" : %Q(<span class="question-help">#{question.help_text}</span>)
|
|
41
|
+
return image_tag(obj.text) if obj.is_a?(Question) and obj.display_type == "image"
|
|
42
|
+
return obj.text if obj.is_a?(Question) and (obj.dependent? or obj.display_type == "label" or obj.part_of_group?)
|
|
43
|
+
"#{@n += 1}) #{obj.text}"
|
|
48
44
|
end
|
|
49
|
-
|
|
45
|
+
# def split_text(text = "") # Split text into with "|" delimiter - parts to go before/after input element
|
|
46
|
+
# {:prefix => text.split("|")[0].blank? ? " " : text.split("|")[0], :postfix => text.split("|")[1] || " "}
|
|
47
|
+
# end
|
|
48
|
+
# def question_help_helper(question)
|
|
49
|
+
# question.help_text.blank? ? "" : %Q(<span class="question-help">#{question.help_text}</span>)
|
|
50
|
+
# end
|
|
51
|
+
|
|
50
52
|
# Answers
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
def rc_to_attr(type_sym)
|
|
54
|
+
case type_sym.to_s
|
|
55
|
+
when /^date|time$/ then :datetime_value
|
|
56
|
+
when /(string|text|integer|float|datetime)/ then "#{type_sym.to_s}_value".to_sym
|
|
57
|
+
else :answer_id
|
|
58
|
+
end
|
|
54
59
|
end
|
|
55
|
-
def
|
|
56
|
-
|
|
60
|
+
def rc_to_as(type_sym)
|
|
61
|
+
case type_sym.to_s
|
|
62
|
+
when /(integer|float)/ then :string
|
|
63
|
+
else type_sym
|
|
64
|
+
end
|
|
57
65
|
end
|
|
58
66
|
|
|
67
|
+
# Responses
|
|
68
|
+
def response_for(response_set, question, answer = nil, response_group = nil)
|
|
69
|
+
return nil unless response_set && question && question.id
|
|
70
|
+
result = response_set.responses.detect{|r| (r.question_id == question.id) && (answer.blank? ? true : r.answer_id == answer.id) && (r.response_group.blank? ? true : r.response_group.to_i == response_group.to_i)}
|
|
71
|
+
result.blank? ? response_set.responses.build(:question_id => question.id, :response_group => response_group) : result
|
|
72
|
+
end
|
|
73
|
+
def response_idx(increment = true)
|
|
74
|
+
@rc ||= 0
|
|
75
|
+
(increment ? @rc += 1 : @rc).to_s
|
|
76
|
+
end
|
|
59
77
|
end
|
|
@@ -1,58 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- when
|
|
11
|
-
=
|
|
12
|
-
|
|
13
|
-
=
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- fields_for_radio(response_obj) do |radio_form|
|
|
21
|
-
= radio_form.radio_button(:answer_id, answer.id, :checked => response_obj.selected?, :title => answer.text)
|
|
22
|
-
= radio_form.label("answer_id_#{answer.id}", split_text(answer.text)[:prefix]) unless hide_label
|
|
23
|
-
- if renderer == :one_string
|
|
24
|
-
= response_form.text_field(:string_value, :size => 25, :maxlength => 250, :autocomplete => "off")
|
|
25
|
-
- if renderer == :one_integer
|
|
26
|
-
= response_form.text_field(:integer_value, :size => 5, :maxlength => 10, :autocomplete => "off")
|
|
27
|
-
= radio_form.label("answer_id_#{answer.id}", split_text(answer.text)[:postfix]) unless hide_label
|
|
28
|
-
- when :none_date
|
|
29
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:prefix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
30
|
-
= response_form.text_field(:datetime_value)
|
|
31
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:postfix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
32
|
-
- when :none_datetime
|
|
33
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:prefix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
34
|
-
= response_form.datetime_select(:datetime_value, {:include_blank => true})
|
|
35
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:postfix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
36
|
-
- when :none_float
|
|
37
|
-
= response_form.label(:float_value, split_text(answer.text)[:prefix]) unless hide_label
|
|
38
|
-
= response_form.text_field(:float_value, :size => 5, :maxlength => 10, :autocomplete => "off")
|
|
39
|
-
= response_form.label(:float_value, split_text(answer.text)[:postfix]) unless hide_label
|
|
40
|
-
- when :none_integer
|
|
41
|
-
= response_form.label(:integer_value, split_text(answer.text)[:prefix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
42
|
-
= response_form.text_field(:integer_value, :size => 5, :maxlength => 10, :autocomplete => "off", :disabled => disabled)
|
|
43
|
-
= response_form.label(:integer_value, split_text(answer.text)[:postfix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
44
|
-
- when :none_string
|
|
45
|
-
= response_form.label(:string_value, split_text(answer.text)[:prefix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
46
|
-
= response_form.text_field(:string_value, :size => 25, :maxlength => 250, :autocomplete => "off", :disabled => disabled)
|
|
47
|
-
= response_form.label(:string_value, split_text(answer.text)[:postfix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
48
|
-
- when :none_text
|
|
49
|
-
= response_form.label(:text_value, split_text(answer.text)[:prefix]) unless hide_label
|
|
50
|
-
= response_form.text_area(:text_value, :cols => 80, :rows => 10)
|
|
51
|
-
= response_form.label(:text_value, split_text(answer.text)[:postfix]) unless hide_label
|
|
52
|
-
- when :none_time
|
|
53
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:prefix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
54
|
-
= response_form.time_select(:datetime_value,{ :include_blank => true })
|
|
55
|
-
= response_form.label(:datetime_value, split_text(answer.text)[:postfix], :class => "#{(disabled)? 'disabled' : 'enabled'}") unless hide_label
|
|
56
|
-
- else
|
|
57
|
-
= answer.text
|
|
58
|
-
|
|
1
|
+
-# TODO: disabled
|
|
2
|
+
- rg ||= nil
|
|
3
|
+
- r = response_for(@response_set, q, a, rg)
|
|
4
|
+
- i = response_idx(q.pick != "one") # argument will be false (don't increment i) if we're on radio buttons
|
|
5
|
+
- f.semantic_fields_for i, r do |ff|
|
|
6
|
+
= ff.quiet_input :question_id unless q.pick == "one" # don't repeat question_id if we're on radio buttons
|
|
7
|
+
= ff.quiet_input :id unless q.pick == "one" or r.new_record?
|
|
8
|
+
= ff.quiet_input :response_group, :value => rg if q.pick != "one" && g && g.display_type == "repeater"
|
|
9
|
+
- case q.pick
|
|
10
|
+
- when "one"
|
|
11
|
+
= ff.input :answer_id, :as => :surveyor_radio, :collection => [[a.text, a.id]], :label => false, :input_html => {:class => a.css_class}, :response_class => a.response_class
|
|
12
|
+
- when "any"
|
|
13
|
+
= ff.input :answer_id, :as => :surveyor_check_boxes, :collection => [[a.text, a.id]], :label => false, :input_html => {:class => a.css_class}, :response_class => a.response_class
|
|
14
|
+
- when "none"
|
|
15
|
+
- if %w(date datetime time float integer string text).include? a.response_class
|
|
16
|
+
= ff.quiet_input :answer_id, :input_html => {:class => a.css_class, :value => a.id}
|
|
17
|
+
= ff.input rc_to_attr(a.response_class), :as => rc_to_as(a.response_class), :label => a.split_or_hidden_text(:pre).blank? ? false : a.split_or_hidden_text(:pre), :hint => a.split_or_hidden_text(:post), :input_html => {:value => a.default_value}
|
|
18
|
+
- else
|
|
19
|
+
= a.text
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#dependents
|
|
2
|
+
.title Follow-up questions from your answers on the previous page
|
|
3
|
+
-# @dependents.each_with_index do |question, index|
|
|
4
|
+
= dependency_explanation_helper(question, @response_set)
|
|
5
|
+
= render question.custom_renderer || "/partials/question", :question => question, :response_set => @response_set, :number => "D#{index+1}"
|
|
@@ -1,72 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
3
|
-
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- when :image
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
- content_tag_for :tr, question, :class => question.css_class(response_set) do
|
|
26
|
-
%th.question_prefix
|
|
27
|
-
%span.text= split_text(question.text)[:prefix]
|
|
28
|
-
%span.help= question.help_text
|
|
29
|
-
= hidden_field_tag("responses[#{question.id}][question_id]", question.id)
|
|
30
|
-
- question.answers.each do |answer|
|
|
31
|
-
%td{:class => "#{cycle("column_highlight", "", :name => "col")}"}
|
|
32
|
-
.answer{:class => answer.custom_class}= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => true})
|
|
33
|
-
%th.question_postfix
|
|
34
|
-
%span.text= split_text(question.text)[:postfix]
|
|
35
|
-
- when :repeater_default, :repeater_dropdown
|
|
36
|
-
- disabled ||= false
|
|
37
|
-
- div_for question, :class => "#{disabled ? 'dis' : 'en'}abled #{question.css_class(response_set)}" do
|
|
38
|
-
%span.text= question.text
|
|
39
|
-
%span.help= question.help_text
|
|
40
|
-
= hidden_field_tag("response_groups[#{question.id}][#{response_group}][response_group]", response_group)
|
|
41
|
-
= hidden_field_tag("response_groups[#{question.id}][#{response_group}][question_id]", question.id)
|
|
42
|
-
%br
|
|
43
|
-
%ol.answers
|
|
44
|
-
- if renderer == :repeater_default
|
|
45
|
-
- question.answers.each do |answer|
|
|
46
|
-
- content_tag_for :li, answer, :class => answer.custom_class do
|
|
47
|
-
= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id, response_group), :response_group => response_group, :hide_label => true, :disabled => disabled})
|
|
48
|
-
- else
|
|
49
|
-
%li.answer
|
|
50
|
-
- options = question.answers.collect{|a| "<option #{ (response_set.response_for(question.id, a.id, response_group).selected?)? "selected='selected'" : nil } value ='#{a.id}'>#{a.text}</option>" }
|
|
51
|
-
= select_tag("response_groups[#{question.id}][#{response_group}][answer_id]", ["<option value=''>Select one...</option>"].concat(options), :disabled => disabled)
|
|
52
|
-
- when :inline_default, :inline_dropdown
|
|
53
|
-
- div_for question, :class => "inline #{question.css_class(response_set)}" do
|
|
54
|
-
= hidden_field_tag("responses[#{question.id}][question_id]", question.id)
|
|
55
|
-
- if renderer == :inline_default
|
|
56
|
-
- question.answers.each do |answer|
|
|
57
|
-
.answer{:class => answer.custom_class}= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => answer.hide_label})
|
|
58
|
-
- else
|
|
59
|
-
- options = question.answers.collect{|a| "<option #{ (response_set.response_for(question.id, a.id).selected?)? "selected='selected'" : nil } value ='#{a.id}'>#{a.text}</option>" }
|
|
60
|
-
= select_tag("responses[#{question.id}][answer_id]", ["<option value=''>Select one...</option>"].concat(options))
|
|
61
|
-
- else # :default, :inline
|
|
62
|
-
- div_for question, :class => question.css_class(response_set) do
|
|
63
|
-
.number= next_number unless question.dependent?
|
|
64
|
-
%fieldset
|
|
65
|
-
%legend
|
|
66
|
-
%span.text= question.text
|
|
67
|
-
%span.help= question.help_text
|
|
68
|
-
= hidden_field_tag("responses[#{question.id}][question_id]", question.id)
|
|
69
|
-
%ol.answers{:class => renderer == :inline ? "inline" : nil}
|
|
70
|
-
- question.answers.each do |answer|
|
|
71
|
-
- content_tag_for :li, answer, :class => answer.custom_class do
|
|
72
|
-
= render(:partial => answer.custom_renderer || "/partials/answer", :locals => {:answer => answer, :question => question, :response_obj => @response_set.response_for(question.id, answer.id), :hide_label => answer.hide_label})
|
|
1
|
+
-# TODO: js for slider
|
|
2
|
+
- rg ||= nil
|
|
3
|
+
- renderer = q.renderer(g ||= nil)
|
|
4
|
+
- f.inputs q_text(q), :id => rg ? "q_#{q.id}_#{rg.id}" : "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}" do
|
|
5
|
+
%span.help= q.help_text
|
|
6
|
+
- case renderer
|
|
7
|
+
- when :image, :label
|
|
8
|
+
- when :dropdown, :inline_dropdown, :slider
|
|
9
|
+
- r = response_for(@response_set, q, nil, rg)
|
|
10
|
+
- i = response_idx
|
|
11
|
+
- f.semantic_fields_for i, r do |ff|
|
|
12
|
+
= ff.quiet_input :question_id
|
|
13
|
+
= ff.quiet_input :response_group, :value => rg if g && g.display_type == "repeater"
|
|
14
|
+
= ff.input :answer_id, :as => :select, :collection => q.answers.map{|a| [a.text, a.id]}, :label => false
|
|
15
|
+
- else # :default, :inline, :inline_default
|
|
16
|
+
- if q.pick == "one"
|
|
17
|
+
- r = response_for(@response_set, q, nil, rg)
|
|
18
|
+
- i = response_idx # increment the response index since the answer partial skips for q.pick == one
|
|
19
|
+
- f.semantic_fields_for i, r do |ff|
|
|
20
|
+
= ff.quiet_input :question_id
|
|
21
|
+
= ff.quiet_input :response_group, :value => rg if g && g.display_type == "repeater"
|
|
22
|
+
= ff.quiet_input :id unless r.new_record?
|
|
23
|
+
- q.answers.each do |a|
|
|
24
|
+
= render a.custom_renderer || '/partials/answer', :q => q, :a => a, :f => f, :rg => rg, :g => g
|
|
@@ -1,39 +1,30 @@
|
|
|
1
|
-
- renderer =
|
|
2
|
-
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
= render(:partial => question.custom_renderer || "/partials/question", :locals => locals.merge({:question => question, :response_group => group_number, :disabled => false}))
|
|
32
|
-
%li.repeater
|
|
33
|
-
- group_questions.each do |question|
|
|
34
|
-
= render(:partial => question.custom_renderer || "/partials/question", :locals => locals.merge({:question => question, :response_group => 9999, :disabled => true}))
|
|
35
|
-
= submit_tag("<= add row", :name => "section[#{group_questions.first.survey_section_id}]question_group_#{question_group.id}", :class => "add_row")
|
|
36
|
-
- else # :inline
|
|
37
|
-
%ul
|
|
38
|
-
- group_questions.each do |question|
|
|
39
|
-
%li{:class => question_group.renderer == :inline ? "inline" : nil}= render(:partial => question.custom_renderer || "/partials/question", :locals => locals.merge({:question => question}))
|
|
1
|
+
- renderer = g.renderer
|
|
2
|
+
- f.inputs q_text(g), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
|
|
3
|
+
%li.help= g.help_text
|
|
4
|
+
- case renderer
|
|
5
|
+
- when :grid
|
|
6
|
+
%li
|
|
7
|
+
%table
|
|
8
|
+
%tbody
|
|
9
|
+
- qs.each_slice(10) do |ten_questions| # header row every 10
|
|
10
|
+
%tr
|
|
11
|
+
%th
|
|
12
|
+
- ten_questions.first.answers.each do |a|
|
|
13
|
+
%th= a.text
|
|
14
|
+
%th
|
|
15
|
+
- ten_questions.each_with_index do |q, i|
|
|
16
|
+
%tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
|
|
17
|
+
%th= q.split_text(:pre)
|
|
18
|
+
- response_idx if q.pick == "one" # increment the response index since the answer partial skips for q.pick == one
|
|
19
|
+
- q.answers.each do |a|
|
|
20
|
+
%td= render a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f
|
|
21
|
+
%th= q.split_text(:post)
|
|
22
|
+
- when :repeater
|
|
23
|
+
- (@response_set.count_group_responses(qs) + 1).times do |rg|
|
|
24
|
+
%li
|
|
25
|
+
- qs.each do |q|
|
|
26
|
+
= render q.custom_renderer || "/partials/question", :g => g, :rg => rg, :q => q, :f => f
|
|
27
|
+
= submit_tag("+ add row", :name => "section[#{@section.id}][g_#{g.id}]", :class => "add_row")
|
|
28
|
+
- else # :inline
|
|
29
|
+
- qs.each do |q|
|
|
30
|
+
= render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
- div_for @section, :class => @section.custom_class do
|
|
2
2
|
%span.title= @section.title
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- group_questions = []
|
|
3
|
+
- qs ||= []
|
|
4
|
+
- (questions = @section.questions).each_with_index do |q, i|
|
|
5
|
+
- if q.part_of_group?
|
|
6
|
+
- qs << q # gather up the group questions
|
|
7
|
+
- if (i+1 >= questions.size) or (q.question_group_id != questions[i+1].question_group_id)
|
|
8
|
+
- # this is the last question of the section, or the group
|
|
9
|
+
= render q.question_group.custom_renderer || "/partials/question_group", :g => q.question_group, :qs => qs, :f => f
|
|
10
|
+
- qs = []
|
|
11
|
+
- else # gather up the group questions
|
|
12
|
+
= render q.custom_renderer || "/partials/question", :q => q, :f => f
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
#surveyor
|
|
2
|
-
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
%li{:class => ("active" if s == @section)}= menu_button_for(s)
|
|
10
|
-
#header
|
|
11
|
-
.title= @survey.title
|
|
2
|
+
- unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
|
|
3
|
+
.surveyor_flash
|
|
4
|
+
= flash_messages(types)
|
|
5
|
+
.close
|
|
6
|
+
- semantic_form_for(:r, @response_set, :url => update_my_survey_path, :html => {:method => :put, :id => "survey_form", :class => @survey.custom_class}) do |f|
|
|
7
|
+
= render 'partials/section_menu' unless @sections.size < 3
|
|
8
|
+
.survey_title= @survey.title
|
|
12
9
|
.previous_section= previous_section
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
= render(:partial => question.custom_renderer || "/partials/question", :locals => {:question => question, :response_set => @response_set, :number => "D#{index+1}"})
|
|
19
|
-
-# cache section if there are no responses for that section in th current response_set
|
|
20
|
-
- if @response_set.no_responses_for_section?(@section)
|
|
21
|
-
- cache("section_#{@section.id}") do
|
|
22
|
-
-# cache
|
|
23
|
-
= render(:partial => "/partials/section", :locals => {:section => @section, :questions => @questions, :response_set => @response_set})
|
|
24
|
-
- else
|
|
25
|
-
-# no cache
|
|
26
|
-
= render(:partial => "/partials/section", :locals => {:section => @section, :questions => @questions, :response_set => @response_set})
|
|
10
|
+
= render 'partials/dependents' unless @dependents.empty?
|
|
11
|
+
- if @response_set.no_responses_for_section?(@section) # cache if response_set has no responses for current section
|
|
12
|
+
= cache("section_#{@section.id}"){ render "/partials/section", :f => f }
|
|
13
|
+
- else # no cache
|
|
14
|
+
= render "/partials/section", :f => f
|
|
27
15
|
.next_section= next_section
|
|
28
|
-
|
|
16
|
+
%br
|