internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: learningequality/kolibri

Issue:
In Exam Creation, all breadcrumbs go back to the "top level"
### Observed behavior

When navigating through topics in the Exam Creation workflow, clicking a breadcrumb will take you to the top level (all channels), even if the breadcrumb's title was for a different sub-topic.
 
### Expected behavior

Clicking the breadcrumb will take you the correct topic.


### Steps to reproduce

1. Enter an Exam Creation Workflow
1. Navigate to a non-channel topic several levels deep
1. On the breadcrumbs list, click a topic that is not the top level
1. Get sent to the top level

### Context

Latest 0.10 release on Kolibribeta



Discussion:

Resolving patch:
diff --git a/kolibri/content/api.py b/kolibri/content/api.py
--- a/kolibri/content/api.py
+++ b/kolibri/content/api.py
@@ -415,7 +415,8 @@ def ancestors(self, request, **kwargs):
         if cache.get(cache_key) is not None:
             return Response(cache.get(cache_key))
 
-        ancestors = list(self.get_object(prefetch=False).get_ancestors().values('pk', 'title'))
+        # TODO remove 'pk' once UI standardizes to 'id'
+        ancestors = list(self.get_object(prefetch=False).get_ancestors().values('pk', 'id', 'title'))
 
         cache.set(cache_key, ancestors, 60 * 10)
 


Test patch:
Repository: learningequality/kolibri

Issue:
The new learners and coachs account, can't view the kolibri 0.11.0a3 at first login
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
When I create a learners account and test to login, the page show like this "The requested URL / was not found on this server."

<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->



### Expected behavior
Must login to kolibri page.
<!--
Description of what behavior was expected but did not occur
-->


### Errors and logs
```
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. 127.0.0.1:8080 
```
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/kolibri.log
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
1. login with admin account
2. go to facility and user tab
3. create new learner account
4. try to login the new learner account and see the error page.
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context
Windows 7 and 10
kolibri 0.11.0a3
firefox 61.0.1(64-bit)
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->
### Screenshot
![errorloginpage](https://user-images.githubusercontent.com/38421180/42367122-fb1ae096-80b7-11e8-9165-6e73b2702a72.png)



Discussion:
Is there any chance that multiple Kolibri or Python processes are running simultaneously?
This is an issue with the way we handle `first_login` 
@rtibbles
https://github.com/learningequality/kolibri/blob/e9a394ac7d31aa15bfaa3ed86c84c17ba3182040/kolibri/core/views.py#L95
Yeah, the first login flag needs to be amended slightly to fall back to the non first login if not available. Will fix. 

Resolving patch:
diff --git a/kolibri/core/views.py b/kolibri/core/views.py
--- a/kolibri/core/views.py
+++ b/kolibri/core/views.py
@@ -59,6 +59,13 @@ def logout_view(request):
 def get_url_by_role(role, first_login):
     obj = next((hook for hook in RoleBasedRedirectHook().registered_hooks
                 if hook.role == role and hook.first_login == first_login), None)
+
+    if obj is None and first_login:
+        # If it is the first_login, do a fallback to find the non-first login behaviour when it is
+        # not available
+        obj = next((hook for hook in RoleBasedRedirectHook().registered_hooks
+                    if hook.role == role and hook.first_login is False), None)
+
     if obj:
         return obj.url
 


Test patch:
Repository: learningequality/kolibri

Issue:
add mechanism to track and report method of installation in 'server info' page and error reports

### Observed behavior

Currently we can report the kolibri version number and operating system, but not mechanism of installation (pex vs pip vs deb vs exe)

### Expected behavior

We should have the mechanism of installation available to the app for use in e.g. the server info page and error reports

### User-facing consequences

When users submit error reports, it's more complicated for us to ask "how did you install it" than to simply say "copy and paste this text"

### Context

0.10.0




Discussion:

Resolving patch:
diff --git a/kolibri/core/device/api.py b/kolibri/core/device/api.py
--- a/kolibri/core/device/api.py
+++ b/kolibri/core/device/api.py
@@ -19,6 +19,7 @@
 from kolibri.core.decorators import signin_redirect_exempt
 from kolibri.utils.conf import OPTIONS
 from kolibri.utils.server import get_urls
+from kolibri.utils.server import installation_type
 from kolibri.utils.system import get_free_space
 from kolibri.utils.time import local_now
 
@@ -93,5 +94,6 @@ def get(self, request, format=None):
         info['server_time'] = local_now()
         # Returns the named timezone for the server (the time above only includes the offset)
         info['server_timezone'] = settings.TIME_ZONE
+        info['installer'] = installation_type()
 
         return Response(info)
diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -1,7 +1,10 @@
 import atexit
 import logging
 import os
+import sys
 import threading
+from subprocess import CalledProcessError
+from subprocess import check_output
 
 import cherrypy
 import ifcfg
@@ -322,3 +325,38 @@ def get_urls(listen_port=None):
         return STATUS_RUNNING, urls
     except NotRunning as e:
         return e.status_code, []
+
+
+def installation_type():  # noqa:C901
+    """
+    Tries to guess how the running kolibri server was installed
+
+    :returns: install_type is the type of detected installation
+    """
+    install_type = 'Unknown'
+    if len(sys.argv) > 1:
+        launcher = sys.argv[0]
+        if launcher.endswith('.pex'):
+            install_type = 'pex'
+        elif 'runserver' in sys.argv:
+            install_type = 'devserver'
+        elif launcher == '/usr/bin/kolibri':
+            # find out if this is from the debian package
+            install_type = 'dpkg'
+            try:
+                check_output(['apt-cache', 'show', 'kolibri'])
+                apt_repo = str(check_output(['apt-cache', 'madison', 'kolibri']))
+                if apt_repo:
+                    install_type = 'apt'
+            except CalledProcessError:  # kolibri package not installed!
+                install_type = 'whl'
+        elif '\\Scripts\\kolibri' in launcher:
+            paths = sys.path
+            for path in paths:
+                if 'kolibri.exe' in path:
+                    install_type = 'Windows'
+                    break
+        elif 'start' in sys.argv:
+            install_type = 'whl'
+
+    return install_type


Test patch:
Repository: learningequality/kolibri

Issue:
After deleting the channel, still it is showing the channel name in learn tab.

### Observed behavior
We have deleted a channel in Kolibri-0.9.5b2. But after deleting the channel in device tab, it removes the entry for that channel. But when we go to the learn tab, it shows deleted channel name.
Please find screenshot for more information.

### Expected behavior
When we delete any channel from device tab, it must not show name of same channel in learn tab.

### Steps to reproduce
1. Login with device owner.
2. Delete the channel.
3. Go to the learn tab.
4. You will see deleted channel name in learn tab.

### Context

 * Kolibri version : Kolibri-0.9.5b2
 * Operating system: Ubuntu 14.04
 * Browser: Chrome

### Screenshots
After deleting channel in device tab:
![screen shot 2018-09-11 at 4 58 50 pm](https://user-images.githubusercontent.com/12776071/45357955-9a8efb00-b5e5-11e8-8c5f-ac4045a8f8f2.png)


After deleting channel in learn tab:
![screenshot from 2018-09-11 13_33_26](https://user-images.githubusercontent.com/12776071/45357989-a975ad80-b5e5-11e8-91d2-a439d33f10c7.png)



Discussion:

Resolving patch:
diff --git a/kolibri/content/models.py b/kolibri/content/models.py
--- a/kolibri/content/models.py
+++ b/kolibri/content/models.py
@@ -23,6 +23,7 @@
 from mptt.models import TreeForeignKey
 
 from .utils import paths
+from kolibri.core.device.models import ContentCacheKey
 from kolibri.core.fields import DateTimeTzField
 
 PRESET_LOOKUP = dict(format_presets.choices)
@@ -304,3 +305,4 @@ def __str__(self):
     def delete_content_tree_and_files(self):
         # Use Django ORM to ensure cascading delete:
         self.root.delete()
+        ContentCacheKey.update_cache_key()


Test patch:
Repository: learningequality/kolibri

Issue:
Lift the code quality in kolibri.logger
### Observed behavior

This module does not use `from __future__ import unicode_literals`, which makes the CSV exports *a little* unpredictable! I've see calls to `str` a couple of times

Also, it's not PEP8.

### Expected behavior

Should conform with the rest of the codebase.

### User-facing consequences

potential for encoding errors

### Errors and logs

n/a

### Steps to reproduce

n/a

### Context

n/a


Discussion:

Resolving patch:
diff --git a/kolibri/core/logger/csv.py b/kolibri/core/logger/csv.py
--- a/kolibri/core/logger/csv.py
+++ b/kolibri/core/logger/csv.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
 import math
 
 from rest_framework import serializers


Test patch:
diff --git a/kolibri/core/logger/test/test_api.py b/kolibri/core/logger/test/test_api.py
--- a/kolibri/core/logger/test/test_api.py
+++ b/kolibri/core/logger/test/test_api.py
@@ -451,8 +451,8 @@ def test_exam_not_active_patch_permissions(self):
         self.exam.active = False
         self.exam.save()
         response = self.client.patch(reverse('kolibri:core:examattemptlog-detail', kwargs={
-                'pk': examattemptlog.id
-            }), {"start_timestamp": timezone.now()}, format="json")
+            'pk': examattemptlog.id
+        }), {"start_timestamp": timezone.now()}, format="json")
         self.assertEqual(response.status_code, 403)
 
     def test_examlog_closed_patch_permissions(self):
@@ -472,8 +472,8 @@ def test_examlog_closed_patch_permissions(self):
         self.examlog.closed = True
         self.examlog.save()
         response = self.client.patch(reverse('kolibri:core:examattemptlog-detail', kwargs={
-                'pk': examattemptlog.id
-            }), {"start_timestamp": timezone.now()}, format="json")
+            'pk': examattemptlog.id
+        }), {"start_timestamp": timezone.now()}, format="json")
         self.assertEqual(response.status_code, 403)
 
     def tearDown(self):
Repository: learningequality/kolibri

Issue:
Enable ePUB plugin to run by default

### Observed behavior

ePUB plugin is not enabled by default, and it prevents from importing & viewing ePUB files, until the command `kolibri plugin kolibri.plugins.document_epub_render enable` is run.

### User-facing consequences
Inability to view and import ePUB files.


### Context
dev environment, tried on `develop` and `0.11.a7` branches



Discussion:

Resolving patch:
diff --git a/kolibri/utils/conf.py b/kolibri/utils/conf.py
--- a/kolibri/utils/conf.py
+++ b/kolibri/utils/conf.py
@@ -68,6 +68,7 @@
         "kolibri.plugins.user",
         "kolibri_exercise_perseus_plugin",
         "kolibri.plugins.style_guide",
+        "kolibri.plugins.document_epub_render",
     ]
 
 #: Everything in this list is added to django.conf.settings.INSTALLED_APPS


Test patch:
Repository: learningequality/kolibri

Issue:
<Improvement> Not showing user is exist notification on UI.

### Observed behavior
We are able to create user using CREATE AN ACCOUNT option which is on login page of kolibri. But when someone uses existing username to create account, it will not show any kind of existing user notification on UI.
Not able to distinguish whether account is exist or not.
### Expected behavior
It must show existing username notification on UI if user is exist.


### Steps to reproduce
1. Login with Admin and go to the facility.
2. Click on settings.
3. Select Allow learners to create accounts.
4. Logout and click on CREATE AN ACCOUNT button and use existing username to create account.

### Context

 * Kolibri version : Kolibri 0.11.0 
 * Operating system : ubuntu 14.04
 * Browser : Chrome

### Screenshots:
![1](https://user-images.githubusercontent.com/12776071/49732114-840b4500-fca3-11e8-9917-a08ae5515d26.png)




Discussion:
thanks - this might be a regression

Resolving patch:
diff --git a/kolibri/core/auth/serializers.py b/kolibri/core/auth/serializers.py
--- a/kolibri/core/auth/serializers.py
+++ b/kolibri/core/auth/serializers.py
@@ -55,8 +55,10 @@ class FacilityUserSignupSerializer(FacilityUserSerializer):
 
     def validate_username(self, value):
         if FacilityUser.objects.filter(username__iexact=value).exists():
-            raise serializers.ValidationError(detail={'username': ['An account with that username already exists.']},
-                                              code=error_constants.USERNAME_ALREADY_EXISTS)
+            raise serializers.ValidationError(
+                detail='An account with that username already exists.',
+                code=error_constants.USERNAME_ALREADY_EXISTS
+            )
         return value
 
 


Test patch:
diff --git a/integration_testing/features/guest/guest-sign-up-account.feature b/integration_testing/features/guest/guest-sign-up-account.feature
--- a/integration_testing/features/guest/guest-sign-up-account.feature
+++ b/integration_testing/features/guest/guest-sign-up-account.feature
@@ -15,6 +15,11 @@ Feature: Guest sign up for account
      And I click the *Finish* button 
     Then I am signed in and I can see the *Learn > Channels* page
 
+  Scenario: Username is already taken
+    Given A user already exists with some username
+    When I try to sign up for a new account with that username
+    Then I get a validation message shown next to the username field that the name is already taken
+
   Examples:
   | full_name | password | username | password | facility |
   | juan .p   | learner  | juan     | pass     | school   |
Repository: learningequality/kolibri

Issue:
Some images are not found 
### Observed behavior
In the current Kolibri develop branch, some images are not found after building js bundle.
I.e. 
`yarn devserver`works perfectly
`yarn build & yarn django-devserver` gives a not-found error in the urls
/user/kolibri-logo.svg
/user/background.jpg
![badroutes](https://user-images.githubusercontent.com/1008178/49745603-a733f580-fc9f-11e8-841d-65598017798b.png)
It looks like a path issue in the frontend

### Expected behavior
All the images should be found when using the built bundles.

### User-facing consequences
Bad look

### Steps to reproduce
Using develop code
`yarn build` will build the bundles
`yarn django-devserver` will run only the Django webserver.
Browsing in Kolibri will be visible


### Context
* Kolibri develop branch
* Tested with Google Chrome
* OS: Linux



Discussion:

Resolving patch:
diff --git a/kolibri/core/templatetags/kolibri_tags.py b/kolibri/core/templatetags/kolibri_tags.py
--- a/kolibri/core/templatetags/kolibri_tags.py
+++ b/kolibri/core/templatetags/kolibri_tags.py
@@ -157,10 +157,9 @@ def kolibri_navigation_actions():
 def kolibri_set_urls(context):
     js_global_object_name = getattr(settings, 'JS_REVERSE_JS_GLOBAL_OBJECT_NAME', JS_GLOBAL_OBJECT_NAME)
     js_var_name = getattr(settings, 'JS_REVERSE_JS_VAR_NAME', JS_VAR_NAME)
-    js = (js_reverse_inline(context) +
-          """
+    js = (js_reverse_inline(context) + """
           Object.assign({kolibri}.urls, {global_object}.{js_var});
-          {kolibri}.urls.__staticURL = '{static_url}';
+          {kolibri}.urls.__setStaticURL('{static_url}');
           """.format(
         kolibri=conf.KOLIBRI_CORE_JS_NAME,
         global_object=js_global_object_name,


Test patch:
Repository: learningequality/kolibri

Issue:
Shows sorry! something went wrong.
### Observed behavior
When coach is going to the recent tab to see exercise and video progress then it shows error.


### Expected behavior
It must show progress instead of error.

### Steps to reproduce
1. Login with coach.
2. go to the recent tab.
3. Go to the exercise/video and see.

### Context

 * Kolibri version : kolibri 0.11.0
 * Operating system : Ubuntu 14.04
 * Browser : chrome

### Screenshot
![1](https://user-images.githubusercontent.com/12776071/50138341-4d958180-02c4-11e9-92b7-01a9fb28acc2.png)
![2](https://user-images.githubusercontent.com/12776071/50138342-4d958180-02c4-11e9-9426-fe0709d16751.png)
![3](https://user-images.githubusercontent.com/12776071/50138343-4e2e1800-02c4-11e9-9ac4-e520796024ed.png)



Discussion:

Resolving patch:
diff --git a/kolibri/plugins/coach/api.py b/kolibri/plugins/coach/api.py
--- a/kolibri/plugins/coach/api.py
+++ b/kolibri/plugins/coach/api.py
@@ -102,7 +102,7 @@ class ContentSummaryViewSet(viewsets.ReadOnlyModelViewSet):
 
     def get_queryset(self):
         channel_id = self.kwargs['channel_id']
-        return ContentNode.objects.filter(Q(channel_id=channel_id) & Q(available=True)).order_by('lft')
+        return ContentNode.objects.filter(Q(channel_id=channel_id)).order_by('lft')
 
 
 class RecentReportViewSet(ReportBaseViewSet):


Test patch:
Repository: learningequality/kolibri

Issue:
When starting Exams, Notifications and Attempt logs can be out of sync

### Observed behavior

1. As a learner, start an exam, but do not do any of the questions
1. After some time, a Notification will be recorded for the exam with a status of "Started"
1. However, querying the class summary API, the 'exam learner status' for that exam will have a status of "NotStarted".

This can lead to an inconsistency, where the Notification will update the in-memory classSummary data and cause the dashboard and reports to show that 1 learner has "started" an exam, but if you were to refresh (and get the on-server class summary data without the updating notification), it will revert to showing 0 learners starting the exam.

### Expected behavior

Since, the UI intends to use Notifications to patch class summary in real time, the two notions of "Exam Started" should match to avoid situations like the on described above.


### User-facing consequences

inconsistent / fluctuating values in reports


### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context

0.12.0 a 7


Discussion:
cc @rtibbles @jredrejo 

In `class_summary_api` I compute the status as

```python
    def get_status(self, exam_log):
        if exam_log.closed:
            return COMPLETED
        elif exam_log.attemptlogs.values_list("item").count() > 0:
            return STARTED
        return NOT_STARTED
```

Any recommendations on how to update this to be consistent with the notification behavior?
I guess similar to the `needs_help` work I did in the same API, querying the notifications to do the `STARTED` flagging?
Is there not information in the exam logs about whether the user has opened it or not? That's all I need here
The first time the user opens the exam, it creates the ExamLog itself. I'll change the logic so it doesn't check for attemptlogs, just returns started if there's an ExamLog at all.
perfect
Do we have the same issue for other types of content? In `content_status_serializer`, I see we do:
```
        elif log["progress"] == 0:
            return NOT_STARTED
```

Do we want it to show as "started" as soon as people open other types of content, or only once `progress > 0`?

Resolving patch:
diff --git a/kolibri/plugins/coach/class_summary_api.py b/kolibri/plugins/coach/class_summary_api.py
--- a/kolibri/plugins/coach/class_summary_api.py
+++ b/kolibri/plugins/coach/class_summary_api.py
@@ -108,9 +108,8 @@ class ExamStatusSerializer(serializers.ModelSerializer):
     def get_status(self, exam_log):
         if exam_log.closed:
             return COMPLETED
-        elif exam_log.attemptlogs.values_list("item").count() > 0:
+        else:
             return STARTED
-        return NOT_STARTED
 
     def get_num_correct(self, exam_log):
         return (


Test patch:
Repository: learningequality/kolibri

Issue:
z-order issues with exercises during quiz creation

### Observed behavior

observed by @jtamiace during 0.12.0 alpha testing:

![image](https://user-images.githubusercontent.com/2367265/52090683-ec212d80-2566-11e9-9c8f-353fb55ddbe8.png)


### Expected behavior

Exercises should be hidden below bottom bar.

Note: the easiest way to fix this will _not_ be to play with z-orders because the perseus renderer is too unpredictable. Instead, set an appropriate value for `marginBottom` on `CoreBase` so that the scrolling area is not actually under the bottom bar.

### User-facing consequences

 broken layout



### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context

k 0.12.0 alpha 5



Discussion:

Resolving patch:
diff --git a/kolibri/plugins/coach/api.py b/kolibri/plugins/coach/api.py
--- a/kolibri/plugins/coach/api.py
+++ b/kolibri/plugins/coach/api.py
@@ -154,7 +154,7 @@ def list(self, request, *args, **kwargs):
         """
         It provides the list of ClassroomNotificationsViewset from DRF.
         Then it fetches and saves the needed information to know how many coaches
-        are requesting notificatios in the last five minutes
+        are requesting notifications in the last five minutes
         """
         response = super(viewsets.ReadOnlyModelViewSet, self).list(request, *args, **kwargs)
 


Test patch:
Repository: learningequality/kolibri

Issue:
ValueError: invalid literal for int() with base 10
Sentry Issue: [KOLIBRI-BACKEND-8](https://sentry.io/learningequality/kolibri-backend/issues/877480545/?referrer=github_integration)

```
ValueError: invalid literal for int() with base 10: '0.00293684005737'
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/utils/deprecation.py", line 142, in __call__
    response = self.process_response(request, response)
  File "kolibri/core/analytics/middleware.py", line 144, in process_response
    if int(duration) > MetricsMiddleware.slowest_request_time:
```


Discussion:
Sentry issue: [KOLIBRI-BACKEND-9](https://sentry.io/learningequality/kolibri-backend/issues/877487448/?referrer=github_integration)

Resolving patch:
diff --git a/kolibri/core/analytics/middleware.py b/kolibri/core/analytics/middleware.py
--- a/kolibri/core/analytics/middleware.py
+++ b/kolibri/core/analytics/middleware.py
@@ -141,7 +141,7 @@ def process_response(self, request, response):
             path = request.get_full_path()
             duration, memory_before, memory, load_before, load = self.metrics.get_stats()
             max_time = False
-            if int(duration) > MetricsMiddleware.slowest_request_time:
+            if float(duration) > MetricsMiddleware.slowest_request_time:
                 MetricsMiddleware.slowest_request_time = int(duration)
                 max_time = True
             timestamp = time.strftime('%Y/%m/%d %H:%M:%S.%f')


Test patch: