From 3feaa9f411144b9121603faffb7b0b8073b77b70 Mon Sep 17 00:00:00 2001 From: Felienne Hermans Date: Wed, 27 Sep 2023 20:29:30 +0200 Subject: [PATCH] [TESTING] Weblate fix script (#4544) One of our biggest time sinks is fixing Weblate snippets (it is mine for sure and I could use my time in better ways). Sometimes, this is needed because a weblate PR is blocking other content PRs. While of course it is not great to throw away snippets, and we should fix them when possible, this PR introduces an environment variable called `fix_for_weblate`, which can be set to revert broken snippets back to English. So if needed this can be used --- content/adventures/ar.yaml | 4 +- content/adventures/ca.yaml | 2 +- content/adventures/cs.yaml | 4 +- content/adventures/cy.yaml | 2 +- content/adventures/de.yaml | 2 +- content/adventures/en.yaml | 2 +- content/adventures/eo.yaml | 2 +- content/adventures/es.yaml | 2 +- content/adventures/fi.yaml | 2 +- content/adventures/fr.yaml | 4 +- content/adventures/hi.yaml | 8 +- content/adventures/kmr.yaml | 2 +- content/adventures/ko.yaml | 4 +- content/adventures/nb_NO.yaml | 6 +- content/adventures/nl.yaml | 4 +- content/adventures/pl.yaml | 2 +- content/adventures/pt_BR.yaml | 2 +- content/adventures/ro.yaml | 2 +- content/adventures/ru.yaml | 8 +- content/adventures/sr.yaml | 4 +- content/adventures/sv.yaml | 2 +- content/adventures/te.yaml | 2 +- content/adventures/tr.yaml | 4 +- content/adventures/uk.yaml | 4 +- content/adventures/zh_Hans.yaml | 8 +- content/adventures/zh_Hant.yaml | 2 +- tests/Tester.py | 13 +- .../test_public_programs.py | 2 +- tests/test_snippets/test_adventures.py | 152 +++++++++--------- tests/test_snippets/test_parsons.py | 57 +++++-- 30 files changed, 170 insertions(+), 144 deletions(-) diff --git a/content/adventures/ar.yaml b/content/adventures/ar.yaml index 1291a099983..11d36d5d0c3 100644 --- a/content/adventures/ar.yaml +++ b/content/adventures/ar.yaml @@ -252,9 +252,9 @@ adventures: ``` {print} حقيبة الظهر خاصته أصبحت ثقيلة للغاية. {print} كان داخلها زجاجة ماء و مصباح و طعام. - المحتويات هي ماء، مصباح، طعام + المحتويات {is} ماء، مصباح، طعام الزائد {is} {ask} ما الذي عليه التخلص منه؟ - {remove} الزائد {from} المحتويات + {remove} الزائد {from} المحتويات ``` start_code: "{print} قصتك" 13: diff --git a/content/adventures/ca.yaml b/content/adventures/ca.yaml index c7d238308fc..95734195e44 100644 --- a/content/adventures/ca.yaml +++ b/content/adventures/ca.yaml @@ -82,7 +82,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCan you use the 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}` in your own story?\n" start_code: '{print} La teva història' 7: diff --git a/content/adventures/cs.yaml b/content/adventures/cs.yaml index ab2463c0700..0eda5184b69 100644 --- a/content/adventures/cs.yaml +++ b/content/adventures/cs.yaml @@ -304,9 +304,9 @@ adventures: example_code_2: | ``` {print} Slyší zvuk - zvirata {is} 🐿, 🦔, 🦇, 🦉 + zvířata {is} 🐿, 🦔, 🦇, 🦉 zvire {is} {ask} Co si myslíš, že to je? - {add} zvire {to_list} zvirata + {add} zvire {to_list} zvířata {print} to byla zvířata {at} {random} ``` story_text_3: | diff --git a/content/adventures/cy.yaml b/content/adventures/cy.yaml index 1ace1f8d514..a4b218dcebc 100644 --- a/content/adventures/cy.yaml +++ b/content/adventures/cy.yaml @@ -92,7 +92,7 @@ adventures: story_text_2: "The command `{add}` can also come in handy in your story.\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCan you use the 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}` in your own story?\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" start_code: '{print} Your story' 4: diff --git a/content/adventures/de.yaml b/content/adventures/de.yaml index ba167a38bb6..be72448ec7e 100644 --- a/content/adventures/de.yaml +++ b/content/adventures/de.yaml @@ -381,7 +381,7 @@ adventures: Füge neue Zeilen Code zu deiner Geschichte hinzu, sodass alle neuen Befehle mindestens ein Mal in deiner Geschichte vorkommen. example_code_3: | ``` - {print} Sein Rucksack wurde viel zu schwer. + {print} Sein Ruck sack wurde viel zu schwer. {print} Drinnen waren eine Flasche Wasser, eine Taschenlampe und ein Ziegelstein. Rucksack {is} Wasser, Taschenlampe, Ziegelstein rauswerfen {is} {ask} Welchen Gegenstand soll er rauswerfen? diff --git a/content/adventures/en.yaml b/content/adventures/en.yaml index d179fea571e..6884a014d4d 100644 --- a/content/adventures/en.yaml +++ b/content/adventures/en.yaml @@ -1126,7 +1126,7 @@ adventures: animals {is} 🐿, 🦔, 🦇, 🦉 animal {is} {ask} What do you think it is? {add} animal {to_list} animals - {print} it was an animal {at} {random} + {print} it was an animals {at} {random} ``` story_text_3: | This is an example of the `{remove}` command in your story diff --git a/content/adventures/eo.yaml b/content/adventures/eo.yaml index 4532b00831c..f4a0edfab8f 100644 --- a/content/adventures/eo.yaml +++ b/content/adventures/eo.yaml @@ -323,7 +323,7 @@ adventures: story_text: "En ĉi tiu nivelo, vi lernos kiel facile peti (per `{ask}`) la mendojn de viaj gastoj en mallonga kodo.\n" example_code: "```\npladoj = entreo, ĉefplado, deserto\n{for} plado {in} pladoj\n manĝaĵo = {ask} 'Kion vi volas manĝi por via ' plado '?'\n {print} manĝaĵo ' estos via ' plado\n```\n" story_text_2: "\nKompreneble, vi ankaŭ povus mendi por pluraj homoj!\n" - example_code_2: "```\npladoj = entreo, ĉefplado, deserto\nnomoj = Timoteo, Omaro\n{for} nomo {in} nomoj\n {for} plado {in} pladoj\n manĝaĵo = {ask} nomo ', kion vi volas manĝi por via ' plado '?'\n {print} nomo ' mendas ' food 'n por sia ' plado\n```\n" + example_code_2: "```\npladoj = entreo, ĉefplado, deserto\nnomoj = Timoteo, Omaro\n{for} nomo {in} nomoj\n {for} plado {in} pladoj\n manĝaĵo = {ask} nomo ', kion vi volas manĝi por via ' plado '?'\n {print} nomo ' mendas ' manĝaĵo 'n por sia ' plado\n```\n" start_code: pladoj = entreo, ĉefplado, deserto 11: story_text: "Oni povas uzi `{for} i {in} {range} 1 {to} 5` por orde presi (kune kun `{print}`) la mendojn de pluraj klientoj.\n" diff --git a/content/adventures/es.yaml b/content/adventures/es.yaml index c6364a7762c..daee00a33ea 100644 --- a/content/adventures/es.yaml +++ b/content/adventures/es.yaml @@ -257,7 +257,7 @@ adventures: animales {is} 🐿, 🦔, 🦇, 🦉 animal {is} {ask} ¿Qué piensas qué es? {add} animal {to_list} animales - {print} fue un animal {at} {random} + {print} fue un animales {at} {random} ``` story_text_3: | Este es un ejemplo del comando `{remove}` en tu historia diff --git a/content/adventures/fi.yaml b/content/adventures/fi.yaml index 7f2b1255626..d7d18d7c252 100644 --- a/content/adventures/fi.yaml +++ b/content/adventures/fi.yaml @@ -79,7 +79,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCan you use the 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}` in your own story?\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" 15: diff --git a/content/adventures/fr.yaml b/content/adventures/fr.yaml index 9c1e862dc36..d17e52cf3ab 100644 --- a/content/adventures/fr.yaml +++ b/content/adventures/fr.yaml @@ -212,9 +212,9 @@ adventures: ``` {print} Son sac à dos est beaucoup trop lourd. {print} Il y a dedans une bouteille d'eau, une lampe torche et une brique. - sac {is} eau, torche, brique + sac_à_dos {is} eau, torche, brique jeté {is} {ask} Quel objet devrions-nous jeter ? - {remove} jeté {from} sac + {remove} jeté {from} sac_à_dos ``` start_code: "{print} Ton histoire" 4: diff --git a/content/adventures/hi.yaml b/content/adventures/hi.yaml index 46fb4f05c26..964cdf7e28e 100644 --- a/content/adventures/hi.yaml +++ b/content/adventures/hi.yaml @@ -276,16 +276,16 @@ adventures: example_code_2: |- ``` {print} वह एक आवाज सुनता है - जानवरों {is}🐿, 🦔, 🦇, 🦉 - जानवर {is} {ask} आपको क्या लगता है कि यह क्या है? - {add} जानवर {to_list} जानवरों + जानवरों {is} 🐿, 🦔, 🦇, 🦉 + जानवर_extra {is} {ask} आपको क्या लगता है कि यह क्या है? + {add} जानवर_extra {to_list} जानवरों {print} यह एक था जानवरों {at} {random} ``` story_text_3: |- यह आपकी कहानी में `{remove}` आदेश का एक उदाहरण है example_code_3: | ``` - {print} उनका बैग बहुत भारी हो गया था। + {print} उनका बै ग बहुत भारी हो गया था। {print} अंदर पानी की एक बोतल, एक टॉर्च और एक ईंट थी। बैग {is} पानी, टॉर्च, ईंट डंप {is} {ask} उसे कौन सी वस्तु गिराना चाहिए? diff --git a/content/adventures/kmr.yaml b/content/adventures/kmr.yaml index 076f7b73854..08f1e99010e 100644 --- a/content/adventures/kmr.yaml +++ b/content/adventures/kmr.yaml @@ -92,7 +92,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCopy your story from the previous levels into this level.\nIn this level you've learned 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}`.\nAdd new lines of code to your story, so that all of the new commands are featured at least once in your story.\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" start_code: '{print} Your story' diff --git a/content/adventures/ko.yaml b/content/adventures/ko.yaml index 6b4e516be79..2b3fc5a732c 100644 --- a/content/adventures/ko.yaml +++ b/content/adventures/ko.yaml @@ -334,7 +334,7 @@ adventures: story_text_2: "### 연습문제\nThe calculator above will calculate the answer for you, but you can also make a program to test your own maths skills, like this:\nFill in the blanks to make it complete!\n" example_code_2: "```\ncorrect_answer = 11 * 27\nanswer = {ask} 'How much is 11 times 27?'\n{if} answer {is} _ {print} 'good job!'\n{else} {print} 'Wrong! It was ' _\n```\n" start_code: "{print} 'Welcome to this calculator!'" - story_text_3: "\n **Extra** You can also let the computer do random sums on its own using random.\n\n This is how you choose a number of tables to practice, and from that you always get a different sum:\n" + story_text_3: "\n**Extra** You can also let the computer do random sums on its own using random.\n\n This is how you choose a number of tables to practice, and from that you always get a different sum:\n" 9: story_text: "In level 6 you created a calculator, in this level you can expand that code so it asks multiple questions.\n\n### 연습문제 1\nCan you finish line 10 to make to program work?\n\n### 연습문제 2\nGive the player feedback when the enter a right or wrong answer. To achieve that, expand your program with an `{else}`.\n" example_code: "```\nscore = 0\n{repeat} 10 {times}\n numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\n number1 = numbers {at} {random}\n number2 = numbers {at} {random}\n correct_answer = number1 * number2\n {print} 'What is ' number1 ' times ' number2 '?'\n answer = {ask} 'Type your answer here...'\n {print} 'Your answer is' answer\n {if} _ {is} _\n score = score + 1\n{print} 'Great job! Your score is... ' score ' out of 10!'\n```\n" @@ -621,7 +621,7 @@ adventures: 6: story_text: "You can also make an Earthworm die again in this, but now you can also calculate how many points have been rolled.\nYou may know that the worm counts 5 points for Earthworms. Now after a roll you can immediately calculate how many points you have thrown.\nThis is the code to calculate points for one die:\n\n### 연습문제\nCan you make the code so that you get the total score for 8 dice? To do that, you have to cut and paste some lines of the code.\n" example_code: "```\nchoices = 1, 2, 3, 4, 5, earthworm\npoints = 0\nthrow = choices {at} {random}\n{print} 'you threw ' throw\n{if} throw {is} earthworm points = points + 5 {else} points = points + throw\n{print} 'those are ' points ' points'\n```\n" - example_code_2: "\n Did you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7!\n" + example_code_2: "\nDid you manage to calculate the score for 8 dice? That required a lot of cutting and pasting, right? We are going to make that easier in level 7!\n" start_code: "{print} 'What will the die indicate this time?'" 7: story_text: "You can also make a dice again in this level. With the `{repeat}` code you can easily roll a whole hand of dice.\n\n### 연습문제\nTry to finish the sample code! **Extra** Think of a game you know that involves a dice and program that using a `{repeat}`.\n" diff --git a/content/adventures/nb_NO.yaml b/content/adventures/nb_NO.yaml index de7fc0cd80c..6bd5930f74a 100644 --- a/content/adventures/nb_NO.yaml +++ b/content/adventures/nb_NO.yaml @@ -119,7 +119,7 @@ adventures: story_text_2: "Kommandoen `{add}` kan også være nyttig i historien din.\n" example_code_2: "```\n{print} Han hører en lyd\ndyrene {is} 🐿, 🦔, 🦇, 🦉\ndyret {is} {ask} Hva tror du det er?\n{add} dyret {to_list} dyrene\n{print} det var en dyrene {at} {random}\n```\n" story_text_3: "Dette er et eksempel på `{remove}` kommandoen i historien din\n" - example_code_3: "```\n{print} Ryggsekken hans ble alt for tung.\n{print} Inni den var en vannflaske, en lommelykt og en murstein.\nryggsek {is} vannflaske, lommelykt, murstein\ndump {is} {ask} Hvilken ting skal han legge igjen?\n{remove} dump {from} ryggsekk\n```\n" + example_code_3: "```\n{print} Ryggsekken hans ble alt for tung.\n{print} Inni den var en vannflaske, en lommelykt og en murstein.\nryggsekk {is} vannflaske, lommelykt, murstein\ndump {is} {ask} Hvilken ting skal han legge igjen?\n{remove} dump {from} ryggsekk\n```\n" start_code: '{print} Fortellingen din' 15: story_text: "Ved hjelp av `{while}` løkke kan man gjøre historier mer interessante. For eksempel kan du bruke `{while} spillet {is} 'i gang'`så du kan spille til spillet er over.\nEller så kan du bruke `{while} sverd {is} 'mistet'` så spilleren ikke kan fortsette før de har funnet noe.\n" @@ -329,7 +329,7 @@ adventures: story_text: "Har du problemer med å bestemme hva du vil ha til middag? Du kan la Hedy bestemme for deg!\nLag en liste over dine favorittmåltid og Hedy kan tilfeldig plukke ut en middag til deg.\nDu kan også ha litt gøy ved å la Hedy velge prisen for middagen også. Hva blir det til middag i dag?`\n" example_code: "```\n{print} Velkommen til Hedys Tilfeldige Restaurant!\n{print} Den eneste restauranten som tilfeldig velger hva du får servert og hva det vil koste!\nforretter {is} salat, suppe, carpaccio\nhovedretter {is} pizza, rosenkål, spaghetti\ndesserter {is} brownies, iskrem, franske oster\ndrikker {is} cola, øl, vann\npriser {is} 10 kroner, 100 kroner, 1000 kroner\n{print} Du vil begynne med: forretter {at} {random}\n{print} Og så vil vi servere: hovedretter {at} {random}\n{print} Og til slutt: desserter {at} {random}\n{print} Til maten vil du få drikker {at} {random} å drikke\n{print} Det vil koste deg: priser {at} {random}\n{print} Takk og vel bekomme!\n```\n" story_text_2: "Har dine gjester noen allergier eller noen retter de ikke liker? Da kan du bruke `{remove}`-kommandoen til å fjerne ting fra menyen.\n" - example_code_2: "```\n{print} Mysteriemilkshake\nsmaker {is} jordbær, sjokolader, vanilje\nallergier {is} {ask} Er du allergisk til en av smakene?\n{remove} allergier {from} smaker\n{print} Du vil få en flavors {at} {random} milkshake\n```\n" + example_code_2: "```\n{print} Mysteriemilkshake\nsmaker {is} jordbær, sjokolader, vanilje\nallergier {is} {ask} Er du allergisk til en av smakene?\n{remove} allergier {from} smaker\n{print} Du vil få en smaker {at} {random} milkshake\n```\n" start_code: '# skriv koden din her' 15: story_text: "Med `{while}` kan du sørge for at kundene dine kan fortsette å bestille til de er ferdig.\n" @@ -528,7 +528,7 @@ adventures: story_text: "Hvor ofte må hver ta oppvasken? Er det rettferdig? Du kan telle det på dette nivået.\n" example_code: "```\nfamilie = mamma, pappa, Emma, Sofie\nemma_vasker = 0\noppvasker = familie {at} {random}\n{print} 'Den som tar oppvasken er ' oppvasker\n{if} oppvasker {is} Emma emma_vasker = emma_vasker + 1\n{print} 'Emma tar oppvasken ' emma_vasker ' ganger denne uken'\n```\n\nDu kan nå kopiere linjene 3 til 5 et par ganger (f.eks. 7 ganger for en hel uke) for å regne ut for hele uken.\nLager du koden for hele uken?\n" story_text_2: "Om du er ekstremt uheldig så kan det forrige programmet velge deg til å gjøre oppvasken hele uken! Det er ikke rettferdig!\nFor å lage et mer rettferdig system så kan du bruke `{remove}`-kommandoen for å fjerne en gitt person fra listen. På denne måten trenger du ikke å ta oppvasken igjen før alle har tatt sin tur.\n\nMandag og tirsdag er klar for deg! Kan du legge til resten av uken?\nOg.. kan du komme på en løsning dersom listen er tom?\n" - example_code_2: "```\nfamilie = mamma, pappa, Emma, Sofie\noppvasker = familie {at} {random}\n{print} 'Mandag blir oppvasken tatt av: ' dishwasher\n{remove} oppvasker {from} familie\noppvasker = people {at} {random}\n{print} 'Tirsdag blir oppvasken tatt av: ' dishwasher\n{remove} oppvasker {from} familie\noppvasker = familie {at} {random}\n```\n" + example_code_2: "```\nfamilie = mamma, pappa, Emma, Sofie\noppvasker = familie {at} {random}\n{print} 'Mandag blir oppvasken tatt av: ' oppvasker\n{remove} oppvasker {from} familie\noppvasker = familie {at} {random}\n{print} 'Tirsdag blir oppvasken tatt av: ' oppvasker\n{remove} oppvasker {from} familie\noppvasker = familie {at} {random}\n```\n" start_code: "{print} 'Hvem tar oppvasken?'" 5: story_text: "Med `{if}`kan du nå ha det mer gøy med valg i programmet. Du kan få programmet til å respondere med det valget maskinen har tatt.\n\nKan du fullføre koden så det skriver ut 'det var dumt' når det er din tur og 'jippi!' ellers?\nIkke glem fnutter!\n" diff --git a/content/adventures/nl.yaml b/content/adventures/nl.yaml index f5283d7ac40..2cb595ba56f 100644 --- a/content/adventures/nl.yaml +++ b/content/adventures/nl.yaml @@ -1628,9 +1628,9 @@ adventures: ``` start_code: "# Schrijf jouw code hier" 13: - story_text: |2 + story_text: | - ### Opdracht 1 + ### Opdracht 1 Maak het sommenoefenprogramma nu extra moeilijk. De speler moet twee sommen achter elkaar goed hebben. Maak de codes op de streepjes af. ### Opdracht 2 (extra) diff --git a/content/adventures/pl.yaml b/content/adventures/pl.yaml index b012ffe3612..3f70b606b94 100644 --- a/content/adventures/pl.yaml +++ b/content/adventures/pl.yaml @@ -494,7 +494,7 @@ adventures: story_text_2: "Komenda `{add}` może się przydać w historyjce.\n" example_code_2: "```\n{print} On słyszy odgłos\nzwierzęta {is} 🐿, 🦔, 🦇, 🦉\nzwierzę {is} {ask} Co to było?\n{add} zwierzę {to_list} zwierzęta\n{print} To był odgłos zwierzęta {at} {random}\n```\n" story_text_3: "To jest przykład polecenia `{remove}` w twojej opowieści.\n\n### Ćwiczenie\nSkopiuj swoją opowieść z poprzednich poziomów na ten poziom.\nNa tym poziomie nauczyłeś się 3 nowych komend `{at} {random}`, `{add} {to}` i `{remove} {from}`.\nDodaj nowe wiersze kodu do swojej historii, aby wszystkie nowe polecenia znalazły się w niej przynajmniej raz.\n" - example_code_3: "```\n{print} Jego plecak stał się zbyt ciężki.\n{print} W środku była butelka wody, latarka i cegła.\nplecak {is} woda, latarka, cegła\nwyrzuc {is} {ask} Który przedmiot powinien wyrzucić?\n{remove} wyrzuc {from} plecak\n```\n" + example_code_3: "```\n{print} Jego stał się zbyt ciężki.\n{print} W środku była butelka wody, latarka i cegła.\nplecak {is} woda, latarka, cegła\nwyrzuc {is} {ask} Który przedmiot powinien wyrzucić?\n{remove} wyrzuc {from} plecak\n```\n" start_code: '{print} Twoja histora' 15: story_text: "Przy użyciu pętli `{while}` możesz stworzyć jeszcze bardziej wciągające opowieści. Na przykład, możesz użyć `{while} gra {is} 'działa'` żeby kontynuować grę aż się zakończy.\nAlternatywnie możesz napisać `{while} miecz {is} 'zagubiony'` żeby nie pozwolić graczowi kontynuować zanim znajdą miecz.\n" diff --git a/content/adventures/pt_BR.yaml b/content/adventures/pt_BR.yaml index f409a4303e7..81a4d5fd795 100644 --- a/content/adventures/pt_BR.yaml +++ b/content/adventures/pt_BR.yaml @@ -221,7 +221,7 @@ adventures: Este é um exemplo do comando `{remove}` em sua história example_code_3: | ``` - {print} A sua mochila ficou muito pesada. + {print} A sua ficou muito pesada. {print} Dentro havia uma garrafa de água, uma lanterna e um tijolo. mochila {is} água, lanterna, tijolo lixo {is} {ask} Qual item deve ser descartado? diff --git a/content/adventures/ro.yaml b/content/adventures/ro.yaml index ce39dbe56a2..3f0dc30f9b4 100644 --- a/content/adventures/ro.yaml +++ b/content/adventures/ro.yaml @@ -28,7 +28,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCopy your story from the previous levels into this level.\nIn this level you've learned 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}`.\nAdd new lines of code to your story, so that all of the new commands are featured at least once in your story.\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" 4: diff --git a/content/adventures/ru.yaml b/content/adventures/ru.yaml index 26a64638313..bd9c9e06ad8 100644 --- a/content/adventures/ru.yaml +++ b/content/adventures/ru.yaml @@ -87,7 +87,7 @@ adventures: name: История levels: 3: - example_code_2: "```\n{print} Он слышит звук\nживотные {is} 🐿, 🦔, 🦇, 🦉\nживотные {is} {ask} Как ты думаешь, что это?\n{add} животное {to_list} животные\n{print} это было животное {at} {random}\n```\n" + example_code_2: "```\n{print} Он слышит звук\nживотные {is} 🐿, 🦔, 🦇, 🦉\nживотное {is} {ask} Как ты думаешь, что это?\n{add} животное {to_list} животные\n{print} это было животные {at} {random}\n```\n" story_text_3: "Вот пример команды `{remove}` в вашей истории\n\nМожете ли вы использовать 3 новые команды `{at} {random}`, `{add} {to}` и `{remove} {from}` в своей собственной истории?\n" start_code: '{print} Ваша история' story_text: "На уровне 3 вы можете сделать свою историю более увлекательной. Вы можете использовать случайность для любого монстра, животного или другого препятствия, например, так:\n" @@ -201,13 +201,13 @@ adventures: start_code: "{print} 'Кто моет посуду?'" 5: story_text: "С помощью сайта `{if}` вы можете получить больше удовольствия от выбора в программе. Вы можете сделать так, чтобы ваша программа реагировала на выбор, который сделал компьютер.\n\nМожете ли вы дописать код так, чтобы он печатал \"жаль\", когда наступает ваша очередь, а в противном случае - \"да!\"?\nНе забывайте о кавычках!\n" - example_code: "```\nлюди {is} мама, папа, Эмма, Софи\nпосудомоечная машина {is} люди {at} {random}\n{if} посудомоечная машина {is} Софи {print} _ слишком плохо, что я должна мыть посуду _ \n{else} {print} 'к счастью, посуды нет, потому что' _ 'уже моет посуду'\n```\n" + example_code: "```\nлюди {is} мама, папа, Эмма, Софи\nпосудомоечная_машина {is} люди {at} {random}\n{if} посудомоечная_машина {is} Софи {print} _ слишком плохо, что я должна мыть посуду _ \n{else} {print} 'к счастью, посуды нет, потому что' _ 'уже моет посуду'\n```\n" start_code: "{print} 'Кто моет посуду?'" 6: story_text: "Как часто каждый будет мыть посуду? Справедливо ли это? Вы можете посчитать это на этом уровне.\n" example_code: "```\nлюди = mom, dad, Emma, Sophie\nemma_washes = 0\ndishwasher = люди {at} {random}\n{print} 'The dishwasher is' dishwasher\n{if} dishwasher {is} Emma emma_washes = emma_washes + 1\n{print} 'Emma will do the dishes this week' emma_washes 'times'\n```\n\nNow you can copy lines 3 to 5 a few times (e.g. 7 times for a whole week) to calculate for a whole week again.\nDo you make the code for the whole week?\n" story_text_2: "Если вам крайне не повезло, предыдущая программа может выбрать вас для мытья посуды на всю неделю! Это несправедливо!\nЧтобы создать более справедливую систему, вы можете использовать команду `{remove}`, чтобы удалить выбранного человека из списка. Таким образом, вам не придется снова мыть посуду до тех пор, пока все не отмоют свою очередь.\n\nПонедельник и вторник готовы! Можете ли вы добавить остальные дни недели?\nИ... можете ли вы придумать решение для случая, когда список пуст?\n" - example_code_2: "```\nлюди = мама, папа, Эмма, Софи\nпосудомоечная машина = люди {at} {random}\n{print} 'В понедельник посуду моет: ' посудомоечная машина\n{remove} посудомоечная машина {from} люди\nпосудомоечная машина = люди {at} {random}\n{print} 'Вторник посуду моет: ' посудомоечная машина\n{remove} посудомоечная машина {from} люди\nпосудомоечная машина = люди {at} {random}\n```\n" + example_code_2: "```\nлюди = мама, папа, Эмма, Софи\nпосудомоечная_машина = люди {at} {random}\n{print} 'В понедельник посуду моет: ' посудомоечная_машина\n{remove} посудомоечная_машина {from} люди\nпосудомоечная_машина = люди {at} {random}\n{print} 'Вторник посуду моет: ' посудомоечная_машина\n{remove} посудомоечная_машина {from} люди\nпосудомоечная_машина = люди {at} {random}\n```\n" start_code: "{print} 'Кто моет посуду?'" 7: story_text: "На сайте `{repeat}` вы можете повторять фрагменты кода. С его помощью можно рассчитать, кто будет мыть посуду в течение всей недели.\n" @@ -431,7 +431,7 @@ adventures: example_code: "```\nстих = 99\n{print} стих ' бутылки пива на стене '\n{print} стих ' бутылки пива'\n{print} 'Возьми одну, передай по кругу'\nстих = стих - 1\n{print} стих ' бутылки пива на стене'\n{sleep}\n```\n" start_code: "{print} 'Давай петь!'" story_text_2: "Эта детская песенка отсчитывает время от 5 маленьких обезьянок до 1 обезьянки.\nЕсли вы скопируете строки 2 - 7 и вставите их под кодом, вы сможете спеть всю песню!\n" - example_code_2: "```\nчисло = 6\nчисло = число - 1\nprint number ' Маленькие обезьянки прыгают по кровати'\nprint 'Один упал и ударился головой'\nprint 'Мама позвонила доктору, и доктор сказал'\nprint 'Больше никаких обезьян, прыгающих на кровати!\nsleep\n```\n" + example_code_2: "```\nчисло = 6\nчисло = число - 1\nprint число ' Маленькие обезьянки прыгают по кровати'\nprint 'Один упал и ударился головой'\nprint 'Мама позвонила доктору, и доктор сказал'\nprint 'Больше никаких обезьян, прыгающих на кровати!'\nsleep\n```\n" 7: story_text: "Песни часто содержат много повторений. Например... Детеныш акулы! Если вы поете ее, вы продолжаете петь одно и то же:\n\nBaby Shark tututudutudu
\nBaby Shark tutututudutudu
\nBaby Shark tututudutudu
\nBaby Shark\n\nВы можете сделать эту песню намного короче с помощью `{repeat}`! Вы можете закончить код?\n" example_code: "```\n{repeat} _ _ {print} 'Baby Shark tututudutudu'\n{print} 'Baby Shark'\n```\n\nAfter Baby Shark you can of course also program other songs. There are many songs with repetition.\n" diff --git a/content/adventures/sr.yaml b/content/adventures/sr.yaml index 3102991429c..daeb9b70b93 100644 --- a/content/adventures/sr.yaml +++ b/content/adventures/sr.yaml @@ -75,9 +75,9 @@ adventures: story: levels: 3: - example_code_3: "```\n{print} Njegov ranac je postao previše težak.\n{print} Unutra je bila flaša sa vodom, baterijska lampa i cigla.\nranac {is} vida, lampa, cigla\notpad {is} {ask} Šta bi iz torbe trebalo izbaciti?\n{remove} otpad {from} ranac\n```\n" + example_code_3: "```\n{print} Njegov je postao previše težak.\n{print} Unutra je bila flaša sa vodom, baterijska lampa i cigla.\nranac {is} vida, lampa, cigla\notpad {is} {ask} Šta bi iz torbe trebalo izbaciti?\n{remove} otpad {from} ranac\n```\n" start_code: '{print} Tvoja priča' - example_code_2: "```\n{print} On čuje zvuk\nživotinje {is} 🐿, 🦔, 🦇, 🦉\nživotinja {is} {ask} Šta misliš da je to?\n{add} životinja {to_list} životinje\n{print} to je bila životinjal {at} {random}\n```\n" + example_code_2: "```\n{print} On čuje zvuk\nživotinje {is} 🐿, 🦔, 🦇, 🦉\nživotinja {is} {ask} Šta misliš da je to?\n{add} životinja {to_list} životinje\n{print} to je bila životinje {at} {random}\n```\n" story_text: "U nivou 3 možeš osmisliti priču da bude još zanimljivija. Možeš odabrati bilo koje čudovište, životinju ili bilo koju drugu prepreku, ovako:\n" example_code: "```\nživotinje {is} 🦔, 🐿, 🦉, 🦇\n{print} On sada cuje zvuk životinje {at} {random}\n```\n" story_text_2: "Komanda `{add}` ti takodje može biti korisna u tvojoj priči.\n" diff --git a/content/adventures/sv.yaml b/content/adventures/sv.yaml index 27f9e4cc655..3a7c5408432 100644 --- a/content/adventures/sv.yaml +++ b/content/adventures/sv.yaml @@ -192,7 +192,7 @@ adventures: story_text: "Sånger innehåller ofta många upprepningar. Ibland bygger upprepningarna också på räkning.\nTill exempel i den välkända sången 'Bottles of beer'. Du kan programmera den låten med lite matematik.\n\nTips: Använd funktionen för högläsning för att låta Hedy sjunga sången för dig!\n\n### Övning\nDu kan nu upprepa raderna 2 till 7 hur många gånger som helst genom att kopiera raderna.\n" example_code: "```\nvers = 99\n{print} vers ' ölflaskor på väggen'\n{print} vers ' ölflaskor'\n{print} 'Ta en ner, skicka runt den'\nvers = vers - 1\n{print} vers ' ölflaskor på väggen'\n{sleep}\n```\n" story_text_2: "Denna barnvisa räknar ner från fem små apor till en apa.\nOm du kopierar rad 2–7 och klistrar in dem under koden kan du sjunga hela sången!\n" - example_code_2: "```\nantal = 6\nantal = antal - 1\n{print} antal ' små apor som hoppar på sängen'.\n{print} 'En av dem ramla ner av och slog huvudet.'\n{print} 'Mamma ringde till doktorn och doktorn sa'\n{print} 'INGA FLER APOR SOM HOPPAR PÅ SÄNGEN!'\n{sleep}\n```\n" + example_code_2: "```\nantal = 6\nantal = antal - 1\n{print} antal ' små apor som hoppar på sängen.'\n{print} 'En av dem ramla ner av och slog huvudet.'\n{print} 'Mamma ringde till doktorn och doktorn sa'\n{print} 'INGA FLER APOR SOM HOPPAR PÅ SÄNGEN!'\n{sleep}\n```\n" 7: story_text: "Sånger innehåller ofta många upprepningar. Till exempel ... Baby Shark! Om du sjunger den sjunger du samma sak hela tiden:\n\nBaby Shark tututududutudu
\nBaby Shark tututududutudu
\nBaby Shark tututudutudu
\nBaby Shark\n\n### Övning\nKan du skriva ut låten Baby Shark med `{repeat}`? Avsluta koden genom att ersätta tomrummen i koden?\n**Extra** Efter Baby Shark kan du naturligtvis också programmera andra låtar. Det finns många låtar med upprepning!\nKan du komma på en sång tilloch skriva ut den?\n" example_code: "```\n{repeat} _ _ {print} 'Baby Shark tututudutudu'\n{print} 'Baby Shark'\n```\n" diff --git a/content/adventures/te.yaml b/content/adventures/te.yaml index 41002c143f0..58dd0fde0a8 100644 --- a/content/adventures/te.yaml +++ b/content/adventures/te.yaml @@ -86,7 +86,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCan you use the 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}` in your own story?\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" 4: diff --git a/content/adventures/tr.yaml b/content/adventures/tr.yaml index 81759a5fa7c..bd6c1b9e4d7 100644 --- a/content/adventures/tr.yaml +++ b/content/adventures/tr.yaml @@ -2764,9 +2764,9 @@ adventures: story_text: "Gerçek Python koduna ulaştık! Yani bu, bundan sonra `{print}` ve `{range}` ile beraber artık bir de parantez kullanmamız gerektiği anlamına geliyor.\nBu aynı zamanda İngilizce komutları kullandığınız sürece bu seviyedeki Hedy kodunu herhangi bir Python ortamında kullanabileceğiniz anlamına gelir. Şimdiye kadar kullanmadıysanız, bunu yapmak için komutlar menüsünden geçişi değiştirebilirsiniz." example_code: "```\n{print}('Merhaba!')\n{for} i {in} {range}(1, 10):\n {print}('Bu, satır ', i)\n```\n" story_text_2: Birden fazla öğe yazdırmak istiyorsanız, bunları virgülle ayırmanız gerekir. - example_code_2: "```\nsıcaklık = 25\n{print}('Hava dışarıda ', temperature, ' derece')\n```\n" + example_code_2: "```\nsıcaklık = 25\n{print}('Hava dışarıda ', sıcaklık, ' derece')\n```\n" story_text_3: Python kodunu elde etmek için yapmamız gereken son değişiklik `{ask}` ifadesini `{input}` olarak değiştirmektir. - example_code_3: "```\n{print}('Benim adım Hedy!')\nisim = {input}('Senin adın ne?')\n{print}('Demek senin ismin ', name)\n```\n" + example_code_3: "```\n{print}('Benim adım Hedy!')\nisim = {input}('Senin adın ne?')\n{print}('Demek senin ismin ', isim)\n```\n" ask_command: name: "{ask}" description: sor komutuna giriş diff --git a/content/adventures/uk.yaml b/content/adventures/uk.yaml index 0068bde8d27..3b16f08de4f 100644 --- a/content/adventures/uk.yaml +++ b/content/adventures/uk.yaml @@ -93,9 +93,9 @@ adventures: story_text: "На третьому рівні ви можете зробити свою історію веселішою. Ви можете використовувати випадковість для будь-якого монстра, тварини або іншої перешкоди, наприклад, так:\n" example_code: "```\nтварини {is} 🦔, 🐿, 🦉, 🦇\n{print} Тепер він чує звуки тварини {at} {random}\n```\n" story_text_2: "Команда `{add}` також може стати в нагоді у вашій історії.\n" - example_code_2: "```\n{print} Він чує звук\nтварини {is} 🐿, 🦔, 🦇, 🦉\nтварина {is} {ask} Як ти думаєш, яка це істота?\n{add} тварина {to_list} тварини\n{print} це була тварина {at} {random}\n```\n" + example_code_2: "```\n{print} Він чує звук\nтварини {is} 🐿, 🦔, 🦇, 🦉\nтварина {is} {ask} Як ти думаєш, яка це істота?\n{add} тварина {to_list} тварини\n{print} це була тварини {at} {random}\n```\n" story_text_3: "Ось приклад команди `{remove}` у вашій історії\n\nСкопіюйте свою історію з попередніх рівнів у цей рівень.\nУ цьому рівні ви вивчили 3 нові команди `{at} {random}`, `{add} {to}` та `{remove} {from}` .\nДодайте нові рядки коду до вашої історії, щоб усі нові команди з'явилися у ній хоча б один раз.\n" - example_code_3: "```\n{print} Його рюкзак став занадто важким.\n{print} Усередині були пляшка води, ліхтарик і цегла.\nрюкзак {is} вода, ліхтарик, цегла\nвикинути {is} {ask} Який предмет він повинен викинути?\n{remove} викинути {from} рюкзак\n```\n" + example_code_3: "```\n{print} Його став занадто важким.\n{print} Усередині були пляшка води, ліхтарик і цегла.\nрюкзак {is} вода, ліхтарик, цегла\nвикинути {is} {ask} Який предмет він повинен викинути?\n{remove} викинути {from} рюкзак\n```\n" start_code: '{print} Твоя історія' 4: story_text: "Ви могли помітити, що у попередніх рівнях залишилась проблема. Ви намагались надрукувати речення, яке містить слово name, тобто `{print}` моє ім'я - name.\nВи можете розв'язувати цю проблему у цьому рівні. Ви повинні використовувати лапки для всього, що збираєтесь надрукувати.\n\n##Вправа\nСкопіюйте приклад коду і змусьте його працювати, додавши лапки в рядках.\n\n##Вправа2\nПоверніться на попередній рівень і скопіюйте код вашої історії. Зробіть так, щоб код працював на цьому рівні, додавши лапки в потрібних місцях.\nЗверніть увагу: Змінні у вашій історії повинні бути поза лапками. Так само, як у другому рядку прикладу коду. У цьому рядку ім'я змінної знаходиться поза лапками.\n" diff --git a/content/adventures/zh_Hans.yaml b/content/adventures/zh_Hans.yaml index 8f6011e67ae..3feeda704a6 100644 --- a/content/adventures/zh_Hans.yaml +++ b/content/adventures/zh_Hans.yaml @@ -364,7 +364,7 @@ adventures: story_text: "每个人洗了多少次碗?是否公平?在这一级你可以进行统计。\n" story_text_2: "如果你运气特别差,上一个程序可能每天都选你去洗碗!这不公平!\n为了创造一个更公平的系统,你可以用`{remove}`命令把选中的人从列表中移除。这样除非所有人都被轮到过一次,不然你不用再洗碗。\n\n周一和周二已经帮你写好了!你能把这周剩下的加上吗?\n另外……当列表里空了的时候,你有办法解决吗?\n" example_code: "```\n人们 = 妈妈, 爸爸, 艾玛, 索菲\n艾玛洗碗 = 0\n洗碗的 = 人们 {at} {random}\n{print} '洗碗的人是' 洗碗的\n{if} 洗碗的 {is} 艾玛 艾玛洗碗 = 艾玛洗碗 + 1\n{print} '艾玛这周要洗' 艾玛洗碗 '次碗'\n```\n\n现在你需要将第3到第5行复制几次(比如,复制7次表示一周)来计算一整周。\n你能写出一整周用的代码吗?\n" - example_code_2: "```\n人们 = 妈妈, 爸爸, 艾玛, 索菲\n洗碗的 = 人们 {at} {random}\n{print} '周一洗碗的是:' 洗碗的\n{remove} 洗碗的 {from} 人们\n洗碗的 = 人们 {at} {random}\n{print} '周二洗碗的是:' 洗碗的\n{remove} 洗碗的 {from} 人们菲\n洗碗的 = 人们 {at} {random}\n```\n" + example_code_2: "```\n人们 = 妈妈, 爸爸, 艾玛, 索菲\n洗碗的 = 人们 {at} {random}\n{print} '周一洗碗的是:' 洗碗的\n{remove} 洗碗的 {from} 人们\n洗碗的 = 人们 {at} {random}\n{print} '周二洗碗的是:' 洗碗的\n{remove} 洗碗的 {from} 人们\n洗碗的 = 人们 {at} {random}\n```\n" start_code: "{print} '谁负责洗碗?'" 4: story_text: "使用引号,可以使你的洗碗程序更加出色。\n\n### 练习\n首先,在空白处填写正确的符号或命令,以使此示例程序正常工作。\n你明白了吗?太好了!现在从上一个级别复制你自己的代码,并通过在正确的位置添加引号使其在此级别中正常工作。\n" @@ -698,7 +698,7 @@ adventures: 全餐 = 前菜, 主菜, 甜点 {for} 餐品 {in} 全餐 {print} '你的上菜顺序是 ' 餐品 '?' - _ + _ _ ``` story_text_2: | @@ -712,8 +712,8 @@ adventures: 客人们 = 丁满, 彭彭 {for} 客人 {in} 客人们 {for} 餐品 {in} 全餐 - 食物 = {ask} 客人 ',你想要吃什么' 餐品 '?' - {print} 客人 '点了' 食物 '作为' 餐品 + 食物 = {ask} 客人 ',你想要吃什么' 餐品 '?' + {print} 客人 '点了' 食物 '作为' 餐品 ``` start_code: "全餐 = 前菜, 主菜, 甜点" 11: diff --git a/content/adventures/zh_Hant.yaml b/content/adventures/zh_Hant.yaml index 98b63ba5645..f6d57efff2c 100644 --- a/content/adventures/zh_Hant.yaml +++ b/content/adventures/zh_Hant.yaml @@ -80,7 +80,7 @@ adventures: story_text: "In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:\n" example_code: "```\nanimals {is} 🦔, 🐿, 🦉, 🦇\n{print} He now hears the sound of an animals {at} {random}\n```\n" story_text_2: "The command `{add}` can also come in handy in your story.\n" - example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animal {at} {random}\n```\n" + example_code_2: "```\n{print} He hears a sound\nanimals {is} 🐿, 🦔, 🦇, 🦉\nanimal {is} {ask} What do you think it is?\n{add} animal {to_list} animals\n{print} it was an animals {at} {random}\n```\n" story_text_3: "This is an example of the `{remove}` command in your story\n\n### Exercise\nCan you use the 3 new commands `{at} {random}` , `{add} {to}` and `{remove} {from}` in your own story?\n" example_code_3: "```\n{print} His backpack got way too heavy.\n{print} Inside were a bottle of water, a flashlight and a brick.\nbag {is} water, flashlight, brick\ndump {is} {ask} Which item should he dump?\n{remove} dump {from} bag\n```\n" 4: diff --git a/tests/Tester.py b/tests/Tester.py index fa67e71c98e..0f867b35874 100644 --- a/tests/Tester.py +++ b/tests/Tester.py @@ -17,20 +17,27 @@ class Snippet: - def __init__(self, filename, level, code, field_name=None, adventure_name=None, error=None, language=None): + def __init__(self, filename, level, code, field_name=None, adventure_name=None, error=None, language=None, key=None, counter=0): self.filename = filename self.level = level - self.field_name = field_name + self.field_name = field_name if field_name is not None else '' self.code = code self.error = error + self.key = key if key is not None else '' filename_shorter = os.path.basename(filename) if language is None: self.language = filename_shorter.split(".")[0] else: self.language = language self.adventure_name = adventure_name - self.name = f'{self.language}-{self.level}-{self.field_name}' + self.name = f'{self.language}-{self.level}-{self.key}-{self.field_name}' self.hash = md5digest(self.code) + self.counter = counter + if counter > 0: + self.name += f'-{self.counter + 1}' + + def __repr__(self): + return f'Snippet({self.name})' class SkippedMapping: diff --git a/tests/test_public_programs/test_public_programs.py b/tests/test_public_programs/test_public_programs.py index 799446ff6b5..10ca8d80d4e 100644 --- a/tests/test_public_programs/test_public_programs.py +++ b/tests/test_public_programs/test_public_programs.py @@ -20,7 +20,7 @@ for p in public_programs: s = Snippet(filename='file', level=int(p['level']), - field_name='field', + field_name=None, code=p['code'], language=p['language'], error=p['error'] diff --git a/tests/test_snippets/test_adventures.py b/tests/test_snippets/test_adventures.py index 12df3594021..b0fab6c0839 100644 --- a/tests/test_snippets/test_adventures.py +++ b/tests/test_snippets/test_adventures.py @@ -10,6 +10,14 @@ from tests.Tester import HedyTester, Snippet from website.yaml_file import YamlFile +fix_error = False +# set this to True to revert broken snippets to their en counterpart automatically +# this is useful for large Weblate PRs that need to go through, this fixes broken snippets +if os.getenv('fix_for_weblate'): + fix_error = True + +check_stories = False + # Set the current directory to the root Hedy folder os.chdir(os.path.join(os.getcwd(), __file__.replace(os.path.basename(__file__), ''))) @@ -22,13 +30,14 @@ def collect_snippets(path, filtered_language=None): files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and f.endswith('.yaml')] for f in files: lang = f.split(".")[0] - if not filtered_language or (filtered_language and lang == filtered_language): + # we always grab the en snippets to restore broken code + if not filtered_language or (filtered_language and (lang == filtered_language or lang == 'en')): f = os.path.join(path, f) yaml = YamlFile.for_file(f) - for name, adventure in yaml['adventures'].items(): + for key, adventure in yaml['adventures'].items(): # the default tab sometimes contains broken code to make a point to learners about changing syntax. - if not name == 'default': + if not key == 'default': for level_number in adventure['levels']: if level_number > hedy.HEDY_MAX_LEVEL: print('content above max level!') @@ -36,77 +45,49 @@ def collect_snippets(path, filtered_language=None): level = adventure['levels'][level_number] adventure_name = adventure['name'] - code_snippet_counter = 0 - # code snippets inside story_text - for tag in utils.markdown_to_html_tags(level['story_text']): - if tag.name != 'pre' or not tag.contents[0]: - continue - # Can be used to catch more languages with example codes in the story_text - # feedback = f"Example code in story text {lang}, {adventure_name}, - # {level_number}, not recommended!" - # print(feedback) - code_snippet_counter += 1 - try: - code = tag.contents[0].contents[0] - except BaseException: - print("Code container is empty...") - continue - - snippet = Snippet( - filename=f, - level=level_number, - field_name=adventure_name + ' snippet #' + str(code_snippet_counter), - code=code, - adventure_name=adventure_name) - Hedy_snippets.append(snippet) - - # code snippets inside start_code - try: - start_code = level['start_code'] - snippet = Snippet( - filename=f, - level=level_number, - field_name='start_code', - code=start_code, - adventure_name=adventure_name) - Hedy_snippets.append(snippet) - - except KeyError: - print(f'Problem reading startcode for {lang} level {level}') - pass - # Code snippets inside example code - try: - example_code = utils.markdown_to_html_tags(level['example_code']) - for tag in example_code: - if tag.name != 'pre' or not tag.contents[0]: - continue - code_snippet_counter += 1 - try: - code = tag.contents[0].contents[0] - except BaseException: - print("Code container is empty...") - continue - - snippet = Snippet( + for adventure_part, text in level.items(): + is_markdown = adventure_part != 'start_code' + + if is_markdown: + # If we have Markdown, there can be multiple code blocks inside it + codes = [tag.contents[0].contents[0] + for tag in utils.markdown_to_html_tags(text) + if tag.name == 'pre' and tag.contents and tag.contents[0].contents] + else: + # If we don't have Markdown (this happensin the start_code field) + # the entire field is a single code block + codes = [text] + + if check_stories and adventure_part == 'story_text' and codes != []: + # Can be used to catch languages with example codes in the story_text + # at once point in time, this was the default and some languages still use this old + # structure + + feedback = f"Example code in story text {lang}, {adventure_name},\ + {level_number}, not recommended!" + raise Exception(feedback) + + for i, code in enumerate(codes): + Hedy_snippets.append(Snippet( filename=f, level=level_number, - field_name=adventure_name + ' snippet #' + str(code_snippet_counter), + field_name=adventure_part, code=code, - adventure_name=adventure_name) - Hedy_snippets.append(snippet) - except Exception as E: - print(E) + adventure_name=adventure_name, + key=key, + counter=1)) return Hedy_snippets -# filtered_language = 'fr' + +# filtered_language = 'tr' # use this to filter on 1 lang, zh_Hans for Chinese, nb_NO for Norwegian, pt_PT for Portuguese Hedy_snippets = [(s.name, s) for s in collect_snippets(path='../../content/adventures', filtered_language=filtered_language)] -# level = 5 +# level = 6 # if level: # Hedy_snippets = [(name, snippet) for (name, snippet) in Hedy_snippets if snippet.level == level] @@ -137,19 +118,34 @@ def test_adventures(self, name, snippet): except OSError: return None # programs with ask cannot be tested with output :( except exceptions.HedyException as E: - try: - location = E.error_location - except BaseException: - location = 'No Location Found' - - # Must run this in the context of the Flask app, because FlaskBabel requires that. - with app.app_context(): - with force_locale('en'): - error_message = translate_error(E.error_code, E.arguments, 'en') - error_message = error_message.replace('', '`') - error_message = error_message.replace('', '`') - print(f'\n----\n{snippet.code}\n----') - print(f'from adventure {snippet.adventure_name}') - print(f'in language {snippet.language} from level {snippet.level} gives error:') - print(f'{error_message} at line {location}') - raise E + if fix_error: + # Read English yaml file + original_yaml = YamlFile.for_file('../../content/adventures/en.yaml') + original_text_part_1 = original_yaml['adventures'][snippet.key]['levels'] + original_text = original_text_part_1[snippet.level][snippet.field_name] + + # Read broken yaml file + broken_yaml = utils.load_yaml_rt(snippet.filename) + broken_yaml['adventures'][snippet.key]['levels'][snippet.level][snippet.field_name] = \ + original_text + + with open(snippet.filename, 'w') as file: + file.write(utils.dump_yaml_rt(broken_yaml)) + + else: + try: + location = E.error_location + except BaseException: + location = 'No Location Found' + + # Must run this in the context of the Flask app, because FlaskBabel requires that. + with app.app_context(): + with force_locale('en'): + error_message = translate_error(E.error_code, E.arguments, 'en') + error_message = error_message.replace('', '`') + error_message = error_message.replace('', '`') + print(f'\n----\n{snippet.code}\n----') + print(f'from adventure {snippet.adventure_name}') + print(f'in language {snippet.language} from level {snippet.level} gives error:') + print(f'{error_message} at line {location}') + raise E diff --git a/tests/test_snippets/test_parsons.py b/tests/test_snippets/test_parsons.py index 0505695b7ed..c12bf676543 100644 --- a/tests/test_snippets/test_parsons.py +++ b/tests/test_snippets/test_parsons.py @@ -1,4 +1,6 @@ import os + +import utils from tests.Tester import HedyTester, Snippet from app import translate_error, app from flask_babel import force_locale @@ -7,6 +9,12 @@ import hedy from website.yaml_file import YamlFile +# set this to True to revert broken snippets to their en counterpart automatically +# this is useful for large Weblate PRs that need to go through, this fixes broken snippets +fix_error = False +if os.getenv('fix_for_weblate'): + fix_error = True + # Set the current directory to the root Hedy folder os.chdir(os.path.join(os.getcwd(), __file__.replace(os.path.basename(__file__), ''))) @@ -40,8 +48,11 @@ def collect_snippets(path): return Hedy_snippets -Hedy_snippets = [(s.name, s) for s in collect_snippets( - path='../../content/parsons')] +Hedy_snippets = [(s.name, s) for s in collect_snippets(path='../../content/parsons')] + +level = 1 +if level: + Hedy_snippets = [(name, snippet) for (name, snippet) in Hedy_snippets if snippet.level == level] Hedy_snippets = HedyTester.translate_keywords_in_snippets(Hedy_snippets) @@ -65,18 +76,30 @@ def test_parsons(self, name, snippet): except OSError: return None # programs with ask cannot be tested with output :( except exceptions.HedyException as E: - try: - location = E.error_location - except BaseException: - location = 'No Location Found' - - # Must run this in the context of the Flask app, because FlaskBabel requires that. - with app.app_context(): - with force_locale('en'): - error_message = translate_error(E.error_code, E.arguments, 'en') - error_message = error_message.replace('', '`') - error_message = error_message.replace('', '`') - print(f'\n----\n{snippet.code}\n----') - print(f'in language {snippet.language} from level {snippet.level} gives error:') - print(f'{error_message} at line {location}') - raise E + if fix_error: + # Read English yaml file + original_yaml = YamlFile.for_file('../../content/parsons/en.yaml') + original_text = original_yaml['levels'][snippet.level][int(snippet.field_name)] + + # Read broken yaml file + broken_yaml = utils.load_yaml_rt(snippet.filename) + broken_yaml['levels'][snippet.level][int(snippet.field_name)] = original_text + + with open(snippet.filename, 'w') as file: + file.write(utils.dump_yaml_rt(broken_yaml)) + else: + try: + location = E.error_location + except BaseException: + location = 'No Location Found' + + # Must run this in the context of the Flask app, because FlaskBabel requires that. + with app.app_context(): + with force_locale('en'): + error_message = translate_error(E.error_code, E.arguments, 'en') + error_message = error_message.replace('', '`') + error_message = error_message.replace('', '`') + print(f'\n----\n{snippet.code}\n----') + print(f'in language {snippet.language} from level {snippet.level} gives error:') + print(f'{error_message} at line {location}') + raise E