helena 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 390dd724977bdba8cd62758efcccd35fce495eee
4
- data.tar.gz: e7ad85893364a0853ed95d85bbe94ab7d524dda1
3
+ metadata.gz: acadeb9841bf21c2de938861517824219cd1e517
4
+ data.tar.gz: d9a338d54c6551a53b85f6f496a4ce3d11475594
5
5
  SHA512:
6
- metadata.gz: 29c53f9f7e399ed5a64a41e93710de9f00c87da442ea194aaa0ce3d400043e202d0a0ef6a7cb46f161c27d82a92951481ed02af2e89ef8cd95fc5994daf2dca8
7
- data.tar.gz: 7ad9e37117d15ab0f403d0d1df08fd59912a1ee60c23f2725cc20e25572e8c5277285bb54417d0e696e6ef50d880eade07b33c1fc8b2059e4a51f8b19bfc9259
6
+ metadata.gz: 74cb384bc70e07c17c593792da8ca7aa3c7a7b5ce7b4543a357a7e8be432cc7466412f54aeed35678495dc54fa6eec165dadc6d32abffa845d0551f9de0861ba
7
+ data.tar.gz: 96e6a034c109870e6bad4cbf0950ff8d38546df49395cd9e3d1424a6a22b32547d0acc3cec09caeca394ae511d7262429608d7c4784c9ca049413332df70d515
@@ -1,6 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.0
3
4
  - 2.1
4
5
 
5
6
  services:
6
7
  - mongodb
8
+
9
+ cache: bundler
10
+ sudo: false
data/Gemfile CHANGED
@@ -15,7 +15,7 @@ group :development, :test do
15
15
  gem 'pry'
16
16
  gem 'pry-byebug'
17
17
  gem 'ruby-progressbar'
18
- gem 'mongoid-rspec', '~> 2.0.0.rc1'
18
+ gem 'mongoid-rspec'
19
19
  gem 'quiet_assets'
20
20
  gem 'better_errors'
21
21
  gem 'launchy'
@@ -1,15 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helena (1.0.0.rc2)
4
+ helena (1.0.0.rc3)
5
5
  bootstrap-sass (~> 3.2)
6
6
  breadcrumbs_on_rails (~> 2.3)
7
- haml-rails (~> 0.5)
8
- jquery-rails (~> 3.1)
7
+ browser (~> 0.8)
8
+ haml-rails (~> 0.9)
9
+ jquery-rails (~> 4.0)
9
10
  mongoid (~> 4.0)
10
11
  mongoid-simple-tags (~> 0.1)
12
+ mongoid-tree (~> 2.0)
11
13
  mongoid_orderable (~> 4.1)
12
- rails (~> 4.1)
14
+ rails (~> 4.2)
13
15
  rails-i18n (~> 4.0)
14
16
  responders (~> 2.0)
15
17
  sass-rails (~> 5.0)
@@ -19,44 +21,44 @@ PATH
19
21
  GEM
20
22
  remote: https://rubygems.org/
21
23
  specs:
22
- actionmailer (4.2.1)
23
- actionpack (= 4.2.1)
24
- actionview (= 4.2.1)
25
- activejob (= 4.2.1)
24
+ actionmailer (4.2.2)
25
+ actionpack (= 4.2.2)
26
+ actionview (= 4.2.2)
27
+ activejob (= 4.2.2)
26
28
  mail (~> 2.5, >= 2.5.4)
27
29
  rails-dom-testing (~> 1.0, >= 1.0.5)
28
- actionpack (4.2.1)
29
- actionview (= 4.2.1)
30
- activesupport (= 4.2.1)
30
+ actionpack (4.2.2)
31
+ actionview (= 4.2.2)
32
+ activesupport (= 4.2.2)
31
33
  rack (~> 1.6)
32
34
  rack-test (~> 0.6.2)
33
35
  rails-dom-testing (~> 1.0, >= 1.0.5)
34
36
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
35
- actionview (4.2.1)
36
- activesupport (= 4.2.1)
37
+ actionview (4.2.2)
38
+ activesupport (= 4.2.2)
37
39
  builder (~> 3.1)
38
40
  erubis (~> 2.7.0)
39
41
  rails-dom-testing (~> 1.0, >= 1.0.5)
40
42
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
41
- activejob (4.2.1)
42
- activesupport (= 4.2.1)
43
+ activejob (4.2.2)
44
+ activesupport (= 4.2.2)
43
45
  globalid (>= 0.3.0)
44
- activemodel (4.2.1)
45
- activesupport (= 4.2.1)
46
+ activemodel (4.2.2)
47
+ activesupport (= 4.2.2)
46
48
  builder (~> 3.1)
47
- activerecord (4.2.1)
48
- activemodel (= 4.2.1)
49
- activesupport (= 4.2.1)
49
+ activerecord (4.2.2)
50
+ activemodel (= 4.2.2)
51
+ activesupport (= 4.2.2)
50
52
  arel (~> 6.0)
51
- activesupport (4.2.1)
53
+ activesupport (4.2.2)
52
54
  i18n (~> 0.7)
53
55
  json (~> 1.7, >= 1.7.7)
54
56
  minitest (~> 5.1)
55
57
  thread_safe (~> 0.3, >= 0.3.4)
56
58
  tzinfo (~> 1.1)
57
59
  addressable (2.3.8)
58
- arel (6.0.0)
59
- autoprefixer-rails (5.1.10)
60
+ arel (6.0.2)
61
+ autoprefixer-rails (5.2.1)
60
62
  execjs
61
63
  json
62
64
  better_errors (2.1.1)
@@ -65,13 +67,14 @@ GEM
65
67
  rack (>= 0.9.0)
66
68
  binding_of_caller (0.7.2)
67
69
  debug_inspector (>= 0.0.1)
68
- bootstrap-sass (3.3.4.1)
70
+ bootstrap-sass (3.3.5)
69
71
  autoprefixer-rails (>= 5.0.0.1)
70
72
  sass (>= 3.2.19)
71
73
  breadcrumbs_on_rails (2.3.0)
72
- bson (2.3.0)
74
+ browser (0.8.0)
75
+ bson (3.1.0)
73
76
  builder (3.2.2)
74
- byebug (4.0.5)
77
+ byebug (5.0.0)
75
78
  columnize (= 0.9.0)
76
79
  capybara (2.4.4)
77
80
  mime-types (>= 1.16)
@@ -84,10 +87,10 @@ GEM
84
87
  coderay (1.1.0)
85
88
  columnize (0.9.0)
86
89
  connection_pool (2.2.0)
87
- coveralls (0.8.0)
88
- multi_json (~> 1.10)
90
+ coveralls (0.8.2)
91
+ json (~> 1.8)
89
92
  rest-client (>= 1.6.8, < 2)
90
- simplecov (~> 0.9.1)
93
+ simplecov (~> 0.10.0)
91
94
  term-ansicolor (~> 1.3)
92
95
  thor (~> 0.19.1)
93
96
  database_cleaner (1.4.1)
@@ -107,7 +110,8 @@ GEM
107
110
  factory_girl_rails (4.5.0)
108
111
  factory_girl (~> 4.5.0)
109
112
  railties (>= 3.0.0)
110
- ffaker (1.32.1)
113
+ faker (1.4.3)
114
+ i18n (~> 0.5)
111
115
  ffi (1.9.8)
112
116
  globalid (0.3.5)
113
117
  activesupport (>= 4.1.0)
@@ -119,7 +123,7 @@ GEM
119
123
  haml (>= 4.0.6, < 5.0)
120
124
  html2haml (>= 1.0.1)
121
125
  railties (>= 4.0.1)
122
- highline (1.7.1)
126
+ highline (1.7.2)
123
127
  html2haml (2.0.0)
124
128
  erubis (~> 2.7.0)
125
129
  haml (~> 4.0.0)
@@ -128,7 +132,7 @@ GEM
128
132
  http-cookie (1.0.2)
129
133
  domain_name (~> 0.5)
130
134
  i18n (0.7.0)
131
- i18n-tasks (0.8.2)
135
+ i18n-tasks (0.8.3)
132
136
  activesupport
133
137
  easy_translate (>= 0.5.0)
134
138
  erubis
@@ -136,39 +140,42 @@ GEM
136
140
  i18n
137
141
  term-ansicolor
138
142
  terminal-table
139
- jquery-rails (3.1.2)
140
- railties (>= 3.0, < 5.0)
143
+ jquery-rails (4.0.4)
144
+ rails-dom-testing (~> 1.0)
145
+ railties (>= 4.2.0)
141
146
  thor (>= 0.14, < 2.0)
142
- json (1.8.2)
147
+ json (1.8.3)
143
148
  launchy (2.4.3)
144
149
  addressable (~> 2.3)
145
- loofah (2.0.1)
150
+ loofah (2.0.2)
146
151
  nokogiri (>= 1.5.9)
147
152
  mail (2.6.3)
148
153
  mime-types (>= 1.16, < 3)
149
154
  method_source (0.8.2)
150
- mime-types (2.4.3)
155
+ mime-types (2.6.1)
151
156
  mini_portile (0.6.2)
152
- minitest (5.6.0)
157
+ minitest (5.7.0)
153
158
  mongoid (4.0.2)
154
159
  activemodel (~> 4.0)
155
160
  moped (~> 2.0.0)
156
161
  origin (~> 2.1)
157
162
  tzinfo (>= 0.3.37)
158
- mongoid-rspec (2.0.0)
163
+ mongoid-rspec (2.2.0)
159
164
  mongoid (~> 4.0.0)
160
165
  rake
161
166
  rspec (~> 3.1)
162
167
  mongoid-simple-tags (0.1.3)
163
168
  json (~> 1.8)
164
169
  mongoid (>= 3.0.3)
170
+ mongoid-tree (2.0.0)
171
+ mongoid (>= 4.0, <= 5.0)
165
172
  mongoid_orderable (4.1.1)
166
173
  mongoid
167
- moped (2.0.4)
168
- bson (~> 2.2)
174
+ moped (2.0.6)
175
+ bson (~> 3.0)
169
176
  connection_pool (~> 2.0)
170
177
  optionable (~> 0.2.0)
171
- multi_json (1.11.0)
178
+ multi_json (1.11.1)
172
179
  netrc (0.10.3)
173
180
  nokogiri (1.6.6.2)
174
181
  mini_portile (~> 0.6.0)
@@ -178,24 +185,24 @@ GEM
178
185
  coderay (~> 1.1.0)
179
186
  method_source (~> 0.8.1)
180
187
  slop (~> 3.4)
181
- pry-byebug (3.1.0)
182
- byebug (~> 4.0)
188
+ pry-byebug (3.2.0)
189
+ byebug (~> 5.0)
183
190
  pry (~> 0.10)
184
191
  quiet_assets (1.1.0)
185
192
  railties (>= 3.1, < 5.0)
186
- rack (1.6.0)
193
+ rack (1.6.4)
187
194
  rack-test (0.6.3)
188
195
  rack (>= 1.0)
189
- rails (4.2.1)
190
- actionmailer (= 4.2.1)
191
- actionpack (= 4.2.1)
192
- actionview (= 4.2.1)
193
- activejob (= 4.2.1)
194
- activemodel (= 4.2.1)
195
- activerecord (= 4.2.1)
196
- activesupport (= 4.2.1)
196
+ rails (4.2.2)
197
+ actionmailer (= 4.2.2)
198
+ actionpack (= 4.2.2)
199
+ actionview (= 4.2.2)
200
+ activejob (= 4.2.2)
201
+ activemodel (= 4.2.2)
202
+ activerecord (= 4.2.2)
203
+ activesupport (= 4.2.2)
197
204
  bundler (>= 1.3.0, < 2.0)
198
- railties (= 4.2.1)
205
+ railties (= 4.2.2)
199
206
  sprockets-rails
200
207
  rails-deprecated_sanitizer (1.0.3)
201
208
  activesupport (>= 4.2.0.alpha)
@@ -208,9 +215,9 @@ GEM
208
215
  rails-i18n (4.0.4)
209
216
  i18n (~> 0.6)
210
217
  railties (~> 4.0)
211
- railties (4.2.1)
212
- actionpack (= 4.2.1)
213
- activesupport (= 4.2.1)
218
+ railties (4.2.2)
219
+ actionpack (= 4.2.2)
220
+ activesupport (= 4.2.2)
214
221
  rake (>= 0.8.7)
215
222
  thor (>= 0.18.1, < 2.0)
216
223
  rake (10.4.2)
@@ -220,75 +227,75 @@ GEM
220
227
  http-cookie (>= 1.0.2, < 2.0)
221
228
  mime-types (>= 1.16, < 3.0)
222
229
  netrc (~> 0.7)
223
- rspec (3.2.0)
224
- rspec-core (~> 3.2.0)
225
- rspec-expectations (~> 3.2.0)
226
- rspec-mocks (~> 3.2.0)
230
+ rspec (3.3.0)
231
+ rspec-core (~> 3.3.0)
232
+ rspec-expectations (~> 3.3.0)
233
+ rspec-mocks (~> 3.3.0)
227
234
  rspec-collection_matchers (1.1.2)
228
235
  rspec-expectations (>= 2.99.0.beta1)
229
- rspec-core (3.2.3)
230
- rspec-support (~> 3.2.0)
231
- rspec-expectations (3.2.1)
236
+ rspec-core (3.3.2)
237
+ rspec-support (~> 3.3.0)
238
+ rspec-expectations (3.3.1)
232
239
  diff-lcs (>= 1.2.0, < 2.0)
233
- rspec-support (~> 3.2.0)
234
- rspec-mocks (3.2.1)
240
+ rspec-support (~> 3.3.0)
241
+ rspec-mocks (3.3.2)
235
242
  diff-lcs (>= 1.2.0, < 2.0)
236
- rspec-support (~> 3.2.0)
237
- rspec-rails (3.2.1)
243
+ rspec-support (~> 3.3.0)
244
+ rspec-rails (3.3.3)
238
245
  actionpack (>= 3.0, < 4.3)
239
246
  activesupport (>= 3.0, < 4.3)
240
247
  railties (>= 3.0, < 4.3)
241
- rspec-core (~> 3.2.0)
242
- rspec-expectations (~> 3.2.0)
243
- rspec-mocks (~> 3.2.0)
244
- rspec-support (~> 3.2.0)
245
- rspec-support (3.2.2)
248
+ rspec-core (~> 3.3.0)
249
+ rspec-expectations (~> 3.3.0)
250
+ rspec-mocks (~> 3.3.0)
251
+ rspec-support (~> 3.3.0)
252
+ rspec-support (3.3.0)
246
253
  ruby-progressbar (1.7.5)
247
- ruby_parser (3.6.6)
254
+ ruby_parser (3.7.0)
248
255
  sexp_processor (~> 4.1)
249
256
  rubyzip (1.1.7)
250
- sass (3.4.13)
251
- sass-rails (5.0.2)
257
+ sass (3.4.14)
258
+ sass-rails (5.0.3)
252
259
  railties (>= 4.0.0, < 5.0)
253
260
  sass (~> 3.1)
254
261
  sprockets (>= 2.8, < 4.0)
255
262
  sprockets-rails (>= 2.0, < 4.0)
256
263
  tilt (~> 1.1)
257
- selenium-webdriver (2.45.0)
264
+ selenium-webdriver (2.46.2)
258
265
  childprocess (~> 0.5)
259
266
  multi_json (~> 1.0)
260
267
  rubyzip (~> 1.0)
261
268
  websocket (~> 1.0)
262
- sexp_processor (4.5.0)
269
+ sexp_processor (4.6.0)
263
270
  shoulda-matchers (2.8.0)
264
271
  activesupport (>= 3.0.0)
265
272
  simple_form (3.1.0)
266
273
  actionpack (~> 4.0)
267
274
  activemodel (~> 4.0)
268
- simplecov (0.9.2)
275
+ simplecov (0.10.0)
269
276
  docile (~> 1.1.0)
270
- multi_json (~> 1.0)
271
- simplecov-html (~> 0.9.0)
272
- simplecov-html (0.9.0)
273
- slim (3.0.3)
277
+ json (~> 1.8)
278
+ simplecov-html (~> 0.10.0)
279
+ simplecov-html (0.10.0)
280
+ slim (3.0.6)
274
281
  temple (~> 0.7.3)
275
282
  tilt (>= 1.3.3, < 2.1)
276
283
  slop (3.6.0)
277
- sprockets (3.0.1)
284
+ sprockets (3.2.0)
278
285
  rack (~> 1.0)
279
- sprockets-rails (2.2.4)
286
+ sprockets-rails (2.3.2)
280
287
  actionpack (>= 3.0)
281
288
  activesupport (>= 3.0)
282
289
  sprockets (>= 2.8, < 4.0)
283
- temple (0.7.5)
284
- term-ansicolor (1.3.0)
290
+ temple (0.7.6)
291
+ term-ansicolor (1.3.2)
285
292
  tins (~> 1.0)
286
293
  terminal-table (1.4.5)
287
294
  thor (0.19.1)
288
295
  thread (0.2.0)
289
296
  thread_safe (0.3.5)
290
297
  tilt (1.4.1)
291
- tins (1.3.5)
298
+ tins (1.5.4)
292
299
  tzinfo (1.2.2)
293
300
  thread_safe (~> 0.1)
294
301
  unf (0.1.4)
@@ -310,12 +317,12 @@ DEPENDENCIES
310
317
  coveralls
311
318
  database_cleaner (~> 1.3)
312
319
  factory_girl_rails (~> 4.4)
313
- ffaker (~> 1.23)
320
+ faker (~> 1.4)
314
321
  helena!
315
322
  i18n-tasks
316
323
  jquery-rails
317
324
  launchy
318
- mongoid-rspec (~> 2.0.0.rc1)
325
+ mongoid-rspec
319
326
  pry
320
327
  pry-byebug
321
328
  quiet_assets
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  [![Build Status](https://img.shields.io/travis/gurix/helena/master.svg?style=flat)](https://travis-ci.org/gurix/helena)
2
2
  [![Code Climate](https://img.shields.io/codeclimate/github/gurix/helena.svg?style=flat)](https://codeclimate.com/github/gurix/helena)
3
3
  [![Dependency Status](https://img.shields.io/gemnasium/gurix/helena.svg?style=flat)](https://gemnasium.com/gurix/helena)
4
- [![Dependency Status](https://img.shields.io/gem/v/helena.svg?style=flat)](https://rubygems.org/gems/helena)
5
- [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/gurix/helena?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+ [![Rubygems Version](https://img.shields.io/gem/v/helena.svg?style=flat)](https://rubygems.org/gems/helena)
5
+ [![Coverage Status](https://coveralls.io/repos/gurix/helena/badge.svg?branch=master&service=github)](https://coveralls.io/github/gurix/helena?branch=master)
6
6
  # Helena
7
7
  Helena is an online survey/test framework designed for agile survey/test development, longitudinal studies and instant feedback.
8
8
 
@@ -5,7 +5,7 @@ module Helena
5
5
 
6
6
  belongs_to :version
7
7
 
8
- has_many :questions, inverse_of: :question_group, class_name: 'Helena::Question', dependent: :destroy
8
+ has_many :questions, inverse_of: :question_group, class_name: 'Helena::Question', dependent: :destroy, autosave: true
9
9
 
10
10
  orderable scope: :version
11
11
 
@@ -13,7 +13,7 @@ module Helena
13
13
  field :allow_to_go_back, type: Boolean
14
14
 
15
15
  def question_codes
16
- questions.map { |question| [question.code] + question.sub_questions.map(&:code) }.flatten
16
+ questions.map { |question| [question.code] + question.sub_questions.map(&:code) }.flatten
17
17
  end
18
18
  end
19
19
  end
@@ -14,10 +14,13 @@ module Helena
14
14
 
15
15
  validates :token, :view_token, uniqueness: true
16
16
 
17
+ index created_at: 1
18
+ index updated_at: 1
19
+
17
20
  before_create :reset_tokens
18
21
 
19
22
  def answers_as_yaml
20
- Hash[answers.map { | answer | [answer.code, answer.value] }.sort].to_yaml
23
+ Hash[answers.map { |answer| [answer.code, answer.value] }.sort].to_yaml
21
24
  end
22
25
 
23
26
  def answers_as_yaml=(yaml)
@@ -33,15 +36,6 @@ module Helena
33
36
  self.view_token = generate_token(25) until unique_token_for?(:view_token)
34
37
  end
35
38
 
36
- def self.to_csv
37
- CSV.generate do |csv|
38
- csv << fields.keys + uniq_answer_codes
39
- all.each do |session|
40
- csv << session.attributes.values_at(*fields.keys) + answer_values_in(session)
41
- end
42
- end
43
- end
44
-
45
39
  def as_json(options)
46
40
  session = super(options)
47
41
  session[:answer] = answers_as_hash
@@ -49,19 +43,11 @@ module Helena
49
43
  end
50
44
 
51
45
  def answers_as_hash
52
- answers.map { |answer| [answer[:code], answer[:value]] }.to_h
46
+ Hash[*answers.map { |answer| [answer[:code], answer[:value]] }.flatten]
53
47
  end
54
48
 
55
49
  private
56
50
 
57
- def self.answer_values_in(session)
58
- answers = []
59
- answer_codes.each do |code|
60
- answers << session.answers.where(code: code).first.try(&:value)
61
- end
62
- answers
63
- end
64
-
65
51
  def self.answer_codes
66
52
  answer_codes = []
67
53
  all.each do |session|
@@ -70,12 +56,6 @@ module Helena
70
56
  answer_codes
71
57
  end
72
58
 
73
- def self.uniq_answer_codes
74
- answer_codes.map do |code|
75
- fields.keys.include?(code) ? "answer_#{code}" : code
76
- end
77
- end
78
-
79
59
  def generate_token(size)
80
60
  SecureRandom.base64(size).delete('/+=')[0, size]
81
61
  end
@@ -85,7 +65,7 @@ module Helena
85
65
  end
86
66
 
87
67
  def update_answers(parsed_answers)
88
- parsed_answers.each do | code, value |
68
+ parsed_answers.each do |code, value|
89
69
  answer = answers.where(code: code).first
90
70
  if answer
91
71
  next if answer.value == value
@@ -2,6 +2,7 @@ module Helena
2
2
  class Version
3
3
  include Helena::Concerns::ApplicationModel
4
4
  include Mongoid::Orderable # Needed, because the embedded objects needs this, see
5
+ include Mongoid::Tree
5
6
 
6
7
  field :version, type: Integer, default: 0
7
8
  field :notes, type: String
@@ -11,8 +12,8 @@ module Helena
11
12
 
12
13
  belongs_to :survey
13
14
 
14
- has_many :question_groups, inverse_of: :version, dependent: :destroy, class_name: 'Helena::QuestionGroup'
15
- has_many :sessions, inverse_of: :version, dependent: :destroy, class_name: 'Helena::Session'
15
+ has_many :question_groups, inverse_of: :version, dependent: :destroy, class_name: 'Helena::QuestionGroup', autosave: true
16
+ has_many :sessions, inverse_of: :version, dependent: :destroy, class_name: 'Helena::Session', autosave: true
16
17
 
17
18
  embeds_one :survey_detail, class_name: 'Helena::SurveyDetail'
18
19
 
@@ -1,33 +1,56 @@
1
1
  - label_width = "#{60 / question.labels.count}%"
2
+ - mobile = (browser.mobile? || browser.tablet?) # Use a special layout for this devices
2
3
 
3
4
  .radio_matrix.form-group{ class: "#{'has-error' if errors.present?}" }
4
5
  %label{class: "#{'text-danger' if errors.present?}"}
5
6
  != question.question_text
6
7
  = ' *' if question.required
7
- .table-responsive
8
- %table.table
9
- %thead
10
- %tr
11
- %th
12
- - question.labels.each do |label|
13
- %th{ width: label_width }
14
- = label.text
15
- %th
16
-
17
- %tbody
18
- - question.sub_questions.each do |sub_question|
8
+ - unless mobile
9
+ .table-responsive
10
+ %table.table
11
+ %thead
19
12
  %tr
20
- %td.text-right
21
- = sub_question.parts.first
22
- - if errors[sub_question.code]
23
- .help-block.text-danger= errors[sub_question.code]
13
+ %th
24
14
  - question.labels.each do |label|
25
- - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
26
- - checked ||= (label.preselected? ? true : false)
27
- %td{ width: label_width }
28
- %label
29
- = form.simple_fields_for :answers do |answer_form|
30
- = answer_form.radio_button sub_question.code, label.value, checked: checked
31
- %span.hide-text= label.text
32
- %td
33
- = sub_question.parts.last if sub_question.splitted?
15
+ %th{ width: label_width }
16
+ = label.text
17
+ %th
18
+
19
+ %tbody
20
+ - question.sub_questions.each do |sub_question|
21
+ %tr
22
+ %td.text-right
23
+ = sub_question.parts.first
24
+ - if errors[sub_question.code]
25
+ .help-block.text-danger= errors[sub_question.code]
26
+ - question.labels.each do |label|
27
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
28
+ - checked ||= (label.preselected? ? true : false)
29
+ %td{ width: label_width }
30
+ %label
31
+ = form.simple_fields_for :answers do |answer_form|
32
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
33
+ %span.hide-text= label.text
34
+ %td
35
+ = sub_question.parts.last if sub_question.splitted?
36
+ - if mobile
37
+ .mobile
38
+ - question.sub_questions.each do |sub_question|
39
+ %table.table.well
40
+ %tbody
41
+ %tr
42
+ %td.part= sub_question.parts.first
43
+ %tr
44
+ %td
45
+ - question.labels.each do |label|
46
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
47
+ - checked ||= (label.preselected? ? true : false)
48
+ .radio
49
+ %label.responsive_label
50
+ = form.simple_fields_for :answers do |answer_form|
51
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
52
+ = label.text
53
+ &nbsp;
54
+ - if sub_question.splitted?
55
+ %tr
56
+ %td.part= sub_question.parts.last
@@ -1,29 +1,53 @@
1
1
  - label_width = "#{80 / question.labels.count}%"
2
+ - mobile = (browser.mobile? || browser.tablet?) # Use a special layout for this devices
2
3
 
3
4
  .radio_matrix.form-group{ class: "#{'has-error' if errors.present?}" }
4
5
  %label{class: "#{'text-danger' if errors.present?}"}
5
6
  != question.question_text
6
7
  = ' *' if question.required
7
- .table-responsive
8
- %table.table
9
- %thead
10
- %tr
11
- %th
12
- - question.labels.each do |label|
13
- %th{ width: label_width }
14
- = label.text
15
- %tbody
16
- - question.sub_questions.each do |sub_question|
8
+ - unless mobile
9
+ .table-responsive
10
+ %table.table
11
+ %thead
17
12
  %tr
18
- %td
19
- = sub_question.parts.first
20
- - if errors[sub_question.code]
21
- .help-block.text-danger= errors[sub_question.code]
13
+ %th
22
14
  - question.labels.each do |label|
23
- - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
24
- - checked ||= (label.preselected? ? true : false)
25
- %td{ width: label_width }
26
- %label
27
- = form.simple_fields_for :answers do |answer_form|
28
- = answer_form.radio_button sub_question.code, label.value, checked: checked
29
- %span.hide-text= label.text
15
+ %th{ width: label_width }
16
+ = label.text
17
+ %tbody
18
+ - question.sub_questions.each do |sub_question|
19
+ %tr
20
+ %td
21
+ = sub_question.parts.first
22
+ - if errors[sub_question.code]
23
+ .help-block.text-danger= errors[sub_question.code]
24
+ - question.labels.each do |label|
25
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
26
+ - checked ||= (label.preselected? ? true : false)
27
+ %td{ width: label_width }
28
+ %label
29
+ = form.simple_fields_for :answers do |answer_form|
30
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
31
+ %span.hide-text= label.text
32
+
33
+ - if mobile
34
+ .mobile
35
+ - question.sub_questions.each do |sub_question|
36
+ %table.table.well
37
+ %tbody
38
+ %tr
39
+ %td.part= sub_question.parts.first
40
+ %tr
41
+ %td
42
+ - question.labels.each do |label|
43
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
44
+ - checked ||= (label.preselected? ? true : false)
45
+ .radio
46
+ %label.responsive_label
47
+ = form.simple_fields_for :answers do |answer_form|
48
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
49
+ = label.text
50
+ &nbsp;
51
+ - if sub_question.splitted?
52
+ %tr
53
+ %td.part= sub_question.parts.last
@@ -1 +1,6 @@
1
- = question.default_value.html_safe
1
+ .short_text.form-group
2
+ - if question.question_text.present?
3
+ label
4
+ = question.question_text.html_safe
5
+
6
+ = question.default_value.html_safe
@@ -1,5 +1,5 @@
1
1
  require 'factory_girl'
2
- require 'ffaker'
2
+ require 'faker'
3
3
  require 'database_cleaner'
4
4
  require 'helena/survey_importer'
5
5
 
@@ -19,24 +19,26 @@ survey/test development, longitudinal studies and instant feedback.'
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
21
 
22
- s.add_dependency 'rails', '~> 4.1'
22
+ s.add_dependency 'rails', '~> 4.2'
23
23
  s.add_dependency 'mongoid', '~> 4.0'
24
24
  s.add_dependency 'mongoid_orderable', '~> 4.1'
25
25
  s.add_dependency 'mongoid-simple-tags', '~> 0.1'
26
- s.add_dependency 'haml-rails', '~> 0.5'
26
+ s.add_dependency 'haml-rails', '~> 0.9'
27
27
  s.add_dependency 'slim', '~> 3.0'
28
- s.add_dependency 'jquery-rails', '~> 3.1'
28
+ s.add_dependency 'jquery-rails', '~> 4.0'
29
29
  s.add_dependency 'sass-rails', '~> 5.0'
30
30
  s.add_dependency 'bootstrap-sass', '~> 3.2'
31
31
  s.add_dependency 'simple_form', '~> 3.1.0.rc2'
32
32
  s.add_dependency 'breadcrumbs_on_rails', '~> 2.3'
33
33
  s.add_dependency 'rails-i18n', '~> 4.0'
34
34
  s.add_dependency 'responders', '~> 2.0'
35
+ s.add_dependency 'browser', '~> 0.8'
36
+ s.add_dependency 'mongoid-tree', '~> 2.0'
35
37
 
36
38
  s.add_development_dependency 'rspec-rails', '~> 3'
37
39
  s.add_development_dependency 'rspec-collection_matchers', '~> 1'
38
40
  s.add_development_dependency 'factory_girl_rails', '~> 4.4'
39
41
  s.add_development_dependency 'database_cleaner', '~> 1.3'
40
- s.add_development_dependency 'ffaker', '~> 1.23'
42
+ s.add_development_dependency 'faker', '~> 1.4'
41
43
  s.add_development_dependency 'capybara', '~> 2.3'
42
44
  end
@@ -6,8 +6,8 @@ require 'mongoid'
6
6
  require 'simple_form' # TODO: Remove this when amdin interface is finally moved
7
7
  require 'mongoid_orderable'
8
8
  require 'mongoid-simple-tags'
9
- require 'csv'
10
9
  require 'slim'
10
+ require 'mongoid/tree'
11
11
 
12
12
  module Helena
13
13
  end
@@ -13,7 +13,7 @@ module Helena
13
13
  private
14
14
 
15
15
  def create_survey
16
- @survey = Helena::Survey.new @parsed.except('versions')
16
+ @survey = Helena::Survey.find_or_initialize_by @parsed.except('versions')
17
17
  return unless @survey.save!
18
18
  return unless @parsed['versions']
19
19
  @parsed['versions'].each { |parsed_version| create_version parsed_version }
@@ -21,7 +21,7 @@ module Helena
21
21
 
22
22
  def create_version(parsed_version)
23
23
  version = build_version(parsed_version)
24
-
24
+ return unless version.new_record? # We ignore already imported versions
25
25
  return unless version.save!
26
26
  return unless parsed_version.last['question_groups']
27
27
  parsed_version.last['question_groups'].each { |parsed_question_group| create_question_group version, parsed_question_group }
@@ -43,7 +43,7 @@ module Helena
43
43
  end
44
44
 
45
45
  def build_version(parsed_version)
46
- version = @survey.versions.build parsed_version.last.except('question_groups')
46
+ version = @survey.versions.find_or_initialize_by parsed_version.last.except('question_groups', 'survey_detail')
47
47
  version.version = parsed_version.first
48
48
  version.survey_detail = parsed_version.last['survey_detail']
49
49
  version
@@ -1,3 +1,3 @@
1
1
  module Helena
2
- VERSION = '1.0.0.rc2'
2
+ VERSION = '1.0.0.rc3'
3
3
  end
@@ -1,12 +1,12 @@
1
1
  module Helena
2
2
  class VersionPublisher
3
3
  def self.publish(version)
4
- copied_version = create_copied_version_from(version)
4
+ copied_version = build_copied_version_from(version)
5
5
 
6
6
  version.question_groups.each do |original_question_group|
7
- question_group = copied_version.question_groups.create reset_ids(original_question_group.attributes)
7
+ question_group = copied_version.question_groups.build original_question_group.clone.attributes
8
8
  original_question_group.questions.each do |original_question|
9
- question = question_group.questions.create reset_ids(original_question.attributes)
9
+ question = question_group.questions.build original_question.clone.attributes
10
10
  question.labels = original_question.labels
11
11
  question.sub_questions = original_question.sub_questions
12
12
  end
@@ -16,6 +16,7 @@ module Helena
16
16
 
17
17
  def self.adjust_copied_attributes(version, copied_version)
18
18
  copied_version.version = newest_version_of(version.survey) + 1
19
+ copied_version.survey_detail = version.survey_detail.attributes if version.survey_detail
19
20
  copied_version.created_at = DateTime.now
20
21
  copied_version.updated_at = DateTime.now
21
22
  copied_version.active = false
@@ -26,23 +27,9 @@ module Helena
26
27
  survey.newest_version.version
27
28
  end
28
29
 
29
- def self.create_copied_version_from(version)
30
- copied_version = Helena::Version.new reset_ids(version.attributes)
31
- copied_version = adjust_copied_attributes(version, copied_version)
32
- copied_version.survey_detail = reset_ids(version.survey_detail.attributes) if version.survey_detail
33
- copied_version.save
34
- copied_version
35
- end
36
-
37
- def self.reset_ids(attributes)
38
- attributes.each do |key, value|
39
- if key == '_id' && value.is_a?(BSON::ObjectId)
40
- attributes[key] = BSON::ObjectId.new
41
- elsif value.is_a?(Hash) || value.is_a?(Array)
42
- attributes[key] = reset_ids(value)
43
- end
44
- end
45
- attributes
30
+ def self.build_copied_version_from(version)
31
+ copied_version = version.clone
32
+ adjust_copied_attributes(version, copied_version)
46
33
  end
47
34
  end
48
35
  end
@@ -5,6 +5,7 @@ require 'action_controller/railtie'
5
5
  require 'action_mailer/railtie'
6
6
  require 'sprockets/railtie'
7
7
  require 'rails/mongoid'
8
+ require 'browser'
8
9
 
9
10
  Bundler.require(*Rails.groups)
10
11
  require 'helena'
@@ -3,21 +3,29 @@ require 'spec_helper'
3
3
  describe Helena::VersionPublisher do
4
4
  let!(:survey) { create :survey }
5
5
  let!(:source_version) { survey.versions.create version: 42, active: true }
6
- let!(:survey_detail) { source_version.survey_detail = build :survey_detail }
6
+ let!(:survey_detail) { source_version.survey_detail = build :survey_detail, title: 'Bla Bla' }
7
7
  let!(:question_group) { source_version.question_groups.create }
8
- let!(:question) { build(:radio_matrix_question, code: 'abc', question_group: question_group) }
9
- let!(:label) { build(:label, text: 'xyz', value: 'asdf', question: question) }
10
- let!(:sub_question) { build(:sub_question, text: 'ymca', code: 'cde', question: question) }
8
+ let!(:question) { create(:radio_matrix_question, code: 'abc', question_group: question_group) }
9
+ let!(:label) { create(:label, text: 'xyz', value: 'asdf', question: question) }
10
+ let!(:sub_question) { create(:sub_question, text: 'ymca', code: 'cde', question: question) }
11
11
 
12
12
  it 'creates a new version' do
13
13
  allow(DateTime).to receive(:now).and_return('Tue, 24 Jun 2014 10:24:08 +0200')
14
14
 
15
15
  new_version = Helena::VersionPublisher.publish(source_version)
16
+ new_version.save
16
17
 
17
18
  expect(new_version.version).to eq 43
18
- expect(new_version.survey_detail).to be_a Helena::SurveyDetail
19
+ expect(new_version.survey_detail.title).to eq 'Bla Bla'
20
+
19
21
  expect(new_version).to have(1).question_groups
22
+ expect(Helena::QuestionGroup.count).to eq 2
23
+ expect(new_version.question_groups.first.id).not_to eq source_version.question_groups.first.id
24
+
20
25
  expect(new_version.question_groups.first).to have_exactly(1).questions
26
+ expect(new_version.question_groups.first.questions.first.id).not_to eq source_version.question_groups.first.questions.first.id
27
+ expect(Helena::Question.count).to eq 2
28
+
21
29
  expect(new_version.question_groups.first.questions.first).to have_exactly(1).labels
22
30
  expect(new_version.question_groups.first.questions.first).to have_exactly(1).sub_questions
23
31
  expect(new_version.created_at).to eq 'Tue, 24 Jun 2014 10:24:08 +0200'
@@ -13,6 +13,9 @@ describe Helena::Session do
13
13
  it { expect(subject).to validate_uniqueness_of(:token) }
14
14
  it { expect(subject).to validate_uniqueness_of(:view_token) }
15
15
 
16
+ it { expect(subject).to have_index_for(created_at: 1) }
17
+ it { expect(subject).to have_index_for(updated_at: 1) }
18
+
16
19
  it 'has a valid factory' do
17
20
  expect(build :session).to be_valid
18
21
  end
@@ -22,17 +25,6 @@ describe Helena::Session do
22
25
  expect(create(:session_without_token).token).to eq 'a493oP'
23
26
  end
24
27
 
25
- it 'exports as CSV with answers' do
26
- session.answers << Helena::Answer.build_generic('a', 42, '192.168.0.1')
27
- session.answers << Helena::Answer.build_generic('b', true, '192.235.0.1')
28
- session.answers << Helena::Answer.build_generic('c', 'Barbra Streisand!!', '192.999.0.1')
29
-
30
- csv = Helena::Session.to_csv
31
-
32
- expect(csv).to include 'a,b,c'
33
- expect(csv).to include '42,true,Barbra Streisand!!'
34
- end
35
-
36
28
  describe '#answers_as_yaml and #answer_as_yaml=' do
37
29
  before do
38
30
  session.answers << Helena::Answer.build_generic('c', 'Barbra Streisand!!', '192.999.0.1')
@@ -1,4 +1,4 @@
1
- require 'ffaker'
1
+ require 'faker'
2
2
  require 'coveralls'
3
3
 
4
4
  Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helena
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Graf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-27 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongoid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.5'
75
+ version: '0.9'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.5'
82
+ version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: slim
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.1'
103
+ version: '4.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.1'
110
+ version: '4.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sass-rails
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,34 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '2.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: browser
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.8'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.8'
209
+ - !ruby/object:Gem::Dependency
210
+ name: mongoid-tree
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '2.0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '2.0'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: rspec-rails
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -249,19 +277,19 @@ dependencies:
249
277
  - !ruby/object:Gem::Version
250
278
  version: '1.3'
251
279
  - !ruby/object:Gem::Dependency
252
- name: ffaker
280
+ name: faker
253
281
  requirement: !ruby/object:Gem::Requirement
254
282
  requirements:
255
283
  - - "~>"
256
284
  - !ruby/object:Gem::Version
257
- version: '1.23'
285
+ version: '1.4'
258
286
  type: :development
259
287
  prerelease: false
260
288
  version_requirements: !ruby/object:Gem::Requirement
261
289
  requirements:
262
290
  - - "~>"
263
291
  - !ruby/object:Gem::Version
264
- version: '1.23'
292
+ version: '1.4'
265
293
  - !ruby/object:Gem::Dependency
266
294
  name: capybara
267
295
  requirement: !ruby/object:Gem::Requirement
@@ -447,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
447
475
  version: 1.3.1
448
476
  requirements: []
449
477
  rubyforge_project:
450
- rubygems_version: 2.2.2
478
+ rubygems_version: 2.4.5
451
479
  signing_key:
452
480
  specification_version: 4
453
481
  summary: Helena is an online survey/test framework designed for agile survey/test