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

Issue:
Starting up Kolibri Development Server
### Observed behavior

Trying to run the Kolobri Development Server from Ubuntu Bash on Windows, but it raises a ValueError for incorrect timezone (local).

### Expected behavior

Should start up the Kolibri server on local machine.

### Errors and logs

Relevant errors and tracebacks from:

*virtual environment command line:
```
Traceback (most recent call last):
  File "/home/alan/.venvs/kolibri/bin/kolibri", line 11, in <module>
    load_entry_point('kolibri', 'console_scripts', 'kolibri')()
  File "/home/alan/Kolibri1/kolibri/kolibri/utils/cli.py", line 607, in main
    initialize(debug=debug)
  File "/home/alan/Kolibri1/kolibri/kolibri/utils/cli.py", line 176, in initialize
    django.setup()
  File "/home/alan/.venvs/kolibri/local/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/alan/.venvs/kolibri/local/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/home/alan/.venvs/kolibri/local/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/alan/.venvs/kolibri/local/lib/python2.7/site-packages/django/conf/__init__.py", line 138, in __init__
    raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
ValueError: Incorrect timezone setting: local

```

### Steps to reproduce

Run command to start up Kolibri Development server. 

kolibri --debug manage devserver --webpack

### Context

* Kolibri version: Develop Branch
* Operating system: Ubuntu Bash for Windows


Discussion:

Resolving patch:
diff --git a/kolibri/deployment/default/settings/base.py b/kolibri/deployment/default/settings/base.py
--- a/kolibri/deployment/default/settings/base.py
+++ b/kolibri/deployment/default/settings/base.py
@@ -13,6 +13,8 @@
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 import os
 
+import pytz
+
 # import kolibri, so we can get the path to the module.
 import kolibri
 # we load other utilities related to i18n
@@ -155,7 +157,18 @@
 
 LANGUAGE_CODE = conf.config.get("LANGUAGE_CODE") or "en"
 
-TIME_ZONE = get_localzone().zone
+try:
+    TIME_ZONE = get_localzone().zone
+except pytz.UnknownTimeZoneError:
+    # Do not fail at this point because a timezone was not
+    # detected.
+    TIME_ZONE = pytz.utc.zone
+
+# Fixes https://github.com/regebro/tzlocal/issues/44
+# tzlocal 1.4 returns 'local' if unable to detect the timezone,
+# and this TZ id is invalid
+if TIME_ZONE == "local":
+    TIME_ZONE = pytz.utc.zone
 
 USE_I18N = True
 


Test patch:
Repository: learningequality/kolibri

Issue:
Invalid exam report timestamp
### Observed behavior
After submitting exam, when teacher go to the exam report to watch exam report. Exam report shows timestamp like "Completed 47 years ago". System time and date is as of today.

Note : Getting "Completed 47 years ago" timestamp for every exam.

### Expected behavior
It must shows correct timestamp.

### Steps to reproduce
1. Login with learner and give exam.
2. Login with teacher account and go to the coach.
3. See exam report.

### Context

* Kolibri version: Kolibri 0.4.7
* Operating system: Ubuntu 14.04
* Browser: Chrome

###Screenshots

![timestamp](https://user-images.githubusercontent.com/12776071/31876429-3472584c-b7f0-11e7-8e93-89cb761b6c9d.png)




Discussion:
@rtibbles I faced same timestamp issue on another server too.

![today](https://user-images.githubusercontent.com/12776071/31943337-13ee69de-b8e6-11e7-9ec2-09d3008ac992.png)

I see lots of places where `completion_timestamp` is set, so I'm curious whether we're using a consistent format everywhere for that. Does it always come from the `now()` function or is it ever  set directly by the server? 

Also, in the exam view's 'page status' prop we pass the value through `Date()`:

```
:completionTimestamp="new Date(completionTimestamp)"
```

maybe there's a chance that's causing unexpected behaviors, especially if we do in fact have multiple timestamp formats floating around

Resolving patch:
diff --git a/kolibri/core/exams/api.py b/kolibri/core/exams/api.py
--- a/kolibri/core/exams/api.py
+++ b/kolibri/core/exams/api.py
@@ -1,5 +1,6 @@
 from django.db.models.query import F
 from django.shortcuts import get_object_or_404
+from django.utils.timezone import now
 from kolibri.auth.api import KolibriAuthPermissions, KolibriAuthPermissionsFilter
 from kolibri.auth.filters import HierarchyRelationsFilter
 from kolibri.core.exams import models, serializers
@@ -32,6 +33,13 @@ class ExamViewset(viewsets.ModelViewSet):
     def get_queryset(self):
         return models.Exam.objects.all()
 
+    def perform_update(self, serializer):
+        was_active = serializer.instance.active
+        serializer.save()
+        if was_active and not serializer.instance.active:
+            # Has changed from active to not active, set completion_timestamps on all non closed examlogs
+            serializer.instance.examlogs.filter(completion_timestamp__isnull=True).update(completion_timestamp=now())
+
 
 class ExamAssignmentViewset(viewsets.ModelViewSet):
     serializer_class = serializers.ExamAssignmentSerializer


Test patch:
Repository: learningequality/kolibri

Issue:
"Featured in ..." ordering on Recommended page
### Observed behavior

Order of channels (3) listed in "Featured in..." on the Recommended page is based on content id.

### Expected behavior

Order of channels to be manipulate-able, by changing the ordering to be most recently imported.

### User-facing consequences

Quick way to allow for control on which channels appear on the Recommended page.



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
@@ -32,7 +32,7 @@ class ChannelMetadataViewSet(viewsets.ReadOnlyModelViewSet):
     filter_class = ChannelMetadataFilter
 
     def get_queryset(self):
-        return models.ChannelMetadata.objects.all()
+        return models.ChannelMetadata.objects.all().order_by('-last_updated')
 
 
 class IdFilter(filters.FilterSet):


Test patch:
Repository: learningequality/kolibri

Issue:
Content importing is stuck in a "Queued" state until finished
### Observed behavior

Content imports is stuck in "preparing" in the UX before it suddenly becomes marked as "Finished".

### Expected behavior

It show progress downloading.

### User-facing consequences

Users have no idea what the progress of their content import is.




Discussion:

Resolving patch:
diff --git a/kolibri/tasks/api.py b/kolibri/tasks/api.py
--- a/kolibri/tasks/api.py
+++ b/kolibri/tasks/api.py
@@ -115,6 +115,8 @@ def startremotecontentimport(self, request):
             node_ids=node_ids,
             exclude_node_ids=exclude_node_ids,
             extra_metadata=job_metadata,
+            track_progress=True,
+            cancellable=True,
         )
 
         resp = _job_to_response(get_client().status(job_id))
@@ -201,6 +203,8 @@ def startdiskcontentimport(self, request):
             node_ids=node_ids,
             exclude_node_ids=exclude_node_ids,
             extra_metadata=job_metadata,
+            track_progress=True,
+            cancellable=True,
         )
 
         resp = _job_to_response(get_client().status(job_id))
@@ -231,7 +235,8 @@ def startdeletechannel(self, request):
             "deletechannel",
             channel_id,
             track_progress=True,
-            extra_metadata=job_metadata,)
+            extra_metadata=job_metadata,
+        )
 
         # attempt to get the created Task, otherwise return pending status
         resp = _job_to_response(get_client().status(task_id))


Test patch:
Repository: learningequality/kolibri

Issue:
partially-complete transfers prevent a successful upgrade
### Observed behavior

If Kolibri 0.6 is shut down while a transfer is in progress, running Kolibri 0.7 won't work

### Expected behavior

Upgrades should occur smoothly. Preferably the transfer can pick up where it left off, but if it needs to be canceled that's the next best solution.

### User-facing consequences

Kolibri is not usable after attempting to upgrade.

### Errors and logs

lots of this:

```
ERROR    Internal Server Error: /api/tasks/
Traceback (most recent call last):
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/viewsets.py", line 87, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch
    response = self.handle_exception(exc)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch
    response = handler(request, *args, **kwargs)
  File "kolibri/tasks/api.py", line 42, in list
    jobs_response = [_job_to_response(j) for j in get_client().all_jobs()]
  File "kolibri/tasks/api.py", line 427, in _job_to_response
    "type": job.extra_metadata.get("type"),
AttributeError: 'Job' object has no attribute 'extra_metadata'
```

### Steps to reproduce

* start up 0.6
* start a long-running import
* shut down 0.6 before import completes
* start up 0.7


### Context

* Kolibri version: 0.6 -> 0.7
* Operating system: OSX



Discussion:
Yeah, this looks like it's because of a breaking change to iceqube (Task v0.7 is not compatible with Task v0.6). The fix is to delete the Task DB, but maybe it would be better if this work an automatic step when upgrading.

Resolving patch:
diff --git a/kolibri/tasks/api.py b/kolibri/tasks/api.py
--- a/kolibri/tasks/api.py
+++ b/kolibri/tasks/api.py
@@ -424,8 +424,8 @@ def _job_to_response(job):
         }
     else:
         return {
-            "type": job.extra_metadata.get("type"),
-            "started_by": job.extra_metadata.get("started_by"),
+            "type": getattr(job, "extra_metadata", {}).get("type"),
+            "started_by": getattr(job, "extra_metadata", {}).get("started_by"),
             "status": job.state,
             "exception": str(job.exception),
             "traceback": str(job.traceback),


Test patch:
Repository: learningequality/kolibri

Issue:
updateChannelMetadata fails on upgrade
### Observed behavior
Can't see any content when I install latest.

### Expected behavior

Content should still be available

### User-facing consequences

Thinking that all content was deleted

### Errors and logs

```
Traceback (most recent call last):
  File "/home/david/.virtualenvs/kolibri/bin/kolibri", line 9, in <module>
    load_entry_point('kolibri', 'console_scripts', 'kolibri')()
  File "/home/david/Work/kolibri/kolibri/utils/cli.py", line 655, in main
    start(port, daemon=daemon)
  File "/home/david/Work/kolibri/kolibri/utils/cli.py", line 311, in start
    update()
  File "/home/david/Work/kolibri/kolibri/utils/cli.py", line 295, in update
    update_channel_metadata()
  File "/home/david/Work/kolibri/kolibri/content/utils/annotation.py", line 35, in update_channel_metadata
    set_availability()
TypeError: set_availability() takes at least 1 argument (0 given)
```


### Steps to reproduce

try and run latest `release-v0.7.x` with existing content

### Context

* Kolibri version:  0.7
* Operating system: Linux
* Browser: Chromium



Discussion:

Resolving patch:
diff --git a/kolibri/content/utils/annotation.py b/kolibri/content/utils/annotation.py
--- a/kolibri/content/utils/annotation.py
+++ b/kolibri/content/utils/annotation.py
@@ -1,5 +1,5 @@
-import logging as logger
 import datetime
+import logging as logger
 import os
 
 from django.conf import settings
@@ -26,13 +26,10 @@ def update_channel_metadata():
     """
     from .channel_import import import_channel_from_local_db
     channel_ids = get_channel_ids_for_content_database_dir(settings.CONTENT_DATABASE_DIR)
-    imported = False
     for channel_id in channel_ids:
         if not ChannelMetadata.objects.filter(id=channel_id).exists():
             import_channel_from_local_db(channel_id)
-            imported = True
-    if imported:
-        set_availability()
+            set_availability(channel_id)
 
 
 def set_leaf_node_availability_from_local_file_availability():


Test patch:
Repository: learningequality/kolibri

Issue:
inconsistent channel ordering

### Observed behavior

In 'Recommended', channel order is based on order of import:'

![image](https://user-images.githubusercontent.com/2367265/35355527-66d57dd6-0102-11e8-82ec-74e93859d2de.png)

In 'Channels', order is not the same:

![image](https://user-images.githubusercontent.com/2367265/35355543-76f21d46-0102-11e8-8206-3376acf08f93.png)


### Expected behavior

In the 'Channels' sub-section, order should be based on order of import.

### User-facing consequences

Administrators are not able to control the order that channels appear in on that page.

### Context

Desired for one VF deployment.

@rtibbles would you mind linking to the change you made to update the 'Recommended' page?





Discussion:

Resolving patch:
diff --git a/kolibri/__init__.py b/kolibri/__init__.py
--- a/kolibri/__init__.py
+++ b/kolibri/__init__.py
@@ -6,7 +6,7 @@
 
 #: This may not be the exact version as it's subject to modification with
 #: get_version() - use ``kolibri.__version__`` for the exact version string.
-VERSION = (0, 6, 1, 'final', 0)
+VERSION = (0, 6, 2, 'final', 0)
 
 __author__ = 'Learning Equality'
 __email__ = 'info@learningequality.org'


Test patch:
Repository: learningequality/kolibri

Issue:
Translatable strings are not being properly updated on devserver
## Summary

- Sometimes tr strings that are modified do not get properly updated.

## System information

 - Version: 0.6
 - Operating system: Ubuntu
 - Node 6.11.2

## How to reproduce

1. Try editing tr strings and check that they are updated in the UI. Pretty random.

## Real-life consequences 

- Development rage 


Discussion:
Note that this is due to server side caching of the loaded JSON message files, need to make the caching conditional on DEBUG mode.

Resolving patch:
diff --git a/kolibri/core/webpack/hooks.py b/kolibri/core/webpack/hooks.py
--- a/kolibri/core/webpack/hooks.py
+++ b/kolibri/core/webpack/hooks.py
@@ -236,7 +236,7 @@ def frontend_message_file(self, lang_code):
     def frontend_messages(self):
         global _JSON_MESSAGES_FILE_CACHE
         lang_code = get_language()
-        if not _JSON_MESSAGES_FILE_CACHE.get(self.unique_slug, {}).get(lang_code):
+        if not _JSON_MESSAGES_FILE_CACHE.get(self.unique_slug, {}).get(lang_code) or django_settings.DEBUG:
             frontend_message_file = self.frontend_message_file(lang_code)
             if frontend_message_file:
                 with open(frontend_message_file) as f:


Test patch:
Repository: learningequality/kolibri

Issue:
Rename Buildkite assets for clarity
## Summary

When downloading builds from `buildkite/kolibri/assets` details link, filenames are too complex and difficult to distinguish. 

![selection_655](https://user-images.githubusercontent.com/1457929/31338580-259d1370-ad00-11e7-9c8a-f890d2515631.png)

These links do save some time, but filenames are longer then those downloaded individually from Buildkite (green). Could we make them shorter? For example, get rid of the useless prefix and various `%2F` in between in order to make this:

`kolibri%2Fbuildkite%2Fbuild-2313%2F2755%2Fkolibri-0.6.dev020170929214748-git.pex` (red)

into this:

`build-2313-kolibri-0.6.dev020170929214748-git.pex` (yellow)

Or just `kolibri-0.6.dev020170929214748-git.pex` if those build details are not necessary.

![selection_653](https://user-images.githubusercontent.com/1457929/31339729-198fddf2-ad04-11e7-8b85-d1e0125600e4.png)


Discussion:
@radinamatic it looks like the path is translated into a filename

`kolibri%2Fbuildkite%2Fbuild-2313%2F2755%2F` means `kolibri/buildkite/build-2313/2755/`. This could just be stripped off or just put the buildkite build number at the end of the file name.

One important thing here: These builds are for testers, not end users.

Nice Ubuntu theme :)
+1 for stripping all the unnecessary! :+1: 
 

> These builds are for testers, not end users.

The issue was filed for totally selfish reasons... :smiling_imp: 

> Nice Ubuntu theme :)

GNOME dark :heart: 


Resolving patch:
diff --git a/.buildkite/upload_artifacts.py b/.buildkite/upload_artifacts.py
--- a/.buildkite/upload_artifacts.py
+++ b/.buildkite/upload_artifacts.py
@@ -167,16 +167,16 @@ def upload_artifacts():
     for file_data in artifacts.values():
         logging.info("Uploading file (%s)" % (file_data.get("name")))
         if is_release:
-            blob = bucket.blob('kolibri/%s/%s/%s' % (RELEASE_DIR, BUILD_ID, file_data.get("name")))
+            blob = bucket.blob('kolibri-%s-%s-%s' % (RELEASE_DIR, BUILD_ID, file_data.get("name")))
         else:
-            blob = bucket.blob('kolibri/buildkite/build-%s/%s/%s' % (ISSUE_ID, BUILD_ID, file_data.get("name")))
+            blob = bucket.blob('kolibri-buildkite-build-%s-%s-%s' % (ISSUE_ID, BUILD_ID, file_data.get("name")))
         blob.upload_from_filename(filename=file_data.get("file_location"))
         blob.make_public()
         file_data.update({'media_url': blob.media_link})
 
     html = create_status_report_html(artifacts)
 
-    blob = bucket.blob('kolibri/%s/%s/report.html' % (RELEASE_DIR, BUILD_ID))
+    blob = bucket.blob('kolibri-%s-%s-report.html' % (RELEASE_DIR, BUILD_ID))
 
     blob.upload_from_string(html, content_type='text/html')
 


Test patch:
Repository: learningequality/kolibri

Issue:
Some sample learners from generate-user-data appearing out of order
On Coach Learner Reports, these two appear at top of list

Link to beta page: http://kolibribeta.learningequality.org/coach/#/fa4cbfeda32c0c0fbf1832fc1ddd10c3/learners

<img width="540" alt="screen shot 2018-03-12 at 2 11 48 pm" src="https://user-images.githubusercontent.com/10248067/37309843-64794974-25ff-11e8-88ac-8ca7f6bfe558.png">

Observations: 
1. "Jikutokuruka" and "Takitoteka" don't appear in alphabetical order (rest of list is alphabetized)


Discussion:
Do we alphabetize by username or fullname?
In this particular table, since fullname is in first row, we alphabetize by the fullname (this was not consistent in other User tables until recently.)

The issue here is that rows 3 and below follow that, but for some reason the first two don't. My hunch is that it has something to do with the spreadsheet these names come from (character encoding, or something).

Resolving patch:
diff --git a/kolibri/logger/utils/user_data.py b/kolibri/logger/utils/user_data.py
--- a/kolibri/logger/utils/user_data.py
+++ b/kolibri/logger/utils/user_data.py
@@ -83,7 +83,7 @@ def get_or_create_classroom_users(**options):
             # Get the first base data that does not have a matching user already
             base_data = user_data[n_in_classroom + i]
             # Randomly create the name from 1 to 3 of the three user name fields
-            name = " ".join([base_data[key] for key in random.sample(user_data_name_fields, random.randint(1, 3))])
+            name = " ".join([base_data[key] for key in random.sample(user_data_name_fields, random.randint(1, 3)) if base_data[key]])
             user = FacilityUser.objects.create(
                 facility=facility,
                 full_name=name,


Test patch:
diff --git a/kolibri/logger/test/test_generateuserdata.py b/kolibri/logger/test/test_generateuserdata.py
--- a/kolibri/logger/test/test_generateuserdata.py
+++ b/kolibri/logger/test/test_generateuserdata.py
@@ -50,3 +50,7 @@ def test_summary_logs_for_each_user(self):
 
     def test_lessons_created(self):
         self.assertEqual(Lesson.objects.count(), n_lessons * n_classes * n_facilities)
+
+    def test_no_spacey_names(self):
+        for user in FacilityUser.objects.all():
+            self.assertEqual(user.full_name.strip(), user.full_name)
Repository: learningequality/kolibri

Issue:
Setup 'Open in Editor' functionality for vue devtools
Configure webpack according to these docs so developers can open the source code for a vue component from within Vue Devtools

https://github.com/vuejs/vue-devtools/blob/master/docs/open-in-editor.md


Discussion:

Resolving patch:
diff --git a/kolibri/deployment/default/settings/dev.py b/kolibri/deployment/default/settings/dev.py
--- a/kolibri/deployment/default/settings/dev.py
+++ b/kolibri/deployment/default/settings/dev.py
@@ -1,7 +1,11 @@
-from __future__ import absolute_import, print_function, unicode_literals
+from __future__ import absolute_import
+from __future__ import print_function
+from __future__ import unicode_literals
 
 from .base import *  # noqa isort:skip @UnusedWildImport
 
 INSTALLED_APPS += ['rest_framework_swagger']  # noqa
 
 REST_SWAGGER = True
+
+REDIRECT_WEBPACK = True
diff --git a/kolibri/deployment/default/urls.py b/kolibri/deployment/default/urls.py
--- a/kolibri/deployment/default/urls.py
+++ b/kolibri/deployment/default/urls.py
@@ -17,10 +17,13 @@
 .. moduleauthor:: Learning Equality <info@learningequality.org>
 
 """
-from __future__ import absolute_import, print_function, unicode_literals
+from __future__ import absolute_import
+from __future__ import print_function
+from __future__ import unicode_literals
 
 from django.conf import settings
-from django.conf.urls import include, url
+from django.conf.urls import include
+from django.conf.urls import url
 from django.contrib import admin
 from morango import urls as morango_urls
 
@@ -57,3 +60,13 @@
     urlpatterns += [
         url(r'^api_explorer/', schema_view)
     ]
+
+if getattr(settings, 'REDIRECT_WEBPACK', False):
+    from django.http.response import HttpResponseRedirect
+
+    def webpack_redirect_view(request):
+        return HttpResponseRedirect('http://127.0.0.1:3000/__open-in-editor?{query}'.format(query=request.GET.urlencode()))
+
+    urlpatterns += [
+        url(r'^__open-in-editor/', webpack_redirect_view)
+    ]


Test patch:
Repository: learningequality/kolibri

Issue:
hide topics and channels with no exercises during exam creation

### Observed behavior

reported by @khangmach 

Channels and topics with no exercises available are still showing and are disabled

### Expected behavior

They should be taken out of the UI list completely

### User-facing consequences

extra visual noise


### Steps to reproduce

Create new exam, look at channel list, see disabled channel names. Navigate to available channel, see disabled topics

### Context

0.10.0



Discussion:

Resolving patch:
diff --git a/kolibri/core/content/api.py b/kolibri/core/content/api.py
--- a/kolibri/core/content/api.py
+++ b/kolibri/core/content/api.py
@@ -54,7 +54,7 @@ def filter_has_exercise(self, queryset, name, value):
 
         for channel in queryset:
             channel_has_exercise = channel.root.get_descendants() \
-                .filter(kind=content_kinds.EXERCISE) \
+                .filter(kind=content_kinds.EXERCISE, available=True) \
                 .exists()
             if channel_has_exercise:
                 channel_ids.append(channel.id)


Test patch: