quby 4.0.3 → 5.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/quby/questionnaires.rb +1 -0
  3. data/lib/quby/questionnaires/api.rb +5 -1
  4. data/lib/quby/questionnaires/deserializer.rb +433 -0
  5. data/lib/quby/questionnaires/dsl.rb +10 -15
  6. data/lib/quby/questionnaires/entities.rb +1 -0
  7. data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
  8. data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
  9. data/lib/quby/questionnaires/entities/definition.rb +3 -5
  10. data/lib/quby/questionnaires/entities/fields.rb +0 -15
  11. data/lib/quby/questionnaires/entities/question.rb +9 -32
  12. data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
  13. data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
  14. data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
  15. data/lib/quby/questionnaires/entities/score_calculation.rb +36 -3
  16. data/lib/quby/questionnaires/repos.rb +1 -0
  17. data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
  18. data/lib/quby/version.rb +1 -1
  19. data/spec/internal/log/test-events.log +166 -0
  20. data/spec/internal/log/test.log +6170 -0
  21. data/spec/internal/tmp/capybara/screenshot_2020-10-27-14-25-21.063.html +207 -0
  22. data/spec/internal/tmp/capybara/screenshot_2020-10-27-14-25-21.063.png +0 -0
  23. data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
  24. data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
  25. data/spec/quby/questionnaires/dsl_spec.rb +0 -9
  26. data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
  27. data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
  28. data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
  29. data/spec/quby/table_backend/range_tree_spec.rb +7 -0
  30. data/spec/spec_helper.rb +1 -0
  31. metadata +25 -46
  32. data/lib/quby/questionnaires/dsl/base.rb +0 -20
  33. data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
  34. data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
  35. data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
  36. data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -57
  37. data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
  38. data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
  39. data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
  40. data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
  41. data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
  42. data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -252
  43. data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
  44. data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
  45. data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
  46. data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
  47. data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
  48. data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
  49. data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
  50. data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
  51. data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
  52. data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
  53. data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
  54. data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
  55. data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
  56. data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
  57. data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
  58. data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
  59. data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
  60. data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -66
  61. data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
  62. data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
  63. data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
  64. data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
  65. data/spec/support/examples_for_chart_builders.rb +0 -59
@@ -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
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class DateQuestionBuilder < Base
8
- include MinMaxValidations
9
-
10
- def initialize(key, options = {}, &block)
11
- super
12
- @question = Entities::Questions::DateQuestion.new(key, options)
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class DeprecatedQuestionBuilder < Base
8
- include MultipleChoice
9
-
10
- def initialize(key, options = {}, &block)
11
- super
12
- @question = Entities::Questions::DeprecatedQuestion.new(key, options)
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class FloatQuestionBuilder < Base
8
- include MinMaxValidations
9
- include Labeling
10
- include Units
11
- include Sizes
12
-
13
- def initialize(key, options = {}, &block)
14
- super
15
- @question = Entities::Questions::FloatQuestion.new(key, options)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class IntegerQuestionBuilder < Base
8
- include MinMaxValidations
9
- include Labeling
10
- include Units
11
- include Sizes
12
-
13
- def initialize(key, options = {}, &block)
14
- super
15
- @question = Entities::Questions::IntegerQuestion.new(key, options)
16
- end
17
- end
18
- end
19
- end
20
- end
21
- 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 RadioQuestionBuilder < Base
8
- include MultipleChoice
9
- include Subquestions
10
- include InnerTitles
11
-
12
- def initialize(key, options = {}, &block)
13
- super
14
- @question = Entities::Questions::RadioQuestion.new(key, options)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class SelectQuestionBuilder < Base
8
- include MultipleChoice
9
-
10
- def initialize(key, options = {}, &block)
11
- super
12
- @question = Entities::Questions::SelectQuestion.new(key, options)
13
- end
14
- end
15
- end
16
- end
17
- end
18
- 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 StringQuestionBuilder < Base
8
- include RegexpValidations
9
- include Units
10
- include Sizes
11
-
12
- def initialize(key, options = {}, &block)
13
- super
14
- @question = Entities::Questions::StringQuestion.new(key, options)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class TextQuestionBuilder < Base
8
- include RegexpValidations
9
-
10
- def initialize(key, options = {}, &block)
11
- super
12
- @question = Entities::Questions::TextQuestion.new(key, options)
13
- end
14
-
15
- def lines(value)
16
- @question.lines = value
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +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 ScoreBuilder
9
- attr_reader :key
10
- attr_reader :calculation
11
-
12
- def initialize(key, options = {}, &block)
13
- @score = Entities::ScoreCalculation.new(key, options, &block)
14
- end
15
-
16
- def build
17
- @score
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable LineLength
4
-
5
- module Quby
6
- module Questionnaires
7
- module DSL
8
- module StandardizedPanelGenerators
9
- def start_panel
10
- panel do
11
- text "Welkom bij deze vragenlijst"
12
- end
13
- end
14
-
15
- def end_panel
16
- panel do
17
- text "*Bedankt voor het invullen van deze vragenlijst.*<br>
18
- * U kunt uw antwoorden downloaden door op de knop &#39;Download als PDF&#39; te klikken. Dit bestand is ook geschikt om af te drukken.<br>
19
- * Sla de antwoorden op door op de &#39;Klaar&#39;-knop onderaan te klikken. Daarna kunt u uw antwoorden niet meer wijzigen."
20
- end
21
- end
22
-
23
- def informal_end_panel
24
- panel do
25
- text "*Bedankt voor het invullen van deze vragenlijst.*<br>
26
- * Je kan je antwoorden downloaden door op de knop &#39;Download als PDF&#39; te klikken. Dit bestand is ook geschikt om af te drukken.<br>
27
- * Sla de antwoorden op door op de &#39;Klaar&#39;-knop onderaan te klikken. Daarna kun je je antwoorden niet meer wijzigen."
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,48 +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 TableBuilder
9
- prepend CallsCustomMethods
10
- include Helpers
11
-
12
- def initialize(panel, options = {})
13
- @panel = panel
14
- @table = Entities::Table.new(options)
15
- @default_question_options = options[:default_question_options] || {}
16
- @panel.items << @table
17
- end
18
-
19
- def title(value)
20
- @table.title = value
21
- end
22
-
23
- def description(value)
24
- @table.description = value
25
- end
26
-
27
- def text(value, options = {})
28
- @table.items << Entities::Text.new(value.to_s, options)
29
- end
30
-
31
- def question(key, options = {}, &block)
32
- options = @default_question_options.merge(options)
33
- .merge(table: @table,
34
- questionnaire: @panel.questionnaire)
35
-
36
- check_question_keys_uniqueness key, options, @panel.questionnaire
37
- fail "You can't create a slider in a table at the moment" if options[:as] == :slider
38
-
39
- question = QuestionBuilder.build(key, options, &block)
40
-
41
- @panel.questionnaire.register_question(question)
42
- @table.items << question
43
- @panel.items << question
44
- end
45
- end
46
- end
47
- end
48
- end