Skip to content

Commit

Permalink
Merge pull request #9 from studoo-app/dev
Browse files Browse the repository at this point in the history
v1.20
  • Loading branch information
bfoujols authored Oct 12, 2023
2 parents 509a53b + 7f8709d commit 4f4da31
Show file tree
Hide file tree
Showing 43 changed files with 847 additions and 1,616 deletions.
13 changes: 13 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ____ _ _
# / ___|| |_ _ _ __| | ___ ___
# \___ \| __| | | |/ _` |/ _ \ / _ \
# ___) | |_| |_| | (_| | (_) | (_) |
# |____/ \__|\__,_|\__,_|\___/ \___/
# ___ ___ _ __ / _(_) __ _
# / __/ _ \| '_ \| |_| |/ _` |
# | (_| (_) | | | | _| | (_| |
# \___\___/|_| |_|_| |_|\__, |
# |___/
#
# Fichier de configuration des variables d'environnement du projet
#
2 changes: 1 addition & 1 deletion Insomnia.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_type":"export","__export_format":4,"__export_date":"2023-05-20T20:40:31.494Z","__export_source":"insomnia.desktop.app:v2023.2.1","resources":[{"_id":"req_f76fef108bc34f9b8c5e0894182ade73","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613331771,"created":1684613090752,"url":"{{ _.base_url }}/login","name":"AUTH","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={\"identifiant\":\"{% prompt 'Login', 'Login', '', '', false, true %}\",\"motdepasse\":\"{% prompt 'Password', 'Password', '', '', false, true %}\"}"},"parameters":[],"headers":[{"id":"pair_bee54c9f90a0457496c9867f51e5827c","name":"User-Agent","value":"{{ _.userAgent }}","description":""},{"name":"Content-Type","value":"text/plain","id":"pair_7e017438bdb341479dd693b79b630048"}],"authentication":{"type":"basic","useISO88591":false,"disabled":false,"username":"","password":""},"metaSortKey":-1677642375217.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_8b88eed40d18448594eb2ca1c852227e","parentId":null,"modified":1684613090743,"created":1684613090743,"name":"[Mock] API Ecole directe","description":"","scope":"collection","_type":"workspace"},{"_id":"req_e0dfbd1e3be94402a3941e817a592005","parentId":"fld_5c938e65e9be45bda8694b8da4b9e272","modified":1684615179620,"created":1684613090749,"url":"{{ _.base_url }}/eleves/{% prompt 'ID Etudiant', 'ID Etudiant', '', '', false, true %}/viescolaire","name":"VIE-SCOLAIRE","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={}"},"parameters":[],"headers":[{"name":"Content-Type","value":"text/plain","id":"pair_da6e720040bb4431bb15a67b641916fd"},{"id":"pair_95df22947d88461baaca60aa205db67f","name":"X-Token","value":"{{ _.token }}","description":""},{"id":"pair_997347b40daf4ff6819055cf8da2ce66","name":"User-Agent","value":"{{ _.userAgent }}","description":""}],"authentication":{},"metaSortKey":-1677696694751.875,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_5c938e65e9be45bda8694b8da4b9e272","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090748,"created":1684613090748,"name":"ETUDIANTS","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1677629788426.875,"_type":"request_group"},{"_id":"req_cc705a1d7f924e729fc89c3b799a7e04","parentId":"fld_5aa0e4b2e1564040a1e231a446572cfb","modified":1684614987076,"created":1684613090751,"url":"{{ _.base_url }}/classes/{% prompt 'ID CLASSE', 'ID CLASSE', '', '', false, true %}/eleves","name":"LISTE DES ETUDIANTS","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={}"},"parameters":[],"headers":[{"id":"pair_b37126573c854406b85e983c77284fd9","name":"X-Token","value":"{{ _.token }}","description":""},{"id":"pair_99d38edcf3c849dbb3b8be616bca3eca","name":"User-Agent","value":"{{ _.userAgent }}","description":""},{"name":"Content-Type","value":"text/plain","id":"pair_fd3f6e0637384d6e83c31b3639709a60"}],"authentication":{},"metaSortKey":-1679944295730,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_5aa0e4b2e1564040a1e231a446572cfb","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090750,"created":1684613090750,"name":"PROFESSEUR","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1677629788401.875,"_type":"request_group"},{"_id":"env_c86073e7e91344a0b2d45a71d145ee44","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684614768759,"created":1684613090744,"name":"Base Environment","data":{"base_url":"{{ _.protocol }}://{{ _.domain }}{{ _.path }}","protocol":"http","domain":"localhost:9042","path":"/v3","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","token":"{% response 'body', 'req_f76fef108bc34f9b8c5e0894182ade73', 'b64::JC50b2tlbg==::46b', 'when-expired', 60 %}"},"dataPropertyOrder":{"&":["base_url","protocol","domain","path","userAgent","token"]},"color":null,"isPrivate":false,"metaSortKey":1677616649078,"_type":"environment"},{"_id":"jar_e9e9b6b35c3b4d90a5145f07deeb76c6","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613142826,"created":1684613090745,"name":"Default Jar","cookies":[{"key":"PHPSESSID","value":"empc08h39h98f6h6fk8j9tfrd0","domain":"localhost","path":"/","hostOnly":true,"creation":"2023-05-20T20:05:42.825Z","lastAccessed":"2023-05-20T20:05:42.825Z","id":"2986582957181614"}],"_type":"cookie_jar"},{"_id":"spc_0f7734a76e19414a9e6d3515ba3781bc","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090755,"created":1684613090746,"fileName":"[Mock] API Ecole directe","contents":"","contentType":"yaml","_type":"api_spec"}]}
{"_type":"export","__export_format":4,"__export_date":"2023-10-12T14:17:51.738Z","__export_source":"insomnia.desktop.app:v8.2.0","resources":[{"_id":"req_06083037e4e14496a02f2faa755b9168","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120188374,"created":1697118847636,"url":"http://localhost:9042/dataset/profs","name":"DATASET PROFS","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1697118847636,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_9e80fda306104119b8e2e665d2eddb1e","parentId":null,"modified":1681383240922,"created":1681383240922,"name":"Mock API Ecole Directe","description":"","scope":"collection","_type":"workspace"},{"_id":"req_d67ed6f5c06446358e1ed66f62c2a11b","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120156017,"created":1697120150273,"url":"http://localhost:9042/dataset/etudiants","name":"DATASET ETUDIANTS","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696862822785.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_eaedb5c0d0a5405385e2e79947361ee8","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120194084,"created":1697120182749,"url":"http://localhost:9042/dataset/classes","name":"DATASET CLASSES","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696734810360.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_4276619706334739b397a880d8d76e17","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696606872779,"created":1696606797935,"url":"http://localhost:9042/init","name":"INIT","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696606797935,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_51d08a58b665460dbf867d962403c913","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696610741054,"created":1684303208342,"url":"http://localhost:9042/v3/classes/{% prompt 'id', 'id', '', '', false, true %}/eleves","name":"CLASSE","description":"","method":"POST","body":{},"parameters":[],"headers":[{"id":"pair_983dd164565f44e9b66542fa4f81d500","name":"X-Token","value":"e9cd1a5abe69b9e01fa0015dc0def07ef36d9567e3cdf60d20d3","description":""}],"authentication":{},"metaSortKey":-1684303208342,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_66b0b30b48e2441c8d51c4fca6409b92","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696610710540,"created":1681383248003,"url":"http://localhost:9042/v3/login","name":"AUTH","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={\"identifiant\":\"{% prompt 'Login', 'Login', '', '', false, true %}\",\"motdepasse\":\"{% prompt 'Password', 'Password', '', '', false, true %}\"}"},"parameters":[],"headers":[{"name":"Content-Type","value":"text/plain"}],"authentication":{},"metaSortKey":-1681383248003,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_08a1b82f717c1ad5425d2279ef144cc067a1c261","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1681383240924,"created":1681383240924,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1681383240924,"_type":"environment"},{"_id":"jar_08a1b82f717c1ad5425d2279ef144cc067a1c261","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1684611502035,"created":1681383240925,"name":"Default Jar","cookies":[{"key":"PHPSESSID","value":"kut4a64nfh8mfogiug456o2lsd","domain":"localhost","path":"/","hostOnly":true,"creation":"2023-05-20T19:38:22.035Z","lastAccessed":"2023-05-20T19:38:22.035Z","id":"031894855197976524"}],"_type":"cookie_jar"},{"_id":"spc_0214a1ff9d82431f96dd9f65e12e7faf","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1681383240922,"created":1681383240922,"fileName":"Mock API Ecole Directe","contents":"","contentType":"yaml","_type":"api_spec"}]}
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,36 @@ Vous pouvez tester l'API via Insomnia :

## Utilisation de l'API Ecole Directe Mock

Ce mock auto-génère des données aléatoires pour les tokens authentifications :
Ce mock auto-génère des données à travers des fakers :

### API : /dataset/classes

Visualisation des données des classes

### API : /dataset/etudiants

Visualisation des données des étudiants

### API : /dataset/profs

Visualisation des données des profs

### API : /login

| Login/Password | Role | Niveau | Id Niveau |
|--------------------------|----------------|--------------------------|---------------|
| flore/test | Etudiante | BTS SIO 1 année A (1TSSIOA) | 107 |
| julie/test | Etudiante | BTS SIO 1 année B (1TSSIOB) | 150 |
| nico/test | Etudiant | BTS SIO 2 année (2TSSIOSLAM) | 102 |
| jeremy/test | Etudiant | MASTER 2 (MS2D2ALT) | 140 |
| jbouvier/test | Prof | BTS SIO ADM | 107, 102, 140 |
| bdan/test | Prof | BTS SIO ADM | 107, 150 |
Certains users sont configurés dans le fichier de configDataSet

| Login/Password | Role | Niveau | Id Niveau |
|--------------------------|----------------|------------------------------|---------------|
| FPELTIER/test | Etudiante | BTS SIO 1 année A (1TSSIOA) | 107 |
| PTORRE/test | Etudiante | BTS SIO 1 année A (1TSSIOA) | 107 |
| JBOULLAM/test | Etudiant | Bachelor CSI | 140 |

### API : /classes

| Login/Password | Role | Niveau | Id Niveau |
|--------------------------|----------------|--------------------------|---------------|
| jbouvier/test | Prof | BTS SIO ADM | 107 |
| Login/Password | Role | Id Classe |
|--------------------------|----------------|---------------------|
| JBOUVIER/test | Prof | 107,120,134,140,141 |
| BDAN/test | Prof | 107,120 |

## Pour developper le mock
Télécharger le projet depuis GitHub et se rendre dans le dossier
Expand Down
17 changes: 0 additions & 17 deletions api/index.php

This file was deleted.

28 changes: 28 additions & 0 deletions app/Config/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
index:
uri: /
controller: Controller\WelcomeController
httpMethod: [GET]
datasetclasses:
uri: /dataset/classes
controller: Controller\DataSetClassesController
httpMethod: [GET]
datasetetudiants:
uri: /dataset/etudiants
controller: Controller\DataSetEtudiantsController
httpMethod: [GET]
datasetprof:
uri: /dataset/profs
controller: Controller\DataSetProfController
httpMethod: [GET]
init:
uri: /init
controller: Controller\InitController
httpMethod: [GET]
login:
uri: /{api}/login
controller: Controller\LoginController
httpMethod: [POST]
classe:
uri: /{api}/classes/{classe}/eleves
controller: Controller\ClasseController
httpMethod: [GET,POST]
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
*/


namespace MockEcoleDirecteApi\Controller;
namespace Controller;

use MockEcoleDirecteApi\Core\Controller\Request;
use MockEcoleDirecteApi\Model\LoginModel;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;
use Model\LoginModel;

class ClasseController implements \MockEcoleDirecteApi\Core\Controller\ControllerInterface
class ClasseController implements ControllerInterface
{
public function execute(Request $request): bool|string
public function execute(Request $request): string|null
{
$versionAPI = strtoupper($request->getVars()["api"]);

Expand Down
30 changes: 30 additions & 0 deletions app/Controller/DataSetClassesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetClassesController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM classes");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
30 changes: 30 additions & 0 deletions app/Controller/DataSetEtudiantsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetEtudiantsController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM users WHERE typeCompte = 'E' ORDER BY classeId");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
30 changes: 30 additions & 0 deletions app/Controller/DataSetProfController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetProfController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM users WHERE typeCompte = 'P' ORDER BY classeId");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
Loading

0 comments on commit 4f4da31

Please sign in to comment.