Пример #1
0
def updateRating(username, userRating, qK, qRating, result):
    user = User.all().filter("username =", username).get()
    question = Question.get(qK)
    user.rating, question.rating = getNewRatings(userRating, qRating, result)
    user.put()
    question.put()
    return str(user.rating)
Пример #2
0
def getQuestionKeys(genre, update=False):
    """memset all the KEYS under the GENRE return the keys"""
    questions = memg(genre)
    if (not questions) or update:
        questions = Question.all(keys_only=True).filter("genre =", genre)
        questions = [x for x in questions]
        mems(genre, questions)
    return questions
Пример #3
0
def voteQuestion(up, key):  # up=1 down=0 that's "up?"
    question = Question.get(key)
    if up:
        question.votes += 1
    else:
        question.votes -= 1
    if question.votes < -10:
        db.delete(key)
        getQuestionKeys(update=True)
    else:
        question.put()
Пример #4
0
def createQuestion(q, a, c1, c2, c3, genre):
    """db and memset the question with the KEY"""
    quest = Question(question=q, rating=1200.0, votes=0, answer=a, choice1=c1, choice2=c2, choice3=c3, genre=genre)
    quest.put()
    mems(str(quest.key()), quest)
    logging.info("question: " + q + " created.")