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

Issue:
error message does not display row number correctly
### Observed behavior

Currently shows this:

![image](https://user-images.githubusercontent.com/2367265/81125301-9a472000-8eec-11ea-95f5-619818a4c4b2.png)


### Expected behavior

The simpler fix:

| Row number | Error column | Current value | Error |
|--|--|--|--|
| 3  | Password (PASSWORD) | `*` | The password field is required. To leave the password unchanged in existing users, insert an asterisk (*) |


If we also want to show the username, could do something like this:

| Row number | Username | Error column | Current value | Error |
|--|--|--|--|--|
| 3 | `some_user` | Password (PASSWORD) | `*` | The password field is required. To leave the password unchanged in existing users, insert an asterisk (*) |

### User-facing consequences

slightly confusing error output

### Steps to reproduce

create a new user during CSV import, and set the password to `*`

### Context

pf-mvp



Discussion:

Resolving patch:
diff --git a/kolibri/core/auth/management/commands/bulkimportusers.py b/kolibri/core/auth/management/commands/bulkimportusers.py
--- a/kolibri/core/auth/management/commands/bulkimportusers.py
+++ b/kolibri/core/auth/management/commands/bulkimportusers.py
@@ -301,6 +301,7 @@ def validate(self, data):
             # if there aren't any errors, let's add the user and classes
             if not error_flag:
                 self.check_classroom(row, username)
+                row["position"] = index + 1
                 self.users[username] = row
 
 
@@ -509,9 +510,10 @@ def build_users_objects(self, users):
             else:
                 if not values["password"]:
                     error = {
-                        "row": "USERNAME:{}".format(user),
+                        "row": users[user]["position"],
+                        "username": user,
                         "message": MESSAGES[REQUIRED_PASSWORD],
-                        "field": "password",
+                        "field": "PASSWORD",
                         "value": "*",
                     }
                     per_line_errors.append(error)


Test patch:
diff --git a/kolibri/core/auth/test/test_bulk_import.py b/kolibri/core/auth/test/test_bulk_import.py
--- a/kolibri/core/auth/test/test_bulk_import.py
+++ b/kolibri/core/auth/test/test_bulk_import.py
@@ -238,6 +238,7 @@ def test_password_is_required(self):
         # validation when checking db content should trigger an error for '*'  password for a non-existing user:
         assert "'value': '*'" in result[1]
         assert "new_coach" in result[1]
+        assert "'row': 2" in result[1]
 
     def test_asterisk_in_password(self):
         _, first_filepath = tempfile.mkstemp(suffix=".csv")
Repository: learningequality/kolibri

Issue:
backport disabling of BasicAuth

### Observed behavior

back-port https://github.com/learningequality/kolibri/pull/6807 to 0.13

we originally targeted to 0.14 out of an abundance of caution but it ought to be safe enough in 0.13 with some quick sanity integration testing

### User-facing consequences

issues on IIAB


### Context

0.13.2


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
@@ -312,6 +312,9 @@
 
 REST_FRAMEWORK = {
     "UNAUTHENTICATED_USER": "kolibri.core.auth.models.KolibriAnonymousUser",
+    "DEFAULT_AUTHENTICATION_CLASSES": [
+        "rest_framework.authentication.SessionAuthentication",
+    ],
     "DEFAULT_CONTENT_NEGOTIATION_CLASS": "kolibri.core.negotiation.JSONOnlyContentNegotiation",
     "EXCEPTION_HANDLER": "kolibri.core.utils.exception_handler.custom_exception_handler",
 }
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
@@ -21,6 +21,11 @@
 
 REST_FRAMEWORK = {
     "UNAUTHENTICATED_USER": "kolibri.core.auth.models.KolibriAnonymousUser",
+    "DEFAULT_AUTHENTICATION_CLASSES": [
+        # Activate basic auth for external API testing tools
+        "rest_framework.authentication.BasicAuthentication",
+        "rest_framework.authentication.SessionAuthentication",
+    ],
     "DEFAULT_RENDERER_CLASSES": (
         "rest_framework.renderers.JSONRenderer",
         "rest_framework.renderers.BrowsableAPIRenderer",


Test patch:
Repository: learningequality/kolibri

Issue:
Question number has a zero value
<!--
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
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->

There's an error occurs when the learner takes a quiz. 
![q1-zero-number](https://user-images.githubusercontent.com/38421180/85150233-da881500-b284-11ea-851a-ccd699abec52.png)


### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

Learners can take a quiz.
### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

…

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * 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
```
-->
```
Question number 0 is not valid for this quiz
```

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

1. Create a quiz
2. Log in as a learner
3. take a quiz

### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

* Kolibri version : 0.14.0b2
 * Operating system : Windows 7
 * Browser : IE11 and Chrome



Discussion:
The problem is in the quiz creation, as it's created with 0 questions:
![image](https://user-images.githubusercontent.com/1008178/85312514-389c3e80-b4b7-11ea-9561-674bc6a546df.png)


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
@@ -358,7 +358,7 @@ def consolidate(self, items, queryset):
         output = []
 
         for item in items:
-            item["assessmentmetadata"] = assessmentmetadata.get("id")
+            item["assessmentmetadata"] = assessmentmetadata.get(item["id"])
             item["files"] = list(
                 map(lambda x: map_file(x, item), files.get(item["id"], []))
             )


Test patch:
Repository: learningequality/kolibri

Issue:
inconsistent learner enrollment issues with multiple facilities

### Observed behavior

observed by @carinediaz 


> I created my Learners and when I tried to enrolled them into my class, Kolibri wasn't finding them and I realized I was somehow taken to Facility 2, when I created my class and all my users under Demo Facility

corroborated by @nucleogenesis 

> I second this - I don't know if I marked this in the last bug bash or not but this is something I've encountered.
> 
> Like if I start creating learners in a Facility that is not the first one that was created - then after one or two learners being created the third one is created into a that facility (the one I made during provisioning)
> 
> Not easy or consistently replicated though 😕



### Context


0.14.0 beta 3


Discussion:
I believe that the problem is that the link to this button is hard-coded and "forgets" the Facility ID in the URL that's used to help the app remember what facility the admin is working with

![image](https://user-images.githubusercontent.com/10248067/85441264-c1f95280-b543-11ea-9e49-17726273344e.png)

So if you're creating and enrolling learners, click the "All classes" link, and do more work, you may end up enrolling learners in the wrong classroom.

Resolving patch:
diff --git a/kolibri/core/tasks/api.py b/kolibri/core/tasks/api.py
--- a/kolibri/core/tasks/api.py
+++ b/kolibri/core/tasks/api.py
@@ -646,9 +646,9 @@ def manage_fileobject(request, temp_dir):
         delete = request.data.get("delete", None)
         dryrun = request.data.get("dryrun", None)
         userid = request.user.pk
-        facility = request.user.facility.id
+        facility_id = request.data.get("facility_id", None)
         job_type = "IMPORTUSERSFROMCSV"
-        job_metadata = {"type": job_type, "started_by": userid, "facility": facility}
+        job_metadata = {"type": job_type, "started_by": userid, "facility": facility_id}
         job_args = ["bulkimportusers"]
         if dryrun:
             job_args.append("--dryrun")
@@ -657,7 +657,7 @@ def manage_fileobject(request, temp_dir):
         job_args.append(filepath)
 
         job_kwd_args = {
-            "facility": facility,
+            "facility": facility_id,
             "userid": userid,
             "locale": locale,
             "extra_metadata": job_metadata,


Test patch:
Repository: learningequality/kolibri

Issue:
Learner activity records partially not visible after upgrade to 0.14b3
# Observed Behaviour

Upgraded from 0.13.3 to 0.14b3. Learner activity records were partially not visible in Class Home -> Class activity and Reports. Downgraded back to 0.13.3 and they are all visible again.

# Expected behavior

All learner activity should be visible as prior to upgrade


# User-facing consequences

 Confusion and fear of data loss.

# Errors and logs

None on screen

# Steps to reproduce

Upgrade from 0.13.3 to 0.14.0-b3 and check learner activity records.



# Context
Ubuntu 18.04.3
Package : 0.14.beta3 .deb



Discussion:

Resolving patch:
diff --git a/kolibri/core/query.py b/kolibri/core/query.py
--- a/kolibri/core/query.py
+++ b/kolibri/core/query.py
@@ -8,10 +8,17 @@
     from django.contrib.postgres.aggregates import ArrayAgg
 
     class NotNullArrayAgg(ArrayAgg):
+        def __init__(self, *args, **kwargs):
+            self.result_field = kwargs.pop("result_field", None)
+            super(NotNullArrayAgg, self).__init__(*args, **kwargs)
+
         def convert_value(self, value, expression, connection, context):
             if not value:
                 return []
-            return filter(lambda x: x is not None, value)
+            results = list(filter(lambda x: x is not None, value))
+            if self.result_field is not None:
+                return list(map(self.result_field.to_python, results))
+            return results
 
 
 except ImportError:
@@ -54,7 +61,7 @@ def convert_value(self, value, expression, connection, context):
             return []
         results = value.split(",")
         if self.result_field is not None:
-            return map(self.result_field.to_python, results)
+            return list(map(self.result_field.to_python, results))
         return results
 
 
@@ -68,11 +75,16 @@ def get_source_field(model, field_path):
 
 
 def annotate_array_aggregate(queryset, **kwargs):
+    model = queryset.model
     if connection.vendor == "postgresql" and NotNullArrayAgg is not None:
         return queryset.annotate(
-            **{target: NotNullArrayAgg(source) for target, source in kwargs.items()}
+            **{
+                target: NotNullArrayAgg(
+                    source, result_field=get_source_field(model, source)
+                )
+                for target, source in kwargs.items()
+            }
         )
-    model = queryset.model
     # Call values on "pk" to insert a GROUP BY to ensure the GROUP CONCAT
     # is called by row and not across the entire queryset.
     return queryset.values("pk").annotate(


Test patch:
Repository: learningequality/kolibri

Issue:
import footer styling regression


### Observed behavior

![image](https://user-images.githubusercontent.com/2367265/85073073-fef1cd80-b16e-11ea-98c5-8e2342430929.png)

### Expected behavior

button and text should be vertically centered, or the footer should be shorter in height



### Steps to reproduce

import

### Context


0.14 beta 3


Discussion:

Resolving patch:
diff --git a/kolibri/core/content/utils/channels.py b/kolibri/core/content/utils/channels.py
--- a/kolibri/core/content/utils/channels.py
+++ b/kolibri/core/content/utils/channels.py
@@ -123,7 +123,7 @@ def get_channels_for_data_folder(datafolder):
             "id": channel.id,
             "name": channel.name,
             "description": channel.description,
-            "tagline": channel.tagline,
+            "tagline": getattr(channel, "tagline", ""),
             "thumbnail": channel.thumbnail,
             "version": channel.version,
             "root": channel.root_id,


Test patch:
diff --git a/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js b/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
--- a/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
+++ b/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
@@ -33,8 +33,8 @@ describe('SuperuserCredentialsForm', () => {
       full_name: 'Schoolhouse Rock',
       username: 'schoolhouse_rock',
       password: 'password',
-      birth_year: 'NOT_SPECIFIED',
-      gender: 'NOT_SPECIFIED',
+      birth_year: 'DEFERRED',
+      gender: 'DEFERRED',
     });
     expect(wrapper.vm.$emit).toHaveBeenCalledWith('click_next', {
       full_name: 'Schoolhouse Rock',
Repository: learningequality/kolibri

Issue:
Update profile modal displays to super admin account created with setup wizard 
### Observed behavior
_(Wouldn't even know this might be an issue if I hadn't been reviewing super admin Gherkins all past week :blush:)_

According to the [Gherkin scenario](https://github.com/learningequality/kolibri/blob/release-v0.13.x/integration_testing/features/learner/learner-profile-update-notification.feature#L22), this should not appear:

![Ubuntu16 04 (start)  Running  - Oracle VM VirtualBox_677](https://user-images.githubusercontent.com/1457929/85937605-68a76f80-b905-11ea-8f75-88ff846fa271.png)

### Expected behavior
No profile update modal for the super admin.

### User-facing consequences
Annoyed super admin.

### Errors and logs
…

### Steps to reproduce
1. Install Kolibri
2. Go through the setup wizard
3. Go to Learn 

### Context
 * Kolibri version: 0.14.0b6, DEB installer
 * Operating system: Ubuntu 16.04
 * Browser: both Firefox and Chrome



Discussion:

Resolving patch:
diff --git a/kolibri/core/device/utils.py b/kolibri/core/device/utils.py
--- a/kolibri/core/device/utils.py
+++ b/kolibri/core/device/utils.py
@@ -90,11 +90,15 @@ def create_superuser(user_data, facility):
     ).exists():
         raise ValidationError("An account with that username already exists")
 
+    # gender and birth_year are set to "DEFERRED", since superusers do not
+    # need to provide this and are not nudged to update profile on Learn page
     superuser = FacilityUser.objects.create(
         full_name=full_name or username,
         username=username,
         password=password,
         facility=facility,
+        gender="DEFERRED",
+        birth_year="DEFERRED",
     )
 
     superuser.full_clean()


Test patch:
diff --git a/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js b/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
--- a/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
+++ b/kolibri/plugins/setup_wizard/assets/test/views/SuperuserCredentialsForm.spec.js
@@ -33,8 +33,6 @@ describe('SuperuserCredentialsForm', () => {
       full_name: 'Schoolhouse Rock',
       username: 'schoolhouse_rock',
       password: 'password',
-      birth_year: 'DEFERRED',
-      gender: 'DEFERRED',
     });
     expect(wrapper.vm.$emit).toHaveBeenCalledWith('click_next', {
       full_name: 'Schoolhouse Rock',
Repository: learningequality/kolibri

Issue:
Inaccurate reporting of installer when using DEB
### Observed behavior

After installing the DEB on Ubuntu, I went to Device -> Info, and the "Installer" field showed "whl".

### Expected behavior

Should show something like "deb".

### User-facing consequences

When users report issues to us, we may make different suggestions/interpretations based on what installer was used. This could lead us astray here.

It also throws off nutritionfacts stats.

### Errors and logs

```
Version:           0.14.0rc1
OS:                Linux-5.3.0-7648-generic-x86_64-with-Ubuntu-19.10-eoan
Python:            3.7.5
Installer:         whl
Server:            Kolibri internal server
Database:          /home/jamalex/.kolibri/db.sqlite3
Free disk space:   344 GB
Server time:       Thu Aug 06 2020 13:48:38 GMT-0700 (Pacific Daylight Time)
Server timezone:   America/Los_Angeles
```



Discussion:

Resolving patch:
diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -549,13 +549,14 @@ def is_debian_package():
         try:
             check_output(["apt-cache", "show", "kolibri"])
             apt_repo = str(check_output(["apt-cache", "madison", "kolibri"]))
-            if apt_repo:
+            if len(apt_repo) > 4:  # repo will have at least http
                 install_type = "apt"
         except (
             CalledProcessError,
             FileNotFoundError,
         ):  # kolibri package not installed!
-            install_type = "whl"
+            if sys.path[-1] != "/usr/lib/python3/dist-packages":
+                install_type = "whl"
         return install_type
 
     def is_kolibri_server():


Test patch:
Repository: learningequality/kolibri

Issue:
Subquery in `FaclityViewset` `last_synced` annotation can return multiple results
<!--
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

This subquery from the `TransferSession` table can return multiple results, which causes the `/api/auth/facility` endpoint to  break

https://github.com/learningequality/kolibri/blob/release-v0.14.x/kolibri/core/auth/api.py#L359

### Expected behavior

The `/api/auth/facility` endpoint doesn't break because of this query. The subquery should be limited to a returning a single value.

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

…

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * 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
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

…



Discussion:

Resolving patch:
diff --git a/kolibri/core/auth/api.py b/kolibri/core/auth/api.py
--- a/kolibri/core/auth/api.py
+++ b/kolibri/core/auth/api.py
@@ -366,7 +366,7 @@ def annotate_queryset(self, queryset):
                         )
                     )
                     .order_by("-last_activity_timestamp")
-                    .values("last_activity_timestamp")
+                    .values("last_activity_timestamp")[:1]
                 )
             )
         )


Test patch:
Repository: learningequality/kolibri

Issue:
Use WhiteNoise and precompression to serve static assets
### Observed behavior
We currently serve static files using CherryPy, and gzip them on the fly every time they are served.

This results in a performance cost.

### Expected behavior
We should:

* Use `compression-webpack-plugin` https://v4.webpack.js.org/plugins/compression-webpack-plugin/ to precompress our built static assets using zopfli
* Use our JS build pipeline to also do a pass over other js and css static assets that we ship, to pre-compress those too
* Use WhiteNoise instead of CherryPy to serve our static files so that any precompressed assets can be conditionally served

### User-facing consequences
Faster response times when browser caches are not already filled



Discussion:

Resolving patch:
diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -10,6 +10,7 @@
 from cherrypy.process.plugins import SimplePlugin
 from cherrypy.process.servers import ServerAdapter
 from django.conf import settings
+from whitenoise import WhiteNoise
 from zeroconf import get_all_addresses
 
 import kolibri
@@ -267,21 +268,22 @@ def configure_http_server(port):
     # Mount the application
     from kolibri.deployment.default.wsgi import application
 
-    cherrypy.tree.graft(application, "/")
-
     if not getattr(settings, "DEVELOPER_MODE", False):
         # Mount static files
-        cherrypy.tree.mount(
-            cherrypy.tools.staticdir.handler(section="/", dir=settings.STATIC_ROOT),
-            settings.STATIC_URL,
-            config={
-                "/": {
-                    "tools.gzip.on": True,
-                    "tools.gzip.mime_types": ["text/*", "application/javascript"],
-                }
-            },
+        application = WhiteNoise(
+            application,
+            root=settings.STATIC_ROOT,
+            prefix=settings.STATIC_URL,
+            # Use 1 day as the default cache time for static assets
+            max_age=24 * 60 * 60,
+            # Add a test for any file name that contains a semantic version number
+            # or a 32 digit number (assumed to be a file hash)
+            # these files will be cached indefinitely
+            immutable_file_test=r"((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)|[a-f0-9]{32})",
         )
 
+    cherrypy.tree.graft(application, "/")
+
     # Mount media files
     cherrypy.tree.mount(
         cherrypy.tools.staticdir.handler(section="/", dir=settings.MEDIA_ROOT),


Test patch:
Repository: learningequality/kolibri

Issue:
Upgrade kolibri-exercise-perseus-plugin to 1.3.4
Things to do:

- [x] Publish kolibri_exercise_perseus_plugin==1.3.4 to PyPi
- [x] Update dependency in `requirements/base.txt`
- [x] Apply this change to 0.14 branch https://github.com/rtibbles/kolibri/commit/b8fcd70084380d23af7182d5b80e4849a5d0b93c


Discussion:
@jonboiser Shall I work upon this?
Thanks @Cronus1007 , but publishing to PyPi requires being a maintainer of the project.
@jonboiser Yes I agree. No issues.

Resolving patch:
diff --git a/kolibri/core/content/utils/paths.py b/kolibri/core/content/utils/paths.py
--- a/kolibri/core/content/utils/paths.py
+++ b/kolibri/core/content/utils/paths.py
@@ -13,8 +13,7 @@
 VALID_STORAGE_FILENAME = re.compile(r"[0-9a-f]{32}(-data)?\.[0-9a-z]+")
 
 # set of file extensions that should be considered zip files and allow access to internal files
-POSSIBLE_ZIPPED_FILE_EXTENSIONS = set([".perseus", ".zip", ".h5p"])
-# TODO: add ".epub" and ".epub3" if epub-equivalent of ZipContentView implemented
+POSSIBLE_ZIPPED_FILE_EXTENSIONS = set([".zip", ".h5p"])
 
 
 def _maybe_makedirs(path):


Test patch: