File size: 1,893 Bytes
0070e0b
 
 
020091c
0070e0b
 
 
 
 
 
 
 
020091c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0070e0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st 
import pandas as pd
import time
import altair as alt

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("Results:")

def display_pre_quiz():
   source = st.session_state.prequiz_df
   if source is not None and len(source) > 0: 
    st.write("Pre-Quiz Results: \n")
    source["Performance"] = source["num_correct"] / source["num_questions"] * 100
    source = source.sort_values(by='Performance', ascending=False)
    c = alt.Chart(source).mark_bar().encode(y=alt.Y("Subtopic", sort=None), x=alt.X(
                "Performance",
                scale=alt.Scale(domain=[0, 100]),
                axis=alt.Axis(values=[0, 25, 50, 75, 100], title="Performance (%)")
            ))
    st.altair_chart(c,use_container_width=True)

display_pre_quiz()

def response_to_idx(response, row):
  if response == row['A']:
    return 0
  elif response == row['B']:
    return 1
  elif response == row['C']:
    return 2
  elif response == row['D']:
    return 3
  elif response == row['E']:
    return 4

questions = []
for index, row in prequiz_qs.iterrows():
  check_or_x = 'βœ…' if st.session_state.pre_quiz_correct[index] == 1 else '❌'
  st.write(f"Question {index + 1}: {check_or_x}")
  questions.append(st.radio(
    row['Question'],
    [row['A'], row['B'], row['C'], row['D'], row['E']],
    key=f'prequiz{row["qid"]}',
    index=response_to_idx(st.session_state.pre_quiz_answers[index], row),
    disabled=True
  ))
  st.divider()

btn = st.button("Click here when finished")

if btn:
  if st.session_state.group_id == "A":
    st.session_state.tutor_start_time = time.time()
    st.switch_page("pages/llm_tutor.py")
  else:
    st.session_state.textbook_start_time = time.time()
    st.switch_page("pages/textbook.py")