first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
export function buildURL(query) {
|
||||||
|
let url =
|
||||||
|
"https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?limit=10"
|
||||||
|
|
||||||
|
if (query && query.trim() !== "") {
|
||||||
|
url += "&where=search(lib_for_voe_ins, '" + query + "')"
|
||||||
|
}
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchFormations(query) {
|
||||||
|
const url = buildURL(query)
|
||||||
|
const response = await fetch(url)
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Erreur HTTP")
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export function buildURL(query) {
|
||||||
|
let url =
|
||||||
|
"https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?limit=10"
|
||||||
|
|
||||||
|
if (query && query.trim() !== "") {
|
||||||
|
url += "&where=search(lib_for_voe_ins, '" + query + "')"
|
||||||
|
}
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchFormations(query) {
|
||||||
|
const url = buildURL(query)
|
||||||
|
const response = await fetch(url)
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Erreur HTTP")
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json()
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export function createFormation(raw) {
|
||||||
|
let taux = 0
|
||||||
|
|
||||||
|
if (raw.voe_tot && raw.voe_tot > 0) {
|
||||||
|
taux = Math.round((raw.acc_tot / raw.voe_tot) * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: raw.cod_uai + "-" + raw.lib_for_voe_ins,
|
||||||
|
nom: raw.lib_for_voe_ins,
|
||||||
|
etablissement: raw.g_ea_lib_vx,
|
||||||
|
ville: raw.ville_etab,
|
||||||
|
departement: raw.dep,
|
||||||
|
filiere: raw.fili,
|
||||||
|
selectivite: raw.select_form,
|
||||||
|
capacite: raw.capa_fin,
|
||||||
|
candidats: raw.voe_tot,
|
||||||
|
admis: raw.acc_tot,
|
||||||
|
tauxAcces: taux,
|
||||||
|
latitude: raw.g_olocalisation_des_formations ? raw.g_olocalisation_des_formations.lat : null,
|
||||||
|
longitude: raw.g_olocalisation_des_formations ? raw.g_olocalisation_des_formations.lon : null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export function createFormation(raw) {
|
||||||
|
let taux = 0
|
||||||
|
|
||||||
|
if (raw.voe_tot && raw.voe_tot > 0) {
|
||||||
|
taux = Math.round((raw.acc_tot / raw.voe_tot) * 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: raw.cod_uai + "-" + raw.lib_for_voe_ins,
|
||||||
|
nom: raw.lib_for_voe_ins,
|
||||||
|
etablissement: raw.g_ea_lib_vx,
|
||||||
|
ville: raw.ville_etab,
|
||||||
|
departement: raw.dep,
|
||||||
|
filiere: raw.fili,
|
||||||
|
selectivite: raw.select_form,
|
||||||
|
capacite: raw.capa_fin,
|
||||||
|
candidats: raw.voe_tot,
|
||||||
|
admis: raw.acc_tot,
|
||||||
|
tauxAcces: taux,
|
||||||
|
latitude: raw.g_olocalisation_des_formations ? raw.g_olocalisation_des_formations.lat : null,
|
||||||
|
longitude: raw.g_olocalisation_des_formations ? raw.g_olocalisation_des_formations.lon : null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Parcoursup - test API</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Mini projet Parcoursup</h1>
|
||||||
|
<p>Recherche de formations Parcoursup</p>
|
||||||
|
|
||||||
|
<input id="search" type="text" placeholder="Ex : BUT informatique" />
|
||||||
|
<button id="btn-test">Rechercher</button>
|
||||||
|
|
||||||
|
<div id="output">En attente...</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="module" src="./main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Parcoursup - test API</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Mini projet Parcoursup</h1>
|
||||||
|
<p>Recherche de formations Parcoursup</p>
|
||||||
|
|
||||||
|
<input id="search" type="text" placeholder="Ex : BUT informatique" />
|
||||||
|
<button id="btn-test">Rechercher</button>
|
||||||
|
|
||||||
|
<div id="output">En attente...</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="module" src="./main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { fetchFormations } from "./api.js"
|
||||||
|
import { createFormation } from "./formation.js"
|
||||||
|
|
||||||
|
let lastFormations = []
|
||||||
|
|
||||||
|
const button = document.getElementById("btn-test")
|
||||||
|
const output = document.getElementById("output")
|
||||||
|
const searchInput = document.getElementById("search")
|
||||||
|
|
||||||
|
function showDetail(index) {
|
||||||
|
const f = lastFormations[index]
|
||||||
|
|
||||||
|
output.innerHTML = `
|
||||||
|
<div style="border:1px solid #ccc; padding:10px; margin:10px;">
|
||||||
|
<h2>${f.nom}</h2>
|
||||||
|
<p><b>Établissement :</b> ${f.etablissement}</p>
|
||||||
|
<p><b>Ville :</b> ${f.ville}</p>
|
||||||
|
<p><b>Département :</b> ${f.departement}</p>
|
||||||
|
<p><b>Filière :</b> ${f.filiere}</p>
|
||||||
|
<p><b>Sélectivité :</b> ${f.selectivite}</p>
|
||||||
|
<p><b>Capacité :</b> ${f.capacite}</p>
|
||||||
|
<p><b>Candidats :</b> ${f.candidats}</p>
|
||||||
|
<p><b>Admis :</b> ${f.admis}</p>
|
||||||
|
<p><b>Taux d'accès :</b> ${f.tauxAcces}%</p>
|
||||||
|
<button id="back-btn">Retour</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
|
||||||
|
const backBtn = document.getElementById("back-btn")
|
||||||
|
backBtn.addEventListener("click", testAPI)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.showDetail = showDetail
|
||||||
|
|
||||||
|
async function testAPI() {
|
||||||
|
output.textContent = "Chargement..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query = searchInput.value
|
||||||
|
|
||||||
|
const data = await fetchFormations(query)
|
||||||
|
|
||||||
|
if (data.results && data.results.length > 0) {
|
||||||
|
const formations = []
|
||||||
|
|
||||||
|
for (let i = 0; i < data.results.length; i++) {
|
||||||
|
const raw = data.results[i]
|
||||||
|
const formation = createFormation(raw)
|
||||||
|
formations.push(formation)
|
||||||
|
}
|
||||||
|
|
||||||
|
lastFormations = formations
|
||||||
|
|
||||||
|
let html = ""
|
||||||
|
|
||||||
|
for (let i = 0; i < formations.length; i++) {
|
||||||
|
const f = formations[i]
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<div style="border:1px solid #ccc; padding:10px; margin:10px;">
|
||||||
|
<h3>${f.nom}</h3>
|
||||||
|
<p><b>Établissement :</b> ${f.etablissement}</p>
|
||||||
|
<p><b>Ville :</b> ${f.ville} (${f.departement})</p>
|
||||||
|
<p><b>Filière :</b> ${f.filiere}</p>
|
||||||
|
<p><b>Taux d'accès :</b> ${f.tauxAcces}%</p>
|
||||||
|
<button onclick="showDetail(${i})">Voir détail</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
output.innerHTML = html
|
||||||
|
} else {
|
||||||
|
output.textContent = "Aucun résultat trouvé"
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erreur :", error)
|
||||||
|
output.textContent = "Erreur lors de la requête"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button.addEventListener("click", testAPI)
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { fetchFormations } from "./api.js"
|
||||||
|
import { createFormation } from "./formation.js"
|
||||||
|
|
||||||
|
let lastFormations = []
|
||||||
|
|
||||||
|
const button = document.getElementById("btn-test")
|
||||||
|
const output = document.getElementById("output")
|
||||||
|
const searchInput = document.getElementById("search")
|
||||||
|
|
||||||
|
function showDetail(index) {
|
||||||
|
const f = lastFormations[index]
|
||||||
|
|
||||||
|
output.innerHTML = `
|
||||||
|
<div style="border:1px solid #ccc; padding:10px; margin:10px;">
|
||||||
|
<h2>${f.nom}</h2>
|
||||||
|
<p><b>Établissement :</b> ${f.etablissement}</p>
|
||||||
|
<p><b>Ville :</b> ${f.ville}</p>
|
||||||
|
<p><b>Département :</b> ${f.departement}</p>
|
||||||
|
<p><b>Filière :</b> ${f.filiere}</p>
|
||||||
|
<p><b>Sélectivité :</b> ${f.selectivite}</p>
|
||||||
|
<p><b>Capacité :</b> ${f.capacite}</p>
|
||||||
|
<p><b>Candidats :</b> ${f.candidats}</p>
|
||||||
|
<p><b>Admis :</b> ${f.admis}</p>
|
||||||
|
<p><b>Taux d'accès :</b> ${f.tauxAcces}%</p>
|
||||||
|
<button id="back-btn">Retour</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
|
||||||
|
const backBtn = document.getElementById("back-btn")
|
||||||
|
backBtn.addEventListener("click", testAPI)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.showDetail = showDetail
|
||||||
|
|
||||||
|
async function testAPI() {
|
||||||
|
output.textContent = "Chargement..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
const query = searchInput.value
|
||||||
|
|
||||||
|
const data = await fetchFormations(query)
|
||||||
|
|
||||||
|
if (data.results && data.results.length > 0) {
|
||||||
|
const formations = []
|
||||||
|
|
||||||
|
for (let i = 0; i < data.results.length; i++) {
|
||||||
|
const raw = data.results[i]
|
||||||
|
const formation = createFormation(raw)
|
||||||
|
formations.push(formation)
|
||||||
|
}
|
||||||
|
|
||||||
|
lastFormations = formations
|
||||||
|
|
||||||
|
let html = ""
|
||||||
|
|
||||||
|
for (let i = 0; i < formations.length; i++) {
|
||||||
|
const f = formations[i]
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<div style="border:1px solid #ccc; padding:10px; margin:10px;">
|
||||||
|
<h3>${f.nom}</h3>
|
||||||
|
<p><b>Établissement :</b> ${f.etablissement}</p>
|
||||||
|
<p><b>Ville :</b> ${f.ville} (${f.departement})</p>
|
||||||
|
<p><b>Filière :</b> ${f.filiere}</p>
|
||||||
|
<p><b>Taux d'accès :</b> ${f.tauxAcces}%</p>
|
||||||
|
<button onclick="showDetail(${i})">Voir détail</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
output.innerHTML = html
|
||||||
|
} else {
|
||||||
|
output.textContent = "Aucun résultat trouvé"
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erreur :", error)
|
||||||
|
output.textContent = "Erreur lors de la requête"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button.addEventListener("click", testAPI)
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Calculatrice simple</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Calculatrice</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$resultat = "";
|
||||||
|
$op1 = "";
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
$op1 = $_POST["op1"];
|
||||||
|
$op2 = $_POST["op2"];
|
||||||
|
$operation = $_POST["operation"];
|
||||||
|
|
||||||
|
// Vérification que ce sont bien des nombres
|
||||||
|
if (is_numeric($op1) && is_numeric($op2)) {
|
||||||
|
switch ($operation) {
|
||||||
|
case "+":
|
||||||
|
$resultat = $op1 + $op2;
|
||||||
|
break;
|
||||||
|
case "-":
|
||||||
|
$resultat = $op1 - $op2;
|
||||||
|
break;
|
||||||
|
case "*":
|
||||||
|
$resultat = $op1 * $op2;
|
||||||
|
break;
|
||||||
|
case "/":
|
||||||
|
if ($op2 == 0) {
|
||||||
|
$resultat = "Erreur : division par 0 !";
|
||||||
|
} else {
|
||||||
|
$resultat = $op1 / $op2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pour utiliser le résultat comme prochaine valeur d'opérande 1
|
||||||
|
|
||||||
|
if (is_numeric($resultat)) {
|
||||||
|
$op1 = $resultat;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$resultat = "Veuillez entrer deux nombres valides.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" name="op1" value="<?= htmlspecialchars($op1) ?>" required>
|
||||||
|
<select name="operation">
|
||||||
|
<option value="+">+</option>
|
||||||
|
<option value="-">-</option>
|
||||||
|
<option value="*">*</option>
|
||||||
|
<option value="/">/</option>
|
||||||
|
</select>
|
||||||
|
<input type="text" name="op2" required>
|
||||||
|
<input type="submit" value="Calculer">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php if ($resultat !== ""): ?>
|
||||||
|
<h2>Résultat : <?= $resultat ?></h2>
|
||||||
|
<?php endif; ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user