def post(self, task_name): if not self.r_params["testing_enabled"]: raise tornado.web.HTTPError(404) task = self.get_task(task_name) if task is None: raise tornado.web.HTTPError(404) query_args = dict() try: user_test = accept_user_test(self.sql_session, self.service.file_cacher, self.current_user, task, self.timestamp, self.request.files, self.get_argument("language", None)) self.sql_session.commit() except TestingNotAllowed: logger.warning("User %s tried to make test on task %s.", self.current_user.user.username, task_name) raise tornado.web.HTTPError(404) except UnacceptableUserTest as e: logger.info("Sent error: `%s' - `%s'", e.subject, e.text) self.notify_error(e.subject, e.text) else: self.service.evaluation_service.new_user_test( user_test_id=user_test.id) self.notify_success( N_("Test received"), N_("Your test has been received " "and is currently being executed.")) # The argument (encrypted user test id) is not used by CWS # (nor it discloses information to the user), but it is # useful for automatic testing to obtain the user test id). query_args["user_test_id"] = \ encrypt_number(user_test.id, config.secret_key) self.redirect( self.contest_url("testing", task_name=task.name, **query_args))
def post(self, task_name): if not self.r_params["testing_enabled"]: raise tornado.web.HTTPError(404) task = self.get_task(task_name) if task is None: raise tornado.web.HTTPError(404) query_args = dict() try: user_test = accept_user_test( self.sql_session, self.service.file_cacher, self.current_user, task, self.timestamp, self.request.files, self.get_argument("language", None)) self.sql_session.commit() except TestingNotAllowed: logger.warning("User %s tried to make test on task %s.", self.current_user.user.username, task_name) raise tornado.web.HTTPError(404) except UnacceptableUserTest as e: logger.info("Sent error: `%s' - `%s'", e.subject, e.text) self.notify_error(e.subject, e.text) else: self.service.evaluation_service.new_user_test( user_test_id=user_test.id) self.notify_success(N_("Test received"), N_("Your test has been received " "and is currently being executed.")) # The argument (encrypted user test id) is not used by CWS # (nor it discloses information to the user), but it is # useful for automatic testing to obtain the user test id). query_args["user_test_id"] = \ encrypt_number(user_test.id, config.secret_key) self.redirect(self.contest_url("testing", task_name=task.name, **query_args))
def call(self): return accept_user_test( self.session, self.file_cacher, self.participation, self.task, self.timestamp, self.tornado_files, self.language_name)