forked from tom.biard/ScienceQuest
Compare commits
10 Commits
master
...
doc_kahoot
Author | SHA1 | Date |
---|---|---|
Gwenael PLANCHON | 3103fe9ef6 | 9 months ago |
Lilian BRETON | 071dfee14b | 9 months ago |
Tom BIARD | 01b52cd301 | 9 months ago |
Lilian BRETON | 0877094043 | 9 months ago |
Lilian BRETON | 1b1410fffd | 9 months ago |
Lilian BRETON | 7664afc138 | 9 months ago |
Lilian BRETON | e792740e4e | 9 months ago |
Lilian BRETON | 6fdc58151d | 9 months ago |
Lilian BRETON | ddf5ee0a43 | 9 months ago |
Lilian BRETON | 3c94c2dde4 | 9 months ago |
@ -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,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Neutral.iml" filepath="$PROJECT_DIR$/.idea/Neutral.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,125 @@
|
||||
<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="<div>kahoot</div>" 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="<div>Choisir niveau de difficulté</div><div>en fonction de la popularité</div>" 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="<div>Choisir le theme des scientifiques</div><div>(Math, SVT, Informatique, tous...)</div>" 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="<div>joueur</div>" 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="<div>Rejoindre partie</div><div>non lancée<br></div>" 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="<div>Répondre a une question</div>" 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="<div>&lt;&lt;include&gt;&gt;</div>" 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="<div>Répondre juste a une question</div>" 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="<div>Répondre faux a une question</div>" 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="<div>Ajouter scientifique dans historique</div>" 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="<div>&lt;&lt;include&gt;&gt;</div>" 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="<div>Affiche les questions<br></div>" 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="<div>&lt;&lt;include&gt;&gt;</div>" 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="<div>&lt;&lt;include&gt;&gt;</div>" 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="<div>&lt;&lt;include&gt;&gt;</div>" 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="<div>Lancer partie</div>" 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="&lt;&lt;include&gt;&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="&lt;&lt;include&gt;&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>
|
After Width: | Height: | Size: 29 KiB |
@ -0,0 +1,26 @@
|
||||
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
|
@ -0,0 +1 @@
|
||||
<?php
|
@ -0,0 +1,35 @@
|
||||
<html>
|
||||
|
||||
<body>
|
||||
test
|
||||
|
||||
<?php
|
||||
use model\Connection;
|
||||
|
||||
require_once("Connection.php");
|
||||
|
||||
//A CHANGER
|
||||
$user= 'sasa';
|
||||
$pass='sasa';
|
||||
$dsn='mysql:host=localhost;dbname=siteperso';
|
||||
try{
|
||||
$con=new Connection($dsn,$user,$pass);
|
||||
|
||||
$query = "SELECT * FROM categorie WHERE id=:id";
|
||||
|
||||
|
||||
echo $con->executeQuery($query, array(':id' => array(1, PDO::PARAM_INT) ) );
|
||||
|
||||
$results=$con->getResults();
|
||||
Foreach ($results as $row)
|
||||
print $row['titre'];
|
||||
|
||||
|
||||
}
|
||||
catch( PDOException $Exception ) {
|
||||
echo 'erreur';
|
||||
echo $Exception->getMessage();}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class AdminGateway
|
||||
{
|
||||
private \PDO $con;
|
||||
|
||||
public function __construct(\PDO $con)
|
||||
{
|
||||
$this->con=$con;
|
||||
}
|
||||
|
||||
public function login(string $username, string $password): bool
|
||||
{
|
||||
$sql = "SELECT * FROM admin WHERE username=:username";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
if ($result && password_verify($password, $result['password'])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getHashedPassword(string $username): string
|
||||
{
|
||||
$sql = "SELECT password FROM user WHERE username=:username";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['password'];
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use PDO;
|
||||
|
||||
class Connection extends PDO {
|
||||
|
||||
private $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password) {
|
||||
|
||||
parent::__construct($dsn,$username,$password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
/** * @param string $query
|
||||
* @param array $parameters *
|
||||
* @return bool Returns `true` on success, `false` otherwise
|
||||
*/
|
||||
|
||||
public function executeQuery(string $query, array $parameters = []) : bool{
|
||||
$this->stmt = parent::prepare($query);
|
||||
foreach ($parameters as $name => $value) {
|
||||
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
public function getResults() : array {
|
||||
return $this->stmt->fetchall();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class ScientistGateway
|
||||
{
|
||||
private $con;
|
||||
|
||||
function __construct(Connection $co) {
|
||||
$this->con = $co;
|
||||
}
|
||||
|
||||
// function findByName(string $name) :? Scientist {
|
||||
// $usr = null;
|
||||
// }
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class UserGateway
|
||||
{
|
||||
private \PDO $con;
|
||||
private \PDOStatement $stmt;
|
||||
public function __construct(\PDO $con, \PDOStatement $stmt)
|
||||
{
|
||||
$this->con=$con;
|
||||
$this->stmt=$stmt;
|
||||
}
|
||||
|
||||
public function login(string $username, string $password): bool
|
||||
{
|
||||
$sql = "SELECT * FROM user WHERE username=:username";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
if ($result && password_verify($password, $result['password'])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function addUser(string $username, string $password): void
|
||||
{
|
||||
$sql = "INSERT INTO user (username, password) VALUES (:username, :password)";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->bindValue(':password', $password);
|
||||
$stmt->execute();
|
||||
}
|
||||
public function deleteUser(int $id): void
|
||||
{
|
||||
$sql = "DELETE FROM user WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
}
|
||||
public function updateUser(int $id, string $username, string $password): void
|
||||
{
|
||||
$sql = "UPDATE user SET username=:username, password=:password WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->bindValue(':password', $password);
|
||||
$stmt->execute();
|
||||
}
|
||||
public function getUser(int $id): User
|
||||
{
|
||||
$sql = "SELECT * FROM user WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return new User($result['id'], $result['username'], $result['password']);
|
||||
}
|
||||
public function getUsers(): array
|
||||
{
|
||||
$sql = "SELECT * FROM user";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetchAll();
|
||||
$users = [];
|
||||
foreach ($result as $user) {
|
||||
$users[] = new User($user['id'], $user['username'], $user['password']);
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
public function getHashedPasswordById(int $id): string
|
||||
{
|
||||
$sql = "SELECT password FROM user WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['password'];
|
||||
}
|
||||
public function getUserId(string $username): int
|
||||
{
|
||||
$sql = "SELECT id FROM user WHERE username=:username";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['id'];
|
||||
}
|
||||
public function getUserByUsernameAndPassword(string $username, string $password): User
|
||||
{
|
||||
$sql = "SELECT * FROM user WHERE username=:username AND password=:password";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':username', $username);
|
||||
$stmt->bindValue(':password', $password);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return new User($result['id'], $result['username'], $result['password']);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Admin extends User
|
||||
{
|
||||
private string $email;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $email
|
||||
*/
|
||||
public function __construct(int $id, string $username, string $password, string $email)
|
||||
{
|
||||
parent::__construct($id, $username, $password);
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return parent::getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
public function setEmail(string $email): void
|
||||
{
|
||||
parent::setUsername($email);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
enum Difficulty
|
||||
{
|
||||
case Easy;
|
||||
case Medium;
|
||||
case Hard;
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Scientist
|
||||
{
|
||||
private int $id;
|
||||
private string $name;
|
||||
private string $firstName;
|
||||
private string $photo;
|
||||
private string $description;
|
||||
private Theme $theme;
|
||||
private Difficulty $difficulty;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string $firstName
|
||||
* @param string $photo
|
||||
* @param string $description
|
||||
* @param Theme $theme
|
||||
* @param Difficulty $difficulty
|
||||
*/
|
||||
public function __construct(int $id, string $name, string $firstName, string $photo, string $description, Theme $theme, Difficulty $difficulty)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->firstName = $firstName;
|
||||
$this->photo = $photo;
|
||||
$this->description = $description;
|
||||
$this->theme = $theme;
|
||||
$this->difficulty = $difficulty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName(): string
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $firstName
|
||||
*/
|
||||
public function setFirstName(string $firstName): void
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhoto(): string
|
||||
{
|
||||
return $this->photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $photo
|
||||
*/
|
||||
public function setPhoto(string $photo): void
|
||||
{
|
||||
$this->photo = $photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Theme
|
||||
*/
|
||||
public function getTheme(): Theme
|
||||
{
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Theme $theme
|
||||
*/
|
||||
public function setTheme(Theme $theme): void
|
||||
{
|
||||
$this->theme = $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Difficulty
|
||||
*/
|
||||
public function getDifficulty(): Difficulty
|
||||
{
|
||||
return $this->difficulty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Difficulty $difficulty
|
||||
*/
|
||||
public function setDifficulty(Difficulty $difficulty): void
|
||||
{
|
||||
$this->difficulty = $difficulty;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
enum Theme
|
||||
{
|
||||
case Maths;
|
||||
case Physics;
|
||||
case Chemistry;
|
||||
case Biology;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class User
|
||||
{
|
||||
private int $id;
|
||||
private string $username;
|
||||
private string $password;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*/
|
||||
|
||||
public function __construct(int $id, string $username, string $password)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->username=$username;
|
||||
$this->password=$password;
|
||||
}
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
public function setUsername(string $username): void
|
||||
{
|
||||
$this->username=$username;
|
||||
}
|
||||
public function setPassword(string $password): void
|
||||
{
|
||||
$this->password=$password;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue