diff --git a/data/models.py b/data/models.py index 4d61bf8..a3269d8 100644 --- a/data/models.py +++ b/data/models.py @@ -2,6 +2,7 @@ import json import logging import re +import cProfile from django.conf import settings from django.core.exceptions import ValidationError, FieldError @@ -120,7 +121,7 @@ def get_student(self, key_str): return student def __str__(self): - return "%s (%s)" % (self.name, self.created) + return "%s (%s) id:%s" % (self.name, self.created, self.key) class Exercise(models.Model): @@ -222,13 +223,20 @@ def top_comparisons(self, rows): return sorted_unique_set def comparisons_for_student(self, student): - return self._comparisons_by_submission( + student_list = self._comparisons_by_submission( self.valid_matched_submissions\ .filter(student=student)\ .order_by("created")\ .values_list("id", flat=True) ) + unique_set = set() + + for student in student_list: + unique_set.update(student["matches"]) + + return unique_set + def _comparisons_by_submission(self, submissions): comparisons = [] for s_id in submissions: diff --git a/review/templates/review/_comparisontable_new.html b/review/templates/review/_comparisontable_unique.html similarity index 80% rename from review/templates/review/_comparisontable_new.html rename to review/templates/review/_comparisontable_unique.html index 1e56f7e..9ed26b9 100644 --- a/review/templates/review/_comparisontable_new.html +++ b/review/templates/review/_comparisontable_unique.html @@ -2,7 +2,7 @@ {% for comparison in comparisons %} - + {% if forloop.counter|divisibleby:10 %} {% endif %} diff --git a/review/templates/review/comparison.html b/review/templates/review/comparison.html index 09f25e3..4ebbb77 100644 --- a/review/templates/review/comparison.html +++ b/review/templates/review/comparison.html @@ -17,7 +17,7 @@ -{% include 'review/_comparisontable.html' %} +{% include 'review/_comparisontable_unique.html' %}

Similarity: {{ comparison.similarity|percent }}

diff --git a/review/templates/review/exercise.html b/review/templates/review/exercise.html index 688e034..ed05e26 100644 --- a/review/templates/review/exercise.html +++ b/review/templates/review/exercise.html @@ -16,7 +16,7 @@

Comparison pairs with highest similarity

Show 100 rows -{% include 'review/_comparisontable_new.html' %} +{% include 'review/_comparisontable_unique.html' %}
 Waiting for Javascript...
{% student_td course comparison %}{% student_td course comparison %}