Module: SurveyorGui::SurveyformsHelper
- Defined in:
- app/helpers/surveyor_gui/surveyforms_helper.rb
Instance Method Summary collapse
- #list_dependencies(o) ⇒ Object
- #list_phrase(args) ⇒ Object
- #question_group_class(question) ⇒ Object
- #question_group_heading(f) ⇒ Object
- #render_one_group(qg) ⇒ Object
- #render_questions_and_groups_helper(q, ss) ⇒ Object
- #row_label_if_question_group(question) ⇒ Object
Instance Method Details
#list_dependencies(o) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 5 def list_dependencies(o) controlling_questions = o.controlling_questions controlling_question_ids = controlling_questions.map{|q| q.question_number.to_s+')'}.uniq count = controlling_question_ids.count retstr ='This question is shown depending on the ' retstr += 'answer'.pluralize(count) retstr += ' to ' retstr += 'question'.pluralize(count) + ' ' retstr + list_phrase(controlling_question_ids) end |
#list_phrase(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 17 def list_phrase(args) ## given a list of word parameters, return a syntactically correct phrase ## [dog] = "dog" ## [dog, cat] = "dog and cat" ## [dog, cat, bird] = "dog, cat and bird" case args.count when 0 '' when 1 args[0] when 2 args[0] + ' and ' + args[1] else last = args.count args.take(last - 2).join(', ') + ', ' + args[last - 2] + ' and ' + args[last - 1] end end |
#question_group_class(question) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 76 def question_group_class(question) if @current_group.question_group.display_type == "inline" "inline" elsif @current_group.question_group.display_type == "default" "default" else if question.question_type_id == :grid_dropdown "dropdown" else "grid" end end end |
#question_group_heading(f) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 59 def question_group_heading(f) if f.object.question_type_id == :grid_dropdown heading = f.object.question_group.columns elsif f.object.question_group.display_type == "grid" heading = f.object.answers else heading = [] end heading.map {|a| "<span class=\"question_group_heading #{f.object.question_type_id.to_s}\" >#{a.text}<\/span>"}.join().html_safe end |
#render_one_group(qg) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 49 def render_one_group(qg) qg.simple_fields_for :questions, @current_group.questions do |f| if f.object.is_comment != true render "question_group_fields", f: f elsif f.object.is_comment == true "</div>".html_safe+(render "question_field", f: f)+"<div>".html_safe end end end |
#render_questions_and_groups_helper(q, ss) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 35 def render_questions_and_groups_helper(q, ss) #this method will render either a question or a complete question group. #we always iterate through questions, and if we happen to notice a question #belongs to a group, we process the group at that time. #note that questions carry a question_group_id, and this is how we know #that a question is part of a group, and that it should not be rendered individually, #but as part of a group. if q.object.part_of_group? _render_initial_group(q, ss) || _respond_to_a_change_in_group_id(q, ss) else render "question_wrapper", f: q end end |
#row_label_if_question_group(question) ⇒ Object
70 71 72 73 74 |
# File 'app/helpers/surveyor_gui/surveyforms_helper.rb', line 70 def row_label_if_question_group(question) if question.part_of_group? "<span class=\"row_name\">#{question.text}: </span>".html_safe end end |