def METHOD_NAME(request, pk):
    if QUIZREPLIES_SESSIONKEY not in request.session:
        # This entry in the session is created when the user starts the quiz.
        # Could be missing if the users session is invalidated while they are
        # taking the quiz, or there is foul play.
        messages.info(
            request, "Beklager, det har oppstått en feil. (Brukte du for lang tid?)"
        )
        return redirect("/quiz")
    quiz_reply_id = request.POST.get("quiz_reply_id")
    if quiz_reply_id not in request.session[QUIZREPLIES_SESSIONKEY]:
        # The quiz reply id submitted with the POST request is invalid.
        # Most likely foul play.
        messages.info(request, "Beklager, det har oppstått en feil.")
        return redirect("/quiz")
    # Get the start-time of the submitted quizreply
    starttimestring = request.session[QUIZREPLIES_SESSIONKEY][quiz_reply_id]
    # Converted to a datetime
    startdatetime = datetime.strptime(starttimestring, DATE_FORMAT)
    # Remove the id and mark the session as modified
    del request.session[QUIZREPLIES_SESSIONKEY][quiz_reply_id]
    request.session.modified = True
    quiz = get_object_or_404(Quiz, id=pk)
    questions = quiz.questions.all()
    answers = (request.POST.get(f"{q.id}_alternative") for q in questions)
    q_and_a = [
        (q, int(answer)) for q, answer in zip(questions, answers) if answer is not None
    ]
    if len(q_and_a) == 0:
        # User didn't answer any questions -> deny the reply
        messages.info(request, "Du må svare på minst ett spørsmål!")
        return redirect("/quiz")
    # Create the reply
    reply = QuizReply.objects.create(
        user=request.user,
        scoreboard=quiz.scoreboard,
        start=startdatetime,
        when=startdatetime,
    )
    try:
        reply.add_question_replies(q_and_a)
    except QuizReplyTimeout:
        messages.info(request, "Beklager, tiden gikk ut")
        return redirect("/")
    else:
        reply.save()
    messages.info(request, f"Du svarte på {len(q_and_a)} av {len(questions)} spørsmål.")
    return redirect(reply.get_absolute_url())