Compare commits

..

2 Commits
master ... php

@ -0,0 +1,18 @@
kind: pipeline
type: docker
name: ScienceQuestPhp
trigger:
branch:
- php
event:
- push
steps:
- name: code-analysis-php
image: aosapps/drone-sonar-plugin
settings:
sonar_host:
from_secret: sonar_host
sonar_token:
from_secret: sonar_sae_token

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/project/src/config" isTestSource="false" packagePrefix="config\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/controller" isTestSource="false" packagePrefix="controller\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/model" isTestSource="false" packagePrefix="model\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/model/exception" isTestSource="false" packagePrefix="model\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/model/gateways" isTestSource="false" packagePrefix="model\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/model/mdl" isTestSource="false" packagePrefix="model\" />
<sourceFolder url="file://$MODULE_DIR$/project/src/model/metier" isTestSource="false" packagePrefix="model\" />
<excludeFolder url="file://$MODULE_DIR$/project/src/vendor/altorouter/altorouter" />
<excludeFolder url="file://$MODULE_DIR$/project/src/vendor/composer" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="ProjetPHP">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ScienceQuest.iml" filepath="$PROJECT_DIR$/.idea/ScienceQuest.iml" />
</modules>
</component>
</project>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/project/src/vendor/altorouter/altorouter" />
<path value="$PROJECT_DIR$/project/src/vendor/composer" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.4">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -1,73 +0,0 @@
```plantuml
@startwbs
<style>
wbsDiagram {
.blue {
BackgroundColor lightblue
}
.green {
BackgroundColor lightgreen
}
.yellow {
BackgroundColor #ffbf87
}
.orange {
BackgroundColor lightyellow
}
.red {
BackgroundColor #FFB2B2
}
.pink {
BackgroundColor #ff99ee
}
.purple {
BackgroundColor #cfb3ff
}
}
</style>
* Projet "Science Quest" <<blue>>
** Établir la conception <<green>>
*** Créer le site Web <<yellow>>
**** Conception des mini-jeux <<orange>>
***** Conception du jeu "Qui-est-ce ?" <<red>>
***** Conception du jeu "Quizz" <<red>>
***** Conception du jeu "Pendu" <<red>>
*** Créer l'application Mobile <<yellow>>
**** Conception des mini-jeux <<orange>>
***** Conception du jeu "Qui-est-ce ?" <<red>>
***** Conception du jeu "Quizz" <<red>>
***** Conception du jeu "Pendu" <<red>>
** Démarrer le développement <<green>>
*** Développer le site Web <<yellow>>
**** Développement des mini-jeux <<orange>>
***** Développement du jeu "Qui-est-ce ?" <<red>>
***** Développement du jeu "Quizz" <<red>>
***** Développement du jeu "Pendu" <<red>>
*** Développer l'application Mobile <<yellow>>
**** Développement des mini-jeux <<orange>>
***** Développement du jeu "Qui-est-ce ?" <<red>>
***** Développement du jeu "Quizz" <<red>>
***** Développement du jeu "Pendu" <<red>>
** Tester l'application <<green>>
*** Tester le site Web <<yellow>>
**** Test des mini-jeux <<orange>>
***** Test du jeu "Qui-est-ce ?" <<red>>
***** Test du jeu "Quizz" <<red>>
***** Test du jeu "Pendu" <<red>>
*** Tester l'application Mobile <<yellow>>
**** Test des mini-jeux <<orange>>
***** Test du jeu "Qui-est-ce ?" <<red>>
***** Test du jeu "Quizz" <<red>>
***** Test du jeu "Pendu" <<red>>
** Création des livrables <<pink>>
*** Application client web <<purple>>
*** Application client mobile <<purple>>
*** Application admin web <<purple>>
*** Application app monitoring web <<purple>>
*** Conception et contenu de la base de données <<purple>>
*** Installation dun pare-feu <<purple>>
*** Installation dun service web <<purple>>
*** Installation dun SGBD <<purple>>
*** Installation des serveurs pour les services nommées ci-dessus et configurations <<purple>>
@endwbs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

@ -1,90 +0,0 @@
```plantuml
@startuml "BDD"
class Scientifique{
nom : String
prenom : String
photo : Raw
dateNaissance : Date
descriptif : String
ratioTrouvee : Float
}
class Thematique{
libelle : String
}
class Sexe{
libelle : String
}
class "Difficulte"{
libelle: String
}
class Indice{
indice : String
}
Scientifique "*" --> "1..*" Thematique
Scientifique "*" --> "1" Sexe
Scientifique "*" --> "1" "Difficulte"
Scientifique "*" <-- "*"Utilisateur : A découvert <
Scientifique .. Admin : Gérer <
Scientifique "1" --> "*" Indice
class Question{
question : String
}
class Reponse{
reponse : String
}
Question "1" --> "1..*" Reponse
Reponse "0..*" --> "1" Scientifique
abstract class Joueur{
pseudo : String {unique}
}
class Utilisateur{
email : String {unique}
motDePasse : Hash
}
class Invite{
idSession : Integer
}
Joueur <|-- Utilisateur
Joueur <|-- Invite
class Admin{
email : String {unique}
motDePasse : Hash
}
abstract class Jeu{
nom : String
nbrParties : Integer
}
Jeu .. Scientifique : Accède >
class Pendu extends Jeu
Pendu "1" --> "1..*" Scientifique
class Partie{
codeInvitation : String
isFinished : Boolean
}
Partie "*" --> "1" Jeu
Partie "1" --> "1..*" Joueur
@enduml
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

@ -1,130 +0,0 @@
Logiciel : plantuml
https://plantuml.com/fr/
@startuml "Diagramme de classes participantes PHP"
class FrontController <<contrôle>>{
}
FrontController --> ControllerAdmin
FrontController --> ControllerUtilisateur
FrontController --> ControllerInvite
class ControllerUtilisateur <<contrôle>>{
}
ControllerUtilisateur --> ControllerLancerJeu
class ControllerInvite <<contrôle>>{
}
ControllerInvite --> ControllerLancerJeu
class ControllerAdmin <<contrôle>>{
}
class ControllerLancerJeu <<contrôle>>{
lancerJeuAléatoirement()
lancerJeu()
}
class Accueil <<dialogue>>{
rejoindrePartie()
lancerUnJeu()
seConnecter()
seDeconnecter()
}
Accueil --> RejoindrePartie
Accueil --> LancerUnJeu
Accueil --> Connexion
class RejoindrePartie <<dialogue>>{
codeInvitation : String
rejoindrePartie()
}
class LancerUnJeu <<dialogue>>{
jeux : Array
choisirJeu()
choisirJeuAléatoirement()
}
class Connexion <<dialogue>>{
email : String
motDePasse : String
seConnecter()
}
Connexion --> EspacePersonnel
class EspacePersonnel <<dialogue>>{
scientifiqueTrouvés : Array
accéderFicheScientifique()
ChangerPseudo()
}
EspacePersonnel --> DetailsScientifique
EspacePersonnel --> ChangerPseudo
class DetailsScientifique <<dialogue>>{
nom : String
prenom : String
photo : String
dateNaissance : Date
descriptif : String
thematiques : Array
retourEspacePersonnel()
}
class ChangerPseudo <<dialogue>>{
pseudo : String
setPseudo()
}
class Scientifique <<entité>>{
nom : String
prenom : String
photo : Raw
dateNaissance : Date
descriptif : String
ratioTrouvee : Float
}
class Thematique <<entité>>{
libelle : String
}
class "Difficulté" <<entité>>{
libelle: String
}
abstract Compte <<entité>>{
email : String
motDePasse : Hash
}
class Utilisateur <<entité>>{
pseudo : String
}
class Admin <<entité>>{
}
class Jeu <<entité>>{
nom : String
nbrParties : Integer
}
@enduml

@ -1,90 +0,0 @@
Logiciel : plantuml
https://plantuml.com/fr/
@startuml "Diagramme de classes participantes lancer une partie"
class Invité <<acteur>>{}
Invité --> Accueil : 1
Accueil --> FrontController : 2
LancerUnJeu --> FrontController : 9
class FrontController <<contrôle>>{
}
FrontController --> ControllerInvite : 3 , 1O, 16, 24
class ControllerInvite <<contrôle>>{
}
ControllerInvite --> ControllerLancerJeu : 4, 11, 17, 25
class ControllerLancerJeu <<contrôle>>{
lancerJeuAléatoirement()
lancerJeu()
}
ControllerLancerJeu --> LancerUnJeu : 6
ControllerLancerJeu --> Jeu : 5
ControllerLancerJeu --> SaisirPseudo : 12
ControllerLancerJeu --> Difficulté : 18
ControllerLancerJeu --> Thematique : 19
ControllerLancerJeu --> ConfigurerUnjeu : 20
ControllerLancerJeu --> VueDuJeu : 26
class Accueil <<dialogue>>{
rejoindrePartie()
lancerUnJeu()
seConnecter()
seDeconnecter()
}
class VueDuJeu <<dialogue>>{
}
VueDuJeu --> Invité : 27
class SaisirPseudo <<dialogue>>{
pseudo : String
valider()
}
SaisirPseudo --> Invité : 13
SaisirPseudo <-- Invité : 14
SaisirPseudo --> FrontController : 15
class LancerUnJeu <<dialogue>>{
jeux : Array
choisirJeu()
choisirJeuAléatoirement()
}
class ConfigurerUnjeu <<dialogue>>{
difficulté : Integer
thématique : Integer
valider()
}
Invité <-- ConfigurerUnjeu : 21
Invité --> ConfigurerUnjeu : 22
ConfigurerUnjeu --> FrontController : 23
LancerUnJeu --> Invité : 7
LancerUnJeu <-- Invité : 8
class Thematique <<entité>>{
libelle : String
}
class "Difficulté" <<entité>>{
libelle: String
}
class Jeu <<entité>>{
nom : String
nbrParties : Integer
}
@enduml

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 189 KiB

File diff suppressed because one or more lines are too long

@ -1,125 +0,0 @@
<mxfile host="app.diagrams.net" modified="2023-10-26T14:31:05.858Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" etag="DA3skaueM-lHySTBLYxc" version="22.0.8" type="device">
<diagram name="Page-1" id="jla4qwjFgwFRS1lIauP8">
<mxGraphModel dx="1434" dy="764" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="4sC6NxI0jN4h-IAwyfg9-5" value="" style="whiteSpace=wrap;html=1;aspect=fixed;movable=0;resizable=0;rotatable=0;deletable=0;editable=0;locked=1;connectable=0;" vertex="1" parent="1">
<mxGeometry x="150" y="20" width="630" height="630" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-4" target="4sC6NxI0jN4h-IAwyfg9-7">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-49" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-4" target="4sC6NxI0jN4h-IAwyfg9-39">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-4" value="enseignant" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="50" y="38" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-6" value="&lt;div&gt;kahoot&lt;/div&gt;" style="text;align=center;fontStyle=1;verticalAlign=middle;spacingLeft=3;spacingRight=3;strokeColor=none;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" vertex="1" parent="1">
<mxGeometry x="150" y="20" width="80" height="26" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-7" value="Creer partie" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="160" y="46" width="130" height="44" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-10" value="&lt;div&gt;Choisir niveau de difficulté&lt;/div&gt;&lt;div&gt;en fonction de la popularité&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="470" y="28" width="180" height="70" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-11" value="&lt;div&gt;Choisir le theme des scientifiques&lt;/div&gt;&lt;div&gt;(Math, SVT, Informatique, tous...)&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="480" y="110" width="220" height="70" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-19" target="4sC6NxI0jN4h-IAwyfg9-23">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-19" target="4sC6NxI0jN4h-IAwyfg9-46">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-19" value="&lt;div&gt;joueur&lt;/div&gt;" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;" vertex="1" parent="1">
<mxGeometry x="50" y="325" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-23" value="&lt;div&gt;Rejoindre partie&lt;/div&gt;&lt;div&gt;non lancée&lt;br&gt;&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="155" y="330" width="130" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-25" value="&lt;div&gt;Répondre a une question&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="330" width="140" height="70" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-26" value="&lt;div&gt;&amp;lt;&amp;lt;include&amp;gt;&amp;gt;&lt;/div&gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-40" target="4sC6NxI0jN4h-IAwyfg9-25">
<mxGeometry relative="1" as="geometry">
<mxPoint x="350" y="355" as="sourcePoint" />
<mxPoint x="440" y="345" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-27" value="&lt;div&gt;Répondre juste a une question&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="390" y="435" width="130" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-28" value="" style="endArrow=block;endSize=16;endFill=0;html=1;rounded=0;exitX=0.585;exitY=-0.02;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.343;entryY=0.957;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-27" target="4sC6NxI0jN4h-IAwyfg9-25">
<mxGeometry width="160" relative="1" as="geometry">
<mxPoint x="400" y="345" as="sourcePoint" />
<mxPoint x="560" y="345" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-29" value="&lt;div&gt;Répondre faux a une question&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="540" y="425" width="130" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-30" value="" style="endArrow=block;endSize=16;endFill=0;html=1;rounded=0;entryX=0.793;entryY=0.9;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-29" target="4sC6NxI0jN4h-IAwyfg9-25">
<mxGeometry width="160" relative="1" as="geometry">
<mxPoint x="476" y="444" as="sourcePoint" />
<mxPoint x="498" y="397" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-31" value="&lt;div&gt;Ajouter scientifique dans historique&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="395" y="525" width="120" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-33" value="&lt;div&gt;&amp;lt;&amp;lt;include&amp;gt;&amp;gt;&lt;/div&gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-27" target="4sC6NxI0jN4h-IAwyfg9-31">
<mxGeometry relative="1" as="geometry">
<mxPoint x="520" y="345" as="sourcePoint" />
<mxPoint x="440" y="345" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-34" value="&lt;div&gt;Affiche les questions&lt;br&gt;&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="375" y="200" width="140" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-36" value="&lt;div&gt;&amp;lt;&amp;lt;include&amp;gt;&amp;gt;&lt;/div&gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;exitX=0.454;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-7" target="4sC6NxI0jN4h-IAwyfg9-39">
<mxGeometry relative="1" as="geometry">
<mxPoint x="460" y="280" as="sourcePoint" />
<mxPoint x="380" y="280" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-37" value="&lt;div&gt;&amp;lt;&amp;lt;include&amp;gt;&amp;gt;&lt;/div&gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=0.923;exitY=0.727;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-7" target="4sC6NxI0jN4h-IAwyfg9-11">
<mxGeometry relative="1" as="geometry">
<mxPoint x="460" y="280" as="sourcePoint" />
<mxPoint x="380" y="280" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-38" value="&lt;div&gt;&amp;lt;&amp;lt;include&amp;gt;&amp;gt;&lt;/div&gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-7" target="4sC6NxI0jN4h-IAwyfg9-10">
<mxGeometry relative="1" as="geometry">
<mxPoint x="460" y="280" as="sourcePoint" />
<mxPoint x="380" y="280" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-39" value="&lt;div&gt;Lancer partie&lt;/div&gt;" style="ellipse;whiteSpace=wrap;html=1;direction=west;" vertex="1" parent="1">
<mxGeometry x="160" y="150" width="130" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-40" value="Jouer dans partie lancée" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="170" y="425" width="130" height="50" as="geometry" />
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-42" value="&amp;lt;&amp;lt;include&amp;gt;&amp;gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-39" target="4sC6NxI0jN4h-IAwyfg9-34">
<mxGeometry relative="1" as="geometry">
<mxPoint x="460" y="280" as="sourcePoint" />
<mxPoint x="380" y="280" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-44" value="&amp;lt;&amp;lt;include&amp;gt;&amp;gt;" style="html=1;verticalAlign=bottom;endArrow=open;dashed=1;endSize=8;curved=0;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4sC6NxI0jN4h-IAwyfg9-23" target="4sC6NxI0jN4h-IAwyfg9-40">
<mxGeometry relative="1" as="geometry">
<mxPoint x="460" y="280" as="sourcePoint" />
<mxPoint x="230" y="390" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="4sC6NxI0jN4h-IAwyfg9-46" value="voir résultats finaux" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="150" y="230" width="140" height="60" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 29 KiB

@ -1,26 +0,0 @@
PHP SAE
Actions disponibles pour admin :
- connexion
- déconnexion
- gestion scientifique
- accéder stats site
Actions users :
- créer partie
- rejoindre partie
- historique scientifiques trouvés
Vues nécessaires :
- Accueil
- création partie
- rejoindre partie
- la partie (dépend des jeux)
- historique des scientifiques trouvés
Pour admin
- connexion (pop-up si possible)
- Gestion des scientifiques (genre une liste et on peut les supprimer)
- ajouter scientifique

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

@ -1,135 +0,0 @@
```plantuml
@startuml
entity "Jeu" as jeu {
<u>id : int
nom : string
nbrParties : int
}
entity "Scientifique" as scientifique {
<u>id : int
nom : string
prenom : string
photo : string
dateNaissance : date
descriptif : string
ratioTrouvee : float
sexe: char
#idThematique : int
#idDifficulte : int
#idSexe : int
}
entity "Thematique" as thematique {
<u>id : int
libelle : string
}
entity "Difficulte" as difficulte {
<u>id : int
libelle : string
}
entity "Joueur" as joueur {
<u>id : int
pseudo : string
#idPartie : int
}
entity "Utilisateur" as utilisateur {
<u>#idJoueur : int
email : string
motDePasse : string
pseudo : string
}
entity "Invite" as invite {
<u>#idJoueur : int
}
entity "Partie" as partie {
<u>id : int
codeInvitation : string
isStarted: bool
#idJeu : int
}
entity "Admin" as admin {
<u>id : int
email : string
motDePasse : string
}
entity "Decouvrir" as decouvrir {
<u>#idUtilisateur : int
<u>#idScientifique : int
}
entity "Indice" as indice {
<u>id : int
indice : string
#idScientifique : int
}
entity "Reponse" as reponse {
<u>id : int
reponse : string
#idScientifique : int
#idQuestion : int
}
entity "Question" as question {
<u>id : int
question : string
}
entity "Action" as action {
<u>id : int
dateAction : date
}
entity "Jouer" as jouer {
#idAction
#idPartie
}
entity "ActionPendu" as actionPendu {
<u>#idAction
lettre : char
wordToFind : string
lifeLeft : int
}
entity "ActionKahoot" as actionKahoot {
<u>#idAction
numReponse: int
tempsReponse: int
#idJoueur
}
entity "ActionQuiEstCe" as actionQuiEstCe {
<u>#idAction
#idJoueur
}
actionPendu --> action
actionQuiEstCe --> action
actionQuiEstCe --> joueur
actionKahoot --> action
actionKahoot --> joueur
jouer --> action
jouer --> partie
partie --> jeu
partie <-- joueur
invite --> joueur
utilisateur --> joueur
scientifique --> thematique
scientifique --> difficulte
scientifique --> indice
question --> reponse
reponse --> scientifique
decouvrir --> scientifique
decouvrir --> utilisateur
jeu --> scientifique
@enduml

@ -1,49 +0,0 @@
**Jeu(<ins>id</ins>, nom, nbrParties)**
- *id* : clef primaire de la table Jeu
**Scientifique(<ins>id</ins>, nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, sexe, #idThematique, #idDifficulte)**
- *id* : clef primaire de la table Scientifique
- *#idThematique* clef étrangère en référence à *id* de la table Thematique
- *#idDifficulte* clef étrangère en référence à *id* de la table Difficulté
**Thematique(<ins>id</ins>, libelle)**
- *id* : clef primaire de la table Thematique
**Difficulté(<ins>id</ins>, libelle)**
- *id* : clef primaire de la table Difficulté
**Joueur(<ins>id</ins>, pseudo, #idPartie)**
- *id* : clef primaire de la table Joueur
- *#idPartie* : clef étrangère en référence à *id* de la table Partie
**Utilisateur(<ins>#idJoueur</ins>, email, motDePasse, pseudo)**
- *idJoueur* : clef primaire de la table Joueur
- *#idJoueur* : clef étrangère en référence à *id* de la table Joueur
**Invite(<ins>#idJoueur</ins>)**
- *idJoueur* : clef primaire de la table Joueur
- *#idJoueur* : clef étrangère en référence à *id* de la table Joueur
**Partie(<ins>id</ins>, codeInvitation, #idJeu)**
- *id* : clef primaire de la table Partie
- *#idJeu* : clef étrangère en référence à *id* de la table Jeu
**Admin(<ins>#id</ins>, email, motDePasse)**
- *id* : clef primaire de la table Admin
**Decouvrir(<ins>#idUtilisateur</ins>, <ins>#idScientifique</ins>)**
- *idUtilisateur*, *idScientifique* : clef primaire de la table découvrir
- *#idUtilisateur* : clef étangère en référence à *idJoueur* de la table Utilisateur
- *#idScientifique* : clef étrangère en référence à *id* de la table Scientifique
**Indice(<ins>id</ins>, indice, #idScientifique)**
- *id* : clef primaire de la table Indice
- *#idScientifique* : clef étrangère en référence à *id* de la table Scientifique
**Reponse(<ins>id</ins>, reponse, #idScientifique, #idQuestion)**
- *id* : clef primaire de la table Reponse
- *#idScientifique* : clef étrangère en référence à *id* de la table Scientifique
- *#idQuestion* : clef étrangère en référence à *id* de la table Question
**Question(<ins>id</ins>, question)**
- *id* : clef primaire de la table Question

@ -1,181 +0,0 @@
-- Testé sous pgsql 15
DROP TABLE IF EXISTS Reponse CASCADE;
DROP TABLE IF EXISTS Question CASCADE;
DROP TABLE IF EXISTS Admin CASCADE;
DROP TABLE IF EXISTS Partie CASCADE;
DROP TABLE IF EXISTS Jeu CASCADE;
DROP TABLE IF EXISTS Decouvrir CASCADE;
DROP TABLE IF EXISTS Utilisateur CASCADE;
DROP TABLE IF EXISTS Invite CASCADE;
DROP TABLE IF EXISTS Joueur CASCADE;
DROP TABLE IF EXISTS Indice CASCADE;
DROP TABLE IF EXISTS Scientifique CASCADE;
DROP TABLE IF EXISTS Thematique CASCADE;
DROP TABLE IF EXISTS Difficulte;
-- THEMATIQUE
CREATE TABLE Thematique(
id SERIAL PRIMARY KEY,
libelle varchar(128) NOT NULL UNIQUE
);
-- DIFFICULTE
CREATE TABLE Difficulte(
id SERIAL PRIMARY KEY,
libelle varchar(128) NOT NULL UNIQUE
);
-- SCIENTIFIQUE
CREATE TABLE Scientifique(
id SERIAL PRIMARY KEY,
nom varchar(128) NOT NULL,
prenom varchar(128) NOT NULL,
photo varchar(512) NOT NULL,
dateNaissance date NOT NULL,
descriptif text NOT NULL,
ratioTrouvee numeric(5,4),
sexe char(1) NOT NULL CHECK(sexe IN ('F', 'H')),
idThematique integer REFERENCES Thematique(id),
idDifficulte integer REFERENCES Difficulte(id)
);
-- INDICE
CREATE TABLE Indice(
id SERIAL PRIMARY KEY,
libelle varchar(512) NOT NULL,
idScientifique integer REFERENCES Scientifique(id)
);
-- QUESTION
CREATE TABLE Question(
id SERIAL PRIMARY KEY,
question varchar(256) NOT NULL UNIQUE
);
-- REPONSE
CREATE TABLE Reponse(
id SERIAL PRIMARY KEY,
reponse varchar(255) NOT NULL,
idQuestion integer REFERENCES Question(id),
idScientifique integer REFERENCES Scientifique(id)
);
-- ADMIN
CREATE TABLE Admin(
id SERIAL PRIMARY KEY,
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
);
-- Jeu
CREATE TABLE Jeu(
id SERIAL PRIMARY KEY,
nom varchar(128) NOT NULL UNIQUE,
nbrParties integer NOT NULL DEFAULT 0
);
-- Partie
CREATE TABLE Partie(
id SERIAL PRIMARY KEY,
codeInvitation varchar(5) NOT NULL UNIQUE,
idJeu integer REFERENCES Jeu(id)
);
-- JOUEUR
CREATE TABLE Joueur(
id SERIAL PRIMARY KEY,
idPartie integer REFERENCES Partie(id),
pseudo varchar(255) NOT NULL UNIQUE
);
-- Invite
CREATE TABLE Invite(
idJoueur integer PRIMARY KEY REFERENCES Joueur(id)
);
-- Utilisateur
CREATE TABLE Utilisateur(
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
);
-- Decouvrir
CREATE TABLE Decouvrir(
idUtilisateur integer REFERENCES Utilisateur(idJoueur),
idScientifique integer REFERENCES Scientifique(id),
PRIMARY KEY (idUtilisateur, idScientifique)
);
-- INSERTS
-- Scientifiques
INSERT INTO Difficulte(libelle) VALUES ('Facile'),('Intermédiaire'),('Difficile');
INSERT INTO Thematique(libelle) VALUES ('Nucléaire'),('Mathématiques');
INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, sexe)
VALUES
('Marie', 'Curie', '', CURRENT_DATE, 'desc', 0.50, 1, 1, 'F'),
('Albert', 'Einstein', '', CURRENT_DATE, 'desc', 0.7540, 2, 1, 'H'),
('Sophie', 'Germain', '', CURRENT_DATE, 'desc', 0.1432, 2, 2, 'F');
-- Jeu
INSERT INTO Jeu(nom) VALUES ('Qui-est-ce ?'),('Science Quizz'), ('Pendu');
-- Questions
INSERT INTO Question(question)
VALUES
('Qui a reçu le prix Nobel de chimie en 1911, pour avoir réussi à isoler un gramme de radium ?'),
('Quel mathématicien a dit : « Dieu existe, cest les mathématiques » ?'),
('Quel mathématicienne utilisa comme nom d"emprunt « Antoine Auguste Le Blanc » ?');
-- Indices
INSERT INTO Indice (libelle, idscientifique) VALUES
('Indice pour aider', 1),
('S''appelle Marie', 1);
-- Réponses
INSERT INTO Reponse(reponse, idQuestion, idScientifique)
VALUES
('Marie Curie', 1, 1),
('Albert Einstein', 2, 2),
('Sophie Germain', 3, 3);
-- Utilisateurs
INSERT INTO Joueur(pseudo) VALUES ('moi, le meilleur joueur du monde'); --id = 1
INSERT INTO Utilisateur(idJoueur,email,password) VALUES (1, 'joueur','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
-- mdp = test
-- Découvrir
INSERT INTO decouvrir(idUtilisateur,idScientifique) VALUES (1,1);
-- Admin
INSERT INTO Admin(id,email,password) VALUES (1, 'admin','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
-- mdp = test
-- Partie
INSERT INTO Partie(codeInvitation, idJeu) VALUES ('abcde', 1);

@ -1,59 +0,0 @@
```plantuml
@startuml
:Utilisateur: as u
:Utilisateur avec compte: as uc
:Administrateur: as admin
uc <|-- u
package Mini-jeux{
u --> (Rejoindre une partie avec un code d'invitation)
u --> (Accéder à la liste des jeux)
u --> (Se créer un compte)
u --> (Choisir un jeu)
(Choisir un jeu) <|-- (chosir de façon aléatoire)
(Choisir un jeu) <|-- (choisir dans la liste)
(Choisir un jeu) <.. (Créer une partie) : <<include>>
(Créer une partie) <.. (générer un code d'invitation) : <<include>>
(Créer une partie) ..> (configurer la thématique des scientifiques) : <<extends>>
(Créer une partie) ..> (configure la difficulté des scientifiques) : <<extends>>
(Créer une partie) ..> (Lancer une partie) : <<extends>>
(Créer une partie) ..> (Saisir pseudo) : <<extends>>
note "Pour l'utilisateur connecté : utilisera le pseudo associé à son compte" as notePseudo
note "Pour l'utilisateur connecté : on garde les scientifiques découverts pendant la partie dans son compte" as noteUC
noteUC .. (Lancer une partie)
notePseudo .. (Saisir pseudo)
uc --> (Se déconnecter)
(Saisir son pseudo) <.. (Se connecter) : <<include>>
uc --> (Saisir son pseudo)
(Supprimer son compte) <.. (Se connecter) : <<include>>
uc --> (Supprimer son compte)
(Accéder à la liste des scientifiques découverts) <.. (Se connecter) : <<include>>
uc --> (Accéder à la liste des scientifiques découverts)
(Accéder à la liste des scientifiques découverts) <.. (Afficher la fiche détaillé du scientifique) : <<extends>>
}
package "Mini-jeux Administration"{
admin --> (Se déconnecter du panel)
admin --> (Lister les scientifiques)
(Lister les scientifiques) <.. (Se connecter en tant qu'admin) : <<include>>
(Lister les scientifiques) <.. (Ajouter Scientifique): <<extends>>
(Lister les scientifiques) <.. (Modifier Scientifique): <<extends>>
(Lister les scientifiques) <.. (Supprimer Scientifique): <<extends>>
admin --> (Lister les scientifiques qui posent le plus de problèmes aux joueurs)
(Lister les scientifiques qui posent le plus de problèmes aux joueurs) <.. (Se connecter en tant qu'admin) : <<include>>
admin --> (Lister les statistiques d'utilisation des jeux)
(Lister les statistiques d'utilisation des jeux) <.. (Se connecter en tant qu'admin) : <<include>>
}
@enduml
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 31 KiB

@ -1,26 +1,3 @@
# Science Quest
# SCIENCEQUEST
## Accés rapide
- ### [Android](https://codefirst.iut.uca.fr/git/tom.biard/ScienceQuest/src/branch/Android/android)
- ### [API](https://codefirst.iut.uca.fr/git/tom.biard/ScienceQuest/src/branch/Springboot/SpringBootProject/)
- ### [Site Internet](https://codefirst.iut.uca.fr/git/tom.biard/ScienceQuest/src/branch/front/science-quest)
- ### [Documents](https://codefirst.iut.uca.fr/git/tom.biard/ScienceQuest/src/branch/master/Documentation)
## Description
Dans le cadre de lapprentissage au sein du BUT Informatique de Clermont-Ferrand, un projet est établi tout au long de lannée afin de mettre en place une simulation dentreprise gérée par les étudiants. Il répond à un besoin établi par un client, un professeur de lIUT, ici **Mme Anaïs Durand** dans le rôle du Product Owner, tout cela encadré par notre tutrice de projet **Mme Audrey Pouclet**.
Le projet repose sur la création dun **site internet ayant pour but premier de faire découvrir des personnalités scientifiques féminines peu connues à travers des activités vidéoludiques** sous forme de mini-jeux, seul où à plusieurs, destinées aux enfants.
Les mini-jeux retenus sont les suivants:
- **Quizz (style Kahoot)** Des questions sont posées aux participants et ceux-ci doivent choisir une des 4 réponses proposées dans le temps imparti. Si la réponse est bonne le joueur gagne des points, le joueur ayant le plus de points gagne la partie !
- **Pendu (jeu solo)**
Le système tire un scientifique au hasard selon les paramètres de la partie.
Le joueur voit alors une photo du scientifique en plus de plusieurs indices (tel que sa nationalité ou encore sa date de naissance).
A partir de ces informations le joueur devra retrouver le nom du scientifique sous la forme dun pendu
Mise en situation d'une entreprise fictive établissant un lien avec un Product Owner (PO) ayant pour but de réaliser son projet durant 100 heures dédiées tout au long de l'année.

@ -0,0 +1,5 @@
vendor/
composer.lock
js/bootstrap*.js*
css/bootstrap*.css*
config.php

@ -0,0 +1,3 @@
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

@ -0,0 +1,26 @@
{
"autoload": {
"psr-4": {
"controller\\": "controller/",
"config\\": "config/",
"model\\": ["model/", "model/mdl/", "model/gateways/", "model/metier/", "model/exception/"]
}
},
"require": {
"altorouter/altorouter": "^2.0",
"twig/twig": "^3.7",
"twbs/bootstrap": "^5.3",
"ext-iconv": "*",
"ext-pdo": "*"
},
"scripts": {
"post-update-cmd": [
"mkdir -p ./css",
"mkdir -p ./js",
"rm -f ./js/bootstrap*.js*",
"rm -f ./css/bootstrap*.css*",
"cp ./vendor/twbs/bootstrap/dist/js/* ./js/",
"cp ./vendor/twbs/bootstrap/dist/css/* ./css/"
]
}
}

Binary file not shown.

@ -0,0 +1,111 @@
<?php
namespace config;
use model\ConfigurationJeu;
use model\Joueur;
use model\MdlPendu;
use model\MdlScienceQuizz;
use model\ValidationException;
class Validation
{
public static function val_action($action)
{
if (!isset($action)) {
throw new ValidationException('pas d\'action');
}
}
public static function val_form(string &$jeu, string &$difficulty, &$dVueErreur)
{
if ($jeu == '' || !filter_var($jeu, FILTER_SANITIZE_STRING)) {
$dVueErreur[] = 'Aucun jeu selectionné';
$jeu = 0;
throw new ValidationException("Erreur jeu");
}
if ($difficulty == '' || !filter_var($difficulty, FILTER_VALIDATE_INT)) {
$dVueErreur[] = "Aucune difficulté séléctionnée";
$difficulty = 0;
throw new ValidationException("Erreur difficulté");
}
}
public static function valUserLogin(string $user, &$dVueErreur)
{
if ($user == '' || !filter_var($user, FILTER_SANITIZE_STRING)) {
$dVueErreur[] = 'Identifiant invalide';
$jeu = 0;
throw new ValidationException("Erreur identifiant");
}
}
public static function valCodeInvitation(string $codeInvitation, &$dVueErreur): string
{
if($codeInvitation == ''){
$dVueErreur[] = 'Code d\'invitation invalide';
throw new ValidationException("Code d'invitation invalide");
}
return htmlspecialchars($codeInvitation);
}
public static function valPseudo(string &$pseudo, &$dVueErreur){
$pseudo = trim($pseudo);
$pseudo = htmlspecialchars($pseudo);
$pseudo = filter_var($pseudo, FILTER_UNSAFE_RAW);
if($pseudo == '' ){
$dVueErreur[] = 'Pseudo invalide';
throw new ValidationException("Pseudo invalide");
}
return $pseudo;
}
public static function valRole(&$role, &$dVueErreur): Joueur
{
if(! $role instanceof Joueur){
$role = NULL;
$dVueErreur[] = 'Role invalide';
throw new ValidationException('Role invalide');
}
return $role;
}
public static function valConfigurationJeu($configurationJeu, &$dVueErreur): ConfigurationJeu
{
if(! $configurationJeu instanceof ConfigurationJeu){
$role = NULL;
$dVueErreur[] = 'Configuration du jeu invalide';
throw new ValidationException('Configuration du jeu');
}
return $configurationJeu;
}
public static function valMdlPendu($pendu, &$dVueErreur): MdlPendu
{
if(! $pendu instanceof MdlPendu){
$role = NULL;
$dVueErreur[] = 'Erreur mauvais jeu en utilisation';
throw new ValidationException('Erreur mauvais jeu en utilisation');
}
return $pendu;
}
public static function valPosInt($val) : int {
if(is_int($val) && $val > 0) {
return 0;
}
return $val;
}
public static function valMdlScienceQuizz($scienceQuizz, array &$dVueErreur): MdlScienceQuizz
{
if(! $scienceQuizz instanceof MdlScienceQuizz){
$role = NULL;
$dVueErreur[] = 'Erreur, mauvais jeu en utilisation';
throw new ValidationException('Erreur, mauvais jeu en utilisation');
}
return $scienceQuizz;
}
}

@ -0,0 +1,18 @@
<?php
namespace config;
$config = [
"rep" => __DIR__.'/../',
"db" => ["dsn" => 'pgsql:host=localhost;dbname=postgres',
"login" => 'postgres',
"mdp" => 'root'],
"templates" => ["index" => 'vues/index.php',
"pseudo" => 'pseudo.html',
"jouer" => "jouer.html",
"pendu" => "pendu.html",
"penduScore" => 'penduScore.html',
"scienceQuizz" => 'scienceQuizz.html',
"scienceQuizzReponse" => 'scienceQuizzReponse.html',
"scienceQuizzRecap" => 'scienceQuizzRecap.html',]
];

@ -0,0 +1,137 @@
<?php
namespace controller;
use config\Validation;
use Exception;
use PDOException;
use model\MdlDifficulte;
use model\MdlScientifique;
use model\MdlSexe;
use model\MdlThematique;
use model\Scientifique;
//gerer la connexion des admins
class AdminController {
public function defaultAction(array $params) {
global $twig;
echo $twig->render('admin/accueil.html');
}
public function notLogged(array $params) {
global $twig;
//dire acces interdit aux non admins
$dVueErreur[] = 'Erreur 403 : Accès interdit !';
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
}
public function stats(array $params) {
global $twig;
echo $twig->render('admin/stats.html');
}
public function ajouterScientifiques(array $params) {
global $twig;
$sexe = new MdlSexe();
$theme = new MdlThematique();
$diff = new MdlDifficulte();
$scient=null;
if(!empty($_POST)){
$id=0;
if(isset($_GET["id"])){
$id=intval($_GET["id"]);
}
try{
$this->verifierDonnees();
} catch (Exception $ex){
$dVueErreur[] = 'Erreur : '.$ex;
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
return;
}
$sci = new Scientifique(
$id,
$_POST["name"],
$_POST["prenom"],
$_POST["url"],
\DateTime::createFromFormat("Y-m-d", $_POST["date"]),
$_POST["description"],
0,
$theme->getFromId(intval($_POST["theme"])),
$diff->getFromId(intval($_POST["difficulte"])),
$sexe->getFromId(intval($_POST["sexe"]))
);
$mdlsci=new MdlScientifique();
if(isset($_GET["id"])){
$mdlsci->editScientifique($sci);
} else {
$mdlsci->addScientifique($sci);
}
}
if(isset($_GET["id"])){
$scient=new MdlScientifique();
$scient=$scient->getScientifique($_GET["id"]);
}
echo $twig->render('admin/ajouterScientifiques.html',['sexe' => $sexe->getAll(), 'themes' => $theme->getAll(), 'difficultes' => $diff->getAll(), 'scientifique' => $scient]);
}
public function listeScientifiques(array $params) {
global $twig;
$ms = new MdlScientifique();
if (!isset($params['id'])) {
$page = 1;
} else {
$page = Validation::valPosInt($params['id']);
}
$dVue['listeScientifiques'] = $ms->getScientifiquesParPage($page);
$dVue['pageMax'] = $ms->getMaxPages();
$dVue['page'] = $page;
if ($page - 1 <= 0) {
$dVue['pagePrec'] = 1;
} else {
$dVue['pagePrec'] = $page - 1;
}
if ($page + 1 >= $dVue['pageMax']) {
$dVue['pageSuiv'] = $dVue['pageMax'];
} else {
$dVue['pageSuiv'] = $page + 1;
}
echo $twig->render('admin/listeScientifiques.html',['dVue' => $dVue]);
}
private function verifierDonnees(){
$sexe = new MdlSexe();
$theme = new MdlThematique();
$diff = new MdlDifficulte();
$selectTheme=$theme->getFromId(intval($_POST["theme"]));
$selectDiff=$diff->getFromId(intval($_POST["difficulte"]));
$selectSexe=$sexe->getFromId(intval($_POST["sexe"]));
//todo : verifier les données, mettre dans une fonction et try catch
if(strlen($_POST["name"]) < 2){
throw new Exception("nom trop court");
}
if(strlen($_POST["prenom"]) < 2){
throw new Exception("prénom trop court");
}
if(empty($_POST["url"])){
throw new Exception("pas de photo");
}
if(strlen($_POST["name"]) < 2){
throw new Exception("nom trop court");
}
if(strlen($_POST["description"]) < 20){
throw new Exception("description trop courte ");
}
if($selectTheme==null){
throw new Exception("thematique inconnue");
}
if($selectSexe==null){
throw new Exception("sexe inconnu");
}
if($selectDiff==null){
throw new Exception("difficulté inconnue");
}
}
}
?>

@ -0,0 +1,116 @@
<?php
namespace controller;
use AltoRouter;
use config\Validation;
use Exception;
use http\Params;
use model\ConfigurationJeu;
use model\Connection;
use model\LoginException;
use model\MdlAdmin;
use model\MdlDifficulte;
use model\MdlJeu;
use model\MdlUser;
use model\ValidationException;
use PDOException;
class FrontController
{
private Connection $con;
/**
* @throws Exception
*/
public function __construct()
{
global $twig, $router, $dVue;
global $basePath;
global $dVueErreur;
//altorouter
$router = new AltoRouter();
$router->setBasePath($basePath);
// Correspond à action = null et permet d'éviter une erreur sur la page /index.php
$router->map('GET|POST','/index.php','UserController');
$router->map('GET|POST','/pseudo/[a:action]?','_TO_DELETE__PseudoController');
$router->map('GET|POST','/admin/[a:action]?/[i:id]?','AdminController');
$router->map('GET|POST','/[a:action]?/[i:id]?','UserController');
try {
session_start();
} catch (Exception $e) {
die('Session start failed: ' . $e->getMessage());
}
$dVue['idAdmin'] = false;
$dVue['idUser'] = false;
if(isset($_SESSION['pseudo'])) {
$dVue['pseudo'] = $_SESSION['pseudo'];
if (isset($_SESSION['isUser']) && $_SESSION['isUser']) {
$dVue['isUser'] = true;
} elseif (isset($_SESSION['idAdmin']) && $_SESSION['idAdmin']) {
$dVue['isAdmin'] = true;
}
}
try {
$match = $router->match();
if (!$match) {
throw new Exception('Wrong call');
}
switch($match['target']) {
case 'UserController':
$this->callController('UserController',$match);
break;
case 'AdminController':
$action = $match['params']['action'] ?? '';
if (!MdlAdmin::isAdmin()) {
$match['params']['action'] = 'notLogged';
}
$this->callController('AdminController',$match);
break;
case '_TO_DELETE__PseudoController':
$this->callController('_TO_DELETE__PseudoController',$match);
break;
//mauvaise action
default:
$dVueErreur[] = "Erreur d'appel php";
echo $twig->render('accueil.html', ['dVueErreur' => $dVueErreur]);
break;
}
} catch (LoginException $e) {
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
echo $twig->render('login.html');
} catch (Exception $e2) {
$dVueErreur[] = 'Erreur inattendue !';
$dVueErreur[] = $e2->getMessage();
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
}
exit(0);
}
private function callController(string $cont, array $match) {
global $twig;
$controller = '\\controller\\'.$cont;
$controller = new $controller;
$action = $match['params']['action'] ?? 'defaultAction';
if (is_callable(array($controller,$action))) {
call_user_func_array(array($controller,$action),array($match['params']));
} else {
echo $twig->render('erreur.html', ['dVueErreur' => array('Page inconnue')]);
}
}
}

@ -0,0 +1,157 @@
<?php
namespace controller;
use config\Validation;
use Exception;
use model\ConfigurationJeu;
use model\Connection;
use model\LoginException;
use model\MdlAdmin;
use model\MdlDifficulte;
use model\MdlJeu;
use model\MdlScientifique;
use model\MdlUser;
use model\PseudoDejaPrisException;
use model\ValidationException;
class InviteController
{
public function defaultAction(array $params) {
global $twig, $dVue;
echo $twig->render('accueil.html', ["dVue"=>$dVue]);
}
public function historique(array $params) {
global $twig;
global $dVueErreur;
global $dVue;
$ms = new MdlScientifique();
if (!isset($params['id'])) {
$page = 1;
} else {
$page = Validation::valPosInt($params['id']);
}
$pseudo = Validation::valPseudo($_SESSION['pseudo'],$dVueErreur);
$dVue['listeScientifiques'] = $ms->getHistoriqueParPage($pseudo,$page);
$dVue['pageMax'] = $ms->getMaxPagesHistorique($pseudo);
$dVue['page'] = $page;
if ($page - 1 <= 0) {
$dVue['pagePrec'] = 1;
} else {
$dVue['pagePrec'] = $page - 1;
}
if ($page + 1 >= $dVue['pageMax']) {
$dVue['pageSuiv'] = $dVue['pageMax'];
} else {
$dVue['pageSuiv'] = $page + 1;
}
echo $twig->render('historique.html',['dVue' => $dVue]);
}
public function joinParty(array $params) {
global $twig;
if(isset($_POST['codeInvitation'])){
$codeInvitation = $_POST['codeInvitation'];
Validation::valCodeInvitation($codeInvitation, $dVueErreur);
echo $twig->render('join.html');
}
}
/**
* @throws Exception
*/
public function jouer(array $params) {
global $twig, $config;
$dVue = [];
$dVueErreur = [];
if(isset($_SESSION["configuration"]) && isset($_SESSION['role'])){
try{
$role = $_SESSION['role'];
$role = Validation::valRole($role, $dVueErreur);
$configurationJeu = $_SESSION['configuration'];
$configurationJeu = Validation::valConfigurationJeu($configurationJeu, $dVueErreur);
}catch(ValidationException $e){
header('Location: .');
}
if(count($dVueErreur) == 0){
$idJeu = $configurationJeu->getJeu()->getId();
switch($idJeu){
case 2:
new _TO_DELETE__ScienceQuizzController($role, $configurationJeu);
break;
case 3:
new _TO_DELETE__PenduController($role, $configurationJeu);
break;
default:
throw new Exception("Jeu non défini !");
}
}
}else{
header("Location: .");
}
}
public function createParty(array $params) : void
{
global $twig;
global $dVueErreur;
$listJeu = (new MdlJeu())->getAll();
$listDifficulte = (new MdlDifficulte())->getAll();
$dVueCreateJeu = [];
foreach($listJeu as $jeu){
$dVueCreateJeu[] = ['id' => $jeu->getId(), 'nom' => $jeu->getNom()];
}
$dVueCreateDifficulte = [];
foreach($listDifficulte as $difficulte){
$dVueCreateDifficulte[] = ['id' => $difficulte->getId(), 'libelle' => $difficulte->getLibelle()];
}
echo $twig->render('create.html', ["dVueErreur" => $dVueErreur, 'dVueCreate' => ["jeux" => $dVueCreateJeu, "difficultes" => $dVueCreateDifficulte]]);
}
public function ValidationFormulaire(array $params)
{
global $twig;
global $dVue;
global $dVueErreur;
global $basePath;
$id_jeu = $_POST['jeu'] ?? '';
$id_difficulte = $_POST['difficulte'] ?? '';
try{
Validation::val_form($id_jeu, $id_difficulte, $dVueErreur);
}catch (ValidationException|Exception $ex){
$this->CreateParty($dVueErreur);
}
if(count($dVueErreur) == 0){
$jeu = (new MdlJeu())->getFromId($id_jeu);
$difficulte = (new MdlDifficulte())->getFromId($id_difficulte);
$_SESSION['configuration'] = new ConfigurationJeu($jeu, $difficulte);
if(isset($_SESSION['role'])){
header('Location: '.$basePath.'/jouer');
}else{
header("Location: ".$basePath."/pseudo");
}
#echo $twig->render('accueil.html', ['dVue' => $dVue, 'dVueErreur' => $dVueErreur]);
}else{
$this->CreateParty($dVueErreur);
}
}
}

@ -0,0 +1,96 @@
<?php
namespace controller;
use config\Validation;
use Exception;
use model\ConfigurationJeu;
use model\Connection;
use model\GameGateway;
use model\Joueur;
use model\MdlDifficulte;
use model\MdlJeu;
use model\MdlScientifique;
use model\PseudoDejaPrisException;
use model\ValidationException;
use model\MdlUser;
use model\MdlAdmin;
use model\LoginException;
use model\Utilisateur;
class UserController extends InviteController {
public function listerLesScientifiquesDecouverts() {
}
public function afficherDetailScientifique() {
}
public function login() {
global $twig;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
Validation::valUserLogin($_REQUEST['login'], $dVueErreur);
$ug = new MdlUser();
if ($ug->login($_REQUEST['login'], $_REQUEST['password'])) {
$_SESSION['pseudo'] = $_REQUEST['login'];
$_SESSION['idUser'] = true;
$_SESSION['isLogged'] = true;
$_SESSION['role'] = $ug->getFromEmail($_REQUEST['login']);
header("Location: .");
} else {
//voir si c'est un admin
$ug = new MdlAdmin();
if ($ug->login($_REQUEST['login'], $_REQUEST['password'])) {
$_SESSION['pseudo'] = $_REQUEST['login'];
$_SESSION['isAdmin'] = true;
$_SESSION['isLogged'] = true;
unset($_SESSION['role']);
header("Location: .");
} else {
$dVueErreur[] = "Connexion échouée";
throw new LoginException("Connexion err");
}
}
} else {
echo $twig->render('login.html');
}
}
public function register() {
global $twig, $dVueErreur;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if($_REQUEST['password']!=$_REQUEST['cpassword']){
$dVueErreur[]="Mots de passe différents.";
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
return;
}
$ug = new MdlUser();
try{
if($ug->register($_REQUEST['login'], $_REQUEST['password'])){
header('Location: login');
} else {
$dVueErreur[]="Erreur de création de compte. Le compte doit déjà exister.";
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
}
} catch (PseudoDejaPrisException $ex){
$dVueErreur[]="Erreur de création de compte. Le compte existe déjà.";
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
}catch(Exception $ex){
$dVueErreur[]="Erreur de création de compte.";
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
}
} else {
echo $twig->render('register.html');
}
}
public function logout(){
session_destroy();
$_SESSION=[];
header("Location: .");
}
}

@ -0,0 +1,46 @@
<?php
namespace controller;
use config\Validation;
use Exception;
use model\ValidationException;
class _TO_DELETE__JouerController{
/**
* @throws Exception
*/
public function __construct(){
global $twig, $config;
global $dVue;
global $dVueErreur;
global $basePath;
if(isset($_SESSION["configuration"]) && isset($_SESSION['role'])){
try{
$role = $_SESSION['role'];
$role = Validation::valRole($role, $dVueErreur);
$configurationJeu = $_SESSION['configuration'];
$configurationJeu = Validation::valConfigurationJeu($configurationJeu, $dVueErreur);
}catch(ValidationException $e){
header('Location: '.$basePath);
}
if(count($dVueErreur) == 0){
$idJeu = $configurationJeu->getJeu()->getId();
switch($idJeu){
case 2:
new _TO_DELETE__ScienceQuizzController($role, $configurationJeu);
break;
case 3:
new _TO_DELETE__PenduController($role, $configurationJeu);
break;
default:
throw new Exception("Jeu non défini !");
}
}
}else{
header("Location: ".$basePath);
}
}
}

@ -0,0 +1,133 @@
<?php
namespace controller;
use Exception;
use model\ConfigurationJeu;
use model\Joueur;
use model\MdlPendu;
use model\MdlScientifique;
use config\Validation;
use model\MdlUser;
use model\Utilisateur;
use model\ValidationException;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
class _TO_DELETE__PenduController{
private array $dVue;
private Joueur $role;
private array $dVueErreur;
private MdlPendu $pendu;
/**
* @throws Exception
*/
public function __construct(Joueur $role, ConfigurationJeu $configJeu)
{
$this->role=$role;
$this->dVue = [];
$this->dVueErreur = [];
if(isset($_SESSION['pendu']) && Validation::valMdlPendu($_SESSION['pendu'], $this->dVueErreur)){
$this->pendu = $_SESSION['pendu'];
}else{
$this->reinit();
}
if(isset($_POST['lettre'])){
try{
$this->pendu->jouerLettre($_POST['lettre']);
}catch (ValidationException $e){
$this->dVueErreur[] = $e->getMessage();
}
}
if($this->pendu->aGagne()){
$this->renderAgagne();
}elseif($this->pendu->aPerdu()){
$this->renderAPerdu();
}else{
$this->renderJeu();
}
}
/**
* @throws Exception
*/
private function reinit(){
$mdlScientifique = new MdlScientifique();
$scientifique = $mdlScientifique->getRandom();
$this->pendu = new MdlPendu($scientifique);
$_SESSION['pendu'] = $this->pendu;
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
private function renderJeu(){
global $twig, $config;
$this->dVue['decouvert'] = $this->pendu->getDecouvert();
$this->dVue['essaisRestant'] = $this->pendu->getEssaisRestant();
$lettreUtilisees = $this->pendu->getLettreUtilisees();
sort($lettreUtilisees);
$this->dVue['lettresUtilisees'] = $lettreUtilisees;
echo $twig->render($config['templates']['pendu'], ['dVue' => $this->dVue, 'dVueErreur'=>$this->dVueErreur]);
}
private function ajouterScientifiqueDecouvert(){
if($this->role instanceof Utilisateur){
try{
(new MdlUser())->addScientifiqueDecouvert($this->role->getId(), $this->pendu->getScientifique()->getId());
}
catch(ValidationException $e){
$this->dVueErreur[] = $e->getMessage();
}
}
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
private function renderAgagne(){
$this->dVue['messageScore'] = "Vous avez gagné !";
$this->ajouterScientifiqueDecouvert();
$this->renderScore();
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
private function renderAPerdu(){
$this->dVue['messageScore'] = "Vous avez perdu !";
$this->renderScore();
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
private function renderScore(){
global $twig, $config;
$this->dVue['nbTours'] = $this->pendu->getNbTours();
$this->dVue['nbFails'] = $this->pendu->getNbFails();
$scientifique = $this->pendu->getScientifique();
$dScientifique = [];
$dScientifique['nom'] = $scientifique->getNom();
$dScientifique['prenom'] = $scientifique->getPrenom();
$dScientifique['sexe'] = $scientifique->getSexe()->getLibelle();
$dScientifique['thematique'] = $scientifique->getThematique()->getLibelle();
$dScientifique['dateNaiss'] = $scientifique->getDateNaiss()->format('d/m/Y');
$this->dVue['scientifique'] = $dScientifique;
unset($_SESSION['pendu']);
echo $twig->render($config['templates']['penduScore'], ["dVue" => $this->dVue]);
}
}

@ -0,0 +1,44 @@
<?php
namespace controller;
use config\Validation;
use model\IdSessionDoubleException;
use model\PseudoDejaPrisException;
use model\ValidationException;
use model\MdlInvite;
class _TO_DELETE__PseudoController{
public function defaultAction(){
global $twig, $config;
global $basePath;
$dVue = [];
$dVueErreur = [];
if(isset($_POST["pseudo"])){
try{
$mdlInvite = new MdlInvite();
$pseudo = $_POST["pseudo"];
$pseudo = Validation::valPseudo($pseudo, $dVueErreur);
$role = $mdlInvite->insertInvite($pseudo, session_id());
}catch(ValidationException $e){
}catch(PseudoDejaPrisException $e){
$dVueErreur[] = "Pseudo déjà pris";
}catch(IdSessionDoubleException $e){
try{
$role = $mdlInvite->setPseudo($e->getIdJoueur(), $pseudo);
}catch(PseudoDejaPrisException $e){
$dVueErreur[] = "Pseudo déjà pris";
}
}
if(isset($role)){
$_SESSION['role'] = $role;
header('Location: '.$basePath.'/jouer');
}
}
echo $twig->render($config['templates']['pseudo'], ["dVue" => $dVue, "dVueErreur" => $dVueErreur]);
}
}

@ -0,0 +1,132 @@
<?php
namespace controller;
use Exception;
use model\ConfigurationJeu;
use model\Connection;
use model\Joueur;
use model\MdlScienceQuizz;
use model\MdlScientifique;
use config\Validation;
use model\ScientifiqueGateway;
use model\ValidationException;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
class _TO_DELETE__ScienceQuizzController
{
private array $dVue;
private array $dVueErreur;
private MdlScienceQuizz $scienceQuizz;
private Connection $con;
/**
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
* @throws Exception
*/
public function __construct(Joueur $role, ConfigurationJeu $configJeu)
{
$this->dVue = [];
$this->dVueErreur = [];
if (isset($_SESSION['scienceQuizz']) && Validation::valMdlScienceQuizz($_SESSION['scienceQuizz'], $this->dVueErreur)) {
$this->scienceQuizz = $_SESSION['scienceQuizz'];
} else {
$this->reInit();
}
if ($this->scienceQuizz->partieTerminee()) {
$this->vueRecap();
}
else {
$this->vueJeu();
}
}
/**
* @throws Exception
*/
private function reInit()
{
$mdlScientifique = new MdlScientifique();
$scientifique = $mdlScientifique->getRandom();
$idScientifique = $scientifique->getId();
$questions = $mdlScientifique->getQuestions($idScientifique);
$this->scienceQuizz = new MdlScienceQuizz($idScientifique,$questions);
$_SESSION['scienceQuizz'] = $this->scienceQuizz;
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
private function vueJeu()
{
global $twig, $config;
$dStatJeu['numQuestion'] = $this->scienceQuizz->getNumQuestion();
$questions = $this->scienceQuizz->getQuestions();
if ($questions) {
$dStatJeu['question'] = $this->scienceQuizz->getRandomQuestion($questions);
} else {
// Gérer le cas où aucune question n'est disponible
$this->dVueErreur[] = "Aucune question disponible.";
echo $twig->render('erreur.html', ['dVueErreur' => $this->dVueErreur]);
return;
}
$this->dVue['statJeu'] = $dStatJeu;
echo $twig->render($config['templates']['scienceQuizz'], ['dVue' => $this->dVue, 'dVueErreur' => $this->dVueErreur]);
?>
<script>
setTimeout(function() {
window.location.href = "/scienceQuizzReponse.html";
}, 30000);
</script>
<?php
}
/**
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
private function vueReponse()
{
global $twig, $config;
$dScientifique['nom'] = $this->scienceQuizz->getNom();
$dScientifique['prenom'] = $this->scienceQuizz->getPrenom();
$dScientifique['dateNaissance'] = $this->scienceQuizz->getDateNaissance();
$this->dVue['scientifique'] = $dScientifique;
echo $twig->render($config['templates']['scienceQuizzReponse'], ["dVue" => $this->dVue]);
}
/**
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
private function vueRecap()
{
global $twig, $config;
$dStatJoueur ['bonneReponse'] = $this->scienceQuizz->getBonneReponse();
$dStatJoueur ['nbPoints'] = $this->scienceQuizz->getNbPoints();
$this->dVue['statJoueur'] = $dStatJoueur;
unset($_SESSION['scienceQuizz']);
echo $twig->render($config['templates']['scienceQuizzRecap'], ["dVue" => $this->dVue]);
}
}

@ -0,0 +1,197 @@
-- Testé sous pgsql 15
DROP TABLE IF EXISTS Reponse;
DROP TABLE IF EXISTS Question;
DROP TABLE IF EXISTS Admin;
DROP TABLE IF EXISTS Partie;
DROP TABLE IF EXISTS Jeu;
DROP TABLE IF EXISTS Decouvrir;
DROP TABLE IF EXISTS Utilisateur;
DROP TABLE IF EXISTS Invite;
DROP TABLE IF EXISTS Joueur;
DROP TABLE IF EXISTS Indice;
DROP TABLE IF EXISTS Scientifique;
DROP TABLE IF EXISTS Thematique;
DROP TABLE IF EXISTS Difficulte;
DROP TABLE IF EXISTS Sexe;
-- THEMATIQUE
CREATE TABLE Thematique(
id SERIAL PRIMARY KEY,
libelle varchar(128) NOT NULL UNIQUE
);
-- DIFFICULTE
CREATE TABLE Difficulte(
id SERIAL PRIMARY KEY,
libelle varchar(128) NOT NULL UNIQUE
);
-- SEXE
CREATE TABLE Sexe(
id SERIAL PRIMARY KEY,
libelle varchar(128) NOT NULL UNIQUE
);
-- SCIENTIFIQUE
CREATE TABLE Scientifique(
id SERIAL PRIMARY KEY,
nom varchar(128) NOT NULL,
prenom varchar(128) NOT NULL,
photo varchar(512) NOT NULL,
dateNaissance date NOT NULL,
descriptif text NOT NULL,
ratioTrouvee numeric(5,4),
idThematique integer REFERENCES Thematique(id),
idDifficulte integer REFERENCES Difficulte(id),
idSexe integer REFERENCES Sexe(id)
);
-- INDICE
CREATE TABLE Indice(
id SERIAL PRIMARY KEY,
libelle varchar(512) NOT NULL UNIQUE,
idScientifique integer REFERENCES Scientifique(id)
);
-- QUESTION
CREATE TABLE Question(
id SERIAL PRIMARY KEY,
question varchar(256) NOT NULL UNIQUE
);
-- REPONSE
CREATE TABLE Reponse(
id SERIAL PRIMARY KEY,
reponse varchar(255) NOT NULL,
idQuestion integer REFERENCES Question(id),
idScientifique integer REFERENCES Scientifique(id)
);
-- ADMIN
CREATE TABLE Admin(
id SERIAL PRIMARY KEY,
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
);
-- JOUEUR
CREATE TABLE Joueur(
id SERIAL PRIMARY KEY,
pseudo varchar(255) NOT NULL UNIQUE
);
-- Invite
CREATE TABLE Invite(
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
idSession varchar(255) NOT NULL UNIQUE
);
-- Utilisateur
CREATE TABLE Utilisateur(
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
);
-- Decouvrir
CREATE TABLE Decouvrir(
idUtilisateur integer REFERENCES Utilisateur(idJoueur),
idScientifique integer REFERENCES Scientifique(id),
PRIMARY KEY (idUtilisateur, idScientifique)
);
-- Jeu
CREATE TABLE Jeu(
id SERIAL PRIMARY KEY,
nom varchar(128) NOT NULL UNIQUE,
nbrParties integer NOT NULL DEFAULT 0
);
-- Partie
CREATE TABLE Partie(
id SERIAL PRIMARY KEY,
codeInvitation varchar(10) NOT NULL UNIQUE,
idJoueur integer REFERENCES Joueur(id),
idJeu integer REFERENCES Jeu(id)
);
-- INSERTS
-- Scientifiques
INSERT INTO Difficulte(libelle) VALUES ('Facile'),('Intermédiaire'),('Difficile');
INSERT INTO Sexe(libelle) VALUES ('Homme'),('Femme');
INSERT INTO Thematique(libelle) VALUES ('Nucléaire'),('Mathématiques');
INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe)
VALUES
('Marie', 'Curie', '', CURRENT_DATE, 'desc', 0, 1, 1, 2),
('Albert', 'Einstein', '', CURRENT_DATE, 'desc', 0, 2, 1, 1),
('Sophie', 'Germain', '', CURRENT_DATE, 'desc', 0, 2, 2, 2);
-- Jeu
INSERT INTO Jeu(nom) VALUES ('Qui-est-ce ?'),('Science Quizz'), ('Pendu');
-- Questions
INSERT INTO Question(question)
VALUES
('Qui a reçu le prix Nobel de chimie en 1911, pour avoir réussi à isoler un gramme de radium ?'),
('Quel mathématicien a dit : « Dieu existe, cest les mathématiques » ?'),
('Quel mathématicienne utilisa comme nom d"emprunt « Antoine Auguste Le Blanc » ?');
-- Réponses
INSERT INTO Reponse(reponse, idQuestion, idScientifique)
VALUES
('Marie Curie', 1, 1),
('Albert Einstein', 2, 2),
('Sophie Germain', 3, 3);
-- Utilisateurs
INSERT INTO Joueur(id,pseudo) VALUES (1337, 'moi, le meilleur joueur du monde');
INSERT INTO Utilisateur(idJoueur,email,password) VALUES (1337, 'joueur','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
-- mdp = test
INSERT INTO decouvrir(idUtilisateur,idScientifique) VALUES (1337,1);
INSERT INTO Admin(id,email,password) VALUES (1, 'admin','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS');
-- mdp = test

@ -0,0 +1,22 @@
<?php
require_once(__DIR__.'/vendor/autoload.php');
require_once(__DIR__.'/config/config.php');
use controller\FrontController;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
//twig
$loader = new FilesystemLoader('templates');
$twig = new Environment($loader, [
'cache' => false,
]);
$basePath = preg_replace('/\/index.php/i', '', $_SERVER['PHP_SELF']);
// Tableau qui contient les messages d'erreur
$dVueErreur = [];
$dVue['basePath'] = $basePath;
$cont = new FrontController();

@ -0,0 +1,26 @@
<?php
namespace model;
use RuntimeException;
class IdSessionDoubleException extends RuntimeException
{
private int $idJoueur;
private string $idSession;
public function __construct($idJoueur, $idSession)
{
parent::__construct();
$this->idJoueur=$idJoueur;
$this->idSession=$idSession;
}
public function getIdJoueur():int{
return $this->idJoueur;
}
public function getIdSession(): string{
return $this->idSession;
}
}

@ -0,0 +1,9 @@
<?php
namespace model;
use Exception;
class LoginException extends Exception
{
}

@ -0,0 +1,10 @@
<?php
namespace model;
use RuntimeException;
class PseudoDejaPrisException extends RuntimeException
{
}

@ -0,0 +1,7 @@
<?php
namespace model;
use RuntimeException;
class ValidationException extends RuntimeException{
}

@ -0,0 +1,122 @@
<?php
namespace model;
use PDO;
use PDOStatement;
class AdminGateway
{
private Connection $con;
public function __construct(Connection $con)
{
$this->con=$con;
}
public function login(string $email, string $password): bool
{
$sql = "SELECT * FROM Admin WHERE email=:email";
$this->con->executeQuery($sql, array(
':email' => array($email, PDO::PARAM_STR)
));
$result = $this->con->getOneResult();
if (!empty($result)) {
return password_verify($password,$result['password']);
}
return false;
}
public function addUser(string $email, string $password): void
{
$sql = "INSERT INTO Admin (email, password) VALUES (:email, :password)";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
$stmt->execute();
}
public function deleteUser(int $id): void
{
$sql = "DELETE FROM Admin WHERE id=:id";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
}
public function updateUser(int $id, string $email, string $password): void
{
$sql = "UPDATE Admin SET email=:email, password=:password WHERE id=:id";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':email', $email);
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
$stmt->execute();
}
public function getUser(int $id): Admin
{
$sql = "SELECT * FROM Admin WHERE id=:id";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
$result = $stmt->fetch();
return new Admin($result['id'], $result['email'], $result['password']);
}
public function getUsers(): array
{
$sql = "SELECT * FROM Admin";
$stmt = $this->con->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll();
$users = [];
foreach ($result as $user) {
$users[] = new Admin($user['id'], $user['email'], $user['password']);
}
return $users;
}
public function getHashedPasswordById(int $id): string
{
$sql = "SELECT password FROM Admin WHERE id=:id";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
$result = $stmt->fetch();
return $result['password'];
}
public function getHashedPassword(int $email): string
{
$sql = "SELECT password FROM Admin WHERE email=:email";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->execute();
$result = $stmt->fetch();
return $result['password'];
}
public function getUserId(string $email): int
{
$sql = "SELECT id FROM Admin WHERE email=:email";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->execute();
$result = $stmt->fetch();
return $result['id'];
}
public function getUserByEmailAndPassword(string $email, string $password): Admin
{
$sql = "SELECT * FROM Admin WHERE email=:email AND password=:password";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
$stmt->execute();
$result = $stmt->fetch();
return new Admin($result['id'], $result['email'], $result['password']);
}
public function getFromEmail(string $email): array
{
$this->con->executeQuery(
"SELECT id, email, password FROM Admin WHERE email = :email;",
[":pseudo" => [$email, $this->con::PARAM_STR]]
);
return $this->con->getOneResult();
}
}

@ -0,0 +1,63 @@
<?php
namespace model;
use Exception;
use PDO;
use PDOException;
use PDOStatement;
class Connection extends PDO {
private PDOStatement $stmt;
public function __construct(string $dsn, string $username, string $password) {
try {
parent::__construct($dsn, $username, $password);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
}
/** *
* @param string $query
* @param array $params
* @return bool|null Returns `true` on success, `false` otherwise
*/
/**
* @param string $query
* @param array $params
* @return PDOStatement|false Returns `PDOStatement` on success, `false` otherwise
* @throws Exception
*/
public function executeQuery(string $query, array $params = [])
{
try {
$stmt = $this->prepare($query);
foreach ($params as $param => $value) {
$stmt->bindValue($param, $value[0], $value[1]);
}
$stmt->execute();
$this->stmt = $stmt;
return $stmt;
} catch (PDOException $e) {
throw new Exception($e->getMessage());
}
}
public function getResults() : array {
return $this->stmt->fetchall();
}
public function getOneResult() {
return $this->stmt->fetch();
}
}

@ -0,0 +1,24 @@
<?php
namespace model;
class DifficulteGateway
{
private Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
public function getAll() : array
{
$this->con->executeQuery("SELECT id, libelle FROM Difficulte;");
return $this->con->getResults();
}
public function getFromId(int $id): array
{
$this->con->executeQuery("SELECT id, libelle FROM Difficulte WHERE id=:id;",
[':id' => [$id, $this->con::PARAM_INT]]);
return $this->con->getOneResult();
}
}

@ -0,0 +1,20 @@
<?php
namespace model;
class IndiceGateway
{
public function __construct(Connection $con)
{
}
public function getFromId(int $id) : array {
}
public function getFromScientifique(int $idScientifique) : array {
}
}

@ -0,0 +1,68 @@
<?php
namespace model;
class InviteGateway extends JoueurGateway
{
function __construct(Connection $con) {
parent::__construct($con);
}
// public function getFromIdSession($idSession): array|bool // <- Seulement autorisé en PHP 8 /!\ (on est en 7.4)
// {
// $this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
// [":idSession" => [$idSession, $this->con::PARAM_STR]]);
// return $this->con->getOneResult();
// }
/**
* @param string $idSession
* @return array|bool
*/
public function getFromIdSession(string $idSession) { // <- PHP 7.4
$this->con->executeQuery(
"SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
[":idSession" => [$idSession, $this->con::PARAM_STR]]
);
return $this->con->getOneResult();
}
// public function getFromId($id): array|bool // <- Seulement autorisé en PHP 8 /!\ (on est en 7.4)
// {
// $this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
// [":id" => [$id, $this->con::PARAM_INT]]);
// return $this->con->getOneResult();
// }
/**
* @param int $id
* @return array|bool
*/
public function getFromId(int $id) { // <- PHP 7.4
$this->con->executeQuery(
"SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
[":id" => [$id, $this->con::PARAM_INT]]
);
return $this->con->getOneResult();
}
public function insertInvite(string $pseudo, string $idSession): int{
$row = $this->getFromIdSession($idSession);
if($row){
throw new IdSessionDoubleException($row['idjoueur'], $row['idsession']);
}else{
$id = $this->insertJoueur($pseudo);
$this->con->executeQuery("INSERT INTO Invite(idJoueur, idSession) VALUES(:id, :idSession);",
[":id" => [$id, $this->con::PARAM_INT],
":idSession" => [$idSession, $this->con::PARAM_STR]]);
return $id;
}
}
public function supprimerInvite(int $id) : bool {
}
}

@ -0,0 +1,24 @@
<?php
namespace model;
class JeuGateway
{
private Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
public function getAll() : array
{
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu;");
return $this->con->getResults();
}
public function getFromId(int $id): array
{
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu WHERE id=:id;",
[':id' => [$id, $this->con::PARAM_INT]]);
return $this->con->getOneResult();
}
}

@ -0,0 +1,51 @@
<?php
namespace model;
class JoueurGateway
{
protected Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
// protected function getFromPseudo($pseudo): array|bool <- autorisé seulement en PHP 8
// {
// $this->con->executeQuery("SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;",
// [":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
// return $this->con->getOneResult();
// }
/**
* @param string $pseudo
* @return array|bool
*/
public function getFromPseudo(string $pseudo) { // <- PHP 7.4
$this->con->executeQuery(
"SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;",
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]
);
return $this->con->getOneResult();
}
public function insertJoueur(string $pseudo): int{
if($this->getFromPseudo($pseudo)){
throw new PseudoDejaPrisException();
}else{
$this->con->executeQuery("INSERT INTO Joueur(pseudo) VALUES(:pseudo);",
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
return $this->getFromPseudo($pseudo)["id"];
}
}
public function setPseudo(int $id, string $pseudo){
if($this->getFromPseudo($pseudo)){
throw new PseudoDejaPrisException();
}else{
$this->con->executeQuery("UPDATE Joueur SET pseudo=:pseudo WHERE id=:id",
[":pseudo" => [$pseudo, $this->con::PARAM_STR],
":id" => [$id, $this->con::PARAM_INT]]);
}
}
}

@ -0,0 +1,31 @@
<?php
namespace model;
class PartieGateway
{
public function __construct(Connection $con)
{
}
public function getFromId(int $id) : Partie {
}
public function getFromCodeInvitation(string $code) : Partie {
}
public function creerPartie(Jeu $jeu, Joueur $joueur) : Partie {
}
public function rejoindrePartie(string $codeInvitation, Joueur $joueur) : bool {
}
public function supprimerPartie(int $id) : bool {
}
}

@ -0,0 +1,20 @@
<?php
namespace model;
class QuestionGateway
{
public function __construct(Connection $con)
{
}
public function getRandom() : Question {
}
public function getFromId(int $id) : Question {
}
}

@ -0,0 +1,20 @@
<?php
namespace model;
class ReponseGateway
{
public function __construct(Connection $con)
{
}
public function getFromId(int $id) : Reponse {
}
public function getFromQuestion(int $idQuestion) : array {
}
}

@ -0,0 +1,164 @@
<?php
namespace model;
use Exception;
class ScientifiqueGateway
{
private Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
public function getFromId(int $id) : array {
}
// public function getRandom(): array|bool{ <- autorisé seulement en PHP 8
// $this->con->executeQuery(
// "SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, index FROM Scientifique ORDER BY RANDOM() LIMIT 1;");
// return $this->con->getOneResult();
// }
/**
* @return array|bool
* @throws Exception
*/
public function getRandom() { // PHP 7.4
$this->con->executeQuery(
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;"
);
return $this->con->getOneResult();
}
public function getRandomFromDifficulte(Difficulte $difficulte) : array {
}
/**
* @throws Exception
*/
public function addScientifique(Scientifique $sci): bool{
return $this->con->executeQuery(
"INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe) VALUES (:nom, :prenom, :photo, :dateNaissance, :descriptif, :ratioTrouvee, :idThematique, :idDifficulte, :idSexe);"
,[
":nom"=>[$sci->getNom(),$this->con::PARAM_STR],
":prenom"=>[$sci->getPrenom(),$this->con::PARAM_STR],
":photo"=>[$sci->getPhoto(),$this->con::PARAM_STR],
":dateNaissance"=>[date("Y-m-d H:i:s", $sci->getDateNaiss()->getTimestamp()),$this->con::PARAM_STR],
":descriptif"=>[$sci->getDescriptif(),$this->con::PARAM_STR],
":ratioTrouvee"=>[$sci->getRatioTrouvee(),$this->con::PARAM_STR],
":idThematique"=>[$sci->getThematique()->getId(),$this->con::PARAM_STR],
":idDifficulte"=>[$sci->getDifficulte()->getId(),$this->con::PARAM_STR],
":idSexe"=>[$sci->getSexe()->getId(),$this->con::PARAM_STR]
]) ? true : false ;
}
public function getScientifiquesParPages(int $currentPage, int $nbElemByPage) : array {
$query = 'SELECT * FROM Scientifique LIMIT :nbElem OFFSET :ind ';
$index = ($currentPage-1)*$nbElemByPage;
$this->con->executeQuery($query,array(
':ind' => array($index,\PDO::PARAM_INT),
':nbElem' => array($nbElemByPage,\PDO::PARAM_INT)
));
return $this->con->getResults();
}
public function getHistorique(string $pseudoJoueur, int $currentPage, int $nbElemByPage) : array {
if($currentPage == 0) $currentPage = 1;
$query = 'SELECT s.*
FROM Scientifique s, Decouvrir d, Utilisateur u
WHERE s.id = d.idscientifique
AND d.idutilisateur = u.idJoueur
AND u.email = :pseudo
LIMIT :nbElem OFFSET :ind ';
$index = ($currentPage-1)*$nbElemByPage;
$this->con->executeQuery($query,array(
':ind' => array($index,\PDO::PARAM_INT),
':nbElem' => array($nbElemByPage,\PDO::PARAM_INT),
':pseudo' => array($pseudoJoueur,\PDO::PARAM_STR)
));
return $this->con->getResults();
}
public function getNbScientifique() : int {
$query = 'SELECT DISTINCT count(*) as val FROM Scientifique';
$this->con->executeQuery($query);
return $this->con->getResults()[0]['val'];
}
public function getNbScientifiqueHistorique(string $pseudoJoueur) : int {
$query = 'SELECT count(*) as val
FROM Scientifique s, Decouvrir d, Utilisateur u
WHERE s.id = d.idscientifique
AND d.idutilisateur = u.idJoueur
AND u.email = :pseudo';
$params = array(
':pseudo' => array($pseudoJoueur,\PDO::PARAM_STR)
);
$this->con->executeQuery($query,$params);
return $this->con->getResults()[0]['val'];
}
/**
* @throws Exception
*/
public function editScientifique(Scientifique $sci): bool{
return $this->con->executeQuery(
"UPDATE Scientifique SET nom = :nom, prenom = :prenom, photo = :photo, dateNaissance = :dateNaissance, descriptif = :descriptif, ratioTrouvee = :ratioTrouvee, idThematique = :idThematique, idDifficulte = :idDifficulte, idSexe = :idSexe WHERE id=:id;"
,[
":nom"=>[$sci->getNom(),$this->con::PARAM_STR],
":prenom"=>[$sci->getPrenom(),$this->con::PARAM_STR],
":photo"=>[$sci->getPhoto(),$this->con::PARAM_STR],
":dateNaissance"=>[date("Y-m-d H:i:s", $sci->getDateNaiss()->getTimestamp()),$this->con::PARAM_STR],
":descriptif"=>[$sci->getDescriptif(),$this->con::PARAM_STR],
":ratioTrouvee"=>[$sci->getRatioTrouvee(),$this->con::PARAM_STR],
":idThematique"=>[$sci->getThematique()->getId(),$this->con::PARAM_STR],
":idDifficulte"=>[$sci->getDifficulte()->getId(),$this->con::PARAM_STR],
":idSexe"=>[$sci->getSexe()->getId(),$this->con::PARAM_STR],
":id"=>[$sci->getId(),$this->con::PARAM_INT]
]) ? true : false ;
}
/**
* @throws Exception
*/
public function deleteScientifique(int $id): bool{
return $this->con->executeQuery(
"DELETE FROM Scientifique WHERE id=:id;"
,[
":id"=>[$id,$this->con::PARAM_INT]
]);
}
/**
* @throws Exception
*/
public function getScientifique(int $id) {
$this->con->executeQuery(
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe FROM Scientifique WHERE id=:id;"
,[
":id"=>[$id,$this->con::PARAM_INT]
]);
return $this->con->getOneResult();
}
/**
* @throws Exception
*/
public function getQuestions(int $idScientifique): array
{
$query = "SELECT q.* FROM Question q
JOIN Reponse r ON q.id = r.idQuestion
WHERE r.idScientifique = :idScientifique
ORDER BY RANDOM() LIMIT 5";
$params = [":idScientifique" => [$idScientifique, $this->con::PARAM_INT]];
$this->con->executeQuery($query, $params);
return $this->con->getResults();
}
}

@ -0,0 +1,29 @@
<?php
namespace model;
class SexeGateway
{
private Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
public function getFromId(int $id): array
{
$this->con->executeQuery("SELECT id, libelle FROM Sexe WHERE id=:id;",
[':id' => [$id, $this->con::PARAM_INT]]);
return $this->con->getOneResult();
}
public function getAll(): array
{
$this->con->executeQuery("SELECT id, libelle FROM Sexe;");
return $this->con->getResults();
}
public function getFromScientifique(int $idScientifique) : array {
}
}

@ -0,0 +1,28 @@
<?php
namespace model;
class ThematiqueGateway
{
private Connection $con;
function __construct(Connection $con) {
$this->con = $con;
}
public function getFromId(int $id): array
{
$this->con->executeQuery("SELECT id, libelle FROM Thematique WHERE id=:id;",
[':id' => [$id, $this->con::PARAM_INT]]);
return $this->con->getOneResult();
}
public function getAll(): array
{
$this->con->executeQuery("SELECT id, libelle FROM Thematique;");
return $this->con->getResults();
}
public function getFromScientifique(int $idScientifique) : array {
}
}

@ -0,0 +1,59 @@
<?php
namespace model;
class UtilisateurConnecteGateway extends JoueurGateway {
function __construct(Connection $con) {
$this->con = $con;
}
public function login(string $email, string $password): bool
{
$sql = "SELECT * FROM Utilisateur WHERE email=:email";
$this->con->executeQuery($sql, array(
':email' => array($email, \PDO::PARAM_STR)
));
$result = $this->con->getOneResult();
if (!empty($result)) {
return password_verify($password,$result['password']);
}
return false;
}
public function register(string $email, string $password, int $idjoueur): bool
{
$sql = "INSERT INTO Utilisateur(email, password,idjoueur) VALUES (:email,:password,:idjoueur);";
return $this->con->executeQuery($sql, [
':email' => array($email, \PDO::PARAM_STR),
':password' => array(password_hash($password, PASSWORD_BCRYPT), \PDO::PARAM_STR),
':idjoueur' => array($idjoueur, \PDO::PARAM_INT)
]
);
}
public function getFromId(int $id){
$this->con->executeQuery(
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE id = :id;",
[":id" => [$id, $this->con::PARAM_INT]]
);
return $this->con->getOneResult();
}
public function getFromEmail(string $email){
$this->con->executeQuery(
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE email = :email;",
[":email" => [$email, $this->con::PARAM_STR]]
);
return $this->con->getOneResult();
}
public function addScientifiqueDecouvert(int $idUtilisateur, int $idScientifique){
$this->con->executeQuery(
"INSERT INTO Decouvrir(idUtilisateur, idScientifique) VALUES (:idUtilisateur, :idScientifique);",
[":idUtilisateur" => [$idUtilisateur, $this->con::PARAM_INT],
":idScientifique" => [$idScientifique, $this->con::PARAM_INT]]
);
}
}

@ -0,0 +1,46 @@
<?php
namespace model;
class MdlAdmin extends MdlBase{
private AdminGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new AdminGateway($this->con);
}
public function login(string $username, string $password): bool{
if ($this->gw->login($username, $password)) {
$_SESSION['pseudo'] = $username;
$_SESSION['admin'] = true;
return true;
}
return false;
}
public static function isAdmin(): bool
{
if(!isset($_SESSION['admin'])
|| !$_SESSION['admin']
|| !isset($_SESSION['pseudo'])
|| $_SESSION['pseudo'] == null) {
return false;
}
return true;
}
public static function logout() {
global $basePath;
session_unset();
session_destroy();
$_SESSION = array();
header("Location: .");
}
public function getFromEmail(string $email): Admin{
$row = $this->gw->getFromEmail($email);
return new Admin($row['id'], $row['email'], $row['password']);
}
}

@ -0,0 +1,13 @@
<?php
namespace model;
abstract class MdlBase{
protected Connection $con;
public function __construct()
{
global $config;
$this->con = new Connection($config["db"]["dsn"], $config["db"]["login"], $config["db"]["mdp"]);
}
}

@ -0,0 +1,25 @@
<?php
namespace model;
class MdlDifficulte extends MdlBase{
private DifficulteGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new DifficulteGateway($this->con);
}
public function getAll(): array{
$listDifficulte = [];
foreach($this->gw->getAll() as $row){
$listDifficulte[] = new Difficulte($row['id'], $row['libelle']);
}
return $listDifficulte;
}
public function getFromId(int $id): Difficulte{
$row = $this->gw->getFromId($id);
return new Difficulte($row['id'], $row['libelle']);
}
}

@ -0,0 +1,27 @@
<?php
namespace model;
class MdlInvite extends MdlBase{
private InviteGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new InviteGateway($this->con);
}
public function setPseudo(int $id, string $pseudo): Invite{
$this->gw->setPseudo($id, $pseudo);
return $this->getFromId($id);
}
public function insertInvite(string $pseudo, string $idSession): Invite{
$id = $this->gw->insertInvite($pseudo, $idSession);
return $this->getFromId($id);
}
public function getFromId(int $id): Invite{
$row = $this->gw->getFromId($id);
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']);
}
}

@ -0,0 +1,25 @@
<?php
namespace model;
class MdlJeu extends MdlBase{
private JeuGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new JeuGateway($this->con);
}
public function getAll(): array{
$listJeu = [];
foreach($this->gw->getAll() as $row){
$listJeu[] = new Jeu($row['id'], $row['nom'], $row['nbrparties']);
}
return $listJeu;
}
public function getFromId(int $id): Jeu{
$row = $this->gw->getFromId($id);
return new Jeu($row['id'], $row['nom'], $row['nbrparties']);
}
}

@ -0,0 +1,91 @@
<?php
namespace model;
class MdlPendu{
private Scientifique $scientifiqueATrouver;
private string $aTrouver;
private int $nbFail;
private int $nbTours;
private array $lettreExceptees;
private array $lettreUtilisees;
private static int $nbFailsMax = 8;
public function __construct(Scientifique $scientifiqueATrouver){
$this->scientifiqueATrouver = $scientifiqueATrouver;
$this->aTrouver = iconv('UTF-8', 'ASCII//TRANSLIT', $scientifiqueATrouver->getPrenom()." ".$scientifiqueATrouver->getNom()); #suppression des accents
$this->aTrouver = preg_replace('/[^A-Za-z0-9 ]/', '', $this->aTrouver); // Retire les caractères non-alphanumeric
$this->nbFail = 0;
$this->nbTours = 0;
$this->lettreExceptees = [' ', '-'];
$this->lettreUtilisees = [];
}
public function jouerLettre(string $lettre): string{
$lettre = strtolower($lettre);
if(strlen($lettre) != 1){ throw new ValidationException("Veuillez fournir une seule lettre");}
if(!ctype_alpha($lettre)){ throw new ValidationException("Veuillez fournir un caractère alphabétique");}
if(in_array($lettre, $this->lettreUtilisees)){ throw new ValidationException("Vous avez déjà joué cette lettre");}
$this->nbTours += 1;
// if(!str_contains($this->aTrouver, $lettre)){ // UNIQUEMENT EN PHP 8.0
// $this->nbFail += 1;
// }
if (strpos($this->aTrouver, $lettre) === false) { // PHP 7.4
$this->nbFail += 1;
}
$this->lettreUtilisees[] = $lettre;
return $this->getDecouvert();
}
public function getScientifique(): Scientifique
{
return $this->scientifiqueATrouver;
}
public function getLettreUtilisees(): array{
return $this->lettreUtilisees;
}
public function getATrouver(): string
{
return $this->aTrouver;
}
public function getDecouvert(): string
{
$decouvert = '';
foreach(str_split($this->aTrouver) as $lettre){
if(in_array(strtolower($lettre), $this->lettreUtilisees) || in_array(strtolower($lettre), $this->lettreExceptees)){
$decouvert.=$lettre;
}else{
$decouvert.="_";
}
}
return $decouvert;
}
public function getNbTours():int{
return $this->nbTours;
}
public function getNbFails():int{
return $this->nbFail;
}
public function getEssaisRestant():int{
return $this::$nbFailsMax - $this->nbFail;
}
public function aGagne(): bool{
return $this->getDecouvert() == $this->getATrouver();
}
public function aPerdu(): bool{
return $this->getEssaisRestant() <= 0;
}
}

@ -0,0 +1,108 @@
<?php
namespace model;
use Exception;
class MdlScienceQuizz
{
private int $bonneReponse;
private string $nbPoints;
private int $numQuestion;
private array $reponses;
private array $questions;
private array $questionsPass;
private bool $partieTerminee;
private int $scientifique;
public function __construct(int $scientifique, array $questions)
{
$this->bonneReponse = 0;
$this->nbPoints = 0;
$this->numQuestion = 0;
$this->reponses = [];
$this->scientifique = $scientifique;
$this->questions = $questions;
$this->questionsPass = [];
$this->partieTerminee = false;
}
/**
* @return array
*/
public function getQuestions(): array
{
return $this->questions;
}
public function getScientifique(): int
{
return $this->scientifique;
}
/**
* @return int
*/
public function getBonneReponse(): int
{
return $this->bonneReponse;
}
/**
* @return string
*/
public function getNbPoints(): string
{
return $this->nbPoints;
}
/**
* @return int
*/
public function getNumQuestion(): int
{
return $this->numQuestion;
}
/**
* @return array
*/
public function getReponses(): array
{
return $this->reponses;
}
/**
* @param int $bonneReponse
*/
public function setBonneReponse(int $bonneReponse): void
{
$this->bonneReponse = $bonneReponse;
}
// Sélectionne une question aléatoire
/**
* @throws Exception
*/
public function getRandomQuestion(array $questions): string
{
$randomNum=random_int(0, count($questions)-1);
$question=$questions[$randomNum];
$this->questionsPass[]=$question;
if (count($this->questionsPass)==count($questions))
{
$this->partieTerminee=true;
}
return $question;
}
public function partieTerminee(): bool
{
return $this->partieTerminee;
}
}

@ -0,0 +1,172 @@
<?php
namespace model;
use DateTime;
use Exception;
use RuntimeException;
class MdlScientifique extends MdlBase{
private ScientifiqueGateway $gw;
private MdlSexe $mdlSexe;
private MdlDifficulte $mdlDifficulte;
private MdlThematique $mdlThematique;
public function __construct(){
parent::__construct();
$this->gw = new ScientifiqueGateway($this->con);
$this->mdlSexe = new MdlSexe();
$this->mdlDifficulte = new MdlDifficulte();
$this->mdlThematique = new MdlThematique();
}
/**
* @throws Exception
*/
public function getRandom(): Scientifique{
$row = $this->gw->getRandom();
if(!$row) throw new RuntimeException("Erreur aucun scientifique trouvé");
$sexe = $this->mdlSexe->getFromId($row['idsexe']);
$difficulte = $this->mdlDifficulte->getFromId($row['iddifficulte']);
$thematique = $this->mdlThematique->getFromId($row['idthematique']);
return new Scientifique($row['id'],
$row['nom'],
$row['prenom'],
$row['photo'],
new DateTime($row['datenaissance']),
$row['descriptif'],
$row['ratiotrouvee'],
$thematique,
$difficulte,
$sexe);
}
/**
* @throws Exception
*/
public function addScientifique(Scientifique $s): bool
{
return $this->gw->addScientifique($s);
}
public function getScientifiquesParPage(int $page) : array {
$nbElemParPage = 20;
$pageMax = ceil($this->gw->getNbScientifique()/$nbElemParPage);
if ($page <= 0) {
$page = 1;
} elseif ($page > $pageMax) {
$page = $pageMax;
}
$result = $this->gw->getScientifiquesParPages($page,$nbElemParPage);
$scientifiques = array();
foreach ($result as $scientifique) {
$sexe = $this->mdlSexe->getFromId($scientifique['idsexe']);
$difficulte = $this->mdlDifficulte->getFromId($scientifique['iddifficulte']);
$thematique = $this->mdlThematique->getFromId($scientifique['idthematique']);
$scientifiques[] = new Scientifique($scientifique['id'],
$scientifique['nom'],
$scientifique['prenom'],
$scientifique['photo'],
new DateTime($scientifique['datenaissance']),
$scientifique['descriptif'],
$scientifique['ratiotrouvee'],
$thematique,
$difficulte,
$sexe);
}
return $scientifiques;
}
public function getHistoriqueParPage(string $pseudoJoueur,int $page) {
$nbElemParPage = 20;
$pageMax = ceil($this->gw->getNbScientifiqueHistorique($pseudoJoueur)/$nbElemParPage);
if ($page <= 0) {
$page = 1;
} elseif ($page > $pageMax) {
$page = $pageMax;
}
$result = $this->gw->getHistorique($pseudoJoueur,$page,$nbElemParPage);
$scientifiques = array();
foreach ($result as $scientifique) {
$sexe = $this->mdlSexe->getFromId($scientifique['idsexe']);
$difficulte = $this->mdlDifficulte->getFromId($scientifique['iddifficulte']);
$thematique = $this->mdlThematique->getFromId($scientifique['idthematique']);
$scientifiques[] = new Scientifique($scientifique['id'],
$scientifique['nom'],
$scientifique['prenom'],
$scientifique['photo'],
new DateTime($scientifique['datenaissance']),
$scientifique['descriptif'],
$scientifique['ratiotrouvee'],
$thematique,
$difficulte,
$sexe);
}
return $scientifiques;
}
public function getMaxPages() : int {
$nbElemParPage = 20;
return ceil($this->gw->getNbScientifique()/$nbElemParPage);
}
public function getMaxPagesHistorique(string $pseudo) : int {
$nbElemParPage = 20;
return ceil($this->gw->getNbScientifiqueHistorique($pseudo)/$nbElemParPage);
}
public function editScientifique(Scientifique $s){
return $this->gw->editScientifique($s);
}
/**
* @throws Exception
*/
public function getScientifique(int $id): Scientifique
{
$t=$this->gw->getScientifique($id);
if(gettype($t)!="array"){
throw new Exception("Scientifique non trouvé");
}
$sexe=new MdlSexe();
$sexe=$sexe->getFromId($t["idsexe"]);
$diff=new MdlDifficulte();
$diff=$diff->getFromId($t["iddifficulte"]);
$theme=new MdlThematique();
$theme=$theme->getFromId($t["idthematique"]);
return new Scientifique(
$id,
$t["nom"],
$t["prenom"],
$t["photo"],
DateTime::createFromFormat("Y-m-d", $t["datenaissance"]),
$t["descriptif"],
$t["ratiotrouvee"],
$theme,
$diff,
$sexe
);
}
/**
* @throws Exception
*/
public function getQuestions(int $id): array
{
$t = $this->gw->getQuestions($id);
if (gettype($t) != "array") {
throw new Exception("Scientifique non trouvé");
}
$questions = [];
foreach ($t as $question) {
$questions[] = $question["question"];
}
return $questions;
}
}

@ -0,0 +1,25 @@
<?php
namespace model;
class MdlSexe extends MdlBase{
private SexeGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new SexeGateway($this->con);
}
public function getFromId(int $id): Sexe{
$row = $this->gw->getFromId($id);
return new Sexe($row['id'], $row['libelle']);
}
public function getAll(): array {
$ret=array();
$row = $this->gw->getAll();
for($i=0; $i< count($row); $i++){
array_push($ret, new Sexe($row[$i]['id'], $row[$i]['libelle']));
}
return $ret;
}
}

@ -0,0 +1,26 @@
<?php
namespace model;
class MdlThematique extends MdlBase{
private ThematiqueGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new ThematiqueGateway($this->con);
}
public function getFromId(int $id): Thematique{
$row = $this->gw->getFromId($id);
return new Thematique($row['id'], $row['libelle']);
}
public function getAll(): array {
$ret=array();
$row = $this->gw->getAll();
for($i=0; $i< count($row); $i++){
array_push($ret, new Thematique($row[$i]['id'], $row[$i]['libelle']));
}
return $ret;
}
}

@ -0,0 +1,39 @@
<?php
namespace model;
class MdlUser extends MdlBase{
private UtilisateurConnecteGateway $gw;
public function __construct(){
parent::__construct();
$this->gw = new UtilisateurConnecteGateway($this->con);
}
public function login(string $username, string $password): bool{
return $this->gw->login($username, $password);
}
public function register(string $username, string $password): bool{
$temp = new JoueurGateway($this->con);
$temp->insertJoueur($username);
return $this->gw->register($username, $password, $temp->getFromPseudo($username)["id"]);
}
public function setPseudo(int $id, string $pseudo): Utilisateur{
$this->gw->setPseudo($id, $pseudo);
return $this->getFromId($id);
}
public function getFromId(int $id): Utilisateur{
$row = $this->gw->getFromId($id);
return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
}
public function getFromEmail(string $email): Utilisateur{
$row = $this->gw->getFromEmail($email);
return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
}
public function addScientifiqueDecouvert(int $idUtilisateur, int $idScientifique){
$this->gw->addScientifiqueDecouvert($idUtilisateur, $idScientifique);
}
}

@ -0,0 +1,47 @@
<?php
namespace model;
class Admin
{
private int $id;
private string $email;
private string $password;
/**
* @param int $id
* @param string $password
* @param string $email
*/
public function __construct(int $id, string $email, string $password)
{
$this->id=$id;
$this->password=$password;
$this->email = $email;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getPassword(): string
{
return $this->password;
}
}

@ -0,0 +1,21 @@
<?php
namespace model;
class ConfigurationJeu{
private Difficulte $difficulte;
private Jeu $jeu;
public function __construct(Jeu $jeu, Difficulte $difficulte){
$this->jeu = $jeu;
$this->difficulte = $difficulte;
}
public function getDifficulte(): Difficulte{
return $this->difficulte;
}
public function getJeu(): Jeu{
return $this->jeu;
}
}

@ -0,0 +1,37 @@
<?php
namespace model;
class Difficulte
{
private int $id;
private string $libelle;
/**
* @param int $id
* @param string $libelle
*/
public function __construct(int $id, string $libelle)
{
$this->id=$id;
$this->libelle=$libelle;
}
/**
* @return int
*/
public function getId(): int{
return $this->id;
}
/**
* @return string
*/
public function getLibelle(): string{
return $this->libelle;
}
public function __toString() {
return $this->libelle;
}
}

@ -0,0 +1,18 @@
<?php
namespace model;
class Invite extends Joueur{
private string $idSession;
public function __construct(int $id, string $pseudo, string $idSession)
{
parent::__construct($id,$pseudo);
$this->idSession = $idSession;
}
public function getIdSession(): string
{
return $this->idSession;
}
}

@ -0,0 +1,51 @@
<?php
namespace model;
class Jeu
{
private int $id;
private string $nom;
private int $nbrParties;
/**
* @param int $id
* @param string $nom
* @param int $nbrParties
*/
public function __construct(int $id, string $nom, int $nbrParties)
{
$this->id=$id;
$this->nom=$nom;
$this->nbrParties=$nbrParties;
}
/**
* @return int
*/
public function getId(): int{
return $this->id;
}
/**
* @return string
*/
public function getNom(): string{
return $this->nom;
}
/**
* @return int
*/
public function getNbParties():int{
return $this->nbrParties;
}
/**
* @return int
*/
public function incrementNbParties(): int{
$this->nbrParties += 1;
return $this->nbrParties;
}
}

@ -0,0 +1,24 @@
<?php
namespace model;
abstract class Joueur{
private int $id;
private string $pseudo;
public function __construct(int $id, string $pseudo){
$this->id=$id;
$this->pseudo=$pseudo;
}
public function getId(): int
{
return $this->id;
}
public function getPseudo(): String
{
return $this->pseudo;
}
}

@ -0,0 +1,138 @@
<?php
namespace model;
use DateTime;
class Scientifique
{
private int $id;
private string $nom;
private string $prenom;
private string $photo;
private DateTime $dateNaiss;
private string $descriptif;
private float $ratioTrouvee;
private Thematique $thematique;
private Difficulte $difficulte;
private Sexe $sexe;
private array $questions;
/**
* @param int $id
* @param string $nom
* @param string $prenom
* @param string $photo
* @param DateTime $dateNaiss
* @param string $descriptif
* @param float $ratioTrouvee
* @param Thematique $thematique
* @param Difficulte $difficulte
* @param Sexe $sexe
* @param array $questions
*/
public function __construct(int $id,
string $nom,
string $prenom,
string $photo,
DateTime $dateNaiss,
string $descriptif,
float $ratioTrouvee,
Thematique $thematique,
Difficulte $difficulte,
Sexe $sexe,
array $questions = [])
{
$this->id = $id;
$this->nom = $nom;
$this->prenom = $prenom;
$this->photo = $photo;
$this->ratioTrouvee = $ratioTrouvee;
$this->descriptif = $descriptif;
$this->dateNaiss = $dateNaiss;
$this->thematique = $thematique;
$this->difficulte = $difficulte;
$this->sexe = $sexe;
$this->questions = $questions;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getNom(): string
{
return $this->nom;
}
/**
* @return string
*/
public function getPrenom(): string
{
return $this->prenom;
}
/**
* @return string
*/
public function getPhoto(): string
{
return $this->photo;
}
/**
* @return string
*/
public function getDescriptif(): string
{
return $this->descriptif;
}
/**
* @return DateTime
*/
public function getDateNaiss(): DateTime
{
return $this->dateNaiss;
}
/**
* @return float
*/
public function getRatioTrouvee(): float
{
return $this->ratioTrouvee;
}
/**
* @return Thematique
*/
public function getThematique(): Thematique
{
return $this->thematique;
}
/**
* @return Difficulte
*/
public function getDifficulte(): Difficulte
{
return $this->difficulte;
}
/**
* @return Sexe
*/
public function getSexe(): Sexe
{
return $this->sexe;
}
}

@ -0,0 +1,30 @@
<?php
namespace model;
class Sexe
{
private int $id;
private string $libelle;
public function __construct(int $id, string $libelle)
{
$this->id=$id;
$this->libelle=$libelle;
}
public function getId():int
{
return $this->id;
}
public function getLibelle(): string
{
return $this->libelle;
}
public function __toString()
{
return $this->libelle;
}
}

@ -0,0 +1,30 @@
<?php
namespace model;
class Thematique
{
private int $id;
private string $libelle;
public function __construct(int $id, string $libelle)
{
$this->id=$id;
$this->libelle=$libelle;
}
public function getId():int
{
return $this->id;
}
public function getLibelle(): string
{
return $this->libelle;
}
public function __toString()
{
return $this->libelle;
}
}

@ -0,0 +1,25 @@
<?php
namespace model;
class Utilisateur extends Joueur{
private string $email;
private string $motDePasse; #hash du mot de passe
public function __construct(int $id, string $pseudo, string $email, string $motDePasse)
{
parent::__construct($id,$pseudo);
$this->email = $email;
$this->motDePasse = $motDePasse;
}
public function getEmail(): string
{
return $this->email;
}
public function getMotDePasse(): string
{
return $this->motDePasse;
}
}

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../css/bootstrap.min.css">
<style>
body {
margin: 10px;
}
</style>
<title>Accueil</title>
</head>
<body>
<h1>Bienvenue sur Mini-Jeux</h1>
<!--TODO A DEPLACER DANS SA PROPRE VUE-->
{% if dVue.nomJeu is defined %}
<p>Jeu selectionné : {{dVue.nomJeu}}</p>
{% endif %}
{% if dVue.libelleDifficulte is defined %}
<p>Difficulte selectionné : {{dVue.libelleDifficulte}}</p>
{% endif %}
<!--FIN TODO-->
<div align="right">
{% if dVue.pseudo is defined %}
<p><a href="logout">{{dVue.pseudo}}</a></p>
<p><a href="historique">Historique</a></p>
{% else %}
<p><a href="login">Se connecter</a></p>
{% endif %}
</div>
<br><br><br><br>
<center>
<a href="joinParty">Rejoindre une partie</a>
<a href="createParty">Créer une partie</a>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
margin: 10px;
}
</style>
<title>Accueil</title>
</head>
<body>
<h1>Bienvenue sur Mini-Console Admin</h1>
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
<br><br><br><br>
<center>
<a href="admin/ajouterScientifiques">Ajouter Scientifiques</a>
<br>
<a href="admin/listeScientifiques">Lister les scientifiques</a>
</center>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Ajouter un(e) scientifique</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
p,
label {
font:
1rem 'Fira Sans',
sans-serif;
}
input {
margin: 0.4rem;
}
</style>
</head>
<body>
<h1>ajouterScientifiques</h1>
<br><br><br>
<center>
<form action="" method="post">
<div>
<label for="name">Nom :</label>
<input type="text" id="name" name="name" required minlength="1" maxlength="128"
value="{% if scientifique is not null %}{{ scientifique.nom }}{% endif %}"/>
</div>
<div>
<label for="name">Prénom :</label>
<input type="text" id="prenom" name="prenom" required minlength="1" maxlength="128"
value="{% if scientifique is not null %}{{ scientifique.prenom }}{% endif %}"/>
</div>
<div>
<label for="name">URL de la photo :</label>
<input type="text" id="url" name="url" required minlength="1" maxlength="512"
value="{% if scientifique is not null %}{{ scientifique.photo }}{% endif %}"/>
</div>
<div>
<label for="name">Date de naissance :</label>
<input type="date" id="date" name="date" required
value="{% if scientifique is not null %}{{ scientifique.date|date('Y-m-d') }}{% endif %}"/>
</div>
<div>
<label for="name">Description (histoire, accomplissements...) :</label>
<textarea name="description" cols="40" rows="5">{% if scientifique is not null %}{{ scientifique.descriptif }}{% endif %}</textarea>
</div>
<fieldset>
<legend>Sexe :</legend>
{% for se in sexe %}
<div>
<input type="radio" id="sexe{{se.id}}" name="sexe" value="{{se.id}}"
{% if scientifique is not null %}
{% if scientifique.sexe.getId == se.id %}
checked
{% endif %}
{% endif %}
/>
<label for="{{se.id}}">{{se.libelle}}</label>
</div>
{% endfor %}
</fieldset>
<fieldset>
<legend>Thematique :</legend>
{% for se in themes %}
<div>
<input type="radio" id="theme{{se.id}}" name="theme" value="{{se.id}}"
{% if scientifique is not null %}
{% if scientifique.thematique.getId == se.id %}
checked
{% endif %}
{% endif %}
/>
<label for="{{se.id}}">{{se.libelle}}</label>
</div>
{% endfor %}
</fieldset>
<fieldset>
<legend>Difficulté :</legend>
{% for se in difficultes %}
<div>
<input type="radio" id="diff{{se.id}}" name="difficulte" value="{{se.id}}"
{% if scientifique is not null %}
{% if scientifique.difficulte.getId == se.id %}
checked
{% endif %}
{% endif %}
/>
<label for="{{se.id}}">{{se.libelle}}</label>
</div>
{% endfor %}
</fieldset>
<input type="submit" value="Envoyer" />
</form>
</center>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
margin: 10px;
}
</style>
<title>Liste des scientifiques</title>
</head>
<body>
<h1>Voici la liste des scientifiques dans la base de données :</h1>
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
<br><br><br><br>
<center>
<a href="ajouterScientifiques">Ajouter un(e) scientifique</a>
{% for scientifique in dVue.listeScientifiques %}
<div>
<h2>{{ scientifique.getNom() }} {{ scientifique.getPrenom() }}</h2>
<p>Sexe : {{ scientifique.getSexe() }}</p>
<p>Né(e) le {{ scientifique.getDateNess() }}</p>
<p>Thematique : {{ scientifique.getThematique() }}</p>
<p>Difficulté à trouver : {{ scientifique.getDifficulte() }}</p>
<a href='ajouterScientifiques?id={{scientifique.getId()}}'>Modifier</a>
</div>
<br>
<br>
{% endfor %}
<div>
<a href="{{ dVue.pagePrec }}"><</a>
<a href="1">1</a>
<p>{{ dVue.page }}</p>
<a href="{{ dVue.pageMax }}">1</a>
<a href="{{ dVue.pageSuiv }}">></a>
</div>
</center>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Créer une partie</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<style>
p,
label {
font:
1rem 'Fira Sans',
sans-serif;
}
input {
margin: 0.4rem;
}
</style>
</head>
<body>
<h1>Créer une partie</h1>
<br><br><br>
<center>
<p>Pour créer voter partie, merci de faire vos choix et de cliquer sur valider</p>
<form action="validationFormulaire" method="post">
<fieldset>
<legend>Mini-jeux disponibles</legend>
{% if dVueErreur|length > 0 %}
<div>
<h5>Erreur : </h5>
{% for erreur in dVueErreur %}
<p>{{erreur}}</p>
{% endfor %}
</div>
{% endif %}
{% if dVueCreate is defined %}
{% if dVueCreate["jeux"] is defined %}
{% for value in dVueCreate["jeux"] %}
<div>
<input required type="radio" name="jeu" id="{{value['id']}}" value="{{value['id']}}">
<label for="{{value['id']}}">{{value['nom']}}</label>
</div>
{% endfor %}
{% endif %}
</fieldset>
{% if dVueCreate["difficultes"] is defined %}
<label for="difficulte">Difficulté</label>
<select required name="difficulte" id="difficulte">
{% for diff in dVueCreate["difficultes"] %}
<option value="{{diff['id']}}">{{diff['libelle']}}</option>
{% endfor %}
</select>
{% endif %}
<input type="submit" value="Valider">
{% endif %}
</form>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,6 @@
<h1>Une erreur s'est produite !</h1>
{% if dVueErreur is defined %}
{% for value in dVueErreur %}
<p>{{value}}</p>
{% endfor %}
{% endif %}

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
margin: 10px;
}
</style>
<title>Historique des scientifiques découverts :</title>
</head>
<body>
<h1>Voici l'historique des scientifiques découverts :</h1>
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
<br><br><br><br>
<center>
{% for scientifique in dVue.listeScientifiques %}
<div>
<h2>{{ scientifique.getNom() }} {{ scientifique.getPrenom() }}</h2>
<p>Sexe : {{ scientifique.getSexe() }}</p>
<p>Né(e) le {{ scientifique.getDateNess() }}</p>
<p>Thematique : {{ scientifique.getThematique() }}</p>
<p>Difficulté à trouver : {{ scientifique.getDifficulte() }}</p>
</div>
<br>
<br>
{% endfor %}
<div>
<a href="{{ dVue.pagePrec }}"><</a>
<a href="1">1</a>
<p>{{ dVue.page }}</p>
<a href="{{ dVue.pageMax }}">1</a>
<a href="{{ dVue.pageSuiv }}">></a>
</div>
</center>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Rejoindre une partie</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
<h1>Rejoindre une partie</h1>
<center>
<p>Merci de vous munir de votre code de partie</p>
<form action="#" method="post">
<label for="codeInvitation">Code de la partie</label>
<input type="text" name="codeInvitation" id="codeInvitation">
<input type="submit" value="Valider">
</form>
<div>
{% if dErreur is defined %}
{% for err in dErreur %}
<p>{{ err }}</p>
{% endfor %}
{% endif %}
</div>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Se connecter</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
<h1>Se connecter</h1>
<center>
<form action="#" method="post">
<label for="login">Login</label><br>
<input type="text" name="login" id="login">
<br>
<label for="password">Mot de passe</label><br>
<input type="password" name="password" id="password">
<br><br>
<input type="submit" value="Valider"><br/>
<a href="register">Creer un compte</a>
{% for error in dErreur %}
<br>
<p style="color: red">
{{error}}
</p>
{% endfor %}
</form>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Pendu</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<style>
p,
label {
font:
1rem 'Fira Sans',
sans-serif;
}
input {
margin: 0.4rem;
}
</style>
</head>
<body>
<br><br><br>
<center>
<p></p>
<form action="" method="post">
<fieldset>
{% if dVue.decouvert is defined %}
<div>
<h1>
{{dVue.decouvert}}
</h1>
</div>
<br>
{% endif %}
{% if dVue.essaisRestant is defined %}
<p>Il vous reste {{dVue.essaisRestant}} essais</p>
{% endif %}
{% if dVue.lettresUtilisees is defined %}
<h5>Lettres utilisées</h5>
<div>
{%for lettre in dVue.lettresUtilisees %}
{{lettre}}&nbsp;
{% endfor %}
</div>
{% endif %}
<legend>Votre lettre</legend>
{% if dVueErreur|length > 0 %}
<div>
<h5>Erreur : </h5>
{% for erreur in dVueErreur %}
<p>{{erreur}}</p>
{% endfor %}
</div>
{% endif %}
<div>
<label>
<input required type="text" name="lettre">
</label>
</div>
</fieldset>
<input type="submit" value="Valider">
</form>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Pendu - Score</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<style>
p,
label {
font:
1rem 'Fira Sans',
sans-serif;
}
input {
margin: 0.4rem;
}
</style>
</head>
<body>
<br><br><br>
<center>
{% if dVue.messageScore is defined %}
<h1>{{dVue.messageScore}}</h1>
{% endif %}
{% if dVue.nbTours is defined and dVue.nbFails is defined %}
<p>Vous avez fais {{dVue.nbTours}} essais et {{dVue.nbFails}} erreur(s)</p>
{% endif %}
{% if dVue.scientifique is defined %}
<h2>Le scientifique a trouvé été {{dVue.scientifique.prenom}} {{dVue.scientifique.nom}}</h2>
<div>
<h3>Voici quelques informations à son sujet</h3>
<p>Né(e) le : {{dVue.scientifique.dateNaiss}}</p>
<p>Sexe : {{dVue.scientifique.sexe}}</p>
<p>Domaine : {{dVue.scientifique.thematique}}</p>
<p>{{dVue.scientifique.descriptif}}</p>
</div>
{% endif %}
<a href=".">Retour à l'accueil</a>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Saisir Pseudo</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<style>
p,
label {
font:
1rem 'Fira Sans',
sans-serif;
}
input {
margin: 0.4rem;
}
</style>
</head>
<body>
<br><br><br>
<center>
<p></p>
<form action="" method="post">
<fieldset>
<legend>Veuillez choisir votre pseudo</legend>
{% if dVueErreur|length > 0 %}
<div>
<h5>Erreur : </h5>
{% for erreur in dVueErreur %}
<p>{{erreur}}</p>
{% endfor %}
</div>
{% endif %}
<div>
<label for="txt_pseudo">
<input required type="text" name="pseudo" id="txt_pseudo">
</label>
</div>
</fieldset>
<input type="submit" value="Valider">
</form>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>S'inscrire</title>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<script>
function checkmdp(){
if(cpassword.value===password.value){
mdpbad.style='';
reg.disabled=false;
} else {
mdpbad.style='visibility: hidden';
reg.disabled=true;
}
}
</script>
</head>
<body>
<h1>S'inscrire</h1>
<center>
<form action="#" method="post">
<label for="login">Login</label><br>
<input type="text" name="login" id="login">
<br>
<label for="password">Mot de passe</label><br>
<input type="password" name="password" id="password"><br>
<label for="cpassword">Confirmer mot de passe</label><br>
<input type="password" name="cpassword" id="cpassword" onchange="">
<p id="mdpbad" style="visibility: hidden">Les mots de passe ne correspondent pas!</p>
<br><br>
<input id="reg" type="submit" value="Valider">
{% for error in dErreur %}
<br>
<p style="color: red">
{{error}}
</p>
{% endfor %}
</form>
</center>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save