Commit a835b3f5 authored by Samarth Joshi's avatar Samarth Joshi

Adding @login_required to all functions

parent 8dd9b52e
......@@ -40,6 +40,7 @@ from django.core.files.storage import default_storage
startedquiz = dict()
@login_required
def index(request):
""" This function is responsible for for rendering the quiz page to the student for the selected quiz by the student
"""
......@@ -79,8 +80,7 @@ def result(request):
return HttpResponse("You have already submitted this quiz")
@login_required
def save_ans(request):
"""
this function keeps saving the response of the quiz while the student is attempting in order to ensure if due to network failure
......@@ -94,6 +94,7 @@ def save_ans(request):
t.save()
return HttpResponse('')
@login_required
def save_cribs(request):
"""This function saves the cribs that the student has raised"""
crib=request.GET.get('cribs')
......@@ -104,7 +105,8 @@ def save_cribs(request):
t=cribs(cribs=crib,studentId=request.user,questionId=questionInstance,quizId=quizInstance)
t.save()
return HttpResponse('Suuuuuccess')
@login_required
def upload(request):
"""This function Renders the upload page for instructor to upload quiz through csv"""
return render(request,'upload.html')
......@@ -122,11 +124,13 @@ def student(request):
else:
return render(request,'student.html')
@login_required
def ongoing_quiz(request):
"""Displays all ongoing quiz to the professor who has hosted the quiz"""
quizzes = quiz.objects.all().order_by('-date', '-startTime')
return render(request, 'ongoing_quiz.html', {'quizId': quizzes})
@login_required
def upload_file(request):
""" This function reads the csv file and inserts the questions into the database """
uploaded=False
......@@ -144,7 +148,7 @@ def upload_file(request):
else :
return render(request,'upload.html',{temp1:'invalid File'})
@login_required
def instructor(request):
"""This function is used to display the instructor with graphs(bell curve and histogram) , cribs raised by the students of the quiz selected"""
q_id = request.GET.get('quiz_id')
......@@ -200,6 +204,7 @@ def instructor(request):
quizDone = True
return render(request, 'instructor.html',{"graph": html_graph, "graph1": html_graph, "graph2": html_graph1,'quiz':quizInstance,'cribs':cribs, 'all_quizes': allquizs, 'quizDone':quizDone})
@login_required
def quizTable(request):
"""This function helps in rendering all the quiz hosted by the instructor"""
quizs = quiz.objects.filter(quizInstructor=request.user).all()
......@@ -217,6 +222,7 @@ def handle_uploaded_file(f,q1):
q=Questions(question=row[0],option1=row[1],option2=row[2],option3=row[3],option4=row[4],answer=row[5],type=row[6],marks=int(row[7]),negative=float(row[8]),explainations=row[9],quizCode=q1.quizCode,quizId=q1)#hardcoded quizid
q.save()
@login_required
def create_quiz(request):
"""This function renders the create quiz page for manually entering questions"""
return render(request, 'quiz_create.html')
......@@ -264,7 +270,7 @@ def view_sub(request):
total = total + sub.questionId.marks
return render(request,'view_submissions.html', { 'submissions' : subs , 'score': round(score,2), 'total': total, 'quizId': quizId })
@login_required
def add_quiz(request):
"""This function makes insert into database for all the manually entered quiz questions"""
vals=list()
......@@ -294,6 +300,7 @@ def add_quiz(request):
i=i+9
return render(request,'professor.html',{'quiz_upload':True})#(request,'success')
@login_required
def monitor(request):
"""
Thid function renders the monitor page for the instructor to view ongoing quiz , and monitor the student activity
......@@ -319,6 +326,7 @@ def getbeat(request):
test = startedquiz.get(quizId)
return render(request,'student_activity.html', {'activity': test })
@login_required
def view_logs(request):
"""THus function helps in viewing all the quizzes logs"""
quizId = int(request.GET.get('quiz'))
......@@ -326,6 +334,7 @@ def view_logs(request):
quiz_logs = log.objects.all().filter(quizId=quizInstance)
return render(request,'log.html', {'logs': quiz_logs })
@login_required
def heartbeat(request):
"""This function keeps track of student whether he exited full screen and which question he is currently on"""
quizId = int(request.GET.get('quiz'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment