quby 4.0.4 → 5.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quby/questionnaires.rb +1 -0
- data/lib/quby/questionnaires/api.rb +5 -1
- data/lib/quby/questionnaires/deserializer.rb +433 -0
- data/lib/quby/questionnaires/dsl.rb +10 -15
- data/lib/quby/questionnaires/entities.rb +1 -0
- data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
- data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
- data/lib/quby/questionnaires/entities/definition.rb +3 -5
- data/lib/quby/questionnaires/entities/fields.rb +0 -15
- data/lib/quby/questionnaires/entities/question.rb +9 -32
- data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
- data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
- data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
- data/lib/quby/questionnaires/entities/score_calculation.rb +36 -3
- data/lib/quby/questionnaires/repos.rb +1 -0
- data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
- data/lib/quby/version.rb +1 -1
- data/spec/internal/log/test-events.log +0 -451
- data/spec/internal/log/test.log +0 -18003
- data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
- data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
- data/spec/quby/questionnaires/dsl_spec.rb +0 -9
- data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
- data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
- data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
- data/spec/quby/table_backend/range_tree_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- metadata +22 -139
- data/lib/quby/questionnaires/dsl/base.rb +0 -20
- data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
- data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
- data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -57
- data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
- data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
- data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
- data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
- data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -260
- data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
- data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
- data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
- data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-31.954.html +0 -207
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-31.954.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-59.938.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-59.938.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-08.700.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-08.700.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-11.550.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-11.550.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-14.413.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-14.413.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-17.275.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-17.275.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-20.191.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-20.191.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-23.042.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-23.042.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-25.927.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-25.927.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-28.735.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-28.735.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.422.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.422.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.738.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.738.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-41-16.971.html +0 -207
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-41-16.971.png +0 -0
- data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
- data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
- data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -66
- data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
- data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
- data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
- data/spec/support/examples_for_chart_builders.rb +0 -59
@@ -1,260 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/dsl/panel_builder'
|
4
|
-
require 'quby/questionnaires/dsl/table_builder'
|
5
|
-
require 'quby/questionnaires/dsl/question_builder'
|
6
|
-
require 'quby/questionnaires/dsl/score_builder'
|
7
|
-
require 'quby/questionnaires/dsl/charting/line_chart_builder'
|
8
|
-
require 'quby/questionnaires/dsl/charting/radar_chart_builder'
|
9
|
-
require 'quby/questionnaires/dsl/charting/bar_chart_builder'
|
10
|
-
require 'quby/questionnaires/dsl/charting/overview_chart_builder'
|
11
|
-
|
12
|
-
require_relative 'standardized_panel_generators'
|
13
|
-
|
14
|
-
module Quby
|
15
|
-
module Questionnaires
|
16
|
-
module DSL
|
17
|
-
class QuestionnaireBuilder
|
18
|
-
prepend CallsCustomMethods
|
19
|
-
include StandardizedPanelGenerators
|
20
|
-
include Helpers
|
21
|
-
|
22
|
-
def initialize(target_instance)
|
23
|
-
@questionnaire = target_instance
|
24
|
-
@default_question_options = {}
|
25
|
-
@custom_methods = {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def leave_page_alert(text)
|
29
|
-
@questionnaire.leave_page_alert = text
|
30
|
-
end
|
31
|
-
|
32
|
-
def key(key)
|
33
|
-
# no-op, key is now passed in to Questionnaire constructor
|
34
|
-
end
|
35
|
-
|
36
|
-
def roqua_keys(*keys)
|
37
|
-
@questionnaire.roqua_keys = keys
|
38
|
-
end
|
39
|
-
|
40
|
-
def do_not_check_key_clashes
|
41
|
-
@questionnaire.check_key_clashes = false
|
42
|
-
end
|
43
|
-
|
44
|
-
def do_not_check_score_keys_consistency
|
45
|
-
@questionnaire.check_score_keys_consistency = false
|
46
|
-
end
|
47
|
-
|
48
|
-
def do_not_validate_html
|
49
|
-
@questionnaire.validate_html = false
|
50
|
-
end
|
51
|
-
|
52
|
-
def title(title)
|
53
|
-
@questionnaire.title = title
|
54
|
-
end
|
55
|
-
|
56
|
-
def description(description)
|
57
|
-
@questionnaire.description = description
|
58
|
-
end
|
59
|
-
|
60
|
-
def outcome_description(description)
|
61
|
-
@questionnaire.outcome_description = description
|
62
|
-
end
|
63
|
-
|
64
|
-
def short_description(description)
|
65
|
-
@questionnaire.short_description = description
|
66
|
-
end
|
67
|
-
|
68
|
-
def version(key, notes)
|
69
|
-
# nothing, for forward compatibility with v5 (quby-compiler)
|
70
|
-
end
|
71
|
-
|
72
|
-
def sbg_key(sbg_key)
|
73
|
-
@questionnaire.sbg_key = sbg_key
|
74
|
-
end
|
75
|
-
|
76
|
-
def sbg_domain(sbg_code, outcome:, from: nil, till: nil, sbg_key: nil, primary: false)
|
77
|
-
@questionnaire.sbg_domains << {
|
78
|
-
sbg_code: sbg_code,
|
79
|
-
from: from,
|
80
|
-
till: till,
|
81
|
-
outcome: outcome,
|
82
|
-
sbg_key: sbg_key || @questionnaire.sbg_key,
|
83
|
-
primary: primary
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def abortable
|
88
|
-
@questionnaire.abortable = true
|
89
|
-
end
|
90
|
-
|
91
|
-
def allow_hotkeys(type = :all)
|
92
|
-
@questionnaire.allow_hotkeys = type
|
93
|
-
end
|
94
|
-
|
95
|
-
def license(type, licensor: nil)
|
96
|
-
@questionnaire.license = type
|
97
|
-
@questionnaire.licensor = licensor
|
98
|
-
end
|
99
|
-
|
100
|
-
def language(language)
|
101
|
-
@questionnaire.language = language
|
102
|
-
end
|
103
|
-
|
104
|
-
def respondent_types(*respondent_types)
|
105
|
-
@questionnaire.respondent_types = respondent_types
|
106
|
-
end
|
107
|
-
|
108
|
-
def tags(*tags)
|
109
|
-
@questionnaire.tags = tags
|
110
|
-
end
|
111
|
-
|
112
|
-
def outcome_regeneration_requested_at(timestamp)
|
113
|
-
@questionnaire.outcome_regeneration_requested_at = timestamp
|
114
|
-
end
|
115
|
-
|
116
|
-
def deactivate_answers_requested_at(timestamp)
|
117
|
-
@questionnaire.deactivate_answers_requested_at = timestamp
|
118
|
-
end
|
119
|
-
|
120
|
-
def enable_previous_questionnaire_button
|
121
|
-
@questionnaire.enable_previous_questionnaire_button = true
|
122
|
-
end
|
123
|
-
|
124
|
-
def renderer_version(version)
|
125
|
-
@questionnaire.renderer_version = version
|
126
|
-
end
|
127
|
-
|
128
|
-
def css(value)
|
129
|
-
@questionnaire.extra_css += value
|
130
|
-
end
|
131
|
-
|
132
|
-
def allow_switch_to_bulk(value=true)
|
133
|
-
@questionnaire.allow_switch_to_bulk = value
|
134
|
-
end
|
135
|
-
|
136
|
-
def default_answer_value(value)
|
137
|
-
@questionnaire.default_answer_value = value
|
138
|
-
end
|
139
|
-
|
140
|
-
def panel(title = nil, options = {}, &block)
|
141
|
-
panel = PanelBuilder.build(title, options.merge(default_panel_options), &block)
|
142
|
-
@questionnaire.add_panel(panel)
|
143
|
-
end
|
144
|
-
|
145
|
-
def custom_method(key, &block)
|
146
|
-
if PanelBuilder.new(nil, custom_methods: @custom_methods).respond_to? key
|
147
|
-
fail 'Custom method trying to override existing method'
|
148
|
-
end
|
149
|
-
@custom_methods[key] = block
|
150
|
-
end
|
151
|
-
|
152
|
-
def import_lookup_tree(key)
|
153
|
-
# nothing, for forwards compatibility with v5 (quby-compiler)
|
154
|
-
end
|
155
|
-
|
156
|
-
def add_lookup_tree(key, levels:, tree:)
|
157
|
-
@questionnaire.lookup_tables[key] = Quby::TableBackend::RangeTree.new(levels: levels, tree: tree)
|
158
|
-
end
|
159
|
-
|
160
|
-
def default_question_options(options = {})
|
161
|
-
@default_question_options.merge!(options)
|
162
|
-
end
|
163
|
-
|
164
|
-
# Short-circuit the question command to perform an implicit panel
|
165
|
-
def question(key, options = {}, &block)
|
166
|
-
panel(nil, default_panel_options) do
|
167
|
-
question(key, @default_question_options.merge(options).merge(questionnaire: @questionnaire), &block)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
# Short-circuit the text command to perform an implicit panel
|
172
|
-
def text(value, options = {})
|
173
|
-
panel(nil, default_panel_options) do
|
174
|
-
text(value, options)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
# Short-circuit the table command to perform an implicit panel
|
179
|
-
def table(options = {}, &block)
|
180
|
-
panel(nil, default_panel_options) do
|
181
|
-
table(options, &block)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
# variable :totaal do
|
186
|
-
# # Plain old Ruby code here, executed in the scope of the answer
|
187
|
-
# # variables are private to the score calculation
|
188
|
-
# q01 + q02 + q03
|
189
|
-
# end
|
190
|
-
def variable(key, options = {}, &block)
|
191
|
-
s = ScoreBuilder.new(key, options, &block)
|
192
|
-
@questionnaire.add_score_calculation s.build
|
193
|
-
end
|
194
|
-
|
195
|
-
def score(key, options = {}, &block)
|
196
|
-
@questionnaire.errors.add "Score #{key}", 'misses label in score call' if options[:label].blank?
|
197
|
-
schema = options.delete(:schema)
|
198
|
-
@questionnaire.add_score_schema(key, options[:label], schema) if schema.present?
|
199
|
-
variable(key, options.reverse_merge(score: true), &block)
|
200
|
-
end
|
201
|
-
|
202
|
-
def score_schema(key, label, options)
|
203
|
-
@questionnaire.add_score_schema(key, label, options)
|
204
|
-
end
|
205
|
-
|
206
|
-
def attention(options = {}, &block)
|
207
|
-
variable(:attention, options.reverse_merge(action: true), &block)
|
208
|
-
end
|
209
|
-
|
210
|
-
def alarm(options = {}, &block)
|
211
|
-
variable(:alarm, options.reverse_merge(action: true), &block)
|
212
|
-
end
|
213
|
-
|
214
|
-
def completion(options = {}, &block)
|
215
|
-
variable(:completion, options.reverse_merge(completion: true), &block)
|
216
|
-
end
|
217
|
-
|
218
|
-
def overview_chart(*args, &block)
|
219
|
-
raise "Cannot define more than one overview chart" if @questionnaire.charts.overview.present?
|
220
|
-
builder = OverviewChartBuilder.new(@questionnaire, *args)
|
221
|
-
@questionnaire.charts.overview = builder.build(&block)
|
222
|
-
end
|
223
|
-
|
224
|
-
def line_chart(*args, &block)
|
225
|
-
builder = LineChartBuilder.new(@questionnaire, *args)
|
226
|
-
@questionnaire.add_chart(builder.build(&block))
|
227
|
-
end
|
228
|
-
|
229
|
-
def bar_chart(*args, &block)
|
230
|
-
builder = BarChartBuilder.new(@questionnaire, *args)
|
231
|
-
@questionnaire.add_chart(builder.build(&block))
|
232
|
-
end
|
233
|
-
|
234
|
-
def radar_chart(*args, &block)
|
235
|
-
builder = RadarChartBuilder.new(@questionnaire, *args)
|
236
|
-
@questionnaire.add_chart(builder.build(&block))
|
237
|
-
end
|
238
|
-
|
239
|
-
def flag(flag_options)
|
240
|
-
@questionnaire.add_flag flag_options
|
241
|
-
end
|
242
|
-
|
243
|
-
def textvar(textvar_options)
|
244
|
-
@questionnaire.add_textvar textvar_options
|
245
|
-
end
|
246
|
-
|
247
|
-
def outcome_table(table_options)
|
248
|
-
@questionnaire.add_outcome_table table_options
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
|
253
|
-
def default_panel_options
|
254
|
-
{questionnaire: @questionnaire, default_question_options: @default_question_options,
|
255
|
-
custom_methods: @custom_methods}
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
@@ -1,179 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module Questions
|
7
|
-
class Base < ::Quby::Questionnaires::DSL::Base
|
8
|
-
attr_reader :key
|
9
|
-
attr_reader :title
|
10
|
-
attr_reader :type
|
11
|
-
attr_reader :questionnaire
|
12
|
-
|
13
|
-
def initialize(key, options = {})
|
14
|
-
@questionnaire = options[:questionnaire]
|
15
|
-
end
|
16
|
-
|
17
|
-
def build
|
18
|
-
@question
|
19
|
-
end
|
20
|
-
|
21
|
-
def title(value)
|
22
|
-
@question.title = value
|
23
|
-
end
|
24
|
-
|
25
|
-
def context_free_title(value)
|
26
|
-
@question.context_free_title = value
|
27
|
-
end
|
28
|
-
|
29
|
-
def description(value)
|
30
|
-
@question.description = value
|
31
|
-
end
|
32
|
-
|
33
|
-
def presentation(value)
|
34
|
-
@question.presentation = value
|
35
|
-
end
|
36
|
-
|
37
|
-
def hidden(value = true)
|
38
|
-
@question.hidden = value
|
39
|
-
end
|
40
|
-
|
41
|
-
def depends_on(keys)
|
42
|
-
@question.set_depends_on(keys)
|
43
|
-
end
|
44
|
-
|
45
|
-
def default_position(value)
|
46
|
-
@question.default_position = value
|
47
|
-
end
|
48
|
-
|
49
|
-
def validates_presence_of_answer(options = {})
|
50
|
-
@question.validations ||= []
|
51
|
-
@question.validations << {type: :requires_answer}.reverse_merge(options)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
module RegexpValidations
|
56
|
-
def validates_format_with(regexp, options = {})
|
57
|
-
@question.validations ||= []
|
58
|
-
@question.validations << {type: :regexp, matcher: regexp}.reverse_merge(options)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
module MinMaxValidations
|
63
|
-
def validates_minimum(value, options = {})
|
64
|
-
subtype = @question.type == :date ? :date : :number
|
65
|
-
@question.validations ||= []
|
66
|
-
@question.validations << {type: :minimum, value: value, subtype: subtype}.reverse_merge(options)
|
67
|
-
end
|
68
|
-
|
69
|
-
def validates_maximum(value, options = {})
|
70
|
-
subtype = @question.type == :date ? :date : :number
|
71
|
-
@question.validations ||= []
|
72
|
-
@question.validations << {type: :maximum, value: value, subtype: subtype}.reverse_merge(options)
|
73
|
-
end
|
74
|
-
|
75
|
-
def validates_in_range(range, options = {})
|
76
|
-
subtype = @question.type == :date ? :date : :number
|
77
|
-
@question.validations ||= []
|
78
|
-
@question.validations << {type: :minimum, value: range.first, subtype: subtype}.reverse_merge(options)
|
79
|
-
@question.validations << {type: :maximum, value: range.last, subtype: subtype}.reverse_merge(options)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
module Labeling
|
84
|
-
def label(value)
|
85
|
-
@question.labels << value
|
86
|
-
end
|
87
|
-
|
88
|
-
# deprecated
|
89
|
-
def left_label(value)
|
90
|
-
@question.labels.unshift(value)
|
91
|
-
end
|
92
|
-
|
93
|
-
# deprecated
|
94
|
-
def right_label(value)
|
95
|
-
@question.labels << value
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
module MultipleChoice
|
100
|
-
def option(key, options = {}, &block)
|
101
|
-
question_option = Entities::QuestionOption.new(key, @question, options)
|
102
|
-
if @questionnaire.key_in_use?(question_option.input_key) || @question.key_in_use?(question_option.input_key)
|
103
|
-
fail "#{questionnaire.key}:#{@question.key}:#{question_option.key}: " \
|
104
|
-
"A question or option with input key #{question_option.input_key} is already defined."
|
105
|
-
end
|
106
|
-
|
107
|
-
@question.options << question_option
|
108
|
-
instance_eval(&block) if block
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
module Subquestions
|
113
|
-
def initialize(key, options = {}, &block)
|
114
|
-
super
|
115
|
-
@default_question_options = options[:default_question_options] || {}
|
116
|
-
@title_question = nil
|
117
|
-
end
|
118
|
-
|
119
|
-
def build
|
120
|
-
if @title_question
|
121
|
-
@question.options.last.questions << @title_question
|
122
|
-
@title_question = nil
|
123
|
-
end
|
124
|
-
|
125
|
-
super
|
126
|
-
end
|
127
|
-
|
128
|
-
def title_question(key, options = {}, &block)
|
129
|
-
options = @default_question_options.merge({depends_on: @question.key,
|
130
|
-
questionnaire: @questionnaire,
|
131
|
-
parent: @question,
|
132
|
-
presentation: :next_to_title,
|
133
|
-
allow_blank_titles: @question.allow_blank_titles}.merge(options))
|
134
|
-
|
135
|
-
check_question_keys_uniqueness key, options, @questionnaire
|
136
|
-
|
137
|
-
question = QuestionBuilder.build(key, options, &block)
|
138
|
-
|
139
|
-
@questionnaire.register_question(question)
|
140
|
-
@title_question = question
|
141
|
-
end
|
142
|
-
|
143
|
-
def question(key, options = {}, &block)
|
144
|
-
options = @default_question_options.merge(options)
|
145
|
-
.merge(questionnaire: @questionnaire,
|
146
|
-
parent: @question,
|
147
|
-
parent_option_key: @question.options.last.key)
|
148
|
-
|
149
|
-
check_question_keys_uniqueness key, options, @questionnaire
|
150
|
-
|
151
|
-
question = QuestionBuilder.build(key, options, &block)
|
152
|
-
|
153
|
-
@questionnaire.register_question(question)
|
154
|
-
@question.options.last.questions << question
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
module InnerTitles
|
159
|
-
def inner_title(value)
|
160
|
-
question_option = Entities::QuestionOption.new(nil, @question, inner_title: true, description: value)
|
161
|
-
@question.options << question_option
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
module Units
|
166
|
-
def unit(value)
|
167
|
-
@question.unit = value
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
module Sizes
|
172
|
-
def size(value)
|
173
|
-
@question.size = value
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module Questions
|
7
|
-
class CheckboxQuestionBuilder < Base
|
8
|
-
include MultipleChoice
|
9
|
-
include Subquestions
|
10
|
-
include InnerTitles
|
11
|
-
|
12
|
-
def initialize(key, options = {}, &block)
|
13
|
-
super
|
14
|
-
@question = Entities::Questions::CheckboxQuestion.new(key, options)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|