Estou a criar uma função para um typingtest cronometrizado que pretende avaliar o tempo de reação de cada input e calcular o tempo de duração do teste. Este teste finda por um de dois motivos: ou chegamos ao tempo limite (threshold) ou carregamos na barra de espaço. Para obter a duração do exame, estou a somar ao tempo no ínicio do teste (time_b4) os tempos de reação de cada input (reaction_time). O problema é que quando carregamos na barra de espaço, não há tempo de reação, então o tempo de duração do teste calculado terá um desfasamento em relação ao tempo de duração real. Como é que posso resolver isto sem alterar as métricas de tempo médio de reação? E sendo que depois dou return da letra gerada, da letra digitada, do tempo de reação e do time_b4, como posso corrigir sem alterar isto?
' time_b4 = time.time() #Stores the time when the test was started
timing = 0 #Define value 0 to the variable that is going to be used during the while cycle
#The function will run until the duration limit is reached
while not timing >= float(threshold):
correct_letter = random.randint(97,122) #Generates a random letter
print('Type letter "',chr(correct_letter),'"') #Prints the generated letter
time_b4_chr = time.time() #Gets the time before the input
typed_letter = readchar.readkey() #Reads the input letter
time_after = time.time() #Gets the time after the input
reaction_time = time_after - time_b4_chr #Reaction time
timing = time_after - time_b4 #Elapsed time
if typed_letter == chr(32): #Clicking on the space bar
time_after = time.time() #End date of the text
break`
Estou a criar uma função para um typingtest cronometrizado que pretende avaliar o tempo de reação de cada input e calcular o tempo de duração do teste. Este teste finda por um de dois motivos: ou chegamos ao tempo limite (threshold) ou carregamos na barra de espaço. Para obter a duração do exame, estou a somar ao tempo no ínicio do teste (time_b4) os tempos de reação de cada input (reaction_time). O problema é que quando carregamos na barra de espaço, não há tempo de reação, então o tempo de duração do teste calculado terá um desfasamento em relação ao tempo de duração real. Como é que posso resolver isto sem alterar as métricas de tempo médio de reação? E sendo que depois dou return da letra gerada, da letra digitada, do tempo de reação e do time_b4, como posso corrigir sem alterar isto?
' time_b4 = time.time() #Stores the time when the test was started timing = 0 #Define value 0 to the variable that is going to be used during the while cycle