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
cd41d35f
Commit
cd41d35f
authored
Nov 26, 2018
by
NARRA SURAJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
max_marks done, frontend and backend
parent
0a4a3412
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
15 deletions
+92
-15
ARFA/ARFA_app/forms.py
ARFA/ARFA_app/forms.py
+1
-1
ARFA/ARFA_app/models.py
ARFA/ARFA_app/models.py
+1
-0
ARFA/ARFA_app/templates/ARFA_app/create_Test.html
ARFA/ARFA_app/templates/ARFA_app/create_Test.html
+73
-4
ARFA/ARFA_app/views.py
ARFA/ARFA_app/views.py
+16
-10
setup
setup
+1
-0
No files found.
ARFA/ARFA_app/forms.py
View file @
cd41d35f
...
...
@@ -45,7 +45,7 @@ class TestForm(forms.ModelForm):
# 'expected_time_for_completion': forms.TimeInput(attrs={'type':'time'}),
# 'start_time': forms.DateInput(attrs={'type':'datetime-local'}),
}
exclude
=
[
'test_ID'
,
'ownership'
]
exclude
=
[
'test_ID'
,
'ownership'
,
'max_marks'
]
# def clean_start_time(self):
# dt = self.cleaned_data['start_time']
# print dt
...
...
ARFA/ARFA_app/models.py
View file @
cd41d35f
...
...
@@ -33,6 +33,7 @@ class Test(models.Model):
expected_time_for_completion
=
models
.
DurationField
(
blank
=
True
)
start_time
=
models
.
DateTimeField
(
auto_now
=
False
,
auto_now_add
=
False
,
blank
=
False
)
max_marks
=
models
.
IntegerField
(
null
=
True
)
# class TestQuestions(models.Model):
# test_ID = models.ForeignKey(
...
...
ARFA/ARFA_app/templates/ARFA_app/create_Test.html
View file @
cd41d35f
{%extends 'base2.html'%}
{%block head%}
<script>
total_marks
=
0
;
num_questions
=
0
;
function
dispTotalMarks
()
{
$
(
'
#total_marks
'
).
html
(
total_marks
);
}
function
computeTotalMarks
()
{
val
=
0
;
$
(
'
.pos_marks
'
).
each
(
function
()
{
//add '#' to the id of checkbox to obtain that element
//'if' condition checks if the box is checked
//if it is, add to val
if
(
document
.
getElementById
(
$
(
this
).
attr
(
'
checkBoxID
'
)).
checked
)
{
console
.
log
(
$
(
this
).
attr
(
'
checkBoxID
'
))
val
+=
parseFloat
(
$
(
this
).
val
());
}
})
total_marks
=
val
;
}
function
handleMarkChange
()
{
computeTotalMarks
();
dispTotalMarks
();
}
function
handleCheckBoxClick
(
cb
)
{
posmarks
=
parseFloat
((
document
.
getElementById
(
cb
.
getAttribute
(
'
posMarksID
'
))).
value
);
// get value of input field like so: element.value
if
(
cb
.
checked
)
{
total_marks
+=
posmarks
;
//update num_questions
num_questions
++
;
}
else
{
total_marks
-=
posmarks
//update num_questions
num_questions
--
;
}
dispTotalMarks
();
dispNumQuestions
();
}
function
dispNumQuestions
()
{
$
(
'
#num_questions
'
).
html
(
num_questions
);
}
</script>
{%endblock%}
{%block title%}
Create Test
...
...
@@ -18,17 +67,28 @@ Create Test
</div>
<ul
class=
"list-group"
>
<!-- <ul> -->
<div>
<div
style=
"float:right ; "
>
Total Marks :
<p
id=
'total_marks'
></p>
</div>
<br/>
<br/>
<br/>
<div
style=
"float:right ; "
>
Number of Questions :
<p
id=
'num_questions'
></p>
</div>
<form
method=
"POST"
action=
"create_Test"
>
{% csrf_token %}
{{ TestForm.as_p }}
{{TestForm.errors}}
{{TestForm.non_field_errors}}
{%for question in questions%}
<li
class=
"list-group-item"
>
<!-- <li> -->
<div
class=
"row toggle"
>
<div
class=
"col-xs-10"
>
<input
type=
"checkbox"
value=
"True"
name =
"{{question.q_id}}"
>
<input
type=
"checkbox"
value=
"True"
name =
"{{question.q_id}}"
id =
"{{question.q_id}}"
onclick=
"handleCheckBoxClick(this)"
posMarksID=
"{{question.q_id}}pos_marks"
>
<!-- link to posmarks in checkbox -->
{{question.question_text}} {{question.q_id}}
</br>
</div>
</div>
...
...
@@ -48,8 +108,15 @@ Create Test
{%endfor%}
<label>
marks
<input
type=
"number"
name=
"{{question.q_id}}"
min=
"0"
max=
"10"
placeholder=
"4"
step=
"0.25"
value=
"4"
>
<input
type=
"number"
name=
"{{question.q_id}}"
min=
"-10"
max=
"0"
placeholder=
"-1"
step=
"0.25"
value=
"0"
>
<!-- the id of checkboxes is q_id. I'm linking pos_marks to checkboxes
by id -->
<input
class =
"pos_marks"
type=
"number"
name=
"{{question.q_id}}"
min=
"0"
max=
"10"
placeholder=
"4"
step=
"0.25"
value=
"4"
checkBoxID =
"{{question.q_id}}"
onchange=
"handleMarkChange()"
id=
"{{question.q_id}}pos_marks"
>
<input
type=
"number"
name=
"{{question.q_id}}"
min=
"-10"
max=
"0"
placeholder=
"-1"
step=
"0.25"
value=
"0"
>
</label>
</ul>
...
...
@@ -58,6 +125,8 @@ Create Test
{%endfor%}
<button
type=
"submit"
class=
"btn btn-login float-right"
>
Submit
</button>
</form>
</div>
</ul>
</div>
</div>
...
...
ARFA/ARFA_app/views.py
View file @
cd41d35f
...
...
@@ -550,17 +550,8 @@ def create_Test(request):
# print vars(form)
# #debug
if
form
.
is_valid
():
test
=
form
.
save
()
creator
=
models
.
Created_BY
(
test_ID
=
test
,
faculty
=
models
.
Faculty
.
objects
.
filter
(
username
=
request
.
session
[
'username'
])
.
get
())
creator
.
save
()
else
:
if
form
.
errors
:
for
field
in
form
:
print
field
.
errors
return
HttpResponse
(
"Test Form Invalid"
)
max_marks
=
0
for
attr
in
dir
(
Test
):
# print attr
try
:
...
...
@@ -581,6 +572,7 @@ def create_Test(request):
containsObj
.
marks_pos
=
data
[
q
][
1
]
containsObj
.
marks_neg
=
data
[
q
][
2
]
max_marks
+=
int
(
data
[
q
][
1
])
containsObj
.
pk
=
None
containsObj
.
save
()
...
...
@@ -591,6 +583,20 @@ def create_Test(request):
print
e
continue
if
form
.
is_valid
():
test
=
form
.
save
(
commit
=
False
)
#not sure, but if a required attribute (like max_marks)
# is not present this may throw an error.
test
.
max_marks
=
max_marks
test
.
save
()
creator
=
models
.
Created_BY
(
test_ID
=
test
,
faculty
=
models
.
Faculty
.
objects
.
filter
(
username
=
request
.
session
[
'username'
])
.
get
())
creator
.
save
()
else
:
if
form
.
errors
:
for
field
in
form
:
print
field
.
errors
return
HttpResponse
(
"Test Form Invalid"
)
#schedule ranking function when test is finished
print
type
(
test
.
start_time
)
print
type
(
test
.
expected_time_for_completion
)
...
...
setup
0 → 100644
View file @
cd41d35f
pip install django-background-tasks
\ No newline at end of file
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