Skip to content

Commit

Permalink
fix: catch null weighted_possible (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 authored Aug 3, 2023
1 parent 71d364a commit 4a66fb0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion event_routing_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Various backends for receiving edX LMS events..
"""

__version__ = '5.5.3'
__version__ = '5.5.4'
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"context": {
"accept_language": "en-US,en;q=0.9",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
"client_id": "667522224.1583394645",
"course_id": "course-v1:edX+DemoX+Demo_Course",
"course_user_tags": {},
"host": "localhost:18000",
"ip": "172.18.0.1",
"module": {
"display_name": "Checkboxes",
"usage_key": "block-v1:edX+DemoX+Demo_Course+type@problem+block@3fc5461f86764ad7bdbdf6cbdde61e66"
},
"org_id": "edX",
"path": "/courses/course-v1:edX+DemoX+Demo_Course/xblock/block-v1:edX+DemoX+Demo_Course+type@problem+block@3fc5461f86764ad7bdbdf6cbdde61e66/handler/xmodule_handler/problem_check",
"referer": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/courseware/8b66dcd2d6134eda9355089ece4f39f6/ef37eb3cf1724e38b7f88a9ce85a4842/?activate_block_id=block-v1%3AedX%2BDemoX%2BDemo_Course%2Btype%40sequential%2Bblock%40ef37eb3cf1724e38b7f88a9ce85a4842",
"session": "993110e9c27848a545da74a74114158d",
"user_id": 3,
"username": "edx"
},
"data": {
"course_id": "course-v1:edX+DemoX+Demo_Course",
"event_transaction_id": "07adb7b7-db7e-4cfd-9d69-5474a4c5774c",
"event_transaction_type": "edx.grades.problem.submitted",
"problem_id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@3fc5461f86764ad7bdbdf6cbdde61e66",
"user_id": "3",
"weighted_earned": 0,
"weighted_possible": null
},
"name": "edx.grades.problem.submitted",
"timestamp": "2020-07-15T05:59:29.700909+00:00"
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,19 @@ def get_result(self):
`Result`
"""
event_data = self.get_data('data')
if event_data['weighted_possible'] > 0:
scaled = event_data['weighted_earned']/event_data['weighted_possible']
weighted_possible = event_data['weighted_possible'] or 0
weighted_earned = event_data['weighted_earned'] or 0

if weighted_possible > 0:
scaled = weighted_earned/weighted_possible
else:
scaled = 0
return Result(
success=event_data['weighted_earned'] >= event_data['weighted_possible'],
success=weighted_earned >= weighted_possible,
score={
'min': 0,
'max': event_data['weighted_possible'],
'raw': event_data['weighted_earned'],
'max': weighted_possible,
'raw': weighted_earned,
'scaled': scaled
}
)
Expand Down

0 comments on commit 4a66fb0

Please sign in to comment.