Plug the GP database in crabs

This commit is contained in:
BimDav
2023-03-08 17:48:06 +01:00
parent 686b85a9a6
commit 8548f5fa21
4 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ func set_button_active(active: bool) -> void:
func set_stimulus(p_stimulus: Dictionary) -> void:
stimulus = p_stimulus
label.text = stimulus["label"]
label.text = stimulus["Grapheme"]
func _on_button_pressed() -> void:
+3 -8
View File
@@ -2,6 +2,7 @@
extends Minigame
@export var difficulty: = 1
@export var lesson_nb: = 4
const hole_class: = preload("res://sources/minigames/crabs/hole/hole.tscn")
const difficulty_settings: = {
@@ -56,14 +57,8 @@ func _setup_minigame() -> void:
# Find the stimuli and distractions of the minigame.
func _find_stimuli_and_distractions() -> void:
# TODO: fake stimuli and distractor for testing
# Replace in the future by a proper research
stimuli = [{"label": "a", "sound": ""}]
distractions = [
{"label": "e", "sound": ""},
{"label": "u", "sound": ""},
{"label": "o", "sound": ""},
]
stimuli = Database.get_GP_for_lesson(lesson_nb)
distractions = Database.get_GP_before_lesson(lesson_nb)
# Launch the minigame
@@ -11,6 +11,7 @@
[node name="Crabs" instance=ExtResource("1_lbq56")]
script = ExtResource("2_gierf")
difficulty = 4
lesson_nb = 4
minigame_name = "Crabs"
max_number_of_lives = 5
max_progression = 5
+9 -4
View File
@@ -15,7 +15,12 @@ func _exit_tree() -> void:
func get_GP_for_lesson(lesson_nb: int) -> Array:
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb <= ?", [lesson_nb])
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb == ?", [lesson_nb])
return db.query_result
func get_GP_before_lesson(lesson_nb: int) -> Array:
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb < ?", [lesson_nb])
return db.query_result
@@ -31,7 +36,7 @@ func get_words_containing_grapheme(grapheme: String) -> Array:
# Import data from previous Kalulu version
func _import_gps(db) -> void:
func _import_gps() -> void:
var file = FileAccess.open("res://data3/gp_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
@@ -44,7 +49,7 @@ func _import_gps(db) -> void:
print(db.query_result)
func _import_words(db) -> void:
func _import_words() -> void:
var file = FileAccess.open("res://data3/words_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
@@ -67,7 +72,7 @@ func _import_words(db) -> void:
})
func _import_lessons(db) -> void:
func _import_lessons() -> void:
var file = FileAccess.open("res://data3/gp_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():