Skip to content

Commit

Permalink
Fix loading of individual adventures.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Apr 30, 2021
1 parent fece801 commit 775628a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def adventure_page(adventure_name, level):
return redirect(request.url.replace ('/' + adventure_name, '/' + adventure_name + '/' + str (desired_level)), code=302)
# If user is not logged in, or has no saved programs for this adventure, default to the lowest level available for the adventure
if desired_level == 0:
for key in adventure.keys ():
for key in adventure ['levels'].keys ():
if type_check (key, 'int') and (desired_level == 0 or desired_level > key):
desired_level = key
level = desired_level
Expand All @@ -361,7 +361,7 @@ def adventure_page(adventure_name, level):
loaded_program = program ['code']

# If requested level is not in adventure, return 404
if not level in adventure:
if not level in adventure ['levels']:
abort(404)

return hedyweb.render_adventure(
Expand Down
6 changes: 3 additions & 3 deletions hedyweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def render_adventure(adventure_name, adventure, course, request, lang, level_num
arguments_dict['lang'] = lang
arguments_dict['level_nr'] = str(level_number)
arguments_dict['level'] = level_number
arguments_dict['prev_level'] = level_number - 1 if level_number - 1 in adventure else None
arguments_dict['next_level'] = level_number + 1 if level_number + 1 in adventure else None
arguments_dict['prev_level'] = level_number - 1 if level_number - 1 in adventure ['levels'] else None
arguments_dict['next_level'] = level_number + 1 if level_number + 1 in adventure ['levels'] else None
arguments_dict['menu'] = menu
arguments_dict['latest'] = version
arguments_dict['selected_page'] = 'code'
Expand All @@ -85,7 +85,7 @@ def render_adventure(adventure_name, adventure, course, request, lang, level_num
arguments_dict.update(**translations.get_translations(lang, 'ui'))

# Actual assignment
for key, value in adventure [level_number].items ():
for key, value in adventure ['levels'] [level_number].items ():
arguments_dict [key] = value

if not 'story_text' in arguments_dict:
Expand Down

0 comments on commit 775628a

Please sign in to comment.