edx/edx-ora2 — pull request #467 by wedaly (2014-06-30 12:00:23+00:00)
Title: Add criterion foreign key to assessment part model (write only)

In preparation for the full migration with https://github.com/edx/edx-ora2/pull/463.

This adds a new foreign key field `criterion` to the `AssessmentPart` model and ensures that new `AssessmentPart`s write to this field.

This PR performs the first two steps of the migrations required by #463:
1) Add the field criterion_id to the table assessment_assessmentpart, making it nullable.
2) Deploy code that writes criterion_id for new assessments.

Then, in a future release, #463 will...
3) Run a data migration to back-fill the criterion_id for old assessments.
4) Modify criterion_id to make it NOT NULL.
5) Modify option_id to make it nullable.

This ensures that all `AssessmentPart.criterion` fields will contain valid foreign key values once we deploy code that reads this field.

Unfortunately, this increases the query count for creating new assessments by one -- with the refactoring in #463 this will go back down. I'm trying to change as little as possible in this PR to minimize risk, and I think the trade-off in query counts is worth it.

@feanil @stephensanchez Please review. I would like to get this in today's release so #463 can be deployed the following week.