Spaces:
Running
Running
File size: 2,126 Bytes
a1371ed 67fde39 a1371ed 9f5efd9 a1371ed 9f5efd9 a1371ed 9f5efd9 a1371ed 9f5efd9 a1371ed |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import firebase_admin
from firebase_admin import credentials, db
import streamlit as st
def init_connection():
cred = credentials.Certificate('./cs6983-tutor-firebase-adminsdk-fbsvc-9db3bc9bd3.json')
if not firebase_admin._apps:
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://cs6983-tutor-default-rtdb.firebaseio.com/'
})
def push_presurvey_data(q1, q2, q3, q3_other):
ref = db.reference('presurvey')
ref.push({
'name': st.session_state.name,
'group_id': st.session_state.group_id,
'q1': q1,
'q2': q2,
'q3': q3,
'q3_other': q3_other
})
def push_postsurvey_data(q1, q2, q3, q4, q5, q6, q7, q8, q9):
ref = db.reference('postsurvey')
ref.push({
'name': st.session_state.name,
'group_id': st.session_state.group_id,
'q1': q1,
'q2': q2,
'q3': q3,
'q4': q4,
'q5': q5,
'q6': q6,
'q7': q7,
'q8': q8,
'q9': q9
})
def push_prequiz_data(prequiz_correct, duration):
ref = db.reference('prequiz')
ref.push({
'name': st.session_state.name,
'group_id': st.session_state.group_id,
'q1': prequiz_correct[0],
'q2': prequiz_correct[1],
'q3': prequiz_correct[2],
'q4': prequiz_correct[3],
'q5': prequiz_correct[4],
'q6': prequiz_correct[5],
'q7': prequiz_correct[6],
'q8': prequiz_correct[7],
'q9': prequiz_correct[8],
'q10': prequiz_correct[9],
'time': duration
})
def push_postquiz_data(postquiz_correct, duration):
ref = db.reference('postquiz')
ref.push({
'name': st.session_state.name,
'group_id': st.session_state.group_id,
'q1': postquiz_correct[0],
'q2': postquiz_correct[1],
'q3': postquiz_correct[2],
'q4': postquiz_correct[3],
'q5': postquiz_correct[4],
'q6': postquiz_correct[5],
'q7': postquiz_correct[6],
'q8': postquiz_correct[7],
'q9': postquiz_correct[8],
'q10': postquiz_correct[9],
'time': duration
})
def push_study_time_data(duration):
ref = db.reference('study_time')
ref.push({
'name': st.session_state.name,
'group_id': st.session_state.group_id,
'time': duration
}) |