As a former male middle schooler, I can tell you that boners could be seen in normal pants.
As someone who's seen a few boners in my time, it depends mainly on angle, size, and shape.
Overall, they tend to stand out the most if they're just a little below average; if they're too big, it's pretty hard for them to even reach a position where they can become visible unless you're wearing really thin or loose pants. And of course if they're small enough, they won't be very visible anyways.
Ones that are straight or have an upward curve will be a lot more visible than ones with a downward curve.
Then the natural angle varies; some will never under any circumstances point straight forward or up on their own, either because they're too heavy for that (or too front-heavy, with the base being narrower) when erect, or they just naturally point downwards more. So that makes it harder for them to be visible beneath pants. Smaller ones are again more likely to stand out because of this.
But really, when I was in school I never even heard of anyone having a visible boner (and it's the sort of thing that would be talked about), let alone seen it myself. To me, it's always seemed like something that's only common on TV and in anime/manga, but very rare in real life. Maybe all the boys around me were just really skilled at hiding it, but I'd guess it's just not a problem at all for most people.
Swimsuits are a different story though, a whole lot of obvious boners at the beach or pool.