2023-03-28 16:51:44 +02:00
|
|
|
/*
|
|
|
|
Parcoursup API (PAPI)
|
|
|
|
Comprend un set de wrapper afin d'accéder plus aisément aux informations de l'API parcoursup
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PAPI {
|
|
|
|
static dataset = "fr-esr-parcoursup";
|
|
|
|
static timezone = "Europe%2FBerlin";
|
|
|
|
static searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=${PAPI.dataset}&timezone=${PAPI.timezone}`;
|
|
|
|
static async fetchFilieres() {
|
|
|
|
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fili`);
|
|
|
|
let result = await request.json();
|
|
|
|
return result["facet_groups"][0]["facets"];
|
|
|
|
}
|
|
|
|
static async fetchFiliere(filiere) {
|
|
|
|
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
|
|
|
|
let result = await request.json();
|
|
|
|
return result["facet_groups"][0]["facets"];
|
|
|
|
}
|
|
|
|
static async fetchSpecialites(specialite) {
|
|
|
|
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}`);
|
|
|
|
let result = await request.json();
|
|
|
|
return result["facet_groups"][0]["facets"];
|
|
|
|
}
|
|
|
|
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
|
|
|
|
let request = await fetch(`${PAPI.searchURL}&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
|
|
|
|
let result = await request.json();
|
|
|
|
console.log(result["records"]);
|
|
|
|
return result["records"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchEtablissement(state) {
|
|
|
|
return PAPI.fetchEtablissement(state.fili, state.sousfili, state.soussousfili);
|
|
|
|
}
|
2023-03-28 10:15:32 +02:00
|
|
|
var school = {
|
|
|
|
css: null,
|
2023-03-28 16:51:44 +02:00
|
|
|
exports: function search() {
|
|
|
|
return {
|
|
|
|
onBeforeMount(props, state) {
|
|
|
|
this.state = {
|
|
|
|
items: null,
|
|
|
|
fili: "BUT",
|
|
|
|
sousfili: "BUT - Production",
|
|
|
|
soussousfili: "Informatique"
|
|
|
|
};
|
|
|
|
fetchEtablissement(this.state).then(response => {
|
|
|
|
this.update({
|
|
|
|
items: response
|
|
|
|
});
|
|
|
|
console.log(this.state.items);
|
|
|
|
this.state.items.forEach(etablissement => {
|
|
|
|
// calcul la moyenne
|
|
|
|
let pct_sansmention = etablissement.fields.pct_sansmention;
|
|
|
|
let pct_AB = etablissement.fields.pct_ab;
|
|
|
|
let pct_B = etablissement.fields.pct_b;
|
|
|
|
let pct_TB = etablissement.fields.pct_tb;
|
|
|
|
let pct_TBF = etablissement.fields.pct_tbf;
|
|
|
|
let moyenne = (pct_TBF * 18 + pct_TB * 16 + pct_B * 14 + pct_AB * 12 + pct_sansmention * 10) / 100;
|
|
|
|
etablissement.fields['list_com'] = moyenne;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2023-03-28 10:15:32 +02:00
|
|
|
},
|
2023-03-28 16:51:44 +02:00
|
|
|
template: (template, expressionTypes, bindingTypes, getComponent) => template('<main class="container"><div class="block control has-icons-left is-inline-block is-pulled-right"><input class="input" type="search" placeholder="Établissement"/><span class="icon is-small is-left"><i class="fas fa-search"></i></span></div><table class="table is-fullwidth is-hoverable"><thead><tr><th><abbr title="name">Nom</abbr></th><th><abbr title="city">Ville</abbr></th><th><abbr title="dept">Dpt</abbr></th><th><abbr title="moyenne">Moyenne</abbr></th><th><abbr title="selectivite">Sélectivité</abbr></th></tr></thead><tbody><tr expr90="expr90"></tr></tbody></table></main>', [{
|
|
|
|
type: bindingTypes.EACH,
|
|
|
|
getKey: null,
|
|
|
|
condition: null,
|
|
|
|
template: template('<td expr91="expr91"> </td><td expr92="expr92"> </td><td expr93="expr93"> </td><td expr94="expr94"> </td><td expr95="expr95"> </td>', [{
|
|
|
|
redundantAttribute: 'expr91',
|
|
|
|
selector: '[expr91]',
|
|
|
|
expressions: [{
|
|
|
|
type: expressionTypes.TEXT,
|
|
|
|
childNodeIndex: 0,
|
|
|
|
evaluate: _scope => _scope.etablissement.g_ea_lib_vx
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
redundantAttribute: 'expr92',
|
|
|
|
selector: '[expr92]',
|
|
|
|
expressions: [{
|
|
|
|
type: expressionTypes.TEXT,
|
|
|
|
childNodeIndex: 0,
|
|
|
|
evaluate: _scope => _scope.etablissement.ville_etab
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
redundantAttribute: 'expr93',
|
|
|
|
selector: '[expr93]',
|
|
|
|
expressions: [{
|
|
|
|
type: expressionTypes.TEXT,
|
|
|
|
childNodeIndex: 0,
|
|
|
|
evaluate: _scope => _scope.etablissement.dep
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
redundantAttribute: 'expr94',
|
|
|
|
selector: '[expr94]',
|
|
|
|
expressions: [{
|
|
|
|
type: expressionTypes.TEXT,
|
|
|
|
childNodeIndex: 0,
|
|
|
|
evaluate: _scope => _scope.etablissement.list_com
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
redundantAttribute: 'expr95',
|
|
|
|
selector: '[expr95]',
|
|
|
|
expressions: [{
|
|
|
|
type: expressionTypes.TEXT,
|
|
|
|
childNodeIndex: 0,
|
|
|
|
evaluate: _scope => _scope.etablissement.taux_acces_ens
|
|
|
|
}]
|
|
|
|
}]),
|
|
|
|
redundantAttribute: 'expr90',
|
|
|
|
selector: '[expr90]',
|
|
|
|
itemName: 'etablissement',
|
|
|
|
indexName: null,
|
|
|
|
evaluate: _scope => _scope.state.items
|
|
|
|
}]),
|
2023-03-28 10:15:32 +02:00
|
|
|
name: 'school'
|
|
|
|
};
|
|
|
|
|
|
|
|
export { school as default };
|