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
22db66fb
Commit
22db66fb
authored
Nov 26, 2018
by
NARRA SURAJ
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.cse.iitb.ac.in/ARFA/ARFA
parents
af504fb0
5c5ae581
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
92 deletions
+118
-92
.gitignore
.gitignore
+2
-1
ARFA/ARFA_app/forms.py
ARFA/ARFA_app/forms.py
+8
-1
ARFA/ARFA_app/models.py
ARFA/ARFA_app/models.py
+4
-4
ARFA/ARFA_app/static/ARFA_app/create_question.css
ARFA/ARFA_app/static/ARFA_app/create_question.css
+3
-2
ARFA/ARFA_app/templates/ARFA_app/create_question.html
ARFA/ARFA_app/templates/ARFA_app/create_question.html
+69
-72
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
+3
-3
ARFA/ARFA_app/templates/ARFA_app/studentTestHome.html
ARFA/ARFA_app/templates/ARFA_app/studentTestHome.html
+1
-1
ARFA/ARFA_app/utilities.py
ARFA/ARFA_app/utilities.py
+1
-1
ARFA/ARFA_app/views.py
ARFA/ARFA_app/views.py
+27
-7
No files found.
.gitignore
View file @
22db66fb
*.pyc
\ No newline at end of file
*.pyc
logfile
\ No newline at end of file
ARFA/ARFA_app/forms.py
View file @
22db66fb
...
...
@@ -4,6 +4,8 @@ from django.contrib.auth.models import User
from
.models
import
*
from
django.forms.widgets
import
Select
,
Widget
,
DateTimeInput
,
TimeInput
import
datetime
from
.models
import
QuestionImage
from
django.forms
import
Textarea
# from datetimepicker.widgets import DateTimePicker
# class QuestionForm(forms.ModelForm):
...
...
@@ -17,7 +19,7 @@ import datetime
# model = Options
# fields = ('option_value',)
VISIBILITY_CHOICES
=
(
'1980'
,
'1981'
,
'1982'
)
#
VISIBILITY_CHOICES= ('1980', '1981', '1982')
# class TestForm(forms.ModelForm):
# # start_time = forms.DateTimeField(widget=DateTimePicker(), initial=datetime.datetime.now())
...
...
@@ -28,6 +30,11 @@ VISIBILITY_CHOICES= ('1980', '1981', '1982')
# model = Test
# exclude = ['test_ID', 'ownership']
class
ImageFileUploadForm
(
forms
.
ModelForm
):
q_id
=
forms
.
IntegerField
(
label
=
''
)
class
Meta
:
model
=
QuestionImage
fields
=
[
'image'
,
'imageDesc'
]
class
TestForm
(
forms
.
ModelForm
):
# start_time = forms.DateTimeField(input_formats=['%Y-%m-%dT%H:%M'])
...
...
ARFA/ARFA_app/models.py
View file @
22db66fb
...
...
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from
django.db
import
models
from
django.core.validators
import
MinLengthValidator
# Create your models here.
class
arfa_user
(
models
.
Model
):
...
...
@@ -85,18 +86,17 @@ class Question(models.Model):
difficulty_set
=
models
.
CharField
(
max_length
=
20
)
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
(
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
)
image
_id
=
models
.
AutoField
(
primary_key
=
True
)
image
=
models
.
FileField
(
upload_to
=
'ARFA_app/static/ARFA_app/QuestionImages/'
)
imageDesc
=
models
.
CharField
(
max_length
=
100
)
orderNum
=
models
.
IntegerField
(
default
=
1
)
q_ID
=
models
.
ForeignKey
(
'Question'
,
null
=
True
)
class
Takes
(
models
.
Model
):
student
=
models
.
ForeignKey
(
'Student'
,
models
.
SET_NULL
,
blank
=
True
,
null
=
True
)
...
...
ARFA/ARFA_app/static/ARFA_app/create_question.css
View file @
22db66fb
...
...
@@ -18,7 +18,7 @@
height
:
2px
;
background
:
#e0e0e0
;
position
:
absolute
;
width
:
8
0%
;
width
:
6
0%
;
margin
:
0
auto
;
left
:
0
;
right
:
0
;
...
...
@@ -44,6 +44,7 @@ span.round-tab {
z-index
:
2
;
position
:
absolute
;
left
:
0
;
padding-top
:
15px
;
text-align
:
center
;
font-size
:
25px
;
}
...
...
@@ -65,7 +66,7 @@ span.round-tab:hover {
}
.wizard
.nav-tabs
>
li
{
width
:
25
%
;
width
:
33
%
;
}
.wizard
li
:after
{
...
...
ARFA/ARFA_app/templates/ARFA_app/create_question.html
View file @
22db66fb
...
...
@@ -12,6 +12,8 @@
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#images
'
).
hide
();
$
(
'
#id_q_id
'
).
hide
()
;
//Initialize tooltips
$
(
'
.nav-tabs > li a[title]
'
).
tooltip
();
...
...
@@ -51,6 +53,8 @@ function prevTab(elem) {
<script
type=
"text/javascript"
>
var
question_data
=
{}
;
var
options_details
=
{};
var
id
=
-
1
;
var
hasimage
=
0
;
function
addOption
()
{
var
n
=
document
.
getElementById
(
"
optno
"
);
...
...
@@ -65,11 +69,8 @@ function prevTab(elem) {
var
label
=
document
.
createElement
(
"
label
"
);
label
.
innerHTML
=
"
Option
"
+
x
+
"
:
"
;
que
.
appendChild
(
label
);
// que.className = "row" ;
var
r
=
document
.
createElement
(
"
div
"
)
;
r
.
className
=
"
row
"
;
// r.innerHTML = "
<
tr
><
input
class
=
\
"
form-control
\"
size=
\"
30
\"
type=
\"
text
\"
><input class =
\"
form-control
\"
size=
\"
30
\"
type=
\"
text
\"
></tr>
"
;
var
input
=
document
.
createElement
(
"
input
"
);
var
check
=
document
.
createElement
(
"
input
"
);
var
check_ans
=
document
.
createElement
(
"
label
"
);
...
...
@@ -91,12 +92,6 @@ function prevTab(elem) {
r
.
appendChild
(
check
)
;
r
.
appendChild
(
check_ans
)
;
que
.
appendChild
(
r
);
// var text = que.value ;
// text = text + "
<
input
className
=
'
form-control
'
type
=
'
text
'
size
=
'
20
'
placeholder
=
'
Enter an option
'
>
"
;
// document.getElementById('options').innerHTML = text ;
container
.
appendChild
(
que
);
}
function
deleteLastOption
()
...
...
@@ -110,7 +105,7 @@ function prevTab(elem) {
}
function
step1
()
{
{
var
subject
=
document
.
getElementById
(
'
subject
'
)
;
var
qtext
=
document
.
getElementById
(
'
qtext
'
).
value
;
question_data
[
'
subject_ID
'
]
=
subject
.
value
;
...
...
@@ -121,7 +116,7 @@ function prevTab(elem) {
}
function
step2
()
{
{
var
O
=
document
.
getElementById
(
"
options
"
)
;
var
children
=
O
.
children
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
...
...
@@ -135,53 +130,27 @@ function prevTab(elem) {
}
console
.
log
(
options_details
)
;
document
.
getElementById
(
'
l3
'
).
click
()
;
}
function
step3
()
{
$
(
'
#images
'
).
hide
();
document
.
getElementById
(
'
l4
'
).
click
()
;
}
function
post
()
{
// var xhttp = new XMLHttpRequest();
Data
=
{
'
question_data
'
:
question_data
,
'
options_details
'
:
options_details
}
;
console
.
log
(
Data
)
;
// D = {
// client_response : Data,
// csrfmiddlewaretoken: '{{ csrf_token }}'
// } ;
// console.log(D) ;
// var csrftoken = Cookies.get('csrftoken');
// xhttp.onreadystatechange = function() {
// if (this.readyState == 4 && this.status == 200) {
// alert(this.responseText);
// }
// };
// xhttp.open(
"
POST
"
,
"
add_question
"
, true);
// xhttp.send();
// $.post({
// url:
"
add_question
"
,
// data: Data,
//
"
success
"
: function(result) {
// console.log(result);
// }
// }) ;
// console.log( document.getElementById(
"
upload
"
).value ) ;
// document.getElementById(
"
imageForm
"
).submit();
// console.log(
"
still
"
) ;
$
.
ajax
({
url
:
"
add_question
"
,
type :
"
POST
"
,
type
:
"
POST
"
,
data
:
{
client_response
:
JSON
.
stringify
(
Data
),
csrfmiddlewaretoken
:
'
{{ csrf_token }}
'
},
// data : Data ,
// headers: {
// csrfmiddlewaretoken: '{{ csrf_token }}'
// },
success
:
function
(
p
)
{
q
=
JSON
.
parse
(
p
);
console
.
log
(
q
)
;
...
...
@@ -190,7 +159,9 @@ function prevTab(elem) {
alert
(
'
Reason
'
+
'
:
'
+
q
.
reason
)
}
else
{
alert(
"
Successfully
added
to
database
"
) ;
alert
(
"
Successfully added question to database
"
)
;
console
.
log
(
"
Return from post
"
+
q
[
'
q_ID
'
])
;
id
=
q
[
'
q_ID
'
]
;
}
},
error
:
function
(
xhr
,
errmsg
,
err
)
{
...
...
@@ -199,9 +170,50 @@ function prevTab(elem) {
});
}
function
intend_to_add_img
(){
$
(
'
#images
'
).
show
();
hasimage
=
1
;
}
function
uploadImage
()
{
var data = new FormData($('form').get(0));
console
.
log
(
"
Need to add to question
"
+
id
)
;
document
.
getElementById
(
'
id_q_id
'
).
value
=
id
;
$
(
'
#imageForm
'
).
submit
(
function
(
e
){
e
.
preventDefault
();
$form
=
$
(
this
)
var
formData
=
new
FormData
(
this
);
i
=
0
;
console
.
log
(
"
adding here...
"
)
;
$
.
ajax
({
url
:
"
addimage
"
,
type
:
'
POST
'
,
data
:
formData
,
success
:
function
(
response
)
{
$
(
'
.error
'
).
remove
();
console
.
log
(
response
)
if
(
response
.
error
){
$
.
each
(
response
.
errors
,
function
(
name
,
error
){
error
=
'
<small class="text-muted error">
'
+
error
+
'
</small>
'
$form
.
find
(
'
[name=
'
+
name
+
'
]
'
).
after
(
error
);
})
}
else
{
alert
(
response
.
message
)
i
=
1
;
window
.
location
=
""
;
console
.
log
(
"
Added image also
"
)
;
}
},
cache
:
false
,
contentType
:
false
,
processData
:
false
});
});
document
.
getElementById
(
'
imageForm
'
).
submit
()
;
console
.
log
(
"
Image ADDED.. hopefully
"
)
;
}
...
...
@@ -248,13 +260,6 @@ Create Question
</a>
</li>
<li
role=
"presentation"
class=
"disabled"
>
<a
href=
"#complete"
data-toggle=
"tab"
aria-controls=
"complete"
role=
"tab"
title=
"Complete"
id =
"l4"
>
<span
class=
"round-tab"
>
<i
class=
"glyphicon glyphicon-ok"
></i>
</span>
</a>
</li>
</ul>
</div>
...
...
@@ -277,7 +282,7 @@ Create Question
</div>
<ul
class=
"list-inline pull-right"
>
<li><a
href=
"#step2"
><button
type=
"button"
class=
"btn btn-primary next-step"
onclick=
"step1()"
>
Save and continue
</button></a></li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"form-group col-lg-12"
>
<label>
Question Text
</label>
...
...
@@ -302,34 +307,26 @@ Create Question
<h3>
Step 3 - Add some pictures
</h3>
<p>
Drop images in the order you want to display
</p>
<ul
class=
"list-inline pull-right"
>
<li><button
type=
"button"
class=
"btn btn-default prev-step"
onclick=
"document.getElementById('l2').click() ;"
>
Previous
</button></li>
<li><button
type=
"button"
class=
"btn btn-default prev-step"
onclick=
"document.getElementById('l2').click() ;
"
>
Previous
</button></li>
<li><button
type=
"button"
class=
"btn btn-default next-step"
onclick=
"document.getElementById('l4').click() ;"
>
Skip
</button></li>
<li><button
align=
"left"
type=
"button"
class=
"btn btn-primary"
id=
"addsubjectiveque"
onclick=
"intend_to_add_img() ; post()"
>
Add an image
</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> -->
</ul>
</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>
</ul>
</div>
<div
class=
"clearfix"
></div>
</div>
</form>
<div
id =
"images"
>
<form
method=
"POST"
enctype=
"multipart/form-data"
id=
"imageForm"
novalidate=
""
>
{% csrf_token %}
{{ form.as_p }}
<button
onclick=
"uploadImage()"
class=
"btn btn-primary btn-info-full"
>
Post the Question
</button>
</form>
</div>
</div>
</section>
</div>
...
...
ARFA/ARFA_app/templates/ARFA_app/loadStudentTest.html
View file @
22db66fb
...
...
@@ -19,7 +19,9 @@ Total Time :<b > {{total_time.hours}} {{total_time.minutes}} </b>
// Set the date we're counting down to
var
countDownDate
=
new
Date
(
{{
end_time
}}
);
countDownDate
.
setMonth
(
countDownDate
.
getMonth
()
-
1
)
;
countDownDate
.
setMonth
(
countDownDate
.
getMonth
()
-
1
)
;
countDownDate
.
setMonth
(
countDownDate
.
getMonth
()
-
1
)
;
countDownDate
.
setMonth
(
countDownDate
.
getMonth
()
-
1
)
;
console
.
log
(
countDownDate
)
;
// Update the count down every 1 second
var
x
=
setInterval
(
function
()
{
...
...
@@ -52,7 +54,6 @@ var x = setInterval(function() {
<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"
>
{% for question, options in questions.items %}
<div
class=
"row"
style=
"margin-top: 10px; margin-bottom: 10px"
>
...
...
@@ -62,7 +63,6 @@ var x = setInterval(function() {
{% endfor %}
</div>
{% endfor %}
<button
type=
"submit"
class=
"btn btn-login"
style=
"float: right;"
>
Submit
</button>
</form>
</font>
...
...
ARFA/ARFA_app/templates/ARFA_app/studentTestHome.html
View file @
22db66fb
...
...
@@ -24,7 +24,7 @@ My Tests
<form
method=
"POST"
action=
"loadStudentTest"
>
{% csrf_token %}
<input
name=
"testID"
value=
"{{t.test_ID}}"
type=
"hidden"
>
<button
>
Load Test
</button>
<button
type=
"submit"
class=
"btn btn-login float-right"
style=
"margin-top: 10px ;margin-right: 40px"
>
Load Test
</button>
</form>
</div>
{% endfor %}
...
...
ARFA/ARFA_app/utilities.py
View file @
22db66fb
...
...
@@ -115,7 +115,7 @@ def get_all_questions(request):
# args = {'username':'mathura'}
cursor
=
connection
.
cursor
()
cursor
.
execute
(
''' SELECT s.subject,q."q_ID" as q_ID,q.question_text,q.topic,q.subtopic,q.source,
q.difficulty_set,q.
image_link,q.
visibility,q.ownership,o."option_Value" as option_details,
q.difficulty_set,q.visibility,q.ownership,o."option_Value" as option_details,
o."is_Answer"
FROM "ARFA_app_question" as q,
"ARFA_app_options" as o,"ARFA_app_subject" as s
...
...
ARFA/ARFA_app/views.py
View file @
22db66fb
...
...
@@ -25,6 +25,8 @@ from django.db import connection
from
django.db
import
IntegrityError
from
django.db.models
import
F
from
.forms
import
TestForm
from
.forms
import
ImageFileUploadForm
from
django.http
import
JsonResponse
import
datetime
def
login
(
request
):
...
...
@@ -230,6 +232,7 @@ def studentTestHome(request):
return
HttpResponse
(
"Not a student"
)
now
=
datetime
.
datetime
.
now
()
print
now
activeTests
=
Test
.
objects
.
filter
(
start_time__gte
=
now
-
F
(
'expected_time_for_completion'
),
start_time__lte
=
now
)
practiceTests
=
Test
.
objects
.
filter
(
start_time__lte
=
now
-
F
(
'expected_time_for_completion'
))
...
...
@@ -268,6 +271,7 @@ def loadStudentTest(request):
testName
=
Test
.
objects
.
values
(
'test_name'
)
.
get
(
pk
=
test_ID
)
st
=
Test
.
objects
.
values
(
'start_time'
)
.
get
(
pk
=
test_ID
)
start_time
=
st
[
'start_time'
]
# start_time = start_time + datetime.timedelta(hours=5,minutes=30)
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'
]
...
...
@@ -360,7 +364,12 @@ def result(request):
def
create_question
(
request
):
return
render
(
request
,
'ARFA_app/create_question.html'
,
request
.
session
.
get
(
'args'
,
None
))
form
=
ImageFileUploadForm
arg1
=
{
'form'
:
form
}
args
=
request
.
session
.
get
(
'args'
,
None
)
if
args
!=
None
:
arg1
.
update
(
args
)
return
render
(
request
,
'ARFA_app/create_question.html'
,
arg1
)
def
view_personal_question
(
request
):
...
...
@@ -372,7 +381,7 @@ def view_personal_question(request):
args
=
{
'username'
:
request
.
session
[
'username'
],
'is_session'
:
True
}
cursor
=
connection
.
cursor
()
cursor
.
execute
(
''' SELECT s.subject,q."q_ID" as q_ID,q.question_text,q.topic,q.subtopic,q.source,
q.difficulty_set,q.
image_link,q.
visibility,q.ownership,o."option_Value" as option_details,
q.difficulty_set,q.visibility,q.ownership,o."option_Value" as option_details,
o."is_Answer"
FROM "ARFA_app_question" as q,
"ARFA_app_options" as o,"ARFA_app_subject" as s
...
...
@@ -631,7 +640,7 @@ def add_question(request):
option
=
models
.
Options
(
q_ID
=
question
,
option_Value
=
options
[
str
(
i
)][
'option_Value'
],
is_Answer
=
options
[
str
(
i
)][
'is_Answer'
],
option_ID
=
options
[
str
(
i
)][
'id'
])
option
.
save
()
return
HttpResponse
(
json
.
dumps
({
'status'
:
'Success'
}))
return
HttpResponse
(
json
.
dumps
({
'status'
:
'Success'
,
'q_ID'
:
question
.
q_ID
}))
except
:
return
HttpResponse
(
json
.
dumps
({
'status'
:
'Failed'
,
'reason'
:
'input/database error'
}))
...
...
@@ -661,10 +670,21 @@ def view_personal_Test(request):
def
addimage
(
request
):
files
=
request
.
FILES
print
files
print
"hello"
return
HttpResponse
(
"success"
)
if
request
.
method
==
'POST'
:
form
=
ImageFileUploadForm
(
request
.
POST
,
request
.
FILES
)
print
form
.
data
print
form
.
data
[
'q_id'
]
if
form
.
is_valid
():
p
=
form
.
save
()
p
.
q_ID
=
models
.
Question
(
q_ID
=
form
.
data
[
'q_id'
])
p
.
save
()
print
p
.
image_id
return
JsonResponse
({
'error'
:
False
,
'message'
:
'Uploaded Successfully'
,
'id'
:
p
.
image_id
})
else
:
return
JsonResponse
({
'error'
:
True
,
'errors'
:
form
.
errors
})
else
:
return
redirect
(
'/arfa'
)
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