Merge remote-tracking branch 'origin/reorganisation' into reorganisation

pull/17/head
brongniart 6 months ago
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>&quot;</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

File diff suppressed because it is too large Load Diff

@ -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">{
&quot;associatedIndex&quot;: 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.

BIN
src/.DS_Store vendored

Binary file not shown.

@ -9,6 +9,11 @@ class CharacterEntity
private string $img_path; private string $img_path;
/**
* @param int $id_character
* @param string $name
* @param string $img_path
*/
public function __construct(int $id_character, string $name, string $img_path) public function __construct(int $id_character, string $name, string $img_path)
{ {
$this->id_character = $id_character; $this->id_character = $id_character;
@ -16,31 +21,56 @@ class CharacterEntity
$this->img_path = $img_path; $this->img_path = $img_path;
} }
/**
* @return int
*/
public function getIdCharacter(): int public function getIdCharacter(): int
{ {
return $this->id_character; return $this->id_character;
} }
public function getName() : string
{
return $this -> name;
}
public function getImgPath() : string
{
return $this -> img_path;
}
/**
* @param int $id_character
*/
public function setIdCharacter(int $id_character): void public function setIdCharacter(int $id_character): void
{ {
$this->id_character = $id_character; $this->id_character = $id_character;
} }
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void public function setName(string $name): void
{ {
$this->name = $name; $this->name = $name;
} }
/**
* @return string
*/
public function getImgPath(): string
{
return $this->img_path;
}
/**
* @param string $img_path
*/
public function setImgPath(string $img_path): void public function setImgPath(string $img_path): void
{ {
$this->img_path = $img_path; $this->img_path = $img_path;
} }
} }

@ -6,34 +6,66 @@ class CommentaryEntity {
private string $comment; private string $comment;
private string $date; private string $date;
/**
public function __construct(int $id_comment, string $comment, string $date) { * @param int $id_comment
* @param string $comment
* @param string $date
*/
public function __construct(int $id_comment, string $comment, string $date)
{
$this->id_comment = $id_comment; $this->id_comment = $id_comment;
$this->comment = $comment; $this->comment = $comment;
$this->date = $date; $this->date = $date;
} }
public function getIdComment(): int { /**
* @return int
*/
public function getIdComment(): int
{
return $this->id_comment; return $this->id_comment;
} }
public function getComment(): string {
return $this->comment;
}
public function getDate(): string {
return $this->date;
}
public function setIdComment(int $id_comment): void { /**
* @param int $id_comment
*/
public function setIdComment(int $id_comment): void
{
$this->id_comment = $id_comment; $this->id_comment = $id_comment;
} }
public function setComment(string $comment): void { /**
* @return string
*/
public function getComment(): string
{
return $this->comment;
}
/**
* @param string $comment
*/
public function setComment(string $comment): void
{
$this->comment = $comment; $this->comment = $comment;
} }
public function setDate(string $date): void { /**
* @return string
*/
public function getDate(): string
{
return $this->date;
}
/**
* @param string $date
*/
public function setDate(string $date): void
{
$this->date = $date; $this->date = $date;
} }
} }

@ -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;
}
}

@ -10,6 +10,15 @@
private string $answerD; private string $answerD;
private string $cAnswer; private string $cAnswer;
/**
* @param int $id_question
* @param string $question
* @param string $answerA
* @param string $answerB
* @param string $answerC
* @param string $answerD
* @param string $cAnswer
*/
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer) public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
{ {
$this->id_question = $id_question; $this->id_question = $id_question;
@ -21,68 +30,118 @@
$this->cAnswer = $cAnswer; $this->cAnswer = $cAnswer;
} }
/**
* @return int
*/
public function getIdQuestion(): int public function getIdQuestion(): int
{ {
return $this->id_question; return $this->id_question;
} }
/**
* @param int $id_question
*/
public function setIdQuestion(int $id_question): void
{
$this->id_question = $id_question;
}
/**
* @return string
*/
public function getQuestion(): string public function getQuestion(): string
{ {
return $this->question; return $this->question;
} }
public function getAnswerA() : string /**
* @param string $question
*/
public function setQuestion(string $question): void
{ {
return $this -> answerA; $this->question = $question;
} }
public function getAnswerB() : string /**
* @return string
*/
public function getAnswerA(): string
{ {
return $this -> answerB; return $this->answerA;
} }
public function getAnswerC() : string /**
* @param string $answerA
*/
public function setAnswerA(string $answerA): void
{ {
return $this -> answerC; $this->answerA = $answerA;
} }
public function getAnswerD() : string /**
* @return string
*/
public function getAnswerB(): string
{ {
return $this -> answerD; return $this->answerB;
} }
public function getCAnswer() : string /**
* @param string $answerB
*/
public function setAnswerB(string $answerB): void
{ {
return $this -> cAnswer; $this->answerB = $answerB;
} }
public function setQuestion(string $newQuestion) : void /**
* @return string
*/
public function getAnswerC(): string
{ {
$this -> question = $question; return $this->answerC;
} }
public function setAnswerA(string $newAnswerA) : void /**
* @param string $answerC
*/
public function setAnswerC(string $answerC): void
{ {
$this -> answerA = $newAnswerA; $this->answerC = $answerC;
} }
public function setAnswerB(string $newAnswerB) : void /**
* @return string
*/
public function getAnswerD(): string
{ {
$this -> answerB = $newAnswerB; return $this->answerD;
} }
public function setAnswerC(string $newAnswerC) : void /**
* @param string $answerD
*/
public function setAnswerD(string $answerD): void
{ {
$this -> answerC = $newAnswerC; $this->answerD = $answerD;
} }
public function setAnswerD(string $newAnswerD) : void /**
* @return string
*/
public function getCAnswer(): string
{ {
$this -> answerD = $newAnswerD; return $this->cAnswer;
} }
public function setCAnswer(string $newCAnswer) : void /**
* @param string $cAnswer
*/
public function setCAnswer(string $cAnswer): void
{ {
$this -> cAnswer = $newCAnswer; $this->cAnswer = $cAnswer;
} }
} }

@ -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;
}
}

@ -11,7 +11,18 @@
private int $like; private int $like;
private string $langue; private string $langue;
function __construct(int $id, string $content, string $carac, string $imgPath, string $titleSrc, string $dateSrc, int $like, string $langue) { /**
* @param int $id
* @param string $content
* @param string $carac
* @param string $imgPath
* @param string $titleSrc
* @param string $dateSrc
* @param int $like
* @param string $langue
*/
public function __construct(int $id, string $content, string $carac, string $imgPath, string $titleSrc, string $dateSrc, int $like, string $langue)
{
$this->id = $id; $this->id = $id;
$this->content = $content; $this->content = $content;
$this->carac = $carac; $this->carac = $carac;
@ -22,68 +33,135 @@
$this->langue = $langue; $this->langue = $langue;
} }
public function getId() : int{ /**
return $id; * @return int
*/
public function getId(): int
{
return $this->id;
} }
public function getContent() : string{ /**
return $content; * @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
} }
public function getCarac() : string{ /**
return $content; * @return string
*/
public function getContent(): string
{
return $this->content;
} }
public function getImgPath() : string{ /**
return $imgPath; * @param string $content
*/
public function setContent(string $content): void
{
$this->content = $content;
} }
public function getTitleSrc() : string{ /**
return $titleSrc; * @return string
*/
public function getCarac(): string
{
return $this->carac;
} }
public function getDateSrc() : string{ /**
return $dateSrc; * @param string $carac
*/
public function setCarac(string $carac): void
{
$this->carac = $carac;
} }
public function getLike() : int{ /**
return $like; * @return string
*/
public function getImgPath(): string
{
return $this->imgPath;
} }
public function getLangue() : string{ /**
return $langue; * @param string $imgPath
*/
public function setImgPath(string $imgPath): void
{
$this->imgPath = $imgPath;
} }
public function setId(int $id){ /**
$this->id = $id; * @return string
*/
public function getTitleSrc(): string
{
return $this->titleSrc;
} }
public function setContent(string $content){ /**
$this->content = $content; * @param string $titleSrc
*/
public function setTitleSrc(string $titleSrc): void
{
$this->titleSrc = $titleSrc;
} }
public function setCarac(string $carac){ /**
$this->carac = $carac; * @return string
*/
public function getDateSrc(): string
{
return $this->dateSrc;
} }
public function setImgPath(string $imgPat){ /**
$this->imgPath = $imgPath; * @param string $dateSrc
*/
public function setDateSrc(string $dateSrc): void
{
$this->dateSrc = $dateSrc;
} }
public function setTitleSrc(string $titleSrc){ /**
$this->titleSrc = $titleSrc; * @return int
*/
public function getLike(): int
{
return $this->like;
} }
public function setDateSrc(string $dateSrc){ /**
$this->datesrc = $dateSrc; * @param int $like
*/
public function setLike(int $like): void
{
$this->like = $like;
} }
public function setLike(int $like){ /**
$this->like = $like; * @return string
*/
public function getLangue(): string
{
return $this->langue;
} }
public function setlangue(string $langue){ /**
* @param string $langue
*/
public function setLangue(string $langue): void
{
$this->langue = $langue; $this->langue = $langue;
} }
} }
?> ?>

@ -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;
}
}

@ -8,6 +8,11 @@ class SourceEntity
private string $date; private string $date;
/**
* @param int $id_source
* @param string $title
* @param string $date
*/
public function __construct(int $id_source, string $title, string $date) public function __construct(int $id_source, string $title, string $date)
{ {
$this->id_source = $id_source; $this->id_source = $id_source;
@ -15,33 +20,57 @@ class SourceEntity
$this->date = $date; $this->date = $date;
} }
/**
* @return int
*/
public function getIdSource(): int public function getIdSource(): int
{ {
return $this->id_source; return $this->id_source;
} }
public function getTitle() : string /**
* @param int $id_source
*/
public function setIdSource(int $id_source): void
{ {
return $this -> title ; $this->id_source = $id_source;
} }
public function getDate() : string /**
* @return string
*/
public function getTitle(): string
{ {
return $this -> date ; return $this->title;
} }
public function setIdSource(int $id_source) : void /**
* @param string $title
*/
public function setTitle(string $title): void
{ {
$this -> id_source = $id_source ; $this->title = $title;
} }
public function setTitle(string $title): void{ /**
$this -> title = $title ; * @return string
*/
public function getDate(): string
{
return $this->date;
} }
/**
* @param string $date
*/
public function setDate(string $date): void public function setDate(string $date): void
{ {
$this->date = $date; $this->date = $date;
} }
} }

@ -9,51 +9,115 @@
private string $img; private string $img;
private string $email; private string $email;
function __construct(string $id, string $pseudo, string $password, string $image, string $mail) { /**
* @param string $id
* @param string $username
* @param string $passwd
* @param string $hidenPasswd
* @param string $img
* @param string $email
*/
public function __construct(string $id, string $username, string $passwd, string $img, string $email)
{
$this->id = $id; $this->id = $id;
$this->username = $pseudo; $this->username = $username;
$this->passwd = $password; $this->passwd = $passwd;
$this->hidenPasswd = hidenPassWd($password); $this->hidenPasswd = hidenPasswd($passwd);
$this->img = $image; $this->img = $img;
$this->email = $mail; $this->email = $email;
} }
public function getId() : string{ /**
* @return string
*/
public function getId(): string
{
return $this->id; return $this->id;
} }
public function getUsername() : string{ /**
* @param string $id
*/
public function setId(string $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getUsername(): string
{
return $this->username; return $this->username;
} }
public function getPasswd() : string{ /**
return $this->passwd; * @param string $username
*/
public function setUsername(string $username): void
{
$this->username = $username;
} }
public function getImg() : string{ /**
* @return string
*/
public function getImg(): string
{
return $this->img; return $this->img;
} }
public function getEmail() : string{ /**
* @param string $img
*/
public function setImg(string $img): void
{
$this->img = $img;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email; return $this->email;
} }
public function setUsername(string $username){ /**
$this->username = $username; * @param string $email
*/
public function setEmail(string $email): void
{
$this->email = $email;
} }
public function setPasswd(string $passwd){ /**
$this->passwd = $passwd; * @return string
$this->hidenPassWd = hidenPassWd($passwd); */
public function getPasswd(): string
{
return $this->passwd;
} }
public function setImg(string $img){ /**
$this->img = $img; * @return string
*/
public function getHidenPasswd(): string
{
return $this->hidenPasswd;
} }
public function setEmail(string $email){ /**
$this->email = $email; * @param string $passwd
*/
public function setPasswd(string $passwd): void
{
$this->passwd = $passwd;
$this->hidenPassWd = hidenPassWd($passwd);
} }
} }

@ -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…
Cancel
Save