Repository: learningequality/kolibri

Issue:
The attempts for each question that learner takes in an exam is incorrect.
## Summary
The attempts history for each question that learner takes in an exam is incorrect.

How are these attempts calculated? Also I don't remember making those attempts the tare shown in the screenshot. 

## System information
 - Version: Kolibri 0.4.0alpha4
 - Operating system: Ubuntu 14.04 LTS
 - Browser: Chrome

## How to reproduce

1. Give an exam
2. Check the reports  
3. Validate each of the attempts.

## Screenshots
![attempts 1](https://cloud.githubusercontent.com/assets/13453618/25662344/d04b8564-3031-11e7-871a-e97436af9b62.png)

![attempts 2](https://cloud.githubusercontent.com/assets/13453618/25662347/d43b0c3a-3031-11e7-96ca-d441e12cc057.png)

![order](https://cloud.githubusercontent.com/assets/13453618/25662415/1519fd10-3032-11e7-9051-3567c90abc61.png)




Discussion:

Resolving patch:
diff --git a/kolibri/logger/migrations/0009_auto_20170502_2225.py b/kolibri/logger/migrations/0009_auto_20170502_2225.py
new file mode 100644
--- /dev/null
+++ b/kolibri/logger/migrations/0009_auto_20170502_2225.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2017-05-02 22:25
+from __future__ import unicode_literals
+
+import jsonfield.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('logger', '0008_auto_20170430_1418'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='attemptlog',
+            name='answer',
+            field=jsonfield.fields.JSONField(blank=True, default={}, null=True),
+        ),
+        migrations.AlterField(
+            model_name='examattemptlog',
+            name='answer',
+            field=jsonfield.fields.JSONField(blank=True, default={}, null=True),
+        ),
+    ]
diff --git a/kolibri/logger/models.py b/kolibri/logger/models.py
--- a/kolibri/logger/models.py
+++ b/kolibri/logger/models.py
@@ -194,7 +194,7 @@ class BaseAttemptLog(BaseLogModel):
     correct = models.FloatField(validators=[MinValueValidator(0), MaxValueValidator(1)])
     hinted = models.BooleanField(default=False)
     # JSON blob that would allow the learner's answer to be rerendered in the frontend interface
-    answer = JSONField(default={})
+    answer = JSONField(default={}, null=True, blank=True)
     # A human readable answer that could be rendered directly in coach reports, can be blank.
     simple_answer = models.CharField(max_length=200, blank=True)
     # A JSON Array with a sequence of JSON objects that describe the history of interaction of the user
diff --git a/kolibri/logger/serializers.py b/kolibri/logger/serializers.py
--- a/kolibri/logger/serializers.py
+++ b/kolibri/logger/serializers.py
@@ -64,7 +64,7 @@ class Meta:
                   'complete', 'correct', 'hinted', 'answer', 'simple_answer', 'interaction_history')
 
 class ExamAttemptLogSerializer(serializers.ModelSerializer):
-    answer = serializers.JSONField(default='{}')
+    answer = serializers.JSONField(default='{}', allow_null=True)
     interaction_history = serializers.JSONField(default='[]')
 
     class Meta:


Test patch: