Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,11 @@ import requests
|
|
| 3 |
import json
|
| 4 |
import web3
|
| 5 |
|
| 6 |
-
total_number_pages =
|
| 7 |
placeholder_buttons = None
|
| 8 |
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
# Function that records radio element changes
|
|
@@ -25,7 +27,7 @@ def answer_change(state, key):
|
|
| 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)
|
|
@@ -35,28 +37,41 @@ 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["Q2"] = None
|
|
|
|
|
|
|
| 38 |
st.session_state["disabled"] = False
|
| 39 |
|
| 40 |
# Page 1; Video
|
| 41 |
if st.session_state["current_page"] == 1:
|
| 42 |
|
| 43 |
-
st.markdown("""<p class="big-font"
|
| 44 |
|
| 45 |
-
st.
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
st.markdown("""<style> div[class*="
|
| 53 |
|
| 54 |
|
| 55 |
placeholder = st.empty()
|
| 56 |
|
| 57 |
if st.button('Next', key='next_button_page_1'):
|
| 58 |
all_answered = True
|
| 59 |
-
if st.session_state["Q1"] == None:
|
|
|
|
|
|
|
| 60 |
all_answered = False
|
| 61 |
if all_answered:
|
| 62 |
st.session_state["current_page"] += 1
|
|
@@ -70,11 +85,17 @@ if st.session_state["current_page"] == 1:
|
|
| 70 |
|
| 71 |
elif st.session_state["current_page"] == 2:
|
| 72 |
|
| 73 |
-
st.
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
st.markdown("""<style> div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 79 |
|
| 80 |
|
|
@@ -88,7 +109,64 @@ elif st.session_state["current_page"] == 2:
|
|
| 88 |
with col2:
|
| 89 |
if st.button('Next'):
|
| 90 |
all_answered = True
|
| 91 |
-
if st.session_state["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
all_answered = False
|
| 93 |
if all_answered:
|
| 94 |
st.session_state["current_page"] += 1
|
|
|
|
| 3 |
import json
|
| 4 |
import web3
|
| 5 |
|
| 6 |
+
total_number_pages = 4
|
| 7 |
placeholder_buttons = None
|
| 8 |
|
| 9 |
+
Q2_radio_options = ["A","B"]
|
| 10 |
+
Q4_radio_options = []
|
| 11 |
|
| 12 |
|
| 13 |
# Function that records radio element changes
|
|
|
|
| 27 |
st.session_state[state] = st.session_state[key]
|
| 28 |
|
| 29 |
st.set_page_config(page_title='IPFS-Based Survey',)
|
| 30 |
+
st.title('Test 1')
|
| 31 |
|
| 32 |
st.markdown("<style>.row-widget.stButton {text-align: center;}</style>", unsafe_allow_html=True)
|
| 33 |
st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True)
|
|
|
|
| 37 |
st.session_state["current_page"] = 1
|
| 38 |
st.session_state["Q1"] = None
|
| 39 |
st.session_state["Q2"] = None
|
| 40 |
+
st.session_state["Q3"] = None
|
| 41 |
+
st.session_state["Q4"] = None
|
| 42 |
st.session_state["disabled"] = False
|
| 43 |
|
| 44 |
# Page 1; Video
|
| 45 |
if st.session_state["current_page"] == 1:
|
| 46 |
|
| 47 |
+
st.markdown("""<p class="big-font">I am describing this survey.</p>""", unsafe_allow_html=True)
|
| 48 |
|
| 49 |
+
st.text_area(label = "Do you like pie?",
|
| 50 |
+
value= "" if st.session_state["Q1"] == None else st.session_state["Q1"],
|
| 51 |
+
key = 'Q1_text',
|
| 52 |
+
on_change = answer_change,
|
| 53 |
+
args = ( "Q1", "Q1_text",))
|
| 54 |
+
|
| 55 |
+
st.markdown("""<style> div[class*="stText"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
st.radio(label = "MC Question",
|
| 59 |
+
options = Q2_radio_options,
|
| 60 |
+
index = None if st.session_state["Q2"] == None else st.session_state["Q2"],
|
| 61 |
+
key = 'Q2_radio',
|
| 62 |
+
on_change = radio_change,
|
| 63 |
+
args = (Q2_radio_options, "Q2", "Q2_radio",))
|
| 64 |
|
| 65 |
+
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 66 |
|
| 67 |
|
| 68 |
placeholder = st.empty()
|
| 69 |
|
| 70 |
if st.button('Next', key='next_button_page_1'):
|
| 71 |
all_answered = True
|
| 72 |
+
if st.session_state["Q1"] == None or st.session_state["Q1"] == []:
|
| 73 |
+
all_answered = False
|
| 74 |
+
if st.session_state["Q2"] == None or st.session_state["Q2"] == []:
|
| 75 |
all_answered = False
|
| 76 |
if all_answered:
|
| 77 |
st.session_state["current_page"] += 1
|
|
|
|
| 85 |
|
| 86 |
elif st.session_state["current_page"] == 2:
|
| 87 |
|
| 88 |
+
st.video("https://www.youtube.com/watch?v=qJxi122kxgQ")
|
| 89 |
+
st.markdown("""<p style='font-size:18px;'>Go Luka!</p>""", unsafe_allow_html=True)
|
| 90 |
+
st.image("https://th.bing.com/th/id/OIP.M7inwN-YD5ycRt1VWQ9dCQHaEK?rs=1&pid=ImgDetMain")
|
| 91 |
+
st.markdown("""<p style='font-size:18px;'>Youtube</p>""", unsafe_allow_html=True)
|
| 92 |
+
if st.session_state["Q3"] == None:
|
| 93 |
+
st.session_state["Q3"] = 5
|
| 94 |
+
st.slider(label="You messing with it?",min_value=0,max_value=10,
|
| 95 |
+
value= st.session_state["Q3"],
|
| 96 |
+
key = "Q3_slider",
|
| 97 |
+
on_change = answer_change,
|
| 98 |
+
args = ("Q3", "Q3_slider",))
|
| 99 |
st.markdown("""<style> div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 100 |
|
| 101 |
|
|
|
|
| 109 |
with col2:
|
| 110 |
if st.button('Next'):
|
| 111 |
all_answered = True
|
| 112 |
+
if st.session_state["Q3"] == None or st.session_state["Q3"] == []:
|
| 113 |
+
all_answered = False
|
| 114 |
+
if all_answered:
|
| 115 |
+
st.session_state["current_page"] += 1
|
| 116 |
+
st.rerun()
|
| 117 |
+
else:
|
| 118 |
+
with placeholder.container():
|
| 119 |
+
st.warning("Please answer all the questions on this page.", icon="⚠️")
|
| 120 |
+
|
| 121 |
+
st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
elif st.session_state["current_page"] == 3:
|
| 125 |
+
|
| 126 |
+
st.markdown("""<p style='font-size:18px;'>Page!</p>""", unsafe_allow_html=True)
|
| 127 |
+
placeholder = st.empty()
|
| 128 |
+
|
| 129 |
+
col1, col2 = st.columns(2)
|
| 130 |
+
with col1:
|
| 131 |
+
if st.button('Back'):
|
| 132 |
+
st.session_state["current_page"] -= 1
|
| 133 |
+
st.rerun()
|
| 134 |
+
with col2:
|
| 135 |
+
if st.button('Next'):
|
| 136 |
+
all_answered = True
|
| 137 |
+
if all_answered:
|
| 138 |
+
st.session_state["current_page"] += 1
|
| 139 |
+
st.rerun()
|
| 140 |
+
else:
|
| 141 |
+
with placeholder.container():
|
| 142 |
+
st.warning("Please answer all the questions on this page.", icon="⚠️")
|
| 143 |
+
|
| 144 |
+
st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
elif st.session_state["current_page"] == 4:
|
| 148 |
+
|
| 149 |
+
st.selectbox(label = "1234567890asdfghjkl No answer select question",
|
| 150 |
+
options = Q4_radio_options,
|
| 151 |
+
index = None if st.session_state["Q4"] == None else st.session_state["Q4"],
|
| 152 |
+
key = 'Q4_radio',
|
| 153 |
+
on_change = radio_change,
|
| 154 |
+
args = (Q4_radio_options, "Q4", "Q4_radio",))
|
| 155 |
+
|
| 156 |
+
st.markdown("""<style> div[class*="stSelectbox"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
placeholder = st.empty()
|
| 160 |
+
|
| 161 |
+
col1, col2 = st.columns(2)
|
| 162 |
+
with col1:
|
| 163 |
+
if st.button('Back'):
|
| 164 |
+
st.session_state["current_page"] -= 1
|
| 165 |
+
st.rerun()
|
| 166 |
+
with col2:
|
| 167 |
+
if st.button('Next'):
|
| 168 |
+
all_answered = True
|
| 169 |
+
if st.session_state["Q4"] == None or st.session_state["Q4"] == []:
|
| 170 |
all_answered = False
|
| 171 |
if all_answered:
|
| 172 |
st.session_state["current_page"] += 1
|