From e1478cb88dc3aa1c6097a92279deca0fc4d090d1 Mon Sep 17 00:00:00 2001 From: Carolus Bramnatyo Seno Mahesworo Date: Mon, 1 Dec 2025 15:47:09 +0700 Subject: [PATCH] feat: make a feature for leaderboard --- src/game/firstperson.html | 2 +- src/js/firstperson.js | 30 +----------------------------- src/js/soal.js | 29 +++++++++++++++++++++++++++++ src/leaderboard.php | 25 ++++++++++++++----------- 4 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/game/firstperson.html b/src/game/firstperson.html index 4902153..89ad2ae 100644 --- a/src/game/firstperson.html +++ b/src/game/firstperson.html @@ -24,6 +24,6 @@ - + \ No newline at end of file diff --git a/src/js/firstperson.js b/src/js/firstperson.js index eeaf632..551dd26 100644 --- a/src/js/firstperson.js +++ b/src/js/firstperson.js @@ -1,32 +1,4 @@ -const questions = [ - { - question: "what is Python ?", - answers: [ - {text: "Programming Lang", correct: true}, - {text: "Animal", correct: false}, - {text: "Danger", correct: false}, - {text: "All Answer Correct", correct: false}, - ] - }, - { - question: "Data type at python ?", - answers: [ - {text: "Docx", correct: false}, - {text: "CSV", correct: false}, - {text: "String", correct: true}, - {text: "SQL", correct: false}, - ] - }, - { - question: "Index at python start from ?", - answers: [ - {text: "1", correct: false}, - {text: "-1", correct: false}, - {text: "10", correct: false}, - {text: "0", correct: true}, - ] - }, -]; +import { questions } from "./soal.js"; const questionElement = document.getElementById("question") const answerBtn = document.getElementById("btn-answer") diff --git a/src/js/soal.js b/src/js/soal.js index e69de29..b0e1aaf 100644 --- a/src/js/soal.js +++ b/src/js/soal.js @@ -0,0 +1,29 @@ +export const questions = [ + { + question: "what is Python ?", + answers: [ + {text: "Programming Lang", correct: true}, + {text: "Animal", correct: false}, + {text: "Danger", correct: false}, + {text: "All Answer Correct", correct: false}, + ] + }, + { + question: "Data type at python ?", + answers: [ + {text: "Docx", correct: false}, + {text: "CSV", correct: false}, + {text: "String", correct: true}, + {text: "SQL", correct: false}, + ] + }, + { + question: "Index at python start from ?", + answers: [ + {text: "1", correct: false}, + {text: "-1", correct: false}, + {text: "10", correct: false}, + {text: "0", correct: true}, + ] + }, +]; \ No newline at end of file diff --git a/src/leaderboard.php b/src/leaderboard.php index dccc690..5aa82e3 100644 --- a/src/leaderboard.php +++ b/src/leaderboard.php @@ -1,4 +1,7 @@ -0){ $score = $row['score']; } +$queryrank = "SELECT COUNT(*) as ranking FROM users WHERE score > $score"; +$resultrank = mysqli_query($db, $queryrank); +$rowrank = mysqli_fetch_assoc($resultrank); +$realrank = $rowrank['ranking']+1; $result = mysqli_query($db, $sql); $leaderboard = []; @@ -80,19 +87,15 @@ if($result){ ?> - - - - - - +
+ + + + - +
PTS PTS