import random


def generate_answers(question_3, question_5, range_3, range_5, sample_size=32):
    """
    Helper function that generates answers with response times in
    a certain range
    :param question_3: The question in block 3
    :param question_5: The question in block 5
    :param range_3: Range of response times in block 3
    :param range_5: Range of response times in block 5
    :param sample_size: Amount of images to associate
    :return: List of answers
    """
    block_3_times = random.choices(range_3, k=sample_size)
    block_5_times = random.choices(range_5, k=sample_size)

    block_3 = list(map(lambda x: {"block_nr": 2, "response_time": x, "question_id": question_3.id},
                       block_3_times))
    block_5 = list(map(lambda x: {"block_nr": 4, "response_time": x, "question_id": question_5.id},
                       block_5_times))

    block_3.extend(block_5)

    return block_3