def get( self, user ): if not user.played_today: self.redirect( '/question' ) return score = self.request.get( 'score' ) if not score: score = 0 place = self.request.get( 'place' ) if not place: place = 0 already_played = False if not (score == '1' or score == '2' or score == '-1'): if user.last_played: already_played = True troupe_mates = user.get_troupe_mates () while len(troupe_mates) <= 5: troupe_mates.append( '%d. -' % (len(troupe_mates) + 1) ) template_values = { 'CSS_FILE' : 'result', 'q_score' : int(score), 'score' : user.score, 'question' : get_question().question, 'answer' : get_question().answer, 'already_played' : already_played, 'place' : place, 'troupe_mates' : troupe_mates[0:5] # Top 5 people } self.response.out.write( self.render_page( 'result.html', template_values ) )
def get(self, user): if not user.played_today: self.redirect('/question') return score = self.request.get('score') if not score: score = 0 place = self.request.get('place') if not place: place = 0 already_played = False if not (score == '1' or score == '2' or score == '-1'): if user.last_played: already_played = True troupe_mates = user.get_troupe_mates() while len(troupe_mates) <= 5: troupe_mates.append('%d. -' % (len(troupe_mates) + 1)) template_values = { 'CSS_FILE': 'result', 'q_score': int(score), 'score': user.score, 'question': get_question().question, 'answer': get_question().answer, 'already_played': already_played, 'place': place, 'troupe_mates': troupe_mates[0:5] # Top 5 people } self.response.out.write( self.render_page('result.html', template_values))
def get( self, user ): q = get_question() template_values = { 'JS_FILE' : 'question', 'CSS_FILE' : 'question', 'TODAY' : datetime.date( datetime.today() ) .strftime( '%A %B %d, %Y' ), 'PASS' : PASS, 'q' : q } self.response.out.write( self.render_page( 'question.html', template_values ) )
def get(self, user): q = get_question() template_values = { 'JS_FILE': 'question', 'CSS_FILE': 'question', 'TODAY': datetime.date(datetime.today()).strftime('%A %B %d, %Y'), 'PASS': PASS, 'q': q } self.response.out.write( self.render_page('question.html', template_values))
def get_category(message, new_ticket): new_ticket.category = message.text update_reg_ticket(new_ticket) bot.send_message(message.from_user.id, f'Выбрана категория товара: {new_ticket.category}') first_question = get_question(1) bot.register_next_step_handler(message, get_questions, new_ticket, question=first_question) bot.send_message(message.from_user.id, first_question.text, reply_markup=get_yes_no_markups())
def post(self, user): # Grab the user's answer ans = self.request.get('q1') # Grab today's question question = get_question() # Check if the user is correct: score = user.update_score(question, ans) # Update time user.last_played = triv_today(True) user.played_today = True user.put() # Go to Results screen self.redirect('/result?score=%s' % score)
def post( self, user ): # Grab the user's answer ans = self.request.get( 'q1' ) # Grab today's question question = get_question( ) # Check if the user is correct: score = user.update_score( question, ans ) # Update time user.last_played = triv_today( True ) user.played_today = True user.put() # Go to Results screen self.redirect( '/result?score=%s' % score )
def get(self): # Fetch question q = get_question() # And mark it as used! if q: q.state = 'used' q.put() # Get a new question new_q = Question.all().filter("state = ", 'unused').get() # Set the day to today! new_q.day = triv_today() new_q.state = 'in_use' # Save the new question new_q.put() if Question.all().filter('state = ', 'unused').count() <= 3: Emailer.outOfQuestions()
def get( self ): # Fetch question q = get_question() # And mark it as used! if q: q.state = 'used' q.put() # Get a new question new_q = Question.all().filter("state = ", 'unused').get() # Set the day to today! new_q.day = triv_today( ) new_q.state = 'in_use' # Save the new question new_q.put() if Question.all().filter('state = ', 'unused').count() <= 3: Emailer.outOfQuestions()
def get_questions(message, new_ticket, question): try: question = get_next_question(question, new_ticket, message.text) question = get_question(question.id) bot.send_message(message.from_user.id, question.text, reply_markup=get_yes_no_markups()) if question.final_status: raise Exception('Have No Next Question') bot.register_next_step_handler(message, get_questions, new_ticket, question=question) except Exception as s: print(f'Have Exception: {s}') print('Опрос закончен') bot.send_message(message.from_user.id, 'Спасибо!', reply_markup=continue_markups()) bot.register_next_step_handler(message, initial_block)