Spaces:
Running
Running
Yara Kyrychenko
commited on
Commit
Β·
026e174
1
Parent(s):
6f15ef8
remove completion code and upd Finish to Submit Interaction
Browse files
app.py
CHANGED
|
@@ -76,17 +76,15 @@ with st.sidebar:
|
|
| 76 |
|
| 77 |
β Do not share any personal information (e.g., name or address).
|
| 78 |
|
| 79 |
-
β οΈ You must click on **at least 5 links** before you will see a *
|
| 80 |
|
| 81 |
β If you encounter any technical issues, please let us know.
|
| 82 |
|
| 83 |
-
{"β" if st.session_state.inserted > 1 else "β"} **Step 3.
|
| 84 |
-
|
| 85 |
-
β οΈ Do not forget to copy & paste your completion code!
|
| 86 |
|
| 87 |
βΊ You can always return to this panel by clicking the arrow on the top left.
|
| 88 |
|
| 89 |
-
{"π **All done! Please
|
| 90 |
""")
|
| 91 |
if st.session_state.gotit == False or st.session_state.submitted == False:
|
| 92 |
st.session_state.gotit = st.button("Let's start!", key=None, help=None, use_container_width=True)
|
|
@@ -193,12 +191,30 @@ elif st.session_state.submitted == False:
|
|
| 193 |
pass
|
| 194 |
|
| 195 |
elif st.session_state.inserted > 1:
|
| 196 |
-
st.markdown("##
|
| 197 |
-
st.markdown('**
|
| 198 |
-
st.markdown(f'## {st.session_state.user_id}')
|
| 199 |
-
st.markdown('**Please copy the code and enter it into the survey field below.**')
|
| 200 |
|
| 201 |
elif query := st.text_input("Enter search query and press Enter", placeholder="Search Google..."):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
if query != st.session_state.messages[-1]["query"] or st.session_state.page != st.session_state.messages[-1]["page"]:
|
| 204 |
results = google_search(query, st.session_state.page)
|
|
@@ -218,25 +234,3 @@ elif query := st.text_input("Enter search query and press Enter", placeholder="S
|
|
| 218 |
if st.button("Next Page β‘οΈ",use_container_width=True):
|
| 219 |
st.session_state.page += 1
|
| 220 |
st.rerun()
|
| 221 |
-
|
| 222 |
-
if (len(st.session_state.clicked_links) > 4 or st.session_state.max_messages == len(st.session_state.messages)) and not st.session_state.inserted > 1:
|
| 223 |
-
columns = st.columns((1,1,1))
|
| 224 |
-
with columns[2]:
|
| 225 |
-
if st.button("Finish",use_container_width=True):
|
| 226 |
-
keys = ["inserted", "messages", "convo_start_time", 'clicked_links']
|
| 227 |
-
|
| 228 |
-
st.session_state.user_data.update({key: st.session_state[key] for key in keys})
|
| 229 |
-
|
| 230 |
-
st.session_state.user_data["convo_end_time"] = datetime.now()
|
| 231 |
-
|
| 232 |
-
with MongoClient(st.secrets["mongo"],server_api=ServerApi('1')) as client:
|
| 233 |
-
db = client.chat
|
| 234 |
-
collection = db.app
|
| 235 |
-
user_data = st.session_state.user_data
|
| 236 |
-
#del user_data['_id']
|
| 237 |
-
|
| 238 |
-
collection.insert_one(user_data)
|
| 239 |
-
st.session_state.inserted += 1
|
| 240 |
-
|
| 241 |
-
st.rerun()
|
| 242 |
-
|
|
|
|
| 76 |
|
| 77 |
β Do not share any personal information (e.g., name or address).
|
| 78 |
|
| 79 |
+
β οΈ You must click on **at least 5 links** before you will see a *Submit Interaction* button. You can continue before submitting, but but **you must click *Submit Interaction* to recieve compensation**.
|
| 80 |
|
| 81 |
β If you encounter any technical issues, please let us know.
|
| 82 |
|
| 83 |
+
{"β" if st.session_state.inserted > 1 else "β"} **Step 3. Press the *Submit Interaction* button**
|
|
|
|
|
|
|
| 84 |
|
| 85 |
βΊ You can always return to this panel by clicking the arrow on the top left.
|
| 86 |
|
| 87 |
+
{"π **All done! Please press *Next* in the survey.**" if st.session_state.inserted > 1 else ""}
|
| 88 |
""")
|
| 89 |
if st.session_state.gotit == False or st.session_state.submitted == False:
|
| 90 |
st.session_state.gotit = st.button("Let's start!", key=None, help=None, use_container_width=True)
|
|
|
|
| 191 |
pass
|
| 192 |
|
| 193 |
elif st.session_state.inserted > 1:
|
| 194 |
+
st.markdown("## Please press *Next* in the survey to proceed.")
|
| 195 |
+
st.markdown('β **This is not the end of the study.**')
|
|
|
|
|
|
|
| 196 |
|
| 197 |
elif query := st.text_input("Enter search query and press Enter", placeholder="Search Google..."):
|
| 198 |
+
if (len(st.session_state.clicked_links) > 4 or st.session_state.max_messages == len(st.session_state.messages)) and not st.session_state.inserted > 1:
|
| 199 |
+
columns = st.columns((1,1,1))
|
| 200 |
+
with columns[2]:
|
| 201 |
+
if st.button("Submit Interaction",use_container_width=True,type='primary'):
|
| 202 |
+
keys = ["inserted", "messages", "convo_start_time", 'clicked_links']
|
| 203 |
+
|
| 204 |
+
st.session_state.user_data.update({key: st.session_state[key] for key in keys})
|
| 205 |
+
|
| 206 |
+
st.session_state.user_data["convo_end_time"] = datetime.now()
|
| 207 |
+
|
| 208 |
+
with MongoClient(st.secrets["mongo"],server_api=ServerApi('1')) as client:
|
| 209 |
+
db = client.chat
|
| 210 |
+
collection = db.app
|
| 211 |
+
user_data = st.session_state.user_data
|
| 212 |
+
#del user_data['_id']
|
| 213 |
+
|
| 214 |
+
collection.insert_one(user_data)
|
| 215 |
+
st.session_state.inserted += 1
|
| 216 |
+
|
| 217 |
+
st.rerun()
|
| 218 |
|
| 219 |
if query != st.session_state.messages[-1]["query"] or st.session_state.page != st.session_state.messages[-1]["page"]:
|
| 220 |
results = google_search(query, st.session_state.page)
|
|
|
|
| 234 |
if st.button("Next Page β‘οΈ",use_container_width=True):
|
| 235 |
st.session_state.page += 1
|
| 236 |
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|