louiecerv commited on
Commit
e602057
·
1 Parent(s): 00c87b7

fixed navigation logic

Browse files
__pycache__/quiz_gui_helper.cpython-313.pyc CHANGED
Binary files a/__pycache__/quiz_gui_helper.cpython-313.pyc and b/__pycache__/quiz_gui_helper.cpython-313.pyc differ
 
pages/3_Take_Exam.py CHANGED
@@ -11,6 +11,8 @@ if "quiz_started" not in st.session_state:
11
  if "quiz_loaded" not in st.session_state:
12
  st.session_state.quiz_loaded = False
13
 
 
 
14
 
15
  def main():
16
  if not st.session_state.quiz_loaded:
@@ -19,6 +21,8 @@ def main():
19
 
20
  if st.session_state.quiz_started:
21
  st.write("You are currently taking the exam.")
 
 
22
 
23
  else:
24
  #read the metadata and quiz_data from the session state
 
11
  if "quiz_loaded" not in st.session_state:
12
  st.session_state.quiz_loaded = False
13
 
14
+ if "quiz_completed" not in st.session_state:
15
+ st.session_state.quiz_completed = False
16
 
17
  def main():
18
  if not st.session_state.quiz_loaded:
 
21
 
22
  if st.session_state.quiz_started:
23
  st.write("You are currently taking the exam.")
24
+ quiz_data = st.session_state.quiz_data
25
+ _QuizGUI(quiz_data).start_quiz()
26
 
27
  else:
28
  #read the metadata and quiz_data from the session state
pages/4_View_Result.py CHANGED
@@ -1,12 +1,16 @@
1
  import streamlit as st
 
 
2
 
3
  def main():
4
  st.title("View Results")
5
 
6
- if not st.session_state.exam_completed:
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")
7
 
8
+ if not st.session_state.quiz_completed:
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
@@ -58,7 +58,11 @@ class _QuizGUI:
58
  st.button("Next", on_click=self.check_answer)
59
  else:
60
  st.success(f"Quiz completed! Your final score is {st.session_state.score}/{len(self.quiz_data)}.")
 
 
61
 
 
 
62
  st.write("### Quiz Summary")
63
  for i, question_data in enumerate(self.quiz_data):
64
  st.write(f"**Question {i + 1}:** {question_data['question']}")
@@ -69,3 +73,5 @@ class _QuizGUI:
69
  st.write("- **Result:** ✅ Correct")
70
  else:
71
  st.write("- **Result:** ❌ Incorrect")
 
 
 
58
  st.button("Next", on_click=self.check_answer)
59
  else:
60
  st.success(f"Quiz completed! Your final score is {st.session_state.score}/{len(self.quiz_data)}.")
61
+ st.write("You can view the summary of your quiz in the results page.")
62
+ st.session_state.quiz_completed = True
63
 
64
+ def view_results(self):
65
+ if st.session_state.completed:
66
  st.write("### Quiz Summary")
67
  for i, question_data in enumerate(self.quiz_data):
68
  st.write(f"**Question {i + 1}:** {question_data['question']}")
 
73
  st.write("- **Result:** ✅ Correct")
74
  else:
75
  st.write("- **Result:** ❌ Incorrect")
76
+ else:
77
+ st.warning("Please complete the quiz first.")