fixed floating point conversion in percentages for results page

This commit is contained in:
Jaap Marsman 2022-11-13 16:53:49 +08:00
parent 134867857b
commit 9d1d38db90
3 changed files with 25 additions and 22 deletions

View File

@ -23,6 +23,19 @@ func _process(_delta):
$"Panel/BehaviourButtons".visible = true $"Panel/BehaviourButtons".visible = true
func calculate_percentages():
global_ints.total_observed_time = global_ints.total_behaviours / 3
global_ints.one_behaviour_percent = int((float(global_ints.one_behaviour_score) / global_ints.total_behaviours) * 100)
global_ints.two_behaviour_percent = int((float(global_ints.two_behaviour_score) / global_ints.total_behaviours) * 100)
global_ints.three_behaviour_percent = int((float(global_ints.three_behaviour_score) / global_ints.total_behaviours) * 100)
global_ints.four_behaviour_percent = int((float(global_ints.four_behaviour_score) / global_ints.total_behaviours) * 100)
global_ints.five_behaviour_percent = int((float(global_ints.five_behaviour_score) / global_ints.total_behaviours) * 100)
func on_interval_moment(): func on_interval_moment():
print("Timer reaches 0 - Let's check if buttons have been pressed and count something") print("Timer reaches 0 - Let's check if buttons have been pressed and count something")
toggle_observation = false toggle_observation = false
@ -57,6 +70,7 @@ func _on_TwentySecondTimer_timeout():
$"TwentySecondTimer".stop() $"TwentySecondTimer".stop()
global_ints.generate_results = true global_ints.generate_results = true
calculate_percentages()
$"../Results".visible = true $"../Results".visible = true
if global_ints.locked_observations_intervals_remaining > 1: if global_ints.locked_observations_intervals_remaining > 1:
@ -115,4 +129,5 @@ func _on_Button_pressed():
$"TwentySecondTimer".stop() $"TwentySecondTimer".stop()
global_ints.generate_results = true global_ints.generate_results = true
calculate_percentages()
$"../Results".visible = true $"../Results".visible = true

View File

@ -87,18 +87,6 @@ func _on_Results_visibility_changed():
if global_ints.generate_results == true: if global_ints.generate_results == true:
global_ints.generate_results = false global_ints.generate_results = false
global_ints.total_observed_time = global_ints.total_behaviours / 3
global_ints.one_behaviour_percent = (global_ints.one_behaviour_score / global_ints.total_behaviours) * 100
global_ints.two_behaviour_percent = (global_ints.two_behaviour_score / global_ints.total_behaviours) * 100
global_ints.three_behaviour_percent = (global_ints.three_behaviour_score / global_ints.total_behaviours) * 100
global_ints.four_behaviour_percent = (global_ints.four_behaviour_score / global_ints.total_behaviours) * 100
global_ints.five_behaviour_percent = (global_ints.five_behaviour_score / global_ints.total_behaviours) * 100
var result_text : String var result_text : String
result_text = str("Date: " , global_ints.ddmmyyyy , "\nTime: ", global_ints.observation_start_time , " to " , global_ints.observation_end_time , "\n \nThis Time Sampling Form (TSF) observation was completed by " , global_ints.observer_person_name , ". " , global_ints.observed_person_name , " was observed for " , global_ints.total_observed_time , " minute(s) during " , global_ints.observed_activity , ". \n \nDuring the observation, The ", global_ints.one_behaviour," behaviour was observed ", global_ints.one_behaviour_score, " out of ",global_ints.total_behaviours," times, resulting in ",global_ints.one_behaviour_percent,"%. The ",global_ints.two_behaviour," behaviour was observed ",global_ints.two_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.two_behaviour_percent,"%. The ",global_ints.three_behaviour," behaviour was observed ",global_ints.three_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.three_behaviour_percent,"%. The ", global_ints.four_behaviour," behaviour was observed ",global_ints.four_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.four_behaviour_percent,"%. The ",global_ints.five_behaviour," behaviour was observed ",global_ints.five_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.five_behaviour_percent,"%. ",global_ints.six_behaviour_score," intervals were not scored.") result_text = str("Date: " , global_ints.ddmmyyyy , "\nTime: ", global_ints.observation_start_time , " to " , global_ints.observation_end_time , "\n \nThis Time Sampling Form (TSF) observation was completed by " , global_ints.observer_person_name , ". " , global_ints.observed_person_name , " was observed for " , global_ints.total_observed_time , " minute(s) during " , global_ints.observed_activity , ". \n \nDuring the observation, The ", global_ints.one_behaviour," behaviour was observed ", global_ints.one_behaviour_score, " out of ",global_ints.total_behaviours," times, resulting in ",global_ints.one_behaviour_percent,"%. The ",global_ints.two_behaviour," behaviour was observed ",global_ints.two_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.two_behaviour_percent,"%. The ",global_ints.three_behaviour," behaviour was observed ",global_ints.three_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.three_behaviour_percent,"%. The ", global_ints.four_behaviour," behaviour was observed ",global_ints.four_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.four_behaviour_percent,"%. The ",global_ints.five_behaviour," behaviour was observed ",global_ints.five_behaviour_score," out of ",global_ints.total_behaviours," times, resulting in ",global_ints.five_behaviour_percent,"%. ",global_ints.six_behaviour_score," intervals were not scored.")

View File

@ -55,11 +55,11 @@ var four_behaviour_score : int
var five_behaviour_score : int var five_behaviour_score : int
var six_behaviour_score : int var six_behaviour_score : int
var one_behaviour_percent : int var one_behaviour_percent : float
var two_behaviour_percent : int var two_behaviour_percent : float
var three_behaviour_percent : int var three_behaviour_percent : float
var four_behaviour_percent : int var four_behaviour_percent : float
var five_behaviour_percent : int var five_behaviour_percent : float
func reset_all_vars(): func reset_all_vars():
observation_minutes = 15 observation_minutes = 15
@ -104,11 +104,11 @@ func reset_all_vars():
five_behaviour_score = 0 five_behaviour_score = 0
six_behaviour_score = 0 six_behaviour_score = 0
one_behaviour_percent = 0 one_behaviour_percent = 0.0
two_behaviour_percent = 0 two_behaviour_percent = 0.0
three_behaviour_percent = 0 three_behaviour_percent = 0.0
four_behaviour_percent = 0 four_behaviour_percent = 0.0
five_behaviour_percent = 0 five_behaviour_percent = 0.0
observation_start_time = "" observation_start_time = ""
observation_end_time = "" observation_end_time = ""