shreypatel19 commited on
Commit
a1371ed
·
1 Parent(s): 18ca070

started working on firebase

Browse files
cs6983-tutor-firebase-adminsdk-fbsvc-9db3bc9bd3.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "cs6983-tutor",
4
+ "private_key_id": "9db3bc9bd31ae6b09982f02d8e6c20874d0359d6",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQChlc8O5679qINS\ndxnoipGEoWd0vvGjfEj+F79Dl9JpSd/J6l19zIzWhbnLVYOg5H8bxJwZ5JbHbnqs\neLx+WoeZddgcYDthivfwDxQ3bCW7V6bjJZRlyBtd8GFqRo0O6wVZPaGI6C6cltEe\nV16uHiiEUconV70Xcey2bkY5p1LuNTJHvwze5jFQ86eo+cMPpyR6qB/7LoMdDavk\nu+5LsNyLgD1fzC04+ROvjhscUne7FJcnPo70XrxtfIySRfAzfzdiCjU5fcDA+rHC\nIG6ijB73yAfkwIH9Yw7ZdRCLb+9wClfrin14mMI7p305rryxF1i6PPETHLaIcsr5\nAhx8vpbnAgMBAAECggEAAqUnVWj2hOGAJivxSSISPW0U+qTGON+9JCezB6y8aDZ/\nith4J6nfDlifENSOtJC5AfUx0adbzoT2TiIl18hXRZcCbtMmdbN8Lo+t9uBMLSkY\nqsmVMyYCSK3kMloC+iEKc9+zPWtWRABLXmdIvf9GuNp2kuFNT6Jw9mWPZxHgT3+Z\nv8VhHEuirxM0xfqRHJiO7Jv4Zrj9OnsbxcOtgHvBG3Opa6yfpIO1efq984Jy6iXw\nnegsQXyXA4sAV1+FQ++uImwKwcc9WDu5gXStZ732Py+vroOFGUtY5QZftm3b8wZL\nEC8LZI3ZDJxHdgr0B7wbbhHbI1ZGwYa5smqEcVOWxQKBgQDea6NAsgjd6+pVFwhC\nEa2U6WB23PYK3PqkZP6cviOdN3HT2EF3yjWgBk+9aKxNk3eElRDFleh/jU/yk/qJ\nSLXZnII7jlqeLARjoJb9o/rRxbhi5ERmmZO0puLVyveM9dhfxgWKdsousj2aU5ql\nuAb2xe858fSVvY+BlJ3erLvU8wKBgQC5+vCEJlLFkGl7pfIyubqFOiEKlpdLFCCm\nVMy5wHnRZPlTI2PlpA0RgN1X9GD7mb+mJ5DQpguI2DdyVS9zS8JPY+StJ2toYoRi\n7W8lkd4uBS05p4zxUVRq7nXlc8bCv6fJgHKjAYLKJqpqhHafYRHaxfuUkCK8qKZ2\n+YSbtQoDPQKBgFF+BpaRpIYLBhSfF7t9VqgUye9DDjL0vDC3gEJVuB7GTcJcncAS\nKouzREwVqevSeBvvsfFy93ikggJTDZx3M4nDukOv6KvDXOhT0n6kMiXh16kEEbu1\n0VSDQOEsOH9BJEIS/7y3wWRSkheVQjgtsP+BjiEg8Yhbp9TGawFHMJrZAoGBAJBT\nwFEdmIB/KIzvZDyfS7NWQAwCf5ihHxFVn6bLSv4H+UDepwiwPgAGXD+Eg7rdPxBH\nhieVpD/nY2gT2YYFFd8ca3tAqybPxWMsVWP3hk96bvVeJI+liPiO4+lT5rx9lU1X\npB8B7ijIxtlwwMnAv+ViXXGWRY7Y5o5P5uwbG5EVAoGBAIvdl4wNNJ8Z7qaI6G68\naccHwKjujIKGDohVYlStjfJN9UNJzpOXacj362FFdlwxNve6KlGQkRKmd5bP0bNR\nD9LXiYVP1N23w4lpdjUnfmx3vygszkk1dnHlLTbyLwo234b+17eL5Mw+tnG85ILf\nn42jVEHVLEbxstADwX/Rn0T8\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "[email protected]",
7
+ "client_id": "113263299691307350865",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40cs6983-tutor.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }
pages/postquiz.py CHANGED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from utils.firebase_util import push_postquiz_data
4
+
5
+ df = pd.read_csv("./LSATLR_questions.csv")
6
+ df['qid'] = df['qid'].astype(int)
7
+ postquiz_qs = df[df['qid'] > 0].sort_values(by='qid', ascending=False).reset_index(drop=True)
8
+
9
+ st.title("Post-Quiz")
10
+ st.write("Please answer the following questions to the best of your ability. (Est. time: 15m)")
11
+
12
+ questions = []
13
+ for index, row in postquiz_qs.iterrows():
14
+ st.write(f"Question {index + 1}:")
15
+ questions.append(st.radio(
16
+ row['Question'],
17
+ [row['A'], row['B'], row['C'], row['D'], row['E']],
18
+ key=f'prequiz{row["qid"]}',
19
+ ))
20
+ st.divider()
21
+
22
+ def on_submit():
23
+ corr = []
24
+ for index, row in postquiz_qs.iterrows():
25
+ correct_answer = row[row['Correct Ans.']]
26
+ if questions[index] == correct_answer:
27
+ corr.append(1)
28
+ else:
29
+ corr.append(0)
30
+ postquiz_qs['Correct'] = corr
31
+ postquiz_qs.groupby('Subtopic').agg(num_correct=('Correct', 'sum'), num_questions=('Correct', 'count')).reset_index()
32
+ push_postquiz_data(corr)
33
+ st.switch_page("pages/postsurvey.py")
34
+
35
+
36
+
37
+ st.button("Submit", on_click=on_submit)
38
+
pages/postsurvey.py CHANGED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.firebase_util import push_postsurvey_data
3
+
4
+ st.write("Please answer the following questions")
5
+ q1 = st.radio("How was the difficulty of the second quiz compared to the first?",
6
+ ["Easier", "Litttle Easier", "Similar", "Little Harder", "Harder"],
7
+ key="postquiz1")
8
+ q2 = st.slider("On a scale of 1-5, how ready do you feel about your logical reasoning skills post the study?" \
9
+ "1: No change at all\n" \
10
+ "5: Significant improvement",
11
+ 1, 5, 3)
12
+ q3 = st.slider("How helpful did you find the AI tutor to help you learn concepts?" \
13
+ "1: Not helpful at all\n" \
14
+ "5: Extremely helpful",
15
+ 1, 5, 3)
16
+ q4 = st.slider("How often did you find it confusing and frustrating when learning?" \
17
+ "1: Never" \
18
+ "5: Frequently",
19
+ 1, 5, 3)
20
+ q5 = st.slider("How engaging did you find the tutoring experience?" \
21
+ "1: Completely boring" \
22
+ "5: Extremely engaging",
23
+ 1, 5, 3)
24
+ q6 = st.radio("Would you use this type of studing (textbook/AI) future learning experiences?",
25
+ ["Yes", "No"],
26
+ key="postquiz6")
27
+ q7 = st.text_input("What did you like about the learning experience?")
28
+ q8 = st.text_input("What did you dislike about the learning experience?")
29
+ q9 = st.text_input("What would you like to see improved in the future?")
30
+
31
+ btn = st.button("Submit")
32
+
33
+ if btn:
34
+ push_postsurvey_data(q1, q2, q3, q4, q5, q6, q7, q8, q9)
35
+ st.write("Thank you for your participation!")
36
+ st.stop()
pages/prequiz.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import os
4
 
5
  df = pd.read_csv("./LSATLR_questions.csv")
6
  df['qid'] = df['qid'].astype(int)
@@ -28,10 +28,15 @@ def on_submit():
28
  else:
29
  corr.append(0)
30
  prequiz_qs['Correct'] = corr
31
- prequiz_qs.groupby('Subtopic').agg(num_correct=('Correct', 'sum'), num_questions=('Correct', 'count')).reset_index()
32
- st.session_state.prequiz_df = prequiz_qs
 
 
 
 
 
33
 
34
 
35
 
36
- st.button("Submit", on_click=lambda: st.session_state.update({"prequiz_answers": questions}))
37
 
 
1
  import streamlit as st
2
  import pandas as pd
3
+ from utils.firebase_util import push_prequiz_data
4
 
5
  df = pd.read_csv("./LSATLR_questions.csv")
6
  df['qid'] = df['qid'].astype(int)
 
28
  else:
29
  corr.append(0)
30
  prequiz_qs['Correct'] = corr
31
+ pqq_processed = prequiz_qs.groupby('Subtopic').agg(num_correct=('Correct', 'sum'), num_questions=('Correct', 'count')).reset_index()
32
+ st.session_state.prequiz_df = pqq_processed
33
+ push_prequiz_data(corr)
34
+ if st.session_state.group_id == "A":
35
+ st.switch_page("pages/llm_tutor.py")
36
+ else:
37
+ st.switch_page("pages/textbook.py")
38
 
39
 
40
 
41
+ st.button("Submit", on_click=on_submit)
42
 
requirements.txt CHANGED
@@ -3,3 +3,4 @@ chromadb
3
  genai
4
  datasets
5
  joblib
 
 
3
  genai
4
  datasets
5
  joblib
6
+ firebase-admin
utils/firebase_util.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import firebase_admin
2
+ from firebase_admin import credentials, db
3
+ import streamlit as st
4
+
5
+ cred = credentials.Certificate('../cs6983-tutor-firebase-adminsdk-fbsvc-9db3bc9bd3.json')
6
+ firebase_admin.initialize_app(cred, {
7
+ 'databaseURL': 'https://cs6983-tutor-default-rtdb.firebaseio.com/'
8
+ })
9
+
10
+ def push_presurvey_data(q1, q2, q3, q3_other):
11
+ ref = db.reference('presurvey')
12
+ ref.push({
13
+ 'name': st.session_state.name,
14
+ 'group_id': st.session_state.group_id,
15
+ 'q1': q1,
16
+ 'q2': q2,
17
+ 'q3': q3,
18
+ 'q3_other': q3_other
19
+ })
20
+
21
+ def push_postsurvey_data(q1, q2, q3, q4, q5, q6, q7, q8, q9):
22
+ ref = db.reference('postsurvey')
23
+ ref.push({
24
+ 'name': st.session_state.name,
25
+ 'group_id': st.session_state.group_id,
26
+ 'q1': q1,
27
+ 'q2': q2,
28
+ 'q3': q3,
29
+ 'q4': q4,
30
+ 'q5': q5,
31
+ 'q6': q6,
32
+ 'q7': q7,
33
+ 'q8': q8,
34
+ 'q9': q9
35
+ })
36
+
37
+ def push_prequiz_data(prequiz_correct):
38
+ ref = db.reference('prequiz')
39
+ ref.push({
40
+ 'name': st.session_state.name,
41
+ 'group_id': st.session_state.group_id,
42
+ 'q1': prequiz_correct[0],
43
+ 'q2': prequiz_correct[1],
44
+ 'q3': prequiz_correct[2],
45
+ 'q4': prequiz_correct[3],
46
+ 'q5': prequiz_correct[4],
47
+ 'q6': prequiz_correct[5],
48
+ 'q7': prequiz_correct[6],
49
+ 'q8': prequiz_correct[7],
50
+ 'q9': prequiz_correct[8],
51
+ 'q10': prequiz_correct[9],
52
+ })
53
+
54
+ def push_postquiz_data(postquiz_correct):
55
+ ref = db.reference('postquiz')
56
+ ref.push({
57
+ 'name': st.session_state.name,
58
+ 'group_id': st.session_state.group_id,
59
+ 'q1': postquiz_correct[0],
60
+ 'q2': postquiz_correct[1],
61
+ 'q3': postquiz_correct[2],
62
+ 'q4': postquiz_correct[3],
63
+ 'q5': postquiz_correct[4],
64
+ 'q6': postquiz_correct[5],
65
+ 'q7': postquiz_correct[6],
66
+ 'q8': postquiz_correct[7],
67
+ 'q9': postquiz_correct[8],
68
+ 'q10': postquiz_correct[9],
69
+ })