Replay a submission: add the same job in the queue, keeping submission id, submission date and input data
        :param submission: Submission to replay
        :param copy: If copy is true, the submission will be copied to admin submissions before replay
        :param debug: If debug is true, more debug data will be saved

def replay_job(self, task, submission, copy=False, debug=False):
        """
        Replay a submission: add the same job in the queue, keeping submission id, submission date and input data
        :param submission: Submission to replay
        :param copy: If copy is true, the submission will be copied to admin submissions before replay
        :param debug: If debug is true, more debug data will be saved
        """
        if not self._user_manager.session_logged_in():
            raise Exception("A user must be logged in to submit an object")

        # Don't enable ssh debug
        ssh_callback = lambda host, port, password: self._handle_ssh_callback(submission["_id"], host, port, password)

        # Load input data and add username to dict
        inputdata = bson.BSON.decode(self._gridfs.get(submission["input"]).read())

        if not copy:
            submissionid = submission["_id"]
            username = submission["username"][0] # TODO: this may be inconsistent with add_job

            # Remove the submission archive : it will be regenerated
            if submission.get("archive", None) is not None:
                self._gridfs.delete(submission["archive"])
        else:
            del submission["_id"]
            username = self._user_manager.session_username()
            submission["username"] = [username]
            submission["submitted_on"] = datetime.now()
            inputdata["@username"] = username
            inputdata["@lang"] = self._user_manager.session_language()
            submission["input"] = self._gridfs.put(bson.BSON.encode(inputdata))
            submission["tests"] = {} # Be sure tags are reinitialized
            submissionid = self._database.submissions.insert(submission)

        jobid = self._client.new_job(task, inputdata,
                                     (lambda result, grade, problems, tests, custom, state, archive, stdout, stderr:
                                      self._job_done_callback(submissionid, task, result, grade, problems, tests, custom, state, archive, stdout, stderr, copy)),
                                     "Frontend - {}".format(submission["username"]), debug, ssh_callback)

        # Clean the submission document in db
        self._database.submissions.update(
            {"_id": submission["_id"]},
            {"$set": {"jobid": jobid, "status": "waiting", "response_type": task.get_response_type()},
             "$unset": {"result": "", "grade": "", "text": "", "tests": "", "problems": "", "archive": "", "state": "", "custom": ""}
             })

        if not copy:
            self._logger.info("Replaying submission %s - %s - %s - %s", submission["username"], submission["courseid"],
                              submission["taskid"], submission["_id"])
        else:
            self._logger.info("Copying submission %s - %s - %s - %s as %s", submission["username"], submission["courseid"],
                              submission["taskid"], submission["_id"], self._user_manager.session_username())