Skip to content

Commit

Permalink
💻 add roles of variables: stepper in for loops (hedyorg#5538)
Browse files Browse the repository at this point in the history
I've added the stepper role, it works with for loops, but other kinds of steppers are not working yet. 

Also started using labels so that the variable role names can be translated into the different languages (added the English myself, with container now called list and input instead of input constant).

**How to test**

Follow these steps to verify this PR works as intended:

* change the feature flag showRoles in debugging.ts to true
* go to Hedy level 11 and run this program (or something similar) in the debugger:
```
for counter in range 1 to 10
    print counter
print 'Ready or not. Here I come!'
```
* check that in the variables view, the role that is shown for the variable counter is stepper. 

**Checklist**
Done? Check if you have it all in place using this list: (mark with x if done)

- [ x] Contains one of the PR categories in the name
- [ x] Describes changes in the format above
- [ ] Links to an existing issue or discussion
- [ x] Has a "How to test" section

If you're unsure about any of these, don't hesitate to ask. We're here to help!
  • Loading branch information
juliabolt authored Jun 4, 2024
1 parent 1bdb046 commit 0e2929b
Show file tree
Hide file tree
Showing 56 changed files with 1,315 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3569,16 +3569,18 @@ def determine_roles(lookup, input_string, level, lang):
assignments = [x for x in lookup if x.name == var]

if (assignments[0].tree.data == 'for_list'):
roles_dictionary[var] = 'walker'
roles_dictionary[var] = gettext('walker_variable_role')
elif (assignments[0].tree.data == 'for_loop'):
roles_dictionary[var] = gettext('stepper_variable_role')
elif (assignments[0].type_ == 'list'):
roles_dictionary[var] = 'container'
roles_dictionary[var] = gettext('list_variable_role')
elif (len(assignments) == 1):
if (assignments[0].type_ == 'input'):
roles_dictionary[var] = 'input constant'
roles_dictionary[var] = gettext('input_variable_role')
else:
roles_dictionary[var] = 'constant'
roles_dictionary[var] = gettext('constant_variable_role')
else:
roles_dictionary[var] = 'unknown'
roles_dictionary[var] = gettext('unknown_variable_role')

return roles_dictionary

Expand Down
18 changes: 18 additions & 0 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ msgstr ""
msgid "connect_guest_teacher"
msgstr ""

msgid "constant_variable_role"
msgstr ""

msgid "content_invalid"
msgstr ""

Expand Down Expand Up @@ -815,6 +818,9 @@ msgstr ""
msgid "input"
msgstr ""

msgid "input_variable_role"
msgstr ""

msgid "integer"
msgstr ""

Expand Down Expand Up @@ -938,6 +944,9 @@ msgstr ""
msgid "list"
msgstr ""

msgid "list_variable_role"
msgstr ""

msgid "live_dashboard"
msgstr ""

Expand Down Expand Up @@ -1592,6 +1601,9 @@ msgstr ""
msgid "step_title"
msgstr ""

msgid "stepper_variable_role"
msgstr ""

msgid "stop_code_button"
msgstr ""

Expand Down Expand Up @@ -1829,6 +1841,9 @@ msgstr ""
msgid "unique_usernames"
msgstr ""

msgid "unknown_variable_role"
msgstr ""

msgid "unlock_thresholds"
msgstr ""

Expand Down Expand Up @@ -1904,6 +1919,9 @@ msgstr ""
msgid "view_slides"
msgstr ""

msgid "walker_variable_role"
msgstr ""

msgid "welcome"
msgstr ""

Expand Down
24 changes: 24 additions & 0 deletions translations/ar/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ msgstr "Congratulations, {username}, you have completed Hedy!"
msgid "connect_guest_teacher"
msgstr "I would like to be connected with a guest teacher who can give a few lessons"

msgid "constant_variable_role"
msgstr ""

msgid "content_invalid"
msgstr "هذه المغامرة غير صالحة"

Expand Down Expand Up @@ -946,6 +949,9 @@ msgstr "Incorrect Indentation"
msgid "input"
msgstr "اجابة باستخدام اسأل"

msgid "input_variable_role"
msgstr ""

msgid "integer"
msgstr "رقم"

Expand Down Expand Up @@ -1086,6 +1092,9 @@ msgstr "الرابط"
msgid "list"
msgstr "قائمة"

msgid "list_variable_role"
msgstr ""

#, fuzzy
msgid "live_dashboard"
msgstr "Live Dashboard"
Expand Down Expand Up @@ -1827,6 +1836,9 @@ msgstr "Start teaching"
msgid "step_title"
msgstr "المهمة"

msgid "stepper_variable_role"
msgstr ""

msgid "stop_code_button"
msgstr "ايقاف البرنامج"

Expand Down Expand Up @@ -2106,6 +2118,9 @@ msgstr "Your program is unfavourited."
msgid "unique_usernames"
msgstr "يجب أن تكون جميع أسماء المستخدمين لا نظير لها."

msgid "unknown_variable_role"
msgstr ""

#, fuzzy
msgid "unlock_thresholds"
msgstr "Unlock level thresholds"
Expand Down Expand Up @@ -2195,6 +2210,9 @@ msgstr "عرض البرنامج"
msgid "view_slides"
msgstr "View slides"

msgid "walker_variable_role"
msgstr ""

msgid "welcome"
msgstr "مرحباً"

Expand Down Expand Up @@ -2409,3 +2427,9 @@ msgstr "Your program"
#~ msgid "update_profile"
#~ msgstr "تحديث الملف الشخصي"

#~ msgid "container_variable_role"
#~ msgstr ""

#~ msgid "input_constant_variable_role"
#~ msgstr ""

24 changes: 24 additions & 0 deletions translations/bg/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ msgstr "Congratulations, {username}, you have completed Hedy!"
msgid "connect_guest_teacher"
msgstr "I would like to be connected with a guest teacher who can give a few lessons"

msgid "constant_variable_role"
msgstr ""

#, fuzzy
msgid "content_invalid"
msgstr "This adventure is invalid."
Expand Down Expand Up @@ -1048,6 +1051,9 @@ msgstr "Incorrect Indentation"
msgid "input"
msgstr "input from `{ask}`"

msgid "input_variable_role"
msgstr ""

#, fuzzy
msgid "integer"
msgstr "a number"
Expand Down Expand Up @@ -1208,6 +1214,9 @@ msgstr "Вход"
msgid "list"
msgstr "a list"

msgid "list_variable_role"
msgstr ""

#, fuzzy
msgid "live_dashboard"
msgstr "Live Dashboard"
Expand Down Expand Up @@ -2046,6 +2055,9 @@ msgstr "Start teaching"
msgid "step_title"
msgstr "Задача"

msgid "stepper_variable_role"
msgstr ""

#, fuzzy
msgid "stop_code_button"
msgstr "Save code"
Expand Down Expand Up @@ -2356,6 +2368,9 @@ msgstr "Your program is unfavourited."
msgid "unique_usernames"
msgstr "All usernames need to be unique."

msgid "unknown_variable_role"
msgstr ""

#, fuzzy
msgid "unlock_thresholds"
msgstr "Unlock level thresholds"
Expand Down Expand Up @@ -2453,6 +2468,9 @@ msgstr "View program"
msgid "view_slides"
msgstr "View slides"

msgid "walker_variable_role"
msgstr ""

#, fuzzy
msgid "welcome"
msgstr "Welcome to Hedy! Your are now the proud owner of a teachers account which allows you to create classes and invite students."
Expand Down Expand Up @@ -2683,3 +2701,9 @@ msgstr "Your program"
#~ msgid "variables"
#~ msgstr "Variables"

#~ msgid "container_variable_role"
#~ msgstr ""

#~ msgid "input_constant_variable_role"
#~ msgstr ""

24 changes: 24 additions & 0 deletions translations/bn/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ msgstr "Congratulations, {username}, you have completed Hedy!"
msgid "connect_guest_teacher"
msgstr "I would like to be connected with a guest teacher who can give a few lessons"

msgid "constant_variable_role"
msgstr ""

#, fuzzy
msgid "content_invalid"
msgstr "This adventure is invalid."
Expand Down Expand Up @@ -1081,6 +1084,9 @@ msgstr "Incorrect Indentation"
msgid "input"
msgstr "input from `{ask}`"

msgid "input_variable_role"
msgstr ""

#, fuzzy
msgid "integer"
msgstr "a number"
Expand Down Expand Up @@ -1245,6 +1251,9 @@ msgstr "Log in"
msgid "list"
msgstr "a list"

msgid "list_variable_role"
msgstr ""

#, fuzzy
msgid "live_dashboard"
msgstr "Live Dashboard"
Expand Down Expand Up @@ -2125,6 +2134,9 @@ msgstr "Start teaching"
msgid "step_title"
msgstr "Assignment"

msgid "stepper_variable_role"
msgstr ""

#, fuzzy
msgid "stop_code_button"
msgstr "Save code"
Expand Down Expand Up @@ -2451,6 +2463,9 @@ msgstr "Your program is unfavourited।"
msgid "unique_usernames"
msgstr "All usernames need to be unique."

msgid "unknown_variable_role"
msgstr ""

#, fuzzy
msgid "unlock_thresholds"
msgstr "Unlock level thresholds"
Expand Down Expand Up @@ -2551,6 +2566,9 @@ msgstr "View program"
msgid "view_slides"
msgstr "View slides"

msgid "walker_variable_role"
msgstr ""

#, fuzzy
msgid "welcome"
msgstr "Welcome to Hedy! Your are now the proud owner of a teachers account which allows you to create classes and invite students."
Expand Down Expand Up @@ -2782,3 +2800,9 @@ msgstr "Your program"
#~ msgid "variables"
#~ msgstr "Variables"

#~ msgid "container_variable_role"
#~ msgstr ""

#~ msgid "input_constant_variable_role"
#~ msgstr ""

24 changes: 24 additions & 0 deletions translations/ca/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ msgstr "Felicitats, {username}, has completat Hedy!"
msgid "connect_guest_teacher"
msgstr "I would like to be connected with a guest teacher who can give a few lessons"

msgid "constant_variable_role"
msgstr ""

msgid "content_invalid"
msgstr "Aquesta aventura no és vàlida."

Expand Down Expand Up @@ -876,6 +879,9 @@ msgstr "Incorrect Indentation"
msgid "input"
msgstr "input from `{ask}`"

msgid "input_variable_role"
msgstr ""

#, fuzzy
msgid "integer"
msgstr "a number"
Expand Down Expand Up @@ -1034,6 +1040,9 @@ msgstr "Link"
msgid "list"
msgstr "a list"

msgid "list_variable_role"
msgstr ""

#, fuzzy
msgid "live_dashboard"
msgstr "Live Dashboard"
Expand Down Expand Up @@ -1881,6 +1890,9 @@ msgstr "Start teaching"
msgid "step_title"
msgstr "Tasca"

msgid "stepper_variable_role"
msgstr ""

msgid "stop_code_button"
msgstr "Para el programa"

Expand Down Expand Up @@ -2147,6 +2159,9 @@ msgstr "Your program is unfavourited."
msgid "unique_usernames"
msgstr "Tots els noms d'usuari han de ser únics."

msgid "unknown_variable_role"
msgstr ""

msgid "unlock_thresholds"
msgstr "Desbloqueja els llindars de nivell"

Expand Down Expand Up @@ -2229,6 +2244,9 @@ msgstr "Veure el programa"
msgid "view_slides"
msgstr "View slides"

msgid "walker_variable_role"
msgstr ""

msgid "welcome"
msgstr "Benvinguda"

Expand Down Expand Up @@ -2424,3 +2442,9 @@ msgstr "El teu programa"
#~ msgid "variables"
#~ msgstr "Variables"

#~ msgid "container_variable_role"
#~ msgstr ""

#~ msgid "input_constant_variable_role"
#~ msgstr ""

Loading

0 comments on commit 0e2929b

Please sign in to comment.