play tested and working

modified:   app.py
This commit is contained in:
Russell Ballestrini 2024-07-28 20:37:31 -04:00
parent 5d10296f1f
commit 602039ca71

85
app.py
View file

@ -1955,19 +1955,45 @@ def handle_activity_response(room_name, user_response, username):
for s in next_section["steps"]
if s["step_id"] == current_step_id
)
else:
# Move to the next step or section
next_section, next_step = get_next_step(
activity_content, section["section_id"], step["step_id"]
)
if next_step:
activity_state.section_id = next_section["section_id"]
activity_state.step_id = next_step["step_id"]
activity_state.attempts = 0
if next_step:
activity_state.section_id = next_section["section_id"]
activity_state.step_id = next_step["step_id"]
activity_state.attempts = 0
db.session.add(activity_state)
db.session.commit()
db.session.add(activity_state)
db.session.commit()
# Emit the new step content blocks
content = "\n\n".join(next_step["content_blocks"])
# Emit the new step content blocks
content = "\n\n".join(next_step["content_blocks"])
new_message = Message(
username="System", content=content, room_id=room.id
)
db.session.add(new_message)
db.session.commit()
socketio.emit(
"message",
{
"id": new_message.id,
"username": "System",
"content": content,
},
room=room_name,
)
# Emit the new question if it exists
if "question" in next_step:
question_content = f"Question: {next_step['question']}"
new_message = Message(
username="System", content=content, room_id=room.id
username="System",
content=question_content,
room_id=room.id,
)
db.session.add(new_message)
db.session.commit()
@ -1977,44 +2003,7 @@ def handle_activity_response(room_name, user_response, username):
{
"id": new_message.id,
"username": "System",
"content": content,
},
room=room_name,
)
# Emit the new question if it exists
if "question" in next_step:
question_content = f"Question: {next_step['question']}"
new_message = Message(
username="System",
content=question_content,
room_id=room.id,
)
db.session.add(new_message)
db.session.commit()
socketio.emit(
"message",
{
"id": new_message.id,
"username": "System",
"content": question_content,
},
room=room_name,
)
else:
# Display activity info before completing
display_activity_info(room_name, username)
# Activity completed
db.session.delete(activity_state)
db.session.commit()
socketio.emit(
"message",
{
"id": None,
"username": "System",
"content": "Activity completed!",
"content": question_content,
},
room=room_name,
)
@ -2377,7 +2366,7 @@ def provide_feedback(
if not transition:
return "Category not found.", None
feedback = "\n".join(transition["content_blocks"])
feedback = ""
if "ai_feedback" in transition:
tokens_for_ai = (
step["tokens_for_ai"] + " " + transition["ai_feedback"]["tokens_for_ai"]