29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/models/missinglink/survey_respondent_detail.rb', line 29
def response_to_question(question)
return nil unless response = survey_responses.find_by_survey_question_id(question.id)
response_texts = []
case question.answer_strategy
when "first_survey_response_answer_text"
return response.survey_response_answers.first.text
when "answer_row_for_response"
response.survey_response_answers.each do |sra|
if sra.text.nil?
response_texts << SurveyAnswer.find(sra.row_survey_answer_id).text
else
response_texts << (SurveyAnswer.find(sra.row_survey_answer_id).text + ": " + sra.text)
end
end
when "answer_row_and_column_for_response"
response.survey_response_answers.each do |sra|
if sra.text.nil?
response_texts << (SurveyAnswer.find(sra.row_survey_answer_id).text + ": " + SurveyAnswer.find(sra.col_survey_answer_id).text)
else
response_texts << "Other: #{ sra.text }"
end
end
when "answer_row_column_choice_for_response"
response.survey_response_answers.each do |sra|
if sra.text.nil?
response_texts << (SurveyAnswer.find(sra.row_survey_answer_id).text + ", " +
SurveyAnswer.find(sra.col_survey_answer_id).text + ": " +
SurveyAnswer.find(sra.col_choice_survey_answer_id).text)
else
response_texts << "Other: #{ sra.text }"
end
end
end
return response_texts.join("; ")
end
|