Before I get to any solutions I'd like to say how appalled I am by some of the question comments. A school teacher educating our students is trying to find an innovative way keep the attention of his class. This person should be applauded, not ridiculed. Grow up people!
Your going to need several pieces to put all of this together. This is not meant to be suggested as a complete solution but it should get you going in the right direction(s).
First your going to need to think a bit like a hacker. You'll need an agent app running on all the computers which communicates with the "master" computer/agent (client / server) to know when to lock / unlock. This could be fraught with all kinds of synchronization issues so be careful about polling intervals, etc.
For the keyboard you'll essentially need what will start out as a keylogger (think hacker stealing your password). Basically the app will intercept all the keyboard inputs and prevent them from doing anything. I found another question with some info to get you started (Capture and send keyboard / mouse input in C#). I'm going to stay Completely away from the whole, do you have the right to log keyboard inputs of students here. I suggest you just throw the text away and not store it anywhere or at the very least consult your school/district lawyer.
My suggestion would be to start out with an app that takes over the whole screen (including the start menu) and is set to stay on top of all other windows. You can have a text box or something in the middle of the screen with the message you want or just hard code it.
I would suggest resetting the mouse to some corner of the screen whenever it's moved.
Some things to watch out for:
- Make a master key combination that will shut down the app in case it does something you don't expect.
- You WILL end up playing a cat & mouse game with your technically incline students trying to bypass your app.
- Since this is an app running on the machine the task can simply be killed. Maybe the server should poll the clients to see if they're shutdown. You might look into a windows service but there are special considerations for a visual window / element in a service (might not be worth the hassle).
- Perhaps a windows service that checks to see if the app is running and launches it if it's been shut down would be a good compromise.
- This will only work on school computers and not students personal machines
- Depending on the antivirus software installed this may get flagged as a keylogger/hacker tool or virus.
Now for the disclaimers / warnings. You need to figure out the legal parts of this yourself, I'm not making any warranty or legal recommendations here.