Integriere Gamification-Persistenz & Hooks in alle 27 Kapitel (test_aufgabe.py & index.html)

This commit is contained in:
Alex Mueller 2026-08-29 14:53:43 +02:00
parent 86532b15bb
commit 48ed3bb828
59 changed files with 395 additions and 29 deletions

View file

@ -10,5 +10,5 @@
"streak_tage": 1, "streak_tage": 1,
"letzter_aktiver_tag": "2026-08-29", "letzter_aktiver_tag": "2026-08-29",
"historie": [], "historie": [],
"zuletzt_aktualisiert": "2026-08-29T14:51:01.563840" "zuletzt_aktualisiert": "2026-08-29T14:53:37.686061"
} }

View file

@ -205,5 +205,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -60,4 +60,12 @@ class TestKapitel00(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -287,5 +287,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -81,4 +81,12 @@ class TestKapitel01(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -214,5 +214,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -82,4 +82,12 @@ class TestKapitel02(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -194,5 +194,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -98,4 +98,12 @@ class TestKapitel03(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -201,5 +201,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -65,4 +65,12 @@ class TestKapitel04(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -314,5 +314,9 @@ sudo snap install --classic code</code></pre>
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -210,5 +210,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -197,5 +197,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -84,4 +84,12 @@ class TestKapitel05(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -175,5 +175,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -108,4 +108,12 @@ class TestKapitel06(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -211,5 +211,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -95,4 +95,12 @@ class TestKapitel07(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -276,5 +276,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -139,4 +139,12 @@ class TestKapitel08(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -295,5 +295,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -172,4 +172,12 @@ class TestKapitel09Meta(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -355,5 +355,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -190,4 +190,12 @@ class TestKapitel10(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -388,5 +388,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -175,4 +175,12 @@ class TestKapitel11(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -255,5 +255,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -163,4 +163,12 @@ class TestKapitel12(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -243,5 +243,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -141,4 +141,12 @@ class TestKapitel13(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -348,5 +348,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -263,4 +263,12 @@ class TestKapitel14GUI(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -312,5 +312,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -338,4 +338,12 @@ class TestKapitel15(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -323,5 +323,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -424,4 +424,12 @@ class Test07GUIHeadless(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -11,7 +11,7 @@ window.GAMIFICATION_DATA = {
"streak_tage": 1, "streak_tage": 1,
"letzter_aktiver_tag": "2026-08-29", "letzter_aktiver_tag": "2026-08-29",
"historie": [], "historie": [],
"zuletzt_aktualisiert": "2026-08-29T14:51:01.563840" "zuletzt_aktualisiert": "2026-08-29T14:53:37.686061"
}; };
window.GAMIFICATION_BADGES_KATALOG = { window.GAMIFICATION_BADGES_KATALOG = {
"rechenkonegin": { "rechenkonegin": {

View file

@ -301,5 +301,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -124,4 +124,12 @@ class TestKapitelG01(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -252,5 +252,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -110,4 +110,12 @@ class TestKapitelG02(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -255,5 +255,9 @@ return f"Steckbrief: {name} | Größe: {groesse_m:.2f} m | Gewicht: {gewicht_kg:
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -142,4 +142,12 @@ class TestKapitelG03(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -287,5 +287,9 @@ return False</code></pre>
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -157,4 +157,12 @@ class TestKapitelG04(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -328,5 +328,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -175,4 +175,12 @@ class TestKapitelG05(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -281,5 +281,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -164,4 +164,12 @@ class TestKapitelG06(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -272,5 +272,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -120,4 +120,12 @@ class TestKapitelG07(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -227,5 +227,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -94,4 +94,12 @@ class TestKapitelG08(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -301,5 +301,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -139,4 +139,12 @@ class TestKapitelG09(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -251,5 +251,9 @@
</main> </main>
<!-- Lokale Gamification-Scripts (funktionieren auch offline per Doppelklick via file://) -->
<script src="../assets/gamification_data.js"></script>
<script src="../assets/gamification.js"></script>
</body> </body>
</html> </html>

View file

@ -140,4 +140,12 @@ class TestKapitelG10(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) res = unittest.main(verbosity=2, exit=False)
try:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from gamification import report_single_chapter_result
report_single_chapter_result(Path(__file__).parent.name, res.result.wasSuccessful(), res.result.testsRun)
except Exception:
pass
sys.exit(0 if res.result.wasSuccessful() else 1)

View file

@ -308,5 +308,39 @@ window.GAMIFICATION_LEVEL_STUFEN = {json.dumps(LEVEL_STUFEN, indent=2, ensure_as
} }
def report_single_chapter_result(kapitel_ordner: str, tests_erfolgreich: bool, tests_anzahl: int):
"""
Wird von einzelnen test_aufgabe.py Skripten aufgerufen, wenn sie direkt ausgeführt werden.
Aktualisiert den Spielstand und gibt motivierendes Feedback im Terminal aus.
"""
gm = GamificationManager()
aktuelle_geloeste = set(gm.state.get("geloeste_kapitel", []))
if tests_erfolgreich and tests_anzahl > 0:
war_bereits_geloest = kapitel_ordner in aktuelle_geloeste
aktuelle_geloeste.add(kapitel_ordner)
# Gesamtbestandene Tests schätzen/updaten
alte_tests = gm.state.get("bestandene_tests", 0)
neue_tests = alte_tests if war_bereits_geloest else alte_tests + tests_anzahl
events = gm.sync_mit_test_ergebnissen(list(aktuelle_geloeste), neue_tests)
lvl = events["lvl_info"]
print("\n" + "═" * 60)
print(f"🎉 KAPITEL BESTANDEN! ⭐ {lvl['titel']} (Level {lvl['level']})")
print(f"💎 Aktuelle XP: {events['gesamt_xp']} XP | Rang: {lvl['rang']}")
if events.get("level_up"):
print(f"🚀 LEVEL UP! Du bist aufgestiegen zu Level {lvl['level']}!")
if events.get("neue_badges"):
for b in events["neue_badges"]:
print(f"🏆 NEUE TROPHÄE: {b['icon']} {b['name']} (+{b['xp_bonus']} XP Bonus!)")
print(f"💡 Zeige deinen Fortschrittspass mit: python3 profil.py")
print("═" * 60 + "\n")
# Singleton-Instanz # Singleton-Instanz
manager = GamificationManager() manager = GamificationManager()