Sina Media Lab commited on
Commit
bbafe5e
Β·
1 Parent(s): 22745fe
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -49,15 +49,15 @@ def generate_pdf_report():
49
  pdf.multi_cell(0, 10, f"Q{idx+1}: {question}")
50
  for option in options:
51
  if option == correct:
52
- pdf.multi_cell(0, 10, f"βœ… {option} (Correct)")
53
  elif option == selected:
54
- pdf.multi_cell(0, 10, f"❌ {option} (Your Choice)")
55
  else:
56
  pdf.multi_cell(0, 10, f" {option}")
57
  pdf.multi_cell(0, 10, f"Explanation: {explanation}")
58
  pdf.ln(10)
59
 
60
- return pdf.output(dest='S').encode('utf-8')
61
 
62
  # Streamlit interface
63
  st.sidebar.title("Quiz Modules")
@@ -119,16 +119,8 @@ if module_name:
119
  correct_percentage = (st.session_state.correct_count / st.session_state.question_count) * 100
120
  st.write(f"**Correct Answers:** {st.session_state.correct_count}/{st.session_state.question_count} ({correct_percentage:.2f}%)")
121
 
122
- st.markdown(
123
- f"""
124
- <div style='border: 2px solid #ccc; padding: 15px; background-color: #f9f9f9;'>
125
- <strong>Question {st.session_state.question_count + 1}:</strong> {st.session_state.current_question}
126
- <br>
127
- {st.radio("Choose an answer:", st.session_state.options, key=st.session_state.question_count)}
128
- </div>
129
- """,
130
- unsafe_allow_html=True
131
- )
132
 
133
  if st.button("Submit"):
134
  st.session_state.submitted = True
@@ -143,14 +135,14 @@ if module_name:
143
 
144
  if st.session_state.selected_answer == st.session_state.correct_answer:
145
  st.session_state.correct_count += 1
146
- st.success("βœ… Correct!")
147
  else:
148
- st.error("❌ Incorrect.")
149
 
150
  # Explanation with proper width
151
  st.markdown(
152
  f"""
153
- <div style='border: 2px solid #ccc; padding: 15px; background-color: #f0f0f0;'>
154
  <strong>Explanation:</strong> {st.session_state.explanation}
155
  </div>
156
  """,
 
49
  pdf.multi_cell(0, 10, f"Q{idx+1}: {question}")
50
  for option in options:
51
  if option == correct:
52
+ pdf.multi_cell(0, 10, f"βœ”οΈ {option} (Correct)")
53
  elif option == selected:
54
+ pdf.multi_cell(0, 10, f"✘ {option} (Your Choice)")
55
  else:
56
  pdf.multi_cell(0, 10, f" {option}")
57
  pdf.multi_cell(0, 10, f"Explanation: {explanation}")
58
  pdf.ln(10)
59
 
60
+ return pdf.output(dest='S').encode('latin-1', 'replace')
61
 
62
  # Streamlit interface
63
  st.sidebar.title("Quiz Modules")
 
119
  correct_percentage = (st.session_state.correct_count / st.session_state.question_count) * 100
120
  st.write(f"**Correct Answers:** {st.session_state.correct_count}/{st.session_state.question_count} ({correct_percentage:.2f}%)")
121
 
122
+ st.write(f"**Question {st.session_state.question_count + 1}:** {st.session_state.current_question}")
123
+ st.session_state.selected_answer = st.radio("Choose an answer:", st.session_state.options)
 
 
 
 
 
 
 
 
124
 
125
  if st.button("Submit"):
126
  st.session_state.submitted = True
 
135
 
136
  if st.session_state.selected_answer == st.session_state.correct_answer:
137
  st.session_state.correct_count += 1
138
+ st.success("βœ”οΈ Correct!")
139
  else:
140
+ st.error("✘ Incorrect.")
141
 
142
  # Explanation with proper width
143
  st.markdown(
144
  f"""
145
+ <div style='border: 2px solid #ccc; padding: 15px;'>
146
  <strong>Explanation:</strong> {st.session_state.explanation}
147
  </div>
148
  """,