import streamlit as st from google.cloud import firestore # Authenticate to Firestore with the JSON account key. db = firestore.Client.from_service_account_json("./firebase.json") def show_likert_scale(step, type, id): st.write("-----------------------------------") st.subheader(f"'{type}' makes sense to me.") scale = st.radio( "", ["Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly agree"], index=None, horizontal=True, ) if type == 'Whole': dependsOn = 'Whole' else: st.write("..................................."*10) st.subheader(f"'{type}' is dependent on?") dependsOn = st.radio( "", ["Image", "Text", "Both", "Neither"], index=None, horizontal=True, ) submit = st.button('Submit', disabled=scale is None or dependsOn is None) st.write("-----------------------------------") if submit and scale: st.write(f"You selected '{scale}' and {dependsOn}.") user = st.session_state['user'] doc_ref = db.collection(step).document(id) doc_ref.set({ user: { 'scale': scale, 'dependsOn': dependsOn, }, }, merge=True) return True # show_likert_scale('all', 'tmp_cond', '10') # Create a reference to the Google post. # doc_ref = db.collection("posts").document("Google") # # Then get the data at that reference. # doc = doc_ref.get() # # Let's see what we got! # st.write("The id iss: ", doc.id) # st.write("The contents are: ", doc.to_dict())