Class: Quby::Questionnaires::DSL::QuestionnaireBuilder
Instance Attribute Summary
#custom_methods
Instance Method Summary
collapse
-
#abortable ⇒ Object
-
#alarm(options = {}, &block) ⇒ Object
-
#allow_hotkeys(type = :all) ⇒ Object
-
#allow_switch_to_bulk(value = true) ⇒ Object
-
#attention(options = {}, &block) ⇒ Object
-
#bar_chart(*args, &block) ⇒ Object
-
#completion(options = {}, &block) ⇒ Object
-
#css(value) ⇒ Object
-
#custom_method(key, &block) ⇒ Object
-
#deactivate_answers_requested_at(timestamp) ⇒ Object
-
#default_answer_value(value) ⇒ Object
-
#default_question_options(options = {}) ⇒ Object
-
#description(description) ⇒ Object
-
#do_not_check_key_clashes ⇒ Object
-
#do_not_check_score_keys_consistency ⇒ Object
-
#do_not_validate_html ⇒ Object
-
#enable_previous_questionnaire_button ⇒ Object
-
#flag(flag_options) ⇒ Object
-
#initialize(target_instance) ⇒ QuestionnaireBuilder
constructor
A new instance of QuestionnaireBuilder.
-
#key(key) ⇒ Object
-
#language(language) ⇒ Object
-
#leave_page_alert(text) ⇒ Object
-
#license(type, licensor: nil) ⇒ Object
-
#line_chart(*args, &block) ⇒ Object
-
#outcome_description(description) ⇒ Object
-
#outcome_regeneration_requested_at(timestamp) ⇒ Object
-
#outcome_table(table_options) ⇒ Object
-
#overview_chart(*args, &block) ⇒ Object
-
#panel(title = nil, options = {}, &block) ⇒ Object
-
#question(key, options = {}, &block) ⇒ Object
Short-circuit the question command to perform an implicit panel.
-
#radar_chart(*args, &block) ⇒ Object
-
#renderer_version(version) ⇒ Object
-
#respondent_types(*respondent_types) ⇒ Object
-
#roqua_keys(*keys) ⇒ Object
-
#sbg_domain(sbg_code, outcome:, from: nil, till: nil, sbg_key: nil, primary: false) ⇒ Object
-
#sbg_key(sbg_key) ⇒ Object
-
#score(key, options = {}, &block) ⇒ Object
-
#score_schema(key, label, options) ⇒ Object
-
#short_description(description) ⇒ Object
-
#table(options = {}, &block) ⇒ Object
Short-circuit the table command to perform an implicit panel.
-
#tags(*tags) ⇒ Object
-
#text(value, options = {}) ⇒ Object
Short-circuit the text command to perform an implicit panel.
-
#textvar(textvar_options) ⇒ Object
-
#title(title) ⇒ Object
-
#variable(key, options = {}, &block) ⇒ Object
variable :totaal do # Plain old Ruby code here, executed in the scope of the answer # variables are private to the score calculation q01 + q02 + q03 end.
Methods included from Helpers
#check_question_keys_uniqueness, #image_alt, #image_tag, #video_tag
#end_panel, #informal_end_panel, #start_panel
#method_missing, #respond_to_missing?
Constructor Details
Returns a new instance of QuestionnaireBuilder.
22
23
24
25
26
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 22
def initialize(target_instance)
@questionnaire = target_instance
@default_question_options = {}
@custom_methods = {}
end
|
Instance Method Details
#abortable ⇒ Object
83
84
85
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 83
def abortable
@questionnaire.abortable = true
end
|
#alarm(options = {}, &block) ⇒ Object
198
199
200
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 198
def alarm(options = {}, &block)
variable(:alarm, options.reverse_merge(action: true), &block)
end
|
#allow_hotkeys(type = :all) ⇒ Object
87
88
89
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 87
def allow_hotkeys(type = :all)
@questionnaire.allow_hotkeys = type
end
|
#allow_switch_to_bulk(value = true) ⇒ Object
128
129
130
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 128
def allow_switch_to_bulk(value=true)
@questionnaire.allow_switch_to_bulk = value
end
|
#attention(options = {}, &block) ⇒ Object
194
195
196
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 194
def attention(options = {}, &block)
variable(:attention, options.reverse_merge(action: true), &block)
end
|
#bar_chart(*args, &block) ⇒ Object
217
218
219
220
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 217
def bar_chart(*args, &block)
builder = BarChartBuilder.new(@questionnaire, *args)
@questionnaire.add_chart(builder.build(&block))
end
|
#completion(options = {}, &block) ⇒ Object
202
203
204
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 202
def completion(options = {}, &block)
variable(:completion, options.reverse_merge(completion: true), &block)
end
|
#css(value) ⇒ Object
124
125
126
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 124
def css(value)
@questionnaire. += value
end
|
#custom_method(key, &block) ⇒ Object
141
142
143
144
145
146
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 141
def custom_method(key, &block)
if PanelBuilder.new(nil, custom_methods: @custom_methods).respond_to? key
fail 'Custom method trying to override existing method'
end
@custom_methods[key] = block
end
|
#deactivate_answers_requested_at(timestamp) ⇒ Object
112
113
114
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 112
def deactivate_answers_requested_at(timestamp)
@questionnaire.deactivate_answers_requested_at = timestamp
end
|
#default_answer_value(value) ⇒ Object
132
133
134
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 132
def default_answer_value(value)
@questionnaire.default_answer_value = value
end
|
#default_question_options(options = {}) ⇒ Object
148
149
150
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 148
def default_question_options(options = {})
@default_question_options.merge!(options)
end
|
#description(description) ⇒ Object
56
57
58
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 56
def description(description)
@questionnaire.description = description
end
|
#do_not_check_key_clashes ⇒ Object
40
41
42
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 40
def do_not_check_key_clashes
@questionnaire.check_key_clashes = false
end
|
#do_not_check_score_keys_consistency ⇒ Object
44
45
46
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 44
def do_not_check_score_keys_consistency
@questionnaire.check_score_keys_consistency = false
end
|
#do_not_validate_html ⇒ Object
48
49
50
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 48
def do_not_validate_html
@questionnaire.validate_html = false
end
|
116
117
118
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 116
def enable_previous_questionnaire_button
@questionnaire.enable_previous_questionnaire_button = true
end
|
#flag(flag_options) ⇒ Object
227
228
229
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 227
def flag(flag_options)
@questionnaire.add_flag flag_options
end
|
#key(key) ⇒ Object
32
33
34
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 32
def key(key)
end
|
#language(language) ⇒ Object
96
97
98
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 96
def language(language)
@questionnaire.language = language
end
|
#leave_page_alert(text) ⇒ Object
28
29
30
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 28
def leave_page_alert(text)
@questionnaire.leave_page_alert = text
end
|
#license(type, licensor: nil) ⇒ Object
91
92
93
94
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 91
def license(type, licensor: nil)
@questionnaire.license = type
@questionnaire.licensor = licensor
end
|
#line_chart(*args, &block) ⇒ Object
212
213
214
215
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 212
def line_chart(*args, &block)
builder = LineChartBuilder.new(@questionnaire, *args)
@questionnaire.add_chart(builder.build(&block))
end
|
#outcome_description(description) ⇒ Object
60
61
62
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 60
def outcome_description(description)
@questionnaire.outcome_description = description
end
|
#outcome_regeneration_requested_at(timestamp) ⇒ Object
108
109
110
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 108
def outcome_regeneration_requested_at(timestamp)
@questionnaire.outcome_regeneration_requested_at = timestamp
end
|
#outcome_table(table_options) ⇒ Object
235
236
237
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 235
def outcome_table(table_options)
@questionnaire.add_outcome_table table_options
end
|
#overview_chart(*args, &block) ⇒ Object
206
207
208
209
210
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 206
def overview_chart(*args, &block)
raise "Cannot define more than one overview chart" if @questionnaire.charts.overview.present?
builder = OverviewChartBuilder.new(@questionnaire, *args)
@questionnaire.charts.overview = builder.build(&block)
end
|
#panel(title = nil, options = {}, &block) ⇒ Object
136
137
138
139
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 136
def panel(title = nil, options = {}, &block)
panel = PanelBuilder.build(title, options.merge(default_panel_options), &block)
@questionnaire.add_panel(panel)
end
|
#question(key, options = {}, &block) ⇒ Object
Short-circuit the question command to perform an implicit panel
153
154
155
156
157
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 153
def question(key, options = {}, &block)
panel(nil, default_panel_options) do
question(key, @default_question_options.merge(options).merge(questionnaire: @questionnaire), &block)
end
end
|
#radar_chart(*args, &block) ⇒ Object
222
223
224
225
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 222
def radar_chart(*args, &block)
builder = RadarChartBuilder.new(@questionnaire, *args)
@questionnaire.add_chart(builder.build(&block))
end
|
#renderer_version(version) ⇒ Object
120
121
122
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 120
def renderer_version(version)
@questionnaire.renderer_version = version
end
|
#respondent_types(*respondent_types) ⇒ Object
100
101
102
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 100
def respondent_types(*respondent_types)
@questionnaire.respondent_types = respondent_types
end
|
#roqua_keys(*keys) ⇒ Object
36
37
38
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 36
def roqua_keys(*keys)
@questionnaire.roqua_keys = keys
end
|
#sbg_domain(sbg_code, outcome:, from: nil, till: nil, sbg_key: nil, primary: false) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 72
def sbg_domain(sbg_code, outcome:, from: nil, till: nil, sbg_key: nil, primary: false)
@questionnaire.sbg_domains << {
sbg_code: sbg_code,
from: from,
till: till,
outcome: outcome,
sbg_key: sbg_key || @questionnaire.sbg_key,
primary: primary
}
end
|
#sbg_key(sbg_key) ⇒ Object
68
69
70
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 68
def sbg_key(sbg_key)
@questionnaire.sbg_key = sbg_key
end
|
#score(key, options = {}, &block) ⇒ Object
183
184
185
186
187
188
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 183
def score(key, options = {}, &block)
@questionnaire.errors.add "Score #{key}", 'misses label in score call' if options[:label].blank?
schema = options.delete(:schema)
@questionnaire.add_score_schema(key, options[:label], schema) if schema.present?
variable(key, options.reverse_merge(score: true), &block)
end
|
#score_schema(key, label, options) ⇒ Object
190
191
192
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 190
def score_schema(key, label, options)
@questionnaire.add_score_schema(key, label, options)
end
|
#short_description(description) ⇒ Object
64
65
66
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 64
def short_description(description)
@questionnaire.short_description = description
end
|
#table(options = {}, &block) ⇒ Object
Short-circuit the table command to perform an implicit panel
167
168
169
170
171
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 167
def table(options = {}, &block)
panel(nil, default_panel_options) do
table(options, &block)
end
end
|
104
105
106
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 104
def tags(*tags)
@questionnaire.tags = tags
end
|
#text(value, options = {}) ⇒ Object
Short-circuit the text command to perform an implicit panel
160
161
162
163
164
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 160
def text(value, options = {})
panel(nil, default_panel_options) do
text(value, options)
end
end
|
#textvar(textvar_options) ⇒ Object
231
232
233
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 231
def textvar(textvar_options)
@questionnaire.add_textvar textvar_options
end
|
#title(title) ⇒ Object
52
53
54
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 52
def title(title)
@questionnaire.title = title
end
|
#variable(key, options = {}, &block) ⇒ Object
variable :totaal do
q01 + q02 + q03
end
178
179
180
181
|
# File 'lib/quby/questionnaires/dsl/questionnaire_builder.rb', line 178
def variable(key, options = {}, &block)
s = ScoreBuilder.new(key, options, &block)
@questionnaire.add_score_calculation s.build
end
|