def post(self): user = users.get_current_user() # TODO(mbelshe): the dev server doesn't properly handle logins? #if not user: # self.redirect(users.create_login_url(self.request.uri)) # return set_id = self.request.get('set_id') if not set_id: self.send_error("Bad request, no set_id param") return try: set_id = int(set_id) except: self.send_error("Bad request, bad set_id param: %s", set_id) return test_set = models.TestSet.get_by_id(set_id) if not test_set: self.send_error("Could not find set_id: %s", set_id) return my_url = self.request.get('url') test_result = models.TestResult(set=test_set, url=my_url) test_result.using_spdy = bool(self.request.get('using_spdy') == 'true') ApplyStatisticsData(self.request, test_result) key = test_result.put() self.response.out.write(key.id())
def question(message): user = models.getUserById(message.from_user.id) if message.text == getAnswer(user.current_question): user.rigth_answer_count += 1 user.save() if user.current_question == test1_number_of_questions: result = models.TestResult() result.user = user result.result = user.rigth_answer_count result.date = datetime.now() result.save() bot.send_message(message.from_user.id, text="Ваш результат " + str(user.rigth_answer_count) + " из " + str(test1_number_of_questions), reply_markup=getmenukeyboard()) send_result_to_admin(message.from_user, user.rigth_answer_count) else: res_message = get_question(user.current_question) bot.send_message(user.id, text=res_message, reply_markup=getanswerkeyboard(3)) bot.register_next_step_handler(message, question) user.current_question += 1 user.save()
def update_repo_all(force=False): """ Run all tests and models against one another, without first checking matches with KIM_API_init, meant to be used locally as a test """ logger.info("attempting to update repo...") for model in models.Model.all(): for test in models.Test.all(): #logger.info("attempting to update test %r",test) if force or not models.TestResult.test_result_exists(test, model): logger.info("Running %r vs %r", test, model) try: results = run_test_on_model(test, model) tr = models.TestResult(results=results) except: logger.error("WE HAD an error on (%r,%r) with:\n%r", test, model, sys.exc_info()[0]) else: logger.info("%r vs %r seems current", test, model)
def update_repo(force=False): """ Attempt to run all valid matching test and model pairs, meant to be used locally as a test. """ logger.info("attempting to update repo...") for test in models.Test.all(): #logger.info("attempting to update test %r",test) for model in test.models: if force or not models.TestResult.test_result_exists(test, model): logger.info("Running %r vs %r", test, model) try: results = run_test_on_model(test, model) tr = models.TestResult(results=results) except: logger.error("WE HAD an error on (%r,%r) with:\n%r", test, model, sys.exc_info()[0]) else: logger.info("%r vs %r seems current", test, model)
def continue_test(call): user = models.getUserById(call.from_user.id) if user.current_question == test1_number_of_questions: result = models.TestResult() result.user = user result.result = user.rigth_answer_count result.date = datetime.now() result.save() bot.send_message(call.from_user.id, text="Ваш результат " + str(user.rigth_answer_count) + " из " + str(test1_number_of_questions), reply_markup=getmenukeyboard()) send_result_to_admin(call.from_user, user.rigth_answer_count) else: res_message = get_question(user.current_question) bot.send_message(user.id, text=res_message, reply_markup=getanswerkeyboard(3)) user.current_question += 1 user.save()