prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Слать в лототрон только один ответ от одного пользователя
  Сейчас, если пользователь дал три ответа на домашку, то при кросс-проверке все три ответа уйдут разным студентам. Это — плохо, нужно либо слать только первый ответ, либо собирать все ответы в пачку и слать их одному пользователю.
  
  </issue>
  <code>
  [start of src/homework/services/answer_crosscheck_dispatcher.py]
  1 from typing import Optional
  2 
  3 from django.db import transaction
  4 from django.db.models import Count, Q, QuerySet
  5 
  6 from homework.models import Answer, AnswerCrossCheck
  7 from users.models import User
  8 
  9 
  10 class AnswerCrossCheckDispatcher:
  11     """Given a bunch of answers and users, create a cross-check record
  12     for each of them, making sure each answer has a user to check
  13     and number of answers if equal for each user
  14     """
  15     def __init__(self, answers: QuerySet[Answer], answers_per_user: int = 3):
  16         self.answers = Answer.objects.filter(pk__in=[answer.pk for answer in answers])
  17         self.users = User.objects.filter(pk__in=[answer.author_id for answer in answers]).order_by('?')
  18         self.answers_per_user = answers_per_user
  19 
  20     @transaction.atomic
  21     def __call__(self) -> list[AnswerCrossCheck]:
  22         crosschecks = list()
  23         for user in self.users.iterator():
  24             for _ in range(self.answers_per_user):
  25                 answer = self.get_answer_to_check(user)
  26                 if answer is not None:
  27                     crosschecks.append(
  28                         self.give_answer_to_user(answer, user),
  29                     )
  30 
  31         return crosschecks
  32 
  33     def get_answer_to_check(self, user: User) -> Optional[Answer]:
  34         return self.get_answers_with_crosscheck_count() \
  35             .annotate(already_checking=Count('answercrosscheck', filter=Q(answercrosscheck__checker_id=user.id))) \
  36             .exclude(already_checking__gte=1) \
  37             .exclude(author=user) \
  38             .exclude(do_not_crosscheck=True) \
  39             .order_by('crosscheck_count').first()
  40 
  41     def give_answer_to_user(self, answer: Answer, user: User) -> AnswerCrossCheck:
  42         return AnswerCrossCheck.objects.create(answer=answer, checker=user)
  43 
  44     def get_answers_with_crosscheck_count(self) -> QuerySet[Answer]:
  45         return self.answers.annotate(
  46             crosscheck_count=Count('answercrosscheck', filter=Q(answercrosscheck__checker__in=self.users)),
  47         )
  48
  [end of src/homework/services/answer_crosscheck_dispatcher.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/homework/services/answer_crosscheck_dispatcher.py b/src/homework/services/answer_crosscheck_dispatcher.py
  --- a/src/homework/services/answer_crosscheck_dispatcher.py
  +++ b/src/homework/services/answer_crosscheck_dispatcher.py
  @@ -9,11 +9,12 @@
   
   class AnswerCrossCheckDispatcher:
       """Given a bunch of answers and users, create a cross-check record
  -    for each of them, making sure each answer has a user to check
  -    and number of answers if equal for each user
  +    for each of them, making sure the first answer of each user has a user to
  +    check and number of answers if equal for each user
       """
       def __init__(self, answers: QuerySet[Answer], answers_per_user: int = 3):
           self.answers = Answer.objects.filter(pk__in=[answer.pk for answer in answers])
  +        self.unique_author_answers = self.answers.order_by('author_id', 'created').distinct('author_id')
           self.users = User.objects.filter(pk__in=[answer.author_id for answer in answers]).order_by('?')
           self.answers_per_user = answers_per_user
   
  @@ -27,11 +28,11 @@
                       crosschecks.append(
                           self.give_answer_to_user(answer, user),
                       )
  -
           return crosschecks
   
       def get_answer_to_check(self, user: User) -> Optional[Answer]:
           return self.get_answers_with_crosscheck_count() \
  +            .filter(id__in=self.unique_author_answers) \
               .annotate(already_checking=Count('answercrosscheck', filter=Q(answercrosscheck__checker_id=user.id))) \
               .exclude(already_checking__gte=1) \
               .exclude(author=user) \
  
verification_info: {"golden_diff": "diff --git a/src/homework/services/answer_crosscheck_dispatcher.py b/src/homework/services/answer_crosscheck_dispatcher.py\n--- a/src/homework/services/answer_crosscheck_dispatcher.py\n+++ b/src/homework/services/answer_crosscheck_dispatcher.py\n@@ -9,11 +9,12 @@\n \n class AnswerCrossCheckDispatcher:\n     \"\"\"Given a bunch of answers and users, create a cross-check record\n-    for each of them, making sure each answer has a user to check\n-    and number of answers if equal for each user\n+    for each of them, making sure the first answer of each user has a user to\n+    check and number of answers if equal for each user\n     \"\"\"\n     def __init__(self, answers: QuerySet[Answer], answers_per_user: int = 3):\n         self.answers = Answer.objects.filter(pk__in=[answer.pk for answer in answers])\n+        self.unique_author_answers = self.answers.order_by('author_id', 'created').distinct('author_id')\n         self.users = User.objects.filter(pk__in=[answer.author_id for answer in answers]).order_by('?')\n         self.answers_per_user = answers_per_user\n \n@@ -27,11 +28,11 @@\n                     crosschecks.append(\n                         self.give_answer_to_user(answer, user),\n                     )\n-\n         return crosschecks\n \n     def get_answer_to_check(self, user: User) -> Optional[Answer]:\n         return self.get_answers_with_crosscheck_count() \\\n+            .filter(id__in=self.unique_author_answers) \\\n             .annotate(already_checking=Count('answercrosscheck', filter=Q(answercrosscheck__checker_id=user.id))) \\\n             .exclude(already_checking__gte=1) \\\n             .exclude(author=user) \\\n", "issue": "\u0421\u043b\u0430\u0442\u044c \u0432 \u043b\u043e\u0442\u043e\u0442\u0440\u043e\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\n\u0421\u0435\u0439\u0447\u0430\u0441, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u0430\u043b \u0442\u0440\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u043e\u043c\u0430\u0448\u043a\u0443, \u0442\u043e \u043f\u0440\u0438 \u043a\u0440\u043e\u0441\u0441-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0432\u0441\u0435 \u0442\u0440\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u0443\u0439\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c. \u042d\u0442\u043e \u2014 \u043f\u043b\u043e\u0445\u043e, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0441\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u043b\u0438\u0431\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0432 \u043f\u0430\u0447\u043a\u0443 \u0438 \u0441\u043b\u0430\u0442\u044c \u0438\u0445 \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.\n", "before_files": [{"content": "from typing import Optional\n\nfrom django.db import transaction\nfrom django.db.models import Count, Q, QuerySet\n\nfrom homework.models import Answer, AnswerCrossCheck\nfrom users.models import User\n\n\nclass AnswerCrossCheckDispatcher:\n    \"\"\"Given a bunch of answers and users, create a cross-check record\n    for each of them, making sure each answer has a user to check\n    and number of answers if equal for each user\n    \"\"\"\n    def __init__(self, answers: QuerySet[Answer], answers_per_user: int = 3):\n        self.answers = Answer.objects.filter(pk__in=[answer.pk for answer in answers])\n        self.users = User.objects.filter(pk__in=[answer.author_id for answer in answers]).order_by('?')\n        self.answers_per_user = answers_per_user\n\n    @transaction.atomic\n    def __call__(self) -> list[AnswerCrossCheck]:\n        crosschecks = list()\n        for user in self.users.iterator():\n            for _ in range(self.answers_per_user):\n                answer = self.get_answer_to_check(user)\n                if answer is not None:\n                    crosschecks.append(\n                        self.give_answer_to_user(answer, user),\n                    )\n\n        return crosschecks\n\n    def get_answer_to_check(self, user: User) -> Optional[Answer]:\n        return self.get_answers_with_crosscheck_count() \\\n            .annotate(already_checking=Count('answercrosscheck', filter=Q(answercrosscheck__checker_id=user.id))) \\\n            .exclude(already_checking__gte=1) \\\n            .exclude(author=user) \\\n            .exclude(do_not_crosscheck=True) \\\n            .order_by('crosscheck_count').first()\n\n    def give_answer_to_user(self, answer: Answer, user: User) -> AnswerCrossCheck:\n        return AnswerCrossCheck.objects.create(answer=answer, checker=user)\n\n    def get_answers_with_crosscheck_count(self) -> QuerySet[Answer]:\n        return self.answers.annotate(\n            crosscheck_count=Count('answercrosscheck', filter=Q(answercrosscheck__checker__in=self.users)),\n        )\n", "path": "src/homework/services/answer_crosscheck_dispatcher.py"}]}