code:
skill = st.text_input(‘Enter the skill:’)
if skill:
for i in range(5):
print(“Generating question…”)
print(i)
question = generate_question(skill, st.session_state.difficulty)[0]
st.write(“Question generated:”, question)
st.subheader("Question:")
st.write(question)
answer = st.text_input('Your answer', key = st.session_state.num_questions_asked)
time.sleep(10)
submit_button = st.button("Submit", key = st.session_state.num_questions_asked+10)
time.sleep(2)
if submit_button:
if answer.strip():
print("Evaluating answer...")
result, score = evaluate_question(question, answer)
st.write("Evaluation Result:", result)
st.write("Score:", score)
st.session_state.num_questions_asked += 1
print("Number of questions asked:", st.session_state.num_questions_asked)
if score is not None:
# Adjust difficulty level based on score
if score >= 75:
if st.session_state.difficulty == 'easy':
st.session_state.difficulty = 'moderate'
else:
st.session_state.difficulty = 'hard'
elif score < 75:
if st.session_state.difficulty == 'hard':
st.session_state.difficulty = 'moderate'
elif score <= 60 and st.session_state.difficulty == 'moderate':
st.session_state.difficulty = 'easy'
else:
st.write("Proficiency score is None. Staying at the current difficulty level.")
st.write("New Difficulty Level:", st.session_state.difficulty)
else:
st.warning("Please provide an answer before submitting.")