Module: SurveyorHelper
- Includes:
- SurveyorHelperExtensions
- Defined in:
- app/helpers/surveyor_helper.rb
Instance Method Summary collapse
-
#dependency_explanation_helper(question, response_set) ⇒ Object
Section: dependencies, menu, previous and next.
- #fields_for_radio(response, &block) ⇒ Object
-
#fields_for_response(response, response_group = nil, &block) ⇒ Object
Answers.
- #menu_button_for(section) ⇒ Object
-
#next_number ⇒ Object
Questions.
- #next_section ⇒ Object
- #previous_section ⇒ Object
- #question_help_helper(question) ⇒ Object
-
#split_text(text = "") ⇒ Object
Split text into with “|” delimiter - parts to go before/after input element.
-
#surveyor_config ⇒ Object
Configuration.
-
#surveyor_includes ⇒ Object
Layout: stylsheets and javascripts.
- #surveyor_javascripts ⇒ Object
- #surveyor_stylsheets ⇒ Object
Instance Method Details
#dependency_explanation_helper(question, response_set) ⇒ Object
Section: dependencies, menu, previous and next
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/surveyor_helper.rb', line 23 def dependency_explanation_helper(question,response_set) # Attempts to explain why this dependent question needs to be answered by referenced the dependent question and users response trigger_responses = [] dependent_questions = Question.find_all_by_id(question.dependency.dependency_conditions.map(&:question_id)).uniq response_set.responses.find_all_by_question_id(dependent_questions.map(&:id)).uniq.each do |resp| trigger_responses << resp.to_s end " You answered "#{trigger_responses.join("" and "")}" to the question "#{dependent_questions.map(&:text).join("","")}"" end |
#fields_for_radio(response, &block) ⇒ Object
63 64 65 |
# File 'app/helpers/surveyor_helper.rb', line 63 def fields_for_radio(response, &block) fields_for("responses[#{response.question_id}]", response, :builder => SurveyFormBuilder, &block) end |
#fields_for_response(response, response_group = nil, &block) ⇒ Object
Answers
59 60 61 62 |
# File 'app/helpers/surveyor_helper.rb', line 59 def fields_for_response(response, response_group = nil, &block) name = response_group.nil? ? "responses[#{response.question_id}][#{response.answer_id}]" : "response_groups[#{response.question_id}][#{response_group}][#{response.answer_id}]" fields_for(name, response, :builder => SurveyFormBuilder, &block) end |
#menu_button_for(section) ⇒ Object
32 33 34 |
# File 'app/helpers/surveyor_helper.rb', line 32 def (section) submit_tag(section.title, :name => "section[#{section.id}]") end |
#next_number ⇒ Object
Questions
47 48 49 50 |
# File 'app/helpers/surveyor_helper.rb', line 47 def next_number @n ||= 0 "#{@n += 1}<span style='padding-left:0.1em;'>)</span>" end |
#next_section ⇒ Object
40 41 42 43 44 |
# File 'app/helpers/surveyor_helper.rb', line 40 def next_section # @section.next.nil? ? submit_tag("Click here to finish", :name => "finish") : submit_tag("Next section »", :name => "section[#{@section.next.id}]") # refactored to use copy in memory instead of making extra db calls @sections.last == @section ? submit_tag("Click here to finish", :name => "finish") : submit_tag("Next section »", :name => "section[#{@sections[@sections.index(@section)+1].id}]") end |
#previous_section ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/surveyor_helper.rb', line 35 def previous_section # submit_tag("« Previous section", :name => "section[#{@section.previous.id}]") unless @section.previous.nil? # refactored to use copy in memory instead of making extra db calls submit_tag("« Previous section", :name => "section[#{@sections[@sections.index(@section)-1].id}]") unless @sections.first == @section end |
#question_help_helper(question) ⇒ Object
54 55 56 |
# File 'app/helpers/surveyor_helper.rb', line 54 def question_help_helper(question) question.help_text.blank? ? "" : %Q(<span class="question-help">#{question.help_text}</span>) end |
#split_text(text = "") ⇒ Object
Split text into with “|” delimiter - parts to go before/after input element
51 52 53 |
# File 'app/helpers/surveyor_helper.rb', line 51 def split_text(text = "") # Split text into with "|" delimiter - parts to go before/after input element {:prefix => text.split("|")[0].blank? ? " " : text.split("|")[0], :postfix => text.split("|")[1] || " "} end |
#surveyor_config ⇒ Object
Configuration
7 8 9 |
# File 'app/helpers/surveyor_helper.rb', line 7 def surveyor_config Surveyor::Config end |
#surveyor_includes ⇒ Object
Layout: stylsheets and javascripts
12 13 14 |
# File 'app/helpers/surveyor_helper.rb', line 12 def surveyor_includes surveyor_stylsheets + surveyor_javascripts end |
#surveyor_javascripts ⇒ Object
18 19 20 |
# File 'app/helpers/surveyor_helper.rb', line 18 def surveyor_javascripts javascript_include_tag 'surveyor/jquery-1.2.6.js', 'surveyor/jquery-ui-personalized-1.5.3.js', 'surveyor/accessibleUISlider.jQuery.js','surveyor/jquery.form.js', 'surveyor/surveyor.js' end |
#surveyor_stylsheets ⇒ Object
15 16 17 |
# File 'app/helpers/surveyor_helper.rb', line 15 def surveyor_stylsheets stylesheet_link_tag 'surveyor/reset', 'surveyor/surveyor', 'surveyor/ui.theme.css','surveyor/jquery-ui-slider-additions' end |