Exemplo n.º 1
0
async def api_method_start_discussion(request):
    user_id = get_user_id_from_token(request)
    question_id = int(request.ctx.params.get("question_id"))
    result = await services.get_discussion_id(request.ctx.conn, user_id,
                                              question_id)
    await services.add_discussion_to_user(request.ctx.conn, user_id, result)
    return {"discussion_id": str(result)}
Exemplo n.º 2
0
async def api_method_add_hint(request):
    user_id = get_user_id_from_token(request)
    question_id = int(request.ctx.params.get("question_id"))
    value = request.ctx.params.get("value")

    return await services.add_hint(request.ctx.conn, user_id, question_id,
                                   value)
Exemplo n.º 3
0
async def api_method_user_active_question(request):
    user_id = get_user_id_from_token(request)
    question_id = int(request.ctx.params.get("question_id"))
    await services.activate_question_for_user(request.ctx.conn, user_id,
                                              question_id)
    return ""
Exemplo n.º 4
0
async def api_method_get_questions(request):
    user_id = get_user_id_from_token(request)
    questions = await services.get_questions(request.ctx.conn, user_id)
    return questions
Exemplo n.º 5
0
async def api_method_is_active(request):
    user_id = get_user_id_from_token(request)
    question_id = int(request.ctx.params.get("question_id"))
    result = await services.is_question_active_among_users(
        request.ctx.conn, user_id, question_id)
    return result
Exemplo n.º 6
0
async def api_method_vote_message(request):
    user_id = get_user_id_from_token(request)
    message_id = int(request.ctx.params.get("message_id"))
    score = int(request.ctx.params.get("score"))
    return await services.vote_message(request.ctx.conn, message_id, score)
Exemplo n.º 7
0
async def api_method_list_messages(request):
    user_id = get_user_id_from_token(request)
    discussion_id = UUID(request.ctx.params.get("discussion_id"))
    return await services.list_messages(request.ctx.conn, discussion_id)
Exemplo n.º 8
0
async def api_method_add_message(request):
    user_id = get_user_id_from_token(request)
    discussion_id = UUID(request.ctx.params.get("discussion_id"))
    value = request.ctx.params.get("value")
    return await services.add_message(request.ctx.conn, user_id, discussion_id,
                                      value)
Exemplo n.º 9
0
async def api_method_close_discussion(request):
    user_id = get_user_id_from_token(request)
    result = await services.close_discussion(request.ctx.conn, user_id)
    return ""
Exemplo n.º 10
0
async def api_method_get_hint_purchases(request):
    user_id = get_user_id_from_token(request)
    return await services.get_hint_purchases(request.ctx.conn, user_id)
Exemplo n.º 11
0
async def api_method_hints_open(request):
    user_id = get_user_id_from_token(request)
    hint_id = int(request.ctx.params.get("hint_id"))
    return await services.open_hint(request.ctx.conn, user_id, hint_id)
Exemplo n.º 12
0
async def api_method_hints_vote(request):
    hint_id = int(request.ctx.params.get("hint_id"))
    user_id = get_user_id_from_token(request)
    score = int(request.ctx.params.get("score"))
    return await services.vote_hint(request.ctx.conn, user_id, hint_id, score)
Exemplo n.º 13
0
async def api_method_get_hints(request):
    user_id = get_user_id_from_token(request)
    question_id = int(request.ctx.params.get("question_id"))
    return await services.get_hints(request.ctx.conn, user_id, question_id)