Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 6664a4b

Browse files
committed
Block-Lektion 6 „Immer wieder prüfen“, Blöcke mit nicht/und/oder
Start mit Taste A, Endlosschleife mit Notbremse, Ausweichen zum Ausprobieren. Blöcke zeigen „nicht“, „und“, „oder“ und „verlasse die Schleife“ statt !, &&, || und break. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ugz28UyJP4CyzFezJTWZbD
1 parent 4c61c62 commit 6664a4b

20 files changed

Lines changed: 1595 additions & 1178 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The format is loosely inspired by Keep a Changelog.
88

99
### Changed
1010

11-
- **Web 0.15.27, VisuBot block lesson 5 „Lichter und Töne“:** LEDs in RGB colours, blinking with „wiederhole“ and „kurz warten“, a siren with „Ton spielen“, and a free light show. The game „Was passiert?“ (`spiel frage`) shows its rounds as blocks in the block lessons, like „Wo landet der mBot2?“.
11+
- **Web 0.15.27, VisuBot block lessons 5 „Lichter und Töne“ and 6 „Immer wieder prüfen“:** LEDs in RGB colours, blinking with „wiederhole“ and „kurz warten“, a siren with „Ton spielen“, and a free light show. The game „Was passiert?“ (`spiel frage`) shows its rounds as blocks in the block lessons, like „Wo landet der mBot2?“. Lesson 6 „Immer wieder prüfen“: wait for button A (solange nicht …), endless loop with an emergency brake, free obstacle avoidance. Blocks also show „nicht“, „und“, „oder“ and „verlasse die Schleife“ instead of `!`, `&&`, `||` and `break`.
1212
- **Web 0.15.26, VisuBot: short block lessons for younger learners (grades 5/6):** when the block view is on in VisuBot, the learning area shows its own short lesson series from `web/lessons/<lang>/visubot/bloecke/` instead of the Java series (switching back restores it; no exercises tab content there). Lessons are about trying things out: step 1 „Das schaffst du heute“, a few hands-on exercises, a game, and „Das hab ich geschafft“ as the checklist; no knowledge test. First lessons (German): 1 „Losfahren“ (drive, change numbers, turn), 2 „Immer wieder“ (square, „wiederhole“, triangle and other shapes), 3 „Der mBot2 misst“ (show the distance, drive while the way is free) and 4 „Entscheidungen“ (wenn/sonst with the wall and the colour sensor). The blocks now show their keywords in the UI language: „wenn“, „sonst“, „solange“, „wiederhole immer“, „mache“ (en: if, else, while, forever, do; pt: se, senão, enquanto, repetir sempre, faz). In „Wo landet der mBot2?“ the rounds are shown as blocks instead of Java (`blockPicture.ts`). Tests in `blockLessons.test.ts`.
1313
- **Web 0.15.25, VisuBot blocks (stage 5): variables and operators:** new areas in „Elemente“ (VisuBot): **Operatoren** (plus, minus, mal, geteilt durch, Rest beim Teilen, Zufallszahl, kleiner als, größer als, gleich, und, oder, nicht; round = number, hexagonal = yes/no, green), **Variablen** (Variable anlegen → `int zahl = 0` with a free name, setze Variable auf → `zahl = 0`, ändere Variable um → `zahl = zahl + 1`; every declared variable appears as an orange building block) and **Steuerung** („wiederhole 10 mal“ → `for (int i = 0; i < 10; i++)`). In the blocks, operators and variables are dropped onto a white field (an operator gets brackets only when needed) or onto a condition (replaces it; „und“/„oder“/„nicht“ combine with the old condition). Variables show as orange pills; the one being declared or set is not a field. „Zufallszahl von [1] bis [10]“ is a green pill with two fields (`(int) (Math.random() * 10) + 1`). A count loop whose variable is not used in its body reads „wiederhole [10] mal“; its end can also be a variable. Commands from „Elemente“ with empty brackets (`mbot.forward()`) get an empty white field to type the number. The rules come from VisuBlocks (`expressions.ts`, `variables.ts`). Tests in `blockView.test.ts`.
1414
- **Web 0.15.24, descriptions brought up to date:** lesson „Der Editor“ (de/en/pt) explains editing text by double-click/double-tap right in the structure chart (Enter takes it, Esc cancels, keyboard: select and Enter) and the grip line that changes the object inspector's height; VisuBot lesson „Struktogramm und Editor“ (de/en) adds both plus a hint on the button „Blöcke“ (Scratch-like blocks, same program, switch any time), with the new pointer `#zeige-bloecke` (termTips.ts). README: web app published on visucode.de (GitLab website repo) instead of visustruct.org; web/README: no longer „Prototyp“, new section VisuBot with block view and VisuBlocks.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
titel: Immer wieder prüfen
3+
bereich: Sensoren und Entscheidungen
4+
kurz: Auf Taste A warten, immer wieder prüfen und Hindernissen ausweichen.
5+
---
6+
7+
## Das schaffst du heute
8+
9+
::: kompetenzen
10+
- den mBot2 auf Taste A warten lassen
11+
- eine Schleife mit „wiederhole immer“ bauen und wieder verlassen
12+
- den mBot2 Hindernissen ausweichen lassen
13+
:::
14+
15+
## Start mit Taste A
16+
17+
Oben auf dem mBot2 sitzt die Taste **A**, das ist die [Taste mit dem Quadrat]{teil=buttons}. Der mBot2 soll erst losfahren, wenn du sie drückst. Bis dahin wartet er.
18+
19+
Warten heißt: **solange** die Taste **nicht** gedrückt ist, kurz warten. So baust du das:
20+
21+
1. Zieh eine **While-Schleife** unter 🏁.
22+
2. Zieh aus **Operatoren** den Baustein **nicht** auf die Frage hinter **solange**.
23+
3. Zieh den Sensor **Taste A gedrückt?** in den Baustein **nicht**.
24+
4. Leg **kurz warten** in die Schleife und **fahre vor** darunter.
25+
26+
::: übung vbb-start-a
27+
titel: Start mit Taste A
28+
auftrag: Der mBot2 wartet, bis Taste A gedrückt ist. Dann fährt er 30 cm vor.
29+
messwerte: isButtonA=false/true -> forward 30
30+
messwerte: isButtonA=true -> forward 30
31+
braucht: whileSchleife
32+
tipp: Im Kopf der Schleife steht **solange nicht** und dann `mbot.isButtonA()`.
33+
tipp: In der Schleife liegt **kurz warten**, unter der Schleife **fahre vor** mit 30.
34+
lösung: vbb-start-a-loesung.visustruct
35+
:::
36+
37+
> Beim Prüfen drückt VisuBot die Taste für dich: erst eine Weile nicht, dann schon. Fährt dein mBot2 zu früh los, fällt das auf.
38+
39+
## Wiederhole immer
40+
41+
Manche Programme sollen nie aufhören: Der mBot2 fährt, schaut, fährt, schaut … Dafür gibt es die **Endlosschleife**. Im Block steht **wiederhole immer**.
42+
43+
Damit du ihn trotzdem anhalten kannst, baust du eine **Notbremse** ein: **Wenn** Taste A gedrückt ist, **verlasse die Schleife**. Den Block dafür findest du unter **Elemente**, er heißt **Aussprung**. Danach macht das Programm unter der Schleife weiter.
44+
45+
::: übung vbb-notbremse
46+
titel: Notbremse
47+
auftrag: Der mBot2 fährt immer weiter vor. Wird Taste A gedrückt, verlässt er die Schleife und zeigt **Gestoppt** auf dem Bildschirm.
48+
messwerte: isButtonA=true -> none, screen "Gestoppt"
49+
messwerte: isButtonA=false/true -> drives, screen "Gestoppt"
50+
braucht: endlosschleife, aussprung
51+
tipp: In **wiederhole immer** liegt zuerst eine Verzweigung mit **Taste A gedrückt?**. Unter **wenn** kommt der **Aussprung**, **sonst** bleibt leer.
52+
tipp: Unter der Verzweigung, noch in der Schleife, liegt **fahre vor**. Unter der Schleife liegt **Text anzeigen** mit „Gestoppt“.
53+
lösung: vbb-notbremse-loesung.visustruct
54+
:::
55+
56+
## Ausweichen
57+
58+
Jetzt wird es spannend! Der mBot2 soll durch einen Raum fahren, ohne irgendwo anzustoßen. Baue dafür:
59+
60+
- **wiederhole immer**
61+
- darin: **wenn** der Abstand kleiner als 20 ist, **drehe rechts**, **sonst** **fahre vor**
62+
63+
Starte die Simulation und schau zu, wie er sich seinen Weg sucht. Mit **Simulation beenden** hältst du ihn an.
64+
65+
Probier aus:
66+
67+
- Was passiert, wenn du statt **drehe rechts** mal **drehe links** nimmst?
68+
- Was passiert bei **drehe rechts** mit **45**?
69+
- Kannst du ihn bei jeder Drehung piepen lassen?
70+
71+
::: ludwig
72+
So einen Roboter gibt es wirklich: Viele Staubsauger-Roboter fahren genau so durch die Wohnung. Wand vorn? Drehen! Frei? Weiter!
73+
:::
74+
75+
## Spiel: Was passiert?
76+
77+
::: spiel frage
78+
titel: Spiel: Was passiert?
79+
intro: Schau dir die Blöcke an. Was macht der mBot2? Vier Runden.
80+
81+
runde:
82+
while (!mbot.isButtonA()) {
83+
mbot.pause(100);
84+
}
85+
mbot.forward(50);
86+
frage: Niemand drückt eine Taste. Was tut der mBot2?
87+
- Er fährt 50 cm.
88+
- [x] Er wartet und wartet.
89+
- Er fährt immer weiter.
90+
> Solange Taste A nicht gedrückt ist, wartet er in der Schleife.
91+
92+
runde:
93+
while (!mbot.isButtonA()) {
94+
mbot.pause(100);
95+
}
96+
mbot.forward(50);
97+
frage: Du drückst Taste A. Was tut der mBot2?
98+
- [x] Er fährt 50 cm und hört dann auf.
99+
- Er fährt immer weiter.
100+
- Er wartet weiter.
101+
> Jetzt ist die Schleife zu Ende, und der Block darunter läuft einmal.
102+
103+
runde:
104+
while (true) {
105+
mbot.playTone(440, 300);
106+
}
107+
frage: Wie oft piept der mBot2?
108+
- einmal
109+
- zehnmal
110+
- [x] immer weiter, ohne Ende
111+
> **wiederhole immer** hört nie von selbst auf.
112+
113+
runde:
114+
while (true) {
115+
if (mbot.isButtonA()) {
116+
break;
117+
}
118+
mbot.forward();
119+
}
120+
mbot.setLed(255, 0, 0);
121+
frage: Wann leuchten die LEDs rot?
122+
- sofort
123+
- [x] wenn jemand Taste A drückt
124+
- nie
125+
> Erst die Notbremse verlässt die Schleife. Dann geht es unter der Schleife weiter.
126+
:::
127+
128+
## Das hab ich geschafft
129+
130+
Wie gut klappt es schon? ☂️ noch nicht, ⛅ ein bisschen, ☀️ klappt prima. Bei ☂️ und ⛅ bringt dich **Nachlesen** zum passenden Schritt.
131+
132+
::: checkliste
133+
- Ich kann den mBot2 auf Taste A warten lassen. → Start mit Taste A
134+
- Ich kann eine Schleife mit „wiederhole immer“ bauen und wieder verlassen. → Wiederhole immer
135+
- Ich kann den mBot2 Hindernissen ausweichen lassen. → Ausweichen
136+
:::
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<struktogramm caption="-1;">
3+
<strelem typ="6" zx="0" zy="0">
4+
<text>-1;</text>
5+
<schleifeninhalt>
6+
<strelem typ="1" zx="0" zy="0">
7+
<text>109;98;111;116;46;105;115;66;117;116;116;111;110;65;40;41;</text>
8+
<fall fallname="116;114;117;101;">
9+
<strelem typ="7" zx="0" zy="0">
10+
<text>-1;</text>
11+
</strelem>
12+
</fall>
13+
<fall fallname="102;97;108;115;101;">
14+
<strelem typ="0" zx="0" zy="0">
15+
<text>248;</text>
16+
</strelem>
17+
</fall>
18+
</strelem>
19+
<strelem typ="0" zx="0" zy="0">
20+
<text>109;98;111;116;46;102;111;114;119;97;114;100;40;41;</text>
21+
</strelem>
22+
</schleifeninhalt>
23+
</strelem>
24+
<strelem typ="0" zx="0" zy="0">
25+
<text>109;98;111;116;46;115;104;111;119;84;101;120;116;40;34;71;101;115;116;111;112;112;116;34;41;</text>
26+
</strelem>
27+
</struktogramm>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<struktogramm caption="-1;">
3+
<strelem typ="4" zx="0" zy="0">
4+
<text>33;109;98;111;116;46;105;115;66;117;116;116;111;110;65;40;41;</text>
5+
<schleifeninhalt>
6+
<strelem typ="0" zx="0" zy="0">
7+
<text>109;98;111;116;46;112;97;117;115;101;40;49;48;48;41;</text>
8+
</strelem>
9+
</schleifeninhalt>
10+
</strelem>
11+
<strelem typ="0" zx="0" zy="0">
12+
<text>109;98;111;116;46;102;111;114;119;97;114;100;40;51;48;41;</text>
13+
</strelem>
14+
</struktogramm>

‎web/src/i18n/de.strings‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@
325325
"web_visubot_blocks_while" = "solange";
326326
"web_visubot_blocks_endless" = "wiederhole immer";
327327
"web_visubot_blocks_do" = "mache";
328+
"web_visubot_blocks_not" = "nicht";
329+
"web_visubot_blocks_and" = "und";
330+
"web_visubot_blocks_or" = "oder";
331+
"web_visubot_blocks_break" = "verlasse die Schleife";
328332
"web_visubot_blocks_repeat_times" = "mal";
329333
"web_visubot_blocks_random_from" = "Zufallszahl von";
330334
"web_visubot_blocks_random_to" = "bis";

‎web/src/i18n/en.strings‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@
325325
"web_visubot_blocks_while" = "while";
326326
"web_visubot_blocks_endless" = "forever";
327327
"web_visubot_blocks_do" = "do";
328+
"web_visubot_blocks_not" = "not";
329+
"web_visubot_blocks_and" = "and";
330+
"web_visubot_blocks_or" = "or";
331+
"web_visubot_blocks_break" = "leave the loop";
328332
"web_visubot_blocks_repeat_times" = "times";
329333
"web_visubot_blocks_random_from" = "random number from";
330334
"web_visubot_blocks_random_to" = "to";

‎web/src/i18n/pt-PT.strings‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@
323323
"web_visubot_blocks_while" = "enquanto";
324324
"web_visubot_blocks_endless" = "repetir sempre";
325325
"web_visubot_blocks_do" = "faz";
326+
"web_visubot_blocks_not" = "não";
327+
"web_visubot_blocks_and" = "e";
328+
"web_visubot_blocks_or" = "ou";
329+
"web_visubot_blocks_break" = "sair do ciclo";
326330
"web_visubot_blocks_repeat_times" = "vezes";
327331
"web_visubot_blocks_random_from" = "número aleatório de";
328332
"web_visubot_blocks_random_to" = "a";

‎web/src/ui/blockPicture.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export function blockViewLabels(): BlockViewOptions['labels'] {
2727
while: t('web_visubot_blocks_while'),
2828
endless: t('web_visubot_blocks_endless'),
2929
do: t('web_visubot_blocks_do'),
30+
'!': t('web_visubot_blocks_not'),
31+
'&&': t('web_visubot_blocks_and'),
32+
'||': t('web_visubot_blocks_or'),
33+
break: t('web_visubot_blocks_break'),
3034
},
3135
}
3236
}

‎web/src/ui/blockView.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ export class BlockView {
640640
continue
641641
}
642642
// Schlüsselwörter in der Sprache der Oberfläche (Holger 5.11.: für Jüngere „wenn“ statt „if“)
643-
const word = this.word(token.kind === 'kw' ? { ...token, text: this.options.labels.keywords?.[token.text] ?? token.text } : token)
643+
const word = this.word(this.translated(token))
644644
if (v && (token.kind === 'lit' || token.kind === 'str' || (token.kind === 'var' && !token.fixed))) {
645645
word.dataset.value = JSON.stringify({ path: v.path, index: v.n++ })
646646
}
@@ -719,6 +719,22 @@ export class BlockView {
719719
return foot
720720
}
721721

722+
/** Schlüsselwörter und `!`, `&&`, `||` in der Sprache der Oberfläche („nicht“, „und“, „oder“), falls übersetzt. */
723+
private translated(token: BlockToken): BlockToken {
724+
const words = this.options.labels.keywords
725+
if (!words) return token
726+
if (token.kind === 'kw') return { ...token, text: words[token.text] ?? token.text }
727+
if (token.kind !== 'text') return token
728+
// Aussprung: „break“ als ganzer Satz („verlasse die Schleife“)
729+
if (token.text.trim() === 'break' && words.break) return { kind: 'kw', text: words.break }
730+
const text = token.text
731+
.replace(/&&/g, words['&&'] ? ` ${words['&&']} ` : '&&')
732+
.replace(/\|\|/g, words['||'] ? ` ${words['||']} ` : '||')
733+
.replace(/!(?!=)/g, words['!'] ? `${words['!']} ` : '!')
734+
.replace(/ {2,}/g, ' ')
735+
return { ...token, text }
736+
}
737+
722738
private keywordHead(keyword: string): HTMLElement {
723739
const head = document.createElement('div')
724740
head.className = 'bk-head'

‎web/test/blockLessons.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Block-Lektionen (de)', () => {
2121

2222
it('erscheinen nur mit Block-Ansicht in VisuBot, ohne Aufgaben', () => {
2323
expect(showingBlockLessons()).toBe(true)
24-
expect(lessons.length).toBeGreaterThanOrEqual(5)
24+
expect(lessons.length).toBeGreaterThanOrEqual(6)
2525
expect(lessons.every((l) => l.blocks && l.robot)).toBe(true)
2626
lessons.forEach((l, i) => expect(l.number, l.id).toBe(i + 1))
2727
expect(tasks).toEqual([])
@@ -67,7 +67,7 @@ describe('Block-Lektionen (de)', () => {
6767
checked++
6868
}
6969
}
70-
expect(checked).toBeGreaterThanOrEqual(13)
70+
expect(checked).toBeGreaterThanOrEqual(15)
7171
})
7272

7373
it('jede Runde von „Wo landet der mBot2?“ endet auf dem angegebenen Feld', () => {

0 commit comments

Comments
 (0)