open-craft/edx-platform — pull request #25 by bradenmacdonald (2014-12-17 22:46:44+00:00)
Title: Content libraries settings overrides

@dmitchell if you have time, can you please comment on the technical approach I've taken here?

The idea is that we want blocks stored in content libraries to have their `Scope.settings` fields treated as defaults, which can be overridden when the blocks are actually used in a course.

To make this work and to reduce the number of database queries, I have approached this as follows: For blocks stored in content libraries, their `Scope.settings` fields are no longer stored in the structure but are instead stored in a new `defaults` field of the definition.

Thus, when a block is actually used in a course, to read its `Scope.settings` field values, we check (in order of priority):
1. The `fields` of the block's structure entry
2. The `defaults` of the block's definition (but because definitions are lazy-loaded, we only check if a "has_defaults" flag is set on the structure).
3. I think in some cases we also check parent block's values (inheritance).

This has the nice benefit that the block's Scope.settings fields can be reset to the library defaults by the course author at any time. The downside is it introduces a bit more complexity and two new key-value entries in the mongo schema.

CC @antoviaque