lib/survey_html_formatter.rb
#
# For a given survey produce an HTML version of the questions and answers
#
For a given survey produce an HTML version of the questions and answers
For a given survey produce an HTML version of the questions and answers
def survey_to_html(survey, respondent_detail, forEmail = true)
    if survey
      content = '<div class="survey_responses"><h1>' + survey.name + '</h1>'
      content += "\n" if forEmail
      responses = respondent_detail.getResponses(survey.id)
      if respondent_detail.survey_respondent
        person = respondent_detail.survey_respondent.person
        if person
          fname = person.getFullPublicationName()
          content += '<h3 class="response_group_header">Publication Name:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + fname + '</div></div></div>'
          content += "\n" if forEmail
        end
      else
        fname = respondent_detail.getFullName()
        if ! fname.blank?
          content += '<h3 class="response_group_header">Name:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + fname + '</div></div></div>'
          content += "\n" if forEmail
        end
        if ! respondent_detail.email.blank?
          content += '<h3 class="response_group_header">Email:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + respondent_detail.email + '</div></div></div>'
          content += "\n" if forEmail
        end
      end
      survey.survey_groups.each do |group|
        content += group_to_html(group, respondent_detail, forEmail, responses)
      end
      content += '</div>'
      content += "\n" if forEmail
    else
      content = '<div>No Survey Found</div>'
    end
    return content
  end
def survey_to_html ( survey , respondent_detail , forEmail = true ) if survey content = '<div class="survey_responses"><h1>' + survey . name + '</h1>' content += "\n" if forEmail responses = respondent_detail . getResponses ( survey . id ) if respondent_detail . survey_respondent person = respondent_detail . survey_respondent . person if person fname = person . getFullPublicationName ( ) content += '<h3 class="response_group_header">Publication Name:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + fname + '</div></div></div>' content += "\n" if forEmail end else fname = respondent_detail . getFullName ( ) if ! fname . blank? content += '<h3 class="response_group_header">Name:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + fname + '</div></div></div>' content += "\n" if forEmail end if ! respondent_detail . email . blank? content += '<h3 class="response_group_header">Email:</h3><div class="response_group_body"><div class="response_answer"><div class="response_text">' + respondent_detail . email + '</div></div></div>' content += "\n" if forEmail end end survey . survey_groups . each do | group | content += group_to_html ( group , respondent_detail , forEmail , responses ) end content += '</div>' content += "\n" if forEmail else content = '<div>No Survey Found</div>' end return content end
For a given survey produce an HTML version of the questions and answers
For a given survey produce an HTML version of the questions and answers
survey
<not_specific>
respondent_detail
<not_specific>
forEmail
<not_specific>