Clean code naming convention V5

This commit is contained in:
Adrien Ufferte
2025-06-09 20:34:27 +02:00
parent beb04e5cc2
commit fc5fe65f70
4 changed files with 41 additions and 41 deletions
+9 -9
View File
@@ -17,9 +17,9 @@ var gps_scores: Dictionary[int, int] = {}
# Gets the score of a GP if it is below or equals to the remediation score
func get_gp_score(ID: int) -> int:
if gps_scores.has(ID):
return gps_scores[ID] if gps_scores[ID] <= REMEDIATION_SCORE else 0
func get_gp_score(id: int) -> int:
if gps_scores.has(id):
return gps_scores[id] if gps_scores[id] <= REMEDIATION_SCORE else 0
return 0
@@ -28,15 +28,15 @@ func update_gp_scores(minigame_scores: Dictionary) -> void:
if not minigame_scores:
return
Logger.trace("UserRemediation: Update GP Scores: " + str(minigame_scores))
for ID: int in minigame_scores.keys():
for id: int in minigame_scores.keys():
var new_gp_score: int = 0
if gps_scores.has(ID):
new_gp_score += gps_scores[ID]
new_gp_score += minigame_scores[ID]
if gps_scores.has(id):
new_gp_score += gps_scores[id]
new_gp_score += minigame_scores[id]
if new_gp_score >= 0:
gps_scores.erase(ID)
gps_scores.erase(id)
else:
gps_scores[ID] = maxi(MIN_SCORE, new_gp_score)
gps_scores[id] = maxi(MIN_SCORE, new_gp_score)
score_changed.emit()
+4 -4
View File
@@ -318,12 +318,12 @@ func _sort_scoring(stimulus1: Dictionary, stimulus2: Dictionary) -> bool:
# Updates the score of a GP defined by his ID
func _update_score(ID: int, score: int) -> void:
func _update_score(id: int, score: int) -> void:
var new_gp_score: int = 0
if gp_scores.has(ID):
new_gp_score += gp_scores[ID]
if gp_scores.has(id):
new_gp_score += gp_scores[id]
new_gp_score += score
gp_scores[ID] = new_gp_score
gp_scores[id] = new_gp_score
#endregion
+8 -8
View File
@@ -150,23 +150,23 @@ func get_gps_for_lesson(lesson_nb: int, distinct: bool, only_new: bool = false,
return result
func get_gps_from_syllable(syllable_ID: int) -> Array[Dictionary]:
db.query_with_bindings("SELECT GPs.ID, GPs.Grapheme, GPs.Phoneme, GPs.Type FROM Syllables INNER JOIN GPsInSyllables ON Syllables.ID = GPsInSyllables.SyllableID AND Syllables.ID=? INNER JOIN GPs WHERE GPs.ID = GPsInSyllables.GPID ORDER BY Position", [syllable_ID])
func get_gps_from_syllable(syllable_id: int) -> Array[Dictionary]:
db.query_with_bindings("SELECT GPs.ID, GPs.Grapheme, GPs.Phoneme, GPs.Type FROM Syllables INNER JOIN GPsInSyllables ON Syllables.ID = GPsInSyllables.SyllableID AND Syllables.ID=? INNER JOIN GPs WHERE GPs.ID = GPsInSyllables.GPID ORDER BY Position", [syllable_id])
return db.query_result
func get_gp_from_word(ID: int) -> Array:
db.query_with_bindings("SELECT GPs.* FROM Words INNER JOIN GPsInWords ON Words.ID = GPsInWords.WordID AND Words.ID=? INNER JOIN GPs WHERE GPs.ID = GPsInWords.GPID ORDER BY Position", [ID])
func get_gp_from_word(id: int) -> Array:
db.query_with_bindings("SELECT GPs.* FROM Words INNER JOIN GPsInWords ON Words.ID = GPsInWords.WordID AND Words.ID=? INNER JOIN GPs WHERE GPs.ID = GPsInWords.GPID ORDER BY Position", [id])
return db.query_result
func get_gps_from_sentence(sentenceID: int) -> Array[Dictionary]:
func get_gps_from_sentence(sentence_id: int) -> Array[Dictionary]:
db.query_with_bindings("SELECT GPs.ID, GPs.Grapheme, GPs.Phoneme, GPs.Type, GPsInWords.WordID, GPsInWords.Position AS GPPosition, WordsInSentences.Position AS WordPosition FROM GPs
INNER JOIN GPsInWords ON GPsInWords.GPID = GPs.ID
INNER JOIN WordsInSentences ON WordsInSentences.WordID = GPsInWords.WordID
INNER JOIN Sentences ON Sentences.ID = WordsInSentences.SentenceID
WHERE Sentences.ID = ?
ORDER BY WordPosition ASC, GPPosition ASC", [sentenceID])
ORDER BY WordPosition ASC, GPPosition ASC", [sentence_id])
return db.query_result
@@ -468,8 +468,8 @@ func get_audio_stream_for_path(path: String) -> AudioStream:
return load(full_path)
func get_audio_stream_for_word(ID: int) -> AudioStream:
var gps: Array = get_gp_from_word(ID)
func get_audio_stream_for_word(id: int) -> AudioStream:
var gps: Array = get_gp_from_word(id)
var file_name: String = _phoneme_to_string(gps[0].Phoneme as String)
for index: int in range(1, gps.size()):
var gp: Dictionary = gps[index]
+20 -20
View File
@@ -132,16 +132,16 @@ func check_internet_access() -> bool:
return false
func _create_uri_with_parameters(URI: String, params: Dictionary) -> String:
func _create_uri_with_parameters(uri: String, params: Dictionary) -> String:
var is_first_param: bool = true
for key: String in params.keys():
if is_first_param:
URI += "?"
uri += "?"
is_first_param = false
else:
URI += "&"
URI += str(key) + "=" + str(params[key])
return URI
uri += "&"
uri += str(key) + "=" + str(params[key])
return uri
func _create_request_headers(contentTypeJSON: bool = false) -> PackedStringArray:
@@ -169,14 +169,14 @@ func _response() -> Dictionary:
return res
func _get_request(URI: String, params: Dictionary) -> void:
func _get_request(uri: String, params: Dictionary) -> void:
reset_result()
var headers: PackedStringArray = _create_request_headers()
if params.has("password"):
Logger.trace("ServerManager Sending GET request.\n URI = %s\n Parameters not logged because it contains a password." % URI)
Logger.trace("ServerManager Sending GET request.\n URI = %s\n Parameters not logged because it contains a password." % uri)
else:
Logger.trace("ServerManager Sending GET request.\n URI = %s\n Parameters = %s" % [URI, params])
if http_request.request(_create_uri_with_parameters(environment_url + URI, params), headers) == OK:
Logger.trace("ServerManager Sending GET request.\n URI = %s\n Parameters = %s" % [uri, params])
if http_request.request(_create_uri_with_parameters(environment_url + uri, params), headers) == OK:
await request_completed
else:
Logger.error("ServerManager Error sending GET request")
@@ -184,14 +184,14 @@ func _get_request(URI: String, params: Dictionary) -> void:
json = {message = "Internal Server Error"}
func _post_request(URI: String, params: Dictionary) -> void:
func _post_request(uri: String, params: Dictionary) -> void:
reset_result()
var url: String = _create_uri_with_parameters(environment_url + URI, params)
var url: String = _create_uri_with_parameters(environment_url + uri, params)
var headers: PackedStringArray = _create_request_headers()
if params.has("password"):
Logger.trace("ServerManager Sending POST request.\n URI = %s\n Parameters not logged because it contains a password." % URI)
Logger.trace("ServerManager Sending POST request.\n URI = %s\n Parameters not logged because it contains a password." % uri)
else:
Logger.trace("ServerManager Sending POST request.\n URI = %s\n Parameters = %s" % [URI, params])
Logger.trace("ServerManager Sending POST request.\n URI = %s\n Parameters = %s" % [uri, params])
if http_request.request(url, headers, HTTPClient.METHOD_POST, "") == OK:
await request_completed
else:
@@ -200,14 +200,14 @@ func _post_request(URI: String, params: Dictionary) -> void:
json = {message = "Internal Server Error"}
func _post_json_request(URI: String, data: Dictionary) -> void:
func _post_json_request(uri: String, data: Dictionary) -> void:
reset_result()
var req: String = environment_url + URI
var req: String = environment_url + uri
var headers: PackedStringArray = _create_request_headers(true)
if data.has("password"):
Logger.trace("ServerManager sending POST JSON request.\n URI = %s\n Data not logged because it contains a password." % URI)
Logger.trace("ServerManager sending POST JSON request.\n URI = %s\n Data not logged because it contains a password." % uri)
else:
Logger.trace("ServerManager Sending POST JSON request.\n URI = %s\n Data = %s" % [URI, data])
Logger.trace("ServerManager Sending POST JSON request.\n URI = %s\n Data = %s" % [uri, data])
if http_request.request(req, headers, HTTPClient.METHOD_POST, JSON.stringify(data)) == OK:
await request_completed
else:
@@ -216,11 +216,11 @@ func _post_json_request(URI: String, data: Dictionary) -> void:
json = {message = "Internal Server Error"}
func _delete_request(URI: String, params: Dictionary = {}) -> void:
func _delete_request(uri: String, params: Dictionary = {}) -> void:
reset_result()
var req: String = _create_uri_with_parameters(environment_url + URI, params)
var req: String = _create_uri_with_parameters(environment_url + uri, params)
var headers: PackedStringArray = _create_request_headers()
Logger.trace("ServerManager Sending DELETE request.\n URI = %s\n Parameters = %s" % [URI, params])
Logger.trace("ServerManager Sending DELETE request.\n URI = %s\n Parameters = %s" % [uri, params])
if http_request.request(req, headers, HTTPClient.METHOD_DELETE, "") == OK:
await request_completed
else: