diff --git a/admin/includes/leaderboard_functions.php b/admin/includes/leaderboard_functions.php
new file mode 100644
index 0000000..7f32709
--- /dev/null
+++ b/admin/includes/leaderboard_functions.php
@@ -0,0 +1,32 @@
+prepare($sql);
+ $stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+?>
\ No newline at end of file
diff --git a/admin/includes/missions_functions.php b/admin/includes/missions_functions.php
new file mode 100644
index 0000000..90ec3d6
--- /dev/null
+++ b/admin/includes/missions_functions.php
@@ -0,0 +1,44 @@
+prepare("SELECT * FROM missions ORDER BY id DESC");
+ $stmt->execute();
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+
+function get_mission_by_id($id) {
+ $db = db_connect();
+ $stmt = $db->prepare("SELECT * FROM missions WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetch(PDO::FETCH_ASSOC);
+}
+
+function add_mission($title, $description) {
+ $db = db_connect();
+ $stmt = $db->prepare("INSERT INTO missions (title, description) VALUES (:title, :description)");
+ $stmt->bindParam(':title', $title, PDO::PARAM_STR);
+ $stmt->bindParam(':description', $description, PDO::PARAM_STR);
+ return $stmt->execute();
+}
+
+function update_mission($id, $title, $description) {
+ $db = db_connect();
+ $stmt = $db->prepare("UPDATE missions SET title = :title, description = :description WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->bindParam(':title', $title, PDO::PARAM_STR);
+ $stmt->bindParam(':description', $description, PDO::PARAM_STR);
+ return $stmt->execute();
+}
+
+function delete_mission($id) {
+ $db = db_connect();
+ $stmt = $db->prepare("DELETE FROM missions WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ return $stmt->execute();
+}
+
diff --git a/admin/includes/questions_functions.php b/admin/includes/questions_functions.php
new file mode 100644
index 0000000..3761d9d
--- /dev/null
+++ b/admin/includes/questions_functions.php
@@ -0,0 +1,151 @@
+prepare("SELECT name FROM quiz_categories WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetch(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Fetches all questions for a given quiz ID.
+ *
+ * @param int $quiz_id The ID of the quiz category.
+ * @return array An array of questions.
+ */
+function get_questions_by_quiz_id($quiz_id) {
+ $db = db_connect();
+ $stmt = $db->prepare("SELECT * FROM questions WHERE category_id = :quiz_id ORDER BY id ASC");
+ $stmt->bindParam(':quiz_id', $quiz_id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Fetches all answers for a given question ID.
+ *
+ * @param int $question_id The ID of the question.
+ * @return array An array of answers.
+ */
+function get_answers_by_question_id($question_id) {
+ $db = db_connect();
+ $stmt = $db->prepare("SELECT * FROM answers WHERE question_id = :question_id ORDER BY id ASC");
+ $stmt->bindParam(':question_id', $question_id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Deletes a question and its associated answers.
+ *
+ * @param int $id The ID of the question to delete.
+ * @return bool True on success, false on failure.
+ */
+function delete_question($id) {
+ $db = db_connect();
+ // The database should handle answer deletion via ON DELETE CASCADE foreign key
+ $stmt = $db->prepare("DELETE FROM questions WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ return $stmt->execute();
+}
+
+/**
+ * Adds a new question and its answers to the database.
+ *
+ * @param int $quiz_id The ID of the quiz category.
+ * @param string $question_text The text of the question.
+ * @param array $answers An array of answers, where each answer is an array with 'text' and 'is_correct' keys.
+ * @return bool True on success, false on failure.
+ */
+function add_question($quiz_id, $question_text, $answers) {
+ $db = db_connect();
+ try {
+ $db->beginTransaction();
+
+ // Insert the question
+ $stmt = $db->prepare("INSERT INTO questions (category_id, question_text) VALUES (:quiz_id, :question_text)");
+ $stmt->bindParam(':quiz_id', $quiz_id, PDO::PARAM_INT);
+ $stmt->bindParam(':question_text', $question_text, PDO::PARAM_STR);
+ $stmt->execute();
+ $question_id = $db->lastInsertId();
+
+ // Insert the answers
+ $stmt = $db->prepare("INSERT INTO answers (question_id, answer_text, is_correct) VALUES (:question_id, :answer_text, :is_correct)");
+ foreach ($answers as $answer) {
+ $stmt->bindParam(':question_id', $question_id, PDO::PARAM_INT);
+ $stmt->bindParam(':answer_text', $answer['text'], PDO::PARAM_STR);
+ $stmt->bindParam(':is_correct', $answer['is_correct'], PDO::PARAM_BOOL);
+ $stmt->execute();
+ }
+
+ $db->commit();
+ return true;
+ } catch (Exception $e) {
+ $db->rollBack();
+ return false;
+ }
+}
+
+/**
+ * Fetches a single question by its ID for editing.
+ *
+ * @param int $id The ID of the question.
+ * @return array|false The question data or false if not found.
+ */
+function get_question($id) {
+ $db = db_connect();
+ $stmt = $db->prepare("SELECT * FROM questions WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetch(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Updates a question and its answers.
+ *
+ * @param int $question_id The ID of the question to update.
+ * @param string $question_text The new text of the question.
+ * @param array $answers An array of answers to update/insert.
+ * @return bool
+ */
+function update_question($question_id, $question_text, $answers) {
+ $db = db_connect();
+ try {
+ $db->beginTransaction();
+
+ // Update question text
+ $stmt = $db->prepare("UPDATE questions SET question_text = :question_text WHERE id = :id");
+ $stmt->bindParam(':question_text', $question_text, PDO::PARAM_STR);
+ $stmt->bindParam(':id', $question_id, PDO::PARAM_INT);
+ $stmt->execute();
+
+ // Delete old answers
+ $stmt = $db->prepare("DELETE FROM answers WHERE question_id = :question_id");
+ $stmt->bindParam(':question_id', $question_id, PDO::PARAM_INT);
+ $stmt->execute();
+
+ // Insert new answers
+ $stmt = $db->prepare("INSERT INTO answers (question_id, answer_text, is_correct) VALUES (:question_id, :answer_text, :is_correct)");
+ foreach ($answers as $answer) {
+ $stmt->bindParam(':question_id', $question_id, PDO::PARAM_INT);
+ $stmt->bindParam(':answer_text', $answer['text'], PDO::PARAM_STR);
+ $stmt->bindParam(':is_correct', $answer['is_correct'], PDO::PARAM_BOOL);
+ $stmt->execute();
+ }
+
+ $db->commit();
+ return true;
+ } catch (Exception $e) {
+ $db->rollBack();
+ return false;
+ }
+}
+?>
\ No newline at end of file
diff --git a/admin/includes/quizzes_functions.php b/admin/includes/quizzes_functions.php
new file mode 100644
index 0000000..44ae801
--- /dev/null
+++ b/admin/includes/quizzes_functions.php
@@ -0,0 +1,75 @@
+prepare("SELECT * FROM quiz_categories ORDER BY name ASC");
+ $stmt->execute();
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Fetches a single quiz category by its ID.
+ *
+ * @param int $id The ID of the category.
+ * @return array|false The category data or false if not found.
+ */
+function get_quiz_category_by_id($id) {
+ $db = db_connect();
+ $stmt = $db->prepare("SELECT * FROM quiz_categories WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetch(PDO::FETCH_ASSOC);
+}
+
+/**
+ * Adds a new quiz category to the database.
+ *
+ * @param string $name The name of the category.
+ * @param string $description The description of the category.
+ * @return bool True on success, false on failure.
+ */
+function add_quiz_category($name, $description) {
+ $db = db_connect();
+ $stmt = $db->prepare("INSERT INTO quiz_categories (name, description) VALUES (:name, :description)");
+ $stmt->bindParam(':name', $name, PDO::PARAM_STR);
+ $stmt->bindParam(':description', $description, PDO::PARAM_STR);
+ return $stmt->execute();
+}
+
+/**
+ * Updates an existing quiz category.
+ *
+ * @param int $id The ID of the category to update.
+ * @param string $name The new name.
+ * @param string $description The new description.
+ * @return bool True on success, false on failure.
+ */
+function update_quiz_category($id, $name, $description) {
+ $db = db_connect();
+ $stmt = $db->prepare("UPDATE quiz_categories SET name = :name, description = :description WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->bindParam(':name', $name, PDO::PARAM_STR);
+ $stmt->bindParam(':description', $description, PDO::PARAM_STR);
+ return $stmt->execute();
+}
+
+/**
+ * Deletes a quiz category from the database.
+ *
+ * @param int $id The ID of the category to delete.
+ * @return bool True on success, false on failure.
+ */
+function delete_quiz_category($id) {
+ $db = db_connect();
+ $stmt = $db->prepare("DELETE FROM quiz_categories WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ return $stmt->execute();
+}
+
+?>
\ No newline at end of file
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..e311bdf
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,49 @@
+Content file not found for this page.";
+}
+
+
+// --- Include Footer ---
+include __DIR__ . '/partials/footer.php';
+
+?>
\ No newline at end of file
diff --git a/admin/pages/leaderboard.php b/admin/pages/leaderboard.php
new file mode 100644
index 0000000..e12addf
--- /dev/null
+++ b/admin/pages/leaderboard.php
@@ -0,0 +1,39 @@
+
+
+
+
Leaderboard
+
+
+
+
+
+
+
Giocatore
+
Categoria
+
Punteggio
+
Data
+
+
+
+
+
+
Nessun risultato trovato.
+
+
+
+
+
+
+
/
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/pages/missions.php b/admin/pages/missions.php
new file mode 100644
index 0000000..8c5ff2f
--- /dev/null
+++ b/admin/pages/missions.php
@@ -0,0 +1,116 @@
+
+
+
+
\ No newline at end of file
diff --git a/admin/pages/quizzes.php b/admin/pages/quizzes.php
new file mode 100644
index 0000000..bcf196f
--- /dev/null
+++ b/admin/pages/quizzes.php
@@ -0,0 +1,120 @@
+
+
+