Sina Media Lab
commited on
Commit
·
054ca33
1
Parent(s):
d2fbd53
Updates
Browse files
app.py
CHANGED
@@ -31,6 +31,8 @@ if 'module_correct_count' not in st.session_state:
|
|
31 |
st.session_state.module_correct_count = {name: 0 for name in module_names}
|
32 |
if 'module_question_count' not in st.session_state:
|
33 |
st.session_state.module_question_count = {name: 0 for name in module_names}
|
|
|
|
|
34 |
|
35 |
def generate_pdf_report():
|
36 |
pdf = FPDF()
|
@@ -114,8 +116,14 @@ if module_name != st.session_state.current_module:
|
|
114 |
# Generate the first question for the new module
|
115 |
st.session_state.questions.append(generate_new_question(module_name))
|
116 |
|
|
|
|
|
117 |
current_question = st.session_state.questions[st.session_state.current_index]
|
118 |
|
|
|
|
|
|
|
|
|
119 |
# Button Row: Prev, Next, and PDF Download
|
120 |
col1, col2, col3 = st.columns([1, 1, 2])
|
121 |
with col1:
|
@@ -152,7 +160,7 @@ if current_question['answered']:
|
|
152 |
else:
|
153 |
selected_answer = st.radio("Choose an answer:", current_question['options'], key=st.session_state.current_index)
|
154 |
if st.button("Submit"):
|
155 |
-
if
|
156 |
current_question['selected'] = selected_answer
|
157 |
current_question['answered'] = True
|
158 |
st.session_state.module_question_count[module_name] += 1
|
@@ -161,4 +169,4 @@ else:
|
|
161 |
st.session_state.correct_count += 1
|
162 |
st.session_state.module_correct_count[module_name] += 1
|
163 |
|
164 |
-
#
|
|
|
31 |
st.session_state.module_correct_count = {name: 0 for name in module_names}
|
32 |
if 'module_question_count' not in st.session_state:
|
33 |
st.session_state.module_question_count = {name: 0 for name in module_names}
|
34 |
+
if 'selected_answer' not in st.session_state:
|
35 |
+
st.session_state.selected_answer = None
|
36 |
|
37 |
def generate_pdf_report():
|
38 |
pdf = FPDF()
|
|
|
116 |
# Generate the first question for the new module
|
117 |
st.session_state.questions.append(generate_new_question(module_name))
|
118 |
|
119 |
+
# Load the current module for title and description
|
120 |
+
current_module = load_module(st.session_state.current_module)
|
121 |
current_question = st.session_state.questions[st.session_state.current_index]
|
122 |
|
123 |
+
# Display module title and description
|
124 |
+
st.title(current_module.title)
|
125 |
+
st.write(current_module.description)
|
126 |
+
|
127 |
# Button Row: Prev, Next, and PDF Download
|
128 |
col1, col2, col3 = st.columns([1, 1, 2])
|
129 |
with col1:
|
|
|
160 |
else:
|
161 |
selected_answer = st.radio("Choose an answer:", current_question['options'], key=st.session_state.current_index)
|
162 |
if st.button("Submit"):
|
163 |
+
if selected_answer:
|
164 |
current_question['selected'] = selected_answer
|
165 |
current_question['answered'] = True
|
166 |
st.session_state.module_question_count[module_name] += 1
|
|
|
169 |
st.session_state.correct_count += 1
|
170 |
st.session_state.module_correct_count[module_name] += 1
|
171 |
|
172 |
+
st.experimental_rerun() # Trigger a rerun to display the result immediately
|