personal tests

parent 75dcee24
...@@ -40,6 +40,7 @@ INSTALLED_APPS = [ ...@@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
# 'datetimepicker',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -2,8 +2,9 @@ from django import forms ...@@ -2,8 +2,9 @@ from django import forms
from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User from django.contrib.auth.models import User
from .models import * from .models import *
from django.forms.widgets import Select, Widget,DateTimeInput,TimeInput
import datetime
from datetimepicker.widgets import DateTimePicker
# class QuestionForm(forms.ModelForm): # class QuestionForm(forms.ModelForm):
# class Meta: # class Meta:
...@@ -16,7 +17,14 @@ from .models import * ...@@ -16,7 +17,14 @@ from .models import *
# model = Options # model = Options
# fields = ('option_value',) # fields = ('option_value',)
VISIBILITY_CHOICES= ('1980', '1981', '1982')
class TestForm(forms.ModelForm): class TestForm(forms.ModelForm):
class Meta: # start_time = forms.DateTimeField(widget=DateTimePicker(), initial=datetime.datetime.now())
model = Test start_time = forms.DateTimeField(widget=DateTimeInput, initial=datetime.datetime.now())
exclude = ['test_ID', 'ownsership'] expected_time_for_completion = forms.TimeField(widget=TimeInput,initial=datetime.datetime.now())
\ No newline at end of file
class Meta:
model = Test
exclude = ['test_ID', 'ownership']
\ No newline at end of file
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
Create Test Create Test
{%endblock%} {%endblock%}
{%block head%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
{%endblock%}
{%block body%} {%block body%}
<h1> You CAN CREATE A Test HERE prof {{username}}</h1> <h1> You CAN CREATE A Test HERE prof {{username}}</h1>
...@@ -27,18 +35,22 @@ Create Test ...@@ -27,18 +35,22 @@ Create Test
<div class="row toggle"> <div class="row toggle">
<div class="col-xs-10"> <div class="col-xs-10">
<input type="checkbox" value= "True" name = "{{question.q_id}}" > <input type="checkbox" value= "True" name = "{{question.q_id}}" >
{{question.question_text}} {{question.q_id}} </br> {{question.question_text}} </br>
</div> </div>
</div> </div>
<div> <div>
<hr></hr> <hr></hr>
<ul> <ul>
{%for option in question.option_details%} {%for option in question.option_details%}
<li> {{option.is_answer}} {%if option.is_answer %}
{{option.option_text}} <li>
</li> <p style="color: green"> {{option.option_text}} </p>
</li>
<!-- marks --> {%else%}
<li>
{{option.option_text}}
</li>
{%endif%}
{%endfor%} {%endfor%}
<label> marks <label> marks
......
...@@ -40,11 +40,11 @@ profile ...@@ -40,11 +40,11 @@ profile
}); });
</script> </script>
<script type='text/javascript'> <!-- <script type='text/javascript'>
function preventBack(){window.history.forward();} function preventBack(){window.history.forward();}
setTimeout("preventBack()",0); setTimeout("preventBack()",0);
window.onunload =function(){null}; window.onunload =function(){null};
</script> </script> -->
{%endblock%} {%endblock%}
{%block body%} {%block body%}
......
...@@ -34,13 +34,15 @@ View personal Question ...@@ -34,13 +34,15 @@ View personal Question
<!-- <div class="fluid-row"> --> <!-- <div class="fluid-row"> -->
<ul> <ul>
{%for option in question.option_details%} {%for option in question.option_details%}
<!-- <div class="col-xs-1"> --> {%if option.is_answer %}
<li> {{option.is_answer}} <li>
<!-- </div> --> <p style="color: green"> {{option.option_text}} </p>
<!-- <div class="col-xs-5"> --> </li>
{{option.option_text}} {%else%}
<!-- </div> --> <li>
</li> {{option.option_text}}
</li>
{%endif%}
{%endfor%} {%endfor%}
</ul> </ul>
<!-- </div> --> <!-- </div> -->
......
...@@ -6,10 +6,34 @@ ...@@ -6,10 +6,34 @@
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script> </script>
{%endblock%} {%endblock%}
{%block title%} {%block title%}
View personal Test View personal Question
{%endblock%} {%endblock%}
{%block body%} {%block body%}
<h1> You CAN VIEW personal Test HERE prof {{username}}</h1> <h1> You CAN VIEW your tests prof {{username}}</h1>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<div class="container">
<div class="panel-default">
<div class="panel-heading">
<h3 class="panel-title">LIST OF QUESTIONS</h3>
</div>
<ul class="list-group">
<!-- <ul> -->
{%for test in tests%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
{{test.test_name}}
</div>
</div>
<div>
<hr></hr>
</div>
</li>
{%endfor%}
</ul>
</div>
</div>
{%endblock%} {%endblock%}
\ No newline at end of file
...@@ -29,21 +29,19 @@ View personal Question ...@@ -29,21 +29,19 @@ View personal Question
</div> </div>
<div> <div>
<hr></hr> <hr></hr>
<!-- <div class="container"> -->
<!-- <div class="fluid-row"> -->
<ul> <ul>
{%for option in question.option_details%} {%for option in question.option_details%}
<!-- <div class="col-xs-1"> --> {%if option.is_answer %}
<li> {{option.is_answer}} <li>
<!-- </div> --> <p style="color: green"> {{option.option_text}} </p>
<!-- <div class="col-xs-5"> --> </li>
{{option.option_text}} {%else%}
<!-- </div> --> <li>
</li> {{option.option_text}}
</li>
{%endif%}
{%endfor%} {%endfor%}
</ul> </ul>
<!-- </div> -->
<!-- </div> -->
</div> </div>
</li> </li>
{%endfor%} {%endfor%}
......
...@@ -23,7 +23,6 @@ urlpatterns=[ ...@@ -23,7 +23,6 @@ urlpatterns=[
url(r'^send_mess',views.send_mess), url(r'^send_mess',views.send_mess),
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),
] ]
...@@ -313,6 +313,7 @@ def create_Test(request): ...@@ -313,6 +313,7 @@ def create_Test(request):
test = None test = None
TestForm = forms.TestForm() TestForm = forms.TestForm()
args={'username':request.session['username'],'questions':res, 'TestForm':TestForm} args={'username':request.session['username'],'questions':res, 'TestForm':TestForm}
args.update(request.session.get('args',None))
if request.method == "GET": if request.method == "GET":
print res print res
return render(request,'ARFA_app/create_Test.html',args) return render(request,'ARFA_app/create_Test.html',args)
...@@ -356,11 +357,6 @@ def create_Test(request): ...@@ -356,11 +357,6 @@ def create_Test(request):
print data print data
def view_personal_Test(request):
args={'username':request.session['username']}
return render(request,'ARFA_app/view_personal_Test.html',args)
def view_all_Test(request): def view_all_Test(request):
args={'username':request.session['username']} args={'username':request.session['username']}
return render(request,'ARFA_app/view_all_Test.html',args) return render(request,'ARFA_app/view_all_Test.html',args)
...@@ -404,3 +400,26 @@ def add_question(request): ...@@ -404,3 +400,26 @@ def add_question(request):
except: except:
return HttpResponse(json.dumps({'status':'Failed','reason':'input/database error'})) return HttpResponse(json.dumps({'status':'Failed','reason':'input/database error'}))
def view_personal_Test(request):
if(request.session.get('session',None)!=True):
return render(request,'ARFA_app/login.html')
if(request.session.get('role',None)!="faculty"):
return render(request,'ARFA_app/not_a_faculty.html',request.session.get('args',None))
cursor = connection.cursor()
cursor.execute(''' SELECT t."test_ID" as test_ID,t.test_name,t.visibility_student,
t.ownership,t.expected_time_for_completion,t.start_time,t.max_marks
FROM "ARFA_app_created_by" as c,
"ARFA_app_test" as t
WHERE c."test_ID_id" = t."test_ID" and c.faculty_id = %s
order by t.start_time desc ''',[request.session['username']])
rows = cursor.fetchall()
columns = [col[0] for col in cursor.description]
res = dict(zip(columns[:-1], rows))
args={'username':request.session['username'],'tests':res}
return render(request,'ARFA_app/view_personal_Test.html',args)
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