Firstly, if the intruder has already gained entrance to the classroom before you have started to react, you've already lost. There will be no time to mount an effective defense and most, if not all, people in the classroom will be slain. Beyond that, the best thing you can do is use a desk as a shield / ram and bumrush him.
Ideally, if you are made aware of the intruder before he has gained access to the room you are in, you will have locked the door, moved out of sight of all windows, and turned multiple desks on their sides, in front of another, to act as shields.
If you cannot lock the door, you should be prepared to surprise the intruder the moment he enters the room. Station yourself directly adjacent to the door, ideally with one person on either side of it. The moment he enters, attempt to gain control of his gun arm. It is debatable which side of the gun arm is best to be on, inside or outside.
If you are on the outside, seize the wrist such that it locks the hand, and attempt to break his arm at the elbow. Also strike him in the face with your elbow and other hand as best you can.
If you are on the inside, grab the wrist with your outside hand, then the forearm with your inside hand. Then move the outside hand to the gun. Next strike him in the face with the elbow of your inside arm, followed by a strike to the wrist while pulling the gun away. You SHOULD get it.
A rifle MUST be disarmed from the inside angle. Any attempt to disarm a rifle by attacking from the outside will almost assuredly result in failure, as he is able to hold onto the gun with 2 hands and easily jerk it away from you. If you are inside, he cannot simply jerk away as he does not have the leverage. Grab the rifle with both hands, step in, strike with elbow twice, pull away.