Skip to content

Commit

Permalink
Merge branch 'main' into Answers-to-exercises-in-teacher-manual
Browse files Browse the repository at this point in the history
  • Loading branch information
Felienne authored Sep 11, 2023
2 parents 68d5881 + 8721fa7 commit dc2e879
Show file tree
Hide file tree
Showing 281 changed files with 15,038 additions and 5,972 deletions.
10 changes: 5 additions & 5 deletions PULL_REQUEST_TEMPLATE.md → .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ _Changes in detail. For example: "**Adds** translations of levels 1 to 12 to Pol
**Fixes _issue or discussion number_**

Always link the number of the issue or of the discussion that your PR concerns.
Tip, if you use the word `fixes` before the issue number in this description, the related issue will automatically close then the PR is merged!
Tip, if you use the word `fixes` before the issue number in this description, the related issue will automatically close then the PR is merged!

**How to test**

* If this is a UI change: _describe how to run your code to see it in action. See this https://github.com/Felienne/hedy/pull/880#issue-1016304308 for an example_
* If this is a UI change: _describe how to run your code to see it in action. See this https://github.com/hedyorg/hedy/pull/880#issue-1016304308 for an example_
* If this is a language change: _add a few tests showing the difference_

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

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

If you're unsure about any of these, don't hesitate to ask. We're here to help!
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
File renamed without changes.
File renamed without changes.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@ Hedy is a gradual programming language aimed at teaching programming and teachin

The latest version of Hedy can be found at [hedy.org](https://hedy.org).

# Repo stats

![](https://img.shields.io/github/commit-activity/m/hedyorg/hedy)
![](https://img.shields.io/github/last-commit/hedyorg/hedy)
![](https://img.shields.io/github/stars/hedyorg/hedy)
![](https://img.shields.io/github/contributors/hedyorg/hedy)
![](https://img.shields.io/github/issues/hedyorg/hedy)

![Repo Beats statistics](https://repobeats.axiom.co/api/embed/a3206e7c42293ee71446a7081b9c98636953501c.svg "Repobeats analytics image")


What's next?
------------

If you want to see what the core team will work on next, you can follow [our Project](https://github.com/Felienne/hedy/projects/5), the [Discussions](https://github.com/Felienne/hedy/discussions) or join our [Discord](https://discord.gg/8yY7dEme9r) channel.
If you want to see what the core team will work on next, you can follow [our Project Board](https://github.com/orgs/hedyorg/projects/1/views/5), the [Discussions](https://github.com/hedyorg/hedy/discussions) or join our [Discord](https://discord.gg/8yY7dEme9r) channel.

Živjo Hedy! Привет Hedy! !Hedy سلام
----------------------------------------------

A simple way to help out Hedy is to [help us translate Hedy](TRANSLATING.md) using Weblate! You do not need programming experience or knowledge to translate Hedy. Below the current status, help us complete a language, or add a new one.
A simple way to help out Hedy is to [help us translate Hedy](docs/TRANSLATING.md) using Weblate! You do not need programming experience or knowledge to translate Hedy. Below the current status, help us complete a language, or add a new one.

<a href="https://hosted.weblate.org/engage/hedy/">
<img src="https://hosted.weblate.org/widgets/hedy/-/multi-auto.svg" alt="Translation status" />
Expand All @@ -26,12 +37,12 @@ I have an idea for what you should build or improve!

Great! We have multiple ways of monitoring ideas.

If it is a small fix, it is best to [make an issue](https://github.com/Felienne/hedy/issues/new/choose). Issues are meant for things we know that we want to work on, such as:
If it is a small fix, it is best to [make an issue](https://github.com/hedyorg/hedy/issues/new/choose). Issues are meant for things we know that we want to work on, such as:

* Error messages that need to be improved
* Crashes or bugs

If it is a new idea, [start a discussion](https://github.com/Felienne/hedy/discussions/categories/ideas). Discussions are a place to chat about stuff we do not know if we want to work on yet, or we are not sure how to do, such as:
If it is a new idea, [start a discussion](https://github.com/hedyorg/hedy/discussions/categories/ideas). Discussions are a place to chat about stuff we do not know if we want to work on yet, or we are not sure how to do, such as:

* New keywords
* New meanings for existing keywords
Expand All @@ -42,6 +53,6 @@ Please note that we want to be a friendly and welcoming open source project. If
Want to help improve Hedy?
--------------------------

We would love to have a few more programmers join the Hedy team as regular contributors! See how you can get started with contributing in our docs: [CONTRIBUTING.md](CONTRIBUTING.md).
We would love to have a few more programmers join the Hedy team as regular contributors! See how you can get started with contributing in our docs: [CONTRIBUTING.md](docs/CONTRIBUTING.md).

You can follow the [Discussions](https://github.com/Felienne/hedy/discussions) to stay up to date on things we are working on and considering. Full documentation including our design and design principles can be found [DESIGN.md](DESIGN.md)
You can follow the [Project Board](https://github.com/orgs/hedyorg/projects/1/views/5) to see what we are currently working on, and [Discussions](https://github.com/hedyorg/hedy/discussions) to stay up to date on things we are considering. Full documentation including our design and design principles can be found [DESIGN.md](docs/DESIGN.md).
Binary file modified all_snippet_hashes.pkl
Binary file not shown.
58 changes: 33 additions & 25 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def setup_language():
session['lang'] = request.accept_languages.best_match(
ALL_LANGUAGES.keys(), 'en')
g.lang = session['lang']
querylog.log_value(lang=session['lang'])

if 'keyword_lang' not in session:
session['keyword_lang'] = g.lang if g.lang in ALL_KEYWORD_LANGUAGES.keys() else 'en'
Expand Down Expand Up @@ -475,18 +476,19 @@ def parse():
return "body.code must be a string", 400
if 'level' not in body:
return "body.level must be a string", 400
if 'skip_faulty' not in body:
return "body.skip_faulty must be a boolean", 400
if 'adventure_name' in body and not isinstance(body['adventure_name'], str):
return "if present, body.adventure_name must be a string", 400
# TODO: Once we figure out whats wrong with the skip faulty code, we need to reinstantiate this
# if 'skip_faulty' not in body:
# return "body.skip_faulty must be a boolean", 400

error_check = False
if 'error_check' in body:
error_check = True

code = body['code']
level = int(body['level'])
skip_faulty = bool(body['skip_faulty'])
skip_faulty = False # bool(body['skip_faulty'])

# Language should come principally from the request body,
# but we'll fall back to browser default if it's missing for whatever
Expand Down Expand Up @@ -527,18 +529,18 @@ def parse():

try:
response['Code'] = transpile_result.code
source_map_result = transpile_result.source_map.get_result()

for i, mapping in source_map_result.items():
if mapping['error'] is not None:
source_map_result[i]['error'] = translate_error(
source_map_result[i]['error'].error_code,
source_map_result[i]['error'].arguments,
keyword_lang
)

response['source_map'] = source_map_result

# source_map_result = transpile_result.source_map.get_result()

# for i, mapping in source_map_result.items():
# if mapping['error'] is not None:
# source_map_result[i]['error'] = translate_error(
# source_map_result[i]['error'].error_code,
# source_map_result[i]['error'].arguments,
# keyword_lang
# )

# response['source_map'] = source_map_result
response['source_map'] = transpile_result.source_map.get_result()
if transpile_result.has_pygame:
response['has_pygame'] = True

Expand Down Expand Up @@ -1662,20 +1664,20 @@ def explore():
achievement = ACHIEVEMENTS.add_single_achievement(
current_user()['username'], "indiana_jones")

programs = normalize_explore_programs(DATABASE.get_public_programs(
programs = normalize_public_programs(DATABASE.get_public_programs(
limit=40,
level_filter=level,
language_filter=language,
adventure_filter=adventure))
favourite_programs = normalize_explore_programs(DATABASE.get_hedy_choices())
favourite_programs = normalize_public_programs(DATABASE.get_hedy_choices())

adventures_names = hedy_content.Adventures(session['lang']).get_adventure_names()

return render_template(
'explore.html',
programs=programs,
favourite_programs=favourite_programs,
filtered_level=str(level),
filtered_level=str(level) if level else None,
achievement=achievement,
filtered_adventure=adventure,
filtered_lang=language,
Expand All @@ -1685,8 +1687,8 @@ def explore():
current_page='explore')


def normalize_explore_programs(programs):
"""Normalize the content for all programs in the given array, for showing on the /explore page.
def normalize_public_programs(programs):
"""Normalize the content for all programs in the given array, for showing on the /explore or /user page.
Does the following thing:
Expand Down Expand Up @@ -2113,23 +2115,28 @@ def public_user_page(username):
if not user:
return utils.error_page(error=404, ui_message=gettext('user_not_private'))
user_public_info = DATABASE.get_public_profile_settings(username)
page = request.args.get('page', default=None, type=str)
if user_public_info:
user_programs = DATABASE.public_programs_for_user(username)
user_programs = DATABASE.public_programs_for_user(username,
limit=10,
pagination_token=page)
next_page_token = user_programs.next_page_token
user_programs = normalize_public_programs(user_programs)
user_achievements = DATABASE.progress_by_username(username) or {}

favourite_program = None
if 'favourite_program' in user_public_info and user_public_info['favourite_program']:
favourite_program = DATABASE.program_by_id(
user_public_info['favourite_program'])
if len(user_programs) >= 5:
user_programs = user_programs[:5]

last_achieved = None
if user_achievements.get('achieved'):
last_achieved = user_achievements['achieved'][-1]
certificate_message = safe_format(gettext('see_certificate'), username=username)
print(user_programs)
# Todo: TB -> In the near future: add achievement for user visiting their own profile

next_page_url = url_for('public_user_page', username=username, **dict(request.args,
page=next_page_token)) if next_page_token else None
return render_template(
'public-page.html',
user_info=user_public_info,
Expand All @@ -2139,7 +2146,8 @@ def public_user_page(username):
programs=user_programs,
last_achieved=last_achieved,
user_achievements=user_achievements,
certificate_message=certificate_message)
certificate_message=certificate_message,
next_page_url=next_page_url)
return utils.error_page(error=404, ui_message=gettext('user_not_private'))


Expand Down
21 changes: 20 additions & 1 deletion build-tools/heroku/tailwind/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ strong {
}


.green-btn:hover:enabled {
.green-btn:hover:enabled,
a.green-btn:hover {
@apply bg-green-400 border-green-500;
@apply active:bg-green-700 active:border-green-700;
}

.red-btn {
Expand All @@ -173,6 +175,7 @@ strong {

.red-btn:hover {
@apply bg-red-400 border-red-500;
@apply active:bg-red-700 active:border-red-700;
}

.yellow-btn {
Expand All @@ -182,6 +185,7 @@ strong {

.yellow-btn:hover {
@apply bg-yellow-400 border-yellow-500;
@apply active:bg-yellow-700 active:border-yellow-700;
}

.pink-btn {
Expand All @@ -191,6 +195,7 @@ strong {

.pink-btn:hover {
@apply bg-pink-300 border-pink-400;
@apply active:bg-pink-700 active:border-pink-500;
}

.blue-btn {
Expand All @@ -205,6 +210,7 @@ strong {

.blue-btn:hover {
@apply bg-blue-400 border-blue-500;
@apply active:bg-blue-700 active:border-blue-700;
}

/* Styles only for use in MarkDown blocks */
Expand Down Expand Up @@ -294,6 +300,7 @@ code {

.btn:hover {
@apply bg-blue-400 border-blue-500;
@apply active:bg-blue-700 active:border-blue-700
}

.menubar-item {
Expand Down Expand Up @@ -817,3 +824,15 @@ div[class^="ace_incorrect_hedy_code"] {
cursor: pointer !important;
pointer-events: auto;
}

.student_adventure_checkbox[disabled] {
@apply relative bg-gray-200 rounded border-gray-500 !important
}

.student_adventure_checkbox {
@apply relative bg-white rounded border-gray-500 !important
}

.student_adventure_checkbox:checked {
@apply relative bg-green-300 rounded border-gray-500 !important
}
Loading

0 comments on commit dc2e879

Please sign in to comment.