Skip to content

Commit

Permalink
Merge branch 'main' into subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Oct 28, 2024
2 parents a61ee44 + 137ff83 commit fbe5339
Show file tree
Hide file tree
Showing 282 changed files with 46,108 additions and 6,158 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/deploy-to-alpha-manually.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Manually deploy to Alpha
on:
workflow_dispatch: {}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: hedy-alpha
heroku_email: [email protected]
1 change: 1 addition & 0 deletions .github/workflows/deploy-to-alpha.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Automatically deploy to Alpha
on:

# Run this AFTER the unit test job finishes
workflow_run:
# Must be the same as in unittests.yml, cypresstests.yml
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deploy-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ jobs:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: hedy-beta
heroku_email: [email protected]
- name: "Send message on Discord"
if: success()
uses: discord-actions/message@v2
with:
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
message: "Deployed to hedy.org"
7 changes: 6 additions & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ queue_rules:
commit_message_template: |-
{{ title }} (#{{number}})
{{ body }}
{# Add co-author information at the end of the squash merge commit message #}
{% for co_author in co_authors | unique -%}
Co-Authored-By: {{ co_author.name }} <{{ co_author.email }}>
{% endfor -%}
{# `Co-Authored-By` lines must the be last ones for GitHub to recognize them #}
pull_request_rules:
- name: Automatic squash merge on approval
Expand All @@ -21,4 +26,4 @@ pull_request_rules:
comment:
message: Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to [allow changes to be pushed to your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)).
queue:
name: default_queue
name: default_queue
45 changes: 41 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1940,12 +1940,15 @@ def view_program(user, id, language="en"):
result['username']) else None

code = result['code']
if result.get("lang") != "en" and result.get("lang") in ALL_KEYWORD_LANGUAGES.keys():
# if the snippet has blanks, it'll fail in the translation process
# so we just dont translate it if it has any
has_blanks = hedy.location_of_first_blank(code) > 0
if not has_blanks and result.get("lang") != "en" and result.get("lang") in ALL_KEYWORD_LANGUAGES.keys():
code = hedy_translation.translate_keywords(code, from_lang=result.get(
'lang'), to_lang="en", level=int(result.get('level', 1)))
# If the keyword language is non-English -> parse again to guarantee
# completely localized keywords
if g.keyword_lang != "en":
if not has_blanks and g.keyword_lang != "en":
code = hedy_translation.translate_keywords(
code,
from_lang="en",
Expand Down Expand Up @@ -1977,9 +1980,40 @@ def view_program(user, id, language="en"):
arguments_dict['program_timestamp'] = utils.localized_date_format(result['date'])
else:
arguments_dict['show_edit_button'] = True

arguments_dict['show_checkbox'] = is_teacher(user)\
is_students_teacher = is_teacher(user)\
and result['username'] in DATABASE.get_teacher_students(user['username'])
arguments_dict['is_students_teacher'] = is_students_teacher

classes = DATABASE.get_student_classes_ids(result['username'])
next_classmate_adventure_id = None
if classes:
class_id = classes[0]
class_ = DATABASE.get_class(class_id) or {}
students = sorted(class_.get('students', []))
index = students.index(result['username'])
for student in students[index + 1:]:
id = f"{student}-{result['adventure_name']}-{result['level']}"
next_classmate_adventure = DATABASE.student_adventure_by_id(id) or {}
next_classmate_adventure_id = next_classmate_adventure.get('program_id')
if next_classmate_adventure_id:
break

student_customizations = DATABASE.get_student_class_customizations(result['username'])
adventure_index = 0
adventures_for_this_level = student_customizations.get('sorted_adventures', {}).get(str(result['level']), [])
for index, adventure in enumerate(adventures_for_this_level):
if adventure['name'] == result['adventure_name']:
adventure_index = index
break

next_program_id = None
for i in range(adventure_index + 1, len(adventures_for_this_level)):
next_adventure = adventures_for_this_level[i]
next_adventure_id = f"{result['username']}-{next_adventure['name']}-{result['level']}"
next_student_adventure = DATABASE.student_adventure_by_id(next_adventure_id) or {}
next_program_id = next_student_adventure.get('program_id')
if next_program_id:
break

return render_template("view-program-page.html",
blur_button_available=True,
Expand All @@ -1989,6 +2023,9 @@ def view_program(user, id, language="en"):
level=int(result['level']),
code=code),
is_teacher=user['is_teacher'],
class_id=student_customizations['id'],
next_program_id=next_program_id,
next_classmate_program_id=next_classmate_adventure_id,
**arguments_dict)


Expand Down
103 changes: 56 additions & 47 deletions content/adventures/ca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ adventures:
```
clear_command:
name: '{clear}'
default_save_name: clear_command
default_save_name: comanda_netejar
description: comanda {clear}
levels:
4:
Expand Down Expand Up @@ -1711,26 +1711,26 @@ adventures:
Check it out!
example_code: |
```
prices = ['1 million dollars', 'an apple pie', 'nothing']
your_price = prices[{random}]
{print} 'You win ' your_price
{if} your_price == '1 million dollars' :
prizes = ['1 million dollars', 'an apple pie', 'nothing']
your_prize = prizes[{random}]
{print} 'You win ' your_prize
{if} your_prize == '1 million dollars' :
{print} 'Yeah! You are rich!'
{elif} your_price == 'an apple pie' :
{elif} your_prize == 'an apple pie' :
{print} 'Lovely, an apple pie!'
{else}:
{print} 'Better luck next time..'
```
for_command:
name: '{for}'
default_save_name: for
description: for command
default_save_name: per
description: comanda {for}
levels:
10:
story_text: |-
## For
In this level we learn a new code called `{for}`. With `{for}` you can make a list and use all elements.
`{for}` creates a block, like `{repeat}` and `{if}` so all lines in the block need to start with 4 spaces.
## Per
En aquest nivell aprendrem una nova comanda anomenada `{for}`. Amb `{for}` pots fer una llista i utilitzar-ne tots els elements.
`{for}` crea un bloc, com `{repeat}` i `{if}`, de manera que totes les línies del bloc han de començar amb 4 espais.
example_code: |
```
animals = dog, cat, blobfish
Expand Down Expand Up @@ -1780,9 +1780,9 @@ adventures:
{print} (i)
```
fortune:
name: Fortune teller
default_save_name: Fortune Teller
description: Let Hedy predict the future
name: L'endeví
default_save_name: L'endeví
description: Deixa que Hedy predigui el futur
levels:
1:
story_text: |
Expand All @@ -1794,17 +1794,16 @@ adventures:
Like this:
example_code: |
```
{print} Hello, I'm Hedy the fortune teller!
{ask} Who are you?
{print} Let me take a look in my crystal ball
{print} I see... I see...
{echo} Your name is
_ Hola, soc Hedy l'endevina
_ Qui ets tu?
_ Deixa'm donar una ullada a la meva bola de cristall
_ Veig... Veig...
_ El teu nom és
```
story_text_2: |
### Exercise
Hedy now only tells you your name. Can you expand the code so that Hedy can predict more things about you?
Obviously, Hedy isn't a very good fortune teller yet, as she can only repeat the answers that were given by the players!
Take a look in level 2 to improve your fortune teller.
### Exercici
Copia el codi d'exemple a la teva pantalla d'entrada i omple els espais en blanc per fer funcionar el teu codi.
**Extra** Canvia el codi i deixa que l'endevina no només predigui el teu nom, sinó també la teva edat, el teu esport preferit o alguna altra cosa sobre tu mateix.
3:
story_text: |
In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only {echo}.
Expand All @@ -1831,26 +1830,37 @@ adventures:
Go back to the previous level and copy your fortune teller code. Make the code work in this level by adding quotation marks in the right spots.
example_code: |
```
_ Add the quotation marks to this code _
{print} Im Hedy the fortune teller!
question {is} {ask} What do you want to know?
{print} This is your question: question
answers {is} yes, no, maybe
{print} My crystal ball says...
_ Agrega les cometes a aquest codi _
{print} Sóc Hedy l'endevina!
pregunta {is} {ask} Què vols saber?
{print} Aquesta és la teva pregunta: · · pregunta
resposta {is} si, no, potser
{print} La meva bola de cristall diu...
{sleep} 2
{print} answers {at} {random}
{print} resposta {at} {random}
```
5:
story_text: |
In this level you'll learn to (secretly) tip the odds in your favor, when using the fortune teller!
By using `{if}` and `{else}` you can make sure that you will always get a good fotune, while other people might not.
Check out this example to find out how.
### Exercici
En aquest codi d'exemple veuràs com fer un programa endeví que et permeti inclinar les possibilitats a favor teu. Aquest programa que fa trames sempre et diu que guanyaràs la loteria, però els teus amics mai guanyaran.
Usa això per fer el teu propi programa, sigues creatiu! Per exemple, pots crear un codi que predigui que:
* el teu equip esportiu preferit guanyarà a tots els seus contrincants!
* s'elegirà la teva pel·lícula preferida com a pel·lícula de la nit!
* guanyaràs entrades pel teu espectacle preferit!
* ets el més bonic/a de tots/es, com el mirall màgic de la Blancaneu.
Deixa que la teva imaginació faci el treball!
El teu programa ha de tenir almenys 10 línies de codi i ha de contenir com a mínim una comanda '{if}' i '{else}'.
example_code: |
```
{print} 'Im Hedy the fortune teller!'
{print} 'I can predict if youll win the lottery tomorrow!'
friends {is} Jordan, Lucy, Dave
{print} 'I can predict if you will win the lottery tomorrow!'
person {is} {ask} 'Who are you?'
{if} person {is} Hedy {print} 'You will definitely win!🤩' {else} {print} 'Bad luck! Someone else will win!😭'
good_answer {is} Hurray! You win!, You will definitely win!, We have a winner!
bad_answer {is} Bad luck! Try again!, Another person will win, You lose!
{if} person {in} friends {print} good_answer {at} {random}
{else} {print} bad_answer {at} {random}
```
6:
story_text: |
Expand Down Expand Up @@ -1888,23 +1898,22 @@ adventures:
```
7:
story_text: |
In this level you can use the `{repeat}` command to make your machine tell multiple fortunes at once.
### Exercici
Finalitza aquest programa que et diu si el teu enamorat t'estima o no.
example_code: |
```
{print} 'Im Hedy the fortune teller!'
{print} 'You can ask 3 questions!'
{repeat} 3 {times} question = {ask} 'What do you want to know?'
answer = yes, no, maybe
{repeat} 3 {times} {print} 'My crystal ball says... ' answer {at} {random}
{print} 'Tinc una flor amb pètals màgics'
{print} "Si agafes els pètals de la flor, et dirà si el teu amor també t'estima"
quantitat = {ask} 'Quants pètals vols agafar?'
options = t'estima, no t'estima
_ _ _ _ options {at} {random}
```
8:
story_text: |
In the previous levels you've learned how to use `{repeat}` to make the fortune teller answer 3 questions in a row, but we had a problem with printing the questions.
Now that problem is solved, because of the new way of using the `{repeat}` command.
In the next example you can have your fortune teller ask 3 questions and also print them!
En el pròxim exemple pots fre que l'endeví et faci diverses preguntes i també que les imprimeixi!
### Exercise
Can you fill in the `{repeat}` command correctly on the blanks?
### Exercici
Pots posar les comandes correctes als forats en blanc?
example_code: |
```
{print} 'I am Hedy the fortune teller!'
Expand Down
Loading

0 comments on commit fbe5339

Please sign in to comment.