File size: 1,619 Bytes
b1b782c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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())