Enhancing education in heterogeous schools: Theory and applications