Compare commits
6 Commits
tp_servlet
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
529d3ef855 | ||
|
|
6f75f83f58 | ||
|
|
3f264c2a01 | ||
|
|
93224bb17d | ||
|
|
bc5a0e488d | ||
|
|
1139a6ec7e |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
/target/
|
|
||||||
/data/
|
|
||||||
62
README.md
62
README.md
@@ -1,60 +1,18 @@
|
|||||||
# TP1 et TP2_servlet
|
# TP TAA
|
||||||
|
|
||||||
## Demarrge
|
|
||||||
|
|
||||||
Optionnel : Reset la base de donné : ```rm -rd data/*```
|
## TP1 - TP2
|
||||||
|
|
||||||
lancer la base de donné : ```.\run-hsqldb-server.sh``` ou ```.\run-hsqldb-server.bat```
|
Le compte rendu pour le TP1 et TP2 partie servlet est dans la branche tp_servlet
|
||||||
|
|
||||||
run Maven : ```compile jetty:run``` ou ```mvn clean compile jetty:run```
|
Le compte rendu de la partie API Rest du TP2 est dans la branche tp_rest
|
||||||
|
|
||||||
## Graph metier
|
## TP3 - TP4
|
||||||
|
|
||||||
```mermaid
|
Le compte rendu des TP3 et TP4 est dans la branche tp_spring
|
||||||
classDiagram
|
|
||||||
Utilisateur "*" -- "*" Session
|
|
||||||
Session "*" -- "*" Quizz
|
|
||||||
Quizz "1" -- "1..*" Question
|
|
||||||
Utilisateur "1" -- "*" Quizz
|
|
||||||
Question "1" -- "1" Reponse
|
|
||||||
Reponse <|-- ReponseCourte
|
|
||||||
Reponse <|-- Choix
|
|
||||||
|
|
||||||
class Utilisateur {
|
## Auteurs
|
||||||
-id : int
|
|
||||||
-name : String
|
|
||||||
-sessions : List<Session>
|
|
||||||
-email : String
|
|
||||||
-password : String
|
|
||||||
-quizzs : List<Quizz>
|
|
||||||
}
|
|
||||||
class Session{
|
|
||||||
-id : int
|
|
||||||
-codePIN : int
|
|
||||||
-quizzs : List<Quizz>
|
|
||||||
-utilisateurs : List<Utilisateur>
|
|
||||||
-theme : String
|
|
||||||
}
|
|
||||||
class Quizz{
|
|
||||||
-sessions: List<Session>
|
|
||||||
-id : int
|
|
||||||
-createur : Utilisateur
|
|
||||||
-quizz : Quizz
|
|
||||||
}
|
|
||||||
class Reponse{
|
|
||||||
-id : int
|
|
||||||
-question: Question
|
|
||||||
-reponses : ArrayList<String>
|
|
||||||
}
|
|
||||||
class Choix{
|
|
||||||
-choix : ArrayList<String>
|
|
||||||
}
|
|
||||||
class ReponseCourte{
|
|
||||||
}
|
|
||||||
class Question{
|
|
||||||
-id : int
|
|
||||||
-enonce : String
|
|
||||||
-reponse : Reponse
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
- Tuan Minh VU
|
||||||
|
|
||||||
|
- Thibaut ROCHAS
|
||||||
|
|||||||
BIN
hsqldb-2.7.2.jar
BIN
hsqldb-2.7.2.jar
Binary file not shown.
102
pom.xml
102
pom.xml
@@ -1,102 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>test</groupId>
|
|
||||||
<packaging>war</packaging>
|
|
||||||
<artifactId>testjpa</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
<org.mapstruct.version>1.6.3</org.mapstruct.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct</artifactId>
|
|
||||||
<version>1.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-core</artifactId>
|
|
||||||
<version>6.2.7.Final</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.servlet</groupId>
|
|
||||||
<artifactId>jakarta.servlet-api</artifactId>
|
|
||||||
<version>5.0.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
<version>1.7.30</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hsqldb</groupId>
|
|
||||||
<artifactId>hsqldb</artifactId>
|
|
||||||
<version>2.7.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
<version>8.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.42</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin -->
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
|
||||||
<version>11.0.16</version>
|
|
||||||
<configuration>
|
|
||||||
<webApp>
|
|
||||||
<contextPath>/</contextPath>
|
|
||||||
</webApp>
|
|
||||||
<httpConnector>
|
|
||||||
<port>8080</port>
|
|
||||||
</httpConnector>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<version>3.4.0</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.11.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>11</source> <!-- depending on your project -->
|
|
||||||
<target>11</target> <!-- depending on your project -->
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.42</version>
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct-processor</artifactId>
|
|
||||||
<version>1.6.3</version>
|
|
||||||
</path>
|
|
||||||
<!-- other annotation processors -->
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
mkdir data
|
|
||||||
cd data
|
|
||||||
java -cp ..\hsqldb-2.7.2.jar org.hsqldb.Server
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
mvn dependency:copy-dependencies
|
|
||||||
mkdir data 2> /dev/null
|
|
||||||
cd data
|
|
||||||
java -cp ../target/dependency/hsqldb-2.7.2.jar org.hsqldb.Server
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
java -cp hsqldb-2.7.2.jar org.hsqldb.util.DatabaseManagerSwing --driver org.hsqldb.jdbcDriver --url jdbc:hsqldb:hsql://localhost/ --user SA
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#mvn dependency:copy-dependencies
|
|
||||||
java -cp hsqldb-2.7.2.jar org.hsqldb.util.DatabaseManagerSwing --driver org.hsqldb.jdbcDriver --url jdbc:hsqldb:hsql://localhost/ --user SA
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import jpa.EntityManagerHelper;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class AbstractJpaDao<K, T extends Serializable> implements IGenericDao<K, T> {
|
|
||||||
protected EntityManager em;
|
|
||||||
private Class<T> entityClass;
|
|
||||||
|
|
||||||
public AbstractJpaDao() {
|
|
||||||
this.em = EntityManagerHelper.getEntityManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Pour connaitre qu'on travaille avec quelle classe
|
|
||||||
public void setClass(Class<T> class2){
|
|
||||||
this.entityClass= class2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T findOne(K id) {
|
|
||||||
return em.find(entityClass, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> findAll() {
|
|
||||||
return em.createQuery("select e from " + entityClass.getName() + " as e", entityClass).getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
//CRUD
|
|
||||||
public void create(T entity){
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
em.persist(entity);
|
|
||||||
t.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public T findById(K id) {
|
|
||||||
return em.find(entityClass, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T update(T entity){
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
T T_sync = em.merge(entity);
|
|
||||||
t.commit();
|
|
||||||
return T_sync;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete(T entity){
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
em.remove(entity);
|
|
||||||
t.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteById(K id) {
|
|
||||||
T T_to_be_deleted = em.find(entityClass, id);
|
|
||||||
em.remove(T_to_be_deleted);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.EntityManagerFactory;
|
|
||||||
import jakarta.persistence.Persistence;
|
|
||||||
|
|
||||||
public class EntityManagerHelper {
|
|
||||||
|
|
||||||
private static final EntityManagerFactory emf;
|
|
||||||
private static final ThreadLocal<EntityManager> threadLocal;
|
|
||||||
|
|
||||||
static {
|
|
||||||
emf = Persistence.createEntityManagerFactory("dev");
|
|
||||||
threadLocal = new ThreadLocal<EntityManager>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityManager getEntityManager() {
|
|
||||||
EntityManager em = threadLocal.get();
|
|
||||||
|
|
||||||
if (em == null) {
|
|
||||||
em = emf.createEntityManager();
|
|
||||||
threadLocal.set(em);
|
|
||||||
}
|
|
||||||
return em;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void closeEntityManager() {
|
|
||||||
EntityManager em = threadLocal.get();
|
|
||||||
if (em != null) {
|
|
||||||
em.close();
|
|
||||||
threadLocal.set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void closeEntityManagerFactory() {
|
|
||||||
emf.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void beginTransaction() {
|
|
||||||
getEntityManager().getTransaction().begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rollback() {
|
|
||||||
getEntityManager().getTransaction().rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void commit() {
|
|
||||||
getEntityManager().getTransaction().commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IGenericDao<K, T extends Serializable> {
|
|
||||||
void create(final T entity);
|
|
||||||
T findById(final K id);
|
|
||||||
T update(final T entity);
|
|
||||||
void delete(final T entity);
|
|
||||||
void deleteById(final K id);
|
|
||||||
List<T> findAll();
|
|
||||||
T findOne(final K id);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import metier.Question;
|
|
||||||
|
|
||||||
public class QuestionDAO extends AbstractJpaDao<Integer, Question> {
|
|
||||||
public QuestionDAO(){
|
|
||||||
super();
|
|
||||||
this.setClass(Question.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import metier.Question;
|
|
||||||
import metier.Quizz;
|
|
||||||
|
|
||||||
public class QuizzDAO extends AbstractJpaDao<Integer, Quizz> {
|
|
||||||
public QuizzDAO(){
|
|
||||||
super();
|
|
||||||
this.setClass(Quizz.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteAllQuiz(){
|
|
||||||
EntityTransaction et= em.getTransaction();
|
|
||||||
et.begin();
|
|
||||||
em.createQuery("delete from Quizz").executeUpdate();
|
|
||||||
et.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addQuestion(Quizz quizz, Question question) {
|
|
||||||
System.out.println("ajout de question dans le quizz");
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
question.setQuizz(quizz);
|
|
||||||
quizz.getQuestions().add(question);
|
|
||||||
em.merge(quizz);
|
|
||||||
t.commit();
|
|
||||||
em.refresh(quizz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh(Quizz quizz) {
|
|
||||||
em.refresh(quizz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import metier.Question;
|
|
||||||
import metier.Reponse;
|
|
||||||
|
|
||||||
public class ReponseDAO extends AbstractJpaDao<Integer, Reponse> {
|
|
||||||
public ReponseDAO(){
|
|
||||||
super();
|
|
||||||
this.setClass(Reponse.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void addToQuestion(Reponse r, Question q) {
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
|
|
||||||
q.setReponse(r);
|
|
||||||
r.setQuestion(q);
|
|
||||||
em.merge(r);
|
|
||||||
t.commit();
|
|
||||||
em.refresh(q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import jakarta.persistence.Query;
|
|
||||||
import metier.Quizz;
|
|
||||||
import metier.Session;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SessionDAO extends AbstractJpaDao<Integer, Session> {
|
|
||||||
public SessionDAO() {
|
|
||||||
super();
|
|
||||||
this.setClass(Session.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Session> findByTheme(String theme){
|
|
||||||
Query query=em.createQuery("select s from Session s where s.theme=:theme");
|
|
||||||
query.setParameter("theme",theme);
|
|
||||||
List<Session> sessions=query.getResultList();
|
|
||||||
|
|
||||||
if(sessions.size()>0){
|
|
||||||
return sessions;
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh(Session session) {
|
|
||||||
em.refresh(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addQuizz(Quizz q, Session s) {
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
|
|
||||||
q.getSessions().add(s);
|
|
||||||
s.getQuizzs().add(q);
|
|
||||||
em.merge(s);
|
|
||||||
t.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package DAO;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import jakarta.persistence.Query;
|
|
||||||
import metier.Session;
|
|
||||||
import metier.Utilisateur;
|
|
||||||
|
|
||||||
public class UtilisateurDAO extends AbstractJpaDao<Integer, Utilisateur> {
|
|
||||||
public UtilisateurDAO() {
|
|
||||||
super();
|
|
||||||
this.setClass(Utilisateur.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Utilisateur findByEmail(String email){
|
|
||||||
EntityTransaction t=em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
Query query=em.createQuery("select u from Utilisateur u where u.email=:email");
|
|
||||||
query.setParameter("email",email);
|
|
||||||
Utilisateur u=(Utilisateur)query.getSingleResult();
|
|
||||||
t.commit();
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addToSession(int sessionId, int userId) {
|
|
||||||
EntityTransaction t = em.getTransaction();
|
|
||||||
t.begin();
|
|
||||||
Session s = em.find(Session.class, sessionId);
|
|
||||||
Utilisateur u = em.find(Utilisateur.class, userId);
|
|
||||||
|
|
||||||
//FAUT AJOUTER OWNING SIDE ( Ici u --> s)
|
|
||||||
u.getSessions().add(s);
|
|
||||||
//Jsp il faut birectionnelle ou pas?
|
|
||||||
s.getUtilisateurs().add(u);
|
|
||||||
em.merge(u);
|
|
||||||
t.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package DTO;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class QuestionDTO {
|
|
||||||
private int id;
|
|
||||||
private String question;
|
|
||||||
private List<String> reponses_string;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package DTO;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class QuizzDTO {
|
|
||||||
private int id;
|
|
||||||
private Integer sessionId;
|
|
||||||
private Integer utilisateurId;
|
|
||||||
private List<Integer> questionsId;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package DTO;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class SessionDTO {
|
|
||||||
private String theme;
|
|
||||||
private int codePIN;
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
private List<Integer> quizzsId;
|
|
||||||
private List<Integer> utilisateursId;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package DTO;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UtilisateurDTO {
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
private String email;
|
|
||||||
private String password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package Mapper;
|
|
||||||
|
|
||||||
import DTO.QuestionDTO;
|
|
||||||
import metier.Question;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
public interface QuestionMapper {
|
|
||||||
QuestionMapper INSTANCE = Mappers.getMapper( QuestionMapper.class );
|
|
||||||
|
|
||||||
QuestionDTO toDTO(Question question);
|
|
||||||
Question toEntity(QuestionDTO questionDTO);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package Mapper;
|
|
||||||
|
|
||||||
import DTO.QuizzDTO;
|
|
||||||
import metier.Quizz;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
public interface QuizzMapper {
|
|
||||||
QuizzMapper INSTANCE = Mappers.getMapper( QuizzMapper.class );
|
|
||||||
|
|
||||||
QuizzDTO toDTO(Quizz quizz);
|
|
||||||
Quizz toEntity(QuizzDTO quizzDTO);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package Mapper;
|
|
||||||
|
|
||||||
import DTO.SessionDTO;
|
|
||||||
import metier.Session;
|
|
||||||
import metier.Utilisateur;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
public interface SessionMapper {
|
|
||||||
SessionMapper INSTANCE = Mappers.getMapper( SessionMapper.class );
|
|
||||||
|
|
||||||
SessionDTO toDTO(Utilisateur utilisateur);
|
|
||||||
Session toEntity(SessionDTO sessionDTO);
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package Mapper;
|
|
||||||
|
|
||||||
import DTO.UtilisateurDTO;
|
|
||||||
import metier.Utilisateur;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface UtilisateurMapper {
|
|
||||||
UtilisateurMapper INSTANCE = Mappers.getMapper(UtilisateurMapper.class);
|
|
||||||
|
|
||||||
UtilisateurDTO toDTO(Utilisateur utilisateur);
|
|
||||||
Utilisateur toEntity(UtilisateurDTO dto);
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package jpa;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.EntityManagerFactory;
|
|
||||||
import jakarta.persistence.Persistence;
|
|
||||||
|
|
||||||
public class EntityManagerHelper {
|
|
||||||
|
|
||||||
private static final EntityManagerFactory emf;
|
|
||||||
private static final ThreadLocal<EntityManager> threadLocal;
|
|
||||||
|
|
||||||
static {
|
|
||||||
emf = Persistence.createEntityManagerFactory("dev");
|
|
||||||
threadLocal = new ThreadLocal<EntityManager>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityManager getEntityManager() {
|
|
||||||
EntityManager em = threadLocal.get();
|
|
||||||
|
|
||||||
if (em == null) {
|
|
||||||
em = emf.createEntityManager();
|
|
||||||
threadLocal.set(em);
|
|
||||||
}
|
|
||||||
return em;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void closeEntityManager() {
|
|
||||||
EntityManager em = threadLocal.get();
|
|
||||||
if (em != null) {
|
|
||||||
em.close();
|
|
||||||
threadLocal.set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void closeEntityManagerFactory() {
|
|
||||||
emf.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void beginTransaction() {
|
|
||||||
getEntityManager().getTransaction().begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rollback() {
|
|
||||||
getEntityManager().getTransaction().rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void commit() {
|
|
||||||
getEntityManager().getTransaction().commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
package jpa;
|
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.EntityTransaction;
|
|
||||||
import jakarta.persistence.criteria.*;
|
|
||||||
import metier.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JpaTest {
|
|
||||||
private EntityManager manager;
|
|
||||||
|
|
||||||
public JpaTest(EntityManager manager) {
|
|
||||||
this.manager = manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
EntityManager manager = EntityManagerHelper.getEntityManager();
|
|
||||||
|
|
||||||
JpaTest test = new JpaTest(manager);
|
|
||||||
|
|
||||||
EntityTransaction tx = manager.getTransaction();
|
|
||||||
tx.begin();
|
|
||||||
try {
|
|
||||||
test.create_user_test();
|
|
||||||
test.create_session_test();
|
|
||||||
test.create_quizz_test(1,1);
|
|
||||||
test.list_utilisateur();
|
|
||||||
test.list_session();
|
|
||||||
test.list_quizz();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
tx.commit();
|
|
||||||
|
|
||||||
manager.close();
|
|
||||||
EntityManagerHelper.closeEntityManagerFactory();
|
|
||||||
System.out.println(".. done");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void create_user_test() {
|
|
||||||
int numUser = manager.createQuery("SELECT u FROM Utilisateur u", Utilisateur.class).getResultList().size();
|
|
||||||
if (numUser == 0) {
|
|
||||||
//Utilisateur
|
|
||||||
Utilisateur utilisateur1 = new Utilisateur();
|
|
||||||
utilisateur1.setName("Titi");
|
|
||||||
utilisateur1.setEmail("titi@email.com");
|
|
||||||
utilisateur1.setPassword("123456");
|
|
||||||
|
|
||||||
Utilisateur utilisateur2 = new Utilisateur();
|
|
||||||
utilisateur2.setName("Toto");
|
|
||||||
|
|
||||||
manager.persist(utilisateur1);
|
|
||||||
manager.persist(utilisateur2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void create_session_test() {
|
|
||||||
int numUser = manager.createQuery("SELECT u FROM Session u", Session.class).getResultList().size();
|
|
||||||
if (numUser == 0) {
|
|
||||||
//Utilisateur
|
|
||||||
Session session1 = new Session();
|
|
||||||
session1.setCodePIN(1703);
|
|
||||||
session1.setTheme("Inphormatik");
|
|
||||||
session1.setQuizzs(new ArrayList<>());
|
|
||||||
|
|
||||||
List<Utilisateur> ulist = manager.createQuery("select user from Utilisateur user").getResultList();
|
|
||||||
session1.setUtilisateurs(ulist);
|
|
||||||
|
|
||||||
manager.persist(session1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void list_utilisateur() {
|
|
||||||
CriteriaBuilder criteriaBuilder = manager.getCriteriaBuilder();
|
|
||||||
CriteriaQuery<Utilisateur> query = criteriaBuilder.createQuery(Utilisateur.class);
|
|
||||||
Root<Utilisateur> from = query.from(Utilisateur.class);
|
|
||||||
query.select(from);
|
|
||||||
List<Utilisateur> result_utilisatuer_list = manager.createQuery(query).getResultList();
|
|
||||||
for (Utilisateur u : result_utilisatuer_list) {
|
|
||||||
System.out.println(u.getId() + " " + u.getName() + " " + u.getEmail());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void list_session() {
|
|
||||||
CriteriaBuilder criteriaBuilder = manager.getCriteriaBuilder();
|
|
||||||
CriteriaQuery<Session> query = criteriaBuilder.createQuery(Session.class);
|
|
||||||
Root<Session> from = query.from(Session.class);
|
|
||||||
query.select(from);
|
|
||||||
List<Session> result_session_list = manager.createQuery(query).getResultList();
|
|
||||||
for (Session s : result_session_list) {
|
|
||||||
System.out.println(s.getCodePIN() + " " + s.getTheme());
|
|
||||||
for (Utilisateur u : s.getUtilisateurs()) {
|
|
||||||
System.out.println(u.getId() + " " + u.getName() + " " + u.getEmail());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void create_quizz_test(int userId, int sessionId) {
|
|
||||||
|
|
||||||
CriteriaBuilder cb = manager.getCriteriaBuilder();
|
|
||||||
|
|
||||||
//GET USER
|
|
||||||
CriteriaQuery<Utilisateur> cqUser = cb.createQuery(Utilisateur.class);
|
|
||||||
Root<Utilisateur> userRoot = cqUser.from(Utilisateur.class);
|
|
||||||
cqUser.select(userRoot).where(cb.equal(userRoot.get("id"), userId));
|
|
||||||
Utilisateur u1 = manager.createQuery(cqUser).getSingleResult();
|
|
||||||
|
|
||||||
//GET SESSION
|
|
||||||
CriteriaQuery<Session> cqSess = cb.createQuery(Session.class);
|
|
||||||
Root<Session> sessRoot = cqSess.from(Session.class);
|
|
||||||
cqSess.select(sessRoot).where(cb.equal(sessRoot.get("id"), sessionId));
|
|
||||||
Session s1 = manager.createQuery(cqSess).getSingleResult();
|
|
||||||
|
|
||||||
List<Session> ls= u1.getSessions();
|
|
||||||
ls.add(s1);
|
|
||||||
u1.setSessions(ls);
|
|
||||||
Quizz quizz1 = new Quizz();
|
|
||||||
quizz1.setCreateur(u1);
|
|
||||||
quizz1.getSessions().add(s1);
|
|
||||||
|
|
||||||
manager.persist(quizz1);
|
|
||||||
manager.merge(u1);
|
|
||||||
manager.persist(s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void list_quizz() {
|
|
||||||
CriteriaBuilder cb = manager.getCriteriaBuilder();
|
|
||||||
CriteriaQuery<Quizz> cq = cb.createQuery(Quizz.class);
|
|
||||||
Root<Quizz> from = cq.from(Quizz.class);
|
|
||||||
|
|
||||||
List<Integer> sessionIds = new ArrayList<>();
|
|
||||||
sessionIds.add(1);
|
|
||||||
//https://www.w3schools.com/SQL/sql_join_inner.asp
|
|
||||||
//https://stackoverflow.com/questions/15990141/how-to-make-a-criteriabuilder-join-with-a-custom-on-condition
|
|
||||||
Join<Quizz, Session> sessionJoin = from.join("session", JoinType.INNER);
|
|
||||||
cq.select(from).where(sessionJoin.get("id").in(sessionIds));
|
|
||||||
|
|
||||||
List<Quizz> quizzs = manager.createQuery(cq).getResultList();
|
|
||||||
for (Quizz q : quizzs) {
|
|
||||||
System.out.println("Quizz ID: " + q.getId() + ", User: " + q.getCreateur().getName() +
|
|
||||||
", nb session: " + q.getSessions().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@PrimaryKeyJoinColumn(name = "Choix_Id")
|
|
||||||
public class Choix extends Reponse{
|
|
||||||
List<String> choix;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String valHTML(){
|
|
||||||
String res = "";
|
|
||||||
|
|
||||||
for (String val : this.choix) {
|
|
||||||
res+= val+"<br/>";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Question implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private int id;
|
|
||||||
private String enonce;
|
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
|
||||||
@JoinColumn(name ="bonne_reponse", referencedColumnName = "id")
|
|
||||||
private Reponse reponse;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name="id_quizz")
|
|
||||||
private Quizz quizz;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Quizz implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
@ManyToMany
|
|
||||||
private List<Session> sessions = new ArrayList<Session>();
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name="id_utilisateur")
|
|
||||||
private Utilisateur createur;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "quizz", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private List<Question> questions=new ArrayList<Question>();
|
|
||||||
|
|
||||||
public void addQuestion(Question question) {
|
|
||||||
this.questions.add(question);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Inheritance(strategy=InheritanceType.JOINED)
|
|
||||||
@DiscriminatorColumn(name="Type_reponse")
|
|
||||||
@DiscriminatorValue("Reponse")
|
|
||||||
public abstract class Reponse implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
@OneToOne
|
|
||||||
private Question question;
|
|
||||||
public List<String> reponses;
|
|
||||||
|
|
||||||
public String valHTML(){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@PrimaryKeyJoinColumn(name = "RC_Id")
|
|
||||||
public class ReponseCourte extends Reponse{
|
|
||||||
String value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String valHTML(){
|
|
||||||
return "TEXT INPUT<br/>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Session implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
@Column(unique=true)
|
|
||||||
private int codePIN;
|
|
||||||
|
|
||||||
@ManyToMany(mappedBy="sessions")
|
|
||||||
private List<Quizz> quizzs = new ArrayList<>();
|
|
||||||
|
|
||||||
@ManyToMany(mappedBy = "sessions")
|
|
||||||
private List<Utilisateur> utilisateurs = new ArrayList<>();
|
|
||||||
private String theme;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package metier;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Utilisateur implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Column(unique=true)
|
|
||||||
private String email;
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@ManyToMany
|
|
||||||
@JoinTable(
|
|
||||||
name="utilisateur_session",
|
|
||||||
joinColumns = @JoinColumn(name="utilisateur_id"),
|
|
||||||
inverseJoinColumns = @JoinColumn(name = "session_id")
|
|
||||||
)
|
|
||||||
private List<Session> sessions= new ArrayList<>();;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "createur")
|
|
||||||
private List<Quizz> quizzs;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
@WebServlet(name="mytest",
|
|
||||||
urlPatterns={"/myurl"})
|
|
||||||
public class MyServlet extends HttpServlet {
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
PrintWriter p = new PrintWriter(resp.getOutputStream());
|
|
||||||
p.print("Hello world");
|
|
||||||
p.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.doPost(req, resp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import DAO.*;
|
|
||||||
import metier.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
@WebServlet(name="question",
|
|
||||||
urlPatterns={"/QuestionInfo"})
|
|
||||||
public class QuestionInfo extends HttpServlet {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.getRequestDispatcher("/Question.html").forward(req, resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
QuizzDAO quizzDAO = new QuizzDAO();
|
|
||||||
QuestionDAO questionDAO = new QuestionDAO();
|
|
||||||
ReponseDAO reponseDAO = new ReponseDAO();
|
|
||||||
|
|
||||||
|
|
||||||
String ennonce = req.getParameter("question");
|
|
||||||
String type = req.getParameter("type");
|
|
||||||
String choixPossible = req.getParameter("choixPossible");
|
|
||||||
String reponse = req.getParameter("reponse");
|
|
||||||
String idQuizz = req.getParameter("idQuizz");
|
|
||||||
|
|
||||||
Quizz quizz = quizzDAO.findById(Integer.parseInt(idQuizz));
|
|
||||||
if(quizz==null){
|
|
||||||
resp.getWriter().println("<HTML>\n<BODY>\n" +
|
|
||||||
"<H1> Quizz non trouvable </H1>" +
|
|
||||||
"</BODY></HTML>");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
Question question = new Question();
|
|
||||||
question.setEnonce(ennonce);
|
|
||||||
|
|
||||||
List<String> listRep = Arrays.asList(reponse.split("\n"));
|
|
||||||
|
|
||||||
questionDAO.create(question);
|
|
||||||
|
|
||||||
if(type.equals("choix")){
|
|
||||||
Choix choix = new Choix();
|
|
||||||
//question.setReponse(choix);
|
|
||||||
List<String> listChoix = Arrays.asList(choixPossible.split("\n"));
|
|
||||||
choix.setChoix(listChoix);
|
|
||||||
choix.setReponses(listRep);
|
|
||||||
|
|
||||||
reponseDAO.create(choix);
|
|
||||||
reponseDAO.addToQuestion(choix, question);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (type.equals("courte")){
|
|
||||||
ReponseCourte reponseCourte = new ReponseCourte();
|
|
||||||
//question.setReponse(reponseCourte);
|
|
||||||
reponseCourte.setReponses(listRep);
|
|
||||||
|
|
||||||
reponseDAO.create(reponseCourte);
|
|
||||||
reponseDAO.addToQuestion(reponseCourte, question);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
resp.getWriter().println(
|
|
||||||
"<HTML>\n<BODY>\n" +
|
|
||||||
"<H1> Type de question non trouvé </H1>" +
|
|
||||||
"</BODY></HTML>"
|
|
||||||
);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
quizzDAO.addQuestion(quizz,question);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp.getWriter().println(
|
|
||||||
"<HTML>\n<BODY>\n" +
|
|
||||||
"<H1> Question \"" + question.getEnonce() + "\" creee </H1>" +
|
|
||||||
"</BODY></HTML>"
|
|
||||||
);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import DAO.QuizzDAO;
|
|
||||||
import DAO.UtilisateurDAO;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import metier.Quizz;
|
|
||||||
import metier.Utilisateur;
|
|
||||||
|
|
||||||
@WebServlet(name="quizz",
|
|
||||||
urlPatterns={"/QuizzInfo"})
|
|
||||||
public class QuizzInfo extends HttpServlet {
|
|
||||||
QuizzDAO quizzDAO = new QuizzDAO();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.getRequestDispatcher("/Quizz.html").forward(req, resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
//Utilisateur
|
|
||||||
UtilisateurDAO uDAO = new UtilisateurDAO();
|
|
||||||
String email_user = req.getParameter("email_User");
|
|
||||||
String id_User = req.getParameter("id_User");
|
|
||||||
|
|
||||||
Utilisateur u_cree_quizz = null;
|
|
||||||
|
|
||||||
if (id_User != null && !id_User.isEmpty()) {
|
|
||||||
int id = Integer.parseInt(id_User);
|
|
||||||
u_cree_quizz=uDAO.findById(id);
|
|
||||||
}else if(email_user != null && !email_user.isEmpty()){
|
|
||||||
u_cree_quizz=uDAO.findByEmail(email_user);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (u_cree_quizz == null) {
|
|
||||||
resp.getWriter().println("<HTML>\n<BODY>\n" +
|
|
||||||
"<H1> Utilisateur non trouvable </H1>" +
|
|
||||||
"</BODY></HTML>");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
Quizz quizz = new Quizz();
|
|
||||||
quizz.setCreateur(u_cree_quizz);
|
|
||||||
//quizz.setSession(s_attached);
|
|
||||||
quizzDAO.create(quizz);
|
|
||||||
|
|
||||||
resp.getWriter().println("<HTML>\n<BODY>\n" +
|
|
||||||
"<H1>Quizz cree par " + u_cree_quizz.getName() + "</H1>" +
|
|
||||||
"</BODY></HTML>");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import DAO.*;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import metier.Quizz;
|
|
||||||
import metier.Session;
|
|
||||||
|
|
||||||
@WebServlet(name = "session", urlPatterns = {"/SessionInfo"})
|
|
||||||
public class SessionInfo extends HttpServlet {
|
|
||||||
SessionDAO sessionDAO = new SessionDAO();
|
|
||||||
UtilisateurDAO uDAO = new UtilisateurDAO();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.getRequestDispatcher("/Session.html").forward(req, resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
String action = req.getParameter("action");
|
|
||||||
if (action.equals("createSession")) {
|
|
||||||
// Créer une nouvelle session
|
|
||||||
String theme = req.getParameter("theme");
|
|
||||||
String codePin = req.getParameter("codePIN");
|
|
||||||
Session s = new Session();
|
|
||||||
s.setCodePIN(Integer.parseInt(codePin));
|
|
||||||
s.setTheme(theme);
|
|
||||||
sessionDAO.create(s);
|
|
||||||
|
|
||||||
resp.getWriter().println("<h1>Session creee avec id: " +
|
|
||||||
s.getId() + "</h1>");
|
|
||||||
resp.getWriter().println("<h1>Session creee avec code PIN: " +
|
|
||||||
s.getCodePIN() + "</h1>");
|
|
||||||
}
|
|
||||||
else if (action.equals("addQuizz")){
|
|
||||||
String idQuizz = req.getParameter("idQuizz");
|
|
||||||
String sessionID = req.getParameter("sessionID");
|
|
||||||
QuizzDAO quizzDAO = new QuizzDAO();
|
|
||||||
SessionDAO sessionDAO = new SessionDAO();
|
|
||||||
|
|
||||||
Quizz quizz = quizzDAO.findById(Integer.parseInt(idQuizz));
|
|
||||||
if(quizz==null) resp.getWriter().println("<h1>Ce quizz n'existe pas !</h1>");
|
|
||||||
if(quizz==null) resp.getWriter().println("<h1>Cette session n'existe pas !</h1>");
|
|
||||||
Session session = sessionDAO.findById(Integer.parseInt(sessionID));
|
|
||||||
|
|
||||||
sessionDAO.addQuizz(quizz,session);
|
|
||||||
|
|
||||||
|
|
||||||
resp.getWriter().println("<h1>Quizz"+ idQuizz +" est ajouté à la session " + sessionID + " !</h1>");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import DAO.*;
|
|
||||||
import DTO.UtilisateurDTO;
|
|
||||||
import Mapper.UtilisateurMapper;
|
|
||||||
import metier.*;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
|
|
||||||
@WebServlet(name = "Show", urlPatterns = {"/Show"})
|
|
||||||
public class Show extends HttpServlet {
|
|
||||||
Utilisateur u;
|
|
||||||
QuizzDAO quizzDAO = new QuizzDAO();
|
|
||||||
SessionDAO sessionDAO = new SessionDAO();
|
|
||||||
UtilisateurDAO utilisateurDAO = new UtilisateurDAO();
|
|
||||||
QuestionDAO questionDAO = new QuestionDAO();
|
|
||||||
|
|
||||||
UtilisateurMapper mapper_u = Mappers.getMapper(UtilisateurMapper.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
||||||
|
|
||||||
response.setContentType("text/html");
|
|
||||||
|
|
||||||
String result = "<!DOCTYPE html>" +
|
|
||||||
"<html>" +
|
|
||||||
"<head>" +
|
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" + request.getContextPath() + "/css/style.css\">" +
|
|
||||||
"</head>" +
|
|
||||||
"<body>";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//UTILISATEUR
|
|
||||||
List<Utilisateur> listUser = utilisateurDAO.findAll();
|
|
||||||
|
|
||||||
result += "<H2>Utilisateurs :</H2>";
|
|
||||||
result +=
|
|
||||||
"<table class=\"show\">" +
|
|
||||||
"<thead class=\"show\">" +
|
|
||||||
"<tr>" +
|
|
||||||
"<th class=\"Id\">Nom</th><th class=\"show\">Nom</th><th class=\"show\">mail</th><th class=\"show\">Password</th>" +
|
|
||||||
"</tr>" +
|
|
||||||
"</thead>" +
|
|
||||||
"<tbody>";
|
|
||||||
for (Utilisateur u : listUser) {
|
|
||||||
UtilisateurDTO dto = mapper_u.toDTO(u);
|
|
||||||
result +=
|
|
||||||
"<tr>" +
|
|
||||||
"<th class=\"show\">" + dto.getId() + "</th><th class=\"show\">" + dto.getName() + "</th><th class=\"show\">" + dto.getEmail() + "</th><th class=\"show\">" + dto.getPassword() + "</th>"+
|
|
||||||
"</tr>";
|
|
||||||
System.out.println(u.getName()+dto.getEmail());
|
|
||||||
}
|
|
||||||
result +=
|
|
||||||
"</tbody>"+
|
|
||||||
"</table>";
|
|
||||||
|
|
||||||
//QUIZZ
|
|
||||||
List<Quizz> listQuizz = quizzDAO.findAll();
|
|
||||||
|
|
||||||
result += "<H2>Quizz :</H2>";
|
|
||||||
for (Quizz quizz : listQuizz) {
|
|
||||||
quizzDAO.refresh(quizz);
|
|
||||||
result += "<div class=\"quizz\">";
|
|
||||||
result += "quizz n°" + quizz.getId() + "<br/>";
|
|
||||||
result += "<div class=\"tabulation\">";
|
|
||||||
result += "Createur : " + quizz.getCreateur().getEmail() + " (id: " + quizz.getCreateur().getId() + ") <br/>";
|
|
||||||
result += "nb Question : " + quizz.getQuestions().size() +"<br/>";
|
|
||||||
|
|
||||||
|
|
||||||
for (Question question : quizz.getQuestions()) {
|
|
||||||
result += "<div class=\"question\">";
|
|
||||||
result += "Q" + question.getId() + " Ennoncé : "+ question.getEnonce() + "<br/>";
|
|
||||||
|
|
||||||
|
|
||||||
result += "<b>Choix de réponse : </b><br/>";
|
|
||||||
result += "<div class=\"tabulation\">";
|
|
||||||
result += question.getReponse().valHTML();
|
|
||||||
result += "</div>";
|
|
||||||
result += "<b>Reponses corrects :</b><br/>";
|
|
||||||
result += "<div class=\"tabulation\">";
|
|
||||||
for (String reponse : question.getReponse().getReponses()) {
|
|
||||||
result += reponse;
|
|
||||||
}
|
|
||||||
result += "</div></div>";
|
|
||||||
}
|
|
||||||
result += "</div></div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
//SESSION
|
|
||||||
List<Session> listSession = sessionDAO.findAll();
|
|
||||||
result += "<H2>Session : </H2>";
|
|
||||||
result +=
|
|
||||||
"<table class=\"show\">"+
|
|
||||||
"<thead class=\"show\">"+
|
|
||||||
"<tr>"+
|
|
||||||
"<th class=\"show\">ID</th><th class=\"show\">Theme</th><th class=\"show\">Code PIN</th><th class=\"show\">Quizzs</th><th class=\"show\">Participants</th>"+
|
|
||||||
"</tr>"+
|
|
||||||
"</thead>"+
|
|
||||||
"<tbody>";
|
|
||||||
|
|
||||||
for(Session session : listSession){
|
|
||||||
sessionDAO.refresh(session);
|
|
||||||
result+=
|
|
||||||
"<tr>"+
|
|
||||||
"<th class=\"show\">"+session.getId()+"</th>"+"<th class=\"show\">"+session.getTheme()+"</th>"+"<th class=\"show\">"+session.getCodePIN()+"</th>";
|
|
||||||
String quizzsID = "";
|
|
||||||
for(Quizz quizz : session.getQuizzs()){
|
|
||||||
quizzsID += quizz.getId() + " ; ";
|
|
||||||
}
|
|
||||||
String UtilisateurID = "";
|
|
||||||
for(Utilisateur utilisateur : session.getUtilisateurs()){
|
|
||||||
UtilisateurID += utilisateur.getEmail() + " ; ";
|
|
||||||
}
|
|
||||||
result += "<th class=\"show\">"+quizzsID+"</th>"+"<th class=\"show\">"+UtilisateurID+"</th>";
|
|
||||||
result+="</tr>";
|
|
||||||
}
|
|
||||||
|
|
||||||
result +=
|
|
||||||
"</tbody>"+
|
|
||||||
"</table>";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//HTML END
|
|
||||||
result += "</body>\n</html>";
|
|
||||||
|
|
||||||
response.getWriter().write(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package servlet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import DAO.UtilisateurDAO;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import metier.Utilisateur;
|
|
||||||
|
|
||||||
@WebServlet(name = "userinfo", urlPatterns = {"/UserInfo"})
|
|
||||||
public class UserInfo extends HttpServlet {
|
|
||||||
UtilisateurDAO utilisateurDAO = new UtilisateurDAO();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
|
||||||
req.getRequestDispatcher("/UserInfo.html").forward(req, resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
||||||
response.setContentType("text/html");
|
|
||||||
String action = request.getParameter("action");
|
|
||||||
|
|
||||||
if ("addUser".equals(action)) {
|
|
||||||
Utilisateur u = new Utilisateur();
|
|
||||||
u.setName(request.getParameter("name"));
|
|
||||||
u.setEmail(request.getParameter("email"));
|
|
||||||
u.setPassword(request.getParameter("password"));
|
|
||||||
|
|
||||||
|
|
||||||
utilisateurDAO.create(u);
|
|
||||||
PrintWriter out = response.getWriter();
|
|
||||||
out.println("<HTML>\n<BODY>\n" +
|
|
||||||
"<H1>Recapitulatif des informations de l'utilisateur</H1>\n" +
|
|
||||||
"<UL>\n" + " <LI>Nom: " + request.getParameter("name") +
|
|
||||||
"\n" + " <LI>Email: " + request.getParameter("email") + "\n" +
|
|
||||||
"</BODY></HTML>");
|
|
||||||
} else if ("addSession".equals(action)) {
|
|
||||||
int sessionId = Integer.parseInt(request.getParameter("sessionId"));
|
|
||||||
int userId = Integer.parseInt(request.getParameter("userId"));
|
|
||||||
utilisateurDAO.addToSession(sessionId, userId);
|
|
||||||
response.getWriter().println("<h1> Reussi d'ajouter utilisateur " +
|
|
||||||
userId + " à la session " + sessionId + "</h1>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
|
|
||||||
version="3.0">
|
|
||||||
|
|
||||||
<persistence-unit name="dev" transaction-type="RESOURCE_LOCAL">
|
|
||||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
|
||||||
<properties>
|
|
||||||
<property name="jakarta.persistence.jdbc.driver"
|
|
||||||
value="org.hsqldb.jdbcDriver" />
|
|
||||||
<property name="jakarta.persistence.jdbc.url"
|
|
||||||
value="jdbc:hsqldb:hsql://localhost/" />
|
|
||||||
<property name="jakarta.persistence.jdbc.user" value="sa" />
|
|
||||||
<property name="jakarta.persistence.jdbc.password" value="" />
|
|
||||||
<property
|
|
||||||
name="jakarta.persistence.schema-generation.database.action"
|
|
||||||
value="create" />
|
|
||||||
<property name="jakarta.persistence.dialect"
|
|
||||||
value="org.hibernate.dialect.HSQLDialect" />
|
|
||||||
<property name="hibernate.show_sql" value="true" />
|
|
||||||
</properties>
|
|
||||||
</persistence-unit>
|
|
||||||
<persistence-unit name="prod" transaction-type="RESOURCE_LOCAL">
|
|
||||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
|
||||||
<properties>
|
|
||||||
<property name="jakarta.persistence.jdbc.driver"
|
|
||||||
value="org.hsqldb.jdbcDriver" />
|
|
||||||
<property name="jakarta.persistence.jdbc.url"
|
|
||||||
value="jdbc:hsqldb:hsql://localhost/" />
|
|
||||||
<property name="jakarta.persistence.jdbc.user" value="sa" />
|
|
||||||
<property name="jakarta.persistence.jdbc.password" value="" />
|
|
||||||
<property
|
|
||||||
name="jakarta.persistence.schema-generation.database.action"
|
|
||||||
value="update" />
|
|
||||||
<property name="jakarta.persistence.dialect"
|
|
||||||
value="org.hibernate.dialect.HSQLDialect" />
|
|
||||||
<property name="hibernate.show_sql" value="true" />
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
</persistence-unit>
|
|
||||||
|
|
||||||
<persistence-unit name="mysql">
|
|
||||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<property name="jakarta.persistence.jdbc.driver"
|
|
||||||
value="com.mysql.cj.jdbc.Driver" />
|
|
||||||
<property name="jakarta.persistence.jdbc.url"
|
|
||||||
value="jdbc:mysql://localhost/mydatabase" />
|
|
||||||
<property name="jakarta.persistence.jdbc.user" value="tlc" />
|
|
||||||
<property name="jakarta.persistence.jdbc.password" value="tlc" />
|
|
||||||
<property
|
|
||||||
name="jakarta.persistence.schema-generation.database.action"
|
|
||||||
value="update" />
|
|
||||||
<property name="jakarta.persistence.dialect"
|
|
||||||
value="org.hibernate.dialect.MySQL8Dialect" />
|
|
||||||
<property name="hibernate.show_sql" value="true" />
|
|
||||||
<property name="hibernate.c3p0.min_size" value="5" />
|
|
||||||
<property name="hibernate.c3p0.max_size" value="20" />
|
|
||||||
<property name="hibernate.c3p0.timeout" value="300" />
|
|
||||||
<property name="hibernate.c3p0.max_statements" value="50" />
|
|
||||||
<property name="hibernate.c3p0.idle_test_period" value="3000" />
|
|
||||||
</properties>
|
|
||||||
</persistence-unit>
|
|
||||||
|
|
||||||
</persistence>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
----------------------------------------------log4j.properties
|
|
||||||
|
|
||||||
### direct log messages to stdout
|
|
||||||
###
|
|
||||||
log4j.rootLogger=INFO, stdout
|
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
|
||||||
log4j.appender.stdout.Target=System.out
|
|
||||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
|
||||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
|
||||||
|
|
||||||
# Log everything. Good for troubleshooting
|
|
||||||
log4j.logger.org.hibernate=ERROR
|
|
||||||
|
|
||||||
# Log all JDBC parameters
|
|
||||||
log4j.logger.org.hibernate.type=ERROR
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<html lang="fr">
|
|
||||||
<body>
|
|
||||||
<h1>Creer une Question</h1>
|
|
||||||
<form action="QuestionInfo" method="POST">
|
|
||||||
<input type="hidden" name="action" value="createSession">
|
|
||||||
Ennoncé de la question : <input type="text" name="question"><br/>
|
|
||||||
Type :
|
|
||||||
<select id="type" name="type">
|
|
||||||
<option value="choix">Choix multiple</option>
|
|
||||||
<option value="courte">Réponse courte</option>
|
|
||||||
</select><br/>
|
|
||||||
<div id="DivChoix">
|
|
||||||
Choix possible (séparez avec des retour à la ligne):<br/>
|
|
||||||
<textarea id="choixPossible" name="choixPossible" rows="5" cols="40"></textarea><br/>
|
|
||||||
</div>
|
|
||||||
Réponse autorisée (séparez avec des retour à la ligne):<br/>
|
|
||||||
<textarea id="reponse" name="reponse" rows="5" cols="40"></textarea><br/>
|
|
||||||
ID Quizz: <input type="number" name="idQuizz"><br/>
|
|
||||||
<input type="submit" value="Creer Session">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const select = document.getElementById('type');
|
|
||||||
const contenu1 = document.getElementById('DivChoix');
|
|
||||||
|
|
||||||
select.addEventListener('change', function () {
|
|
||||||
if (this.value === 'choix') {
|
|
||||||
contenu1.style.display = 'block';
|
|
||||||
} else{
|
|
||||||
contenu1.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<html lang="en">
|
|
||||||
<body>
|
|
||||||
<form action="QuizzInfo" method="POST">
|
|
||||||
<h1>Creer des quizz</h1>
|
|
||||||
Create from user id : <INPUT type="number" name="id_User" size="20"><BR>
|
|
||||||
Create from user email : <INPUT type="text" name="email_User" size="20"><BR>
|
|
||||||
<INPUT type="submit" value="Creer Quizz"></INPUT>
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<html lang="en">
|
|
||||||
<body>
|
|
||||||
<h1>Creer une session</h1>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form action="SessionInfo" method="POST">
|
|
||||||
<input type="hidden" name="action" value="createSession">
|
|
||||||
Theme: <input type="text" name="theme"><br/>
|
|
||||||
CodePin <input type="number" name="codePIN"><br/>
|
|
||||||
<input type="submit" value="createSession">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<h1>Ajouter un quizz à une session</h1>
|
|
||||||
|
|
||||||
<form action="SessionInfo" method="POST">
|
|
||||||
<input type="hidden" name="action" value="addQuizz">
|
|
||||||
session ID <input type="number" name="sessionID"><br/>
|
|
||||||
ID Quizz <input type="number" name="idQuizz"><br/>
|
|
||||||
<input type="submit" value="addQuizz">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>User manager</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Creer l'utilisateur</h1>
|
|
||||||
<FORM Method="POST" Action="UserInfo">
|
|
||||||
<input type="hidden" name="action" value="addUser">
|
|
||||||
Name : <INPUT type="text" size="20" name="name"><BR>
|
|
||||||
Email : <INPUT type="text" size="20" name="email"><BR>
|
|
||||||
Passworld : <INPUT type="text" size="20" name="password"><BR>
|
|
||||||
<INPUT type="submit" value="Send">
|
|
||||||
</FORM>
|
|
||||||
|
|
||||||
<h1>Ajouter utilisateur dans une session</h1>
|
|
||||||
<form action="UserInfo" method="POST">
|
|
||||||
<input type="hidden" name="action" value="addSession">
|
|
||||||
ID Session: <input type="number" name="sessionId"><br>
|
|
||||||
ID Utilisateur: <input type="number" name="userId"><br>
|
|
||||||
<input type="submit" value="Ajouter">
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
body{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
table.show{
|
|
||||||
border-collapse: collapse;
|
|
||||||
text-align: left;
|
|
||||||
border: 2px solid #C0C0C0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
thead.show{
|
|
||||||
background-color: #F0F0F0;
|
|
||||||
}
|
|
||||||
|
|
||||||
th.show{
|
|
||||||
padding-left: 5px;
|
|
||||||
padding-right: 5px;
|
|
||||||
border: 1px solid #C0C0C0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.tabulation{
|
|
||||||
padding-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.question{
|
|
||||||
border: solid;
|
|
||||||
border-color: #C0C0C0;
|
|
||||||
margin: 5px;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quizz{
|
|
||||||
border: solid;
|
|
||||||
border-color: #909090;
|
|
||||||
margin: 5px;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Kaflop!</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Kaflop!</h1>
|
|
||||||
<a href =http://localhost:8080/UserInfo.html>myform</a>
|
|
||||||
<a href =http://localhost:8080/Session.html>session</a>
|
|
||||||
<a href =http://localhost:8080/Quizz.html>Quizz</a>
|
|
||||||
<a href =http://localhost:8080/Question.html>Question</a>
|
|
||||||
|
|
||||||
|
|
||||||
<a href =Show>show</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user