Commit 784d2f15 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

dynamicmarking,questionmodel modified

parent e8f27753
No preview for this file type
# Generated by Django 2.2.7 on 2020-10-20 03:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('quiz', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='questions',
name='marks',
field=models.IntegerField(default=1, max_length=3),
),
migrations.AddField(
model_name='questions',
name='negative',
field=models.IntegerField(default=0, max_length=3),
),
]
# Generated by Django 2.2.7 on 2020-10-20 03:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('quiz', '0002_auto_20201020_0343'),
]
operations = [
migrations.AddField(
model_name='questions',
name='explainations',
field=models.TextField(default='No Explaination Given', max_length=1000),
),
migrations.AddField(
model_name='questions',
name='quizId',
field=models.CharField(default=10, max_length=100),
),
migrations.AddField(
model_name='questions',
name='type',
field=models.CharField(default=1, max_length=10),
),
migrations.AlterField(
model_name='questions',
name='marks',
field=models.IntegerField(default=1),
),
migrations.AlterField(
model_name='questions',
name='negative',
field=models.FloatField(default=0, max_length=10),
),
]
......@@ -10,3 +10,9 @@ class Questions(models.Model):
option3 = models.CharField(max_length=100)
option4 = models.CharField(max_length=100)
answer = models.CharField(max_length=100)
type=models.CharField(max_length=10,default=1)
marks =models.IntegerField(default=1)
negative = models.FloatField(max_length=10,default=0)
explainations=models.TextField(max_length=1000,default='No Explaination Given')
quizId = models.CharField(max_length=100,default=10)
#questionId=models.AutoField(default=10)
<!DOCTYPE html>
<head>
<head>
<title>Result Page</title>
</head>
<body>
</head>
<body>
<div>
<center><a href="/showAnswers/"><h3>Your Score {{score}}</h3></a></center>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" ></script>
</body>
</html>
</body>
</html>
<!DOCTYPE html>
<head>
<head>
<title>Pariksha</title>
</head>
<body>
</head>
<body>
<center><h1><a href="/quiz/">Start Quiz</a></h1></center>
</body>
</html>
</body>
</html>
......@@ -3,12 +3,16 @@ from django.http import HttpResponse
from . models import Questions
from django.core.paginator import Paginator
lst = []
answers = Questions.objects.all()
#print("hello"+str(answers))
anslist = []
marksList=[]
negative=[]
for i in answers:
anslist.append(i.answer)
print(str(i.answer))
marksList.append(i.marks)
negative.append(i.negative)
def index(request):
obj = Questions.objects.all()
......@@ -20,18 +24,22 @@ def index(request):
page =1
try:
questions = paginator.page(page)
except(EmptyPage,InvalidPage):
except Exception as e:
questions=paginator.page(paginator.num_pages)
return render(request,'index.html',{'obj':obj,'questions':questions,'count':count})
'''
def index(request):
pass
'''
def result(request):
score =0
for i in range(len(lst)):
if lst[i]==anslist[i]:
score +=1
score +=marksList[i]
else:
score-=negative[i]
return render(request,'result.html',{'score':score,'lst':lst})
......@@ -42,5 +50,4 @@ def save_ans(request):
def student(request):
lst.clear()
return render(request,'student.html')
# Create your views here.
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