Skip to content
Snippets Groups Projects
Commit 01254281 authored by quentin.fasler's avatar quentin.fasler
Browse files

readme

parent d54bef60
No related branches found
No related tags found
No related merge requests found
# Mini projet Spring boot "TP-QUIZ"
# Spring boot "TP-QUIZ"
## Configuration du projet
......@@ -6,31 +6,16 @@ Le projet utilise les ressources suivantes situées dans le répertoire `src/mai
- `docker-compose.yml` : Ce fichier permet de lancer deux conteneurs Docker, l'un pour MariaDB et l'autre pour phpMyAdmin.
- `quiz.sql` : Ce fichier contient le script SQL pour créer la BDD.
- `application.properties` : Ce fichier contient la configuration de Spring Boot .
- spring.datasource.* => Configuration pour la connexion a la BDD
- server.servlet.context-path => permet de préfixe les routes par "/api"
## Lancer le projet
### Exécution de Docker Compose
1. Exécutez la commande suivante pour démarrer les conteneurs MariaDB et phpMyAdmin :
```bash
docker-compose up
```
2. Une fois les conteneurs démarrés, accédez à phpMyAdmin en ouvrant votre navigateur web et en accédant à l'URL : `http://localhost:8081`. Utilisez les informations de connexion suivantes :
- Nom d'utilisateur : root
- Mot de passe : root
- hepia.oauth2.* => Configuration Oauth
3. Dans phpMyAdmin, importez le fichier `quiz.sql` pour créer votre schéma de base de données.
Avant de lancer ce projet il est important d'avoir déjà lancé les deux autres starter.
- Starter Oauth: https://gitedu.hesge.ch/repos.quentin.fasler/projet-semestre/starter-oauth
- Starter Quiz : https://gitedu.hesge.ch/repos.quentin.fasler/projet-semestre/starter-oauth
### Exécution de spring boot
......
spring.datasource.url=jdbc:mariadb://localhost:3307/quiz
spring.datasource.url=jdbc:mariadb://localhost:3308/quiz
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
......
......@@ -7,7 +7,7 @@ services:
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3307:3306
- 3308:3306
phpmyadmin:
image: phpmyadmin
......
CREATE TABLE IF NOT EXISTS categories (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL UNIQUE
);
INSERT INTO categories (name) VALUES
('Géographie'),
('Histoire'),
('Science'),
('Cinéma'),
('Musique'),
('Sport'),
('Informatique'),
('Cuisine'),
('Littérature'),
('Art');
CREATE TABLE IF NOT EXISTS questions (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
question_text TEXT NOT NULL,
category_id INTEGER NOT NULL,
FOREIGN KEY (category_id) REFERENCES categories (id)
);
CREATE TABLE IF NOT EXISTS answers (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
answer_text TEXT NOT NULL,
correct BOOLEAN DEFAULT FALSE,
question_id INTEGER NOT NULL,
FOREIGN KEY (question_id) REFERENCES questions (id)
);
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
firstname TEXT NOT NULL,
lastname TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
);
INSERT INTO questions (question_text, category_id)
VALUES
('Question 1', 1),
('Question 2', 2),
('Question 3', 3),
('Question 4', 1),
('Question 5', 2),
('Question 6', 3),
('Question 7', 1),
('Question 8', 2),
('Question 9', 3),
('Question 10', 1);
-- Insérer 30 réponses dans la table "answers" avec une réponse correcte par question
INSERT INTO answers (answer_text, correct, question_id)
VALUES
('Réponse 1 Question 1', TRUE, 1),
('Réponse 2 Question 1', FALSE, 1),
('Réponse 3 Question 1', FALSE, 1),
('Réponse 1 Question 2', FALSE, 2),
('Réponse 2 Question 2', TRUE, 2),
('Réponse 3 Question 2', FALSE, 2),
('Réponse 1 Question 3', FALSE, 3),
('Réponse 2 Question 3', FALSE, 3),
('Réponse 3 Question 3', TRUE, 3),
('Réponse 1 Question 4', TRUE, 4),
('Réponse 2 Question 4', FALSE, 4),
('Réponse 3 Question 4', FALSE, 4),
('Réponse 1 Question 5', FALSE, 5),
('Réponse 2 Question 5', TRUE, 5),
('Réponse 3 Question 5', FALSE, 5),
('Réponse 1 Question 6', FALSE, 6),
('Réponse 2 Question 6', FALSE, 6),
('Réponse 3 Question 6', TRUE, 6),
('Réponse 1 Question 7', TRUE, 7),
('Réponse 2 Question 7', FALSE, 7),
('Réponse 3 Question 7', FALSE, 7),
('Réponse 1 Question 8', FALSE, 8),
('Réponse 2 Question 8', TRUE, 8),
('Réponse 3 Question 8', FALSE, 8),
('Réponse 1 Question 9', FALSE, 9),
('Réponse 2 Question 9', FALSE, 9),
('Réponse 3 Question 9', TRUE, 9),
('Réponse 1 Question 10', TRUE, 10),
('Réponse 2 Question 10', FALSE, 10),
('Réponse 3 Question 10', FALSE, 10);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment