Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Send adventure_name, if any, to server for program logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Apr 30, 2021
1 parent 775628a commit 5db3283
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def load_adventure_for_language(lang):
def load_adventure_assignments_per_level(lang, level):
assignments = []
adventures = load_adventure_for_language(lang)['adventures']
for adventure in adventures.values():
for short_name, adventure in adventures.items ():
if level in adventure['levels']:
assignments.append({
'short_name': short_name,
'name': adventure['name'],
'image': adventure.get('image', None),
'text': adventure['levels'][level].get('story_text', 'No Story Text')
Expand Down Expand Up @@ -185,6 +186,8 @@ def parse():
return "body.code must be a string", 400
if 'level' not in body:
return "body.level must be a string", 400
if 'adventure_name' in body and not type_check (body ['adventure_name'], 'str'):
return "if present, body.adventure_name must be a string", 400

code = body ['code']
level = int(body ['level'])
Expand Down Expand Up @@ -230,7 +233,6 @@ def parse():
except Exception as E:
print(f"error transpiling {code}")
response["Error"] = str(E)

logger.log ({
'session': session_id(),
'date': str(datetime.datetime.now()),
Expand All @@ -240,7 +242,8 @@ def parse():
'server_error': response.get('Error'),
'version': version(),
'username': username,
'is_test': 1 if os.getenv ('IS_TEST_ENV') else None
'is_test': 1 if os.getenv ('IS_TEST_ENV') else None,
'adventure_name': body.get('adventure_name', None)
})

return jsonify(response)
Expand Down
3 changes: 2 additions & 1 deletion static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function runit(level, lang, cb) {
data: JSON.stringify({
level: level,
code: code,
lang: lang
lang: lang,
adventure_name: window.State.adventure_name
}),
contentType: 'application/json',
dataType: 'json'
Expand Down

0 comments on commit 5db3283

Please sign in to comment.