Update app.py
Browse files
app.py
CHANGED
|
@@ -77,7 +77,7 @@ def take_quiz():
|
|
| 77 |
quiz = st.session_state.quizzes[quiz_name]
|
| 78 |
|
| 79 |
for idx, q in enumerate(quiz):
|
| 80 |
-
st.write(f"{idx + 1}. {q['question']}")
|
| 81 |
|
| 82 |
if q['type'] == "Multiple Choice":
|
| 83 |
answer = st.radio("", q['options'], key=f"question_{idx}")
|
|
@@ -93,7 +93,6 @@ def take_quiz():
|
|
| 93 |
st.session_state.results[quiz_name] = responses
|
| 94 |
st.success("Quiz submitted successfully!")
|
| 95 |
|
| 96 |
-
|
| 97 |
def view_results():
|
| 98 |
st.header("View Results")
|
| 99 |
|
|
@@ -116,10 +115,14 @@ def view_results():
|
|
| 116 |
|
| 117 |
if question['type'] == "Multiple Choice" and response == question['correct']:
|
| 118 |
correct_count += 1
|
| 119 |
-
elif question['type'] == "Short Answer" and response.lower() == question['correct'].lower():
|
| 120 |
correct_count += 1
|
| 121 |
|
| 122 |
st.write(f"Score: {correct_count}/{len(quiz)}")
|
| 123 |
|
| 124 |
if __name__ == "__main__":
|
| 125 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
quiz = st.session_state.quizzes[quiz_name]
|
| 78 |
|
| 79 |
for idx, q in enumerate(quiz):
|
| 80 |
+
st.write(f"{idx + 1}. {q['question']}\n")
|
| 81 |
|
| 82 |
if q['type'] == "Multiple Choice":
|
| 83 |
answer = st.radio("", q['options'], key=f"question_{idx}")
|
|
|
|
| 93 |
st.session_state.results[quiz_name] = responses
|
| 94 |
st.success("Quiz submitted successfully!")
|
| 95 |
|
|
|
|
| 96 |
def view_results():
|
| 97 |
st.header("View Results")
|
| 98 |
|
|
|
|
| 115 |
|
| 116 |
if question['type'] == "Multiple Choice" and response == question['correct']:
|
| 117 |
correct_count += 1
|
| 118 |
+
elif question['type'] == "Short Answer" and response and question['correct'] and response.lower() == question['correct'].lower():
|
| 119 |
correct_count += 1
|
| 120 |
|
| 121 |
st.write(f"Score: {correct_count}/{len(quiz)}")
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
| 124 |
main()
|
| 125 |
+
|
| 126 |
+
# requirements.txt
|
| 127 |
+
# streamlit==1.25.0
|
| 128 |
+
# pandas==1.5.3
|