louiecerv commited on
Commit
984ed78
·
2 Parent(s): 067b650 e602057
Files changed (2) hide show
  1. pages/4_View_Result.py +4 -0
  2. quiz_gui_helper.py +4 -0
pages/4_View_Result.py CHANGED
@@ -1,4 +1,6 @@
1
  import streamlit as st
 
 
2
 
3
  def main():
4
  st.title("View Results")
@@ -7,6 +9,8 @@ def main():
7
  st.error("No completed exam results available.")
8
  else:
9
  st.write("Displaying results...")
 
 
10
 
11
  if st.button("Retake Exam"):
12
  st.session_state.quiz_completed = False
 
1
  import streamlit as st
2
+ import json
3
+ from quiz_gui_helper import _QuizGUI
4
 
5
  def main():
6
  st.title("View Results")
 
9
  st.error("No completed exam results available.")
10
  else:
11
  st.write("Displaying results...")
12
+ quiz_data = st.session_state.quiz_data
13
+ _QuizGUI(quiz_data).view_results()
14
 
15
  if st.button("Retake Exam"):
16
  st.session_state.quiz_completed = False
quiz_gui_helper.py CHANGED
@@ -60,7 +60,11 @@ class _QuizGUI:
60
  st.button("Next", on_click=self.check_answer)
61
  else:
62
  st.success(f"Quiz completed! Your final score is {st.session_state.score}/{len(self.quiz_data)}.")
 
 
63
 
 
 
64
  st.write("### Quiz Summary")
65
  for i, question_data in enumerate(self.quiz_data):
66
  st.write(f"**Question {i + 1}:** {question_data['question']}")
 
60
  st.button("Next", on_click=self.check_answer)
61
  else:
62
  st.success(f"Quiz completed! Your final score is {st.session_state.score}/{len(self.quiz_data)}.")
63
+ st.write("You can view the summary of your quiz in the results page.")
64
+ st.session_state.quiz_completed = True
65
 
66
+ def view_results(self):
67
+ if st.session_state.completed:
68
  st.write("### Quiz Summary")
69
  for i, question_data in enumerate(self.quiz_data):
70
  st.write(f"**Question {i + 1}:** {question_data['question']}")