prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  A user must never evaluate him/herself
  In rare cases a user can be participant and contributor in a course (e.g. participating student and tutor for the exercises at the same time).
  The system has to make sure that this user can't answer questions related to him/herself.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `evap/student/views.py`
  Content:
  ```
  1 from django.contrib import messages
  2 from django.core.exceptions import PermissionDenied
  3 from django.db import transaction
  4 from django.shortcuts import get_object_or_404, redirect, render_to_response
  5 from django.template import RequestContext
  6 from django.utils.datastructures import SortedDict
  7 from django.utils.translation import ugettext as _
  8 
  9 from evap.evaluation.auth import login_required
  10 from evap.evaluation.models import Course, Semester
  11 from evap.evaluation.tools import questionnaires_and_contributions
  12 from evap.student.forms import QuestionsForm
  13 from evap.student.tools import make_form_identifier
  14 
  15 from datetime import datetime
  16 
  17 
  18 @login_required
  19 def index(request):
  20     # retrieve all courses, which the user can evaluate at some point
  21     users_courses = Course.objects.filter(
  22             participants=request.user
  23         ).exclude(
  24             voters=request.user
  25         )
  26     # split up into current and future courses
  27     current_courses = users_courses.filter(state='inEvaluation')
  28     future_courses = users_courses.filter(state='approved')
  29 
  30     return render_to_response(
  31         "student_index.html",
  32         dict(current_courses=current_courses,
  33              future_courses=future_courses),
  34         context_instance=RequestContext(request))
  35 
  36 
  37 @login_required
  38 def vote(request, course_id):
  39     # retrieve course and make sure that the user is allowed to vote
  40     course = get_object_or_404(Course, id=course_id)
  41     if not course.can_user_vote(request.user):
  42         raise PermissionDenied
  43 
  44     # build forms
  45     forms = SortedDict()
  46     for questionnaire, contribution in questionnaires_and_contributions(course):
  47         form = QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire)
  48         forms[(contribution, questionnaire)] = form
  49 
  50     if all(form.is_valid() for form in forms.values()):
  51         # begin vote operation
  52         with transaction.commit_on_success():
  53             for (contribution, questionnaire), form in forms.items():
  54                 for question in questionnaire.question_set.all():
  55                     identifier = make_form_identifier(contribution, questionnaire, question)
  56                     value = form.cleaned_data.get(identifier)
  57 
  58                     if type(value) in [str, unicode]:
  59                         value = value.strip()
  60 
  61                     if value == 6: #no answer
  62                         value = None
  63 
  64                     # store the answer if one was given
  65                     if value:
  66                         question.answer_class.objects.create(
  67                             contribution=contribution,
  68                             question=question,
  69                             answer=value)
  70 
  71             # remember that the user voted already
  72             course.voters.add(request.user)
  73 
  74         messages.add_message(request, messages.INFO, _("Your vote was recorded."))
  75         return redirect('evap.student.views.index')
  76     else:
  77         return render_to_response(
  78             "student_vote.html",
  79             dict(forms=forms.values(),
  80                  course=course),
  81             context_instance=RequestContext(request))
  82
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/evap/student/views.py b/evap/student/views.py
  --- a/evap/student/views.py
  +++ b/evap/student/views.py
  @@ -45,6 +45,8 @@
       forms = SortedDict()
       for questionnaire, contribution in questionnaires_and_contributions(course):
           form = QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire)
  +        if form.contribution.contributor == request.user:
  +            continue # users shall not vote about themselves
           forms[(contribution, questionnaire)] = form
   
       if all(form.is_valid() for form in forms.values()):
  
verification_info: {"golden_diff": "diff --git a/evap/student/views.py b/evap/student/views.py\n--- a/evap/student/views.py\n+++ b/evap/student/views.py\n@@ -45,6 +45,8 @@\n     forms = SortedDict()\n     for questionnaire, contribution in questionnaires_and_contributions(course):\n         form = QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire)\n+        if form.contribution.contributor == request.user:\n+            continue # users shall not vote about themselves\n         forms[(contribution, questionnaire)] = form\n \n     if all(form.is_valid() for form in forms.values()):\n", "issue": "A user must never evaluate him/herself\nIn rare cases a user can be participant and contributor in a course (e.g. participating student and tutor for the exercises at the same time).\nThe system has to make sure that this user can't answer questions related to him/herself.\n\n", "before_files": [{"content": "from django.contrib import messages\nfrom django.core.exceptions import PermissionDenied\nfrom django.db import transaction\nfrom django.shortcuts import get_object_or_404, redirect, render_to_response\nfrom django.template import RequestContext\nfrom django.utils.datastructures import SortedDict\nfrom django.utils.translation import ugettext as _\n\nfrom evap.evaluation.auth import login_required\nfrom evap.evaluation.models import Course, Semester\nfrom evap.evaluation.tools import questionnaires_and_contributions\nfrom evap.student.forms import QuestionsForm\nfrom evap.student.tools import make_form_identifier\n\nfrom datetime import datetime\n\n\n@login_required\ndef index(request):\n    # retrieve all courses, which the user can evaluate at some point\n    users_courses = Course.objects.filter(\n            participants=request.user\n        ).exclude(\n            voters=request.user\n        )\n    # split up into current and future courses\n    current_courses = users_courses.filter(state='inEvaluation')\n    future_courses = users_courses.filter(state='approved')\n\n    return render_to_response(\n        \"student_index.html\",\n        dict(current_courses=current_courses,\n             future_courses=future_courses),\n        context_instance=RequestContext(request))\n\n\n@login_required\ndef vote(request, course_id):\n    # retrieve course and make sure that the user is allowed to vote\n    course = get_object_or_404(Course, id=course_id)\n    if not course.can_user_vote(request.user):\n        raise PermissionDenied\n\n    # build forms\n    forms = SortedDict()\n    for questionnaire, contribution in questionnaires_and_contributions(course):\n        form = QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire)\n        forms[(contribution, questionnaire)] = form\n\n    if all(form.is_valid() for form in forms.values()):\n        # begin vote operation\n        with transaction.commit_on_success():\n            for (contribution, questionnaire), form in forms.items():\n                for question in questionnaire.question_set.all():\n                    identifier = make_form_identifier(contribution, questionnaire, question)\n                    value = form.cleaned_data.get(identifier)\n\n                    if type(value) in [str, unicode]:\n                        value = value.strip()\n\n                    if value == 6: #no answer\n                        value = None\n\n                    # store the answer if one was given\n                    if value:\n                        question.answer_class.objects.create(\n                            contribution=contribution,\n                            question=question,\n                            answer=value)\n\n            # remember that the user voted already\n            course.voters.add(request.user)\n\n        messages.add_message(request, messages.INFO, _(\"Your vote was recorded.\"))\n        return redirect('evap.student.views.index')\n    else:\n        return render_to_response(\n            \"student_vote.html\",\n            dict(forms=forms.values(),\n                 course=course),\n            context_instance=RequestContext(request))\n", "path": "evap/student/views.py"}], "after_files": [{"content": "from django.contrib import messages\nfrom django.core.exceptions import PermissionDenied\nfrom django.db import transaction\nfrom django.shortcuts import get_object_or_404, redirect, render_to_response\nfrom django.template import RequestContext\nfrom django.utils.datastructures import SortedDict\nfrom django.utils.translation import ugettext as _\n\nfrom evap.evaluation.auth import login_required\nfrom evap.evaluation.models import Course, Semester\nfrom evap.evaluation.tools import questionnaires_and_contributions\nfrom evap.student.forms import QuestionsForm\nfrom evap.student.tools import make_form_identifier\n\nfrom datetime import datetime\n\n\n@login_required\ndef index(request):\n    # retrieve all courses, which the user can evaluate at some point\n    users_courses = Course.objects.filter(\n            participants=request.user\n        ).exclude(\n            voters=request.user\n        )\n    # split up into current and future courses\n    current_courses = users_courses.filter(state='inEvaluation')\n    future_courses = users_courses.filter(state='approved')\n\n    return render_to_response(\n        \"student_index.html\",\n        dict(current_courses=current_courses,\n             future_courses=future_courses),\n        context_instance=RequestContext(request))\n\n\n@login_required\ndef vote(request, course_id):\n    # retrieve course and make sure that the user is allowed to vote\n    course = get_object_or_404(Course, id=course_id)\n    if not course.can_user_vote(request.user):\n        raise PermissionDenied\n\n    # build forms\n    forms = SortedDict()\n    for questionnaire, contribution in questionnaires_and_contributions(course):\n        form = QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire)\n        if form.contribution.contributor == request.user:\n            continue # users shall not vote about themselves\n        forms[(contribution, questionnaire)] = form\n\n    if all(form.is_valid() for form in forms.values()):\n        # begin vote operation\n        with transaction.commit_on_success():\n            for (contribution, questionnaire), form in forms.items():\n                for question in questionnaire.question_set.all():\n                    identifier = make_form_identifier(contribution, questionnaire, question)\n                    value = form.cleaned_data.get(identifier)\n\n                    if type(value) in [str, unicode]:\n                        value = value.strip()\n\n                    if value == 6: #no answer\n                        value = None\n\n                    # store the answer if one was given\n                    if value:\n                        question.answer_class.objects.create(\n                            contribution=contribution,\n                            question=question,\n                            answer=value)\n\n            # remember that the user voted already\n            course.voters.add(request.user)\n\n        messages.add_message(request, messages.INFO, _(\"Your vote was recorded.\"))\n        return redirect('evap.student.views.index')\n    else:\n        return render_to_response(\n            \"student_vote.html\",\n            dict(forms=forms.values(),\n                 course=course),\n            context_instance=RequestContext(request))\n", "path": "evap/student/views.py"}]}