missinglink 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/missinglink/survey_answer.rb +6 -0
- data/app/models/missinglink/survey_question.rb +62 -0
- data/lib/missinglink/version.rb +1 -1
- data/lib/missinglink.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e4831b34c8d0eda8eb16a551b660387e36a6a46
|
4
|
+
data.tar.gz: fcc9a4b5fd84fd88979877abe8c7f3abe265e836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48717c4b4be1426742ce7e6b18ba29c576ea5cecc19d97fcdfdeb5ee8dd58dcf1c04cfffd79edb5221dd81eec9df97b4bd93c7b7cb33c3b2ed09b5ca44b0ace2
|
7
|
+
data.tar.gz: 461808ece66053ba3d1d614d3c435e3354da7ac3e1bcd3919098409483c99cb8dd53072e109ef598277e267c9bdffb64e3fec7b390380e82ae6e96eadc1810f4
|
@@ -6,6 +6,7 @@ module Missinglink
|
|
6
6
|
has_many :survey_pages, through: :survey_page_questions
|
7
7
|
has_many :survey_answers
|
8
8
|
has_many :survey_responses
|
9
|
+
has_many :survey_response_answers, through: :survey_responses
|
9
10
|
|
10
11
|
def self.parse(page, hash)
|
11
12
|
question = SurveyQuestion.first_or_create_by_sm_id(hash['question_id'])
|
@@ -31,5 +32,66 @@ module Missinglink
|
|
31
32
|
return SurveyQuestion.create(sm_question_id: sm_id)
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
# for reference, when searching, listing all possible responses is
|
37
|
+
# logical, but it is impossible to track all survey response answers
|
38
|
+
# that match the desired answer. therefore, we only track one
|
39
|
+
# example, and later find all similar response answers based on the
|
40
|
+
# question strategy
|
41
|
+
def possible_responses(search_other = false)
|
42
|
+
{}.tap do |hash|
|
43
|
+
survey_response_answers.each do |sra|
|
44
|
+
sa_row = (sra.row_survey_answer_id ? SurveyAnswer.find(sra.row_survey_answer_id) : nil)
|
45
|
+
sa_col = (sra.col_survey_answer_id ? SurveyAnswer.find(sra.col_survey_answer_id) : nil)
|
46
|
+
sa_col_choice = (sra.col_choice_survey_answer_id ? SurveyAnswer.find(sra.col_choice_survey_answer_id) : nil)
|
47
|
+
other_text = ((!search_other || sra.text.nil?) ? nil : "Other: #{ sra.text }")
|
48
|
+
|
49
|
+
case answer_strategy
|
50
|
+
when "first_survey_response_answer_text"
|
51
|
+
hash[sra.text] = sra.id unless (sra.text.nil? || hash[sra.text])
|
52
|
+
when "answer_row_match_for_survey_response_answer_text"
|
53
|
+
hash[sa_row.text] = sra.id unless (sa_row.nil? || hash[sa_row.text])
|
54
|
+
hash[other_text] = sra.id unless (other_text.nil? || hash[other_text])
|
55
|
+
when "row_column_survey_response_answers_and_text"
|
56
|
+
main_text = "#{ sa_row.try(:text) }: #{ sa_col.try(:text) }"
|
57
|
+
hash[main_text] = sra.id unless (sa_row.nil? || sa_col.nil? || hash[main_text])
|
58
|
+
hash[other_text] = sra.id unless (other_text.nil? || hash[other_text])
|
59
|
+
when "row_column_and_choice_survey_response_answers_and_text"
|
60
|
+
main_text = "#{ sa_row.try(:text) }, #{ sa_col.try(:text) }: #{ sa_col_choice.try(:text) }"
|
61
|
+
hash[main_text] = sra.id unless (sa_row.nil? || sa_col.nil? || sa_col_choice.nil? || hash[main_text])
|
62
|
+
hash[other_text] = sra.id unless (other_text.nil? || hash[other_text])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def similar_response_answers(response_answer, search_other = false)
|
69
|
+
if search_other || answer_strategy == "first_survey_response_answer_text"
|
70
|
+
return survey_response_answers.select { |sra| sra.text == response_answer.text }.sort
|
71
|
+
end
|
72
|
+
|
73
|
+
case answer_strategy
|
74
|
+
when "answer_row_match_for_survey_response_answer_text"
|
75
|
+
survey_response_answers.select do |sra|
|
76
|
+
sra.row_survey_answer_id == response_answer.row_survey_answer_id
|
77
|
+
end.sort
|
78
|
+
when "row_column_survey_response_answers_and_text"
|
79
|
+
survey_response_answers.select do |sra|
|
80
|
+
sra.row_survey_answer_id == response_answer.row_survey_answer_id &&
|
81
|
+
sra.col_survey_answer_id == response_answer.col_survey_answer_id
|
82
|
+
end.sort
|
83
|
+
when "row_column_and_choice_survey_response_answers_and_text"
|
84
|
+
survey_response_answers.select do |sra|
|
85
|
+
sra.row_survey_answer_id == response_answer.row_survey_answer_id &&
|
86
|
+
sra.col_survey_answer_id == response_answer.col_survey_answer_id &&
|
87
|
+
sra.col_choice_survey_answer_id == response_answer.col_choice_survey_answer_id
|
88
|
+
end.sort
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
def answer_strategy
|
94
|
+
Missinglink.answer_strategies[type_family][type_subtype]
|
95
|
+
end
|
34
96
|
end
|
35
97
|
end
|
data/lib/missinglink/version.rb
CHANGED
data/lib/missinglink.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: missinglink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Springer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|