quby 5.6.1 → 5.6.2

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
  SHA256:
3
- metadata.gz: 6ba1a0ec73baa50b61bf5aa61e800b2efad36ee13b2431b4c0b11de6723ea17c
4
- data.tar.gz: e71569d856f4ab5f1cac03c89b100bbc42b8b5e2b7340585b8727f4a49570636
3
+ metadata.gz: cd99dcef2d162e1a141450f6145039a13625b0ed353d4babb468d849ef14110b
4
+ data.tar.gz: 6fdd62f95d60b1bd4b983af887a3afc83dc4e38e49f69f44118f3225de4c462e
5
5
  SHA512:
6
- metadata.gz: 8f6f19a3b27df5b7316fe201845d7941c786d234e431b597372512fdfe8284ce5b1c190b4ddd74c2017878ce18a08c3b069bf91e98110b03637b3d45463e6277
7
- data.tar.gz: dd04e3f96c639ad1c7819f47bd71f960dff5766463ab9c249f476068839a86a6b32207bc5b32a260c9db1d735eccb0673aef639b4736c74bd67655405fd14c46
6
+ metadata.gz: b5fd4c4555693ab32bdd68d317bcd095463ef5dec25d4aae786e7626355e29049601c187ff858708e62d5c0a71e9aef4af1601a59790ce50ad0392b9879ba4a4
7
+ data.tar.gz: bbda27366c564a1780c4e94bad7cda6eb698cda3a653e7120b9f0e8a2a1ec240d04c090d03d3254bfe1c998d2451bab76b89ad8a8c46c11d82beae5412da1bd7
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- I18n.available_locales = %i( nl en de )
3
+ I18n.available_locales = %i( nl en de fr sr )
4
4
  I18n.default_locale = :nl
5
5
  I18n.config.enforce_available_locales = true
@@ -0,0 +1,56 @@
1
+ # placeholder in english until we decide to fully translate into french
2
+ fr:
3
+ date:
4
+ formats:
5
+ friendly_date: "%-d %B %Y (%-d-%-m-%Y)"
6
+ step_i_of_n: "Step %{i} of %{n}"
7
+ previous: Previous
8
+ next: Next
9
+ abort: Save for later
10
+ previous_questionnaire: Previous questionnaire
11
+ done: Done
12
+ download_answers_pdf: Download as PDF was moved to the end of the session
13
+ questionnaire_not_completed:
14
+ heading: "This questionnaire hasn't been filled out completely!"
15
+ explanation: "If you decide to save the questionnaire anyway, it could be that scale scores can't be calculated because we don't have all the required answers. You may complete the questionnaire below."
16
+ save_anyway: Save anyway
17
+ thanks_for_filling_out: Thank you for filling out the questionnaire.
18
+ ios_download_instruction: "Your download will open in a new tab.\n\nSave the file in Books/iBooks. Return to the browser using the '< Safari' button in the top left.\n\nBack in the browser, press the back '<' button and press 'Done' to complete your questionnaire."
19
+ validations:
20
+ maximum:
21
+ date: "Entered date must be on or before %{friendly_date}."
22
+ number: "Enter a number of at most %{value}."
23
+ minimum:
24
+ date: "Entered date must be on or after %{friendly_date}."
25
+ number: "Enter a number of at least %{value}."
26
+ requires_answer: "Please fill out this question."
27
+ regexp: "Please enter an answer in the format %{matcher}."
28
+ valid_integer: "Enter a valid integer number"
29
+ valid_float: "Enter a number. Use a period (.) for decimals."
30
+ valid_date:
31
+ valid_date_year: "Enter a valid year in the format YYYY, for example 2015."
32
+ valid_date_month_year: "Enter a valid date in the format MM-YYYY, for example 08-2015."
33
+ valid_date_day_hour_minute_month_year: "Enter a valid date in the format DD-MM-YYYY hh:mm, for example 12-08-2015 13:05."
34
+ valid_date_day_month_year: "Enter a valid date in the format DD-MM-YYYY, for example 12-08-2015."
35
+ valid_date_hour_minute: "Enter a valid time in the format hh:mm, for example 13:05."
36
+ too_many_checked: "You chose too many options"
37
+ not_all_checked: "You chose too few options"
38
+ maximum_checked_allowed:
39
+ one: "Choose up to %{maximum_checked_value} options."
40
+ other: "Choose up to %{maximum_checked_value} options."
41
+ minimum_checked_required:
42
+ one: "Choose at least %{minimum_checked_value} options."
43
+ other: "Choose at least %{minimum_checked_value} options."
44
+ answer_group_minimum: "Answer at least %{value} of these questions"
45
+ answer_group_maximum: "Answer up to %{value} of these questions"
46
+ video_not_supported: Your browser does not support playing this video. Try using a different browser.
47
+ DD: DD
48
+ MM: MM
49
+ YYYY: YYYY
50
+ hh: hh
51
+ mm: mm
52
+ day: day
53
+ month: month
54
+ year: year
55
+ hour: hour
56
+ minute: minute
@@ -0,0 +1,67 @@
1
+ # placeholder in english until we decide to fully translate into serbian
2
+ sr:
3
+ datetime:
4
+ distance_in_words:
5
+ x_years:
6
+ # Rails is missing these base translations.
7
+ # Added them based on the "about X years" and "over X years" translations.
8
+ # Not fully sure if the a vs e endings are correct.
9
+ one: "%{count} година"
10
+ few: "%{count} године"
11
+ many: "%{count} година"
12
+ other: "%{count} година"
13
+
14
+ date:
15
+ formats:
16
+ friendly_date: "%-d %B %Y (%-d-%-m-%Y)"
17
+ step_i_of_n: "Step %{i} of %{n}"
18
+ previous: Previous
19
+ next: Next
20
+ abort: Save for later
21
+ previous_questionnaire: Previous questionnaire
22
+ done: Done
23
+ download_answers_pdf: Download as PDF was moved to the end of the session
24
+ questionnaire_not_completed:
25
+ heading: "This questionnaire hasn't been filled out completely!"
26
+ explanation: "If you decide to save the questionnaire anyway, it could be that scale scores can't be calculated because we don't have all the required answers. You may complete the questionnaire below."
27
+ save_anyway: Save anyway
28
+ thanks_for_filling_out: Thank you for filling out the questionnaire.
29
+ ios_download_instruction: "Your download will open in a new tab.\n\nSave the file in Books/iBooks. Return to the browser using the '< Safari' button in the top left.\n\nBack in the browser, press the back '<' button and press 'Done' to complete your questionnaire."
30
+ validations:
31
+ maximum:
32
+ date: "Entered date must be on or before %{friendly_date}."
33
+ number: "Enter a number of at most %{value}."
34
+ minimum:
35
+ date: "Entered date must be on or after %{friendly_date}."
36
+ number: "Enter a number of at least %{value}."
37
+ requires_answer: "Please fill out this question."
38
+ regexp: "Please enter an answer in the format %{matcher}."
39
+ valid_integer: "Enter a valid integer number"
40
+ valid_float: "Enter a number. Use a period (.) for decimals."
41
+ valid_date:
42
+ valid_date_year: "Enter a valid year in the format YYYY, for example 2015."
43
+ valid_date_month_year: "Enter a valid date in the format MM-YYYY, for example 08-2015."
44
+ valid_date_day_hour_minute_month_year: "Enter a valid date in the format DD-MM-YYYY hh:mm, for example 12-08-2015 13:05."
45
+ valid_date_day_month_year: "Enter a valid date in the format DD-MM-YYYY, for example 12-08-2015."
46
+ valid_date_hour_minute: "Enter a valid time in the format hh:mm, for example 13:05."
47
+ too_many_checked: "You chose too many options"
48
+ not_all_checked: "You chose too few options"
49
+ maximum_checked_allowed:
50
+ one: "Choose up to %{maximum_checked_value} options."
51
+ other: "Choose up to %{maximum_checked_value} options."
52
+ minimum_checked_required:
53
+ one: "Choose at least %{minimum_checked_value} options."
54
+ other: "Choose at least %{minimum_checked_value} options."
55
+ answer_group_minimum: "Answer at least %{value} of these questions"
56
+ answer_group_maximum: "Answer up to %{value} of these questions"
57
+ video_not_supported: Your browser does not support playing this video. Try using a different browser.
58
+ DD: DD
59
+ MM: MM
60
+ YYYY: YYYY
61
+ hh: hh
62
+ mm: mm
63
+ day: day
64
+ month: month
65
+ year: year
66
+ hour: hour
67
+ minute: minute
@@ -62,42 +62,9 @@ module Quby
62
62
  end
63
63
  end
64
64
 
65
- # returns a human readable string description given a key of a question,
66
- # question component (date components, checkbox options), score, flag or textvar
67
- def description_for_variable(key)
68
- # for questionnaires where we do not check_key_clashes we cannot reliably retrace the variable keys,
69
- # since they contain conflicts between option keys and question keys
70
- # in order to be safe we return a string explaining the issue
71
- return "No description due to question/option key clash" if option_hash.key?(key) && question_hash.key?(key)
72
-
73
- variable_description(key)
74
- end
75
-
76
65
  def as_json
77
66
  question_hash
78
67
  end
79
-
80
- private
81
-
82
- # warning, will contain a result even if option/answer key clashes exist for a given key
83
- def variable_description(key)
84
- @question_variable_descriptions ||= @questionnaire.questions
85
- .map(&:variable_descriptions)
86
- .reduce({}, &:merge!)
87
- @question_variable_descriptions[key] ||
88
- score_descriptions[key] ||
89
- @questionnaire.flags[key]&.variable_description ||
90
- @questionnaire.textvars[key]&.description
91
- end
92
-
93
- def score_descriptions
94
- @score_variable_descriptions ||=
95
- @questionnaire.score_schemas.values.map do |score_schema|
96
- score_schema.subscore_schemas.map do |subschema|
97
- [subschema.export_key, "#{score_schema.label} #{subschema.label}"]
98
- end
99
- end.flatten(1).to_h.with_indifferent_access
100
- end
101
68
  end
102
69
  end
103
70
  end
@@ -27,21 +27,6 @@ module Quby
27
27
  yield if answer_flags[key] == trigger_on
28
28
  end
29
29
 
30
- def variable_description
31
- "#{description} (true - '#{description_true}', false - '#{description_false}')"
32
- end
33
-
34
- def to_codebook(_options = {})
35
- output = []
36
- output << "#{key} flag"
37
- output << "'#{description}'" if description.present?
38
- output << " 'true' - #{description_true}"
39
- output << " 'false' - #{description_false}"
40
- output << " '' (leeg) - Vlag niet ingesteld, informatie onbekend"
41
- output << ""
42
- output.join("\n")
43
- end
44
-
45
30
  private
46
31
 
47
32
  def ensure_valid_descriptions
@@ -30,10 +30,6 @@ module Quby
30
30
  class: self.class.to_s
31
31
  }
32
32
  end
33
-
34
- def to_codebook(questionnaire, options = {})
35
- ""
36
- end
37
33
  end
38
34
  end
39
35
  end
@@ -290,41 +290,6 @@ module Quby
290
290
  def subquestion?
291
291
  !parent_option_key.nil?
292
292
  end
293
-
294
- def to_codebook(questionnaire, opts = {})
295
- output = []
296
- question_key = codebook_key(key, questionnaire, opts)
297
- output << "#{question_key} #{codebook_output_type} #{codebook_output_range}#{' deprecated' if hidden}"
298
- output << "\"#{context_free_title}\"" unless context_free_title.blank?
299
- options_string = options.map do |option|
300
- option.to_codebook(questionnaire, opts)
301
- end.compact.join("\n")
302
- output << options_string unless options.blank?
303
- output.join("\n")
304
- end
305
-
306
- def codebook_key(key, questionnaire, opts = {})
307
- key.to_s.gsub(/^v_/, "#{opts[:roqua_key] || questionnaire.key.to_s}_")
308
- end
309
-
310
- def codebook_output_type
311
- type
312
- end
313
-
314
- def codebook_output_range
315
- range_min = validations.find { |i| i[:type] == :minimum }&.fetch(:value, nil)
316
- range_max = validations.find { |i| i[:type] == :maximum }&.fetch(:value, nil)
317
-
318
- if range_min || range_max
319
- "(#{[range_min, "value", range_max].compact.join(" &lt;= ")})"
320
- else
321
- ""
322
- end
323
- end
324
-
325
- def variable_descriptions
326
- {key => context_free_title}.with_indifferent_access
327
- end
328
293
  end
329
294
  end
330
295
  end
@@ -68,28 +68,6 @@ module Quby
68
68
  viewId: view_id
69
69
  }
70
70
  end
71
-
72
- def to_codebook(questionnaire, opts)
73
- return nil if inner_title
74
- output = []
75
-
76
- if question.type == :check_box
77
- option_key = question.codebook_key(key, questionnaire, opts)
78
- output << "#{option_key} #{question.codebook_output_type}#{' deprecated' if hidden || question.hidden }"
79
- output << "\"#{question.title} -- #{description}\"" unless question.title.blank? and description.blank?
80
- output << "1\tChecked"
81
- output << "0\tUnchecked"
82
- output << "empty\tUnchecked"
83
- else
84
- output << "#{value || key}\t\"#{description}\"#{' deprecated' if hidden}"
85
- end
86
-
87
- questions.each do |subquestion|
88
- output << "\t#{subquestion.to_codebook(questionnaire, opts).gsub("\n", "\n\t")}"
89
- end
90
-
91
- output.join("\n")
92
- end
93
71
  end
94
72
  end
95
73
  end
@@ -188,43 +188,6 @@ module Quby
188
188
  }
189
189
  end
190
190
 
191
- # rubocop:disable Metrics/MethodLength
192
- def to_codebook(options = {})
193
- output = []
194
- output << title
195
- output << "Date unknown"
196
- output << ""
197
-
198
- options[:extra_vars]&.each do |var|
199
- output << "#{var[:key]} #{var[:type]}"
200
- output << "\"#{var[:description]}\""
201
- output << ""
202
- end
203
-
204
- top_questions = panels.map do |panel|
205
- panel.items.select { |item| item.is_a? Question }
206
- end.flatten.compact
207
-
208
- top_questions.each do |question|
209
- output << question.to_codebook(self, options)
210
- output << ""
211
- end
212
-
213
- flags.each_value do |flag|
214
- output << flag.to_codebook(options)
215
- output << ""
216
- end
217
-
218
- textvars.each_value do |textvar|
219
- output << textvar.to_codebook(options)
220
- output << ""
221
- end
222
-
223
- output = output.join("\n")
224
- strip_tags(output.gsub(/\<([ 1-9])/, '&lt;\1')).gsub("&lt;", "<")
225
- end
226
- # rubocop:enable Metrics/MethodLength
227
-
228
191
  def key_in_use?(key)
229
192
  fields.key_in_use?(key) || score_calculations.key?(key)
230
193
  end
@@ -26,13 +26,6 @@ module Quby
26
26
  @minimum_checked_required = options[:minimum_checked_required]
27
27
  end
28
28
 
29
- def variable_descriptions
30
- options.each_with_object(key => context_free_title) do |option, hash|
31
- next if option.input_key.blank?
32
- hash[option.input_key] = "#{context_free_title} - #{option.description}"
33
- end.with_indifferent_access
34
- end
35
-
36
29
  def claimed_keys
37
30
  [key]
38
31
  end
@@ -45,12 +38,6 @@ module Quby
45
38
  def as_json(options = {})
46
39
  super.merge(options: @options.as_json)
47
40
  end
48
-
49
- def to_codebook(questionnaire, opts = {})
50
- options.map do |option|
51
- option.to_codebook(questionnaire, opts)
52
- end.compact.join("\n\n")
53
- end
54
41
  end
55
42
  end
56
43
  end
@@ -44,31 +44,12 @@ module Quby
44
44
  end
45
45
  end
46
46
 
47
- def variable_descriptions
48
- components.each_with_object(key => context_free_title) do |component, hash|
49
- key = send("#{component}_key")
50
- hash[key] = "#{context_free_title} (#{I18n.t component})"
51
- end.with_indifferent_access
52
- end
53
-
54
47
  def as_json(options = {})
55
48
  component_keys = components.each_with_object({}) do |component, hash|
56
49
  hash["#{component}Key"] = send("#{component}_key")
57
50
  end
58
51
  super.merge(components: components).merge(component_keys)
59
52
  end
60
-
61
- def to_codebook(questionnaire, opts = {})
62
- output = []
63
- components.each do |component|
64
- output << "#{codebook_key(send("#{component}_key"), questionnaire, opts)} " \
65
- "#{type}_#{component} #{codebook_output_range}"
66
- output << "\"#{title}\"" unless title.blank?
67
- output << options.map(&:to_codebook).join("\n") unless options.blank?
68
- output << ""
69
- end
70
- output.join("\n")
71
- end
72
53
  end
73
54
  end
74
55
  end
@@ -8,10 +8,6 @@ module Quby
8
8
  def as_json(options = {})
9
9
  super.merge(options: @options.as_json)
10
10
  end
11
-
12
- def codebook_output_type
13
- :radio
14
- end
15
11
  end
16
12
  end
17
13
  end
@@ -8,10 +8,6 @@ module Quby
8
8
  def as_json(options = {})
9
9
  super.merge(options: @options.as_json)
10
10
  end
11
-
12
- def codebook_output_type
13
- :radio
14
- end
15
11
  end
16
12
  end
17
13
  end
@@ -10,13 +10,6 @@ module Quby
10
10
  super(key, description, default, depends_on_flag)
11
11
  end
12
12
  # rubocop:enable ParameterLists
13
-
14
- def to_codebook(_options = {})
15
- output = []
16
- output << "#{key} Textvariabele"
17
- output << description
18
- output.join("\n")
19
- end
20
13
  end
21
14
  end
22
15
  end
data/lib/quby/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quby
4
- VERSION = "5.6.1"
4
+ VERSION = "5.6.2"
5
5
  end
@@ -1 +1 @@
1
- # Logfile created on 2023-06-13 12:01:19 +0200 by logger.rb/v1.5.3
1
+ # Logfile created on 2024-01-25 10:27:19 +0100 by logger.rb/v1.5.3
@@ -80,60 +80,5 @@ module Quby::Questionnaires::Entities
80
80
  end
81
81
  end
82
82
  end
83
-
84
- describe '#description_for_variable' do
85
- let(:questionnaire) do
86
- Quby::Questionnaires::DSL.build("test") do
87
- flag key: :flagtest, description_true: 'it true', description_false: 'it false', description: 'it described'
88
- textvar key: :textvartest, description: 'tv description'
89
- question :v_1, type: :radio, title: 'select a few'
90
- question :v_2, type: :radio, title: 'select a few' do
91
- context_free_title 'select a few things'
92
- end
93
- question :v_3, type: :date, title: 'Belangrijke datum', components: %i( day month year hour minute )
94
- question :v_4, type: :check_box do
95
- title "Which?"
96
- option :v_4a1, description: 'option a1'
97
- inner_title 'Really?'
98
- option :v_4a2, description: 'option a2'
99
- end
100
-
101
- score :tot, label: 'Total' do
102
- {value: 2, interpretation: 'Very high'}
103
- end
104
-
105
- score_schema :tot, 'Total', [{key: :value, export_key: :tot, label: 'Score'},
106
- {key: :interpretation, export_key: :tot_i, label: 'Interpretation'}]
107
-
108
- end
109
- end
110
-
111
- it 'returns question context free titles if the variable is a question' do
112
- expect(questionnaire.fields.description_for_variable('v_1')).to eq('select a few')
113
- expect(questionnaire.fields.description_for_variable('v_2')).to eq('select a few things')
114
- end
115
- it 'returns checkbox option descriptions if the variable is a checkbox option' do
116
- keys = %w(v_4 v_4a1 v_4a2)
117
- expect(keys.map { |key| questionnaire.fields.description_for_variable key }).to \
118
- eq(['Which?', 'Which? - option a1', 'Which? - option a2'])
119
- end
120
- it 'returns date question descriptions if the variable is a date question\'s subcomponent' do
121
- keys = %w(v_3 v_3_dd v_3_mm v_3_yyyy v_3_hh v_3_ii)
122
- expect(keys.map { |key| questionnaire.fields.description_for_variable key }).to \
123
- eq(["Belangrijke datum", "Belangrijke datum (dag)", "Belangrijke datum (maand)",
124
- "Belangrijke datum (jaar)", "Belangrijke datum (uur)", "Belangrijke datum (minuut)"])
125
- end
126
- it 'returns score labels if the variable is a subscore\'s exported key' do
127
- expect(questionnaire.fields.description_for_variable('tot_i')).to eq('Total Interpretation')
128
- expect(questionnaire.fields.description_for_variable('tot')).to eq('Total Score')
129
- end
130
- it 'returns flag descriptions' do
131
- expect(questionnaire.fields.description_for_variable('test_flagtest')).to \
132
- eq('it described (true - \'it true\', false - \'it false\')')
133
- end
134
- it 'returns textvar descriptions' do
135
- expect(questionnaire.fields.description_for_variable('test_textvartest')).to eq('tv description')
136
- end
137
- end
138
83
  end
139
84
  end
@@ -17,35 +17,5 @@ module Quby::Questionnaires::Entities
17
17
  depends_on: :other_flag,
18
18
  default_in_interface: false)
19
19
  end
20
-
21
- describe '#to_codebook' do
22
- it 'exports the flag key' do
23
- expect(flag.to_codebook).to include('questkey_flagkey')
24
- end
25
- it 'exports the description' do
26
- expect(flag.to_codebook).to include('test flag')
27
- end
28
- it 'contains the true_description' do
29
- expect(flag.to_codebook).to include('flag is true')
30
- end
31
- it 'contains the false_description' do
32
- expect(flag.to_codebook).to include('flag is false')
33
- end
34
- it 'contains the general blank description' do
35
- expect(flag.to_codebook).to include('\'\' (leeg) - Vlag niet ingesteld, informatie onbekend')
36
- end
37
- it 'requires either both description_true and false or a description' do
38
- error = "Flag 'test' Requires at least either both description_true and description_false or a description"
39
- expect { described_class.new(key: :test) }.to raise_exception(error)
40
- expect { described_class.new(key: :test, description_true: 'test true') }.to raise_exception(error)
41
- expect { described_class.new(key: :test, description_false: 'test false') }.to raise_exception(error)
42
- expect { described_class.new(key: :test, description: 'test') }.to_not raise_exception
43
- end
44
- end
45
- describe '#variable_description' do
46
- it 'returns a single line description of the flag' do
47
- expect(flag.variable_description).to eq("test flag (true - 'flag is true', false - 'flag is false')")
48
- end
49
- end
50
20
  end
51
21
  end
@@ -165,121 +165,6 @@ module Quby::Questionnaires::Entities
165
165
  end
166
166
  end
167
167
 
168
- describe '#to_codebook' do
169
- it "should be able to generate a codebook" do
170
- questionnaire = Quby::Questionnaires::DSL.build("test") do
171
- title 'My Test'
172
- question :v_1, type: :radio do
173
- option :a1, value: 0; option :a2, value: 1
174
- end
175
- end
176
-
177
- expect(questionnaire.to_codebook).to be
178
- end
179
-
180
- it "should not break off a codebook when encountering <" do
181
- questionnaire = Quby::Questionnaires::DSL.build("test2") do
182
- title 'My Test'
183
- question :v_1, type: :radio do
184
- title ' < 20'
185
- option :a1, value: 0
186
- option :a2, value: 1
187
- end
188
- end
189
-
190
- expect(questionnaire.to_codebook).to eq "My Test\nDate unknown\n\ntest2_1 radio \n\" < 20\"\n0\t\"\"\n1\t\"\"\n"
191
- end
192
-
193
- it 'interleaves subquestions between checkbox options, to match quby_proxy behavior' do
194
- questionnaire = Quby::Questionnaires::DSL.build("test") do
195
- title 'My Test'
196
- question(:v_1, type: :check_box) do
197
- option :v_1_a1, value: 0 do
198
- question :v_1_a1_1, type: :string
199
- question :v_1_a1_2, type: :string
200
- end
201
- inner_title 'make it complex'
202
- option :v_1_a2, value: 1 do
203
- question :v_1_a2_1, type: :string
204
- end
205
- end
206
- end
207
-
208
- expect(questionnaire.to_codebook).to eq("My Test\nDate unknown\n\ntest_1_a1 check_box\n1\tChecked\n0\tUnchecked\nempty\tUnchecked\n\ttest_1_a1_1 string \n\ttest_1_a1_2 string \n\ntest_1_a2 check_box\n1\tChecked\n0\tUnchecked\nempty\tUnchecked\n\ttest_1_a2_1 string \n")
209
- end
210
-
211
- describe 'with flags' do
212
- it 'contains flags' do
213
- questionnaire = Quby::Questionnaires::DSL.build("test") do
214
- title 'My Test'
215
-
216
- flag key: :depr,
217
- description_true: 'Er is sprake van depressieklachten',
218
- description_false: 'Er is geen sprake van depressieklachten',
219
- trigger_on: false,
220
- hides_questions: [:v_1]
221
-
222
- question :v_1, type: :string do
223
- title 'gehide door depr false'
224
- end
225
- end
226
-
227
- expect(questionnaire.to_codebook).to eq("My Test\nDate unknown\n\ntest_1 string \n\"gehide door depr false\"\n\ntest_depr flag\n 'true' - Er is sprake van depressieklachten\n 'false' - Er is geen sprake van depressieklachten\n '' (leeg) - Vlag niet ingesteld, informatie onbekend\n\n")
228
- end
229
- end
230
-
231
- describe 'with textvars' do
232
- it 'contains textvars' do
233
- questionnaire = Quby::Questionnaires::DSL.build("test") do
234
- title 'My Test'
235
-
236
- textvar key: :probleem_1, description: 'probleem 1', default: ''
237
-
238
- question :v_1, type: :string do
239
- title 'vraag'
240
- end
241
- end
242
-
243
- expect(questionnaire.to_codebook).to eq("My Test\nDate unknown\n\ntest_1 string \n\"vraag\"\n\ntest_probleem_1 Textvariabele\nprobleem 1\n")
244
- end
245
- end
246
-
247
- describe 'with textvar that depends on a flag' do
248
- it 'will have a depends_on_flag attribute' do
249
- questionnaire = Quby::Questionnaires::DSL.build("test") do
250
- title 'My Test'
251
-
252
- flag key: :testflag, description_true: 'Test', description_false: 'Test uit', shows_questions: [:v_1]
253
- textvar key: :probleem_1, description: 'probleem 1', default: '', depends_on_flag: :test_testflag
254
-
255
- question :v_1, type: :string do
256
- title 'vraag'
257
- end
258
- end
259
-
260
- expect(questionnaire.textvars[:test_probleem_1].depends_on_flag).to eq(:test_testflag)
261
- end
262
- end
263
-
264
- describe 'with textvar that depends on a nonexistent flag' do
265
- it 'will raise on creation' do
266
- expect do
267
- Quby::Questionnaires::DSL.build("test") do
268
- title 'My Test'
269
-
270
- flag key: :testflag, description_true: 'Test', description_false: 'Test uit', shows_questions: [:v_1]
271
- textvar key: :probleem_1, description: 'probleem 1', default: '', depends_on_flag: :nonexistent
272
-
273
- question :v_1, type: :string do
274
- title 'vraag'
275
- end
276
- end
277
- end.to raise_exception(ArgumentError,
278
- 'Textvar \'test_probleem_1\' depends on nonexistent flag \'nonexistent\'')
279
- end
280
- end
281
- end
282
-
283
168
  describe '#add_chart' do
284
169
  let(:charts) { double }
285
170
  let(:chart) { double(key: 'tot', scores: [double("Score")]) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.1
4
+ version: 5.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-06-13 00:00:00.000000000 Z
14
+ date: 2024-01-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: actionpack
@@ -743,7 +743,9 @@ files:
743
743
  - config/initializers/wrap_parameters.rb
744
744
  - config/locales/de.yml
745
745
  - config/locales/en.yml
746
+ - config/locales/fr.yml
746
747
  - config/locales/nl.yml
748
+ - config/locales/sr.yml
747
749
  - config/routes.rb
748
750
  - lib/active_model_modules/array_attribute_valid_validator.rb
749
751
  - lib/active_model_modules/attribute_valid_validator.rb
@@ -829,7 +831,6 @@ files:
829
831
  - lib/quby/settings.rb
830
832
  - lib/quby/table_backend/range_tree.rb
831
833
  - lib/quby/version.rb
832
- - lib/tasks/codebook.rake
833
834
  - spec/active_model_modules/array_attribute_valid_validator_spec.rb
834
835
  - spec/active_model_modules/attribute_valid_validator_spec.rb
835
836
  - spec/active_model_modules/type_validator_spec.rb
@@ -947,7 +948,6 @@ files:
947
948
  - spec/quby/questionnaires/entities/score_schema_spec.rb
948
949
  - spec/quby/questionnaires/entities/sub_score_schema_spec.rb
949
950
  - spec/quby/questionnaires/entities/text_spec.rb
950
- - spec/quby/questionnaires/entities/textvar_spec.rb
951
951
  - spec/quby/questionnaires/repos/disk_repo_spec.rb
952
952
  - spec/quby/questionnaires/repos/memory_repo_spec.rb
953
953
  - spec/quby/range_categories_spec.rb
@@ -1019,7 +1019,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1019
1019
  - !ruby/object:Gem::Version
1020
1020
  version: '0'
1021
1021
  requirements: []
1022
- rubygems_version: 3.4.10
1022
+ rubygems_version: 3.4.22
1023
1023
  signing_key:
1024
1024
  specification_version: 4
1025
1025
  summary: Questionnaire engine
@@ -1141,7 +1141,6 @@ test_files:
1141
1141
  - spec/quby/questionnaires/entities/score_schema_spec.rb
1142
1142
  - spec/quby/questionnaires/entities/sub_score_schema_spec.rb
1143
1143
  - spec/quby/questionnaires/entities/text_spec.rb
1144
- - spec/quby/questionnaires/entities/textvar_spec.rb
1145
1144
  - spec/quby/questionnaires/repos/disk_repo_spec.rb
1146
1145
  - spec/quby/questionnaires/repos/memory_repo_spec.rb
1147
1146
  - spec/quby/range_categories_spec.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :codebook do
4
-
5
- desc "Export all questionnaire codebooks to tmp/codebooks/$key.txt"
6
- task :export => :environment do
7
- system("mkdir -p #{Rails.root}/tmp/codebooks")
8
-
9
- Questionnaire.all.each do |questionnaire|
10
- File.open("#{Rails.root}/tmp/codebooks/#{questionnaire.key}.txt", "w") do |file|
11
- file.puts(questionnaire.to_codebook)
12
- end
13
- end
14
- end
15
-
16
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Quby::Questionnaires::Entities
6
- describe Textvar do
7
- describe '#to_codebook' do
8
- let(:textvar) do
9
- # key is prefixed in lib/quby/questionnaires/entities/questionnaire.rb:248
10
- described_class.new key: :questkey_textvarkey, description: 'textvar description'
11
- end
12
-
13
- it 'exports the textvar key' do
14
- expect(textvar.to_codebook).to include('questkey_textvarkey')
15
- end
16
- it 'contains the description' do
17
- expect(textvar.to_codebook).to include('textvar description')
18
- end
19
- end
20
- end
21
- end