Spaces:
Running
Running
Ashmi Banerjee
commited on
Commit
·
7905b1b
1
Parent(s):
dc2ff87
bug fix: added st.rerun() after next
Browse files- views/nav_buttons.py +23 -22
views/nav_buttons.py
CHANGED
@@ -52,33 +52,34 @@ def navigation_buttons(data, response: Response):
|
|
52 |
st.warning("You are at the beginning of the survey, can't go back.")
|
53 |
# st.rerun()
|
54 |
|
55 |
-
with col2: # Next button
|
56 |
-
if st.button("Next", disabled=
|
57 |
all_ratings = flatten_ratings(response)
|
58 |
if any(rating == 0 for rating in all_ratings):
|
59 |
st.warning("Please provide all ratings before proceeding.")
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
}
|
70 |
-
for model, ratings in response.model_ratings.items()
|
71 |
}
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
}
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
with col3: # Submit button
|
84 |
if st.button("Submit & Resume Later"):
|
|
|
52 |
st.warning("You are at the beginning of the survey, can't go back.")
|
53 |
# st.rerun()
|
54 |
|
55 |
+
with col2: # Next button
|
56 |
+
if st.button("Next", disabled=current_index == len(data) - 1):
|
57 |
all_ratings = flatten_ratings(response)
|
58 |
if any(rating == 0 for rating in all_ratings):
|
59 |
st.warning("Please provide all ratings before proceeding.")
|
60 |
+
elif current_index < len(data) - 1:
|
61 |
+
# Store the ratings with proper structure
|
62 |
+
config_id = data.iloc[current_index]['config_id']
|
63 |
+
if isinstance(response.model_ratings, dict):
|
64 |
+
st.session_state.previous_ratings[config_id] = {
|
65 |
+
model: {
|
66 |
+
'query_v_ratings': ratings.query_v_ratings,
|
67 |
+
'query_p0_ratings': ratings.query_p0_ratings,
|
68 |
+
'query_p1_ratings': ratings.query_p1_ratings
|
|
|
|
|
69 |
}
|
70 |
+
for model, ratings in response.model_ratings.items()
|
71 |
+
}
|
72 |
+
else:
|
73 |
+
st.session_state.previous_ratings[config_id] = {
|
74 |
+
model: {
|
75 |
+
'query_v_ratings': getattr(ratings, 'query_v_ratings', {}),
|
76 |
+
'query_p0_ratings': getattr(ratings, 'query_p0_ratings', {}),
|
77 |
+
'query_p1_ratings': getattr(ratings, 'query_p1_ratings', {})
|
78 |
}
|
79 |
+
for model, ratings in response.model_ratings.items()
|
80 |
+
}
|
81 |
+
st.session_state.current_index += 1
|
82 |
+
st.rerun()
|
83 |
|
84 |
with col3: # Submit button
|
85 |
if st.button("Submit & Resume Later"):
|