Merge pull request #208 from Excello-Recherche-Education/add-logs

Add logs to registration flow
This commit is contained in:
Adrien Ufferte
2026-01-29 13:23:01 +01:00
committed by GitHub
2 changed files with 17 additions and 0 deletions
+11
View File
@@ -30,6 +30,7 @@ var current_steps: Array[Step] = []
func _ready() -> void:
current_steps = [language_step.instantiate(), account_type_step.instantiate()]
Log.info("Register: Initialized registration flow with %d steps" % current_steps.size())
_go_to_step(int(progress_bar.value))
OpeningCurtain.open()
@@ -52,6 +53,7 @@ func _go_to_step(step_index: int) -> void:
next_step.back.connect(_on_step_back)
next_step.next.connect(_on_step_completed)
next_step.on_enter()
Log.trace("Register: Entered step %s (%d/%d)" % [next_step.step_name, step_index + 1, current_steps.size()])
# Handles progress bar
progress_bar.set_value_with_tween(step_index)
@@ -59,12 +61,15 @@ func _go_to_step(step_index: int) -> void:
func _on_step_back(_step: Step) -> void:
if progress_bar.value == 0:
Log.info("Register: Back to main menu from first step")
get_tree().change_scene_to_file(MAIN_MENU_PATH)
else:
Log.trace("Register: Moving back from step %d" % int(progress_bar.value))
_go_to_step(int(progress_bar.value-1))
func _on_step_completed(step: Step) -> void:
Log.trace("Register: Completed step %s" % step.step_name)
match step.step_name:
"type":
# Adds teacher or parent steps
@@ -108,13 +113,19 @@ func _on_step_completed(step: Step) -> void:
if progress_bar.value == current_steps.size()-1:
# Send register via API
Log.info("Register: Submitting registration for %s" % str(register_data.email))
var res: Dictionary = await ServerManager.register(register_data.to_dict())
if res.code == 200:
Log.info("Register: Registration request successful, saving data")
register_data.last_modified = res.body.last_modified
register_data.token = res.body.token
if UserDataManager.register(register_data):
Log.info("Register: Registration stored locally, moving to package downloader")
get_tree().change_scene_to_file(NEXT_SCENE_PATH)
else:
Log.error("Register: Failed to persist registration locally")
else:
Log.warn("Register: Registration failed with code %d" % res.code)
if res.has("body") and (res.body as Dictionary).has("message"):
popup_info_label.text = res.body.message
else:
+6
View File
@@ -56,6 +56,7 @@ func _on_student_changed(value: int)-> void:
progression = UserDataManager.get_student_progression_for_code(device, student)
_create_lessons()
(%PasswordVisualizer as PasswordVisualizer).password = str(value)
Log.info("LessonUnlocks: Loaded student %d for device %d" % [student, device])
var all_students: Array = UserDataManager.teacher_settings.students[device]
for student_data: StudentData in all_students:
if student_data.code == value:
@@ -66,14 +67,17 @@ func _on_student_changed(value: int)-> void:
func _on_back_button_pressed() -> void:
progression.last_modified = Time.get_datetime_string_from_system(true)
UserDataManager.save_student_progression_for_code(device, student, progression)
Log.info("LessonUnlocks: Saved progression for student %d on device %d" % [student, device])
hide()
func _on_delete_button_pressed() -> void:
Log.warn("LessonUnlocks: Delete requested for student %d on device %d" % [student, device])
student_deleted.emit(int(student))
func _on_device_change_button_pressed() -> void:
Log.trace("LessonUnlocks: Device change requested for student %d" % student)
_device_selection_refresh()
device_selection_container.show()
@@ -81,6 +85,7 @@ func _on_device_change_button_pressed() -> void:
func _on_name_changed(new_name: String) -> void:
UserDataManager.teacher_settings.update_student_name(student, new_name)
teacher_settings.update_student_name(student, new_name)
Log.info("LessonUnlocks: Updated student %d name to %s" % [student, new_name])
func _device_selection_refresh() -> void:
@@ -103,6 +108,7 @@ func _device_button_pressed(device_id: int) -> void:
UserDataManager.teacher_settings.update_student_device(student, device_id)
await teacher_settings.refresh_devices_tabs()
device = device_id
Log.info("LessonUnlocks: Updated student %d to device %d" % [student, device_id])
var res_set: Dictionary = await ServerManager.set_student_data(student, {"device_id": device_id})
if not res_set.success:
Log.trace("LessonUnlocks: Device was updated locally for the student, but the network update failed.")