Repository: learningequality/kolibri

Issue:
Error when attempting to view Coach Exam Reports

### Observed behavior
On my instance, go to view exam report at

http://localhost:8000/coach/#/df6308209356328f726a09aa9bd323b7/5d132ba360b54b2ba9df169ffaa43ccb/exams/77d87e49c67c4ff9ac96bc543d836f4f

Get this TypeError (TypeError: filter_collection() takes exactly 3 arguments (4 given))
```
ERROR    Internal Server Error: /api/examlog/
Traceback (most recent call last):
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/viewsets.py", line 90, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/views.py", line 489, in dispatch
    response = self.handle_exception(exc)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/views.py", line 449, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/views.py", line 486, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/mixins.py", line 40, in list
    queryset = self.filter_queryset(self.get_queryset())
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/rest_framework/generics.py", line 152, in filter_queryset
    queryset = backend().filter_queryset(self.request, queryset, self)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django_filters/rest_framework/backends.py", line 54, in filter_queryset
    return filter_class(request.query_params, queryset=queryset, request=request).qs
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django_filters/rest_framework/filterset.py", line 50, in qs
    return super(FilterSet, self).qs
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django_filters/filterset.py", line 220, in qs
    qs = filter_.filter(qs, value)
  File "/Users/jon/.venvs/kolibri/lib/python2.7/site-packages/django_filters/filters.py", line 713, in __call__
    return self.method(qs, self.f.field_name, value)
TypeError: filter_collection() takes exactly 3 arguments (4 given)
ERROR    "GET /api/examlog/?exam=77d87e49c67c4ff9ac96bc543d836f4f&collection=df6308209356328f726a09aa9bd323b7&1515535689923=1515535689923 HTTP/1.1" 500 30882
```
### Expected behavior

No Error. Exam report shows up.

### User-facing consequences

User not able to view Exam reports.

### Errors and logs

See description

### Steps to reproduce

1. Create and activate an Exam
1. Try to view report for the exam. (My classroom has 2 learners. One Learner submitted an attempt).
1. Get error

### Context
 * Kolibri version: develop
 * Operating system: mac
 * Browser: chrome


…




Discussion:
@rtibbles Is it possible this was caused by a breaking change to django_filter (was pre 1.0 for awhile, now at 1.0).

https://github.com/learningequality/kolibri/commit/c2e335a8cbc94f175f0f60ffccf44693e8a5271e

django_filter has also been causing problems for viewing the DRF browsable API. some but not all API endpoints do not work and are pointing to django_filter.
Yes, I thought I had caught most instances of the breaking changes, but possible some are still extant.

Should you open a separate issue for the browsable API issues as well, or is it just a repeat of this issue, you think?
Also somewhat annoying, as the reason I upgraded django_filter was for compatibility with the newer version of DRF, so don't know why it's now having issues with the django_filter API...
I think the DRF API is a different thing entirely, having to do with the Django App settings. I will write up a separate issue for it, after I find some of the affected endpoints.

Resolving patch:
diff --git a/kolibri/logger/api.py b/kolibri/logger/api.py
--- a/kolibri/logger/api.py
+++ b/kolibri/logger/api.py
@@ -154,7 +154,7 @@ class ExamLogFilter(BaseLogFilter):
 
     collection = ModelChoiceFilter(method="filter_collection", queryset=Collection.objects.all())
 
-    def filter_collection(self, queryset, collection):
+    def filter_collection(self, queryset, name, collection):
         return HierarchyRelationsFilter(queryset).filter_by_hierarchy(
             target_user=F('user'),
             ancestor_collection=collection,


Test patch: