diff --git a/app.py b/app.py index 392cfd2..e4796ff 100644 --- a/app.py +++ b/app.py @@ -215,6 +215,7 @@ class ActivityState(db.Model): def clear_metadata(self): self.dict_metadata = {} + def get_room(room_name): """Utility function to get room from room name.""" room = Room.query.filter_by(name=room_name).first() @@ -2331,7 +2332,9 @@ def handle_activity_response(room_name, user_response, username): activity_state.add_metadata(random_key, random_value) # Execute the processing script if it exists - if "processing_script" in step and transition.get("run_processing_script", False): + if "processing_script" in step and transition.get( + "run_processing_script", False + ): result = execute_processing_script( activity_state.dict_metadata, step["processing_script"] ) @@ -2349,7 +2352,11 @@ def handle_activity_response(room_name, user_response, username): plot_image_html = f'Plot Image' if result.get("set_background", False): - socketio.emit("set_background", {"image_data": plot_image_base64}) + socketio.emit( + "set_background", + {"image_data": plot_image_base64}, + room=room_name, + ) socketio.sleep(0.1) else: # Save the plot image to the database @@ -2373,7 +2380,10 @@ def handle_activity_response(room_name, user_response, username): ) socketio.sleep(0.1) - if "metadata_clear" in transition and transition["metadata_clear"] == True: + if ( + "metadata_clear" in transition + and transition["metadata_clear"] == True + ): activity_state.clear_metadata() print(activity_state.dict_metadata) diff --git a/research/activity27-tic-tac-toe.yaml b/research/activity27-tic-tac-toe.yaml index 4d1fcd9..00fab5c 100644 --- a/research/activity27-tic-tac-toe.yaml +++ b/research/activity27-tic-tac-toe.yaml @@ -11,13 +11,7 @@ sections: You will be playing against the AI. You are 'X' and the AI is 'O'. The board positions are numbered 0 to 8 as follows: - ``` - 0 | 1 | 2 - --------- - 3 | 4 | 5 - --------- - 6 | 7 | 8 - ``` + - step_id: "step_1" title: "Your Move" @@ -119,6 +113,7 @@ sections: script_result = { "plot_image": plot_board(board), + "set_background": True, "ai_move": ai_move, "user_move": user_move, "metadata": { diff --git a/static/images/tic-tac-toe.png b/static/images/tic-tac-toe.png new file mode 100644 index 0000000..99eb080 Binary files /dev/null and b/static/images/tic-tac-toe.png differ