The student's code should systematically be written to the localStorage, too. That way, it would not be lost on brutal disconnexion or bugs.
A good point would also be that it could be retrieved by the users not wanting to commit their code in the Cloud.