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):
test_name = models.CharField(max_length=200,unique=True)
visibility_student = models.CharField(max_length=20)
ownership = models.CharField(max_length=20)
expected_time_for_completion = models.CharField(max_length=10)
start_time = models.CharField(max_length=10)
expected_time_for_completion = models.DurationField(blank=True)
start_time = models.DateTimeField(auto_now=False, auto_now_add=False)
max_marks = models.IntegerField(null=True)
# class TestQuestions(models.Model):
......
......@@ -36,7 +36,7 @@ Create Test
<!-- <li> -->
<div class="row toggle">
<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>
</div>
</div>
......
......@@ -255,7 +255,7 @@ profile
<button type="submit" class="btn btn-login float-right">Submit</button>
</form>
</ol>
{%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
<p>{{t.test_name}}</p>
</div>
<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">
<button>Load Test</button>
</form>
......@@ -46,8 +47,9 @@ My Tests
</div>
<div style="float:right">
<form method="POST" action="loadStudentTest">
{% csrf_token %}
<input name="testID" value="{{t.test_ID}}" type="hidden">
<button>Load Test</button>
<button type="submit">Load Test</button>
</form>
</div>
{% endfor %}
......
......@@ -25,6 +25,7 @@ urlpatterns=[
url(r'^add_question',views.add_question),
url(r'^register',views.register),
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
from .models import Question
from .models import Options
from .models import Student
from .models import Evaluation
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
......
......@@ -9,6 +9,8 @@ from .models import Test
from .models import Question
from .models import Options
from .models import Student
from .models import Contains
from .models import Evaluation
from . import utilities
from .utilities import evaluate
from . import forms
......@@ -174,9 +176,40 @@ def studentTestHome(request):
return render(request, 'ARFA_app/studentTestHome.html', data)
def loadStudentTest(request):
if request.method == 'POST':
test_ID = request.POST['test_ID']
print request.POST
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):
# if request.method == 'GET':
......@@ -331,7 +364,7 @@ def create_Test(request):
creator.save()
else:
if form.errors:
for field in form :
for field in form:
print field.errors
return HttpResponse("Test Form Invalid")
......@@ -344,7 +377,7 @@ def create_Test(request):
pass
containsObj = models.Contains(test_ID=test)
# print data
for q in data.keys():
if len(data[q]) != 3:
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