Give some users (e.g., teachers) access to nodes created by a unique subset of other users (that teacher's students)
I've had success with multiple node authors using
nodeaccess_userreference

Gives content access permissions to users for content that references
the users with User reference or Entity reference.


and also with
nodeaccess_nodereference

Gives content access permissions to users if they have access to
content that is referenced with Node reference or Entity reference.
Checks view, update, and delete grant operations, and can pass those
on to the referencing content, or trigger a different grant
configuration according to settings.


In combination with field_permissions or hook_field_access, for restricting access to the reference field, that should enable the feature you're looking for there.
You may want to look at using Rules to set the reference field value on node save as well.