Skip to content

Commit

Permalink
Improve new table implementation
Browse files Browse the repository at this point in the history
- Renamed new table html file to comparisontable_unique instead of comparisontable_new
- Fixed small formatting issue in comparisontable_unique
- Added new comparison table to replace all instances of old comparison table
  • Loading branch information
mikaelGusse committed Feb 13, 2024
1 parent ad9fbe6 commit 2a077bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import re
import cProfile

from django.conf import settings
from django.core.exceptions import ValidationError, FieldError
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<table class="comparison">
<tr>
{% for comparison in comparisons %}
<td> {% student_td course comparison %}</td>
<td>{% student_td course comparison %}</td>
{% if forloop.counter|divisibleby:10 %}
</tr><tr>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion review/templates/review/comparison.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<button type="button"><a href="{% url 'pair_view' course_key=course.key a_key=a.student.key b_key=b.student.key %}">See all comparisons for this pair of students</a></button>

{% include 'review/_comparisontable.html' %}
{% include 'review/_comparisontable_unique.html' %}

<div class="code-comparison"{% if reverse %} data-reverse{% endif %}>
<p>Similarity: <b>{{ comparison.similarity|percent }}</b></p>
Expand Down
2 changes: 1 addition & 1 deletion review/templates/review/exercise.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h4>Comparison pairs with highest similarity</h4>
<a href="{% url 'exercise' course_key=exercise.course.key exercise_key=exercise.key %}?rows=100" class="btn btn-default btn-xs"}">
Show 100 rows
</a>
{% include 'review/_comparisontable_new.html' %}
{% include 'review/_comparisontable_unique.html' %}

<pre id="js" class="well">
Waiting for Javascript...
Expand Down

0 comments on commit 2a077bf

Please sign in to comment.