diff --git a/functions.php b/functions.php index 63e2d1a..a584dce 100644 --- a/functions.php +++ b/functions.php @@ -1,6 +1,7 @@ get_json_params(); + + $datas['level_post_id'] = lhoist_convert_post_id($datas['level_post_id']); + $datas['level_name'] = html_entity_decode(get_the_title($datas['level_post_id']), ENT_QUOTES, 'UTF-8'); + $cleanDatas = lhoist_sanitize_statistic_datas($datas); lhoist_check_statistics_datas_formats($cleanDatas); global $wpdb; - $datetime = new DateTime("now", new DateTimeZone('Europe/Brussels')); - $gameStats = array( - 'session_ID' => "qsdqsdqsdqsd", - 'user_locale' => "FR", - 'user_country' => "France", - 'level_post_id' => 43, - 'level_is_completed' => $level_is_completed ?? "0", - 'level_completion_time' => 200, - 'level_score' => 3, - 'date' => $datetime->format('Y-m-d H:i:s'), - ); $table_name = 'wp_app_users_statistics'; $result_check = $wpdb->insert( $table_name, diff --git a/includes/statistics-page.php b/includes/statistics-page.php index 62d0af3..2958257 100644 --- a/includes/statistics-page.php +++ b/includes/statistics-page.php @@ -75,7 +75,7 @@ function generate_pdf_from_html($html_content, $filename = 'export.pdf') $pdf->SetKeywords('Keywords'); // Définir l'en-tête et le pied de page - $pdf->setHeaderData('', PDF_HEADER_LOGO_WIDTH, 'Title', 'Header text'); + $pdf->setHeaderData('', PDF_HEADER_LOGO_WIDTH, 'Statistiques de jeu ', 'Lhoist Stay safe'); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // Définir la police @@ -133,7 +133,8 @@ function export_data_to_csv() // Écrire les données dans le fichier CSV foreach ($data as $row) { - $row["level_completion_time"] = $row["level_completion_time"] / 100; + // $row["level_completion_time"] = $row["level_completion_time"] / 100; + fputcsv($file, $row); } diff --git a/template-parts/statistics/game-print-stats.php b/template-parts/statistics/game-print-stats.php index f3ed5a7..4141725 100644 --- a/template-parts/statistics/game-print-stats.php +++ b/template-parts/statistics/game-print-stats.php @@ -45,6 +45,11 @@ $level_post_ids = $wpdb->get_col(" FROM $table_name WHERE level_post_id = $level_post_id "); + $average_level_time = $wpdb->get_var(" + SELECT AVG(level_completion_time) as average + FROM $table_name + WHERE level_post_id = $level_post_id + "); $completeLevelsScores = $wpdb->get_results(" SELECT level_score FROM $table_name @@ -62,13 +67,20 @@ $level_post_ids = $wpdb->get_col("
+ a 15.9155 15.9155 0 0 1 0 31.831 + a 15.9155 15.9155 0 0 1 0 -31.831" />

+

Temps moyen

+ +
+

secondes

+ +
+
@@ -92,7 +104,7 @@ $level_post_ids = $wpdb->get_col("

Répartition des langues