示例#1
0
 def room(room_id):
     '''
     :input: {'room_name':'nodejs'}
     :return: boolean
     '''
     json_body = request.get_json()
     issuccess = db_session(Room, json_body, request.method, id=room_id)
     return create_response(201, {'status': issuccess})
示例#2
0
 def group(group_id):
     '''
     :input: {'group_name':'feliz'}
     :return: boolean
     '''
     json_body = request.get_json()
     issuccess = db_session(Group, json_body, request.method, id=group_id)
     return create_response(201, {'status': issuccess})
示例#3
0
 def config(config_id):
     '''
     :input: {'config_name':'settimelimit','challenge_limit':2}
     :return: {'config_name':'settimelimit','challenge_limit':2 in hours}
     '''
     json_body = request.get_json()
     issuccess = db_session(Configuration, json_body, id=config_id)
     return create_response(201, {'status': issuccess})
示例#4
0
 def checkin():
     '''
     :input: {'group':'cbb9cf31-cee5-4208-bfea-654646c83f6d','room':'bdac321b-c65d-463a-97e1-05a11f98024a'}
     :return: boolean
     '''
     json_body = request.get_json()
     issuccess = db_session(CheckIn, json_body, request.method)
     return create_response(201, {'status': issuccess})
示例#5
0
 def room_questions_answers(room_id, qa_id):
     '''
     :input: {
         'question': 5,
         'answer':'sua resposta5',
         'num_points':5,
         'room':'9efcb329-4242-42ba-a1bf-2305f80c86cd'
     } or list
     :return: boolean
     '''
     json_body = request.get_json()
     issuccess = db_session(QuestionsAnswers,
                            json_body,
                            request.method,
                            id=qa_id,
                            room_id=room_id)
     return create_response(201, {'status': issuccess})
示例#6
0
 def group_answer():
     '''
     :input: {
         'question': 5,
         'answer':'sua resposta5',
         'room':'9efcb329-4242-42ba-a1bf-2305f80c86cd',
         'group':'9efcb329-4242-42ba-a1bf-2305f80c86cd'
     }
     :return: try number
     '''
     json_body = request.get_json()
     room_id = json_body.get('room')
     group_id = json_body.get('group')
     question_id = json_body.get('question')
     answer_text = json_body.get('answer')
     checkin_data = group_checkin(room_id, group_id)
     if not checkin_data:
         return create_response(203, {'message_code': 'GNC203'})
     if not group_check_limit_time(checkin_data):
         return create_response(503, {'message_code': 'GTT503'})
     question_answer = get_question_answer(question_id, room_id)
     if not question_answer:
         return create_response(500, {'message_code': 'QNF500'})
     question_answer_id = str(question_answer.id)
     question_answer_ok = question_answer.answer
     json_body.update({'question': question_answer_id})
     wrong_answers, correct_answers = get_group_answers(
         group_id, room_id, question_answer_id, question_answer_ok)
     if not correct_answers:
         if not check_num_attempts(room_id, group_id, question_answer_ok):
             return create_response(503, {'message_code': 'GTO503'})
         inserted = db_session(GroupAnswers,
                               json_body,
                               request.method,
                               group_id=group_id,
                               room_id=room_id)
         if not inserted:
             return create_response(500, {'message_code': 'NIE500'})
         has_valid_answer, wrong_answers, correct_answers = check_group_valid_answer(
             room_id, question_answer_id, question_answer_ok, group_id,
             answer_text)
         if has_valid_answer:
             return create_response(201, {'message_code': 'GTS201'})
         return GroupAnswersSchema().jsonify(wrong_answers, many=True)
     return create_response(302, {'message_code': 'GAO302'})