Energy structure of quantum rings in a magnetic field