Spaces:
Running
Running
Ashmi Banerjee
commited on
Commit
·
bfa9b50
1
Parent(s):
876e6bb
nav buttons fixed the exit & save thing
Browse files- views/nav_buttons.py +15 -1
views/nav_buttons.py
CHANGED
@@ -4,6 +4,7 @@ import streamlit as st
|
|
4 |
from datetime import datetime
|
5 |
import os
|
6 |
from dotenv import load_dotenv
|
|
|
7 |
load_dotenv()
|
8 |
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
|
9 |
|
@@ -24,6 +25,13 @@ def submit_feedback(current_index):
|
|
24 |
st.error(f"An error occurred while submitting feedback: {e}")
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
def navigation_buttons(data, ratings_v, ratings_p0, ratings_p1):
|
28 |
"""Display navigation buttons."""
|
29 |
current_index = st.session_state.current_index
|
@@ -48,4 +56,10 @@ def navigation_buttons(data, ratings_v, ratings_p0, ratings_p1):
|
|
48 |
|
49 |
with col3: # Save & Resume Later button
|
50 |
if st.button("Exit & Resume Later"):
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
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 |
|
|
|
25 |
st.error(f"An error occurred while submitting feedback: {e}")
|
26 |
|
27 |
|
28 |
+
def any_value_zero(response):
|
29 |
+
return any(
|
30 |
+
any(value == 0 for value in query.values())
|
31 |
+
for query in [response.query_v, response.query_p0, response.query_p1]
|
32 |
+
)
|
33 |
+
|
34 |
+
|
35 |
def navigation_buttons(data, ratings_v, ratings_p0, ratings_p1):
|
36 |
"""Display navigation buttons."""
|
37 |
current_index = st.session_state.current_index
|
|
|
56 |
|
57 |
with col3: # Save & Resume Later button
|
58 |
if st.button("Exit & Resume Later"):
|
59 |
+
last_response = st.session_state.responses[-1]
|
60 |
+
if not any_value_zero(last_response):
|
61 |
+
submit_feedback(current_index)
|
62 |
+
else:
|
63 |
+
st.session_state.completed = True
|
64 |
+
st.rerun()
|
65 |
+
# submit_feedback(current_index)
|