exam.py: Cast length to int in Restriction.toxml

Fixes numbas/editor#213