According to
the Al Jazeera's report, the school used to be part of the military complex but was separated 10-ish years ago. A clinic was also built later but was not hit.
Even if it was still inside, that wouldn't have made it okay. On-base schools are nothing new or revolutionary. Everybody does them. The onus is on the aggressor in choosing their targets carefully. International law protects them unless they're directly involved in military operations. Israel loves to use that excuse when bombing hospitals or other other public facilities.
The aforementioned report concludes the school suffered a direct hit and not some sharpenel bouncing off.