LTI Tool Provider OG

LTI identifies the course that a Tool is launched from as a context_id. The base lti_tool_provider module places this in the session but otherwise does nothing specific to the context. If your tool is going to be used from multiple courses you might wish to separate the users and content in Drupal based on this context. The lti_tool_provider_og sub-module uses organic groups to separate contexts. Install og version 7.x-2.x and enable it and lti_tool_provider_og. Create a group entity bundle in your Drupal site. This could be a node content type, taxonomy, or even the user entity or some entity provided by another module. The simplest case would be to create a Course content type and make that a group type.

Group Mapping

The configuration page admin/config/lti-tool-provider/group-mapping will let you select your group entity/bundle that will be associated with LTI contexts. If you choose a node content type, you will be given the option to have these groups auto-provisioned.

You must select a field on the group entity to be associated with the LTI context_id. If you choose to automatically create groups, you can map context_id, context_label, context_title and context_type to fields on the group content type.

If you choose to automatically create groups, it is recommended that the Global Role given to the users who will be adding the LTI Tool link into the LMS courses is given the permission to create the group content type. That will allow those users to add the LTI tool link in the LMS and then to click the link, launching the Tool, and the course group will be automatically created with their Drupal user as the group owner/administrator. The course group will not be provisioned if the Global Role of the user does not have permission to create it.

Group Roles

Organic Groups 7.x-2.x supports group roles, and lti_tool_provider_og will let you map the LTI roles to any defined group roles. This is in addition to the Global Drupal Roles covered earlier. The Global Roles are site wide, the Group Roles are effective only in a group. With Group Roles a user could be a teaching assistant in one course and a student in another.

Group Context

If you enable the Organic Groups Context module from OG, you can detect group context from the LTI Context. Configure this at admin/config/group/context by enabling the LTI Context detection method and drag it to the top of the list.
One place you can use this is in views. You can add contextual filters that "Provide default value" using "Current OG group from context" and thus restrict content to the current LTI context (i.e. course).
Another place is in node add forms when using entityreference_prepopulate. You can prepopulate group fields from the context.