Ryan Walters has loaded up on advanced classes, studied until the wee hours and composed possible graduation speeches in his head as the high-school junior worked to be valedictorian at Heritage High School in Wake Forest, N.C.

But neither he nor any of his classmates will hold the title.

The Wake County Public School System, the 15th-largest...