limesurvey_rails 1.5.0 → 1.6.0
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/limesurvey_rails/survey.rb +92 -4
- data/lib/limesurvey_rails/limesurvey_rails.rb +8 -18
- data/lib/limesurvey_rails/participant.rb +9 -3
- data/lib/limesurvey_rails/version.rb +1 -1
- data/spec/limesurvey_rails_spec.rb +11 -6
- data/spec/models/limesurvey_rails/participant_spec.rb +29 -6
- 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: d528206d39a75793bc0c4693dca10a77862ee58c
|
4
|
+
data.tar.gz: 7c17812488f1c73e7c0406a1e60e127d82d05a65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c305914e21e416f21b3cf9c5810a00cb5a3189985922dfb440122a20095cfecc82e496bf71007e261b66f152c9d2281321c0bc7e692dac7313bf0b8c214cff9
|
7
|
+
data.tar.gz: bce318fc0eb6210ab2ab44711c8a6e8edcf5556079a1253e18425ca28dd20559e91b5ef683d51e80d77a64282f5b1048b47b3bc5c101f35615a36572487755eb
|
@@ -7,9 +7,93 @@ module LimesurveyRails
|
|
7
7
|
GET_SUMMARY_RESPONSES_ATTRIBUTES = %w{ completed_responses incomplete_responses full_responses }
|
8
8
|
GET_SUMMARY_TOKENS_ATTRIBUTES = %w{ token_count token_invalid token_sent token_opted_out token_completed }
|
9
9
|
GET_SUMMARY_ATTRIBUTES = GET_SUMMARY_RESPONSES_ATTRIBUTES + GET_SUMMARY_TOKENS_ATTRIBUTES
|
10
|
-
GET_SURVEY_PROPERTY_ATTRIBUTES = %w{
|
11
|
-
|
12
|
-
|
10
|
+
GET_SURVEY_PROPERTY_ATTRIBUTES = %w{
|
11
|
+
attributedescriptions
|
12
|
+
savetimings
|
13
|
+
allowprev
|
14
|
+
tokenanswerspersistence
|
15
|
+
showgroupinfo
|
16
|
+
showwelcome
|
17
|
+
owner_id
|
18
|
+
template
|
19
|
+
printanswers
|
20
|
+
assessments
|
21
|
+
shownoanswer
|
22
|
+
showprogress
|
23
|
+
admin
|
24
|
+
language
|
25
|
+
ipaddr
|
26
|
+
usecaptcha
|
27
|
+
showqnumcode
|
28
|
+
allowjumps
|
29
|
+
active
|
30
|
+
additional_languages
|
31
|
+
refurl
|
32
|
+
usetokens
|
33
|
+
bouncetime
|
34
|
+
navigationdelay
|
35
|
+
expires
|
36
|
+
datestamp
|
37
|
+
datecreated
|
38
|
+
bounce_email
|
39
|
+
bounceprocessing
|
40
|
+
nokeyboard
|
41
|
+
startdate
|
42
|
+
usecookie
|
43
|
+
publicstatistics
|
44
|
+
bounceaccounttype
|
45
|
+
alloweditaftercompletion
|
46
|
+
adminemail
|
47
|
+
allowregister
|
48
|
+
publicgraphs
|
49
|
+
emailresponseto
|
50
|
+
bounceaccounthost
|
51
|
+
googleanalyticsstyle
|
52
|
+
anonymized
|
53
|
+
allowsave
|
54
|
+
listpublic
|
55
|
+
emailnotificationto
|
56
|
+
bounceaccountpass
|
57
|
+
googleanalyticsapikey
|
58
|
+
faxto
|
59
|
+
autonumber_start
|
60
|
+
htmlemail
|
61
|
+
tokenlength
|
62
|
+
bounceaccountencryption
|
63
|
+
format
|
64
|
+
autoredirect
|
65
|
+
sendconfirmation
|
66
|
+
showxquestions
|
67
|
+
bounceaccountuser
|
68
|
+
}
|
69
|
+
|
70
|
+
GET_LANGUAGE_PROPERTIES_ATTRIBUTES = %w{
|
71
|
+
surveyls_survey_id
|
72
|
+
surveyls_url
|
73
|
+
surveyls_email_register_subj
|
74
|
+
email_admin_notification_subj
|
75
|
+
surveyls_language
|
76
|
+
surveyls_urldescription
|
77
|
+
surveyls_email_register
|
78
|
+
email_admin_notification
|
79
|
+
surveyls_title
|
80
|
+
surveyls_email_invite_subj
|
81
|
+
surveyls_email_confirm_subj
|
82
|
+
email_admin_responses_subj
|
83
|
+
surveyls_description
|
84
|
+
surveyls_email_invite
|
85
|
+
surveyls_email_confirm
|
86
|
+
email_admin_responses
|
87
|
+
surveyls_welcometext
|
88
|
+
surveyls_email_remind_subj
|
89
|
+
surveyls_dateformat
|
90
|
+
surveyls_numberformat
|
91
|
+
surveyls_endtext
|
92
|
+
surveyls_email_remind
|
93
|
+
surveyls_attributecaptions
|
94
|
+
}
|
95
|
+
|
96
|
+
|
13
97
|
ALL_ATTRIBUTES = (GET_SUMMARY_ATTRIBUTES | GET_SURVEY_PROPERTY_ATTRIBUTES | GET_LANGUAGE_PROPERTIES_ATTRIBUTES ).sort.unshift('id')
|
14
98
|
|
15
99
|
attr_accessor *ALL_ATTRIBUTES
|
@@ -21,7 +105,11 @@ module LimesurveyRails
|
|
21
105
|
validates_presence_of :language
|
22
106
|
|
23
107
|
def self.all(lang = nil)
|
24
|
-
|
108
|
+
all_ids.map{|id| build(id,lang) }
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.all_ids
|
112
|
+
LimesurveyRails.list_surveys(LimesurveyRails.configuration.username).map{|s| s['sid'].to_i }
|
25
113
|
end
|
26
114
|
|
27
115
|
def self.find(survey_id,lang = nil)
|
@@ -6,7 +6,7 @@ module LimesurveyRails
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.connect(force = false)
|
9
|
-
if !force and connected?
|
9
|
+
if !force and connected?(true)
|
10
10
|
false
|
11
11
|
else
|
12
12
|
if configured?
|
@@ -29,23 +29,13 @@ module LimesurveyRails
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.connected?(verify = false)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
check_result = api.list_surveys(session_key)
|
38
|
-
raise unless check_result.is_a? Array or check_result['status'] == 'No surveys found'
|
39
|
-
end
|
40
|
-
|
41
|
-
true
|
42
|
-
rescue Exception => e
|
43
|
-
if configuration.try(:auto_connection)
|
44
|
-
connect(true)
|
45
|
-
else
|
46
|
-
false
|
47
|
-
end
|
32
|
+
return false unless configured?
|
33
|
+
return false unless session_key.present?
|
34
|
+
if verify
|
35
|
+
check_result = api.list_surveys(session_key)
|
36
|
+
return false unless (check_result.is_a? Array or check_result['status'] == 'No surveys found')
|
48
37
|
end
|
38
|
+
true
|
49
39
|
end
|
50
40
|
|
51
41
|
def self.reset
|
@@ -69,7 +59,7 @@ module LimesurveyRails
|
|
69
59
|
[]
|
70
60
|
when /(left to send)|(No candidate tokens)$/
|
71
61
|
result # get regular result
|
72
|
-
when /Invalid session key$/
|
62
|
+
when /Invalid session key$/ # ask for a new session key
|
73
63
|
arguments.shift
|
74
64
|
if configuration.auto_connection and connect(true)
|
75
65
|
self.send(method_name, *arguments, &block)
|
@@ -26,14 +26,20 @@ module LimesurveyRails
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def surveys
|
29
|
-
|
29
|
+
survey__ids.map{|id| Survey.find(id) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def survey__ids
|
33
|
+
survey_participations.map(&:survey_id)
|
30
34
|
end
|
31
35
|
|
32
36
|
def available_surveys
|
33
|
-
|
34
|
-
Survey.all.delete_if{|s| ids.include? s.id }
|
37
|
+
available_survey__ids.map{|id| Survey.find(id) }
|
35
38
|
end
|
36
39
|
|
40
|
+
def available_survey__ids
|
41
|
+
Survey.all_ids - survey__ids
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
module ClassMethods
|
@@ -37,8 +37,8 @@ describe LimesurveyRails, :main => true do
|
|
37
37
|
its(:configured?) {is_expected.to be true }
|
38
38
|
describe 'LimesurveyRails.configuration' do
|
39
39
|
subject { LimesurveyRails.configuration }
|
40
|
-
its(:username) {should eq(
|
41
|
-
its(:password) {should eq(
|
40
|
+
its(:username) {should eq(LIMESURVEY_USERNAME) }
|
41
|
+
its(:password) {should eq(LIMESURVEY_PASSWORD) }
|
42
42
|
its(:base_url) {should eq(LIMESURVEY_BASE_URL) }
|
43
43
|
end
|
44
44
|
its(:connected?) { is_expected.to be false }
|
@@ -99,26 +99,31 @@ describe LimesurveyRails, :main => true do
|
|
99
99
|
config.auto_connection = true
|
100
100
|
end
|
101
101
|
end
|
102
|
-
its(:connected?) { is_expected.to be
|
102
|
+
its(:connected?) { is_expected.to be false }
|
103
103
|
describe ".connected?(true)" do
|
104
|
-
specify { expect(LimesurveyRails.connected?(true)).to be
|
104
|
+
specify { expect(LimesurveyRails.connected?(true)).to be false }
|
105
105
|
end
|
106
106
|
context "when it is connected" do
|
107
107
|
before(:each) do
|
108
108
|
LimesurveyRails.connect
|
109
109
|
end
|
110
|
+
its(:connected?) { is_expected.to be true }
|
111
|
+
describe ".connected?(true)" do
|
112
|
+
specify { expect(LimesurveyRails.connected?(true)).to be true }
|
113
|
+
end
|
110
114
|
context "when it's session key becomes invalid/expired" do
|
111
115
|
before(:each) do
|
112
116
|
LimesurveyRails.session_key = 'wrong_session_key'
|
113
117
|
end
|
114
118
|
its(:connected?) { is_expected.to be true }
|
115
119
|
describe ".connected?(true)" do
|
116
|
-
specify { expect(LimesurveyRails.connected?(true)).to be
|
120
|
+
specify { expect(LimesurveyRails.connected?(true)).to be false }
|
117
121
|
end
|
118
122
|
describe ".list_surveys" do
|
119
123
|
it "returns a correct result and LimesurveyRails gets a new session_key after reconnecting" do
|
120
124
|
expect(LimesurveyRails.list_surveys).to be_an(Array) and
|
121
|
-
expect(LimesurveyRails.session_key).not_to eq('wrong_session_key')
|
125
|
+
expect(LimesurveyRails.session_key).not_to eq('wrong_session_key') and
|
126
|
+
expect(LimesurveyRails.connected?(true)).to be true
|
122
127
|
end
|
123
128
|
end
|
124
129
|
end
|
@@ -104,7 +104,7 @@ module LimesurveyRails
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
-
describe "#surveys" do
|
107
|
+
describe "#surveys", :wip do
|
108
108
|
before(:all) do
|
109
109
|
@another_test_survey_id = get_brand_new_test_survey_id(:activate_tokens => true)
|
110
110
|
@another_more_test_survey_id = get_brand_new_test_survey_id(:activate_tokens => true)
|
@@ -120,17 +120,40 @@ module LimesurveyRails
|
|
120
120
|
expect(a_participant.surveys.size).to eq 1 and
|
121
121
|
expect(a_participant.surveys.first).to be_kind_of(Survey)
|
122
122
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
expect(a_participant.
|
123
|
+
describe "#survey__ids" do
|
124
|
+
it "returns an array with the id of the survey" do
|
125
|
+
expect(a_participant.survey__ids.size).to eq 1 and
|
126
|
+
expect(a_participant.survey__ids.first).to eq test_survey.id
|
127
|
+
end
|
128
|
+
end
|
129
|
+
describe "#available_survey__ids" do
|
130
|
+
it "returns an array with the id of the remaining surveys" do
|
131
|
+
expect(a_participant.available_survey__ids).to match_array [another_more_test_survey.id, another_test_survey.id]
|
127
132
|
end
|
128
133
|
end
|
129
134
|
describe "#available_surveys" do
|
130
135
|
it "returns an array with two elements" do
|
131
|
-
expect(a_participant.available_surveys.
|
136
|
+
expect(a_participant.available_surveys.map(&:id)).to match_array [another_more_test_survey.id, another_test_survey.id]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
context "when has added to another survey" do
|
140
|
+
before(:each) { SurveyParticipation.create(:survey_id => another_test_survey.id, :participant_id => a_participant.id ) }
|
141
|
+
it "returns an array with two elements" do
|
142
|
+
expect(a_participant.surveys.map(&:id)).to match_array [test_survey.id, another_test_survey.id]
|
143
|
+
end
|
144
|
+
describe "#survey__ids" do
|
145
|
+
it "returns an array with the ids of the two surveys" do
|
146
|
+
expect(a_participant.survey__ids).to match_array [test_survey.id, another_test_survey.id]
|
147
|
+
end
|
132
148
|
end
|
149
|
+
describe "#available_survey__ids" do
|
150
|
+
it "returns an array with the id of the remaining surveys" do
|
151
|
+
expect(a_participant.available_survey__ids).to match_array [another_more_test_survey.id]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
133
155
|
end
|
156
|
+
|
134
157
|
end
|
135
158
|
end
|
136
159
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limesurvey_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masciugo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|