From 0560de004d0aef97bf1c95025a039b049d832925 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Nov 2025 23:00:01 +0000 Subject: [PATCH] Add fix scripts for activity YAML corrections These scripts document the automated fixes applied to activities 30-37: - fix_activity37.py: Changes 'close' bucket behavior + fixes completion - fix_all_new_activities.py: Fixes final step completion for all activities Keeping for reference and potential reuse on future activities. --- fix_activity37.py | 49 ++++++++++++++++++++++++++ fix_all_new_activities.py | 73 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 fix_activity37.py create mode 100644 fix_all_new_activities.py diff --git a/fix_activity37.py b/fix_activity37.py new file mode 100644 index 0000000..aefd95f --- /dev/null +++ b/fix_activity37.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +""" +Fix activity37: +1. Change 'close' bucket to NOT advance (retry same step) +2. Keep 'off_topic' looping on final step, remove next_section_and_step from completion buckets +""" +import yaml + +def fix_activity37(): + file_path = "research/activity37-programming-languages.yaml" + + # Read original file + with open(file_path, 'r') as f: + activity = yaml.safe_load(f) + + # Fix 1: Change ALL "close" transitions to stay on same step + for section in activity['sections']: + section_id = section['section_id'] + for step in section['steps']: + step_id = step['step_id'] + if 'transitions' in step and 'close' in step.get('buckets', []): + # Change 'close' to stay on same step (don't advance) + if 'close' in step['transitions']: + step['transitions']['close']['next_section_and_step'] = f"{section_id}:{step_id}" + + # Fix 2: For final step (conclusion:step_1), keep ONLY 'off_topic' looping + # Remove next_section_and_step from all other transitions to allow completion + for section in activity['sections']: + if section['section_id'] == 'conclusion': + for step in section['steps']: + if step['step_id'] == 'step_1': + for bucket, transition in step['transitions'].items(): + # Remove next_section_and_step from all except off_topic + if bucket != 'off_topic' and 'next_section_and_step' in transition: + del transition['next_section_and_step'] + # Ensure off_topic loops (for validator to not consider it terminal) + if 'off_topic' in step['transitions']: + step['transitions']['off_topic']['next_section_and_step'] = 'conclusion:step_1' + + # Write back with minimal formatting changes + with open(file_path, 'w') as f: + yaml.dump(activity, f, default_flow_style=False, sort_keys=False, width=1000, allow_unicode=True) + + print(f"✅ Fixed {file_path}") + print(" - 'close' buckets now retry same step (don't advance)") + print(" - Final step can now complete (off_topic loops, others complete)") + +if __name__ == '__main__': + fix_activity37() diff --git a/fix_all_new_activities.py b/fix_all_new_activities.py new file mode 100644 index 0000000..09681c9 --- /dev/null +++ b/fix_all_new_activities.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +""" +Fix completion issues in activities 30-36: +- Keep 'off_topic' looping on final step +- Remove next_section_and_step from all other buckets in final step to allow completion +""" +import yaml +import glob + +def fix_final_step_completion(file_path): + """Fix the final step to allow completion.""" + # Read file + with open(file_path, 'r') as f: + activity = yaml.safe_load(f) + + # Find the last section + if not activity.get('sections'): + return False + + last_section = activity['sections'][-1] + last_section_id = last_section['section_id'] + + # Find the last step in the last section + if not last_section.get('steps'): + return False + + last_step = last_section['steps'][-1] + last_step_id = last_step['step_id'] + + # Fix: Keep ONLY 'off_topic' looping, remove next_section_and_step from other transitions + if 'transitions' not in last_step: + return False + + modified = False + for bucket, transition in last_step['transitions'].items(): + if bucket == 'off_topic': + # Ensure off_topic loops (so validator doesn't consider step terminal) + if 'next_section_and_step' not in transition or transition['next_section_and_step'] != f"{last_section_id}:{last_step_id}": + transition['next_section_and_step'] = f"{last_section_id}:{last_step_id}" + modified = True + else: + # Remove next_section_and_step from completion buckets + if 'next_section_and_step' in transition: + del transition['next_section_and_step'] + modified = True + + if modified: + # Write back + with open(file_path, 'w') as f: + yaml.dump(activity, f, default_flow_style=False, sort_keys=False, width=1000, allow_unicode=True) + return True + + return False + +def main(): + files = [ + 'research/activity30-logic-puzzles.yaml', + 'research/activity31-scientific-method.yaml', + 'research/activity32-world-geography.yaml', + 'research/activity33-environmental-science.yaml', + 'research/activity34-media-literacy.yaml', + 'research/activity35-american-history.yaml', + 'research/activity36-biblical-history.yaml', + ] + + for file_path in files: + if fix_final_step_completion(file_path): + print(f"✅ Fixed {file_path}") + else: + print(f"⚠️ No changes needed for {file_path}") + +if __name__ == '__main__': + main()