prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Warning in courses with small number of participants
  In courses with 5 or less participants a warning should be shown above the course's questionnaire:
  
  _This course has only a small number of participants. Please remember that your comments will be visible for the responsible person and the contributors you're evaluating. If two or more people evaluate the course, the results of all voting questions will also be published._
  
  
  --- 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
  5 from django.utils.translation import ugettext as _
  6 
  7 from evap.evaluation.auth import participant_required
  8 from evap.evaluation.models import Course, Semester
  9 from evap.evaluation.tools import STUDENT_STATES_ORDERED
  10 
  11 from evap.student.forms import QuestionsForm
  12 from evap.student.tools import make_form_identifier
  13 
  14 from collections import OrderedDict
  15 
  16 @participant_required
  17 def index(request):
  18     # retrieve all courses, where the user is a participant and that are not new
  19     courses = list(set(Course.objects.filter(participants=request.user).exclude(state="new")))
  20     voted_courses = list(set(Course.objects.filter(voters=request.user)))
  21     due_courses = list(set(Course.objects.filter(participants=request.user, state='inEvaluation').exclude(voters=request.user)))
  22 
  23     sorter = lambda course: (list(STUDENT_STATES_ORDERED.keys()).index(course.student_state), course.vote_end_date, course.name)
  24     courses.sort(key=sorter)
  25 
  26     semesters = Semester.objects.all()
  27     semester_list = [dict(semester_name=semester.name, id=semester.id, courses=[course for course in courses if course.semester_id == semester.id]) for semester in semesters]
  28 
  29     template_data = dict(
  30         semester_list=semester_list,
  31         voted_courses=voted_courses,
  32         due_courses=due_courses,
  33         can_download_grades=request.user.can_download_grades,
  34     )
  35     return render(request, "student_index.html", template_data)
  36 
  37 
  38 def vote_preview(request, course):
  39     """
  40         Renders a preview of the voting page for the given course.
  41         Not used by the student app itself, but by staff and contributor.
  42     """
  43     form_groups = helper_create_voting_form_groups(request, course.contributions.all())
  44     course_form_group = form_groups.pop(course.general_contribution)
  45     contributor_form_groups = list((contribution.contributor, contribution.label, form_group, False) for contribution, form_group in form_groups.items())
  46 
  47     template_data = dict(
  48             errors_exist=False,
  49             course_form_group=course_form_group,
  50             contributor_form_groups=contributor_form_groups,
  51             course=course,
  52             preview=True)
  53     return render(request, "student_vote.html", template_data)
  54 
  55 
  56 @participant_required
  57 def vote(request, course_id):
  58     # retrieve course and make sure that the user is allowed to vote
  59     course = get_object_or_404(Course, id=course_id)
  60     if not course.can_user_vote(request.user):
  61         raise PermissionDenied
  62 
  63     # prevent a user from voting on themselves.
  64     contributions_to_vote_on = course.contributions.exclude(contributor=request.user).all()
  65     form_groups = helper_create_voting_form_groups(request, contributions_to_vote_on)
  66 
  67     if not all(all(form.is_valid() for form in form_group) for form_group in form_groups.values()):
  68         errors_exist = any(helper_has_errors(form_group) for form_group in form_groups.values())
  69 
  70         course_form_group = form_groups.pop(course.general_contribution)
  71 
  72         contributor_form_groups = list((contribution.contributor, contribution.label, form_group, helper_has_errors(form_group)) for contribution, form_group in form_groups.items())
  73 
  74         template_data = dict(
  75                 errors_exist=errors_exist,
  76                 course_form_group=course_form_group,
  77                 contributor_form_groups=contributor_form_groups,
  78                 course=course,
  79                 preview=False)
  80         return render(request, "student_vote.html", template_data)
  81 
  82     # all forms are valid, begin vote operation
  83     with transaction.atomic():
  84         for contribution, form_group in form_groups.items():
  85             for questionnaire_form in form_group:
  86                 questionnaire = questionnaire_form.questionnaire
  87                 for question in questionnaire.question_set.all():
  88                     identifier = make_form_identifier(contribution, questionnaire, question)
  89                     value = questionnaire_form.cleaned_data.get(identifier)
  90 
  91                     if question.is_text_question:
  92                         if value:
  93                             question.answer_class.objects.create(
  94                                 contribution=contribution,
  95                                 question=question,
  96                                 answer=value)
  97                     else:
  98                         if value != 6:
  99                             answer_counter, created = question.answer_class.objects.get_or_create(contribution=contribution, question=question, answer=value)
  100                             answer_counter.add_vote()
  101                             answer_counter.save()
  102 
  103         # remember that the user voted already
  104         course.voters.add(request.user)
  105 
  106         course.was_evaluated(request)
  107 
  108     messages.success(request, _("Your vote was recorded."))
  109     return redirect('student:index')
  110 
  111 
  112 def helper_create_form_group(request, contribution):
  113     return list(QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire) for questionnaire in contribution.questionnaires.all())
  114 
  115 def helper_create_voting_form_groups(request, contributions):
  116     form_groups = OrderedDict()
  117     for contribution in contributions:
  118         form_groups[contribution] = helper_create_form_group(request, contribution)
  119     return form_groups
  120 
  121 def helper_has_errors(form_group):
  122     return any(form.errors for form in form_group)
  123
  ```
  --- 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
  @@ -76,6 +76,7 @@
                   course_form_group=course_form_group,
                   contributor_form_groups=contributor_form_groups,
                   course=course,
  +                participants_warning=course.num_participants <= 5,
                   preview=False)
           return render(request, "student_vote.html", template_data)
  
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@@ -76,6 +76,7 @@\n                 course_form_group=course_form_group,\n                 contributor_form_groups=contributor_form_groups,\n                 course=course,\n+                participants_warning=course.num_participants <= 5,\n                 preview=False)\n         return render(request, \"student_vote.html\", template_data)\n", "issue": "Warning in courses with small number of participants\nIn courses with 5 or less participants a warning should be shown above the course's questionnaire:\n\n_This course has only a small number of participants. Please remember that your comments will be visible for the responsible person and the contributors you're evaluating. If two or more people evaluate the course, the results of all voting questions will also be published._\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\nfrom django.utils.translation import ugettext as _\n\nfrom evap.evaluation.auth import participant_required\nfrom evap.evaluation.models import Course, Semester\nfrom evap.evaluation.tools import STUDENT_STATES_ORDERED\n\nfrom evap.student.forms import QuestionsForm\nfrom evap.student.tools import make_form_identifier\n\nfrom collections import OrderedDict\n\n@participant_required\ndef index(request):\n    # retrieve all courses, where the user is a participant and that are not new\n    courses = list(set(Course.objects.filter(participants=request.user).exclude(state=\"new\")))\n    voted_courses = list(set(Course.objects.filter(voters=request.user)))\n    due_courses = list(set(Course.objects.filter(participants=request.user, state='inEvaluation').exclude(voters=request.user)))\n\n    sorter = lambda course: (list(STUDENT_STATES_ORDERED.keys()).index(course.student_state), course.vote_end_date, course.name)\n    courses.sort(key=sorter)\n\n    semesters = Semester.objects.all()\n    semester_list = [dict(semester_name=semester.name, id=semester.id, courses=[course for course in courses if course.semester_id == semester.id]) for semester in semesters]\n\n    template_data = dict(\n        semester_list=semester_list,\n        voted_courses=voted_courses,\n        due_courses=due_courses,\n        can_download_grades=request.user.can_download_grades,\n    )\n    return render(request, \"student_index.html\", template_data)\n\n\ndef vote_preview(request, course):\n    \"\"\"\n        Renders a preview of the voting page for the given course.\n        Not used by the student app itself, but by staff and contributor.\n    \"\"\"\n    form_groups = helper_create_voting_form_groups(request, course.contributions.all())\n    course_form_group = form_groups.pop(course.general_contribution)\n    contributor_form_groups = list((contribution.contributor, contribution.label, form_group, False) for contribution, form_group in form_groups.items())\n\n    template_data = dict(\n            errors_exist=False,\n            course_form_group=course_form_group,\n            contributor_form_groups=contributor_form_groups,\n            course=course,\n            preview=True)\n    return render(request, \"student_vote.html\", template_data)\n\n\n@participant_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    # prevent a user from voting on themselves.\n    contributions_to_vote_on = course.contributions.exclude(contributor=request.user).all()\n    form_groups = helper_create_voting_form_groups(request, contributions_to_vote_on)\n\n    if not all(all(form.is_valid() for form in form_group) for form_group in form_groups.values()):\n        errors_exist = any(helper_has_errors(form_group) for form_group in form_groups.values())\n\n        course_form_group = form_groups.pop(course.general_contribution)\n\n        contributor_form_groups = list((contribution.contributor, contribution.label, form_group, helper_has_errors(form_group)) for contribution, form_group in form_groups.items())\n\n        template_data = dict(\n                errors_exist=errors_exist,\n                course_form_group=course_form_group,\n                contributor_form_groups=contributor_form_groups,\n                course=course,\n                preview=False)\n        return render(request, \"student_vote.html\", template_data)\n\n    # all forms are valid, begin vote operation\n    with transaction.atomic():\n        for contribution, form_group in form_groups.items():\n            for questionnaire_form in form_group:\n                questionnaire = questionnaire_form.questionnaire\n                for question in questionnaire.question_set.all():\n                    identifier = make_form_identifier(contribution, questionnaire, question)\n                    value = questionnaire_form.cleaned_data.get(identifier)\n\n                    if question.is_text_question:\n                        if value:\n                            question.answer_class.objects.create(\n                                contribution=contribution,\n                                question=question,\n                                answer=value)\n                    else:\n                        if value != 6:\n                            answer_counter, created = question.answer_class.objects.get_or_create(contribution=contribution, question=question, answer=value)\n                            answer_counter.add_vote()\n                            answer_counter.save()\n\n        # remember that the user voted already\n        course.voters.add(request.user)\n\n        course.was_evaluated(request)\n\n    messages.success(request, _(\"Your vote was recorded.\"))\n    return redirect('student:index')\n\n\ndef helper_create_form_group(request, contribution):\n    return list(QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire) for questionnaire in contribution.questionnaires.all())\n\ndef helper_create_voting_form_groups(request, contributions):\n    form_groups = OrderedDict()\n    for contribution in contributions:\n        form_groups[contribution] = helper_create_form_group(request, contribution)\n    return form_groups\n\ndef helper_has_errors(form_group):\n    return any(form.errors for form in form_group)\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\nfrom django.utils.translation import ugettext as _\n\nfrom evap.evaluation.auth import participant_required\nfrom evap.evaluation.models import Course, Semester\nfrom evap.evaluation.tools import STUDENT_STATES_ORDERED\n\nfrom evap.student.forms import QuestionsForm\nfrom evap.student.tools import make_form_identifier\n\nfrom collections import OrderedDict\n\n@participant_required\ndef index(request):\n    # retrieve all courses, where the user is a participant and that are not new\n    courses = list(set(Course.objects.filter(participants=request.user).exclude(state=\"new\")))\n    voted_courses = list(set(Course.objects.filter(voters=request.user)))\n    due_courses = list(set(Course.objects.filter(participants=request.user, state='inEvaluation').exclude(voters=request.user)))\n\n    sorter = lambda course: (list(STUDENT_STATES_ORDERED.keys()).index(course.student_state), course.vote_end_date, course.name)\n    courses.sort(key=sorter)\n\n    semesters = Semester.objects.all()\n    semester_list = [dict(semester_name=semester.name, id=semester.id, courses=[course for course in courses if course.semester_id == semester.id]) for semester in semesters]\n\n    template_data = dict(\n        semester_list=semester_list,\n        voted_courses=voted_courses,\n        due_courses=due_courses,\n        can_download_grades=request.user.can_download_grades,\n    )\n    return render(request, \"student_index.html\", template_data)\n\n\ndef vote_preview(request, course):\n    \"\"\"\n        Renders a preview of the voting page for the given course.\n        Not used by the student app itself, but by staff and contributor.\n    \"\"\"\n    form_groups = helper_create_voting_form_groups(request, course.contributions.all())\n    course_form_group = form_groups.pop(course.general_contribution)\n    contributor_form_groups = list((contribution.contributor, contribution.label, form_group, False) for contribution, form_group in form_groups.items())\n\n    template_data = dict(\n            errors_exist=False,\n            course_form_group=course_form_group,\n            contributor_form_groups=contributor_form_groups,\n            course=course,\n            preview=True)\n    return render(request, \"student_vote.html\", template_data)\n\n\n@participant_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    # prevent a user from voting on themselves.\n    contributions_to_vote_on = course.contributions.exclude(contributor=request.user).all()\n    form_groups = helper_create_voting_form_groups(request, contributions_to_vote_on)\n\n    if not all(all(form.is_valid() for form in form_group) for form_group in form_groups.values()):\n        errors_exist = any(helper_has_errors(form_group) for form_group in form_groups.values())\n\n        course_form_group = form_groups.pop(course.general_contribution)\n\n        contributor_form_groups = list((contribution.contributor, contribution.label, form_group, helper_has_errors(form_group)) for contribution, form_group in form_groups.items())\n\n        template_data = dict(\n                errors_exist=errors_exist,\n                course_form_group=course_form_group,\n                contributor_form_groups=contributor_form_groups,\n                course=course,\n                participants_warning=course.num_participants <= 5,\n                preview=False)\n        return render(request, \"student_vote.html\", template_data)\n\n    # all forms are valid, begin vote operation\n    with transaction.atomic():\n        for contribution, form_group in form_groups.items():\n            for questionnaire_form in form_group:\n                questionnaire = questionnaire_form.questionnaire\n                for question in questionnaire.question_set.all():\n                    identifier = make_form_identifier(contribution, questionnaire, question)\n                    value = questionnaire_form.cleaned_data.get(identifier)\n\n                    if question.is_text_question:\n                        if value:\n                            question.answer_class.objects.create(\n                                contribution=contribution,\n                                question=question,\n                                answer=value)\n                    else:\n                        if value != 6:\n                            answer_counter, created = question.answer_class.objects.get_or_create(contribution=contribution, question=question, answer=value)\n                            answer_counter.add_vote()\n                            answer_counter.save()\n\n        # remember that the user voted already\n        course.voters.add(request.user)\n\n        course.was_evaluated(request)\n\n    messages.success(request, _(\"Your vote was recorded.\"))\n    return redirect('student:index')\n\n\ndef helper_create_form_group(request, contribution):\n    return list(QuestionsForm(request.POST or None, contribution=contribution, questionnaire=questionnaire) for questionnaire in contribution.questionnaires.all())\n\ndef helper_create_voting_form_groups(request, contributions):\n    form_groups = OrderedDict()\n    for contribution in contributions:\n        form_groups[contribution] = helper_create_form_group(request, contribution)\n    return form_groups\n\ndef helper_has_errors(form_group):\n    return any(form.errors for form in form_group)\n", "path": "evap/student/views.py"}]}