コード例 #1
0
def student_ping(qid):
    """Updates user last ping timestamp and returns current question"""

    # Get models
    student = get_student()
    questionnaire = Questionnaire.select().where(Questionnaire.public_id == qid).get()

    # Update presence
    StudentPresence.update_latest(student, questionnaire)

    # Get current question
    question = questionnaire.presented_question()

    return json.dumps({'presented_question': question.id})
コード例 #2
0
ファイル: misc.py プロジェクト: vojto/riddle
def presentation_status(qid):
    """
    For a questionnaire, returns number of connected users and the
    question that is currently presented.
    """
    # TODO: For now we'll just return status for questionnaire
    # In the future, we'll want to check which questionnaire is being presented
    # by user, and return info for that questionnaire

    try:
        questionnaire = Questionnaire.get(Questionnaire.public_id == qid)
    except Questionnaire.DoesNotExist:
        return response_error('not_found')

    count = StudentPresence.count_active(questionnaire)
    question = questionnaire.presented_question()
    questionData = question.as_json() if question else None

    return json.dumps({'student_count': count, 'presented_question': questionData})
コード例 #3
0
def presentation_status(qid):
    """
    For a questionnaire, returns number of connected users and the
    question that is currently presented.
    """
    # TODO: For now we'll just return status for questionnaire
    # In the future, we'll want to check which questionnaire is being presented
    # by user, and return info for that questionnaire

    try:
        questionnaire = Questionnaire.get(Questionnaire.public_id == qid)
    except Questionnaire.DoesNotExist:
        return response_error('not_found')

    count = StudentPresence.count_active(questionnaire)
    question = questionnaire.presented_question()
    questionData = question.as_json() if question else None

    return json.dumps({
        'student_count': count,
        'presented_question': questionData
    })