stage 2: nice button
[edumed.git] / stage2 / models.py
index 8407ef2..204b4da 100644 (file)
@@ -59,7 +59,7 @@ class Participant(models.Model):
 
 
 class Assignment(models.Model):
-    title = models.CharField(_('title'), max_length=128)
+    title = models.CharField(_('title'), max_length=128, blank=True)
     content = models.TextField(_('content'))
     content_url = models.URLField(_('URL'))
     deadline = models.DateTimeField(_('deadline'))
@@ -175,8 +175,8 @@ class Answer(models.Model):
 
     def total_points(self):
         criterion_count = self.assignment.markcriterion_set.count()
-        for expert in self.experts.all():
-            marks = self.mark_set.filter(expert=expert)
+        for expert_id in self.mark_set.values_list('expert_id', flat=True).distinct():
+            marks = self.mark_set.filter(expert_id=expert_id)
             if len(marks) == criterion_count:
                 yield sum(mark.points for mark in marks)