Bug with sending back grades for a non-leaf blocks on devstack

Description

It seems that sending back grades for a non-leaf blocks works incorrect on devstack. I mean that the problem could be produced only in case of using option:

and only in case of sending back grades for a groups of problems (units)
The problem could be reproducible with exchange between edx and canvas local installations (edx in this scheme is the tool provider and canvas is the tool consumer).

1. The first problem is that the function _progress_summary that should calculate the scores rises an transaction.TransactionManagementError Exception on the line
https://github.com/edx/edx-platform/blob/release/lms/djangoapps/courseware/grades.py#L562
because by default devstack uses mysql option ATOMIC_REQUESTS=True. So Django forcibly starts all requests with a transactions:

2. If the previous option is set as a False it seems that the function send_composite_outcome doesn't rise the exception but the final score will be calculated incorrectly. It always calculated as 0. I've tried to investigate this problem and there is my research:
It seems that the problem in incorrect object ScoresClient. To be precise in fetch_scores method.
Because to init the scores_qset variable it takes set(locations) that could contain BlockUsageLocator objects with defined params like branch and version. For example like this:

But the result scores_qset variable contains BlockUsageLocator objects without the branch and version params like this one:

So in case of execution function get by location with branch and version it doesn't return anything. To fix this issue it seems that function get should be refactored in the such way:

May be it looks like an ugly patch but it works.
Also the function score_for_module should be refactored in the same way too. In my case it works with this changes:

But as I said in the beginning this bug appears only in case of calculation final score in the same process as webserver works. i.e in case of using CELERY_ALWAYS_EAGER = True.

Assignee

Douglas Hall

Reporter

Dmitry Viskov

Labels

Priority

Unset
Configure