Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ARFA
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
ARFA
ARFA
Commits
e3b5d79e
Commit
e3b5d79e
authored
Nov 25, 2018
by
Rahul-chunduru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time counter
parent
6ecc6068
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
143 additions
and
68 deletions
+143
-68
ARFA/ARFA_app/migrations/0001_initial.py
ARFA/ARFA_app/migrations/0001_initial.py
+12
-2
ARFA/ARFA_app/migrations/0002_auto_20181125_1807.py
ARFA/ARFA_app/migrations/0002_auto_20181125_1807.py
+25
-0
ARFA/ARFA_app/migrations/0003_auto_20181125_1102.py
ARFA/ARFA_app/migrations/0003_auto_20181125_1102.py
+0
-30
ARFA/ARFA_app/models.py
ARFA/ARFA_app/models.py
+7
-3
ARFA/ARFA_app/templates/ARFA_app/create_question.html
ARFA/ARFA_app/templates/ARFA_app/create_question.html
+20
-1
ARFA/ARFA_app/templates/ARFA_app/home.html
ARFA/ARFA_app/templates/ARFA_app/home.html
+0
-21
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
+54
-5
ARFA/ARFA_app/urls.py
ARFA/ARFA_app/urls.py
+2
-2
ARFA/ARFA_app/views.py
ARFA/ARFA_app/views.py
+23
-4
No files found.
ARFA/ARFA_app/migrations/0001_initial.py
View file @
e3b5d79e
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1
6 on 2018-11-24 13:16
# Generated by Django 1.11.1
4 on 2018-11-25 16:12
from
__future__
import
unicode_literals
import
django.core.validators
...
...
@@ -87,6 +87,16 @@ class Migration(migrations.Migration):
(
'faculty'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'ARFA_app.Faculty'
)),
],
),
migrations
.
CreateModel
(
name
=
'QuestionImage'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'image'
,
models
.
FileField
(
upload_to
=
'QuestionImages/'
)),
(
'imageDesc'
,
models
.
CharField
(
max_length
=
100
)),
(
'orderNum'
,
models
.
IntegerField
(
default
=
1
)),
(
'question'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'ARFA_app.Question'
)),
],
),
migrations
.
CreateModel
(
name
=
'Responses'
,
fields
=
[
...
...
@@ -137,7 +147,7 @@ class Migration(migrations.Migration):
(
'ownership'
,
models
.
CharField
(
max_length
=
20
)),
(
'expected_time_for_completion'
,
models
.
DurationField
(
blank
=
True
)),
(
'start_time'
,
models
.
DateTimeField
()),
(
'max_marks'
,
models
.
Float
Field
(
null
=
True
)),
(
'max_marks'
,
models
.
Integer
Field
(
null
=
True
)),
],
),
migrations
.
AddField
(
...
...
ARFA/ARFA_app/migrations/0002_auto_20181125_
0931
.py
→
ARFA/ARFA_app/migrations/0002_auto_20181125_
1807
.py
View file @
e3b5d79e
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1
6 on 2018-11-25 09:31
# Generated by Django 1.11.1
4 on 2018-11-25 18:07
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
...
...
@@ -12,19 +12,14 @@ class Migration(migrations.Migration):
]
operations
=
[
migrations
.
A
lter
Field
(
model_name
=
'
test
'
,
name
=
'
expected_time_for_completion
'
,
field
=
models
.
CharField
(
max_length
=
1
0
),
migrations
.
A
dd
Field
(
model_name
=
'
question
'
,
name
=
'
num_appeared
'
,
field
=
models
.
IntegerField
(
default
=
0
),
),
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
),
migrations
.
AddField
(
model_name
=
'question'
,
name
=
'num_correct'
,
field
=
models
.
IntegerField
(
default
=
0
),
),
]
ARFA/ARFA_app/migrations/0003_auto_20181125_1102.py
deleted
100644 → 0
View file @
6ecc6068
# -*- 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
(),
),
]
ARFA/ARFA_app/models.py
View file @
e3b5d79e
...
...
@@ -86,12 +86,16 @@ class Question(models.Model):
difficulty_observed
=
models
.
CharField
(
max_length
=
20
)
question_text
=
models
.
CharField
(
max_length
=
1000
)
image_link
=
models
.
CharField
(
max_length
=
200
)
num_appeared
=
models
.
IntegerField
num_correct
=
models
.
IntegerField
num_appeared
=
models
.
IntegerField
(
default
=
0
)
num_correct
=
models
.
IntegerField
(
default
=
0
)
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
):
...
...
ARFA/ARFA_app/templates/ARFA_app/create_question.html
View file @
e3b5d79e
...
...
@@ -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>
...
...
ARFA/ARFA_app/templates/ARFA_app/home.html
View file @
e3b5d79e
...
...
@@ -234,28 +234,7 @@ profile
</p>
<button type="button" class="btn btn-login float-right" onclick="loadTest()">Load Test</button> -->
<form
action=
"testHome"
method=
'POST'
>
{% csrf_token %}
<button
class=
"btn btn-login float-right"
type=
"submit"
>
Load Test
</button>
</form>
</br>
<ol>
<form
class=
"exam-form"
method=
"POST"
action=
"/arfa/result"
>
{% csrf_token %}
<!-- {{ data }} -->
<input
name=
"testID"
value=
"{{data.testID}}"
type=
"hidden"
>
{{ username }}
{% for question, options in data.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%}
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
View file @
e3b5d79e
...
...
@@ -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
ARFA/ARFA_app/urls.py
View file @
e3b5d79e
...
...
@@ -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
),
...
...
ARFA/ARFA_app/views.py
View file @
e3b5d79e
...
...
@@ -230,12 +230,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
:
...
...
@@ -246,10 +253,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
):
...
...
@@ -397,7 +409,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
()
...
...
@@ -511,4 +523,11 @@ def view_personal_Test(request):
def
addimage
(
request
):
files
=
request
.
FILES
print
files
print
"hello"
return
HttpResponse
(
"success"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment