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
d9bcc517
Commit
d9bcc517
authored
Nov 15, 2020
by
Roshan Rabinarayan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added comments
parent
9c23260a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
quiz/views.py
quiz/views.py
+27
-0
No files found.
quiz/views.py
View file @
d9bcc517
...
...
@@ -41,6 +41,8 @@ from django.core.files.storage import default_storage
startedquiz
=
dict
()
def
index
(
request
):
""" This function is responsible for for rendering the quiz page to the student for the selected quiz by the student
"""
quiz_id
=
int
(
request
.
GET
[
'q'
])
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quiz_id
)
obj
=
Questions
.
objects
.
filter
(
quizId
=
quizInstance
)
.
all
()
.
order_by
(
'questionId'
)
...
...
@@ -51,6 +53,8 @@ def index(request):
@
login_required
def
result
(
request
):
"""This function is called on submission of quiz to calculate the marks og the student the marks are added to total score for
every correct answer and for every wronf answer the negative marks set by instructor are deducted"""
if
request
.
user
.
is_authenticated
and
request
.
method
==
"POST"
:
quizId
=
int
(
request
.
POST
[
'quizId'
])
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quizId
)
...
...
@@ -78,6 +82,10 @@ def result(request):
def
save_ans
(
request
):
"""
this function keeps saving the response of the quiz while the student is attempting in order to ensure if due to network failure
student quiz stops then he can continue later from the point where he was interrupted
"""
ans
=
request
.
GET
[
'ans'
]
quizId
=
request
.
GET
[
'quizId'
]
questionId
=
request
.
GET
[
'questionId'
]
...
...
@@ -87,6 +95,7 @@ def save_ans(request):
return
HttpResponse
(
''
)
def
save_cribs
(
request
):
"""This function saves the cribs that the student has raised"""
crib
=
request
.
GET
.
get
(
'cribs'
)
quizId
=
int
(
request
.
GET
.
get
(
'quiz'
))
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quizId
)
...
...
@@ -97,10 +106,12 @@ def save_cribs(request):
return
HttpResponse
(
'Suuuuuccess'
)
def
upload
(
request
):
"""This function Renders the upload page for instructor to upload quiz through csv"""
return
render
(
request
,
'upload.html'
)
@
login_required
def
student
(
request
):
"""This function depending on the role of the logged in user load the professor dasboard or student dashboard"""
role
=
Permission
.
objects
.
all
()
.
filter
(
userId
=
request
.
user
)
.
values
(
'role'
)
if
role
:
role
=
role
[
0
][
'role'
]
...
...
@@ -112,6 +123,7 @@ def student(request):
return
render
(
request
,
'student.html'
)
def
ongoing_quiz
(
request
):
"""Displays all ongoing quiz to the professor who has hosted the quiz"""
quizzes
=
quiz
.
objects
.
all
()
.
values
(
'quizId'
,
'quizCode'
)
quizId
=
list
()
quizCode
=
list
()
...
...
@@ -120,6 +132,7 @@ def ongoing_quiz(request):
return
render
(
request
,
'ongoing_quiz.html'
,
{
'quizId'
:
quizId
})
def
upload_file
(
request
):
""" This function reads the csv file and inserts the questions into the database """
uploaded
=
False
temp1
=
'test'
random_code
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
digits
,
k
=
6
))
...
...
@@ -137,6 +150,7 @@ def upload_file(request):
def
instructor
(
request
):
"""This function is used to display the instructor with graphs(bell curve and histogram) , cribs raised by the students of the quiz selected"""
q_id
=
request
.
GET
.
get
(
'quiz_id'
)
quizId
=
0
allquizs
=
quiz
.
objects
.
all
()
.
filter
(
quizInstructor
=
request
.
user
)
.
order_by
(
'-date'
,
'-startTime'
)
...
...
@@ -191,10 +205,12 @@ def instructor(request):
return
render
(
request
,
'instructor.html'
,{
"graph"
:
html_graph
,
"graph1"
:
html_graph
,
"graph2"
:
html_graph1
,
'quiz'
:
quizInstance
,
'cribs'
:
cribs
,
'all_quizes'
:
allquizs
,
'quizDone'
:
quizDone
})
def
quizTable
(
request
):
"""This function helps in rendering all the quiz hosted by the instructor"""
quizs
=
quiz
.
objects
.
filter
(
quizInstructor
=
request
.
user
)
.
all
()
return
render
(
request
,
'quizTable.html'
,{
'quiz'
:
quizs
})
def
handle_uploaded_file
(
f
,
q1
):
"""This function reads the csv file uploaded by the instructor and makes insert into the database"""
with
open
(
'name.csv'
,
'wb+'
)
as
destination
:
for
chunk
in
f
.
chunks
():
destination
.
write
(
chunk
)
...
...
@@ -211,6 +227,7 @@ def create_quiz(request):
#login functionality
def
sign_up
(
request
):
"""This function renders the sign up page for the users"""
context
=
{}
form
=
UserCreationForm
(
request
.
POST
or
None
)
if
request
.
method
==
"POST"
:
...
...
@@ -225,6 +242,7 @@ def sign_up(request):
@
login_required
def
submissions
(
request
):
""" This function helps in rendering the submission page showing the student all the previous attempted quizzes"""
#prev_subm = submission.objects.all().filter(studentId=request.user)
prev_subm
=
submission
.
objects
.
all
()
.
filter
(
studentId
=
request
.
user
)
.
values
(
'quizId'
)
.
annotate
(
dcount
=
Count
(
'quizId'
))
return
render
(
request
,
'submissions.html'
,
{
'submissions'
:
prev_subm
})
...
...
@@ -232,6 +250,8 @@ def submissions(request):
@
login_required
def
view_sub
(
request
):
"""This function gives details to the student about the completed quiz consisting of correct answers
and choosen answers also the explainations for the questions provided by the professor"""
if
request
.
method
==
"GET"
:
quizId
=
int
(
request
.
GET
.
get
(
'q'
))
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quizId
)
...
...
@@ -249,6 +269,7 @@ def view_sub(request):
def
add_quiz
(
request
):
"""This function makes insert into database for all the manually entered quiz questions"""
vals
=
list
()
for
req
in
request
.
POST
.
values
():
vals
.
append
(
req
)
...
...
@@ -276,6 +297,9 @@ def add_quiz(request):
return
render
(
request
,
'professor.html'
,{
'quiz_upload'
:
True
})
#(request,'success')
def
monitor
(
request
):
"""
Thid function renders the monitor page for the instructor to view ongoing quiz , and monitor the student activity
"""
q_id
=
request
.
GET
.
get
(
'quiz'
)
allquizs
=
quiz
.
objects
.
all
()
.
filter
(
quizInstructor
=
request
.
user
)
.
order_by
(
'-date'
,
'-startTime'
)
...
...
@@ -292,17 +316,20 @@ def monitor(request):
@
xframe_options_exempt
def
getbeat
(
request
):
"""This function track the student activity for displaying the same on the instructor monitor page"""
quizId
=
int
(
request
.
GET
.
get
(
'quiz'
))
test
=
startedquiz
.
get
(
quizId
)
return
render
(
request
,
'student_activity.html'
,
{
'activity'
:
test
})
def
view_logs
(
request
):
"""THus function helps in viewing all the quizzes logs"""
quizId
=
int
(
request
.
GET
.
get
(
'quiz'
))
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quizId
)
quiz_logs
=
log
.
objects
.
all
()
.
filter
(
quizId
=
quizInstance
)
return
render
(
request
,
'log.html'
,
{
'logs'
:
quiz_logs
})
def
heartbeat
(
request
):
"""This function keeps track of student whether he exited full screen and which question he is currently on"""
quizId
=
int
(
request
.
GET
.
get
(
'quiz'
))
quizInstance
=
quiz
.
objects
.
get
(
pk
=
quizId
)
if
quizId
in
startedquiz
:
...
...
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