log responses
This commit is contained in:
@@ -14,7 +14,7 @@ const blank_class: = preload("res://sources/minigames/ants/blank.tscn")
|
||||
const ant_class: = preload("res://sources/minigames/ants/ant.tscn")
|
||||
const word_class: = preload("res://sources/minigames/ants/word.tscn")
|
||||
|
||||
var current_sentence: String
|
||||
var current_sentence: Dictionary
|
||||
var answersed: = []
|
||||
var answers: = []
|
||||
|
||||
@@ -28,7 +28,7 @@ func _find_stimuli_and_distractions() -> void:
|
||||
max_progression = min(max_progression, sentences_list.size())
|
||||
|
||||
for i in max_progression:
|
||||
var stimulus: String = sentences_list[i].Sentence
|
||||
var stimulus: Dictionary = sentences_list[i]
|
||||
stimuli.append(stimulus)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func _next_sentence() -> void:
|
||||
await get_tree().process_frame
|
||||
|
||||
current_sentence = stimuli.pop_front()
|
||||
var current_words: = current_sentence.split(" ")
|
||||
var current_words: = Database.get_words_in_sentence(current_sentence.ID)
|
||||
|
||||
var number_of_blanks: int = maxi(2, mini(difficulty, current_words.size()))
|
||||
var blanks: = range(current_words.size())
|
||||
@@ -67,9 +67,14 @@ func _next_sentence() -> void:
|
||||
answers = []
|
||||
answersed = []
|
||||
for i in range(current_words.size()):
|
||||
var current_word: Dictionary
|
||||
for word in current_words:
|
||||
if word.Position == i:
|
||||
current_word = word
|
||||
break
|
||||
if i in blanks:
|
||||
var blank: = blank_class.instantiate()
|
||||
blank.stimulus = current_words[i]
|
||||
blank.stimulus = current_word
|
||||
sentence.add_child(blank)
|
||||
|
||||
var ant: = ant_class.instantiate()
|
||||
@@ -79,7 +84,7 @@ func _next_sentence() -> void:
|
||||
var word: = word_class.instantiate()
|
||||
words.add_child(word)
|
||||
|
||||
word.stimulus = current_words[i]
|
||||
word.stimulus = current_word
|
||||
word.current_anchor = ant
|
||||
|
||||
answersed.append(false)
|
||||
@@ -91,7 +96,7 @@ func _next_sentence() -> void:
|
||||
var label: = Label.new()
|
||||
sentence.add_child(label)
|
||||
|
||||
label.text = current_words[i] + " "
|
||||
label.text = current_word.Word + " "
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.set("theme_override_font_sizes/font_size", 72)
|
||||
@@ -124,8 +129,10 @@ func _on_current_progression_changed() -> void:
|
||||
_win()
|
||||
|
||||
|
||||
func _on_word_answer(answer: bool, word: TextureButton) -> void:
|
||||
answers[word.get_index()] = answer
|
||||
func _on_word_answer(stimulus: Dictionary, expected_stimulus: Dictionary, word: TextureButton) -> void:
|
||||
_log_new_response(stimulus, expected_stimulus)
|
||||
|
||||
answers[word.get_index()] = stimulus == expected_stimulus
|
||||
answersed[word.get_index()] = true
|
||||
|
||||
var all_answered: = true
|
||||
|
||||
@@ -6,7 +6,7 @@ const images: = [
|
||||
"res://assets/minigames/ants/graphics/hole_04.png",
|
||||
]
|
||||
|
||||
var stimulus: String
|
||||
var stimulus: Dictionary
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
@@ -8,7 +8,7 @@ signal no_answer()
|
||||
@onready var right_fx: = $RightFX
|
||||
@onready var wrong_fx: = $WrongFX
|
||||
|
||||
var stimulus: String:
|
||||
var stimulus: Dictionary:
|
||||
set = _set_stimulus
|
||||
var follow_mouse: = false
|
||||
var current_anchor: CanvasItem
|
||||
@@ -34,10 +34,10 @@ func _process(_delta: float) -> void:
|
||||
global_position = current_anchor.global_position
|
||||
|
||||
|
||||
func _set_stimulus(value: String) -> void:
|
||||
func _set_stimulus(value: Dictionary) -> void:
|
||||
stimulus = value
|
||||
|
||||
label.text = stimulus
|
||||
label.text = stimulus.Word
|
||||
|
||||
|
||||
func _on_button_down() -> void:
|
||||
@@ -62,4 +62,4 @@ func _on_button_up() -> void:
|
||||
if destination is Area2D:
|
||||
no_answer.emit()
|
||||
else:
|
||||
answer.emit(stimulus == destination.stimulus)
|
||||
answer.emit(stimulus, destination.stimulus)
|
||||
|
||||
@@ -170,13 +170,11 @@ func _reset_logs() -> void:
|
||||
}
|
||||
|
||||
|
||||
func _log_new_response(response: Dictionary, awaited_response: Dictionary, all_stimuli: Array[Dictionary], all_distractors: Array[Dictionary]) -> void:
|
||||
func _log_new_response(response: Dictionary, current_stimulus: Dictionary) -> void:
|
||||
var response_log: = {
|
||||
"reponse": response,
|
||||
"awaited_response": awaited_response,
|
||||
"all_stimuli": all_stimuli,
|
||||
"all_distractors": all_distractors,
|
||||
"is_right": response == awaited_response,
|
||||
"awaited_response": current_stimulus,
|
||||
"is_right": response == current_stimulus,
|
||||
"minigame": minigame_name,
|
||||
"number_of_hints": current_number_of_hints,
|
||||
"current_progression": current_progression,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
extends Minigame
|
||||
|
||||
@export var difficulty: = 1
|
||||
@export var lesson_nb: = 4
|
||||
@export var lesson_nb: = 15
|
||||
|
||||
const hole_class: = preload("res://sources/minigames/crabs/hole/hole.tscn")
|
||||
const difficulty_settings: = {
|
||||
@@ -55,22 +55,28 @@ func _setup_minigame() -> void:
|
||||
holes.append(hole)
|
||||
|
||||
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
stimuli = Database.get_GP_for_lesson(lesson_nb, true)
|
||||
distractions = Database.get_GP_before_lesson(lesson_nb, true)
|
||||
var all_distractions: = Database.get_GP_before_lesson(lesson_nb, true)
|
||||
all_distractions.shuffle()
|
||||
|
||||
var number_of_distractions: int = min((max_progression - 1) / 2, all_distractions.size())
|
||||
var current_distractions: = all_distractions.slice(0, number_of_distractions)
|
||||
|
||||
stimuli.append_array(current_distractions)
|
||||
distractions = stimuli.duplicate()
|
||||
|
||||
|
||||
# Launch the minigame
|
||||
func _start() -> void:
|
||||
super()
|
||||
|
||||
_on_hole_timer_timeout(stimuli[0])
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimuli[0].Phoneme)
|
||||
_on_hole_timer_timeout(stimuli[current_progression % stimuli.size()])
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimuli[current_progression % stimuli.size()].Phoneme)
|
||||
audio_player.play()
|
||||
|
||||
for i in range(int(3.0 * holes.size() / 4.0)):
|
||||
_on_hole_crab_despawned(distractions[randi() % distractions.size()])
|
||||
_on_hole_crab_despawned(stimuli[randi() % stimuli.size()])
|
||||
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
|
||||
@@ -79,14 +85,15 @@ func _start() -> void:
|
||||
|
||||
|
||||
func _on_hole_stimulus_hit(stimulus: Dictionary, hole: Node2D) -> void:
|
||||
if stimulus in stimuli:
|
||||
await hole.right()
|
||||
_log_new_response(stimulus, stimuli[current_progression % stimuli.size()])
|
||||
if stimulus == stimuli[current_progression % stimuli.size()]:
|
||||
hole.right()
|
||||
current_progression += 1
|
||||
else:
|
||||
await hole.wrong()
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimulus.Phoneme)
|
||||
audio_player.play()
|
||||
hole.wrong()
|
||||
current_lives -= 1
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimulus.Phoneme)
|
||||
audio_player.play()
|
||||
|
||||
|
||||
func _on_hole_crab_despawned(stimulus: Dictionary) -> void:
|
||||
@@ -103,7 +110,7 @@ func _on_hole_timer_timeout(stimulus: Dictionary) -> void:
|
||||
while not hole_found:
|
||||
for i in holes_range:
|
||||
if not holes[i].crab:
|
||||
holes[i].spawn_crab(stimulus)
|
||||
holes[i].spawn_crab(stimuli[randi() % stimuli.size()])
|
||||
hole_found = true
|
||||
|
||||
break
|
||||
|
||||
@@ -76,13 +76,11 @@ func is_button_pressed_with_limit(future):
|
||||
|
||||
|
||||
func right() -> void:
|
||||
if is_instance_valid(crab):
|
||||
await crab.right()
|
||||
await crab.right()
|
||||
|
||||
|
||||
func wrong() -> void:
|
||||
if is_instance_valid(crab):
|
||||
await crab.wrong()
|
||||
await crab.wrong()
|
||||
|
||||
|
||||
func _on_crab_hit(stimulus: Dictionary) -> void:
|
||||
|
||||
@@ -123,6 +123,8 @@ func _on_track_lilypad_in_center(lilypad: Control, track: Control) -> void:
|
||||
frog.jump_to(lilypad.global_position)
|
||||
await frog.jumped
|
||||
|
||||
_log_new_response(lilypad.stimulus, track.stimuli[0])
|
||||
|
||||
if lilypad.is_distractor:
|
||||
await lilypad.wrong()
|
||||
|
||||
|
||||
@@ -33,14 +33,21 @@ var blocking_jellyfish: Array[Control] = []
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
stimuli = Database.get_GP_for_lesson(lesson_nb, true)
|
||||
distractions = Database.get_GP_before_lesson(lesson_nb, true)
|
||||
var all_distractions: = Database.get_GP_before_lesson(lesson_nb, true)
|
||||
all_distractions.shuffle()
|
||||
|
||||
var number_of_distractions: int = min((max_progression - 1) / 2, all_distractions.size())
|
||||
var current_distractions: = all_distractions.slice(0, number_of_distractions)
|
||||
|
||||
stimuli.append_array(current_distractions)
|
||||
distractions = stimuli.duplicate()
|
||||
|
||||
|
||||
# Launch the minigame
|
||||
func _start() -> void:
|
||||
super()
|
||||
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimuli[0].Phoneme)
|
||||
audio_player.stream = Database.get_audio_stream_for_phoneme(stimuli[current_progression % stimuli.size()].Phoneme)
|
||||
audio_player.play()
|
||||
spawn_timer.start()
|
||||
|
||||
@@ -67,7 +74,7 @@ func _spawn() -> void:
|
||||
var new_jellyfish: = jellyfish_scene.instantiate()
|
||||
spawning_space.add_child(new_jellyfish)
|
||||
var is_stimulus: = randf() < _get_difficulty_settings().stimuli_ratio
|
||||
new_jellyfish.stimulus = stimuli[0] if is_stimulus else distractions[randi() % distractions.size()]
|
||||
new_jellyfish.stimulus = stimuli[current_progression % stimuli.size()] if is_stimulus else stimuli[randi() % stimuli.size()]
|
||||
var permitted_range: = 0
|
||||
var left_border: = 0
|
||||
# blocking jellyfish is supposed to be ordered
|
||||
@@ -104,6 +111,7 @@ func _spawn() -> void:
|
||||
|
||||
func _on_jellyfish_pressed(jellyfish: Control) -> void:
|
||||
# already clicked
|
||||
_log_new_response(jellyfish.stimulus, stimuli[current_progression % stimuli.size()])
|
||||
if jellyfish.get_parent() != spawning_space:
|
||||
return
|
||||
var jellyfish_position: = jellyfish.global_position
|
||||
@@ -111,7 +119,7 @@ func _on_jellyfish_pressed(jellyfish: Control) -> void:
|
||||
spawning_space.add_sibling(jellyfish)
|
||||
jellyfish.global_position = jellyfish_position
|
||||
var is_right: = false
|
||||
if jellyfish.stimulus in stimuli:
|
||||
if jellyfish.stimulus == stimuli[current_progression % stimuli.size()]:
|
||||
is_right = true
|
||||
jellyfish.happy()
|
||||
jellyfish.right()
|
||||
|
||||
@@ -235,6 +235,8 @@ func _on_wrong_coconut(coconut: Node2D, monkey: Monkey) -> void:
|
||||
|
||||
|
||||
func monkey_throw_to_king(monkey: Monkey) -> void:
|
||||
_log_new_response(monkey.stimulus, stimuli[current_progression])
|
||||
|
||||
lock()
|
||||
var coconut: = await _get_coconut_from_monkey_to_king(monkey)
|
||||
|
||||
|
||||
@@ -165,6 +165,13 @@ func get_sentences() -> Array[Dictionary]:
|
||||
return db.query_result
|
||||
|
||||
|
||||
func get_words_in_sentence(sentence_id: int) -> Array[Dictionary]:
|
||||
db.query_with_bindings("SELECT * FROM WordsInSentences
|
||||
INNER JOIN Words ON Words.ID = WordsInSentences.WordID
|
||||
WHERE SentenceID = ?", [sentence_id])
|
||||
return db.query_result
|
||||
|
||||
|
||||
func get_lessons_count() -> int:
|
||||
db.query("SELECT MAX(Lessons.LessonNb) as i FROM Lessons")
|
||||
return db.query_result[0].i
|
||||
|
||||
Reference in New Issue
Block a user