File size: 1,673 Bytes
f571126
 
a1371ed
9f5efd9
f571126
 
 
 
 
 
6b11018
f571126
 
 
 
 
 
 
4fd3a9c
f571126
 
 
 
06592fc
 
9f5efd9
0070e0b
f571126
 
 
 
 
 
 
0070e0b
f571126
a1371ed
 
9f5efd9
0070e0b
f571126
 
 
67fde39
 
 
6b11018
 
 
 
 
 
 
 
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
import streamlit as st 
import pandas as pd
from utils.firebase_util import push_prequiz_data
import time

df = pd.read_csv("./LSATLR_questions.csv")
df['qid'] = df['qid'].astype(int)
prequiz_qs = df[df['qid'] < 0].sort_values(by='qid', ascending=False).reset_index(drop=True)

st.title("Pre-Quiz")
st.write("Please answer the following questions to the best of your ability.\n\nFeel free to use a piece of scrap paper if it would help.\n\n(Est. time: 10-15m)")

questions = []
for index, row in prequiz_qs.iterrows():
  st.write(f"Question {index + 1}:")
  questions.append(st.radio(
    row['Question'],
    [row['A'], row['B'], row['C'], row['D'], row['E']],
    key=f'prequiz{row["qid"]}'
  ))
  st.divider()

def on_submit():
  print(time.time())
  print(st.session_state.prequiz_start_time)
  duration = time.time() - st.session_state.prequiz_start_time
  st.session_state.pre_quiz_answers = questions
  corr = []
  for index, row in prequiz_qs.iterrows():
    correct_answer = row[row['Correct Ans.']]
    if questions[index] == correct_answer:
      corr.append(1)
    else:
      corr.append(0)
  st.session_state.pre_quiz_correct = corr
  prequiz_qs['Correct'] = corr
  pqq_processed = prequiz_qs.groupby('Subtopic').agg(num_correct=('Correct', 'sum'), num_questions=('Correct', 'count')).reset_index()
  st.session_state.prequiz_df = pqq_processed
  push_prequiz_data(corr, duration)
  st.switch_page("pages/prequiz_results.py")
  
      

btn = st.button("Submit")
if btn:
  on_submit()

st.markdown(
    """<style>
div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {
    font-size: 18px;
}
    </style>
    """, unsafe_allow_html=True)