diff --git a/CHANGELOG.md b/CHANGELOG.md index ff826339..f22b629f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/views/surveyor/show.html.haml b/app/views/surveyor/show.html.haml index 3b4dbd0b..c7c8264f 100644 --- a/app/views/surveyor/show.html.haml +++ b/app/views/surveyor/show.html.haml @@ -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 @@ -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 @@ -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) diff --git a/features/show_survey.feature b/features/show_survey.feature index 32fdd8a4..f4d39dd9 100644 --- a/features/show_survey.feature +++ b/features/show_survey.feature @@ -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