Restrict teacher permissions when specified by local settings

Solves #2592. Not so fun to program, and we really incur some technical debt here.

@jamalex we may want to program in the permissions and roles system soon.