Spaces:
Sleeping
Sleeping
Ashmi Banerjee
commited on
Commit
·
fa1e621
1
Parent(s):
8c97b83
maybe fixed bug
Browse files- app.py +2 -23
- views/intro_screen.py +0 -2
- views/nav_buttons.py +3 -0
- views/questions_screen.py +0 -18
- views/ui_helpers.py +40 -0
app.py
CHANGED
@@ -6,9 +6,10 @@ from dotenv import load_dotenv
|
|
6 |
from views.intro_screen import welcome_screen
|
7 |
from views.questions_screen import questions_screen
|
8 |
from views.continue_survey import continue_survey_screen
|
|
|
9 |
from css.layout import custom_css
|
10 |
-
st.set_page_config(layout="wide")
|
11 |
|
|
|
12 |
|
13 |
load_dotenv()
|
14 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
@@ -36,28 +37,6 @@ def initialization():
|
|
36 |
st.session_state.previous_ratings = {}
|
37 |
|
38 |
|
39 |
-
def exit_screen():
|
40 |
-
"""Display exit screen"""
|
41 |
-
st.markdown("""
|
42 |
-
<div class='exit-container'>
|
43 |
-
<h1>Thank you for participating!</h1>
|
44 |
-
<p>Your responses have been saved successfully.</p>
|
45 |
-
<p>You can safely close this window or start a new survey.</p>
|
46 |
-
</div>
|
47 |
-
""", unsafe_allow_html=True)
|
48 |
-
|
49 |
-
if st.button("Resume Survey"):
|
50 |
-
reset_survey()
|
51 |
-
st.rerun()
|
52 |
-
|
53 |
-
|
54 |
-
def reset_survey():
|
55 |
-
"""Reset the survey state to start over."""
|
56 |
-
st.session_state.responses = []
|
57 |
-
st.session_state.completed = True
|
58 |
-
st.session_state.start_new_survey = True
|
59 |
-
|
60 |
-
|
61 |
def ui():
|
62 |
"""Main function to control the survey flow."""
|
63 |
custom_css()
|
|
|
6 |
from views.intro_screen import welcome_screen
|
7 |
from views.questions_screen import questions_screen
|
8 |
from views.continue_survey import continue_survey_screen
|
9 |
+
from views.ui_helpers import exit_screen
|
10 |
from css.layout import custom_css
|
|
|
11 |
|
12 |
+
st.set_page_config(layout="wide")
|
13 |
|
14 |
load_dotenv()
|
15 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
|
|
37 |
st.session_state.previous_ratings = {}
|
38 |
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def ui():
|
41 |
"""Main function to control the survey flow."""
|
42 |
custom_css()
|
views/intro_screen.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
-
from views.continue_survey import continue_survey_screen
|
5 |
-
from db.crud import read
|
6 |
|
7 |
load_dotenv()
|
8 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
|
|
|
|
4 |
|
5 |
load_dotenv()
|
6 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
views/nav_buttons.py
CHANGED
@@ -5,6 +5,8 @@ from datetime import datetime
|
|
5 |
import os
|
6 |
from dotenv import load_dotenv
|
7 |
|
|
|
|
|
8 |
load_dotenv()
|
9 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
10 |
|
@@ -71,4 +73,5 @@ def navigation_buttons(data, response: Response):
|
|
71 |
submit_feedback(current_index)
|
72 |
if st.session_state.current_index == len(data) - 1:
|
73 |
st.session_state.completed = True
|
|
|
74 |
# st.rerun()
|
|
|
5 |
import os
|
6 |
from dotenv import load_dotenv
|
7 |
|
8 |
+
from views.ui_helpers import display_completion_message
|
9 |
+
|
10 |
load_dotenv()
|
11 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
12 |
|
|
|
73 |
submit_feedback(current_index)
|
74 |
if st.session_state.current_index == len(data) - 1:
|
75 |
st.session_state.completed = True
|
76 |
+
display_completion_message()
|
77 |
# st.rerun()
|
views/questions_screen.py
CHANGED
@@ -3,28 +3,10 @@ import streamlit as st
|
|
3 |
from datetime import datetime
|
4 |
from dotenv import load_dotenv
|
5 |
from views.nav_buttons import navigation_buttons
|
6 |
-
import random
|
7 |
|
8 |
load_dotenv()
|
9 |
|
10 |
|
11 |
-
def display_completion_message():
|
12 |
-
"""Display a standardized survey completion message."""
|
13 |
-
st.markdown(
|
14 |
-
"""
|
15 |
-
<div class='exit-container'>
|
16 |
-
<h1>You have already completed the survey! Thank you for participating!</h1>
|
17 |
-
<p>Your responses have been saved successfully.</p>
|
18 |
-
<p>You can safely close this window or start a new survey.</p>
|
19 |
-
</div>
|
20 |
-
""",
|
21 |
-
unsafe_allow_html=True,
|
22 |
-
)
|
23 |
-
st.session_state.show_questions = False
|
24 |
-
st.session_state.completed = True
|
25 |
-
st.session_state.start_new_survey = True
|
26 |
-
|
27 |
-
|
28 |
def get_previous_ratings(model_name, query_key, current_index):
|
29 |
"""Retrieve previous ratings from session state."""
|
30 |
previous_ratings = {}
|
|
|
3 |
from datetime import datetime
|
4 |
from dotenv import load_dotenv
|
5 |
from views.nav_buttons import navigation_buttons
|
|
|
6 |
|
7 |
load_dotenv()
|
8 |
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def get_previous_ratings(model_name, query_key, current_index):
|
11 |
"""Retrieve previous ratings from session state."""
|
12 |
previous_ratings = {}
|
views/ui_helpers.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
|
4 |
+
def exit_screen():
|
5 |
+
"""Display exit screen"""
|
6 |
+
st.markdown("""
|
7 |
+
<div class='exit-container'>
|
8 |
+
<h1>Thank you for participating!</h1>
|
9 |
+
<p>Your responses have been saved successfully.</p>
|
10 |
+
<p>You can safely close this window or start a new survey.</p>
|
11 |
+
</div>
|
12 |
+
""", unsafe_allow_html=True)
|
13 |
+
|
14 |
+
if st.button("Resume Survey"):
|
15 |
+
reset_survey()
|
16 |
+
st.rerun()
|
17 |
+
|
18 |
+
|
19 |
+
def reset_survey():
|
20 |
+
"""Reset the survey state to start over."""
|
21 |
+
st.session_state.responses = []
|
22 |
+
st.session_state.completed = True
|
23 |
+
st.session_state.start_new_survey = True
|
24 |
+
|
25 |
+
|
26 |
+
def display_completion_message():
|
27 |
+
"""Display a standardized survey completion message."""
|
28 |
+
st.markdown(
|
29 |
+
"""
|
30 |
+
<div class='exit-container'>
|
31 |
+
<h1>You have already completed the survey! Thank you for participating!</h1>
|
32 |
+
<p>Your responses have been saved successfully.</p>
|
33 |
+
<p>You can safely close this window or start a new survey.</p>
|
34 |
+
</div>
|
35 |
+
""",
|
36 |
+
unsafe_allow_html=True,
|
37 |
+
)
|
38 |
+
st.session_state.show_questions = False
|
39 |
+
st.session_state.completed = True
|
40 |
+
st.session_state.start_new_survey = True
|