We want an authoritative and readily-accessible place to track due dates for sections/units in a course. We also want to override due dates per learner, and record the reason for the override. The current implementation stores due dates in the XBlock (in mongodb). If you want to know all of the due dates in a course, you have to walk the entire course structure and pull out each date, which is an inefficient operation.
There is currently a way to override due dates per learner, using `IDDE <https://github.com/mitodl/ccx-idde-overrides-slides/blob/master/markdown/slides.md#individual-due-date-extensions-idde>`_, but this relies on a generic field-override system which doesn't know anything about the underlying data, and enabling this feature results in a database query for every xblock access, for every course on the platform. IDDE also does not allow for an audit trail on due date extensions, nor does it allow instructors to record a reason for the extension.
Decisions
---------
1. Create a new pluggable Django app responsible for dates and date overrides
This approach anticipates other date-related functions in the future, such as APIs for returning a calendar view of upcoming dates.
- The app will contain at least these models:
+ ``DatePolicy``: contains course_key, absolute date and a time delta
+ ``ContentDate``: contains DatePolicy id and content id + field
+ ``UserDate``: contains user id, DatePolicy id, and absolute date + relative date. It will also record an audit trail for the override.
- The app will hook in to the ``LmsModuleSystem`` with a custom ``FieldData`` implementation.
+ If the date exists in the relational database (whether in UserDate or ContentDate), it'll use that date; otherwise, it'll use the one stored in the XBlock.
- The app will expose a REST API for retrieving and updating dates in the database.
2. Create an instructor interface for setting student due dates
The app will listen for the ``SignalHandler.course_published`` signal in Studio and will create/modify ``DatePolicies`` and ``ContentDates`` as required.