To keep it simple, maybe it would be better to not be able to lock individual nodes ? Only flows could be locked and any action on that flow that would enable the Deploy button is impossible while in locked state.
Nodes in a locked flow would be "readonly" (edit dialog available but with the Done button disabled) and not movable. So it would not be possible to add new nodes, edit existing nodes , delete nodes or add/delete/move wires. Selecting nodes and copy them would be possible. Pasting in a locked flow would not.
Inject buttons would still be active (if we don't want that, why not add the possibility to disable the button in the inject node itself ?) but debug buttons would not be active because this kind of action is an "edit" and enables the Deploy button.
Working on the flows level would encourage users to better organize their flows, use links and subflows, instead of having one or two huge flows.
The use case with the teacher/student and the missing nodes/pieces seems very specific to me but of course I'm not in a teacher's position so maybe there's a real need there (?) and in that case node-level locking seems like the route to follow.