Commit 56194c3a authored by NARRA SURAJ's avatar NARRA SURAJ

test display

parent 06868c56
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-25 09:31
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ARFA_app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='test',
name='expected_time_for_completion',
field=models.CharField(max_length=10),
),
migrations.AlterField(
model_name='test',
name='max_marks',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='test',
name='start_time',
field=models.CharField(max_length=10),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-25 11:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ARFA_app', '0002_auto_20181125_0931'),
]
operations = [
migrations.AlterField(
model_name='test',
name='expected_time_for_completion',
field=models.DurationField(blank=True),
),
migrations.AlterField(
model_name='test',
name='max_marks',
field=models.FloatField(null=True),
),
migrations.AlterField(
model_name='test',
name='start_time',
field=models.DateTimeField(),
),
]
...@@ -29,8 +29,8 @@ class Test(models.Model): ...@@ -29,8 +29,8 @@ class Test(models.Model):
test_name = models.CharField(max_length=200,unique=True) test_name = models.CharField(max_length=200,unique=True)
visibility_student = models.CharField(max_length=20) visibility_student = models.CharField(max_length=20)
ownership = models.CharField(max_length=20) ownership = models.CharField(max_length=20)
expected_time_for_completion = models.CharField(max_length=10) expected_time_for_completion = models.DurationField(blank=True)
start_time = models.CharField(max_length=10) start_time = models.DateTimeField(auto_now=False, auto_now_add=False)
max_marks = models.IntegerField(null=True) max_marks = models.IntegerField(null=True)
# class TestQuestions(models.Model): # class TestQuestions(models.Model):
......
...@@ -36,7 +36,7 @@ Create Test ...@@ -36,7 +36,7 @@ Create Test
<!-- <li> --> <!-- <li> -->
<div class="row toggle"> <div class="row toggle">
<div class="col-xs-10"> <div class="col-xs-10">
<input type="checkbox" value= "True" name = "i{{question.q_id}}" > <input type="checkbox" value= "True" name = "{{question.q_id}}" >
{{question.question_text}} {{question.q_id}} </br> {{question.question_text}} {{question.q_id}} </br>
</div> </div>
</div> </div>
......
...@@ -255,7 +255,7 @@ profile ...@@ -255,7 +255,7 @@ profile
<button type="submit" class="btn btn-login float-right">Submit</button> <button type="submit" class="btn btn-login float-right">Submit</button>
</form> </form>
</ol>
{%endblock%} {%endblock%}
{%extends 'base2.html'%}
{%block head%}
{%endblock%}
{%block title%}
{{testName}}
{%endblock%}
{%block body%}
<ol>
<form class="exam-form" method="POST" action="/arfa/result">
{% csrf_token %}
<!-- {{ data }} -->
<input name="testID" value="{{testID}}" type="hidden">
{% for question, options in questions.items %}
<li style="font-weight: bold;">Question : {{ question }}</li>
{% for option in options %}
<input type="checkbox" name = "{{option.0}}" value= "{{option.1}}" >{{ option.2 }} </br>
{% endfor %}
{% endfor %}
<button type="submit" class="btn btn-login float-right">Submit</button>
</form>
</ol>
{%endblock%}
\ No newline at end of file
...@@ -21,7 +21,8 @@ My Tests ...@@ -21,7 +21,8 @@ My Tests
<p>{{t.test_name}}</p> <p>{{t.test_name}}</p>
</div> </div>
<div style="float:right"> <div style="float:right">
<form method="POST" action="loadStudentTest"> <form method="POST" action="arfa/loadStudentTest">
{% csrf_token %}
<input name="testID" value="{{t.test_ID}}" type="hidden"> <input name="testID" value="{{t.test_ID}}" type="hidden">
<button>Load Test</button> <button>Load Test</button>
</form> </form>
...@@ -46,8 +47,9 @@ My Tests ...@@ -46,8 +47,9 @@ My Tests
</div> </div>
<div style="float:right"> <div style="float:right">
<form method="POST" action="loadStudentTest"> <form method="POST" action="loadStudentTest">
{% csrf_token %}
<input name="testID" value="{{t.test_ID}}" type="hidden"> <input name="testID" value="{{t.test_ID}}" type="hidden">
<button>Load Test</button> <button type="submit">Load Test</button>
</form> </form>
</div> </div>
{% endfor %} {% endfor %}
......
...@@ -25,6 +25,7 @@ urlpatterns=[ ...@@ -25,6 +25,7 @@ urlpatterns=[
url(r'^add_question',views.add_question), url(r'^add_question',views.add_question),
url(r'^register',views.register), url(r'^register',views.register),
url(r'^reg',views.reg), url(r'^reg',views.reg),
url(r'^studentTestHome', views.studentTestHome) url(r'^studentTestHome', views.studentTestHome),
url(r'^loadStudentTest', views.loadStudentTest)
] ]
...@@ -8,6 +8,7 @@ from .models import Test ...@@ -8,6 +8,7 @@ from .models import Test
from .models import Question from .models import Question
from .models import Options from .models import Options
from .models import Student from .models import Student
from .models import Evaluation
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpResponse from django.http import HttpResponse
......
...@@ -9,6 +9,8 @@ from .models import Test ...@@ -9,6 +9,8 @@ from .models import Test
from .models import Question from .models import Question
from .models import Options from .models import Options
from .models import Student from .models import Student
from .models import Contains
from .models import Evaluation
from . import utilities from . import utilities
from .utilities import evaluate from .utilities import evaluate
from . import forms from . import forms
...@@ -174,9 +176,40 @@ def studentTestHome(request): ...@@ -174,9 +176,40 @@ def studentTestHome(request):
return render(request, 'ARFA_app/studentTestHome.html', data) return render(request, 'ARFA_app/studentTestHome.html', data)
def loadStudentTest(request): def loadStudentTest(request):
if request.method == 'POST': print request.POST
test_ID = request.POST['test_ID'] if(request.session.get('session',None)!=True):
return render(request,'ARFA_app/login.html')
if request.method == 'GET':
return render(request, 'ARFA_app/home.html')
args = {}
args['username'] = request.session['username']
args['is_session'] = True
test_ID = request.POST['testID']
testName = Test.objects.values('test_name').get(pk=test_ID)
print testName
questions = Contains.objects.filter(test_ID=test_ID).values('q_ID')
options = models.Options.objects.select_related('q_ID').filter(q_ID__in = questions)
print test_ID
print questions.all()
questionsJSON = {}
for option in options:
if option.q_ID.question_text in questionsJSON:
questionsJSON[option.q_ID.question_text].append(
[option.q_ID.q_ID, option.pk, option.option_Value])
else:
questionsJSON[option.q_ID.question_text] = [[option.q_ID.q_ID,
option.pk, option.option_Value]]
# print option.option_Value
# print option.q_ID.q_ID
args['questions'] = questionsJSON
args['testName'] = testName
args['testID'] = test_ID
return render(request, 'ARFA_app/loadStudentTest.html', args)
def testHome(request): def testHome(request):
# if request.method == 'GET': # if request.method == 'GET':
...@@ -331,7 +364,7 @@ def create_Test(request): ...@@ -331,7 +364,7 @@ def create_Test(request):
creator.save() creator.save()
else: else:
if form.errors: if form.errors:
for field in form : for field in form:
print field.errors print field.errors
return HttpResponse("Test Form Invalid") return HttpResponse("Test Form Invalid")
...@@ -344,7 +377,7 @@ def create_Test(request): ...@@ -344,7 +377,7 @@ def create_Test(request):
pass pass
containsObj = models.Contains(test_ID=test) containsObj = models.Contains(test_ID=test)
# print data
for q in data.keys(): for q in data.keys():
if len(data[q]) != 3: if len(data[q]) != 3:
continue continue
......
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