Repository navigation
Expand file tree
/
Copy pathadditional_commodity_code_flow.rb
More file actions
213 lines (178 loc) · 3.99 KB
/
Copy pathadditional_commodity_code_flow.rb
File metadata and controls
213 lines (178 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
class AdditionalCommodityCodeFlow < SmartAnswer::Flow
def define
content_id "bfda3b4f-166b-48e7-9aaf-21bfbd606207"
name "additional-commodity-code"
status :published
# Q1
radio :how_much_starch_glucose? do
option 0
option 5
option 25
option 50
option 75
on_response do |response|
self.calculator = SmartAnswer::Calculators::CommodityCodeCalculator.new
calculator.starch_glucose_weight = response.to_i
end
next_node do |response|
case response.to_i
when 25
question :how_much_sucrose_2?
when 50
question :how_much_sucrose_3?
when 75
question :how_much_sucrose_4?
else
question :how_much_sucrose_1?
end
end
end
# Q2ab
radio :how_much_sucrose_1? do
option 0
option 5
option 30
option 50
option 70
on_response do |response|
calculator.sucrose_weight = response.to_i
end
next_node do
question :how_much_milk_fat?
end
end
# Q2c
radio :how_much_sucrose_2? do
option 0
option 5
option 30
option 50
on_response do |response|
calculator.sucrose_weight = response.to_i
end
next_node do
question :how_much_milk_fat?
end
end
# Q2d
radio :how_much_sucrose_3? do
option 0
option 5
option 30
on_response do |response|
calculator.sucrose_weight = response.to_i
end
next_node do
question :how_much_milk_fat?
end
end
# Q2e
radio :how_much_sucrose_4? do
option 0
option 5
on_response do |response|
calculator.sucrose_weight = response.to_i
end
next_node do
question :how_much_milk_fat?
end
end
# Q3
radio :how_much_milk_fat? do
option 0
option 1
option 3
option 6
option 9
option 12
option 18
option 26
option 40
option 55
option 70
option 85
on_response do |response|
calculator.milk_fat_weight = response.to_i
end
next_node do |response|
case response.to_i
when 0, 1
question :how_much_milk_protein_ab?
when 3
question :how_much_milk_protein_c?
when 6
question :how_much_milk_protein_d?
when 9, 12
question :how_much_milk_protein_ef?
when 18, 26
question :how_much_milk_protein_gh?
else
outcome :commodity_code_result
end
end
end
# Q3ab
radio :how_much_milk_protein_ab? do
option 0
option 2
option 6
option 18
option 30
option 60
on_response do |response|
calculator.milk_protein_weight = response.to_i
end
next_node do
outcome :commodity_code_result
end
end
# Q3c
radio :how_much_milk_protein_c? do
option 0
option 2
option 12
on_response do |response|
calculator.milk_protein_weight = response.to_i
end
next_node do
outcome :commodity_code_result
end
end
# Q3d
radio :how_much_milk_protein_d? do
option 0
option 4
option 15
on_response do |response|
calculator.milk_protein_weight = response.to_i
end
next_node do
outcome :commodity_code_result
end
end
# Q3ef
radio :how_much_milk_protein_ef? do
option 0
option 6
option 18
on_response do |response|
calculator.milk_protein_weight = response.to_i
end
next_node do
outcome :commodity_code_result
end
end
# Q3gh
radio :how_much_milk_protein_gh? do
option 0
option 6
on_response do |response|
calculator.milk_protein_weight = response.to_i
end
next_node do
outcome :commodity_code_result
end
end
outcome :commodity_code_result
end
end