Quadratic and rate-independent limits for a large-deviations functional