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
3bb21da8
Commit
3bb21da8
authored
Nov 15, 2020
by
Samarth Joshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timezone issue
parent
c77170e7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
QuizSystem/settings.py
QuizSystem/settings.py
+1
-1
quiz/models.py
quiz/models.py
+19
-4
quiz/views.py
quiz/views.py
+3
-2
No files found.
QuizSystem/settings.py
View file @
3bb21da8
...
...
@@ -111,7 +111,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'
UTC
'
TIME_ZONE
=
'
Asia/Calcutta
'
USE_I18N
=
True
...
...
quiz/models.py
View file @
3bb21da8
...
...
@@ -2,6 +2,7 @@ from django.db import models
from
django.contrib.auth.models
import
User
import
datetime
from
django.utils
import
timezone
import
pytz
class
Permission
(
models
.
Model
):
"""This class is used to create the userspermission table in database.Defines the permission of the user default permission is Student the admin can provide staff permission"""
...
...
@@ -29,20 +30,34 @@ class quiz(models.Model):
@
property
def
start_datetime
(
self
):
starttime
=
datetime
.
datetime
.
combine
(
self
.
date
,
self
.
startTime
if
self
.
startTime
is
not
None
else
datetime
.
time
.
min
)
return
starttime
tz
=
pytz
.
timezone
(
"Asia/Calcutta"
)
starttime
=
datetime
.
datetime
.
combine
(
self
.
date
,
self
.
startTime
if
self
.
startTime
is
not
None
else
datetime
.
time
.
min
)
return
tz
.
localize
(
starttime
)
@
property
def
end_datetime
(
self
):
starttime
=
datetime
.
datetime
.
combine
(
self
.
date
,
self
.
startTime
if
self
.
startTime
is
not
None
else
datetime
.
time
.
min
)
tz
=
pytz
.
timezone
(
"Asia/Calcutta"
)
starttime
=
datetime
.
datetime
.
combine
(
self
.
date
,
self
.
startTime
if
self
.
startTime
is
not
None
else
datetime
.
time
.
min
)
endtime
=
starttime
+
datetime
.
timedelta
(
minutes
=
self
.
length
)
return
tz
.
localize
(
endtime
)
@
property
def
end_datetime_fortz
(
self
):
starttime
=
datetime
.
datetime
.
combine
(
self
.
date
,
self
.
startTime
if
self
.
startTime
is
not
None
else
datetime
.
time
.
min
)
endtime
=
starttime
+
datetime
.
timedelta
(
minutes
=
self
.
length
)
return
endtime
@
property
def
status
(
self
):
tz
=
pytz
.
timezone
(
"Asia/Calcutta"
)
stt
=
self
.
start_datetime
end
=
self
.
end_datetime
cur
=
datetime
.
datetime
.
now
()
cur
=
tz
.
localize
(
datetime
.
datetime
.
now
())
print
(
self
.
quizInfo
)
print
(
"Sta: "
+
str
(
stt
))
print
(
"End: "
+
str
(
end
))
print
(
"Cur: "
+
str
(
cur
))
if
stt
<=
cur
and
cur
<=
end
:
return
"Ongoing"
elif
cur
>
end
:
...
...
quiz/views.py
View file @
3bb21da8
...
...
@@ -49,9 +49,10 @@ def index(request):
obj
=
Questions
.
objects
.
filter
(
quizId
=
quizInstance
)
.
all
()
.
order_by
(
'questionId'
)
endtime
=
quizInstance
.
end_datetime
curtime
=
datetime
.
now
()
if
curtime
>=
endtime
:
if
quizInstance
.
status
==
"Ended"
:
return
HttpResponse
(
"Quiz has already ended"
)
elif
quizInstance
.
status
==
"Scheduled"
:
return
HttpResponse
(
"Quiz has note started yet"
)
prev_subm
=
submission
.
objects
.
all
()
.
filter
(
quizId
=
quizInstance
,
studentId
=
request
.
user
)
if
len
(
prev_subm
)
!=
0
:
return
HttpResponse
(
"You have already submitted this quiz"
)
...
...
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