commit
be35dfc088
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="dataSourceStorageLocal" created-in="PS-241.18034.69">
|
||||||
|
<data-source name="dbwikifantasy@localhost" uuid="eaeddc81-a403-4011-98cd-8045d0845e45">
|
||||||
|
<database-info product="PostgreSQL" version="14.13 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="14.13" exact-driver-version="42.6">
|
||||||
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
</database-info>
|
||||||
|
<case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" />
|
||||||
|
<secret-storage>master_key</secret-storage>
|
||||||
|
<user-name>kiem</user-name>
|
||||||
|
<schema-mapping>
|
||||||
|
<introspection-scope>
|
||||||
|
<node kind="database" qname="@">
|
||||||
|
<node kind="schema" qname="@" />
|
||||||
|
</node>
|
||||||
|
</introspection-scope>
|
||||||
|
</schema-mapping>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="dbwikifantasy@localhost" uuid="eaeddc81-a403-4011-98cd-8045d0845e45">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql://localhost:5432/dbwikifantasy</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
|||||||
|
#n:postgres
|
@ -0,0 +1,2 @@
|
|||||||
|
#n:public
|
||||||
|
!<md> [676221, 0, null, null, -2147483648, -2147483648]
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
|||||||
|
#n:dbwikifantasy
|
@ -0,0 +1,2 @@
|
|||||||
|
#n:public
|
||||||
|
!<md> [676222, 0, null, null, -2147483648, -2147483648]
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MaterialThemeProjectNewConfig">
|
||||||
|
<option name="metadata">
|
||||||
|
<MTProjectMetadataState>
|
||||||
|
<option name="migrated" value="true" />
|
||||||
|
<option name="pristineConfig" value="false" />
|
||||||
|
<option name="userId" value="-1562669c:19061473cbf:-7ffe" />
|
||||||
|
</MTProjectMetadataState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?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="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>
|
@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="545b2832-eb34-4842-a145-711b7c27ec7f" name="Changes" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
|
||||||
|
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
|
||||||
|
<execution>
|
||||||
|
<phar pharPath="$PROJECT_DIR$/composer.phar" />
|
||||||
|
</execution>
|
||||||
|
</component>
|
||||||
|
<component name="DatabaseLocalColorSettings">
|
||||||
|
<colors>
|
||||||
|
<entry key="69d997e7-7877-4ae4-927e-50b8e6afa2b8" value="Blue" />
|
||||||
|
</colors>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/opt/homebrew/Cellar/php/8.3.8/bin/php" />
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 4
|
||||||
|
}</component>
|
||||||
|
<component name="ProjectId" id="2nQgTIF8ij6j3OAbgJZoTFTTviM" />
|
||||||
|
<component name="ProjectLevelVcsManager">
|
||||||
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"git-widget-placeholder": "reorganisation",
|
||||||
|
"last_opened_file_path": "/Users/kiem/Documents/WikiFantasy/WF-Website",
|
||||||
|
"node.js.detected.package.eslint": "true",
|
||||||
|
"node.js.detected.package.tslint": "true",
|
||||||
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"settings.editor.selected.configurable": "preferences.lookFeel",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
},
|
||||||
|
"keyToStringList": {
|
||||||
|
"DatabaseDriversLRU": [
|
||||||
|
"mysql_aurora_aws",
|
||||||
|
"postgresql"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="SharedIndexes">
|
||||||
|
<attachedChunks>
|
||||||
|
<set>
|
||||||
|
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-PS-241.18034.69" />
|
||||||
|
<option value="bundled-php-predefined-ba97393d7c68-48a1a656d44e-com.jetbrains.php.sharedIndexes-PS-241.18034.69" />
|
||||||
|
</set>
|
||||||
|
</attachedChunks>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="545b2832-eb34-4842-a145-711b7c27ec7f" name="Changes" comment="" />
|
||||||
|
<created>1728910719918</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1728910719918</updated>
|
||||||
|
<workItem from="1728910721002" duration="4421000" />
|
||||||
|
<workItem from="1728918778867" duration="1619000" />
|
||||||
|
<workItem from="1728981304322" duration="593000" />
|
||||||
|
<workItem from="1728981942325" duration="11204000" />
|
||||||
|
<workItem from="1729003830765" duration="7714000" />
|
||||||
|
<workItem from="1729257427490" duration="6303000" />
|
||||||
|
<workItem from="1729585347214" duration="4286000" />
|
||||||
|
<workItem from="1729589655627" duration="1223000" />
|
||||||
|
<workItem from="1729594945956" duration="10727000" />
|
||||||
|
<workItem from="1729620089184" duration="6929000" />
|
||||||
|
<workItem from="1729670413669" duration="9341000" />
|
||||||
|
<workItem from="1729689922577" duration="6030000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class FavoriteEntity
|
||||||
|
{
|
||||||
|
private int $id_user;
|
||||||
|
private int $id_quote;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_user
|
||||||
|
* @param int $id_quote
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_user, int $id_quote)
|
||||||
|
{
|
||||||
|
$this->id_user = $id_user;
|
||||||
|
$this->id_quote = $id_quote;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdUser(): int
|
||||||
|
{
|
||||||
|
return $this->id_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_user
|
||||||
|
*/
|
||||||
|
public function setIdUser(int $id_user): void
|
||||||
|
{
|
||||||
|
$this->id_user = $id_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdQuote(): int
|
||||||
|
{
|
||||||
|
return $this->id_quote;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quote
|
||||||
|
*/
|
||||||
|
public function setIdQuote(int $id_quote): void
|
||||||
|
{
|
||||||
|
$this->id_quote = $id_quote;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ImageEntity
|
||||||
|
{
|
||||||
|
private int $id_img;
|
||||||
|
private string $img_path;
|
||||||
|
private string $isImgProfil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_img
|
||||||
|
* @param string $img_path
|
||||||
|
* @param string $isImgProfil
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_img, string $img_path, string $isImgProfil)
|
||||||
|
{
|
||||||
|
$this->id_img = $id_img;
|
||||||
|
$this->img_path = $img_path;
|
||||||
|
$this->isImgProfil = $isImgProfil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdImg(): int
|
||||||
|
{
|
||||||
|
return $this->id_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIdImg(int $id_img): void
|
||||||
|
{
|
||||||
|
$this->id_img = $id_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getImgPath(): string
|
||||||
|
{
|
||||||
|
return $this->img_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setImgPath(string $img_path): void
|
||||||
|
{
|
||||||
|
$this->img_path = $img_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsImgProfil(): string
|
||||||
|
{
|
||||||
|
return $this->isImgProfil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsImgProfil(string $isImgProfil): void
|
||||||
|
{
|
||||||
|
$this->isImgProfil = $isImgProfil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class QuizEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
private int $id_quiz;
|
||||||
|
|
||||||
|
private int $nb_questions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quiz
|
||||||
|
* @param int $nb_questions
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_quiz, int $nb_questions)
|
||||||
|
{
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
$this->nb_questions = $nb_questions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdQuiz(): int
|
||||||
|
{
|
||||||
|
return $this->id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quiz
|
||||||
|
*/
|
||||||
|
public function setIdQuiz(int $id_quiz): void
|
||||||
|
{
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNbQuestions(): int
|
||||||
|
{
|
||||||
|
return $this->nb_questions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $nb_questions
|
||||||
|
*/
|
||||||
|
public function setNbQuestions(int $nb_questions): void
|
||||||
|
{
|
||||||
|
$this->nb_questions = $nb_questions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Quiz_questionEntity
|
||||||
|
{
|
||||||
|
private int $id_question;
|
||||||
|
private int $id_quiz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_question
|
||||||
|
* @param int $id_quiz
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_question, int $id_quiz)
|
||||||
|
{
|
||||||
|
$this->id_question = $id_question;
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdQuestion(): int
|
||||||
|
{
|
||||||
|
return $this->id_question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_question
|
||||||
|
*/
|
||||||
|
public function setIdQuestion(int $id_question): void
|
||||||
|
{
|
||||||
|
$this->id_question = $id_question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdQuiz(): int
|
||||||
|
{
|
||||||
|
return $this->id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quiz
|
||||||
|
*/
|
||||||
|
public function setIdQuiz(int $id_quiz): void
|
||||||
|
{
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Result_quizEntity
|
||||||
|
{
|
||||||
|
private int $id_quiz;
|
||||||
|
private int $nbQuestion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quiz
|
||||||
|
* @param int $nbQuestion
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_quiz, int $nbQuestion)
|
||||||
|
{
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
$this->nbQuestion = $nbQuestion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIdQuiz(): int
|
||||||
|
{
|
||||||
|
return $this->id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id_quiz
|
||||||
|
*/
|
||||||
|
public function setIdQuiz(int $id_quiz): void
|
||||||
|
{
|
||||||
|
$this->id_quiz = $id_quiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNbQuestion(): int
|
||||||
|
{
|
||||||
|
return $this->nbQuestion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $nbQuestion
|
||||||
|
*/
|
||||||
|
public function setNbQuestion(int $nbQuestion): void
|
||||||
|
{
|
||||||
|
$this->nbQuestion = $nbQuestion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Gateway;
|
||||||
|
use Connection;
|
||||||
|
use PDO;
|
||||||
|
use Entity\characterEntity;
|
||||||
|
|
||||||
|
|
||||||
|
class CharacterGateway
|
||||||
|
{
|
||||||
|
|
||||||
|
private Connection $co;
|
||||||
|
|
||||||
|
public function __construct(Connection $co)
|
||||||
|
{
|
||||||
|
$this -> co = $co;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(int $id_character, string $name , string $img_char) : bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
INSERT INTO Characters
|
||||||
|
VALUES(:id_char, :name, :img_char)
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
'id_char' => array($id_character, PDO::PARAM_INT),
|
||||||
|
'name' => array($name, PDO::PARAM_STR),
|
||||||
|
'img_char' => array($img_char, PDO::PARAM_STR)
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findById(int $id) : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Characters WHERE id_char = :id_c";
|
||||||
|
$this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByName(string $name) : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Characters WHERE name = :n";
|
||||||
|
$this -> co -> executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll() : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Characters";
|
||||||
|
$this -> co -> executeQuery($query);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(int $id) : bool
|
||||||
|
{
|
||||||
|
$query = "DELETE FROM Characters WHERE id_char = :id_c";
|
||||||
|
return $this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(int $id_char, string $name, string $img_char) : bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
UPDATE Characters
|
||||||
|
SET name = :n, img_char = :i
|
||||||
|
WHERE id_char = :id_c
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
"id_c" => array($id_char, PDO::PARAM_INT),
|
||||||
|
"name" => array($name, PDO::PARAM_STR),
|
||||||
|
"i" => array($img_char, PDO::PARAM_STR)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Gateway;
|
||||||
|
use Connection;
|
||||||
|
use PDO;
|
||||||
|
use QuestionEntity;
|
||||||
|
|
||||||
|
require_once("../Gateway/Connection.php");
|
||||||
|
|
||||||
|
class QuestionGateway
|
||||||
|
{
|
||||||
|
private Connection $co;
|
||||||
|
|
||||||
|
public function __construct(Connection $co)
|
||||||
|
{
|
||||||
|
$this -> co = $co;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
INSERT INTO Question
|
||||||
|
VALUES (:id_q, :question, :answerA, :answerB, :answerC, :answerD, :cAnswer)
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
array('id_q' => $id_question, PDO::PARAM_INT),
|
||||||
|
array('question' => $question, PDO::PARAM_STR),
|
||||||
|
array('answerA' => $answerA, PDO::PARAM_STR),
|
||||||
|
array('answerB' => $answerB, PDO::PARAM_STR),
|
||||||
|
array('answerC' => $answerC, PDO::PARAM_STR),
|
||||||
|
array('answerD' => $answerD, PDO::PARAM_STR),
|
||||||
|
array('cAnswer' => $cAnswer, PDO::PARAM_STR),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function findById(int $id) : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Question WHERE id_question = :id_q";
|
||||||
|
$this -> co -> executeQuery($query, ['id_q' => array($id, PDO::PARAM_INT)]);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updateText(int $id_q, string $newQuestion) : bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
UPDATE Question
|
||||||
|
SET question = :question
|
||||||
|
WHERE id_question = :id_q
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
'id_q' => array($id_q, PDO::PARAM_INT),
|
||||||
|
'question' => array($newQuestion, PDO::PARAM_STR)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateAnswers(int $id_q, string $newA, string $newB, string $newC, string $newD, string $newCorrect): bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
UPDATE Question
|
||||||
|
SET answerA = :answerA, answerB = :answerB,
|
||||||
|
answerC = :answerC, answerD = :answerD, cAnswer = :cAnswer
|
||||||
|
WHERE id_question = :id_q
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
'id_q' => array($id_q, PDO::PARAM_INT),
|
||||||
|
'answerA' => array($newA, PDO::PARAM_STR),
|
||||||
|
'answerB' => array($newB, PDO::PARAM_STR),
|
||||||
|
'answerC' => array($newC, PDO::PARAM_STR),
|
||||||
|
'answerD' => array($newD, PDO::PARAM_STR),
|
||||||
|
'cAnswer' => array($newCorrect, PDO::PARAM_STR)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a question from the database by its ID
|
||||||
|
*
|
||||||
|
* @param int $id The ID of the question
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete(int $id) : bool
|
||||||
|
{
|
||||||
|
$query = "DELETE FROM Question WHERE id_question = :id_q";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, ['id_q' => array($id, PDO::PARAM_INT)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all quizzes from the database
|
||||||
|
*
|
||||||
|
* @return QuestionEntity[] An array of `Question` objects
|
||||||
|
*/
|
||||||
|
public function findAll() : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Question";
|
||||||
|
$this -> co -> executeQuery($query);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findRdmQuestion() : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Question ORDER BY RANDOM() LIMIT 1";
|
||||||
|
$this -> co -> executeQuery($query);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Gateway;
|
||||||
|
use Connection;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
require_once("../Entity/quizEntity.php");
|
||||||
|
|
||||||
|
class QuizGateway
|
||||||
|
{
|
||||||
|
private Connection $co;
|
||||||
|
|
||||||
|
public function __construct(Connection $co)
|
||||||
|
{
|
||||||
|
$this -> co = $co;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(int $id_quiz, int $nb_questions) : bool
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
INSERT INTO Quiz
|
||||||
|
VALUES (:id_q, :nb_q)
|
||||||
|
";
|
||||||
|
|
||||||
|
return $this -> co -> executeQuery($query, [
|
||||||
|
':id_q' => array($id_quiz, PDO::PARAM_INT),
|
||||||
|
':nb_q' => array($nb_questions, PDO::PARAM_INT)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findQuizById(int $id) : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Quiz WHERE id_quiz = :id_q";
|
||||||
|
$this -> co -> executeQuery($query, [':id_q' => array($id, PDO::PARAM_INT)]);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(int $id) : bool
|
||||||
|
{
|
||||||
|
$query = "DELETE FROM Quiz WHERE id_quiz = :id_q";
|
||||||
|
return $this -> co -> executeQuery($query, [':id_q' => array($id, PDO::PARAM_INT)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll() : array
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Quiz";
|
||||||
|
$this -> co -> executeQuery($query);
|
||||||
|
return $this -> co -> getResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "../public/script/Connection.php";
|
|
||||||
require_once "characterEntity.php";
|
|
||||||
|
|
||||||
class CharacterGateway
|
|
||||||
{
|
|
||||||
|
|
||||||
private Connection $co;
|
|
||||||
|
|
||||||
public function __construct(Connection $co)
|
|
||||||
{
|
|
||||||
$this -> co = $co;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create(characterEntity $c) : bool
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
INSERT INTO Character
|
|
||||||
VALUES(:id_character, :name, :img_path)
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
"id_character" => array($c -> getIdCharacter(), PDO::PARAM_INT),
|
|
||||||
"name" => array($c -> getName(), PDO::PARAM_STR),
|
|
||||||
"img_path" => array($c -> getImgPath(), PDO::PARAM_STR)
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findById(int $id) : ?characterEntity
|
|
||||||
{
|
|
||||||
$query = "SELECT * FROM Character WHERE id_character = :id_c";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
|
||||||
$res = $this ->co -> getResults();
|
|
||||||
|
|
||||||
if($res)
|
|
||||||
return new characterEntity(
|
|
||||||
$res["id_character"],
|
|
||||||
$res["name"],
|
|
||||||
$res["img_path"]
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findByName(string $name) : ?characterEntity
|
|
||||||
{
|
|
||||||
$query = "SELECT * FROM Character WHERE name = :n";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
|
|
||||||
$res = $this ->co -> getResults();
|
|
||||||
|
|
||||||
if($res)
|
|
||||||
return new characterEntity(
|
|
||||||
$res["id_character"],
|
|
||||||
$res["name"],
|
|
||||||
$res["img_path"]
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findAll() : array
|
|
||||||
{
|
|
||||||
$query = "SELECT * FROM Character";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query);
|
|
||||||
$res = $this ->co -> getResults();
|
|
||||||
|
|
||||||
$characters = [];
|
|
||||||
|
|
||||||
foreach ($res as $character)
|
|
||||||
{
|
|
||||||
$characters[] = new characterEntity(
|
|
||||||
$character["id_character"],
|
|
||||||
$character["name"],
|
|
||||||
$character["img_path"]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $characters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(int $id) : bool
|
|
||||||
{
|
|
||||||
$query = "DELETE FROM Character WHERE id_character = :id_c";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(characterEntity $c) : bool
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
UPDATE Character
|
|
||||||
SET name = :n, img_path = :i
|
|
||||||
WHERE id_character = :id_c
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
"id_c" => array($c -> getIdCharacter(), PDO::PARAM_INT),
|
|
||||||
"name" => array($c -> getName(), PDO::PARAM_STR),
|
|
||||||
"i" => array($c -> getImgPath(), PDO::PARAM_STR)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
use Entity\CharacterEntity;
|
||||||
|
use Gateway\CharacterGateway;
|
||||||
|
|
||||||
|
|
||||||
|
class CharacterModel
|
||||||
|
{
|
||||||
|
|
||||||
|
private CharacterGateway $gateway;
|
||||||
|
|
||||||
|
public function __construct(characterGateway $gw)
|
||||||
|
{
|
||||||
|
$this -> gateway = $gw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createCharacter(int $id_character, string $name , string $img_char) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> create($id_character, $name, $img_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCharacterById(int $id_character) : ?CharacterEntity
|
||||||
|
{
|
||||||
|
$c = $this -> gateway -> findById($id_character);
|
||||||
|
if ($c)
|
||||||
|
return new CharacterEntity(
|
||||||
|
$c['id_character'],
|
||||||
|
$c['name'],
|
||||||
|
$c['img_path']
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCharacterByName(string $name) : ?CharacterEntity
|
||||||
|
{
|
||||||
|
$c = $this -> gateway -> findByName($name);
|
||||||
|
if ($c)
|
||||||
|
return new CharacterEntity(
|
||||||
|
$c['id_character'],
|
||||||
|
$c['name'],
|
||||||
|
$c['img_path']
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllCharacters() : array
|
||||||
|
{
|
||||||
|
$c = $this -> gateway -> findAll();
|
||||||
|
|
||||||
|
$characters = [];
|
||||||
|
|
||||||
|
foreach ($c as $character)
|
||||||
|
{
|
||||||
|
$characters[] = new CharacterEntity(
|
||||||
|
$character['id_character'],
|
||||||
|
$character['name'],
|
||||||
|
$character['img_path']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $characters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteCharacter(int $id_character) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> delete($id_character);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateCharacter(int $id_character, string $name, string $img_char) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> update($id_character, $name, $img_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
use Gateway\QuestionGateway;
|
||||||
|
use QuestionEntity;
|
||||||
|
|
||||||
|
require_once("../Entity/questionEntity.php");
|
||||||
|
require_once("../Gateway/QuestionGateway.php");
|
||||||
|
|
||||||
|
class QuestionModel
|
||||||
|
{
|
||||||
|
private QuestionGateway $gateway;
|
||||||
|
|
||||||
|
public function __construct(QuestionGateway $gw)
|
||||||
|
{
|
||||||
|
$this -> gateway = $gw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createQuestion(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> create($id_question, $question, $answerA, $answerB, $answerC, $answerD, $cAnswer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQuestion(int $id_question) : ?QuestionEntity
|
||||||
|
{
|
||||||
|
$q = $this -> gateway -> findById($id_question);
|
||||||
|
if ($q)
|
||||||
|
return new QuestionEntity(
|
||||||
|
$q['id_question'],
|
||||||
|
$q['question'],
|
||||||
|
$q['answerA'],
|
||||||
|
$q['answerB'],
|
||||||
|
$q['answerC'],
|
||||||
|
$q['answerD'],
|
||||||
|
$q['cAnswer']
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTextQuestion(int $id_question, string $question) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> updateText($id_question, $question);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateAnswersQuestion(int $id_question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> updateAnswers($id_question, $answerA, $answerB, $answerC, $answerD, $cAnswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteQuestion(int $id_question) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> delete($id_question);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllQuestions() : array
|
||||||
|
{
|
||||||
|
$q = $this -> gateway -> findAll();
|
||||||
|
|
||||||
|
$questions = [];
|
||||||
|
|
||||||
|
foreach ($q as $question) {
|
||||||
|
$questions[] = new QuestionEntity(
|
||||||
|
$question['id_question'],
|
||||||
|
$question['question'],
|
||||||
|
$question['answerA'],
|
||||||
|
$question['answerB'],
|
||||||
|
$question['answerC'],
|
||||||
|
$question['answerD'],
|
||||||
|
$question['cAnswer']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $questions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRdmQuestion() : ?QuestionEntity
|
||||||
|
{
|
||||||
|
$q = $this -> gateway -> findRdmQuestion();
|
||||||
|
if ($q)
|
||||||
|
return new QuestionEntity(
|
||||||
|
$q['id_question'],
|
||||||
|
$q['question'],
|
||||||
|
$q['answerA'],
|
||||||
|
$q['answerB'],
|
||||||
|
$q['answerC'],
|
||||||
|
$q['answerD'],
|
||||||
|
$q['cAnswer']
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
use Entity\quizEntity;
|
||||||
|
use Gateway\QuizGateway;
|
||||||
|
|
||||||
|
class QuizModel {
|
||||||
|
|
||||||
|
private QuizGateway $gateway;
|
||||||
|
|
||||||
|
public function __construct(QuizGateway $gw)
|
||||||
|
{
|
||||||
|
$this -> gateway = $gw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createQuiz(int $id_quiz, int $nb_questions) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> create($id_quiz, $nb_questions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQuiz(int $id_quiz): ?quizEntity
|
||||||
|
{
|
||||||
|
$q = $this -> gateway -> findQuizById($id_quiz);
|
||||||
|
if ($q) {
|
||||||
|
return new quizEntity(
|
||||||
|
$q['id_quiz'],
|
||||||
|
$q['nb_questions'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteQuiz(int $id_quiz) : bool
|
||||||
|
{
|
||||||
|
return $this -> gateway -> delete($id_quiz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllQuiz() : array
|
||||||
|
{
|
||||||
|
$q = $this -> gateway -> findAll();
|
||||||
|
|
||||||
|
$quizzes = [];
|
||||||
|
|
||||||
|
foreach ($q as $quiz) {
|
||||||
|
$quizzes[] = new quizEntity(
|
||||||
|
$quiz['id_quiz'],
|
||||||
|
$quiz['nb_questions']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $quizzes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "characterEntity.php";
|
|
||||||
require_once "characterGateway.php";
|
|
||||||
|
|
||||||
class CharacterModel
|
|
||||||
{
|
|
||||||
|
|
||||||
private characterGateway $gateway;
|
|
||||||
|
|
||||||
public function __construct(characterGateway $gateway)
|
|
||||||
{
|
|
||||||
$this -> gateway = $gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createCharacter(int $id_character, string $name , string $img_path) : bool
|
|
||||||
{
|
|
||||||
$q = new CharacterEntity($id_character, $name, $img_path);
|
|
||||||
|
|
||||||
return $this -> gateway -> create($q);
|
|
||||||
}
|
|
||||||
public function getCharacterById(int $id_character) : ?CharacterEntity
|
|
||||||
{
|
|
||||||
return $this -> gateway -> findById($id_character);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCharacterByName(string $name) : ?CharacterEntity
|
|
||||||
{
|
|
||||||
return $this -> gateway -> findByName($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllCharacters() : array
|
|
||||||
{
|
|
||||||
return $this -> gateway -> findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteCharacter(int $id_character) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> delete($id_character);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateCharacter(int $id_character, string $name, string $img_path) : bool
|
|
||||||
{
|
|
||||||
$q = $this -> gateway -> findById($id_character);
|
|
||||||
|
|
||||||
if($q){
|
|
||||||
$q -> setName($name);
|
|
||||||
$q -> setImgPath($img_path);
|
|
||||||
return $this -> gateway -> update($q);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST')
|
||||||
|
{
|
||||||
|
$answer = $_POST['answer'];
|
||||||
|
var_dump($answer);
|
||||||
|
}
|
Loading…
Reference in new issue