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,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/dsl/helpers'
|
4
|
-
require 'quby/questionnaires/dsl/calls_custom_methods'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class Base
|
10
|
-
include Helpers
|
11
|
-
|
12
|
-
def self.build(*args, &block)
|
13
|
-
builder = new(*args)
|
14
|
-
builder.instance_eval(&block) if block
|
15
|
-
builder.build
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module CallsCustomMethods
|
7
|
-
attr_reader :custom_methods
|
8
|
-
|
9
|
-
def initialize(*args)
|
10
|
-
options = args.last.is_a?(::Hash) ? args.last : {}
|
11
|
-
@custom_methods = options[:custom_methods] || {}
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def method_missing(method_sym, *args, &block)
|
16
|
-
if @custom_methods.key? method_sym
|
17
|
-
instance_exec(*args, &custom_methods[method_sym])
|
18
|
-
else
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def respond_to_missing?(method_name, include_private = false)
|
24
|
-
custom_methods.key?(method_name) || super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/bar_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class BarChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::BarChart)
|
11
|
-
|
12
|
-
def plotline(value, color)
|
13
|
-
@chart.plotlines << {value: value, color: color, width: 1, zIndex: 3}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities'
|
4
|
-
|
5
|
-
module Quby
|
6
|
-
module Questionnaires
|
7
|
-
module DSL
|
8
|
-
class ChartBuilder
|
9
|
-
# rubocop:disable AccessorMethodName
|
10
|
-
def self.set_chart_class(chart_class)
|
11
|
-
@chart_class = chart_class
|
12
|
-
end
|
13
|
-
# rubocop:enable AccessorMethodName
|
14
|
-
|
15
|
-
def self.chart_class
|
16
|
-
@chart_class
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(questionnaire, key, options = {})
|
20
|
-
@chart = self.class.chart_class.new(key, options)
|
21
|
-
@questionnaire = questionnaire
|
22
|
-
end
|
23
|
-
|
24
|
-
def title(title)
|
25
|
-
@chart.title = title
|
26
|
-
end
|
27
|
-
|
28
|
-
def range(range)
|
29
|
-
@chart.y_range = range
|
30
|
-
end
|
31
|
-
|
32
|
-
def tick_interval(tick_interval)
|
33
|
-
@chart.tick_interval = tick_interval
|
34
|
-
end
|
35
|
-
|
36
|
-
def y_categories(y_categories)
|
37
|
-
@chart.y_categories = y_categories
|
38
|
-
end
|
39
|
-
|
40
|
-
def y_range_categories(*y_range_categories)
|
41
|
-
@chart.y_range_categories = RangeCategories.new(*y_range_categories).as_range_hash
|
42
|
-
end
|
43
|
-
|
44
|
-
def plotband(from, to, color)
|
45
|
-
@chart.plotbands << {from: from, to: to, color: color}
|
46
|
-
end
|
47
|
-
|
48
|
-
def plot(key, options = {})
|
49
|
-
unless plottable = @questionnaire.find_plottable(key)
|
50
|
-
fail "Questionnaire #{@questionnaire.key} chart #{@chart.key} references unknown score or question #{key}"
|
51
|
-
end
|
52
|
-
|
53
|
-
configure_options plottable, options
|
54
|
-
|
55
|
-
@chart.plottables << Entities::Charting::Plottable.new(plottable.key, options)
|
56
|
-
end
|
57
|
-
|
58
|
-
def chart_type(type)
|
59
|
-
@chart.chart_type = type
|
60
|
-
end
|
61
|
-
|
62
|
-
def build(&block)
|
63
|
-
instance_eval(&block)
|
64
|
-
validate!
|
65
|
-
@chart
|
66
|
-
end
|
67
|
-
|
68
|
-
def validate!
|
69
|
-
if @chart.y_categories.present? && @chart.y_range.present? &&
|
70
|
-
@chart.y_range != (0..(@chart.y_categories.count - 1))
|
71
|
-
fail ArgumentError, 'Y_categories size and range do not match'
|
72
|
-
end
|
73
|
-
|
74
|
-
true
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def configure_options(plottable, options)
|
80
|
-
case plottable
|
81
|
-
when Entities::ScoreCalculation
|
82
|
-
options.reverse_merge! plottable.options
|
83
|
-
when Entities::Question
|
84
|
-
options[:label] ||= plottable.title
|
85
|
-
end
|
86
|
-
options[:questionnaire_key] = @questionnaire.key
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/line_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class LineChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::LineChart)
|
11
|
-
|
12
|
-
def y_axis_label(label)
|
13
|
-
@chart.y_label = label
|
14
|
-
end
|
15
|
-
|
16
|
-
def tonality(value)
|
17
|
-
@chart.tonality = value
|
18
|
-
end
|
19
|
-
|
20
|
-
# value - Number or a hash `{from_age..to_age => {female: 5, default: 4}, .., default: { default: 3 }}`
|
21
|
-
# block - deprecated.
|
22
|
-
def baseline(value = nil, &block)
|
23
|
-
unless value.nil? ^ block.nil?
|
24
|
-
fail ArgumentError, "Must give either value or a block"
|
25
|
-
end
|
26
|
-
|
27
|
-
if value && value.is_a?(Hash)
|
28
|
-
@chart.baseline = ->(age, gender) {
|
29
|
-
age_match = value.find { |age_range, _v| age && age_range === age }
|
30
|
-
hash_by_gender = (age_match&.last || value.stringify_keys["default"])
|
31
|
-
|
32
|
-
gender_match = hash_by_gender.find {|gender_key, _v| gender && gender_key.to_s == gender.to_s }
|
33
|
-
gender_match&.last || hash_by_gender.stringify_keys['default']
|
34
|
-
}
|
35
|
-
elsif value
|
36
|
-
@chart.baseline = ->(age, gender) { value }
|
37
|
-
end
|
38
|
-
|
39
|
-
if block
|
40
|
-
if block.arity != 2
|
41
|
-
fail ArgumentError, "Given block must take two arguments"
|
42
|
-
end
|
43
|
-
@chart.baseline = block
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def clinically_relevant_change(value)
|
48
|
-
@chart.clinically_relevant_change = value
|
49
|
-
end
|
50
|
-
|
51
|
-
def validate!
|
52
|
-
fail "Chart #{@chart.key} has no range specified" unless @chart.y_range
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'quby/questionnaires/entities/charting/overview_chart'
|
2
|
-
require_relative 'chart_builder'
|
3
|
-
|
4
|
-
module Quby
|
5
|
-
module Questionnaires
|
6
|
-
module DSL
|
7
|
-
class OverviewChartBuilder < ChartBuilder
|
8
|
-
set_chart_class(Entities::Charting::OverviewChart)
|
9
|
-
|
10
|
-
def initialize(questionnaire, options = {})
|
11
|
-
@questionnaire = questionnaire
|
12
|
-
@chart = self.class.chart_class.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def subscore(key)
|
16
|
-
@chart.subscore = key
|
17
|
-
end
|
18
|
-
|
19
|
-
def y_max(value)
|
20
|
-
@chart.y_max = value
|
21
|
-
end
|
22
|
-
|
23
|
-
def validate!
|
24
|
-
fail ArgumentError, "subscore not specified" unless @chart.subscore.present?
|
25
|
-
fail ArgumentError, "y_max not specified" unless @chart.y_max.present?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/radar_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class RadarChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::RadarChart)
|
11
|
-
|
12
|
-
def plotline(value, color)
|
13
|
-
@chart.plotlines << {value: value, color: color, width: 1, zIndex: 3}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module Helpers
|
7
|
-
def image_tag(*args)
|
8
|
-
options = args.extract_options!
|
9
|
-
|
10
|
-
ActionController::Base.helpers.image_tag(
|
11
|
-
*args, options.reverse_merge(alt: image_alt(args.first))
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Copied from ActionController::Base.helpers.image_alt, because it will be removed from Rails 6.0, but we want
|
16
|
-
# to keep using this functionality
|
17
|
-
def image_alt(source)
|
18
|
-
File.basename(source, ".*").sub(/-[[:xdigit:]]{32,64}\z/, "").tr("-_", " ").capitalize
|
19
|
-
end
|
20
|
-
|
21
|
-
def check_question_keys_uniqueness(key, options, questionnaire)
|
22
|
-
keys = QuestionBuilder.build(key, options).claimed_keys
|
23
|
-
if keys.any? { |k| questionnaire.key_in_use? k }
|
24
|
-
fail "#{questionnaire.key}:#{key}: A question or option with input key #{key} is already defined."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def video_tag(*urls, poster: nil, autoplay: false, loop: false)
|
29
|
-
# assume the file extension is the video format
|
30
|
-
# otherwise, the host's declared mime type is used to figure out compatibility
|
31
|
-
# which is usually wrong
|
32
|
-
sources = urls.map { |url| [url, url.match(/[^\.]*\z/)&.[](0).downcase] }
|
33
|
-
sources.each { |_url, ext| raise 'unknown video url file extension' unless %w[mp4 webm].include?(ext) }
|
34
|
-
|
35
|
-
ActionController::Base.helpers.tag.video\
|
36
|
-
width: '100%',
|
37
|
-
preload: 'none',
|
38
|
-
poster: poster,
|
39
|
-
loop: loop,
|
40
|
-
autoplay: autoplay,
|
41
|
-
muted: autoplay,
|
42
|
-
controls: '' do |tag|
|
43
|
-
sources.map { |url, ext| tag.source src: url, type: "video/#{ext}" }
|
44
|
-
.append(I18n.t('video_not_supported'))
|
45
|
-
.yield_self(&tag.method(:safe_join))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities'
|
4
|
-
|
5
|
-
module Quby
|
6
|
-
module Questionnaires
|
7
|
-
module DSL
|
8
|
-
class PanelBuilder < Base
|
9
|
-
attr_reader :title
|
10
|
-
attr_reader :questionnaire
|
11
|
-
|
12
|
-
def initialize(title, options = {})
|
13
|
-
@panel = Entities::Panel.new(options.merge(title: title, items: []))
|
14
|
-
@default_question_options = options[:default_question_options] || {}
|
15
|
-
@questionnaire = options[:questionnaire]
|
16
|
-
@custom_methods = options[:custom_methods] || {}
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
@panel
|
21
|
-
end
|
22
|
-
|
23
|
-
def title(value)
|
24
|
-
@panel.title = value
|
25
|
-
end
|
26
|
-
|
27
|
-
def text(value, options = {})
|
28
|
-
@panel.items << Entities::Text.new(value.to_s, options)
|
29
|
-
end
|
30
|
-
|
31
|
-
def html(value)
|
32
|
-
@panel.items << Entities::Text.new('', html_content: value.to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
def raw_html(value)
|
36
|
-
@panel.items << Entities::Text.new('', raw_content: value.to_s)
|
37
|
-
end
|
38
|
-
|
39
|
-
def video(*urls, **options)
|
40
|
-
video_html = video_tag *urls, **options
|
41
|
-
@panel.items << Entities::Text.new('', raw_content: video_html)
|
42
|
-
end
|
43
|
-
|
44
|
-
def default_question_options(options = {})
|
45
|
-
@default_question_options = @default_question_options.merge(options)
|
46
|
-
end
|
47
|
-
|
48
|
-
def question(key, options = {}, &block)
|
49
|
-
options = @default_question_options.merge(options).merge(questionnaire: @panel.questionnaire)
|
50
|
-
|
51
|
-
check_question_keys_uniqueness key, options, @questionnaire
|
52
|
-
|
53
|
-
question = QuestionBuilder.build(key, options, &block)
|
54
|
-
|
55
|
-
@questionnaire.register_question(question)
|
56
|
-
@panel.items << question
|
57
|
-
end
|
58
|
-
|
59
|
-
def table(options = {}, &block)
|
60
|
-
table_builder = TableBuilder.new(@panel, options.merge(questionnaire: @panel.questionnaire,
|
61
|
-
default_question_options: @default_question_options,
|
62
|
-
custom_methods: @custom_methods))
|
63
|
-
table_builder.instance_eval(&block) if block
|
64
|
-
end
|
65
|
-
|
66
|
-
def method_missing(method_sym, *args, &block)
|
67
|
-
if @custom_methods.key? method_sym
|
68
|
-
instance_exec(*args, &@custom_methods[method_sym])
|
69
|
-
else
|
70
|
-
super
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def respond_to_missing?(method_name, include_private = false)
|
75
|
-
@custom_methods.key?(method_name) || super
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities'
|
4
|
-
|
5
|
-
require 'quby/questionnaires/dsl/questions/base'
|
6
|
-
require 'quby/questionnaires/dsl/questions/checkbox_question_builder'
|
7
|
-
require 'quby/questionnaires/dsl/questions/date_question_builder'
|
8
|
-
require 'quby/questionnaires/dsl/questions/deprecated_question_builder'
|
9
|
-
require 'quby/questionnaires/dsl/questions/float_question_builder'
|
10
|
-
require 'quby/questionnaires/dsl/questions/integer_question_builder'
|
11
|
-
require 'quby/questionnaires/dsl/questions/radio_question_builder'
|
12
|
-
require 'quby/questionnaires/dsl/questions/select_question_builder'
|
13
|
-
require 'quby/questionnaires/dsl/questions/string_question_builder'
|
14
|
-
require 'quby/questionnaires/dsl/questions/text_question_builder'
|
15
|
-
|
16
|
-
module Quby
|
17
|
-
module Questionnaires
|
18
|
-
module DSL
|
19
|
-
module QuestionBuilder
|
20
|
-
include Helpers
|
21
|
-
BUILDERS = {
|
22
|
-
'string' => Questions::StringQuestionBuilder,
|
23
|
-
'textarea' => Questions::TextQuestionBuilder,
|
24
|
-
'integer' => Questions::IntegerQuestionBuilder,
|
25
|
-
'float' => Questions::FloatQuestionBuilder,
|
26
|
-
'radio' => Questions::RadioQuestionBuilder,
|
27
|
-
'scale' => Questions::RadioQuestionBuilder,
|
28
|
-
'select' => Questions::SelectQuestionBuilder,
|
29
|
-
'check_box' => Questions::CheckboxQuestionBuilder,
|
30
|
-
'date' => Questions::DateQuestionBuilder,
|
31
|
-
'hidden' => Questions::DeprecatedQuestionBuilder
|
32
|
-
}
|
33
|
-
|
34
|
-
def self.build(key, options = {}, &block)
|
35
|
-
BUILDERS.fetch(options.fetch(:type).to_s).build(key, options, &block)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|