Skip to content

Commit

Permalink
Pull new render methods into show action:
Browse files Browse the repository at this point in the history
- Group text translations (NUBIC#420)
- Answer help text (NUBIC#373)
- Show labels
Closes NUBIC#438, closes NUBIC#442. Thanks @alanjcfs.
  • Loading branch information
Mark Yoon committed Apr 19, 2013
1 parent a9b68f6 commit 9978a7c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ History for Surveyor
- Remove default order on Response. (#423)
- Bug fix for RedCap Parser for DependencyConditions. thanks @ariel-perez-birchbox
- Make Surveyor::Parser accept Answer#reference_identifier via underscore or hash syntax (#439)
- Fix show action and have it use new translation view methods (#438, #442) thanks @alanjcfs

### Dependencies

Expand Down
25 changes: 11 additions & 14 deletions app/views/surveyor/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- unless label.blank?
= render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
- label = nil
= f.inputs q_text(g), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
= f.inputs g.text_for(@render_context, I18n.locale), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
%li.help= g.help_text
- case renderer
- when :grid
Expand All @@ -41,17 +41,18 @@
%tr
%th  
- ten_questions.first.answers.each do |a|
%th= a_text(a)
%th
= a.text_for(nil, @render_context, I18n.locale)
%span.help= a.help_text_for(@render_context, I18n.locale)
%th  
- ten_questions.each_with_index do |q, j|
%tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
- if q.pick == "one"
- r = response_for(@response_set, q, nil, g)
- j = response_idx # increment the response index since the answer partial skips for q.pick == one
%th= q.split(q.text, :pre)
%th
= q.text_for(:pre, @render_context, I18n.locale)
= q.help_text_for(@render_context, I18n.locale)
- q.answers.each do |a|
%td= render a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true
%th= q.split(q.text, :post)
%td= render(a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true) unless q.display_type == "label"
%th= q.text_for(:post, @render_context, I18n.locale)
- when :repeater
- (@response_set.count_group_responses(group_questions) + 1).times do |rg|
%li
Expand All @@ -60,16 +61,12 @@
- else # :inline
- answered_questions.each do |q|
= render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f, :disableFlag => true

- group_questions = []
- answered_questions = []
- else
- if q.display_type == 'label'
- label = q
- unless @response_set.responses.where( :question_id => q.id).empty?
- unless label.blank?
= render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
- label = nil
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
- elsif !(@response_set.responses.where(:question_id => q.id).empty?)
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
- answered_count = answered_count + 1
- if (i+1 >= questions.size) and (answered_count == 0)
Expand Down
29 changes: 29 additions & 0 deletions features/show_survey.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ Feature: showing a survey
| orange |
| brown |
When I go to the last response set show page
Then I should see "You with the sad eyes don't be discouraged"
Then the "blue" radiobutton should be checked
And the "orange" checkbox should be checked
And the "brown" checkbox should be checked

Scenario: Take a survey with group questions, then look at it
Given I parse
"""
survey "Grid question test", :default_mandatory => false do
section 'Communication Skills' do
grid 'Identify communication and interviewing skills' do
a 'Yes'
a 'No'
q 'Able to articulate job duties and skills', :pick => :one
end
q 'Communication Skills Comments'
a :text
end
end
"""
When I start the "Grid question test" survey
Then I should see "Identify communication and interviewing skills"
And I choose "Yes"
And I press "Click here to finish"
Then there should be 1 response set with 1 responses with:
| answer |
| Yes |
When I go to the last response set show page
Then I should see "Identify communication and interviewing skills"
Then the "Yes" radiobutton should be checked

0 comments on commit 9978a7c

Please sign in to comment.