From 45fc1ff5c0ae1fc9e2abc0f17ab626446a9483a2 Mon Sep 17 00:00:00 2001 From: yolou Date: Tue, 17 Mar 2026 17:34:34 +0100 Subject: [PATCH] first commit --- parcoursup/api.js | 21 ++++++++++ parcoursup/api.js~ | 21 ++++++++++ parcoursup/formation.js | 23 +++++++++++ parcoursup/formation.js~ | 23 +++++++++++ parcoursup/index.html | 20 ++++++++++ parcoursup/index.html~ | 20 ++++++++++ parcoursup/main.js | 81 +++++++++++++++++++++++++++++++++++++++ parcoursup/main.js~ | 81 +++++++++++++++++++++++++++++++++++++++ tp2/exo3/calculatrice.php | 68 ++++++++++++++++++++++++++++++++ 9 files changed, 358 insertions(+) create mode 100644 parcoursup/api.js create mode 100644 parcoursup/api.js~ create mode 100644 parcoursup/formation.js create mode 100644 parcoursup/formation.js~ create mode 100644 parcoursup/index.html create mode 100644 parcoursup/index.html~ create mode 100644 parcoursup/main.js create mode 100644 parcoursup/main.js~ create mode 100644 tp2/exo3/calculatrice.php diff --git a/parcoursup/api.js b/parcoursup/api.js new file mode 100644 index 0000000..a6b10da --- /dev/null +++ b/parcoursup/api.js @@ -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() + } \ No newline at end of file diff --git a/parcoursup/api.js~ b/parcoursup/api.js~ new file mode 100644 index 0000000..a6b10da --- /dev/null +++ b/parcoursup/api.js~ @@ -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() + } \ No newline at end of file diff --git a/parcoursup/formation.js b/parcoursup/formation.js new file mode 100644 index 0000000..a7931d1 --- /dev/null +++ b/parcoursup/formation.js @@ -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 + } + } \ No newline at end of file diff --git a/parcoursup/formation.js~ b/parcoursup/formation.js~ new file mode 100644 index 0000000..a7931d1 --- /dev/null +++ b/parcoursup/formation.js~ @@ -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 + } + } \ No newline at end of file diff --git a/parcoursup/index.html b/parcoursup/index.html new file mode 100644 index 0000000..321d43e --- /dev/null +++ b/parcoursup/index.html @@ -0,0 +1,20 @@ + + + + + + Parcoursup - test API + + +

Mini projet Parcoursup

+

Recherche de formations Parcoursup

+ + + + +
En attente...
+ + + + + \ No newline at end of file diff --git a/parcoursup/index.html~ b/parcoursup/index.html~ new file mode 100644 index 0000000..321d43e --- /dev/null +++ b/parcoursup/index.html~ @@ -0,0 +1,20 @@ + + + + + + Parcoursup - test API + + +

Mini projet Parcoursup

+

Recherche de formations Parcoursup

+ + + + +
En attente...
+ + + + + \ No newline at end of file diff --git a/parcoursup/main.js b/parcoursup/main.js new file mode 100644 index 0000000..a8b42ab --- /dev/null +++ b/parcoursup/main.js @@ -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 = ` +
+

${f.nom}

+

Établissement : ${f.etablissement}

+

Ville : ${f.ville}

+

Département : ${f.departement}

+

Filière : ${f.filiere}

+

Sélectivité : ${f.selectivite}

+

Capacité : ${f.capacite}

+

Candidats : ${f.candidats}

+

Admis : ${f.admis}

+

Taux d'accès : ${f.tauxAcces}%

+ +
+ ` + + 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 += ` +
+

${f.nom}

+

Établissement : ${f.etablissement}

+

Ville : ${f.ville} (${f.departement})

+

Filière : ${f.filiere}

+

Taux d'accès : ${f.tauxAcces}%

+ +
+ ` + } + + 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) \ No newline at end of file diff --git a/parcoursup/main.js~ b/parcoursup/main.js~ new file mode 100644 index 0000000..a8b42ab --- /dev/null +++ b/parcoursup/main.js~ @@ -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 = ` +
+

${f.nom}

+

Établissement : ${f.etablissement}

+

Ville : ${f.ville}

+

Département : ${f.departement}

+

Filière : ${f.filiere}

+

Sélectivité : ${f.selectivite}

+

Capacité : ${f.capacite}

+

Candidats : ${f.candidats}

+

Admis : ${f.admis}

+

Taux d'accès : ${f.tauxAcces}%

+ +
+ ` + + 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 += ` +
+

${f.nom}

+

Établissement : ${f.etablissement}

+

Ville : ${f.ville} (${f.departement})

+

Filière : ${f.filiere}

+

Taux d'accès : ${f.tauxAcces}%

+ +
+ ` + } + + 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) \ No newline at end of file diff --git a/tp2/exo3/calculatrice.php b/tp2/exo3/calculatrice.php new file mode 100644 index 0000000..f4e9943 --- /dev/null +++ b/tp2/exo3/calculatrice.php @@ -0,0 +1,68 @@ + + + + + Calculatrice simple + + +

Calculatrice

+ + + +
+ + + + +
+ + +

Résultat :

+ + +