Remove the cover from your smoke detector and look inside. Locate the test button that normally protrudes through a round hole in the lid that allows you to check the function of the smoke detector. When you push the button it causes two contacts (pieces of metal) to touch each other, which causes the alarm to sound.
Push the end of your ribbon between the two metal pieces and then push the button to make sure the alarm does not sound. Place the lid back on the smoke detector making sure that the ribbon hangs freely out.
Duct tape the test button in the down position, the alarm will not sound because you have the ribbon preventing the contacts from touching. Duct tape the smoke detector on the inside of your locker, on the side, a couple of inches from the latch. The ribbon sticking out should be facing towards the locker latch where you open the locker.
Trim the piece of ribbon so that it is just long enough to reach the outer edge of your locker door. Use clear tape and tape the ribbon to the locker door. When you open the locker door the ribbon will pull out, the contacts will touch, and the buzzer will sound, loudly.
Disable the alarm when it is you, about to open your locker, by disconnecting the piece of tape. This will prevent the ribbon from pulling out of the smoke detector and therefore prevent the alarm from going off. Just remember to tape the ribbon back into place when you are finished to reset the alarm.