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)}
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)
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 ""
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
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
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)
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)
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)
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 ""
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)
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)
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)
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)