anastaa3 commited on
Commit
2da0858
·
verified ·
1 Parent(s): 1781819

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -263
app.py CHANGED
@@ -3,15 +3,9 @@ import requests
3
  import json
4
  import web3
5
 
6
- total_number_pages = 7
7
  placeholder_buttons = None
8
 
9
- Q2_radio_options = ["Yes","No"]
10
- Q4_radio_options = ["Option 1 multi","Option 2 multi"]
11
- Q5_radio_options = ["Option 1 Radio","Option 2 Radio"]
12
- Q6_radio_options = ["Green","Red","Blue","Yellow"]
13
- Q7_radio_options = ["Yes","No","Ur dumb"]
14
- Q10_radio_options = ["IDK","Of Course","STFU!!!!!","Inner demons"]
15
 
16
 
17
  # Function that records radio element changes
@@ -31,7 +25,7 @@ def answer_change(state, key):
31
  st.session_state[state] = st.session_state[key]
32
 
33
  st.set_page_config(page_title='IPFS-Based Survey',)
34
- st.title('Newest Test')
35
 
36
  st.markdown("<style>.row-widget.stButton {text-align: center;}</style>", unsafe_allow_html=True)
37
  st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True)
@@ -40,50 +34,29 @@ st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True
40
  if "current_page" not in st.session_state:
41
  st.session_state["current_page"] = 1
42
  st.session_state["Q1"] = None
43
- st.session_state["Q2"] = None
44
- st.session_state["Q3"] = None
45
- st.session_state["Q4"] = None
46
- st.session_state["Q5"] = None
47
- st.session_state["Q6"] = None
48
- st.session_state["Q7"] = None
49
- st.session_state["Q8"] = None
50
- st.session_state["Q9"] = None
51
- st.session_state["Q10"] = None
52
  st.session_state["disabled"] = False
53
 
54
  # Page 1; Video
55
  if st.session_state["current_page"] == 1:
56
 
57
- st.markdown("""<p class="big-font">This is a Test of the latest version of the survey builder Tool</p>""", unsafe_allow_html=True)
58
 
59
- st.video("https://www.youtube.com/watch?v=aJb6Dov0jlM")
60
- st.text_area(label = "This is a text Question and should allow any text input. This should appear on the first page.",
61
- value= "" if st.session_state["Q1"] == None else st.session_state["Q1"],
62
- key = 'Q1_text',
63
- on_change = answer_change,
64
- args = ( "Q1", "Q1_text",))
65
 
66
- st.markdown("""<style> div[class*="stText"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
67
-
68
-
69
- st.selectbox(label = "Selecting Box",
70
- options = Q2_radio_options,
71
- index = None if st.session_state["Q2"] == None else st.session_state["Q2"],
72
- key = 'Q2_radio',
73
- on_change = radio_change,
74
- args = (Q2_radio_options, "Q2", "Q2_radio",))
75
-
76
- st.markdown("""<style> div[class*="stSelectbox"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
77
 
78
 
79
  placeholder = st.empty()
80
 
81
- if st.button('Next', key='next_button_page_1'):
82
  all_answered = True
83
  if st.session_state["Q1"] == None:
84
  all_answered = False
85
- if st.session_state["Q2"] == None:
86
- all_answered = False
87
  if all_answered:
88
  st.session_state["current_page"] += 1
89
  st.rerun()
@@ -94,228 +67,3 @@ if st.session_state["current_page"] == 1:
94
  st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
95
 
96
 
97
- elif st.session_state["current_page"] == 2:
98
-
99
- st.image("http://t3.gstatic.com/licensed-image?q=tbn:ANd9GcTF_OQ101nRiHil4w5295pqLf5M8axplaqmwCthHGgdqlu21bMsP8VmMdl4zkPUnW2pgcNWEWJyl-Y46P1J_d8")
100
- st.slider(label="This is a slider question that allows a numeric input between two numbers. This should appear on the second page.",min_value=0,max_value=10,
101
- value= 5 if st.session_state["Q3"] == None else st.session_state["Q3"],
102
- key = "Q3_slider",
103
- on_change = answer_change,
104
- args = ("Q3", "Q3_slider",))
105
- st.markdown("""<style> div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
106
-
107
-
108
- st.multiselect(label = "This is a multiselect question where you can select multiple answers. This should appear on the second page.",
109
- default = None if st.session_state["Q4"] == None else st.session_state["Q4"],
110
- options = Q4_radio_options,
111
- key = 'Q4_multi',
112
- on_change = multi_change,
113
- args = (Q4_radio_options, "Q4", "Q4_multi",))
114
-
115
- st.markdown("""<style> div[class*="stMulti"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
116
-
117
-
118
- placeholder = st.empty()
119
-
120
- col1, col2 = st.columns(2)
121
- with col1:
122
- if st.button('Back'):
123
- st.session_state["current_page"] -= 1
124
- st.rerun()
125
- with col2:
126
- if st.button('Next'):
127
- all_answered = True
128
- if st.session_state["Q3"] == None:
129
- all_answered = False
130
- if st.session_state["Q4"] == None:
131
- all_answered = False
132
- if all_answered:
133
- st.session_state["current_page"] += 1
134
- st.rerun()
135
- else:
136
- with placeholder.container():
137
- st.warning("Please answer all the questions on this page.", icon="⚠️")
138
-
139
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
140
-
141
-
142
- elif st.session_state["current_page"] == 3:
143
-
144
- st.markdown("""<p style='font-size:18px;'>My Life</p>""", unsafe_allow_html=True)
145
- st.radio(label = "This is a multiple choice question where you can choose one of the following. This should appear on the third page.",
146
- options = Q5_radio_options,
147
- index = None if st.session_state["Q5"] == None else st.session_state["Q5"],
148
- key = 'Q5_radio',
149
- on_change = radio_change,
150
- args = (Q5_radio_options, "Q5", "Q5_radio",))
151
-
152
- st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
153
-
154
-
155
- st.radio(label = "Fav Color?",
156
- options = Q6_radio_options,
157
- index = None if st.session_state["Q6"] == None else st.session_state["Q6"],
158
- key = 'Q6_radio',
159
- on_change = radio_change,
160
- args = (Q6_radio_options, "Q6", "Q6_radio",))
161
-
162
- st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
163
-
164
-
165
- st.multiselect(label = "Party Time",
166
- default = None if st.session_state["Q7"] == None else st.session_state["Q7"],
167
- options = Q7_radio_options,
168
- key = 'Q7_multi',
169
- on_change = multi_change,
170
- args = (Q7_radio_options, "Q7", "Q7_multi",))
171
-
172
- st.markdown("""<style> div[class*="stMulti"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
173
-
174
-
175
- placeholder = st.empty()
176
-
177
- col1, col2 = st.columns(2)
178
- with col1:
179
- if st.button('Back'):
180
- st.session_state["current_page"] -= 1
181
- st.rerun()
182
- with col2:
183
- if st.button('Next'):
184
- all_answered = True
185
- if st.session_state["Q5"] == None:
186
- all_answered = False
187
- if st.session_state["Q6"] == None:
188
- all_answered = False
189
- if st.session_state["Q7"] == None:
190
- all_answered = False
191
- if all_answered:
192
- st.session_state["current_page"] += 1
193
- st.rerun()
194
- else:
195
- with placeholder.container():
196
- st.warning("Please answer all the questions on this page.", icon="⚠️")
197
-
198
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
199
-
200
-
201
- elif st.session_state["current_page"] == 4:
202
-
203
- st.slider(label="Happiness Scale",min_value=0,max_value=100,
204
- value= 50 if st.session_state["Q8"] == None else st.session_state["Q8"],
205
- key = "Q8_slider",
206
- on_change = answer_change,
207
- args = ("Q8", "Q8_slider",))
208
- st.markdown("""<style> div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
209
-
210
-
211
- st.text_area(label = "Why are you this happy/unhappy?",
212
- value= "" if st.session_state["Q9"] == None else st.session_state["Q9"],
213
- key = 'Q9_text',
214
- on_change = answer_change,
215
- args = ( "Q9", "Q9_text",))
216
-
217
- st.markdown("""<style> div[class*="stText"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
218
-
219
-
220
- placeholder = st.empty()
221
-
222
- col1, col2 = st.columns(2)
223
- with col1:
224
- if st.button('Back'):
225
- st.session_state["current_page"] -= 1
226
- st.rerun()
227
- with col2:
228
- if st.button('Next'):
229
- all_answered = True
230
- if st.session_state["Q8"] == None:
231
- all_answered = False
232
- if st.session_state["Q9"] == None:
233
- all_answered = False
234
- if all_answered:
235
- st.session_state["current_page"] += 1
236
- st.rerun()
237
- else:
238
- with placeholder.container():
239
- st.warning("Please answer all the questions on this page.", icon="⚠️")
240
-
241
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
242
-
243
-
244
- elif st.session_state["current_page"] == 5:
245
-
246
- placeholder = st.empty()
247
-
248
- col1, col2 = st.columns(2)
249
- with col1:
250
- if st.button('Back'):
251
- st.session_state["current_page"] -= 1
252
- st.rerun()
253
- with col2:
254
- if st.button('Next'):
255
- all_answered = True
256
- if all_answered:
257
- st.session_state["current_page"] += 1
258
- st.rerun()
259
- else:
260
- with placeholder.container():
261
- st.warning("Please answer all the questions on this page.", icon="⚠️")
262
-
263
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
264
-
265
-
266
- elif st.session_state["current_page"] == 6:
267
-
268
- st.radio(label = "I like cheese?",
269
- options = Q10_radio_options,
270
- index = None if st.session_state["Q10"] == None else st.session_state["Q10"],
271
- key = 'Q10_radio',
272
- on_change = radio_change,
273
- args = (Q10_radio_options, "Q10", "Q10_radio",))
274
-
275
- st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
276
-
277
-
278
- placeholder = st.empty()
279
-
280
- col1, col2 = st.columns(2)
281
- with col1:
282
- if st.button('Back'):
283
- st.session_state["current_page"] -= 1
284
- st.rerun()
285
- with col2:
286
- if st.button('Next'):
287
- all_answered = True
288
- if st.session_state["Q10"] == None:
289
- all_answered = False
290
- if all_answered:
291
- st.session_state["current_page"] += 1
292
- st.rerun()
293
- else:
294
- with placeholder.container():
295
- st.warning("Please answer all the questions on this page.", icon="⚠️")
296
-
297
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
298
-
299
-
300
- elif st.session_state["current_page"] == 7:
301
-
302
- placeholder = st.empty()
303
-
304
- col1, col2 = st.columns(2)
305
- with col1:
306
- if st.button('Back'):
307
- st.session_state["current_page"] -= 1
308
- st.rerun()
309
- with col2:
310
- if st.button('Next'):
311
- all_answered = True
312
- if all_answered:
313
- st.session_state["current_page"] += 1
314
- st.rerun()
315
- else:
316
- with placeholder.container():
317
- st.warning("Please answer all the questions on this page.", icon="⚠️")
318
-
319
- st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
320
-
321
-
 
3
  import json
4
  import web3
5
 
6
+ total_number_pages = 1
7
  placeholder_buttons = None
8
 
 
 
 
 
 
 
9
 
10
 
11
  # Function that records radio element changes
 
25
  st.session_state[state] = st.session_state[key]
26
 
27
  st.set_page_config(page_title='IPFS-Based Survey',)
28
+ st.title('')
29
 
30
  st.markdown("<style>.row-widget.stButton {text-align: center;}</style>", unsafe_allow_html=True)
31
  st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True)
 
34
  if "current_page" not in st.session_state:
35
  st.session_state["current_page"] = 1
36
  st.session_state["Q1"] = None
 
 
 
 
 
 
 
 
 
37
  st.session_state["disabled"] = False
38
 
39
  # Page 1; Video
40
  if st.session_state["current_page"] == 1:
41
 
42
+ st.markdown("""<p class="big-font"></p>""", unsafe_allow_html=True)
43
 
44
+ st.select_slider(label = "Good Work",
45
+ options = ["Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"],
46
+ value= None if st.session_state["Q1"] == None else st.session_state["Q1"],
47
+ key = 'Q1_select_slider',
48
+ on_change = answer_change,
49
+ args = ("Q1", "Q1_select_slider",))
50
 
51
+ st.markdown("""<style> div[class*="stSelectSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
52
 
53
 
54
  placeholder = st.empty()
55
 
56
+ if st.button('Next'):
57
  all_answered = True
58
  if st.session_state["Q1"] == None:
59
  all_answered = False
 
 
60
  if all_answered:
61
  st.session_state["current_page"] += 1
62
  st.rerun()
 
67
  st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
68
 
69