Skip to content

Commit

Permalink
fix: catch null weighted_possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Aug 3, 2023
1 parent 71d364a commit d7121d4
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,22 @@ 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']
weighted_earned = event_data['weighted_earned']

if weighted_possible is None:
weighted_possible = 0

Check warning on line 158 in event_routing_backends/processors/xapi/event_transformers/problem_interaction_events.py

View check run for this annotation

Codecov / codecov/patch

event_routing_backends/processors/xapi/event_transformers/problem_interaction_events.py#L158

Added line #L158 was not covered by tests

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 d7121d4

Please sign in to comment.