Cleaning
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
extends PanelContainer
|
||||
class_name LessonExerciseContainer
|
||||
|
||||
@export var lesson_number: = -1:
|
||||
@export var lesson_number: int = -1:
|
||||
set = _set_lesson_number
|
||||
|
||||
@onready var lesson_id_label: Label = %LessonIDLabel
|
||||
@@ -21,7 +21,7 @@ func _ready() -> void:
|
||||
|
||||
for element: Dictionary in Database.db.query_result:
|
||||
for exercise_button: OptionButton in exercise_buttons:
|
||||
exercise_button.add_item(element.Type, element.ID)
|
||||
exercise_button.add_item(element.Type as String, element.ID as int)
|
||||
|
||||
|
||||
func _set_lesson_number(value: int) -> void:
|
||||
@@ -39,7 +39,7 @@ func _set_lesson_number(value: int) -> void:
|
||||
WHERE LessonNb = " + str(lesson_number))
|
||||
|
||||
for element: Dictionary in Database.db.query_result:
|
||||
var gp: = Label.new()
|
||||
var gp: Label = Label.new()
|
||||
gp.text = Database.get_gp_name(element)
|
||||
lesson_gps.add_child(gp)
|
||||
|
||||
@@ -48,14 +48,14 @@ func _set_lesson_number(value: int) -> void:
|
||||
WHERE LessonNb = " + str(lesson_number))
|
||||
|
||||
for element: Dictionary in Database.db.query_result:
|
||||
exercise_buttons[0].select(exercise_buttons[0].get_item_index(element.Exercise1))
|
||||
exercise_buttons[1].select(exercise_buttons[0].get_item_index(element.Exercise2))
|
||||
exercise_buttons[2].select(exercise_buttons[0].get_item_index(element.Exercise3))
|
||||
exercise_buttons[0].select(exercise_buttons[0].get_item_index(element.Exercise1 as int))
|
||||
exercise_buttons[1].select(exercise_buttons[0].get_item_index(element.Exercise2 as int))
|
||||
exercise_buttons[2].select(exercise_buttons[0].get_item_index(element.Exercise3 as int))
|
||||
|
||||
var gps_in_lesson: = Database.get_gps_for_lesson(lesson_number, true)
|
||||
var syllables_in_lesson: = Database.get_syllables_for_lesson(lesson_number)
|
||||
var words_in_lesson: = Database.get_words_for_lesson(lesson_number)
|
||||
var sentences_in_lesson: = Database.get_sentences(lesson_number, false, sentences_by_lesson)
|
||||
var gps_in_lesson: Array[Dictionary] = Database.get_gps_for_lesson(lesson_number, true)
|
||||
var syllables_in_lesson: Array[Dictionary] = Database.get_syllables_for_lesson(lesson_number)
|
||||
var words_in_lesson: Array[Dictionary] = Database.get_words_for_lesson(lesson_number)
|
||||
var sentences_in_lesson: Array = Database.get_sentences(lesson_number, false, sentences_by_lesson)
|
||||
|
||||
number_of_g_ps.text = str(gps_in_lesson.size())
|
||||
number_of_syllables.text = str(syllables_in_lesson.size())
|
||||
@@ -81,10 +81,10 @@ func _on_save_button_pressed() -> void:
|
||||
Database.db.query("Select * FROM Lessons WHERE LessonNb = " + str(lesson_number))
|
||||
var lesson_id: int = Database.db.query_result[0].ID
|
||||
|
||||
var exercise1: = exercise_buttons[0].get_item_id(exercise_buttons[0].selected)
|
||||
var exercise2: = exercise_buttons[1].get_item_id(exercise_buttons[1].selected)
|
||||
var exercise3: = exercise_buttons[2].get_item_id(exercise_buttons[2].selected)
|
||||
var lesson_dict: = {Exercise1= exercise1, Exercise2= exercise2, Exercise3= exercise3}
|
||||
var exercise1: int = exercise_buttons[0].get_item_id(exercise_buttons[0].selected)
|
||||
var exercise2: int = exercise_buttons[1].get_item_id(exercise_buttons[1].selected)
|
||||
var exercise3: int = exercise_buttons[2].get_item_id(exercise_buttons[2].selected)
|
||||
var lesson_dict: Dictionary = {"Exercise1": exercise1, "Exercise2": exercise2, "Exercise3": exercise3}
|
||||
|
||||
Database.db.query("Select * FROM LessonsExercises WHERE LessonID = " + str(lesson_id))
|
||||
if Database.db.query_result.is_empty():
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
const GARDENS_SCENE: PackedScene = preload("res://sources/gardens/gardens.tscn")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@tool
|
||||
extends WordsMinigame
|
||||
|
||||
signal can_spawn_turtle()
|
||||
|
||||
@@ -15,7 +15,6 @@ point_count = 6
|
||||
|
||||
[node name="TurtlesMinigame" instance=ExtResource("1_geqym")]
|
||||
script = ExtResource("2_f5de7")
|
||||
max_number_of_gps = 6
|
||||
minigame_name = 6
|
||||
lesson_nb = 24
|
||||
difficulty = 4
|
||||
|
||||
@@ -105,7 +105,7 @@ func get_exercise_for_lesson(lesson_nb: int) -> Array[int]:
|
||||
return result
|
||||
|
||||
|
||||
func get_gps_for_lesson(lesson_nb: int, distinct: bool, only_new: bool = false, only_vowels: bool = false, with_other_phonemes: bool = false, include_exceptions: bool = false) -> Array:
|
||||
func get_gps_for_lesson(lesson_nb: int, distinct: bool, only_new: bool = false, only_vowels: bool = false, with_other_phonemes: bool = false, include_exceptions: bool = false) -> Array[Dictionary]:
|
||||
|
||||
var parameters: Array = []
|
||||
var symbol: String = "<=" if not only_new else "=="
|
||||
|
||||
@@ -124,6 +124,7 @@ func _determine_students_update(response_body: Dictionary, need_update_user: Upd
|
||||
else:
|
||||
server_student_remediation_words_unix_time = 0
|
||||
var found: bool = false
|
||||
need_update_students[code_to_check] = {}
|
||||
for device: int in UserDataManager.teacher_settings.students.keys():
|
||||
var students_in_device: Array[StudentData] = UserDataManager.teacher_settings.students[device]
|
||||
for student_data: StudentData in students_in_device:
|
||||
@@ -134,11 +135,11 @@ func _determine_students_update(response_body: Dictionary, need_update_user: Upd
|
||||
var local_student_unix_time: int = Time.get_unix_time_from_datetime_string(student_data.last_modified)
|
||||
if local_student_unix_time == server_student_unix_time:
|
||||
Logger.trace("UserDatabaseSynchronizer: Student %d data timestamp is the same in local and on server. No synchronization necessary" % code_to_check)
|
||||
need_update_students[code_to_check] = {"data": UpdateNeeded.Nothing}
|
||||
need_update_students[code_to_check].merge({"data": UpdateNeeded.Nothing})
|
||||
elif local_student_unix_time > server_student_unix_time:
|
||||
need_update_students[code_to_check] = {"data": UpdateNeeded.FromLocal}
|
||||
need_update_students[code_to_check].merge({"data": UpdateNeeded.FromLocal})
|
||||
else:
|
||||
need_update_students[code_to_check] = {"data": UpdateNeeded.FromServer}
|
||||
need_update_students[code_to_check].merge({"data": UpdateNeeded.FromServer})
|
||||
|
||||
# Synchronize student remediation
|
||||
var student_remediation: UserRemediation = UserDataManager.get_student_remediation_data(code_to_check)
|
||||
@@ -146,38 +147,36 @@ func _determine_students_update(response_body: Dictionary, need_update_user: Upd
|
||||
var local_student_gp_remediation_unix_time: int = Time.get_unix_time_from_datetime_string(student_remediation.gp_last_modified)
|
||||
if local_student_gp_remediation_unix_time == server_student_remediation_gp_unix_time:
|
||||
Logger.trace("UserDatabaseSynchronizer: Student %d GP remediation data timestamp is the same in local and on server. No synchronization necessary" % code_to_check)
|
||||
need_update_students[code_to_check] = {"remediation_gp": UpdateNeeded.Nothing}
|
||||
need_update_students[code_to_check].merge({"remediation_gp": UpdateNeeded.Nothing})
|
||||
elif local_student_gp_remediation_unix_time > server_student_remediation_gp_unix_time:
|
||||
need_update_students[code_to_check] = {"remediation_gp": UpdateNeeded.FromLocal}
|
||||
need_update_students[code_to_check].merge({"remediation_gp": UpdateNeeded.FromLocal})
|
||||
else:
|
||||
need_update_students[code_to_check] = {"remediation_gp": UpdateNeeded.FromServer}
|
||||
need_update_students[code_to_check].merge({"remediation_gp": UpdateNeeded.FromServer})
|
||||
|
||||
var local_student_syllables_remediation_unix_time: int = Time.get_unix_time_from_datetime_string(student_remediation.syllables_last_modified)
|
||||
if local_student_syllables_remediation_unix_time == server_student_remediation_syllables_unix_time:
|
||||
Logger.trace("UserDatabaseSynchronizer: Student %d syllables remediation data timestamp is the same in local and on server. No synchronization necessary" % code_to_check)
|
||||
need_update_students[code_to_check] = {"remediation_syllables": UpdateNeeded.Nothing}
|
||||
need_update_students[code_to_check].merge({"remediation_syllables": UpdateNeeded.Nothing})
|
||||
elif local_student_syllables_remediation_unix_time > server_student_remediation_syllables_unix_time:
|
||||
need_update_students[code_to_check] = {"remediation_syllables": UpdateNeeded.FromLocal}
|
||||
need_update_students[code_to_check].merge({"remediation_syllables": UpdateNeeded.FromLocal})
|
||||
else:
|
||||
need_update_students[code_to_check] = {"remediation_syllables": UpdateNeeded.FromServer}
|
||||
need_update_students[code_to_check].merge({"remediation_syllables": UpdateNeeded.FromServer})
|
||||
|
||||
var local_student_words_remediation_unix_time: int = Time.get_unix_time_from_datetime_string(student_remediation.words_last_modified)
|
||||
if local_student_words_remediation_unix_time == server_student_remediation_words_unix_time:
|
||||
Logger.trace("UserDatabaseSynchronizer: Student %d words remediation data timestamp is the same in local and on server. No synchronization necessary" % code_to_check)
|
||||
need_update_students[code_to_check] = {"remediation_words": UpdateNeeded.Nothing}
|
||||
need_update_students[code_to_check].merge({"remediation_words": UpdateNeeded.Nothing})
|
||||
elif local_student_words_remediation_unix_time > server_student_remediation_words_unix_time:
|
||||
need_update_students[code_to_check] = {"remediation_words": UpdateNeeded.FromLocal}
|
||||
need_update_students[code_to_check].merge({"remediation_words": UpdateNeeded.FromLocal})
|
||||
else:
|
||||
need_update_students[code_to_check] = {"remediation_words": UpdateNeeded.FromServer}
|
||||
need_update_students[code_to_check].merge({"remediation_words": UpdateNeeded.FromServer})
|
||||
break
|
||||
if found:
|
||||
break
|
||||
if not found:
|
||||
if need_update_user == UpdateNeeded.FromServer:
|
||||
need_update_students[code_to_check] = {}
|
||||
need_update_students[code_to_check]["data"] = UpdateNeeded.FromServer
|
||||
elif need_update_user == UpdateNeeded.FromLocal:
|
||||
need_update_students[code_to_check] = {}
|
||||
need_update_students[code_to_check]["data"] = UpdateNeeded.DeleteServer
|
||||
else:
|
||||
Logger.warn("UserDatabaseSynchronizer: Student %d not found in local, but user doesn't need to be updated...this is theoretically not possible" % code_to_check)
|
||||
|
||||
Reference in New Issue
Block a user