Commit b2696eb8 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

models for cribs and submissions

parent fb96024d
No preview for this file type
question1,option1,option2,option3,option4,option1,type,10,5,explaination,6969
question2,option1,option2,option3,option4,option1,type,10,5,explaination,6969
question1,option1,option2,option3,option4,option1,type,10,5,explaination,6969
question2,option1,option2,option3,option4,option1,type,10,5,explaination,6969
# Generated by Django 2.2.7 on 2020-10-20 07:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('quiz', '0003_auto_20201020_0359'),
]
operations = [
migrations.CreateModel(
name='cribs',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('studentId', models.CharField(max_length=100)),
('cribs', models.CharField(max_length=1000)),
('quizId', models.CharField(max_length=100)),
('questionId', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='submission',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('questionId', models.CharField(max_length=100)),
('option', models.CharField(max_length=100)),
('studentId', models.CharField(max_length=100)),
('quizId', models.CharField(max_length=100)),
],
),
migrations.RemoveField(
model_name='questions',
name='id',
),
migrations.AddField(
model_name='questions',
name='questionId',
field=models.AutoField(default=0, primary_key=True, serialize=False),
),
]
......@@ -15,4 +15,17 @@ class Questions(models.Model):
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)
questionId=models.AutoField(primary_key=True,)
class submission(models.Model):
#submission( questionid,selectedoption, quizid, studentid)
questionId=models.CharField(max_length=100)
option=models.CharField(max_length=100)
studentId=models.CharField(max_length=100)
quizId=models.CharField(max_length=100)
class cribs(models.Model):
studentId=models.CharField(max_length=100)
cribs=models.CharField(max_length=1000)
quizId=models.CharField(max_length=100)
questionId=models.CharField(max_length=100)
window.onload = initall;
var saveBookButton ;
var save ;
function initall() {
saveBookButton=document.getElementById('save_ans')//save_ans
saveBookButton.onclick = save_ans;
save=document.getElementById('save_ans')//save_ans
save.onclick = save_ans;
}
function save_ans() {
var ans = $("input:radio[name=name]:checked").val()
......
......@@ -33,7 +33,7 @@
<div >
<div>
{% if questions.has_next %}
<a href="?page={{ questions.next_page_number }}"><button id="submitAnswer">Next</button></a>
<a href="?page={{ questions.next_page_number }}"><button id="save_ans">Next</button></a>
{% else %}
<a href="/result/"><button >Submit Quiz</button></a>
{% endif %}
......
......@@ -7,6 +7,8 @@
<body>
<div>
<center><a href="/showAnswers/"><h3>Your Score {{score}}</h3></a></center>
{{anslist}}
{{lst}}
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" ></script>
......
......@@ -9,7 +9,6 @@ import csv
lst = []
answers = Questions.objects.all()
#print("hello"+str(answers))
anslist = []
marksList=[]
negative=[]
......@@ -34,7 +33,7 @@ def index(request):
questions=paginator.page(paginator.num_pages)
return render(request,'index.html',{'obj':obj,'questions':questions,'count':count})
'''
'''
def index(request):
pass
'''
......@@ -46,12 +45,13 @@ def result(request):
score +=marksList[i]
else:
score-=negative[i]
return render(request,'result.html',{'score':score,'lst':lst})
return render(request,'result.html',{'score':score,'lst':lst,'anslist':anslist})
def save_ans(request):
ans = request.GET['ans']
lst.append(ans)
return HttpResponse('')
def upload(request):
return render(request,'upload.html')
......
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