Bhanuprasadchouki commited on
Commit
f401dd7
·
verified ·
1 Parent(s): a445e0a

Update mcq_test.py

Browse files
Files changed (1) hide show
  1. mcq_test.py +6 -7
mcq_test.py CHANGED
@@ -90,7 +90,7 @@ def main():
90
  - B) Training machine learning models
91
  - C) Collecting and labeling data
92
  - D) Evaluating model performance
93
- """ # Add your full string here
94
  st.session_state.questions = parse_mcq_questions(mcq_list)
95
 
96
  # Display current question number and total questions
@@ -100,14 +100,12 @@ def main():
100
  current_q = st.session_state.questions[st.session_state.current_question]
101
  st.write(current_q['question'])
102
 
103
- # Create radio buttons for options with a default value
104
- # The key change is here - we're using a different format for radio buttons
105
- options = list(current_q['options'].items())
106
  answer = st.radio(
107
  "Select your answer:",
108
- options=['A', 'B', 'C', 'D'],
109
- format_func=lambda x: f"{x}) {current_q['options'][x]}",
110
- key=f"question_{st.session_state.current_question}" # Add unique key for each question
111
  )
112
 
113
  # Navigation buttons in columns
@@ -138,5 +136,6 @@ def main():
138
  st.session_state.answers = []
139
  st.rerun()
140
 
 
141
  if __name__ == "__main__":
142
  main()
 
90
  - B) Training machine learning models
91
  - C) Collecting and labeling data
92
  - D) Evaluating model performance
93
+ """
94
  st.session_state.questions = parse_mcq_questions(mcq_list)
95
 
96
  # Display current question number and total questions
 
100
  current_q = st.session_state.questions[st.session_state.current_question]
101
  st.write(current_q['question'])
102
 
103
+ # Create radio buttons for options with the corrected format_func
 
 
104
  answer = st.radio(
105
  "Select your answer:",
106
+ options=['A', 'B', 'C', 'D'], # List of option keys
107
+ format_func=lambda x: f"{x}) {current_q['options'].get(x, 'Invalid Option')}",
108
+ key=f"question_{st.session_state.current_question}" # Unique key per question
109
  )
110
 
111
  # Navigation buttons in columns
 
136
  st.session_state.answers = []
137
  st.rerun()
138
 
139
+
140
  if __name__ == "__main__":
141
  main()