当前位置: 首页>>代码示例>>Python>>正文


Python Question.objects方法代码示例

本文整理汇总了Python中models.Question.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Question.objects方法的具体用法?Python Question.objects怎么用?Python Question.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Question的用法示例。


在下文中一共展示了Question.objects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: player_questions

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import objects [as 别名]
def player_questions(name):
    ''' get a relevant question
    '''

    '''
    players = Player.objects(name=name)
    if not players:
        abort(404)
    player = players[0]
    '''

    questions = Question.objects()
    index = int(math.floor(random.random()*len(questions)))

    q = questions[index]

    return jsonify({
        'prompt': q.prompt
        , 'response_0': q.possible_responses[0]
        , 'response_1': q.possible_responses[1]
        , 'response_2': q.possible_responses[2]
        , 'response_3': q.possible_responses[3]
        , 'classification': q.classification
        , 'question_id': str(q.id)
    })
开发者ID:conservasian,项目名称:doubleyou,代码行数:27,代码来源:app.py

示例2: destroy_seed

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import objects [as 别名]
def destroy_seed():
    objects = []
    objects.extend(Question.objects())
    objects.extend(Player.objects())
    objects.extend(Answer.objects())
    objects.extend(BodyMediaData.objects())

    for o in objects:
        o.delete()

    return 'ouch'
开发者ID:conservasian,项目名称:doubleyou,代码行数:13,代码来源:app.py

示例3: player_answers

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import objects [as 别名]
def player_answers(name):
    players = Player.objects(name=name)
    if not players:
        abort(404)
    player = players[0]

    question_id = request.form.get('question_id', '')
    response = request.form.get('response', '') 
    question = Question.objects(id=question_id)[0]

    new_answer = Answer(
        question = question
        , player = player
        , data = int(response)
        , timestamp = datetime.datetime.utcnow()
    )
    new_answer.save()

    player.update(set__last_answer_time=datetime.datetime.utcnow())
    answer_count = Answer.objects(player=player).count()

    return jsonify({'status': 'ok', 'answer_count': answer_count})
开发者ID:conservasian,项目名称:doubleyou,代码行数:24,代码来源:app.py

示例4: seed_questions

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import objects [as 别名]
def seed_questions():
    questions = Question.objects()
    if questions:
        return 'already seeded'

    q = Question(
        prompt = 'How many times did you wake up last night?'
        , possible_responses = ['0', '1', '2', '3']
        , classification = 'morning'
    )
    q.save()

    q = Question(
        prompt = 'How bad were your asthma symptoms when you woke up this morning?'
        , possible_responses = ['not bad at all', 'a little bad', 'somewhat bad', 'very bad']
        , classification = 'morning'
    )
    q.save()

    q = Question(
        prompt = 'How rested do you feel this morning?'
        , possible_responses = ['well rested', 'somewhat', 'a little', 'not at all']
        , classification = 'morning'
    )
    q.save()

    q = Question(
        prompt = 'How much trouble did you have falling asleep?'
        , possible_responses = ['no trouble', 'a little trouble', 'some trouble', 'a lot of trouble']
        , classification = 'morning'
    )
    q.save()

    q = Question(
        prompt = 'How limited were you in activities because of your asthma?'
        , possible_responses = ['not at all', 'a little', 'somewhat', 'a lot']
        , classification = 'night'
    )
    q.save()

    q = Question(
        prompt = 'How much shortness did you experience because of your asthma?'
        , possible_responses = ['none at all', 'a little', 'some', 'a lot']
        , classification = 'night'
    )
    q.save()

    q = Question(
        prompt = 'How much time did you wheeze today?'
        , possible_responses = ['none at all', 'a little of the time', 'some of the time', 'a lot of the time']
        , classification = 'night'
    )
    q.save()

    q = Question(
        prompt = 'How many times did you use your inhaler today?'
        , possible_responses = ['zero', '1-2', '3-4', '5+']
        , classification = 'night'
    )
    q.save()

    q = Question(
        prompt = 'How much did your asthma affect your exercise today?'
        , possible_responses = ['not at all', 'a little', 'somewhat', 'a lot']
        , classification = 'night'
    )
    q.save()

    q = Question(
        prompt = 'How would you rate your asthma control today?'
        , possible_responses = ['1', '2', '3', '4']
        , classification = 'night'
    )
    q.save()

    return 'ok'
开发者ID:conservasian,项目名称:doubleyou,代码行数:78,代码来源:app.py


注:本文中的models.Question.objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。