Commit 64685e29 authored by Samarth Joshi's avatar Samarth Joshi

Adding role field in signup html and no quiz created error page

parent dabce1db
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
{% load static %}
<title>Pariksha | Oops!</title>
<link rel="shortcut icon" href="{% static 'img/favicon.svg' %}" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Source Sans Pro', sans-serif;
}
body {
margin: 0px;
}
img {
width: 400px;
height: 400px;
animation: appear 0.5s 1;
}
@keyframes appear {
0% {
width: 0px;
height: 0px;
}
100% {
width: 400px;
height: 400px;
}
}
section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>
</head>
<body>
<section>
<img src="{% static 'img/undraw_blank_canvas.svg' %}">
<h2>Oops! You have not created any quiz.</h2>
</section>
</body>
</html>
\ No newline at end of file
...@@ -186,12 +186,16 @@ button:focus { ...@@ -186,12 +186,16 @@ button:focus {
.helptext { .helptext {
font-size: 0.7em; font-size: 0.7em;
color: black; color: black;
display: none;
} }
li { li {
font-size: 0.7em; font-size: 0.7em;
line-height:20px; line-height:20px;
color: black; color: black;
} }
ul {
display: none;
}
@media (max-width: 500px) { @media (max-width: 500px) {
.window { .window {
...@@ -204,8 +208,25 @@ color: black; ...@@ -204,8 +208,25 @@ color: black;
} }
} }
p {
display: flex;
flex-direction: column;
}
p > input {
width: 100%;
height: 40px;
font-size: 1em;
}
.logo { .logo {
width: 100%; width: 100%;
}
.role_select {
width: 100%;
height: 45px;
margin-bottom: 50px;
border:none;
} }
</style> </style>
</head> </head>
...@@ -221,6 +242,11 @@ color: black; ...@@ -221,6 +242,11 @@ color: black;
<form class='input-line full-width' method="post"> <form class='input-line full-width' method="post">
{% csrf_token %} {% csrf_token %}
{{form.as_p}} {{form.as_p}}
<label for="role">Role:</label>
<select class="role_select" name="role">
<option value="S">Student</option>
<option value="P">Professor</option>
</select>
<div><button class='sub_button full-width'>Sign up</button></div> <div><button class='sub_button full-width'>Sign up</button></div>
</form> </form>
......
...@@ -158,10 +158,10 @@ def instructor(request): ...@@ -158,10 +158,10 @@ def instructor(request):
quizId = int(q_id) quizId = int(q_id)
else: else:
#quizId = quiz.objects.all().filter(quizInstructor=request.user)[0] #quizId = quiz.objects.all().filter(quizInstructor=request.user)[0]
if True: if allquizs:
quizId = allquizs[0].quizId quizId = allquizs[0].quizId
else: else:
print(quizId) return render(request, 'noquiz.html')
quizInstance = quiz.objects.all().filter(quizId=quizId, quizInstructor=request.user)[0] quizInstance = quiz.objects.all().filter(quizId=quizId, quizInstructor=request.user)[0]
students = results.objects.all().filter(quizId=quizId).values('studentId') students = results.objects.all().filter(quizId=quizId).values('studentId')
...@@ -237,7 +237,13 @@ def sign_up(request): ...@@ -237,7 +237,13 @@ def sign_up(request):
if form.is_valid(): if form.is_valid():
user = form.save() user = form.save()
login(request,user) login(request,user)
return render(request,'student.html') role = (request.POST.get('role'))
if role == "P":
p = Permission(userId=request.user, role="P")
p.save()
return render(request,'professor.html')
else:
return render(request,'student.html')
context['form']=form context['form']=form
return render(request,'registration/signup.html',context) return render(request,'registration/signup.html',context)
...@@ -308,6 +314,9 @@ def monitor(request): ...@@ -308,6 +314,9 @@ def monitor(request):
q_id = request.GET.get('quiz') q_id = request.GET.get('quiz')
allquizs = quiz.objects.all().filter(quizInstructor=request.user).order_by('-date', '-startTime') allquizs = quiz.objects.all().filter(quizInstructor=request.user).order_by('-date', '-startTime')
if not allquizs:
return render(request, 'noquiz.html')
if q_id: if q_id:
quizId = int(q_id) quizId = int(q_id)
quizInstance = quiz.objects.get(pk=quizId) quizInstance = quiz.objects.get(pk=quizId)
......
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