Files
edx-platform/common/lib/xmodule/xmodule/timeinfo.py
Sef Kloninger 0246339819 fix crash in peer eval xmodule
As documented in Jira LMS-806:

Steps to reproduce:
* as one user, for a peer evaluated problem, enter something that needs
  peer grading
* as another user, log in and fire up the peer grading panel. You should
  see something that needs attention, a yellow exclamation badge
* clicking on the "do grading" panel will fail with a 500, stacktrace
  attached.
* it's possible that the question where this is being done must first have
  professor calibration done in order for peers to be able to actually get
  work to grade.

Don Mitchell debugged this with me and saw some problems in the ways
that the peer_evaluation xmodule code was accessing dates. Instead of
using the normal lms accessors, by going straight into the _module_data
it would be bypassing some important code (caching?). Fixing this to be
more standard did the trick.
2013-07-31 13:31:25 -07:00

37 lines
1.4 KiB
Python

import logging
from xmodule.fields import Timedelta
log = logging.getLogger(__name__)
class TimeInfo(object):
"""
This is a simple object that calculates and stores datetime information for an XModule
based on the due date and the grace period string
So far it parses out three different pieces of time information:
self.display_due_date - the 'official' due date that gets displayed to students
self.grace_period - the length of the grace period
self.close_date - the real due date
"""
_delta_standin = Timedelta()
def __init__(self, due_date, grace_period_string_or_timedelta):
if due_date is not None:
self.display_due_date = due_date
else:
self.display_due_date = None
if grace_period_string_or_timedelta is not None and self.display_due_date:
if isinstance(grace_period_string_or_timedelta, basestring):
try:
self.grace_period = TimeInfo._delta_standin.from_json(grace_period_string_or_timedelta)
except:
log.error("Error parsing the grace period {0}".format(grace_period_string_or_timedelta))
raise
else:
self.grace_period = grace_period_string_or_timedelta
self.close_date = self.display_due_date + self.grace_period
else:
self.grace_period = None
self.close_date = self.display_due_date