Spaces:
Sleeping
Sleeping
Add app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ total_number_pages = 4
|
|
| 7 |
placeholder_buttons = None
|
| 8 |
|
| 9 |
Q1_radio_options = ["Pizza","Burgers","Pasta","Hot Dogs"]
|
|
|
|
| 10 |
Q3_radio_options = ["Yes","No"]
|
| 11 |
Q4_radio_options = ["N/A", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"]
|
| 12 |
|
|
@@ -40,14 +41,15 @@ if "current_page" not in st.session_state:
|
|
| 40 |
st.session_state["Q2"] = None
|
| 41 |
st.session_state["Q3"] = None
|
| 42 |
st.session_state["Q4"] = None
|
|
|
|
| 43 |
st.session_state["disabled"] = False
|
| 44 |
|
| 45 |
# Page 1; Video
|
| 46 |
if st.session_state["current_page"] == 1:
|
| 47 |
|
| 48 |
-
st.markdown("""<p class="big-font">This is a
|
| 49 |
|
| 50 |
-
st.radio(label = "
|
| 51 |
options = Q1_radio_options,
|
| 52 |
index = None if st.session_state["Q1"] == None else st.session_state["Q1"],
|
| 53 |
key = 'Q1_radio',
|
|
@@ -57,13 +59,14 @@ if st.session_state["current_page"] == 1:
|
|
| 57 |
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 58 |
|
| 59 |
|
| 60 |
-
st.
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
-
st.markdown("""<style> div[class*="
|
| 67 |
|
| 68 |
|
| 69 |
placeholder = st.empty()
|
|
@@ -88,14 +91,14 @@ elif st.session_state["current_page"] == 2:
|
|
| 88 |
|
| 89 |
st.video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
| 90 |
st.markdown("""<p style='font-size:18px;'>Get rick rolled!</p>""", unsafe_allow_html=True)
|
| 91 |
-
st.
|
| 92 |
-
default = None if st.session_state["Q3"] == None else st.session_state["Q3"],
|
| 93 |
options = Q3_radio_options,
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
| 97 |
|
| 98 |
-
st.markdown("""<style> div[class*="
|
| 99 |
|
| 100 |
|
| 101 |
placeholder = st.empty()
|
|
@@ -122,7 +125,7 @@ elif st.session_state["current_page"] == 2:
|
|
| 122 |
|
| 123 |
elif st.session_state["current_page"] == 3:
|
| 124 |
|
| 125 |
-
st.radio(label = "Miami is
|
| 126 |
options = Q4_radio_options,
|
| 127 |
index = None if st.session_state["Q4"] == None else st.session_state["Q4"],
|
| 128 |
key = 'Q4_radio',
|
|
@@ -132,6 +135,16 @@ elif st.session_state["current_page"] == 3:
|
|
| 132 |
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 133 |
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
placeholder = st.empty()
|
| 136 |
|
| 137 |
col1, col2 = st.columns(2)
|
|
@@ -144,6 +157,8 @@ elif st.session_state["current_page"] == 3:
|
|
| 144 |
all_answered = True
|
| 145 |
if st.session_state["Q4"] == None or st.session_state["Q4"] == []:
|
| 146 |
all_answered = False
|
|
|
|
|
|
|
| 147 |
if all_answered:
|
| 148 |
st.session_state["current_page"] += 1
|
| 149 |
st.rerun()
|
|
@@ -165,6 +180,7 @@ elif st.session_state["current_page"] == 4: # Last Page
|
|
| 165 |
"Q2": st.session_state["Q2"],
|
| 166 |
"Q3": st.session_state["Q3"],
|
| 167 |
"Q4": st.session_state["Q4"],
|
|
|
|
| 168 |
})}
|
| 169 |
except Exception as e:
|
| 170 |
print(e)
|
|
|
|
| 7 |
placeholder_buttons = None
|
| 8 |
|
| 9 |
Q1_radio_options = ["Pizza","Burgers","Pasta","Hot Dogs"]
|
| 10 |
+
Q2_radio_options = ["Water","Soda","Coffee","Tea"]
|
| 11 |
Q3_radio_options = ["Yes","No"]
|
| 12 |
Q4_radio_options = ["N/A", "Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"]
|
| 13 |
|
|
|
|
| 41 |
st.session_state["Q2"] = None
|
| 42 |
st.session_state["Q3"] = None
|
| 43 |
st.session_state["Q4"] = None
|
| 44 |
+
st.session_state["Q5"] = None
|
| 45 |
st.session_state["disabled"] = False
|
| 46 |
|
| 47 |
# Page 1; Video
|
| 48 |
if st.session_state["current_page"] == 1:
|
| 49 |
|
| 50 |
+
st.markdown("""<p class="big-font">This is a description for my survey</p>""", unsafe_allow_html=True)
|
| 51 |
|
| 52 |
+
st.radio(label = "What is your favorite food?",
|
| 53 |
options = Q1_radio_options,
|
| 54 |
index = None if st.session_state["Q1"] == None else st.session_state["Q1"],
|
| 55 |
key = 'Q1_radio',
|
|
|
|
| 59 |
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 60 |
|
| 61 |
|
| 62 |
+
st.multiselect(label = "Select all of the drinks that you like.",
|
| 63 |
+
default = None if st.session_state["Q2"] == None else st.session_state["Q2"],
|
| 64 |
+
options = Q2_radio_options,
|
| 65 |
+
key = 'Q2_multi',
|
| 66 |
+
on_change = multi_change,
|
| 67 |
+
args = (Q2_radio_options, "Q2", "Q2_multi",))
|
| 68 |
|
| 69 |
+
st.markdown("""<style> div[class*="stMulti"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 70 |
|
| 71 |
|
| 72 |
placeholder = st.empty()
|
|
|
|
| 91 |
|
| 92 |
st.video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
| 93 |
st.markdown("""<p style='font-size:18px;'>Get rick rolled!</p>""", unsafe_allow_html=True)
|
| 94 |
+
st.selectbox(label = "Was that a good joke?",
|
|
|
|
| 95 |
options = Q3_radio_options,
|
| 96 |
+
index = None if st.session_state["Q3"] == None else st.session_state["Q3"],
|
| 97 |
+
key = 'Q3_radio',
|
| 98 |
+
on_change = radio_change,
|
| 99 |
+
args = (Q3_radio_options, "Q3", "Q3_radio",))
|
| 100 |
|
| 101 |
+
st.markdown("""<style> div[class*="stSelectbox"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 102 |
|
| 103 |
|
| 104 |
placeholder = st.empty()
|
|
|
|
| 125 |
|
| 126 |
elif st.session_state["current_page"] == 3:
|
| 127 |
|
| 128 |
+
st.radio(label = "Miami is the best school.", # Likert
|
| 129 |
options = Q4_radio_options,
|
| 130 |
index = None if st.session_state["Q4"] == None else st.session_state["Q4"],
|
| 131 |
key = 'Q4_radio',
|
|
|
|
| 135 |
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 136 |
|
| 137 |
|
| 138 |
+
if st.session_state["Q5"] == None:
|
| 139 |
+
st.session_state["Q5"] = 50
|
| 140 |
+
st.slider(label="How happy are you today?",min_value=0,max_value=100,
|
| 141 |
+
value= st.session_state["Q5"],
|
| 142 |
+
key = "Q5_slider",
|
| 143 |
+
on_change = answer_change,
|
| 144 |
+
args = ("Q5", "Q5_slider",))
|
| 145 |
+
st.markdown("""<style> div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 18px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 146 |
+
|
| 147 |
+
|
| 148 |
placeholder = st.empty()
|
| 149 |
|
| 150 |
col1, col2 = st.columns(2)
|
|
|
|
| 157 |
all_answered = True
|
| 158 |
if st.session_state["Q4"] == None or st.session_state["Q4"] == []:
|
| 159 |
all_answered = False
|
| 160 |
+
if st.session_state["Q5"] == None or st.session_state["Q5"] == []:
|
| 161 |
+
all_answered = False
|
| 162 |
if all_answered:
|
| 163 |
st.session_state["current_page"] += 1
|
| 164 |
st.rerun()
|
|
|
|
| 180 |
"Q2": st.session_state["Q2"],
|
| 181 |
"Q3": st.session_state["Q3"],
|
| 182 |
"Q4": st.session_state["Q4"],
|
| 183 |
+
"Q5": st.session_state["Q5"],
|
| 184 |
})}
|
| 185 |
except Exception as e:
|
| 186 |
print(e)
|