Schools across Scotland are breaking the law over the adequate provision of toilets, leaving themselves open to legal action from pupils and parents.