def post(self):
     """Validate the user input, and either prompt the user for a
        new answer, or prepare the page for a new question, by
        properly updating the CurrentQuestion entity for the
        given user."""
     user = users.get_current_user()
     current = search_by_user(user.user_id())
     answer = self.request.get('answer')
     if validate(answer,current.solution):
         current.valid = "Correct"
         current.solved += 1
         if current.solved // 10 >= current.level:
             current.level += 1
         previous = current.stmt[0]+' '+current.stmt[1]+' is solved by '
         previous += ' '.join(current.solution)
         current.previous.append(previous)
         solution,stmt = next_question(current.level)
         current.stmt = stmt
         current.solution = solution
     else:
         current.valid = "Try Again"
     current.attempts += 1    
     current.put()
     #self.redirect('/questions')
     self.get()
 def post(self):
     user = users.get_current_user()
     current = search_by_user(user.user_id())
     answer = self.request.get('answer')
     if validate(answer,current.sample_sol):
         current.valid = "Correct"
     else:
         current.valid = "Try Again"
     current.put()
     self.get()
 def get(self):
     user = users.get_current_user()
     if user:
         current = search_by_user(user.user_id())
         stmt = current.sample_stmt[0]+' '+current.sample_stmt[1]
         context = self.context.extend({'stmt':stmt,
                                        'user':user,
                                        'nickname':current.user.email(),
                                        'is_valid':current.valid})
     else:
         context = self.context
     self.render(self.template,**context)
 def get(self):
     """As apposed to previous impleminations, get() will be the only
        rendering method in this handler. Note that necessitates
        pulling updated CurrentQuestion information for each response,
        since the put() method most likely will change the object."""
     user = users.get_current_user()
     current = search_by_user(user.user_id())
     stmt = current.stmt[0]+' '+current.stmt[1]
     context = self.context.extend({'user':user,
                                    'nickname':user.email(),
                                    'stmt':stmt,
                                    'attempt':"",
                                    'problems':current.previous,
                                    'is_valid':current.valid,
                                    'level':current.level,
                                    'solved':current.solved,
                                    'attempts':current.attempts})
     self.render(self.template,**context)