from django.shortcuts import render, redirect, get_object_or_404
from student_info.models import Student
import time

# Create your views here.

def q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.timespent = time.perf_counter()
    student.save(update_fields=['timespent'])
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q1_P.mp3",
        "choice1": "c",
        "choice2": "d",
        "choice3": "p",
        "answer": 3,
        "currentPage": "q1",
        "nextPage": "q2",
        "correctPage": "y_upd_q1",
        "incorrectPage": "upd_q1"
    }
    return render(request, 'exam1.html', my_context)


def q2(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q2_F.mp3",
        "choice1": "s",
        "choice2": "f",
        "choice3": "l",
        "answer": 2,
        "currentPage": "q2",
        "correctPage": "y_upd_q2",
        "incorrectPage": "upd_q2"
    }
    return render(request, 'exam1.html', my_context)


def q3(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q3_N.mp3",
        "choice1": "n",
        "choice2": "m",
        "choice3": "p",
        "answer": 1,
        "currentPage": "q3",
        "nextPage": "q4",
        "correctPage": "y_upd_q3",
        "incorrectPage": "upd_q3"
    }
    return render(request, 'exam1.html', my_context)
def q4(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q4_T.mp3",
        "choice1": "t",
        "choice2": "l",
        "choice3": "d",
        "answer": 1,
        "currentPage": "q4",
        "nextPage": "q5",
        "correctPage": "y_upd_q4",
        "incorrectPage": "upd_q4"
    }
    return render(request, 'exam1.html', my_context)
def q5(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q5_A.mp3",
        "choice1": "a",
        "choice2": "e",
        "choice3": "o",
        "answer": 1,
        "currentPage": "q5",
        "nextPage": "q6",
        "correctPage": "y_upd_q5",
        "incorrectPage": "upd_q5"
    }
    return render(request, 'exam1.html', my_context)
def q6(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q6_S.mp3",
        "choice1": "c",
        "choice2": "h",
        "choice3": "s",
        "answer": 3,
        "currentPage": "q6",
        "nextPage": "q7",
        "correctPage": "y_upd_q6",
        "incorrectPage": "upd_q6"
    }
    return render(request, 'exam1.html', my_context)
def q7(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q7_R.mp3",
        "choice1": "j",
        "choice2": "r",
        "choice3": "g",
        "answer": 2,
        "currentPage": "q7",
        "correctPage": "y_upd_q7",
        "incorrectPage": "upd_q7"
    }
    return render(request, 'exam1.html', my_context)
def q8(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q8_C.mp3",
        "choice1": "d",
        "choice2": "c",
        "choice3": "g",
        "answer": 2,
        "currentPage": "q8",
        "correctPage": "y_upd_q8",
        "incorrectPage": "upd_q8"
    }
    return render(request, 'exam1.html', my_context)
def q9(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q9_K.mp3",
        "choice1": "l",
        "choice2": "k",
        "choice3": "g",
        "answer": 2,
        "currentPage": "q9",
        "correctPage": "y_upd_q9",
        "incorrectPage": "upd_q9"
    }
    return render(request, 'exam1.html', my_context)
def q10(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q10_E.mp3",
        "choice1": "a",
        "choice2": "e",
        "choice3": "c",
        "answer": 2,
        "currentPage": "q10",
        "correctPage": "y_upd_q10",
        "incorrectPage": "upd_q10"
    }
    return render(request, 'exam1.html', my_context)
def q11(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q11_B.mp3",
        "choice1": "b",
        "choice2": "d",
        "choice3": "p",
        "answer": 1,
        "currentPage": "q11",
        "nextPage": "q12",
        "correctPage": "y_upd_q11",
        "incorrectPage": "upd_q11"
    }
    return render(request, 'exam1.html', my_context)
def q12(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q12_G.mp3",
        "choice1": "c",
        "choice2": "a",
        "choice3": "g",
        "answer": 3,
        "currentPage": "q12",
        "correctPage": "y_upd_q12",
        "incorrectPage": "upd_q12"
    }
    return render(request, 'exam1.html', my_context)
def q13(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q13_M.mp3",
        "choice1": "n",
        "choice2": "u",
        "choice3": "m",
        "answer": 3,
        "currentPage": "q13",
        "correctPage": "y_upd_q13",
        "incorrectPage": "upd_q13"
    }
    return render(request, 'exam1.html', my_context)
def q14(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q14_L.mp3",
        "choice1": "l",
        "choice2": "h",
        "choice3": "j",
        "answer": 1,
        "currentPage": "q14",
        "correctPage": "y_upd_q14",
        "incorrectPage": "upd_q14"
    }
    return render(request, 'exam1.html', my_context)
def q15(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q15_I.mp3",
        "choice1": "o",
        "choice2": "a",
        "choice3": "i",
        "answer": 3,
        "currentPage": "q15",
        "correctPage": "y_upd_q15",
        "incorrectPage": "upd_q15"
    }
    return render(request, 'exam1.html', my_context)
def q16(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q16_D.mp3",
        "choice1": "d",
        "choice2": "b",
        "choice3": "c",
        "answer": 1,
        "currentPage": "q16",
        "correctPage": "y_upd_q16",
        "incorrectPage": "upd_q16"
    }
    return render(request, 'exam1.html', my_context)
def q17(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q17_V.mp3",
        "choice1": "w",
        "choice2": "x",
        "choice3": "v",
        "answer": 3,
        "currentPage": "q17",
        "correctPage": "y_upd_q17",
        "incorrectPage": "upd_q17"
    }
    return render(request, 'exam1.html', my_context)
def q18(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q18_J.mp3",
        "choice1": "j",
        "choice2": "l",
        "choice3": "k",
        "answer": 1,
        "currentPage": "q18",
        "correctPage": "y_upd_q18",
        "incorrectPage": "upd_q18"
    }
    return render(request, 'exam1.html', my_context)
def q19(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q19_H.mp3",
        "choice1": "b",
        "choice2": "d",
        "choice3": "h",
        "answer": 3,
        "currentPage": "q19",
        "correctPage": "y_upd_q19",
        "incorrectPage": "upd_q19"
    }
    return render(request, 'exam1.html', my_context)
def q20(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q20_O.mp3",
        "choice1": "a",
        "choice2": "o",
        "choice3": "c",
        "answer": 2,
        "currentPage": "q20",
        "correctPage": "y_upd_q20",
        "incorrectPage": "upd_q20"
    }
    return render(request, 'exam1.html', my_context)
def q21(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q21_Q.mp3",
        "choice1": "q",
        "choice2": "p",
        "choice3": "d",
        "answer": 1,
        "currentPage": "q21",
        "correctPage": "y_upd_q21",
        "incorrectPage": "upd_q21"
    }
    return render(request, 'exam1.html', my_context)
def q22(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q22_W.mp3",
        "choice1": "v",
        "choice2": "w",
        "choice3": "y",
        "answer": 2,
        "currentPage": "q22",
        "correctPage": "y_upd_q22",
        "incorrectPage": "upd_q22"
    }
    return render(request, 'exam1.html', my_context)
def q23(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q23_X.mp3",
        "choice1": "f",
        "choice2": "x",
        "choice3": "q",
        "answer": 2,
        "currentPage": "q23",
        "correctPage": "y_upd_q23",
        "incorrectPage": "upd_q23"
    }
    return render(request, 'exam1.html', my_context)
def q24(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q24_Y.mp3",
        "choice1": "i",
        "choice2": "c",
        "choice3": "y",
        "answer": 3,
        "currentPage": "q24",
        "correctPage": "y_upd_q24",
        "incorrectPage": "upd_q24"
    }
    return render(request, 'exam1.html', my_context)
def q25(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q25_Z.mp3",
        "choice1": "z",
        "choice2": "d",
        "choice3": "e",
        "answer": 1,
        "currentPage": "q25",
        "correctPage": "y_upd_q25",
        "incorrectPage": "upd_q25"
    }
    return render(request, 'exam1.html', my_context)
def q26(request, pk):
    my_context = {
        "student_pk": pk,
        "questionPromptPath": "promptaudio/part1/P1_Q26_U.mp3",
        "choice1": "u",
        "choice2": "a",
        "choice3": "o",
        "answer": 1,
        "currentPage": "q26",
        "correctPage": "y_upd_q26",
        "incorrectPage": "upd_q26"
    }
    return render(request, 'exam1.html', my_context)
def p2q1(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "p",
        "questionPromptPath": "promptaudio/part2/P2_Q1_P.mp3",
        "choice1AudioPath": "answeraudio/letters/C.mp3",
        "choice2AudioPath": "answeraudio/letters/D.mp3",
        "choice3AudioPath": "answeraudio/letters/P.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q1",
        "correctPage": "y_upd_p2q1",
        "incorrectPage": "upd_p2q1"
    }
    return render(request, 'exam2.html', my_context)
def p2q2(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "f",
        "questionPromptPath": "promptaudio/part2/P2_Q2_F.mp3",
        "choice1AudioPath": "answeraudio/letters/S.mp3",
        "choice2AudioPath": "answeraudio/letters/F.mp3",
        "choice3AudioPath": "answeraudio/letters/L.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q2",
        "correctPage": "y_upd_p2q2",
        "incorrectPage": "upd_p2q2"
    }
    return render(request, 'exam2.html', my_context)
def p2q3(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "n",
        "questionPromptPath": "promptaudio/part2/P2_Q3_N.mp3",
        "choice1AudioPath": "answeraudio/letters/N.mp3",
        "choice2AudioPath": "answeraudio/letters/M.mp3",
        "choice3AudioPath": "answeraudio/letters/P.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q3",
        "correctPage": "y_upd_p2q3",
        "incorrectPage": "upd_p2q3"
    }
    return render(request, 'exam2.html', my_context)
def p2q4(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "t",
        "questionPromptPath": "promptaudio/part2/P2_Q4_T.mp3",
        "choice1AudioPath": "answeraudio/letters/T.mp3",
        "choice2AudioPath": "answeraudio/letters/L.mp3",
        "choice3AudioPath": "answeraudio/letters/D.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q4",
        "correctPage": "y_upd_p2q4",
        "incorrectPage": "upd_p2q4"
    }
    return render(request, 'exam2.html', my_context)
def p2q5(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "a",
        "questionPromptPath": "promptaudio/part2/P2_Q5_A.mp3",
        "choice1AudioPath": "answeraudio/letters/A.mp3",
        "choice2AudioPath": "answeraudio/letters/E.mp3",
        "choice3AudioPath": "answeraudio/letters/O.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q5",
        "correctPage": "y_upd_p2q5",
        "incorrectPage": "upd_p2q5"
    }
    return render(request, 'exam2.html', my_context)
def p2q6(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "s",
        "questionPromptPath": "promptaudio/part2/P2_Q6_S.mp3",
        "choice1AudioPath": "answeraudio/letters/C.mp3",
        "choice2AudioPath": "answeraudio/letters/H.mp3",
        "choice3AudioPath": "answeraudio/letters/S.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q6",
        "correctPage": "y_upd_p2q6",
        "incorrectPage": "upd_p2q6"
    }
    return render(request, 'exam2.html', my_context)
def p2q7(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "r",
        "questionPromptPath": "promptaudio/part2/P2_Q7_R.mp3",
        "choice1AudioPath": "answeraudio/letters/J.mp3",
        "choice2AudioPath": "answeraudio/letters/R.mp3",
        "choice3AudioPath": "answeraudio/letters/G.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q7",
        "correctPage": "y_upd_p2q7",
        "incorrectPage": "upd_p2q7"
    }
    return render(request, 'exam2.html', my_context)
def p2q8(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "c",
        "questionPromptPath": "promptaudio/part2/P2_Q8_C.mp3",
        "choice1AudioPath": "answeraudio/letters/D.mp3",
        "choice2AudioPath": "answeraudio/letters/C.mp3",
        "choice3AudioPath": "answeraudio/letters/G.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q8",
        "correctPage": "y_upd_p2q8",
        "incorrectPage": "upd_p2q8"
    }
    return render(request, 'exam2.html', my_context)
def p2q9(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "k",
        "questionPromptPath": "promptaudio/part2/P2_Q9_K.mp3",
        "choice1AudioPath": "answeraudio/letters/L.mp3",
        "choice2AudioPath": "answeraudio/letters/K.mp3",
        "choice3AudioPath": "answeraudio/letters/G.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q9",
        "correctPage": "y_upd_p2q9",
        "incorrectPage": "upd_p2q9"
    }
    return render(request, 'exam2.html', my_context)
def p2q10(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "e",
        "questionPromptPath": "promptaudio/part2/P2_Q10_E.mp3",
        "choice1AudioPath": "answeraudio/letters/A.mp3",
        "choice2AudioPath": "answeraudio/letters/E.mp3",
        "choice3AudioPath": "answeraudio/letters/C.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q10",
        "correctPage": "y_upd_p2q10",
        "incorrectPage": "upd_p2q10"
    }
    return render(request, 'exam2.html', my_context)
def p2q11(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "b",
        "questionPromptPath": "promptaudio/part2/P2_Q11_B.mp3",
        "choice1AudioPath": "answeraudio/letters/B.mp3",
        "choice2AudioPath": "answeraudio/letters/D.mp3",
        "choice3AudioPath": "answeraudio/letters/P.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q11",
        "correctPage": "y_upd_p2q11",
        "incorrectPage": "upd_p2q11"
    }
    return render(request, 'exam2.html', my_context)
def p2q12(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "g",
        "questionPromptPath": "promptaudio/part2/P2_Q12_G.mp3",
        "choice1AudioPath": "answeraudio/letters/C.mp3",
        "choice2AudioPath": "answeraudio/letters/A.mp3",
        "choice3AudioPath": "answeraudio/letters/G.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q12",
        "correctPage": "y_upd_p2q12",
        "incorrectPage": "upd_p2q12"
    }
    return render(request, 'exam2.html', my_context)
def p2q13(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "m",
        "questionPromptPath": "promptaudio/part2/P2_Q13_M.mp3",
        "choice1AudioPath": "answeraudio/letters/N.mp3",
        "choice2AudioPath": "answeraudio/letters/U.mp3",
        "choice3AudioPath": "answeraudio/letters/M.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q13",
        "correctPage": "y_upd_p2q13",
        "incorrectPage": "upd_p2q13"
    }
    return render(request, 'exam2.html', my_context)
def p2q14(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "l",
        "questionPromptPath": "promptaudio/part2/P2_Q14_L.mp3",
        "choice1AudioPath": "answeraudio/letters/L.mp3",
        "choice2AudioPath": "answeraudio/letters/H.mp3",
        "choice3AudioPath": "answeraudio/letters/J.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q14",
        "correctPage": "y_upd_p2q14",
        "incorrectPage": "upd_p2q14"
    }
    return render(request, 'exam2.html', my_context)
def p2q15(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "i",
        "questionPromptPath": "promptaudio/part2/P2_Q15_I.mp3",
        "choice1AudioPath": "answeraudio/letters/O.mp3",
        "choice2AudioPath": "answeraudio/letters/A.mp3",
        "choice3AudioPath": "answeraudio/letters/I.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q15",
        "correctPage": "y_upd_p2q15",
        "incorrectPage": "upd_p2q15"
    }
    return render(request, 'exam2.html', my_context)
def p2q16(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "d",
        "questionPromptPath": "promptaudio/part2/P2_Q16_D.mp3",
        "choice1AudioPath": "answeraudio/letters/D.mp3",
        "choice2AudioPath": "answeraudio/letters/B.mp3",
        "choice3AudioPath": "answeraudio/letters/C.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q16",
        "correctPage": "y_upd_p2q16",
        "incorrectPage": "upd_p2q16"
    }
    return render(request, 'exam2.html', my_context)
def p2q17(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "v",
        "questionPromptPath": "promptaudio/part2/P2_Q17_V.mp3",
        "choice1AudioPath": "answeraudio/letters/W.mp3",
        "choice2AudioPath": "answeraudio/letters/X.mp3",
        "choice3AudioPath": "answeraudio/letters/V.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q17",
        "correctPage": "y_upd_p2q17",
        "incorrectPage": "upd_p2q17"
    }
    return render(request, 'exam2.html', my_context)
def p2q18(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "j",
        "questionPromptPath": "promptaudio/part2/P2_Q18_J.mp3",
        "choice1AudioPath": "answeraudio/letters/J.mp3",
        "choice2AudioPath": "answeraudio/letters/L.mp3",
        "choice3AudioPath": "answeraudio/letters/K.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q18",
        "correctPage": "y_upd_p2q18",
        "incorrectPage": "upd_p2q18"
    }
    return render(request, 'exam2.html', my_context)
def p2q19(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "h",
        "questionPromptPath": "promptaudio/part2/P2_Q19_H.mp3",
        "choice1AudioPath": "answeraudio/letters/B.mp3",
        "choice2AudioPath": "answeraudio/letters/D.mp3",
        "choice3AudioPath": "answeraudio/letters/H.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q19",
        "correctPage": "y_upd_p2q19",
        "incorrectPage": "upd_p2q19"
    }
    return render(request, 'exam2.html', my_context)
def p2q20(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "0",
        "questionPromptPath": "promptaudio/part2/P2_Q20_O.mp3",
        "choice1AudioPath": "answeraudio/letters/A.mp3",
        "choice2AudioPath": "answeraudio/letters/O.mp3",
        "choice3AudioPath": "answeraudio/letters/C.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q20",
        "correctPage": "y_upd_p2q20",
        "incorrectPage": "upd_p2q20"
    }
    return render(request, 'exam2.html', my_context)
def p2q21(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "q",
        "questionPromptPath": "promptaudio/part2/P2_Q21_Q.mp3",
        "choice1AudioPath": "answeraudio/letters/Q.mp3",
        "choice2AudioPath": "answeraudio/letters/P.mp3",
        "choice3AudioPath": "answeraudio/letters/D.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q21",
        "correctPage": "y_upd_p2q21",
        "incorrectPage": "upd_p2q21"
    }
    return render(request, 'exam2.html', my_context)
def p2q22(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "w",
        "questionPromptPath": "promptaudio/part2/P2_Q22_W.mp3",
        "choice1AudioPath": "answeraudio/letters/V.mp3",
        "choice2AudioPath": "answeraudio/letters/W.mp3",
        "choice3AudioPath": "answeraudio/letters/Y.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q22",
        "correctPage": "y_upd_p2q22",
        "incorrectPage": "upd_p2q22"
    }
    return render(request, 'exam2.html', my_context)
def p2q23(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "x",
        "questionPromptPath": "promptaudio/part2/P2_Q23_X.mp3",
        "choice1AudioPath": "answeraudio/letters/F.mp3",
        "choice2AudioPath": "answeraudio/letters/X.mp3",
        "choice3AudioPath": "answeraudio/letters/Q.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q23",
        "correctPage": "y_upd_p2q23",
        "incorrectPage": "upd_p2q23"
    }
    return render(request, 'exam2.html', my_context)
def p2q24(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "y",
        "questionPromptPath": "promptaudio/part2/P2_Q24_Y.mp3",
        "choice1AudioPath": "answeraudio/letters/I.mp3",
        "choice2AudioPath": "answeraudio/letters/C.mp3",
        "choice3AudioPath": "answeraudio/letters/Y.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q24",
        "correctPage": "y_upd_p2q24",
        "incorrectPage": "upd_p2q24"
    }
    return render(request, 'exam2.html', my_context)
def p2q25(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "z",
        "questionPromptPath": "promptaudio/part2/P2_Q25_Z.mp3",
        "choice1AudioPath": "answeraudio/letters/Z.mp3",
        "choice2AudioPath": "answeraudio/letters/D.mp3",
        "choice3AudioPath": "answeraudio/letters/E.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q25",
        "correctPage": "y_upd_p2q25",
        "incorrectPage": "upd_p2q25"
    }
    return render(request, 'exam2.html', my_context)
def p2q26(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "u",
        "questionPromptPath": "promptaudio/part2/P2_Q26_U.mp3",
        "choice1AudioPath": "answeraudio/letters/U.mp3",
        "choice2AudioPath": "answeraudio/letters/A.mp3",
        "choice3AudioPath": "answeraudio/letters/O.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q26",
        "correctPage": "y_upd_p2q26",
        "incorrectPage": "upd_p2q26"
    }
    return render(request, 'exam2.html', my_context)
def p2q27(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "ch",
        "questionPromptPath": "promptaudio/part2/P2_Q27_CH.mp3",
        "choice1AudioPath": "answeraudio/letters/SH.mp3",
        "choice2AudioPath": "answeraudio/letters/TH.mp3",
        "choice3AudioPath": "answeraudio/letters/CH.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p2q27",
        "correctPage": "y_upd_p2q27",
        "incorrectPage": "upd_p2q27"
    }
    return render(request, 'exam2.html', my_context)
def p2q28(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "sh",
        "questionPromptPath": "promptaudio/part2/P2_Q28_SH.mp3",
        "choice1AudioPath": "answeraudio/letters/SH.mp3",
        "choice2AudioPath": "answeraudio/letters/TH.mp3",
        "choice3AudioPath": "answeraudio/letters/CH.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q28",
        "correctPage": "y_upd_p2q28",
        "incorrectPage": "upd_p2q28"
    }
    return render(request, 'exam2.html', my_context)
def p2q29(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "cl",
        "questionPromptPath": "promptaudio/part2/P2_Q29_CL.mp3",
        "choice1AudioPath": "answeraudio/letters/CL.mp3",
        "choice2AudioPath": "answeraudio/letters/BL.mp3",
        "choice3AudioPath": "answeraudio/letters/DR.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p2q29",
        "correctPage": "y_upd_p2q29",
        "incorrectPage": "upd_p2q29"
    }
    return render(request, 'exam2.html', my_context)
def p2q30(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "th",
        "questionPromptPath": "promptaudio/part2/P2_Q30_TH.mp3",
        "choice1AudioPath": "answeraudio/letters/SH.mp3",
        "choice2AudioPath": "answeraudio/letters/TH.mp3",
        "choice3AudioPath": "answeraudio/letters/CH.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q30",
        "correctPage": "y_upd_p2q30",
        "incorrectPage": "upd_p2q30"
    }
    return render(request, 'exam2.html', my_context)
def p2q31(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "wh",
        "questionPromptPath": "promptaudio/part2/P2_Q31_WH.mp3",
        "choice1AudioPath": "answeraudio/letters/QU.mp3",
        "choice2AudioPath": "answeraudio/letters/WH.mp3",
        "choice3AudioPath": "answeraudio/letters/CH.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p2q31",
        "correctPage": "y_upd_p2q31",
        "incorrectPage": "upd_p2q31"
    }
    return render(request, 'exam2.html', my_context)

def upd_q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_1 = 'N'
    student.max_questions_wrong += 1
    student.save(update_fields=['question_1', 'max_questions_wrong'])
    return redirect("exam:q2", pk=pk)

def y_upd_q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_1 = 'Y'
    student.max_questions_wrong = 0
    student.save(update_fields=['question_1', 'max_questions_wrong'])
    return redirect("exam:q2", pk=pk)

def upd_q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_2 = 'N'
    student.max_questions_wrong += 1
    student.save(update_fields=['question_2', 'max_questions_wrong'])
    return redirect("exam:q3", pk=pk)

def y_upd_q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_2 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_2', 'max_questions_wrong'])
    return redirect("exam:q3", pk=pk)

def upd_q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_3 = 'N'
    student.max_questions_wrong += 1
    student.save(update_fields=['question_3', 'max_questions_wrong'])
    return redirect("exam:q4", pk=pk)

def y_upd_q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_3 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_3', 'max_questions_wrong'])
    return redirect("exam:q4", pk=pk)

def upd_q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_4 = 'N'
    student.max_questions_wrong += 1
    student.save(update_fields=['question_4', 'max_questions_wrong'])
    return redirect("exam:q5", pk=pk)

def y_upd_q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_4 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_4', 'max_questions_wrong'])
    return redirect("exam:q5", pk=pk)

def upd_q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_5 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_5', 'max_questions_wrong'])
    return redirect("exam:q6", pk=pk)

def y_upd_q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_5 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_5', 'max_questions_wrong'])
    return redirect("exam:q6", pk=pk)

def upd_q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_6 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_6'])
    return redirect("exam:q7", pk=pk)

def y_upd_q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_6 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_6', 'max_questions_wrong'])
    return redirect("exam:q7", pk=pk)

def upd_q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_7 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_7'])
    return redirect("exam:q8", pk=pk)

def y_upd_q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_7 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_7', 'max_questions_wrong'])
    return redirect("exam:q8", pk=pk)

def upd_q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_8 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_8', 'max_questions_wrong'])
    return redirect("exam:q9", pk=pk)

def y_upd_q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_8 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_8', 'max_questions_wrong'])
    return redirect("exam:q9", pk=pk)

def upd_q9(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_9 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_9', 'max_questions_wrong'])
    return redirect("exam:q10", pk=pk)

def y_upd_q9(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_9 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_9', 'max_questions_wrong'])
    return redirect("exam:q10", pk=pk)

def upd_q10(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_10 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_10', 'max_questions_wrong'])
    return redirect("exam:q11", pk=pk)

def y_upd_q10(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_10 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_10', 'max_questions_wrong'])
    return redirect("exam:q11", pk=pk)

def upd_q11(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_11 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_11', 'max_questions_wrong'])
    return redirect("exam:q12", pk=pk)

def y_upd_q11(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_11 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_11', 'max_questions_wrong'])
    return redirect("exam:q12", pk=pk)

def upd_q12(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_12 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_12', 'max_questions_wrong'])
    return redirect("exam:q13", pk=pk)

def y_upd_q12(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_12 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_12', 'max_questions_wrong'])
    return redirect("exam:q13", pk=pk)

def upd_q13(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_13 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_13', 'max_questions_wrong'])
    return redirect("exam:q14", pk=pk)

def y_upd_q13(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_13= 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_13', 'max_questions_wrong'])
    return redirect("exam:q14", pk=pk)

def upd_q14(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_14 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_14', 'max_questions_wrong'])
    return redirect("exam:q15", pk=pk)

def y_upd_q14(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_14 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_14', 'max_questions_wrong'])
    return redirect("exam:q15", pk=pk)

def upd_q15(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_15 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_15', 'max_questions_wrong'])
    return redirect("exam:q16", pk=pk)

def y_upd_q15(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_15 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_15', 'max_questions_wrong'])
    return redirect("exam:q16", pk=pk)

def upd_q16(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_16 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_16', 'max_questions_wrong'])
    return redirect("exam:q17", pk=pk)

def y_upd_q16(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_16 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_16', 'max_questions_wrong'])
    return redirect("exam:q17", pk=pk)

def upd_q17(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_17 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_17', 'max_questions_wrong'])
    return redirect("exam:q18", pk=pk)

def y_upd_q17(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_17 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_17', 'max_questions_wrong'])
    return redirect("exam:q18", pk=pk)

def upd_q18(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_18 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_18', 'max_questions_wrong'])
    return redirect("exam:q19", pk=pk)

def y_upd_q18(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_18 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_18', 'max_questions_wrong'])
    return redirect("exam:q19", pk=pk)

def upd_q19(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_19 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_19', 'max_questions_wrong'])
    return redirect('exam:q20', pk=pk)

def y_upd_q19(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_19 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_19', 'max_questions_wrong'])
    return redirect("exam:q20", pk=pk)

def upd_q20(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_20 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_20', 'max_questions_wrong'])
    return redirect('exam:q21', pk=pk)

def y_upd_q20(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_20 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_20', 'max_questions_wrong'])
    return redirect("exam:q21", pk=pk)

def upd_q21(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_21 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_21', 'max_questions_wrong'])
    return redirect("exam:q22", pk=pk)

def y_upd_q21(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_21 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_21', 'max_questions_wrong'])
    return redirect("exam:q22", pk=pk)

def upd_q22(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_22 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_22', 'max_questions_wrong'])
    return redirect("exam:q23", pk=pk)

def y_upd_q22(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_22 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_22', 'max_questions_wrong'])
    return redirect("exam:q23", pk=pk)

def upd_q23(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_23 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_23', 'max_questions_wrong'])
    return redirect("exam:q24", pk=pk)

def y_upd_q23(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_23 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_23', 'max_questions_wrong'])
    return redirect("exam:q24", pk=pk)

def upd_q24(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_24 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_24', 'max_questions_wrong'])
    return redirect("exam:q25", pk=pk)

def y_upd_q24(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_24 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_24', 'max_questions_wrong'])
    return redirect("exam:q25", pk=pk)

def upd_q25(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_25 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_25', 'max_questions_wrong'])
    return redirect("exam:q26", pk=pk)

def y_upd_q25(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_25 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_25', 'max_questions_wrong'])
    return redirect("exam:q26", pk=pk)

def upd_q26(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_26 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['question_26', 'max_questions_wrong'])
    return redirect("exam:p2q1", pk=pk)

def y_upd_q26(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.question_25 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['question_25', 'max_questions_wrong'])
    return redirect("exam:q26", pk=pk)

def upd_p2q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_1 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_1', 'max_questions_wrong'])
    return redirect("exam:p2q2", pk=pk)

def y_upd_p2q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_1 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_1', 'max_questions_wrong'])
    return redirect("exam:p2q2", pk=pk)

def upd_p2q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_2 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_2', 'max_questions_wrong'])
    return redirect("exam:p2q3", pk=pk)

def y_upd_p2q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_2 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_2', 'max_questions_wrong'])
    return redirect("exam:p2q3", pk=pk)


def upd_p2q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_3 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_3', 'max_questions_wrong'])
    return redirect("exam:p2q4", pk=pk)

def y_upd_p2q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_3 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_3', 'max_questions_wrong'])
    return redirect("exam:p2q4", pk=pk)


def upd_p2q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_4 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_4', 'max_questions_wrong'])
    return redirect("exam:p2q5", pk=pk)

def y_upd_p2q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_4 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_4', 'max_questions_wrong'])
    return redirect("exam:p2q5", pk=pk)

def upd_p2q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_5 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_5', 'max_questions_wrong'])
    return redirect("exam:p2q6", pk=pk)

def y_upd_p2q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_5 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_5', 'max_questions_wrong'])
    return redirect("exam:p2q5", pk=pk)

def upd_p2q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_6 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_6', 'max_questions_wrong'])
    return redirect("exam:p2q7", pk=pk)

def y_upd_p2q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_6 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_6', 'max_questions_wrong'])
    return redirect("exam:p2q7", pk=pk)

def upd_p2q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_7 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_7', 'max_questions_wrong'])
    return redirect("exam:p2q8", pk=pk)

def y_upd_p2q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_7 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_7', 'max_questions_wrong'])
    return redirect("exam:p2q8", pk=pk)

def upd_p2q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_8 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_8', 'max_questions_wrong'])
    return redirect("exam:p2q9", pk=pk)

def y_upd_p2q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_8 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_8', 'max_questions_wrong'])
    return redirect("exam:p2q9", pk=pk)

def upd_p2q9(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_9 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_9', 'max_questions_wrong'])
    return redirect("exam:p2q10", pk=pk)

def y_upd_p2q9(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_9 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_9', 'max_questions_wrong'])
    return redirect("exam:p2q10", pk=pk)

def upd_p2q10(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_10 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_10', 'max_questions_wrong'])
    return redirect("exam:p2q11", pk=pk)

def y_upd_p2q10(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_10 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_10', 'max_questions_wrong'])
    return redirect("exam:p2q11", pk=pk)

def upd_p2q11(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_11 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_11', 'max_questions_wrong'])
    return redirect("exam:p2q12", pk=pk)

def y_upd_p2q11(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_11 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_11', 'max_questions_wrong'])
    return redirect("exam:p2q12", pk=pk)

def upd_p2q12(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_12 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_12', 'max_questions_wrong'])
    return redirect("exam:p2q13", pk=pk)

def y_upd_p2q12(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_12 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_12', 'max_questions_wrong'])
    return redirect("exam:p2q13", pk=pk)

def upd_p2q13(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_13 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_13', 'max_questions_wrong'])
    return redirect("exam:p2q14", pk=pk)

def y_upd_p2q13(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_13 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_13', 'max_questions_wrong'])
    return redirect("exam:p2q14", pk=pk)

def upd_p2q14(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_14 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_14', 'max_questions_wrong'])
    return redirect("exam:p2q15", pk=pk)

def y_upd_p2q14(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_14 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_14', 'max_questions_wrong'])
    return redirect("exam:p2q15", pk=pk)

def upd_p2q15(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_15 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_15', 'max_questions_wrong'])
    return redirect("exam:p2q16", pk=pk)

def y_upd_p2q15(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_15 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_15', 'max_questions_wrong'])
    return redirect("exam:p2q16", pk=pk)

def upd_p2q16(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_16 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_16', 'max_questions_wrong'])
    return redirect("exam:p2q17", pk=pk)

def y_upd_p2q16(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_16 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_16', 'max_questions_wrong'])
    return redirect("exam:p2q16", pk=pk)

def upd_p2q17(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_17 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_17', 'max_questions_wrong'])
    return redirect("exam:p2q18", pk=pk)

def y_upd_p2q17(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_17 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_17', 'max_questions_wrong'])
    return redirect("exam:p2q18", pk=pk)

def upd_p2q18(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_18 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_18', 'max_questions_wrong'])
    return redirect("exam:p2q19", pk=pk)

def y_upd_p2q18(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_18 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_18', 'max_questions_wrong'])
    return redirect("exam:p2q19", pk=pk)

def upd_p2q19(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_19 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_19', 'max_questions_wrong'])
    return redirect('exam:p2q20', pk=pk)

def y_upd_p2q19(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_19 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_19', 'max_questions_wrong'])
    return redirect("exam:p2q20", pk=pk)    

def upd_p2q20(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_20 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_20', 'max_questions_wrong'])
    return redirect('exam:p2q21', pk=pk)

def y_upd_p2q20(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_20 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_20', 'max_questions_wrong'])
    return redirect("exam:p2q21", pk=pk)

def upd_p2q21(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_21 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_21', 'max_questions_wrong'])
    return redirect("exam:p2q22", pk=pk)

def y_upd_p2q21(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_21 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_21', 'max_questions_wrong'])
    return redirect("exam:p2q22", pk=pk)

def upd_p2q22(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_22 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_22', 'max_questions_wrong'])
    return redirect("exam:p2q23", pk=pk)

def y_upd_p2q22(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_22 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_22', 'max_questions_wrong'])
    return redirect("exam:p2q23", pk=pk)

def upd_p2q23(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_23 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_23', 'max_questions_wrong'])
    return redirect("exam:p2q24", pk=pk)

def y_upd_p2q23(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_23 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_23', 'max_questions_wrong'])
    return redirect("exam:p2q24", pk=pk)

def upd_p2q24(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_24 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_24', 'max_questions_wrong'])
    return redirect("exam:p2q25", pk=pk)

def y_upd_p2q24(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_24 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_24', 'max_questions_wrong'])
    return redirect("exam:p2q25", pk=pk)

def upd_p2q25(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_25 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_25', 'max_questions_wrong'])
    return redirect("exam:p2q26", pk=pk)

def y_upd_p2q25(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_25 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_25', 'max_questions_wrong'])
    return redirect("exam:p2q26", pk=pk)

def upd_p2q26(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_26 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_26', 'max_questions_wrong'])
    return redirect("exam:p2q27", pk=pk)

def y_upd_p2q26(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_26 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_26', 'max_questions_wrong'])
    return redirect("exam:p2q27", pk=pk)


def upd_p2q27(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_27 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_27', 'max_questions_wrong'])
    return redirect("exam:p2q28", pk=pk)

def y_upd_p2q27(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_27 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_27', 'max_questions_wrong'])
    return redirect("exam:p2q28", pk=pk)

def upd_p2q28(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_28 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_28', 'max_questions_wrong'])
    return redirect("exam:p2q29", pk=pk)

def y_upd_p2q28(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_28 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_28', 'max_questions_wrong'])
    return redirect("exam:p2q29", pk=pk)

def upd_p2q29(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_29 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_29', 'max_questions_wrong'])
    return redirect("exam:p2q30", pk=pk)

def y_upd_p2q29(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_29 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_29', 'max_questions_wrong'])
    return redirect("exam:p2q30", pk=pk)

def upd_p2q30(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_30 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_30', 'max_questions_wrong'])
    return redirect("exam:p2q31", pk=pk)

def y_upd_p2q30(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_30 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_30', 'max_questions_wrong'])
    return redirect("exam:p2q31", pk=pk)

def upd_p2q31(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_31 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p2question_31', 'max_questions_wrong'])
    return redirect("exam:p3q1", pk=pk)

def y_upd_p2q31(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p2question_31 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p2question_31', 'max_questions_wrong'])
    return redirect("exam:p3q1", pk=pk)

def p3q1(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q1_PEN.mp3",
        "choice1AudioPath": "answeraudio/words/VAN.mp3",
        "choice2AudioPath": "answeraudio/words/POT.mp3",
        "choice3AudioPath": "answeraudio/words/horse.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "mainPicPath": "images/pen.jpg",
        "firstPicPath": "images/van.jpg",
        "secondPicPath": "images/pot.jpg",
        "thirdPicPath": "images/horse.jpg",
        "currentPage": "p3q1",
        "correctPage": "y_upd_p3q1",
        "incorrectPage": "upd_p3q1",
    }
    return render(request, 'exam3.html', my_context)

def upd_p3q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_1 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_1', 'max_questions_wrong'])
    return redirect("exam:p3q2", pk=pk)

def y_upd_p3q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_1 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_1', 'max_questions_wrong'])
    return redirect("exam:p3q2", pk=pk)

def p3q2(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q2_TENT.mp3",
        "choice1AudioPath": "answeraudio/words/TABLE.mp3",
        "choice2AudioPath": "answeraudio/words/HAMMER.mp3",
        "choice3AudioPath": "answeraudio/words/GIRL.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p3q2",
        "correctPage": "y_upd_p3q2",
        "incorrectPage": "upd_p3q2",
        "mainPicPath": "images/tent.jpg",
        "firstPicPath": "images/table.jpg",
        "secondPicPath": "images/hammer.jpg",
        "thirdPicPath": "images/girl.jpg",
    }
    return render(request, 'exam3.html', my_context)

def upd_p3q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_2 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_2', 'max_questions_wrong'])
    return redirect("exam:p3q3", pk=pk)

def y_upd_p3q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_2 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_2', 'max_questions_wrong'])
    return redirect("exam:p3q3", pk=pk)

def p3q3(request, pk):
    my_context = {
        "student_pk": pk,
         "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q3_HAT.mp3",
        "choice1AudioPath": "answeraudio/words/CAT.mp3",
        "choice2AudioPath": "answeraudio/words/",
        "choice3AudioPath": "answeraudio/words/HAND.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p3q3",
        "correctPage": "y_upd_p3q3",
        "incorrectPage": "upd_p3q3",
        "mainPicPath": "images/hat.jpg",
        "firstPicPath": "images/cat.jpg",
        "secondPicPath": "images/bed.jpg",
        "thirdPicPath": "images/hand.jpg",
    }
    return render(request, 'exam3.html', my_context)

def upd_p3q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_3 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_3', 'max_questions_wrong'])
    return redirect("exam:p3q4", pk=pk)

def y_upd_p3q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_3 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_3', 'max_questions_wrong'])
    return redirect("exam:p3q4", pk=pk)

def p3q4(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q4_MOUSE.mp3",
        "choice1AudioPath": "answeraudio/words/VAN.mp3",
        "choice2AudioPath": "answeraudio/words/POT.mp3",
        "choice3AudioPath": "answeraudio/words/HORSE.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p3q4",
        "correctPage": "y_upd_p3q4",
        "incorrectPage": "upd_p3q4",
        "mainPicPath": "images/mouse.jpg",
        "firstPicPath": "images/van.jpg",
        "secondPicPath": "images/pot.jpg",
        "thirdPicPath": "images/horse.jpg",
    }
    return render(request, 'exam3.html', my_context)


def upd_p3q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_4 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_4', 'max_questions_wrong'])
    return redirect("exam:p3q5", pk=pk)

def y_upd_p3q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_4 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_4', 'max_questions_wrong'])
    return redirect("exam:p3q5", pk=pk)

def p3q5(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q5_BAT.mp3",
        "choice1AudioPath": "answeraudio/words/BOY.mp3",
        "choice2AudioPath": "answeraudio/words/HUG.mp3",
        "choice3AudioPath": "HAT.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p3q5",
        "correctPage": "y_upd_p3q5",
        "incorrectPage": "upd_p3q5",
        "mainPicPath": "images/bat.jpg",
        "firstPicPath": "images/boy.jpg",
        "secondPicPath": "images/hug.jpg",
        "thirdPicPath": "images/hat.jpg",
    }
    return render(request, 'exam3.html', my_context)

def upd_p3q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_5 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_5', 'max_questions_wrong'])
    return redirect("exam:p3q6", pk=pk)

def y_upd_p3q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_5 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_5', 'max_questions_wrong'])
    return redirect("exam:p3q6", pk=pk)

def p3q6(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "",
        "choice1AudioPath": "answeraudio/words/KITE.mp3",
        "choice2AudioPath": "answeraudio/words/SPIDER.mp3",
        "choice3AudioPath": "answeraudio/words/CAR.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p3q6",
        "correctPage": "y_upd_p3q6",
        "incorrectPage": "upd_p3q6",
        "mainPicPath": "images/sing.jpg",
        "firstPicPath": "images/sun.jpg",
        "secondPicPath": "images/ring.jpg",
        "thirdPicPath": "images/boat.jpg",
    }
    return render(request, 'exam3.html', my_context)


def upd_p3q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_6 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_6', 'max_questions_wrong'])
    return redirect("exam:p4q1", pk=pk)

def y_upd_p3q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_6 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_6', 'max_questions_wrong'])
    return redirect("exam:p4q1", pk=pk)

def p3q7(request):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "",
        "choice1AudioPath": "answeraudio/words/SUN.mp3",
        "choice2AudioPath": "answeraudio/words/RING.mp3",
        "choice3AudioPath": "answeraudio/words/BOAT.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p3q7",
        "correctPage": "y_upd_p3q7",
        "incorrectPage": "upd_p3q7",
        "mainPicPath": "images/sing.jpg",
        "firstPicPath": "images/sun.jpg",
        "secondPicPath": "images/ring.jpg",
        "thirdPicPath": "images/boat.jpg",
    }
    return render(request, 'exam3.html', my_context)

def upd_p3q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_7 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_7', 'max_questions_wrong'])
    return redirect("exam:p3q8", pk=pk)
  
  
def y_upd_p3q7(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_7 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_7', 'max_questions_wrong'])
    return redirect("exam:p3q8", pk=pk)

def p3q8(request):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part3/P3_Q8_TREE.mp3",
        "choice1AudioPath": "answeraudio/words/SNAIL.mp3",
        "choice2AudioPath": "answeraudio/words/EGG.mp3",
        "choice3AudioPath": "answeraudio/words/NOSE.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p3q8",
        "correctPage": "y_upd_p3q8",
        "incorrectPage": "upd_p3q8",
        "mainPicPath": "images/nail.jpg",
        "firstPicPath": "images/snail.jpg",
        "secondPicPath": "images/egg.jpg",
        "thirdPicPath": "images/nose.jpg",
    }
    return render(request, 'exam3.html', my_context)
  
def y_upd_p3q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_8 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p3question_8', 'max_questions_wrong'])
    return redirect("exam:p4q1", pk=pk)
  
def upd_p3q8(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p3question_8 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p3question_8', 'max_questions_wrong'])
    return redirect("exam:p4q1", pk=pk)
  

def p4q1(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q1_CAT.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/CAT.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/SET.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/CAN.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p4q1",
        "correctPage": "y_upd_p4q1",
        "incorrectPage": "upd_p4q1",
        "mainPicPath": "images/cat.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_1 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_1', 'max_questions_wrong'])
    return redirect("exam:p4q2", pk=pk)

def y_upd_p4q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_1 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_1', 'max_questions_wrong'])
    return redirect("exam:p4q2", pk=pk)

def p4q2(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q2_CUP.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/SUN.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/CAP.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/CUP.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p4q2",
        "correctPage": "y_upd_p4q2",
        "incorrectPage": "upd_p4q2",
        "mainPicPath": "images/cup.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_2 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_2', 'max_questions_wrong'])
    return redirect("exam:p4q3", pk=pk)

def y_upd_p4q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_2 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_2', 'max_questions_wrong'])
    return redirect("exam:p4q3", pk=pk)

def p4q3(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q3_MOM.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/MAM.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/MOM.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/MEM.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 2,
        "currentPage": "p4q3",
        "correctPage": "y_upd_p4q3",
        "incorrectPage": "upd_p4q3",
        "mainPicPath": "images/mom.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_3 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_3', 'max_questions_wrong'])
    return redirect("exam:p4q4", pk=pk)

def y_upd_p4q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_3 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_3', 'max_questions_wrong'])
    return redirect("exam:p4q4", pk=pk)

def p4q4(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q4_POT.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/POT.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/PAT.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/PUP.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p4q4",
        "correctPage": "y_upd_p4q4",
        "incorrectPage": "upd_p4q4",
        "mainPicPath": "images/pot.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_4 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_4', 'max_questions_wrong'])
    return redirect("exam:p4q5", pk=pk)

def y_upd_p4q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_4 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_4', 'max_questions_wrong'])
    return redirect("exam:p4q5", pk=pk)

def p4q5(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q5_STOP.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/STOP.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/SOP.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/STOM.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p4q5",
        "correctPage": "y_upd_p4q5",
        "incorrectPage": "upd_p4q5",
        "mainPicPath": "images/stop.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_5 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_5', 'max_questions_wrong'])
    return redirect("exam:p4q6", pk=pk)

def y_upd_p4q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_5 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_5', 'max_questions_wrong'])
    return redirect("exam:p4q6", pk=pk)

def p4q6(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part4/P4_Q6_FAN.mp3",
        "choice1AudioPath": "answeraudio/soundOuts/FAN.mp3",
        "choice2AudioPath": "answeraudio/soundOuts/FUN.mp3",
        "choice3AudioPath": "answeraudio/soundOuts/DAN.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 1,
        "currentPage": "p4q6",
        "correctPage": "y_upd_p4q6",
        "incorrectPage": "upd_p4q6",
        "mainPicPath": "images/fan.jpg",
    }
    return render(request, 'exam4.html', my_context)

def upd_p4q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_6 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p4question_6', 'max_questions_wrong'])
    return redirect("exam:p4q6", pk=pk)

def y_upd_p4q6(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p4question_6 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p4question_6', 'max_questions_wrong'])
    return redirect("exam:p4q6", pk=pk)
  
def p5q1(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part5/P5_Q1_BED.mp3",
        "choice1AudioPath": "answeraudio/words/BET.mp3",
        "choice2AudioPath": "answeraudio/words/BAD.mp3",
        "choice3AudioPath": "answeraudio/words/BED.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p5q1",
        "correctPage": "y_upd_p5q1",
        "incorrectPage": "upd_p5q1",
    }
    return render(request, 'exam5.html', my_context)

def upd_p5q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_1 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p5question_1', 'max_questions_wrong'])
    return redirect("exam:p5q2", pk=pk)

def y_upd_p5q1(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_1 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p5question_1', 'max_questions_wrong'])
    return redirect("exam:p5q2", pk=pk)


def p5q2(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part5/P5_Q2_PET.mp3",
        "choice1AudioPath": "answeraudio/words/PET.mp3",
        "choice2AudioPath": "answeraudio/words/PAT.mp3",
        "choice3AudioPath": "answeraudio/words/BET.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p5q2",
        "correctPage": "y_upd_p5q2",
        "incorrectPage": "upd_p5q2",
    }
    return render(request, 'exam5.html', my_context)

def upd_p5q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_2 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p5question_2', 'max_questions_wrong'])
    return redirect("exam:p5q3", pk=pk)

def y_upd_p5q2(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_2 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p5question_2', 'max_questions_wrong'])
    return redirect("exam:p5q3", pk=pk)


def p5q3(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "",
        "choice1AudioPath": "answeraudio/words/BUG.mp3",
        "choice2AudioPath": "answeraudio/words/TAG.mp3",
        "choice3AudioPath": "answeraudio/words/BUT.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p5q3",
        "correctPage": "y_upd_p5q3",
        "incorrectPage": "upd_p5q3",
    }
    return render(request, 'exam5.html', my_context)

def upd_p5q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_3 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p5question_3', 'max_questions_wrong'])
    return redirect("exam:p5q4", pk=pk)

def y_upd_p5q3(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_3 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p5question_3', 'max_questions_wrong'])
    return redirect("exam:p5q4", pk=pk)


def p5q4(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "promptaudio/part5/P5_Q4_CAN.mp3",
        "choice1AudioPath": "answeraudio/words/MAN.mp3",
        "choice2AudioPath": "answeraudio/words/CAN.mp3",
        "choice3AudioPath": "answeraudio/words/CAT.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p5q4",
        "correctPage": "y_upd_p5q4",
        "incorrectPage": "upd_p5q4",
    }
    return render(request, 'exam5.html', my_context)

def upd_p5q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_4 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p5question_4', 'max_questions_wrong'])
    return redirect("exam:p5q5", pk=pk)

def y_upd_p5q4(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_4 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p5question_4', 'max_questions_wrong'])
    return redirect("exam:p5q5", pk=pk)


def p5q5(request, pk):
    my_context = {
        "student_pk": pk,
        "questionLetter": "",
        "questionPromptPath": "",
        "choice1AudioPath": "answeraudio/words/HIT.mp3",
        "choice2AudioPath": "answeraudio/words/HOT.mp3",
        "choice3AudioPath": "answeraudio/words/HIP.mp3",
        "choiceImagePath": "images/speaker.jpg",
        "answer": 3,
        "currentPage": "p5q5",
        "correctPage": "y_upd_p5q5",
        "incorrectPage": "upd_p5q5",
    }
    return render(request, 'exam5.html', my_context)

def upd_p5q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_5 = 'N'
    student.max_questions_wrong += 1
    if student.max_questions_wrong == 5:
        calculateExamResult(pk)
        student.exam_taken = 'Y'
        student.save(update_fields=['exam_taken', 'max_questions_wrong'])
        return redirect ('student_info:students')
    student.save(update_fields=['p5question_5', 'max_questions_wrong'])
    return redirect("exam:done", pk=pk)

def y_upd_p5q5(request, pk):
    student = get_object_or_404(Student, pk=pk)
    student.p5question_5 = 'Y'
    student.max_questions_wrong == 0
    student.save(update_fields=['p5question_5', 'max_questions_wrong'])
    return redirect("exam:done", pk=pk)

def done(request, pk):
    student = get_object_or_404(Student, pk=pk)
    calculateExamResult(pk)
    return render(request, 'done.html')

def calculateExamResult(pk):
    
    student = get_object_or_404(Student, pk=pk)
    student.timespent = time.perf_counter() - student.timespent
    student.save(update_fields=['timespent'])

    score = 0
    
    if student.question_1 == 'Y':
        score += 1
    if student.question_2 == 'Y':
        score += 1
    if student.question_3 == 'Y':
        score += 1
    if student.question_4 == 'Y':
        score += 1
    if student.question_5 == 'Y':
        score += 1
    if student.question_6 == 'Y':
        score += 1
    if student.question_7 == 'Y':
        score += 1
    if student.question_3 == 'Y':
        score += 1
    if student.question_8 == 'Y':
        score += 1
    if student.question_9 == 'Y':
        score += 1
    if student.question_10 == 'Y':
        score += 1
    if student.question_11 == 'Y':
        score += 1
    if student.question_12 == 'Y':
        score += 1
    if student.question_13 == 'Y':
        score += 1
    if student.question_14 == 'Y':
        score += 1
    if student.question_15 == 'Y':
        score += 1
    if student.question_16 == 'Y':
        score += 1
    if student.question_17 == 'Y':
        score += 1
    if student.question_18 == 'Y':
        score += 1
    if student.question_19 == 'Y':
        score += 1
    if student.question_20 == 'Y':
        score += 1
    if student.question_21 == 'Y':
        score += 1
    if student.question_22 == 'Y':
        score += 1
    if student.question_23 == 'Y':
        score += 1
    if student.question_24 == 'Y':
        score += 1
    if student.question_25 == 'Y':
        score += 1
    if student.question_26 == 'Y':
        score += 1
    if student.p2question_1 == 'Y':
        score += 1
    if student.p2question_2 == 'Y':
        score += 1
    if student.p2question_3 == 'Y':
        score += 1
    if student.p2question_4 == 'Y':
        score += 1
    if student.p2question_5 == 'Y':
        score += 1
    if student.p2question_6 == 'Y':
        score += 1
    if student.p2question_7 == 'Y':
        score += 1
    if student.p2question_8 == 'Y':
        score += 1
    if student.p2question_9 == 'Y':
        score += 1
    if student.p2question_10 == 'Y':
        score += 1
    if student.p2question_11 == 'Y':
        score += 1
    if student.p2question_12 == 'Y':
        score += 1
    if student.p2question_13 == 'Y':
        score += 1
    if student.p2question_14 == 'Y':
        score += 1
    if student.p2question_15 == 'Y':
        score += 1
    if student.p2question_16 == 'Y':
        score += 1
    if student.p2question_17 == 'Y':
        score += 1
    if student.p2question_18 == 'Y':
        score += 1
    if student.p2question_19 == 'Y':
        score += 1
    if student.p2question_20 == 'Y':
        score += 1
    if student.p2question_21 == 'Y':
        score += 1
    if student.p2question_22 == 'Y':
        score += 1
    if student.p2question_23 == 'Y':
        score += 1
    if student.p2question_24 == 'Y':
        score += 1
    if student.p2question_25 == 'Y':
        score += 1
    if student.p2question_26 == 'Y':
        score += 1
    if student.p2question_27 == 'Y':
        score += 1
    if student.p2question_28 == 'Y':
        score += 1
    if student.p2question_29 == 'Y':
        score += 1
    if student.p2question_30 == 'Y':
        score += 1
    if student.p2question_31 == 'Y':
        score += 1
    if student.p3question_1 == 'Y':
        score += 1
    if student.p3question_2 == 'Y':
        score += 1
    if student.p3question_3 == 'Y':
        score += 1
    if student.p3question_4 == 'Y':
        score += 1
    if student.p3question_5 == 'Y':
        score += 1
    if student.p3question_6 == 'Y':
        score += 1
    if student.p4question_1 == 'Y':
        score += 1
    if student.p4question_2 == 'Y':
        score += 1
    if student.p4question_3 == 'Y':
        score += 1
    if student.p4question_4 == 'Y':
        score += 1
    if student.p4question_5 == 'Y':
        score += 1
    if student.p4question_6 == 'Y':
        score += 1
    
    final_score = int((score / 69) * 100)

    if final_score <= 60: # 60 needs to be changed to whatever number the Dr.Elliot states is the at_risk benchmark
        student.risk = 'AT_RISK'
    else:
        student.risk = 'GREAT'
    
    student.save()
