Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pariksha
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roshan Rabinarayan
Pariksha
Commits
961f4f25
Commit
961f4f25
authored
Oct 22, 2020
by
Roshan Rabinarayan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
saved submissions
parent
5a5bc06f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
22 deletions
+36
-22
db.sqlite3
db.sqlite3
+0
-0
quiz/__pycache__/views.cpython-38.pyc
quiz/__pycache__/views.cpython-38.pyc
+0
-0
quiz/static/js/quiz_attempt_page.js
quiz/static/js/quiz_attempt_page.js
+2
-2
quiz/templates/index.html
quiz/templates/index.html
+11
-6
quiz/views.py
quiz/views.py
+23
-14
No files found.
db.sqlite3
View file @
961f4f25
No preview for this file type
quiz/__pycache__/views.cpython-38.pyc
View file @
961f4f25
No preview for this file type
quiz/static/js/quiz_attempt_page.js
View file @
961f4f25
...
@@ -34,11 +34,11 @@ function goto_question(x) {
...
@@ -34,11 +34,11 @@ function goto_question(x) {
}
}
}
}
function
set_option
(
question_id
,
option_id
)
{
function
set_option
(
question_id
,
option_id
,
value
)
{
if
(
typeof
question_id
==
"
number
"
&&
typeof
option_id
==
"
number
"
)
{
if
(
typeof
question_id
==
"
number
"
&&
typeof
option_id
==
"
number
"
)
{
if
(
question_id
>=
0
&&
question_id
<
questions_len
&&
option_id
>=
0
&&
option_id
<
4
)
{
if
(
question_id
>=
0
&&
question_id
<
questions_len
&&
option_id
>=
0
&&
option_id
<
4
)
{
var
ans
=
document
.
getElementById
(
'
q
'
+
question_id
);
var
ans
=
document
.
getElementById
(
'
q
'
+
question_id
);
ans
.
value
=
option_id
;
ans
.
value
=
value
;
var
cbox
=
document
.
getElementById
(
"
lbl_
"
+
question_id
+
"
_
"
+
option_id
);
var
cbox
=
document
.
getElementById
(
"
lbl_
"
+
question_id
+
"
_
"
+
option_id
);
console
.
log
(
"
lbl_
"
+
question_id
+
"
_
"
+
option_id
);
console
.
log
(
"
lbl_
"
+
question_id
+
"
_
"
+
option_id
);
cbox
.
style
.
backgroundColor
=
'
#f4fa9c
'
;
cbox
.
style
.
backgroundColor
=
'
#f4fa9c
'
;
...
...
quiz/templates/index.html
View file @
961f4f25
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
</head>
</head>
<body>
<body>
<form
method=
"POST"
action=
"
result"
>
<form
method=
"POST"
action=
"
/result/"
>
{% csrf_token %}
<!-- <h1>{{questions.quizId}} Question {{ questions.end_index }} of {{count}}</h1> -->
<!-- <h1>{{questions.quizId}} Question {{ questions.end_index }} of {{count}}</h1> -->
<aside
id=
"question_palette"
>
<aside
id=
"question_palette"
>
<ul
class=
"questions_list"
>
<ul
class=
"questions_list"
>
...
@@ -35,14 +35,19 @@
...
@@ -35,14 +35,19 @@
<!-- <h1 id ='quizId'>{{i.quizId}}<h1> -->
<!-- <h1 id ='quizId'>{{i.quizId}}<h1> -->
<h1
id =
'questionId'
hidden
>
{{i.questionId}}
</h1>
<h1
id =
'questionId'
hidden
>
{{i.questionId}}
</h1>
<h1>
{{i.question}}
</h1>
<h1>
{{i.question}}
</h1>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}}, 0)"
><span
id=
"lbl_{{forloop.counter0}}_0"
><strong>
A
</strong><span>
{{i.option1}}
</span></span></label>
<input
type=
"hidden"
id=
"qq{{forloop.counter0}}"
name=
"qq{{forloop.counter0}}"
value=
"{{i.questionId}}"
>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}}, 1)"
><span
id=
"lbl_{{forloop.counter0}}_1"
><strong>
B
</strong><span>
{{i.option2}}
</span></span></label>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}},0, ' {{i.option1}}')"
><span
id=
"lbl_{{forloop.counter0}}_0"
><strong>
A
</strong><span>
{{i.option1}}
</span></span></label>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}}, 2)"
><span
id=
"lbl_{{forloop.counter0}}_2"
><strong>
C
</strong><span>
{{i.option3}}
</span></span></label>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}},1, '{{i.option2}}')"
><span
id=
"lbl_{{forloop.counter0}}_1"
><strong>
B
</strong><span>
{{i.option2}}
</span></span></label>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}}, 3)"
><span
id=
"lbl_{{forloop.counter0}}_3"
><strong>
D
</strong><span>
{{i.option4}}
</span></span></label>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}},2, '{{i.option3}}')"
><span
id=
"lbl_{{forloop.counter0}}_2"
><strong>
C
</strong><span>
{{i.option3}}
</span></span></label>
<input
type=
"hidden"
id=
"q{{forloop.counter0}}"
name=
"q{{forloop.counter0}}"
value=
"NA"
>
<label
class=
"op_box"
onclick=
"set_option({{forloop.counter0}}, 3,'{{i.option4}}')"
><span
id=
"lbl_{{forloop.counter0}}_3"
><strong>
D
</strong><span>
{{i.option4}}
</span></span></label>
<input
type=
"hidden"
id=
"q{{forloop.counter0}}"
name=
"{{i.questionId}}"
value=
"NA"
>
<!-- <label ><input type="textarea" name="fame" id="cribs" value="">Cribs...</label> -->
<!-- <label ><input type="textarea" name="fame" id="cribs" value="">Cribs...</label> -->
</div>
</div>
{%endfor%}
{%endfor%}
<input
type=
"hidden"
id=
"quizId"
name=
"quizId"
value=
"{{questions.0.quizId}}"
>
</div>
</div>
</section>
</section>
</form>
</form>
...
...
quiz/views.py
View file @
961f4f25
...
@@ -10,15 +10,11 @@ from . newQuiz import readCSV
...
@@ -10,15 +10,11 @@ from . newQuiz import readCSV
import
csv
import
csv
lst
=
[]
lst
=
[]
answers
=
Questions
.
objects
.
all
()
answers
=
[]
anslist
=
[]
anslist
=
[]
marksList
=
[]
marksList
=
[]
negative
=
[]
negative
=
[]
for
i
in
answers
:
print
(
str
(
i
.
answer
)
+
" "
+
str
(
i
.
negative
)
+
" "
+
str
(
i
.
marks
))
anslist
.
append
(
i
.
answer
)
marksList
.
append
(
i
.
marks
)
negative
.
append
(
i
.
negative
)
def
index
(
request
):
def
index
(
request
):
obj
=
Questions
.
objects
.
get_queryset
()
.
order_by
(
'questionId'
)
obj
=
Questions
.
objects
.
get_queryset
()
.
order_by
(
'questionId'
)
...
@@ -37,14 +33,27 @@ def index(request):
...
@@ -37,14 +33,27 @@ def index(request):
def
result
(
request
):
def
result
(
request
):
score
=
0
st
=
str
()
#print("lstlstlst"+str(len(anslist)))
answer
=
list
()
#contains user responses
for
i
in
range
(
len
(
lst
)):
questionNumber
=
list
()
if
lst
[
i
]
==
anslist
[
i
]:
ans
=
list
()
score
+=
marksList
[
i
]
for
req
in
request
.
POST
:
else
:
ans
.
append
(
req
)
score
-=
negative
[
i
]
if
(
request
.
method
==
"POST"
):
return
render
(
request
,
'result.html'
,{
'score'
:
score
,
'lst'
:
lst
,
'anslist'
:
anslist
})
quizId
=
request
.
POST
[
'quizId'
]
i
=
len
(
request
.
POST
)
j
=
2
while
j
<
i
-
1
:
#last value contains quiz id
questionNumber
.
append
(
request
.
POST
[
ans
[
j
-
1
]])
answer
.
append
(
request
.
POST
[
ans
[
j
]])
t
=
submission
(
questionId
=
request
.
POST
[
ans
[
j
-
1
]],
option
=
request
.
POST
[
ans
[
j
]],
studentId
=
6969
,
quizId
=
quizId
)
#studentid hardcoded
t
.
save
()
j
+=
2
#questionid option pair
return
HttpResponse
(
str
(
ans
))
def
save_ans
(
request
):
def
save_ans
(
request
):
...
...
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