-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Stanford-Online/make-xblock-respect-due-date
Makes xblock due_date aware
- Loading branch information
Showing
5 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Mixins for the Free Text Response XBlock | ||
""" | ||
import datetime | ||
import pytz | ||
from django.conf import settings | ||
|
||
TIME_ZONE = pytz.timezone(getattr(settings, 'TIME_ZONE', pytz.utc.zone)) | ||
|
||
|
||
class EnforceDueDates(object): # pylint: disable=too-few-public-methods | ||
""" | ||
xBlock Mixin to allow xblocks to check the due date | ||
(taking the graceperiod into account) of the | ||
subsection in which they are placed | ||
""" | ||
|
||
# These values are pulled from platform. | ||
# They are defaulted to None for tests. | ||
due = None | ||
graceperiod = None | ||
|
||
def is_past_due(self): | ||
""" | ||
Determine if component is past-due | ||
""" | ||
now = datetime.datetime.utcnow().replace(tzinfo=TIME_ZONE) | ||
if self.due is not None: | ||
due_date = self.due | ||
if self.graceperiod is not None: | ||
due_date = due_date + self.graceperiod | ||
return now > due_date | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters