Skip to content

Commit

Permalink
[FIX] JS Error store_parsons_order (hedyorg#4193)
Browse files Browse the repository at this point in the history
**Description**

Upon submitting the result for a parsons test, a JS Error occurs, level is supplied as an integer in the payload; the store_parsons_order route returns an HTTP 400 whenever the level is not an string instance. 

**Fixes hedyorg#4192**

**How to test**

Go to any level; go to parasons tab; submit a / any answer.

**Checklist**
  
- [x] Contains one of the PR categories in the name
- [x] Describes changes in the format above
- [x] Links to an existing issue or discussion 
- [x] Has a "How to test" section
  • Loading branch information
antoineveldhoven authored Mar 30, 2023
1 parent 1c3a6d0 commit e00174a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,8 +1767,8 @@ def store_parsons_order():
# Validations
if not isinstance(body, dict):
return 'body must be an object', 400
if not isinstance(body.get('level'), str):
return 'level must be a string', 400
if not isinstance(body.get('level'), int):
return 'level must be an integer', 400
if not isinstance(body.get('exercise'), str):
return 'exercise must be a string', 400
if not isinstance(body.get('order'), list):
Expand Down
2 changes: 0 additions & 2 deletions website/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ def save_program(self, user):
if not body.get("force_save", True):
return jsonify({"parse_error": True, "message": gettext("save_parse_warning")})

print('Going into logic')

program = self.logic.store_user_program(
program_id=program_id,
level=body['level'],
Expand Down

0 comments on commit e00174a

Please sign in to comment.