I would guess the weapon was cocked. Although it’s hard to think how the trigger could be pulled, or the discharge happened.
Only thing I can think of is the kid was reaching into his backpack and just grabbed the first thing. As you suggest, the hammer was likely cocked and the safety off. If the kid new anything about guns, then it seems he was ready for action.