diff --git a/parcoursup/api.js b/parcoursup/api.js
index 20b2c65..8766324 100644
--- a/parcoursup/api.js
+++ b/parcoursup/api.js
@@ -1,34 +1,35 @@
-export function buildURL(query, limit = 20, offset = 0, filters = {}) {
- let url =
- "https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?"
+// Construire l'URL de requête vers l'API Parcoursup
+export function construireURL(requete, limite = 20, decalage = 0, filtres = {}) {
- url += "limit=" + limit
- url += "&offset=" + offset
+ 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 (query && query.trim() !== "") {
- conditions.push("search(lib_for_voe_ins, '" + query + "')")
+ if (requete && requete.trim() !== "") {
+ conditions.push("search(lib_for_voe_ins, '" + requete + "')")
}
- if (filters.filiere && filters.filiere !== "") {
- conditions.push("fili='" + filters.filiere + "'")
+ if (filtres.filiere && filtres.filiere !== "") {
+ conditions.push("fili='" + filtres.filiere + "'")
}
- if (filters.selectivite && filters.selectivite !== "") {
- conditions.push("select_form='" + filters.selectivite + "'")
+ if (filtres.selectivite && filtres.selectivite !== "") {
+ conditions.push("select_form='" + filtres.selectivite + "'")
}
- if (filters.region && filters.region !== "") {
- conditions.push("region_etab_aff='" + filters.region + "'")
+ if (filtres.region && filtres.region !== "") {
+ conditions.push("region_etab_aff='" + filtres.region + "'")
}
- if (filters.tauxMin && filters.tauxMin > 0) {
- conditions.push("taux_acces_ens>=" + filters.tauxMin)
+ if (filtres.tauxMin && filtres.tauxMin > 0) {
+ conditions.push("taux_acces_ens>=" + filtres.tauxMin)
}
- if (filters.tauxMax && filters.tauxMax < 100) {
- conditions.push("taux_acces_ens<=" + filters.tauxMax)
+ if (filtres.tauxMax && filtres.tauxMax < 100) {
+ conditions.push("taux_acces_ens<=" + filtres.tauxMax)
}
if (conditions.length > 0) {
@@ -38,19 +39,23 @@ export function buildURL(query, limit = 20, offset = 0, filters = {}) {
return url
}
-export async function fetchFormations(query, limit = 20, offset = 0, filters = {}) {
- const url = buildURL(query, limit, offset, filters)
- const response = await fetch(url)
+// Charger les formations depuis l'API Parcoursup
+export async function chargerFormations(requete, limite = 20, decalage = 0, filtres = {}) {
- if (!response.ok) {
+ var url = construireURL(requete, limite, decalage, filtres)
+ var reponse = await fetch(url)
+
+ if (!reponse.ok) {
throw new Error("Erreur HTTP")
}
- return await response.json()
+ return await reponse.json()
}
-export async function fetchFormationHistory(codUai, nomFormation) {
- var datasets = {
+// 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",
@@ -59,54 +64,59 @@ export async function fetchFormationHistory(codUai, nomFormation) {
2025: "fr-esr-parcoursup"
}
- var history = []
- var searchName = nomFormation.substring(0, 40).replace(/'/g, "\\'")
- var years = [2020, 2021, 2022, 2023, 2024, 2025]
+ var historique = []
+ var nomCourt = nomFormation.substring(0, 40).replace(/'/g, "\\'")
+ var annees = [2020, 2021, 2022, 2023, 2024, 2025]
- for (var i = 0; i < years.length; i++) {
- var year = years[i]
- var dataset = datasets[year]
+ for (var i = 0; i < annees.length; i++) {
+
+ var annee = annees[i]
+ var dataset = jeuDeDonnees[annee]
try {
+
var url = "https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/"
+ dataset + "/records?"
+ "limit=5"
- + "&where=cod_uai%3D'" + codUai + "' AND search(lib_for_voe_ins, '" + searchName + "')"
+ + "&where=cod_uai%3D'" + codUai + "' AND search(lib_for_voe_ins, '" + nomCourt + "')"
+ "&select=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 response = await fetch(url)
+ var reponse = await fetch(url)
- if (response.ok) {
- var data = await response.json()
+ if (reponse.ok) {
- if (data.results && data.results.length > 0) {
- var r = data.results[0]
- var taux = 0
+ var donnees = await reponse.json()
- if (r.voe_tot && r.voe_tot > 0) {
- taux = Math.round((r.acc_tot / r.voe_tot) * 100)
+ 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)
}
- history.push({
- annee: year,
- tauxAcces: taux,
- candidats: r.voe_tot || 0,
- admis: r.acc_tot || 0,
- pctSansMention: r.pct_sansmention || 0,
- pctAB: r.pct_ab || 0,
- pctB: r.pct_b || 0,
- pctTB: r.pct_tb || 0,
- pctTBF: r.pct_tbf || 0,
- pctGeneral: r.pct_bg || 0,
- pctTechno: r.pct_bt || 0,
- pctPro: r.pct_bp || 0
+ 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 " + year + ":", e)
+ console.warn("Erreur pour l'année " + annee + " :", e)
}
}
- return history
+ return historique
}
diff --git a/parcoursup/app.riot b/parcoursup/app.riot
index 34d8e93..6072d0b 100644
--- a/parcoursup/app.riot
+++ b/parcoursup/app.riot
@@ -9,7 +9,7 @@
0 }>
{ state.selectedFormations.length } sélection(s)
-
{ state.query } — { state.total } résultat(s) @@ -32,16 +32,16 @@ results={ state.results } hasSearched={ state.hasSearched } loading={ state.loading } - ondetail={ showDetail } - onselect={ addToSelection }> + ondetail={ afficherDetail } + onselect={ ajouterSelection }>
Établissement : { f.etablissement }
@@ -125,13 +125,13 @@- - { estimateFormation(f) } + + { estimerFormation(f) } - { getEstimateDetail(f) } + { detailEstimation(f) }
-