commit
109ddd9ff5
@ -0,0 +1,62 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CI-pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
|
||||
|
||||
- name: code-inspection
|
||||
image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8
|
||||
secrets: [ SECRET_SONAR_LOGIN ]
|
||||
settings:
|
||||
sonar_host: https://codefirst.iut.uca.fr/sonar/
|
||||
sonar_token:
|
||||
from_secret: SECRET_SONAR_LOGIN
|
||||
commands:
|
||||
- dotnet sonarscanner begin /k:WF-Website /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
|
||||
|
||||
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
|
||||
- dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
|
||||
|
||||
# database container deployment
|
||||
- name: deploy-container-mysql-WIKI_FANTASY
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
environment:
|
||||
IMAGENAME: mysql:latest
|
||||
CONTAINERNAME: mysql
|
||||
COMMAND: create
|
||||
OVERWRITE: false
|
||||
PRIVATE: true
|
||||
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
|
||||
from_secret: db_root_password
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
|
||||
from_secret: db_database
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
|
||||
from_secret: db_user
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
|
||||
from_secret: db_password
|
||||
ADMINS: kentinbrongniart , kevinmondejar , lenibeaulaton , louisguichard-montguers , maximerocher , tommynguyen , matthieurestituito
|
||||
|
||||
|
||||
- name: generate-and-deploy-docs
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
|
||||
failure: ignore
|
||||
volumes:
|
||||
- name:
|
||||
path:
|
||||
commands:
|
||||
- /entrypoint.sh
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
depends_on: []
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
class Quote{
|
||||
public int $id;
|
||||
public string $content;
|
||||
public string $carac;
|
||||
public string $imgPath;
|
||||
public string $titleSrc;
|
||||
public string $dateSrc;
|
||||
public int $like;
|
||||
public string $langue;
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include('Connection.php');
|
||||
|
||||
Class UserGateway{
|
||||
private Connection $con;
|
||||
|
||||
public function __construct(Connection $con){
|
||||
$this->con=$con;
|
||||
}
|
||||
|
||||
public function searchQuote(string $quote,int $numpage,string $language):array{
|
||||
|
||||
//recherche par citation
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE content LIKE '%:quote%' AND isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function searchSource(string $source,int $numpage,string $language):array{
|
||||
|
||||
//recherche par source
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE s.title LIKE '%:source%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function searchPers(string $Carac,int $numpage,string $language):array{
|
||||
|
||||
//recherche par personnage
|
||||
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE c.caracter LIKE '%:pers%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
|
||||
$this->con->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getComment(int $id):array{
|
||||
|
||||
//obtention des commentaire d'une citation
|
||||
$query="SELECT c.id_comment u.username, u.imgPath, c.comment, c.date FROM Commentary c JOIN Quote q ON c.quote = q.id_quote JOIN User u ON u.id_user = c.user JOIN Image i ON i.id_img = u.img WHERE id_quote = :id;";
|
||||
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
|
||||
$result=$this->con->getResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
class QuestionEntity
|
||||
{
|
||||
private int $id_question;
|
||||
private string $question;
|
||||
private string $answerA;
|
||||
private string $answerB;
|
||||
private string $answerC;
|
||||
private string $answerD;
|
||||
private 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 -> question = $question;
|
||||
$this -> answerA = $answerA;
|
||||
$this -> answerB = $answerB;
|
||||
$this -> answerC = $answerC;
|
||||
$this -> answerD = $answerD;
|
||||
$this -> cAnswer = $cAnswer;
|
||||
}
|
||||
|
||||
public function getIdQuestion() : int
|
||||
{
|
||||
return $this -> id_question;
|
||||
}
|
||||
|
||||
public function getQuestion() : string
|
||||
{
|
||||
return $this -> question;
|
||||
}
|
||||
|
||||
public function getAnswerA() : string
|
||||
{
|
||||
return $this -> answerA;
|
||||
}
|
||||
|
||||
public function getAnswerB() : string
|
||||
{
|
||||
return $this -> answerB;
|
||||
}
|
||||
|
||||
public function getAnswerC() : string
|
||||
{
|
||||
return $this -> answerC;
|
||||
}
|
||||
|
||||
public function getAnswerD() : string
|
||||
{
|
||||
return $this -> answerD;
|
||||
}
|
||||
|
||||
public function getCAnswer() : string
|
||||
{
|
||||
return $this -> cAnswer;
|
||||
}
|
||||
|
||||
public function setQuestion(string $newQuestion) : void
|
||||
{
|
||||
$this -> question = $question;
|
||||
}
|
||||
|
||||
public function setAnswerA(string $newAnswerA) : void
|
||||
{
|
||||
$this -> answerA = $newAnswerA;
|
||||
}
|
||||
|
||||
public function setAnswerB(string $newAnswerB) : void
|
||||
{
|
||||
$this -> answerB = $newAnswerB;
|
||||
}
|
||||
|
||||
public function setAnswerC(string $newAnswerC) : void
|
||||
{
|
||||
$this -> answerC = $newAnswerC;
|
||||
}
|
||||
|
||||
public function setAnswerD(string $newAnswerD) : void
|
||||
{
|
||||
$this -> answerD = $newAnswerD;
|
||||
}
|
||||
|
||||
public function setCAnswer(string $newCAnswer) : void
|
||||
{
|
||||
$this -> cAnswer = $newCAnswer;
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
require_once("../script/Connection.php");
|
||||
require_once("questionEntity.php");
|
||||
|
||||
class QuestionGateway
|
||||
{
|
||||
private Connection $co;
|
||||
|
||||
public function __construct(Connection $co)
|
||||
{
|
||||
$this -> co = $co;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new question into the database
|
||||
*
|
||||
* @param QuestionEntity $q The `Question` object to insert
|
||||
* @return bool True if the question was successfully inserted, false otherwise
|
||||
*/
|
||||
public function create(QuestionEntity $q) : bool
|
||||
{
|
||||
$query = "
|
||||
INSERT INTO Question
|
||||
VALUES(:id_q, :question, :answerA, :answerB, :answerC, :answerD, :cAnswer)
|
||||
";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
|
||||
return $stmt -> execute([
|
||||
':id_q' => $q -> getIdquestion(),
|
||||
':question' => $q -> getQuestion(),
|
||||
':answerA' => $q -> getAnswerA(),
|
||||
':answerB' => $q -> getAnswerB(),
|
||||
':answerC' => $q -> getAnswerC(),
|
||||
':answerD' => $q -> getAnswerD(),
|
||||
':cAnswer' => $q -> getCAnswer()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a question from the database by its ID
|
||||
*
|
||||
* @param int $id The ID of the question to retrieve
|
||||
* @return QuestionEntity|null The `Question` object if found, null otherwise
|
||||
*/
|
||||
public function findById(int $id) : ?QuestionEntity
|
||||
{
|
||||
$query = "SELECT * FROM Question WHERE id_question = :id_q";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
$stmt -> execute([':id' => $id]);
|
||||
$res = $stmt -> fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($res)
|
||||
return new QuestionEntity(
|
||||
$res['id_q'],
|
||||
$res['question'],
|
||||
$res['answerA'],
|
||||
$res['answerB'],
|
||||
$res['answerC'],
|
||||
$res['answerD'],
|
||||
$res['cAnswer'],
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the text of and an existing question in the database
|
||||
*
|
||||
* @param QuestionEntity $q The `Question` object with updated information
|
||||
* @return bool True if the text of the question was successfully updated, false otherwise
|
||||
*/
|
||||
public function updateText(QuestionEntity $q) : bool
|
||||
{
|
||||
$query = "
|
||||
UPDATE Question
|
||||
SET question = :question
|
||||
WHERE id_question = :id_q
|
||||
";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
|
||||
return $stmt -> execute([':question' => $q -> getQuestion()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the answers of an existing question in the database
|
||||
*
|
||||
* @param QuestionEntity $q The `Question` object with updated information
|
||||
* @return bool True if the answers of the question was successfully updated, false otherwise
|
||||
*/
|
||||
public function updateAnswers(QuestionEntity $q) : bool
|
||||
{
|
||||
$query = "
|
||||
UPDATE Question
|
||||
SET answerA = :answerA, answerB = :answerB,
|
||||
answerC = :answerC, answerD = :answerD, cAnswer = :cAnswer
|
||||
WHERE id_question = :id_q
|
||||
";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
|
||||
return $stmt -> execute([
|
||||
':id_q' => $q -> getIdQuestion(),
|
||||
':answerA' => $q -> getAnswerA(),
|
||||
':answerB' => $q -> getAnswerB(),
|
||||
':answerC' => $q -> getAnswerC(),
|
||||
':answerD' => $q -> getAnswerD(),
|
||||
':cAnswer' => $q -> getCAnswer(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
|
||||
return $stmt -> execute([':id_q' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all quizzes from the database
|
||||
*
|
||||
* @return QuestionEntity[] An array of `Question` objects
|
||||
*/
|
||||
public function findAll() : array
|
||||
{
|
||||
$query = "SELECT * FROM Question";
|
||||
$stmt = $this -> co -> prepare($query);
|
||||
$stmt->execute();
|
||||
$res = $stmt -> fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$questions = [];
|
||||
|
||||
foreach ($res as $q)
|
||||
$questions[] = new QuestionEntity(
|
||||
$q['id_question'],
|
||||
$q['question'],
|
||||
$q['answerA'],
|
||||
$q['answerB'],
|
||||
$q['answerC'],
|
||||
$q['answerD'],
|
||||
$q['cAnswer']
|
||||
);
|
||||
|
||||
return $questions;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
require_once("questionEntity.php");
|
||||
require_once("questionGateway.php");
|
||||
|
||||
class questionModel
|
||||
{
|
||||
private QuestionGateway $gateway;
|
||||
|
||||
public function __construct(QuestionGateway $gateway)
|
||||
{
|
||||
$this -> gateway = $gateway;
|
||||
}
|
||||
|
||||
public function createQuestion(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer) : bool
|
||||
{
|
||||
$q = new QuestionEntity($id_question, $question, $answerA, $answerB, $answerC, $answerD, $cAnswer);
|
||||
return $this -> gateway -> create($q);
|
||||
}
|
||||
|
||||
public function getQuestion(int $id_question) : ?QuestionEntity
|
||||
{
|
||||
return $this -> gateway -> findById($id_question);
|
||||
}
|
||||
|
||||
public function updateTextQuestion(int $id_question, string $question) : bool
|
||||
{
|
||||
$q = $this -> gateway -> findById($id_question);
|
||||
|
||||
if ($q)
|
||||
{
|
||||
$q -> setQuestion($question);
|
||||
return $this -> gateway -> updateText($q);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateAnswersQuestion(int $id_question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer) : bool
|
||||
{
|
||||
$q = $this -> gateway -> findById($id_question);
|
||||
|
||||
if ($q)
|
||||
{
|
||||
$q -> setAnswerA($answerA);
|
||||
$q -> setAnswerB($answerB);
|
||||
$q -> setAnswerC($answerC);
|
||||
$q -> setAnswerD($answerD);
|
||||
$q -> setAnswerC($cAnswer);
|
||||
return $this -> gateway -> updateAnswers($q);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteQuestion(int $id_question) : bool
|
||||
{
|
||||
return $this -> gateway -> delete($id_question);
|
||||
}
|
||||
|
||||
public function getAllQuestions() : array
|
||||
{
|
||||
return $this -> gateway -> findAll();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
TesteurFichier
|
||||
motDepasseFichier
|
||||
../images/imageProfil.png
|
||||
testeurFichier.compte@wikifantasy.com
|
Loading…
Reference in new issue