From 1e95bad09d55862f01e3266af4687764398cb198 Mon Sep 17 00:00:00 2001 From: sehl Date: Tue, 31 Mar 2026 17:54:23 +0200 Subject: [PATCH 1/5] maj api+formation+app+main et maj index --- parcoursup/api.js | 140 +-------- parcoursup/app.riot | 603 +++++--------------------------------- parcoursup/formation.js | 110 ++----- parcoursup/index.html | 69 ++--- tp2/exo3/calculatrice.php | 68 ----- 5 files changed, 118 insertions(+), 872 deletions(-) delete mode 100644 tp2/exo3/calculatrice.php diff --git a/parcoursup/api.js b/parcoursup/api.js index 72f1e5c..789a836 100644 --- a/parcoursup/api.js +++ b/parcoursup/api.js @@ -1,131 +1,21 @@ -// Échapper les apostrophes dans les valeurs injectées dans la clause where -function echapperValeur(valeur) { - return String(valeur).replace(/'/g, "\\'"); +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 } -// Construire l'URL de requête vers l'API Parcoursup -export function construireURL(requete, limite = 20, decalage = 0, filtres = {}) { +export async function fetchFormations(query) { + const url = buildURL(query) + const response = await fetch(url) - var url = "https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?"; - - url += "limit=" + limite; - url += "&offset=" + decalage; - - var conditions = []; - - if (requete && requete.trim() !== "") { - conditions.push("search(lib_for_voe_ins, '" + echapperValeur(requete.trim()) + "')"); + if (!response.ok) { + throw new Error("Erreur HTTP") } - if (filtres.filiere && filtres.filiere !== "") { - conditions.push("fili='" + echapperValeur(filtres.filiere) + "'"); - } - - if (filtres.selectivite && filtres.selectivite !== "") { - conditions.push("select_form='" + echapperValeur(filtres.selectivite) + "'"); - } - - if (filtres.region && filtres.region !== "") { - conditions.push("region_etab_aff='" + echapperValeur(filtres.region) + "'"); - } - - if (filtres.tauxMin && filtres.tauxMin > 0) { - conditions.push("taux_acces_ens>=" + filtres.tauxMin); - } - - if (filtres.tauxMax && filtres.tauxMax < 100) { - conditions.push("taux_acces_ens<=" + filtres.tauxMax); - } - - if (conditions.length > 0) { - url += "&where=" + encodeURIComponent(conditions.join(" AND ")); - } - - return url; -} - -// Charger les formations depuis l'API Parcoursup -export async function chargerFormations(requete, limite = 20, decalage = 0, filtres = {}) { - - var url = construireURL(requete, limite, decalage, filtres); - var reponse = await fetch(url); - - if (!reponse.ok) { - throw new Error("Erreur HTTP " + reponse.status); - } - - return await reponse.json(); -} - -// Charger l'historique d'une formation sur plusieurs années -export async function chargerHistoriqueFormation(codUai, nomFormation) { - - var jeuDeDonnees = { - 2020: "fr-esr-parcoursup_2020", - 2021: "fr-esr-parcoursup_2021", - 2022: "fr-esr-parcoursup_2022", - 2023: "fr-esr-parcoursup_2023", - 2024: "fr-esr-parcoursup_2024", - 2025: "fr-esr-parcoursup" - }; - - var historique = []; - var nomCourt = echapperValeur((nomFormation || "").substring(0, 40)); - var codeUai = echapperValeur(codUai); - var annees = [2020, 2021, 2022, 2023, 2024, 2025]; - - for (var i = 0; i < annees.length; i++) { - - var annee = annees[i]; - var dataset = jeuDeDonnees[annee]; - - try { - - var where = - "cod_uai='" + codeUai + "' AND search(lib_for_voe_ins, '" + nomCourt + "')"; - - var url = "https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/" - + dataset + "/records?" - + "limit=5" - + "&where=" + encodeURIComponent(where) - + "&select=" + encodeURIComponent("cod_uai,lib_for_voe_ins,voe_tot,acc_tot,pct_sansmention,pct_ab,pct_b,pct_tb,pct_tbf,pct_bg,pct_bt,pct_bp"); - - var reponse = await fetch(url); - - if (reponse.ok) { - - var donnees = await reponse.json(); - - if (donnees.results && donnees.results.length > 0) { - - var ligne = donnees.results[0]; - var taux = 0; - - if (ligne.voe_tot && ligne.voe_tot > 0) { - taux = Math.round((ligne.acc_tot / ligne.voe_tot) * 100); - } - - historique.push({ - annee: annee, - tauxAcces: taux, - candidats: ligne.voe_tot || 0, - admis: ligne.acc_tot || 0, - pctSansMention: ligne.pct_sansmention || 0, - pctAB: ligne.pct_ab || 0, - pctB: ligne.pct_b || 0, - pctTB: ligne.pct_tb || 0, - pctTBF: ligne.pct_tbf || 0, - pctGeneral: ligne.pct_bg || 0, - pctTechno: ligne.pct_bt || 0, - pctPro: ligne.pct_bp || 0 - }); - } - } - - } catch (e) { - console.warn("Erreur pour l'année " + annee + " :", e); - } - } - - return historique; + return await response.json() } \ No newline at end of file diff --git a/parcoursup/app.riot b/parcoursup/app.riot index 28382a3..72fcb55 100644 --- a/parcoursup/app.riot +++ b/parcoursup/app.riot @@ -1,574 +1,105 @@ - + -
- - -
- - -

- { state.query } — { state.total } résultat(s) -

- - - -
-
- - - - -
-
-
- - -
- - -
- -
- Chargement de la formation... -
- - -
- - - -
0 }> -

Comparateur de formations

- -

Choisis ton profil pour estimer tes chances d'intégration.

- -
-
-
- -
- -
-
- -
- -
-
- -
-
- - - -
- -
-

{ f.nom }

- -

Établissement : { f.etablissement }

-

Ville : { f.ville }

-

Filière : { f.filiere }

-

Capacité : { f.capacite }

-

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

- -

- Intégrés : - Général { f.pctGeneral }% / - Techno { f.pctTechno }% / - Pro { f.pctPro }% -

- -

- - { estimerFormation(f) } - - { detailEstimation(f) } -

- - -
-
- -
-

Aucune formation sélectionnée

-

Retourne à la recherche et clique sur "Ajouter à la sélection" pour comparer des formations.

-
-
+
+

{ state.selected.nom }

+

Établissement : { state.selected.etablissement }

+

Ville : { state.selected.ville }

+

Département : { state.selected.departement }

+

Filière : { state.selected.filiere }

+

Sélectivité : { state.selected.selectivite }

+

Capacité : { state.selected.capacite }

+

Candidats : { state.selected.candidats }

+

Admis : { state.selected.admis }

+

Taux d'accès : { state.selected.tauxAcces }%

+
- + \ No newline at end of file diff --git a/parcoursup/formation.js b/parcoursup/formation.js index fbe770e..b03f51f 100644 --- a/parcoursup/formation.js +++ b/parcoursup/formation.js @@ -1,97 +1,23 @@ -// Créer un objet formation à partir des données brutes de l'API -export function creerFormation(brut) { +export function createFormation(raw) { + let taux = 0 - var taux = 0; - var latitude = null; - var longitude = null; - - if (brut.voe_tot && brut.voe_tot > 0) { - taux = Math.round((brut.acc_tot / brut.voe_tot) * 100); - } - - if (brut.g_olocalisation_des_formations) { - latitude = brut.g_olocalisation_des_formations.lat; - longitude = brut.g_olocalisation_des_formations.lon; + if (raw.voe_tot && raw.voe_tot > 0) { + taux = Math.round((raw.acc_tot / raw.voe_tot) * 100) } return { - id: brut.cod_uai + "-" + brut.lib_for_voe_ins, - - nom: brut.lib_for_voe_ins, - etablissement: brut.g_ea_lib_vx, - ville: brut.ville_etab, - departement: brut.dep, - departementLib: brut.dep_lib, - region: brut.region_etab_aff, - academie: brut.acad_mies, - contrat: brut.contrat_etab, - - filiere: brut.fili, - selectivite: brut.select_form, - - capacite: brut.capa_fin, - candidats: brut.voe_tot, - admis: brut.acc_tot, - tauxAcces: taux, - - latitude: latitude, - longitude: longitude, - - pctFemmes: brut.pct_f, - pctBoursiers: brut.pct_bours, - pctNeoBac: brut.pct_neobac, - - pctGeneral: brut.pct_bg, - pctTechno: brut.pct_bt, - pctPro: brut.pct_bp, - - pctSansMention: brut.pct_sansmention, - pctAB: brut.pct_ab, - pctB: brut.pct_b, - pctTB: brut.pct_tb, - pctTBF: brut.pct_tbf, - - pctDebutPhase: brut.pct_acc_debutpp, - pctDateBac: brut.pct_acc_datebac, - pctFinPhase: brut.pct_acc_finpp, - - admisDebutPhase: brut.acc_debutpp, - admisDateBac: brut.acc_datebac, - admisFinPhase: brut.acc_finpp, - - // Phase principale - voePPGeneral: brut.nb_voe_pp_bg, - voePPTechno: brut.nb_voe_pp_bt, - voePPPro: brut.nb_voe_pp_bp, - voePPAutres: brut.nb_voe_pp_at, - voePPTotal: brut.nb_voe_pp, - - classesPPGeneral: brut.nb_cla_pp_bg, - classesPPTechno: brut.nb_cla_pp_bt, - classesPPPro: brut.nb_cla_pp_bp, - classesPPAutres: brut.nb_cla_pp_at, - classesPPTotal: brut.nb_cla_pp, - - propositionsPPGeneral: brut.prop_tot_bg, - propositionsPPTechno: brut.prop_tot_bt, - propositionsPPPro: brut.prop_tot_bp, - propositionsPPAutres: brut.prop_tot_at, - propositionsPPTotal: brut.prop_tot, - - acceptesPPGeneral: brut.acc_bg, - acceptesPPTechno: brut.acc_bt, - acceptesPPPro: brut.acc_bp, - acceptesPPAutres: brut.acc_at, - acceptesPPTotal: brut.acc_pp, - - // Phase complémentaire - voePCGeneral: brut.nb_voe_pc_bg, - voePCTechno: brut.nb_voe_pc_bt, - voePCPro: brut.nb_voe_pc_bp, - voePCAutres: brut.nb_voe_pc_at, - voePCTotal: brut.nb_voe_pc, - - classesPCTotal: brut.nb_cla_pc, - acceptesPCTotal: brut.acc_pc - }; + 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 index da008b8..1485d37 100644 --- a/parcoursup/index.html +++ b/parcoursup/index.html @@ -1,58 +1,25 @@ - - - - Parcoursup Explorer + + + + Parcoursup Riot - - - + + + + + - - - - - + - - - - - - - - - + }) + + \ No newline at end of file diff --git a/tp2/exo3/calculatrice.php b/tp2/exo3/calculatrice.php deleted file mode 100644 index f4e9943..0000000 --- a/tp2/exo3/calculatrice.php +++ /dev/null @@ -1,68 +0,0 @@ - - - - - Calculatrice simple - - -

Calculatrice

- - - -
- - - - -
- - -

Résultat :

- - - From 3604cfdc8b00d4158e10abe9890adf0129dd602e Mon Sep 17 00:00:00 2001 From: sehl Date: Tue, 31 Mar 2026 17:55:55 +0200 Subject: [PATCH 2/5] maj 2 --- parcoursup/app.riot | 57 +--- parcoursup/components/detail-view.riot | 439 +------------------------ parcoursup/components/result-list.riot | 53 +-- parcoursup/components/search-bar.riot | 134 +------- 4 files changed, 50 insertions(+), 633 deletions(-) diff --git a/parcoursup/app.riot b/parcoursup/app.riot index 72fcb55..13c51dc 100644 --- a/parcoursup/app.riot +++ b/parcoursup/app.riot @@ -3,43 +3,21 @@

Recherche de formations Parcoursup avec Riot

- - + -

Chargement...

-

- Aucun résultat trouvé -

- -
-

{ f.nom }

-

Établissement : { f.etablissement }

-

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

-

Filière : { f.filiere }

-

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

- -
+ +
-

{ state.selected.nom }

-

Établissement : { state.selected.etablissement }

-

Ville : { state.selected.ville }

-

Département : { state.selected.departement }

-

Filière : { state.selected.filiere }

-

Sélectivité : { state.selected.selectivite }

-

Capacité : { state.selected.capacite }

-

Candidats : { state.selected.candidats }

-

Admis : { state.selected.admis }

-

Taux d'accès : { state.selected.tauxAcces }%

- - + +
- - + \ No newline at end of file diff --git a/parcoursup/components/result-list.riot b/parcoursup/components/result-list.riot index 28d25cb..edc6ea5 100644 --- a/parcoursup/components/result-list.riot +++ b/parcoursup/components/result-list.riot @@ -1,49 +1,22 @@ -
- -
+
+
Aucun résultat trouvé
-
+
Chargement...
-
-

{ formation.nom }

-

Établissement : { formation.etablissement }

-

Ville : { formation.ville } ({ formation.departement })

-

Filière : { formation.filiere }

-

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

- - - - +
+

{ f.nom }

+

Établissement : { f.etablissement }

+

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

+

Filière : { f.filiere }

+

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

+
-
- - - - + \ No newline at end of file diff --git a/parcoursup/components/search-bar.riot b/parcoursup/components/search-bar.riot index ebc5337..1a625e7 100644 --- a/parcoursup/components/search-bar.riot +++ b/parcoursup/components/search-bar.riot @@ -1,147 +1,27 @@ - - + + + + + - - + \ No newline at end of file diff --git a/parcoursup/components/result-list.riot b/parcoursup/components/result-list.riot index dee485e..9d12a38 100644 --- a/parcoursup/components/result-list.riot +++ b/parcoursup/components/result-list.riot @@ -1,14 +1,14 @@ -
-
+
+
Aucun résultat trouvé
-
+
Chargement...
-
+

{ f.nom }

Établissement : { f.etablissement }

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

diff --git a/parcoursup/components/search-bar.riot b/parcoursup/components/search-bar.riot index 1a625e7..01861a4 100644 --- a/parcoursup/components/search-bar.riot +++ b/parcoursup/components/search-bar.riot @@ -1,5 +1,5 @@ -
+