Mastery log diff returns 500 when a try has null time_spent
🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:
- Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
- Confirm that you’ve read the guidelines in your comment.
Target branch: develop
Observed behavior
the masterylog diff endpoint returns a 500 when either of the two tries it compares has a null time_spent time_spent is null on purpose for tries recorded before logger migration 0011
Errors and logs
File "kolibri/core/logger/viewsets/mastery_log.py", line 109, in diff
"time_spent": target_try["time_spent"] - previous_try["time_spent"],
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
Expected behavior
the diff loads and the time_spent difference is null when one of the values is unknown
User-facing consequences
coaches and learners cant open the quiz or exercise report for a learner whose tries include one recorded before migration 0011 for example data from an older install or synced from an older device
Steps to reproduce
1 give a learner two mastery logs for the same exercise 2 set time_spent to NULL on one of them 3 open that learners exercise report or call GET /api/logger/masterylog/0/diff/?content=<content_id>&user=<user_id> 4 it returns a 500
Context
develop at 5ea5d476cb
Hi @amritraj7237 - in future, please open the issue first and request to be assigned to it, rather than filing a PR and then retroactively opening an issue. This allows us to make sure that issues are well scoped and helpful and to make sure PRs that get opened are setup for success.
Thanks @rtibbles, understood — I'll open an issue and wait to be assigned before starting work next time.
sir can i contribute to this issue
Hi! 👋
Thanks so much for your interest! This issue is already assigned. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.
We really appreciate your willingness to help. 😊
Are you preparing for Google Summer of Code? See our GSoC guidelines.