The Acceleration of Ultra--High-Energy Cosmic Rays in Gamma-Ray Bursts