Demos (Gruppe D): Image cb-web, Aufgaben d-10 Snake, d-11 Sonnensystem, d-12 Highscore auf eigener Lösung, Browser-Prüfung mit Screenshot und Checkliste, Aufgaben mit depends_on

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:53:14 +01:00
parent c8a24fd8b3
commit 8e5be1ed0b
34 changed files with 1125 additions and 30 deletions

10
tasks/D/d-11/check.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Öffnet /work/index.html im Browser (ohne Netz) und arbeitet die Checkliste in check/check_task.py ab.
# Letzte Zeile ist JSON mit Score und Notiz. Screenshot und Bericht liegen danach in /checks/out.
cd /work || { echo '{"score": 0.0, "notes": "kein /work"}'; exit 0; }
python3 /checks/check_task.py 2>/tmp/check.err
status=$?
if [ $status -ne 0 ]; then
echo "{\"score\": 0.0, \"notes\": \"Prüfskript abgebrochen (Exit $status): $(tail -n 1 /tmp/check.err | tr '\"' "'" | cut -c1-160)\"}"
fi
exit 0

View File

@ -0,0 +1,142 @@
"""Checkliste für d-11 (Sonnensystem). Alle Punkte stehen im Aufgabentext (prompt.md)."""
import sys
from webcheck import Checklist, Session, distance
PLANETS = ["merkur", "venus", "erde", "mars", "jupiter", "saturn", "uranus", "neptun"]
SEL = lambda p: f'[data-planet="{p}"]' # noqa: E731
cl = Checklist()
with Session() as s:
if not s.open():
cl.add("index.html vorhanden", False, "Datei /work/index.html fehlt", weight=2)
cl.finish()
sys.exit(0)
page = s.page
s.wait(1.0)
s.screenshot()
cl.add("lädt ohne JavaScript-Fehler", not s.errors, "; ".join(s.errors[:2]), weight=2)
def sun_ok():
b = page.locator("#sun").first.bounding_box()
return (b is not None and b["width"] > 10 and b["height"] > 10), "#sun fehlt oder zu klein"
cl.guard("Sonne (#sun) sichtbar", sun_ok)
def eight():
found = page.eval_on_selector_all("[data-planet]", "els => els.map(e => e.getAttribute('data-planet'))")
return sorted(set(found)) == sorted(PLANETS) and len(found) == 8, f"gefunden: {sorted(found)}"
cl.guard("acht Planeten mit data-planet", eight)
def positions():
return {p: s.center(SEL(p)) for p in PLANETS}
p0 = {}
sun0 = None
def visible():
global p0, sun0
p0 = positions()
sun0 = s.center("#sun")
vw, vh = s.size["width"], s.size["height"]
bad = [p for p, c in p0.items() if c is None or not (0 <= c[0] <= vw and 0 <= c[1] <= vh)]
return not bad and sun0 is not None, f"nicht im Bild: {bad}"
cl.guard("alle Planeten und die Sonne liegen im Bild", visible)
def apart():
pts = [c for c in p0.values() if c]
close = [(i, j) for i in range(len(pts)) for j in range(i + 1, len(pts)) if distance(pts[i], pts[j]) < 4]
return not close, "Planeten liegen übereinander"
cl.guard("Planeten liegen nicht übereinander", apart)
def order():
s.wait(0.7)
p1 = positions()
ds = []
for p in PLANETS:
a, b = p0.get(p), p1.get(p)
if not a or not b or not sun0:
return False, "Position fehlt"
ds.append((distance(a, sun0) + distance(b, sun0)) / 2)
ok = all(ds[i] + 1 < ds[i + 1] for i in range(len(ds) - 1))
return ok, "Abstände zur Sonne: " + ", ".join(str(round(d)) for d in ds)
cl.guard("Bahnen liegen von innen nach außen in Planeten-Reihenfolge", order)
def moving():
a = positions()
s.wait(1.5)
b = positions()
moved = [p for p in PLANETS if a[p] and b[p] and distance(a[p], b[p]) > 3]
return len(moved) >= 6, f"es bewegen sich nur {moved}"
cl.guard("Planeten bewegen sich von selbst (mindestens 6)", moving)
def circular():
d = []
for _ in range(4):
c, sc = s.center(SEL("erde")), s.center("#sun")
d.append(distance(c, sc))
s.wait(0.5)
return max(d) / max(min(d), 1) < 1.3, f"Abstand schwankt: {[round(x) for x in d]}"
cl.guard("Erde kreist in gleichmäßigem Abstand um die Sonne", circular)
def click_info(planet, word):
def run():
loc = page.locator(SEL(planet)).first
try:
loc.click(force=True, timeout=3000)
except Exception: # noqa: BLE001 - bewegtes Ziel: Klick-Ereignis direkt auslösen
loc.dispatch_event("click")
s.wait(0.2)
text = page.locator("#info").first.inner_text(timeout=2000)
if word not in text.lower():
loc.dispatch_event("click")
s.wait(0.2)
text = page.locator("#info").first.inner_text(timeout=2000)
return (word in text.lower() and len(text.strip()) >= len(word) + 8), f"#info: {text[:60]!r}"
return run
for planet, word in (("erde", "erde"), ("mars", "mars"), ("saturn", "saturn")):
cl.guard(f"Klick auf {planet} zeigt Name und mehr in #info", click_info(planet, word))
def pause():
page.locator("#pause").first.click(timeout=3000)
s.wait(0.3)
a = positions()
s.wait(1.0)
b = positions()
still = all(distance(a[p], b[p]) < 1.5 for p in PLANETS if a[p] and b[p])
return still, "Planeten bewegen sich trotz Pause"
cl.guard("Pause hält alle Planeten an", pause)
def resume():
page.locator("#pause").first.click(timeout=3000)
s.wait(0.3)
a = positions()
s.wait(1.5)
b = positions()
moved = [p for p in PLANETS if a[p] and b[p] and distance(a[p], b[p]) > 3]
return len(moved) >= 4, "Bewegung läuft nach dem zweiten Klick nicht weiter"
cl.guard("zweiter Klick setzt die Bewegung fort", resume)
cl.add("kein Zugriff aufs Netz", not s.blocked, f"versucht: {s.blocked[:2]}")
def fits():
w, h, iw, ih = page.evaluate(
"[document.documentElement.scrollWidth, document.documentElement.scrollHeight, innerWidth, innerHeight]"
)
return w <= iw + 1 and h <= ih + 1, f"Seite {w}x{h} in Fenster {iw}x{ih}"
cl.guard("passt in 1280×800 ohne Scrollen", fits)
cl.finish()

12
tasks/D/d-11/prompt.md Normal file
View File

@ -0,0 +1,12 @@
Erstelle die Datei /work/index.html. HTML, CSS und JavaScript stehen alle in dieser einen Datei. Benutze keine Bibliotheken, keine Schriften und keine Bilder aus dem Netz. Die Seite hat später keinen Zugriff aufs Netz.
Die Seite zeigt eine animierte Darstellung unseres Sonnensystems von oben:
- Die Sonne steht in der Mitte. Sie ist ein Element mit dem Attribut id="sun".
- Es gibt die acht Planeten Merkur, Venus, Erde, Mars, Jupiter, Saturn, Uranus und Neptun. Jeder Planet ist ein Element mit dem Attribut data-planet. Der Wert ist der Name in Kleinbuchstaben ohne Umlaute: merkur, venus, erde, mars, jupiter, saturn, uranus, neptun.
- Jeder Planet kreist auf einer eigenen Bahn um die Sonne. Die Bahnen liegen in der Reihenfolge der Planeten von innen nach außen. Die Bewegung läuft von selbst, ohne dass jemand klicken muss (CSS-Animation oder JavaScript).
- Klickt man auf einen Planeten, zeigt das Element mit id="info" den Namen des Planeten (zum Beispiel „Erde“) und mindestens eine weitere Angabe (zum Beispiel Durchmesser oder Abstand zur Sonne).
- Ein Knopf mit id="pause" hält die Bewegung an. Beim nächsten Klick läuft sie weiter.
- Der Hintergrund ist dunkel. Die ganze Seite passt in ein Fenster von 1280 × 800 Pixeln, ohne dass man scrollen muss.
Rufe danach das Werkzeug done auf.

View File

7
tasks/D/d-11/task.toml Normal file
View File

@ -0,0 +1,7 @@
id = "d-11"
title = "Sonnensystem als Webseite"
group = "D"
image = "cb-web:latest"
max_steps = 20
timeout_s = 900
check_timeout_s = 240