Exemplo n.º 1
0
def createAnswer(questionId, accountId, answer, pollStatus):
    answ = Answer()

    answ.QuestionId = questionId
    answ.AccountId = accountId
    account = Account.query.filter_by(Id=accountId).first()
    account.setDomainExpertise()
    if len(account.DomainExpertise) > 0:
        answ.IsExpert = True
    else:
        answ.IsExpert = False
    answ.Answer = answer
    answ.TimeStamp = datetime.date.today()
    answ.Score = 0
    poll = PollOption.query.filter_by(PollOptionName=pollStatus).first()
    answ.PollOptionId = poll.Id
    db.session.add(answ)
    db.session.commit()

    return answ