Commit 6d27c864 authored by SANCHIT JAIN's avatar SANCHIT JAIN

added date time

parents 1d76ca5d 5becfe94
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-25 18:07
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ARFA_app', '0003_auto_20181125_1102'),
]
operations = [
migrations.AddField(
model_name='question',
name='num_appeared',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='question',
name='num_correct',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='test',
name='max_marks',
field=models.IntegerField(null=True),
),
]
......@@ -91,7 +91,11 @@ class Question(models.Model):
visibility = models.CharField(max_length=20)
ownership = models.CharField(max_length=20)
class QuestionImage(models.Model):
image = models.FileField(upload_to='QuestionImages/' )
question = models.ForeignKey('Question' , on_delete=models.CASCADE)
imageDesc = models.CharField(max_length=100)
orderNum = models.IntegerField(default=1)
class Takes(models.Model):
......@@ -151,4 +155,4 @@ class ContactUs(models.Model):
phone_number = models.CharField(max_length=10)
email_ID=models.CharField(max_length=200)
text = models.CharField(max_length=200)
\ No newline at end of file
......@@ -167,7 +167,10 @@ function prevTab(elem) {
// console.log(result);
// }
// }) ;
// console.log( document.getElementById("upload").value ) ;
// document.getElementById("imageForm").submit();
// console.log("still") ;
$.ajax({
url : "add_question",
type : "POST",
......@@ -196,6 +199,10 @@ function prevTab(elem) {
});
}
function uploadImage()
{
var data = new FormData($('form').get(0));
}
......@@ -299,10 +306,22 @@ Create Question
<li><button type="button" class="btn btn-default next-step" onclick="document.getElementById('l4').click() ;">Skip</button></li>
<li><button type="button" class="btn btn-primary btn-info-full next-step" onclick="step3()">Save and continue</button></li>
</ul>
<!-- <form method="post" action="addimage" enctype="multipart/form-data" id="imageForm">
{% csrf_token %}
<label for="upload">
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
<input type="file" id="upload" style="display:none">
</label><br>
<button onclick="post()" class="btn btn-primary btn-info-full" >Post the Question</button>
</form> -->
</div>
<div class="tab-pane" role="tabpanel" id="complete">
<h3>Complete</h3>
<p>You have successfully completed all steps. Here's the preview</p>
<ul class="list-inline pull-right">
<li><button type="button" class="btn btn-default prev-step">Previous</button></li>
<li><button type="button" class="btn btn-primary btn-info-full next-step" onclick="post()">Post </button></li>
......
......@@ -217,6 +217,32 @@ profile
</div>
</div>
</div>
<!-- <h1>USER PROFILE You have succesfully logged in {{ name }} and your password is {{ password }}</h1>
<script type="text/javascript">
function loadTest()
{
// {% csrf_token %}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
alert("asjdb");
}
};
xhttp.open("POST", "/arfa/testHome", true);
// alert("alert2");
xhttp.send();
}
</script>
<p id = "demo">
</p>
<button type="button" class="btn btn-login float-right" onclick="loadTest()">Load Test</button> -->
{%endblock%}
......@@ -3,23 +3,72 @@
{%endblock%}
{%block title%}
{{testName}}
Test {{testName.test_name}}
{%endblock%}
{%block body%}
<div>
<div style="float: right;">
Total Time :<b > {{total_time.hours}} {{total_time.minutes}} </b>
<p> Max Marks. <b>{{max_marks}}</b> </p>
<div id="Timer" style="border-style: solid; text-align: center;"></div>
</div>
<h2 align="center" style=" text-decoration: underline;"><b> {{testName.test_name}} </b> </h2>
</div>
<script>
// Set the date we're counting down to
var countDownDate = new Date( {{ end_time }} );
countDownDate.setMonth(countDownDate.getMonth() - 1) ;
console.log(countDownDate) ;
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
console.log(distance) ;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("Timer").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("Timer").innerHTML = "EXPIRED";
}
}, 1000);
</script>
<div style="margin-left: 5%; margin-top: 10%">
<ol>
<font size="3">
<form class="exam-form" method="POST" action="/arfa/result">
<p style="margin-right: 5%"> <b> Questions </b></p>
{% csrf_token %}
<!-- {{ data }} -->
<input name="testID" value="{{testID}}" type="hidden">
<input name="testID" value="{{testID}}" type="hidden" >
{% for question, options in questions.items %}
<li style="font-weight: bold;">Question : {{ question }}</li>
<div class="row" style="margin-top: 10px; margin-bottom: 10px">
<li style="font-weight: bold;" > {{ question }}</li>
{% for option in options %}
<input type="checkbox" name = "{{option.0}}" value= "{{option.1}}" >{{ option.2 }} </br>
<input type="checkbox" name = "{{option.0}}" value= "{{option.1}}" > {{ option.2 }} </br>
{% endfor %}
</div>
{% endfor %}
<button type="submit" class="btn btn-login float-right">Submit</button>
<button type="submit" class="btn btn-login" style="float: right;">Submit</button>
</form>
</font>
</ol>
<br><br><br><br><br><br>
</div>
{%endblock%}
\ No newline at end of file
......@@ -5,7 +5,6 @@ urlpatterns=[
url(r'^$',views.login),
url(r'^profile',views.profile),
url(r'^logout',views.logout),
url(r'^testHome', views.testHome),
url(r'^result', views.result),
url(r'^create_question',views.create_question),
......@@ -22,7 +21,8 @@ urlpatterns=[
url(r'^faculty',views.faculty),
url(r'^ContactUs',views.ContactUs),
url(r'^send_mess',views.send_mess),
url(r'^add_question',views.add_question),
url(r'^add_question',views.add_question),
url(r'^addimage',views.addimage),
url(r'^register',views.register),
url(r'^reg',views.reg),
url(r'^studentTestHome', views.studentTestHome),
......
......@@ -260,12 +260,19 @@ def loadStudentTest(request):
test_ID = request.POST['testID']
testName = Test.objects.values('test_name').get(pk=test_ID)
print testName
st = Test.objects.values('start_time').get(pk=test_ID)
start_time = st['start_time']
M = Test.objects.values('max_marks').get(pk=test_ID)
total_time = Test.objects.values('expected_time_for_completion').get(pk=test_ID)
end_time = start_time + total_time['expected_time_for_completion']
print end_time.time()
secs = (total_time['expected_time_for_completion'].seconds)
hours = secs // 3600
minute = (secs % 3600) // 60
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:
......@@ -276,10 +283,15 @@ def loadStudentTest(request):
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
args['max_marks'] = M['max_marks']
args['end_time'] = end_time.strftime("%Y, %m,%d, %H,%M,%S")
minutes = ""
if minute != 0:
minutes = str(minute) + " mins"
args['total_time'] = {'hours' : str(hours) + " hr" , 'minutes' : minutes}
return render(request, 'ARFA_app/loadStudentTest.html', args)
def testHome(request):
......@@ -427,7 +439,7 @@ def create_Test(request):
data.pop('csrfmiddlewaretoken')
if not data: #only csrf token was sent, display create test page
return render(request,'ARFA_app/create_Test.html',args)
print vars(form)
if form.is_valid():
test = form.save()
......@@ -541,4 +553,11 @@ def view_personal_Test(request):
def addimage(request):
files = request.FILES
print files
print "hello"
return HttpResponse("success")
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