Update app.py
Browse files
app.py
CHANGED
|
@@ -254,11 +254,17 @@ with welcome_message.container():
|
|
| 254 |
time.sleep(4) # Wait for 4 seconds
|
| 255 |
welcome_message.empty() # Remove the welcome message
|
| 256 |
|
| 257 |
-
# Initialize session state for questions and current index
|
| 258 |
if 'questions' not in st.session_state:
|
| 259 |
st.session_state.questions = []
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
if 'question_index' not in st.session_state:
|
| 261 |
st.session_state.question_index = 0
|
|
|
|
|
|
|
| 262 |
|
| 263 |
# Sidebar Navigation
|
| 264 |
st.sidebar.title("TechPrep Navigation")
|
|
@@ -279,7 +285,10 @@ if nav_option == "Generate Questions":
|
|
| 279 |
with st.spinner("Generating questions..."):
|
| 280 |
questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
|
| 281 |
st.session_state.questions = questions
|
|
|
|
|
|
|
| 282 |
st.session_state.question_index = 0
|
|
|
|
| 283 |
progress_data["questions_solved"][question_type] += num_questions
|
| 284 |
|
| 285 |
# Display questions with navigation
|
|
@@ -311,10 +320,35 @@ if nav_option == "Generate Questions":
|
|
| 311 |
else:
|
| 312 |
with st.spinner("Providing feedback..."):
|
| 313 |
feedback = provide_feedback(model_choice, answer)
|
|
|
|
|
|
|
| 314 |
st.markdown(style_output("Feedback Received:", "#FF5722"), unsafe_allow_html=True)
|
| 315 |
st.write(feedback)
|
| 316 |
progress_data["feedback_provided"] += 1
|
| 317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
elif nav_option == "Mock Interview":
|
| 319 |
st.header("🎥 Mock Interview")
|
| 320 |
schedule_mock_interview()
|
|
@@ -332,4 +366,3 @@ st.markdown("""
|
|
| 332 |
</div>
|
| 333 |
""", unsafe_allow_html=True)
|
| 334 |
|
| 335 |
-
|
|
|
|
| 254 |
time.sleep(4) # Wait for 4 seconds
|
| 255 |
welcome_message.empty() # Remove the welcome message
|
| 256 |
|
| 257 |
+
# Initialize session state for questions, answers, and current index
|
| 258 |
if 'questions' not in st.session_state:
|
| 259 |
st.session_state.questions = []
|
| 260 |
+
if 'answers' not in st.session_state:
|
| 261 |
+
st.session_state.answers = []
|
| 262 |
+
if 'feedback' not in st.session_state:
|
| 263 |
+
st.session_state.feedback = []
|
| 264 |
if 'question_index' not in st.session_state:
|
| 265 |
st.session_state.question_index = 0
|
| 266 |
+
if 'show_results' not in st.session_state:
|
| 267 |
+
st.session_state.show_results = False
|
| 268 |
|
| 269 |
# Sidebar Navigation
|
| 270 |
st.sidebar.title("TechPrep Navigation")
|
|
|
|
| 285 |
with st.spinner("Generating questions..."):
|
| 286 |
questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
|
| 287 |
st.session_state.questions = questions
|
| 288 |
+
st.session_state.answers = ["" for _ in questions]
|
| 289 |
+
st.session_state.feedback = ["" for _ in questions]
|
| 290 |
st.session_state.question_index = 0
|
| 291 |
+
st.session_state.show_results = False
|
| 292 |
progress_data["questions_solved"][question_type] += num_questions
|
| 293 |
|
| 294 |
# Display questions with navigation
|
|
|
|
| 320 |
else:
|
| 321 |
with st.spinner("Providing feedback..."):
|
| 322 |
feedback = provide_feedback(model_choice, answer)
|
| 323 |
+
st.session_state.answers[index] = answer
|
| 324 |
+
st.session_state.feedback[index] = feedback
|
| 325 |
st.markdown(style_output("Feedback Received:", "#FF5722"), unsafe_allow_html=True)
|
| 326 |
st.write(feedback)
|
| 327 |
progress_data["feedback_provided"] += 1
|
| 328 |
|
| 329 |
+
# Show results and score when all questions have been answered
|
| 330 |
+
if index == len(question_list) - 1:
|
| 331 |
+
st.session_state.show_results = True
|
| 332 |
+
|
| 333 |
+
if st.session_state.show_results:
|
| 334 |
+
st.write("### Your Results")
|
| 335 |
+
total_questions = len(st.session_state.questions)
|
| 336 |
+
answered_questions = sum(1 for ans in st.session_state.answers if ans)
|
| 337 |
+
score = (answered_questions / total_questions) * 100
|
| 338 |
+
st.write(f"**Score:** {score:.2f}%")
|
| 339 |
+
|
| 340 |
+
# Display feedback and tips
|
| 341 |
+
st.write("### Feedback Summary")
|
| 342 |
+
for i, (q, ans, fb) in enumerate(zip(st.session_state.questions, st.session_state.answers, st.session_state.feedback)):
|
| 343 |
+
st.write(f"**Question {i + 1}:** {q}")
|
| 344 |
+
st.write(f"**Your Answer:** {ans}")
|
| 345 |
+
st.write(f"**Feedback:** {fb}")
|
| 346 |
+
|
| 347 |
+
tips = get_tips(model_choice, role)
|
| 348 |
+
st.write("### Tips to Improve")
|
| 349 |
+
st.write(tips)
|
| 350 |
+
progress_data["tips_retrieved"] += 1
|
| 351 |
+
|
| 352 |
elif nav_option == "Mock Interview":
|
| 353 |
st.header("🎥 Mock Interview")
|
| 354 |
schedule_mock_interview()
|
|
|
|
| 366 |
</div>
|
| 367 |
""", unsafe_allow_html=True)
|
| 368 |
|
|
|