-- Module-ID-Vereinheitlichung
-- Alte sim-XX-IDs → neue semantische IDs aus module_info
-- Betrifft: class_modules, student_modules, class_assignments, assessments.sim_id

SET NAMES utf8mb4;

-- Mapping:
--   sim-05    → klima       (war "Klimawächter 2D", wir unifizieren — 2D/3D kommt per ?mode=)
--   sim-05-3d → klima-3d    (separater Eintrag, damit 2D/3D unterscheidbar im Lehrer-Dashboard)
--   sim-07    → erdbeben
--   sim-09    → energiemix
--   sim-10    → lieferketten
--   sim-11    → regenwald
--   sim-12    → fluss
--   sim-13    → stadt
--   sim-14    → heli

-- class_modules
UPDATE class_modules SET module_id='klima'       WHERE module_id='sim-05';
UPDATE class_modules SET module_id='klima-3d'    WHERE module_id='sim-05-3d';
UPDATE class_modules SET module_id='erdbeben'    WHERE module_id='sim-07';
UPDATE class_modules SET module_id='energiemix'  WHERE module_id='sim-09';
UPDATE class_modules SET module_id='lieferketten' WHERE module_id='sim-10';
UPDATE class_modules SET module_id='regenwald'   WHERE module_id='sim-11';
UPDATE class_modules SET module_id='fluss'       WHERE module_id='sim-12';
UPDATE class_modules SET module_id='stadt'       WHERE module_id='sim-13';
UPDATE class_modules SET module_id='heli'        WHERE module_id='sim-14';

-- student_modules
UPDATE student_modules SET module_id='klima'       WHERE module_id='sim-05';
UPDATE student_modules SET module_id='klima-3d'    WHERE module_id='sim-05-3d';
UPDATE student_modules SET module_id='erdbeben'    WHERE module_id='sim-07';
UPDATE student_modules SET module_id='energiemix'  WHERE module_id='sim-09';
UPDATE student_modules SET module_id='lieferketten' WHERE module_id='sim-10';
UPDATE student_modules SET module_id='regenwald'   WHERE module_id='sim-11';
UPDATE student_modules SET module_id='fluss'       WHERE module_id='sim-12';
UPDATE student_modules SET module_id='stadt'       WHERE module_id='sim-13';
UPDATE student_modules SET module_id='heli'        WHERE module_id='sim-14';

-- class_assignments
UPDATE class_assignments SET module_id='klima'       WHERE module_id='sim-05';
UPDATE class_assignments SET module_id='klima-3d'    WHERE module_id='sim-05-3d';
UPDATE class_assignments SET module_id='erdbeben'    WHERE module_id='sim-07';
UPDATE class_assignments SET module_id='energiemix'  WHERE module_id='sim-09';
UPDATE class_assignments SET module_id='lieferketten' WHERE module_id='sim-10';
UPDATE class_assignments SET module_id='regenwald'   WHERE module_id='sim-11';
UPDATE class_assignments SET module_id='fluss'       WHERE module_id='sim-12';
UPDATE class_assignments SET module_id='stadt'       WHERE module_id='sim-13';
UPDATE class_assignments SET module_id='heli'        WHERE module_id='sim-14';

-- assessments.sim_id
UPDATE assessments SET sim_id='klima'       WHERE sim_id='sim-05';
UPDATE assessments SET sim_id='klima-3d'    WHERE sim_id='sim-05-3d';
UPDATE assessments SET sim_id='erdbeben'    WHERE sim_id='sim-07';
UPDATE assessments SET sim_id='energiemix'  WHERE sim_id='sim-09';
UPDATE assessments SET sim_id='lieferketten' WHERE sim_id='sim-10';
UPDATE assessments SET sim_id='regenwald'   WHERE sim_id='sim-11';
UPDATE assessments SET sim_id='fluss'       WHERE sim_id='sim-12';
UPDATE assessments SET sim_id='stadt'       WHERE sim_id='sim-13';
UPDATE assessments SET sim_id='heli'        WHERE sim_id='sim-14';

-- assessment_answers.sim_id
UPDATE assessment_answers SET sim_id='klima'       WHERE sim_id='sim-05';
UPDATE assessment_answers SET sim_id='klima-3d'    WHERE sim_id='sim-05-3d';
UPDATE assessment_answers SET sim_id='erdbeben'    WHERE sim_id='sim-07';
UPDATE assessment_answers SET sim_id='energiemix'  WHERE sim_id='sim-09';
UPDATE assessment_answers SET sim_id='lieferketten' WHERE sim_id='sim-10';
UPDATE assessment_answers SET sim_id='regenwald'   WHERE sim_id='sim-11';
UPDATE assessment_answers SET sim_id='fluss'       WHERE sim_id='sim-12';
UPDATE assessment_answers SET sim_id='stadt'       WHERE sim_id='sim-13';
UPDATE assessment_answers SET sim_id='heli'        WHERE sim_id='sim-14';

-- Sicherstellen dass module_info-Einträge für klima-3d existieren
INSERT IGNORE INTO module_info (module_id, title, icon, status, sort_order)
VALUES ('klima-3d', 'Klimawächter 3D', '🌊', 'aktiv', 11);
