diff --git a/components/school.riot b/components/school.riot index f4643e9..2110d5d 100644 --- a/components/school.riot +++ b/components/school.riot @@ -1,11 +1,13 @@ -
-
- - - - -
+
+
+ + + + +
+ + @@ -17,11 +19,52 @@ - + + + + + + + + + +
Sélectivité
{etablissement.g_ea_lib_vx}{etablissement.ville_etab}{etablissement.dep}{etablissement.list_com}{etablissement.taux_acces_ens}
+ diff --git a/javascript/components/school.js b/javascript/components/school.js new file mode 100644 index 0000000..75c0c0b --- /dev/null +++ b/javascript/components/school.js @@ -0,0 +1,122 @@ +/* + 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) { + console.log(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); + return result["records"]; + } +} + +async function fetchEtablissement(state) { + return PAPI.fetchEtablissement(state.fili, state.sousfili, state.soussousfili); +} +var school = { + css: null, + 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; + record.fields['list_com'] = moyenne; + console.log(moyenne); + }); + } + }; + }, + template: (template, expressionTypes, bindingTypes, getComponent) => template('
NomVilleDptMoyenneSélectivité
', [{ + type: bindingTypes.EACH, + getKey: null, + condition: null, + template: template(' ', [{ + redundantAttribute: 'expr1', + selector: '[expr1]', + expressions: [{ + type: expressionTypes.TEXT, + childNodeIndex: 0, + evaluate: _scope => _scope.etablissement.g_ea_lib_vx + }] + }, { + redundantAttribute: 'expr2', + selector: '[expr2]', + expressions: [{ + type: expressionTypes.TEXT, + childNodeIndex: 0, + evaluate: _scope => _scope.etablissement.ville_etab + }] + }, { + redundantAttribute: 'expr3', + selector: '[expr3]', + expressions: [{ + type: expressionTypes.TEXT, + childNodeIndex: 0, + evaluate: _scope => _scope.etablissement.dep + }] + }, { + redundantAttribute: 'expr4', + selector: '[expr4]', + expressions: [{ + type: expressionTypes.TEXT, + childNodeIndex: 0, + evaluate: _scope => _scope.etablissement.list_com + }] + }, { + redundantAttribute: 'expr5', + selector: '[expr5]', + expressions: [{ + type: expressionTypes.TEXT, + childNodeIndex: 0, + evaluate: _scope => _scope.etablissement.taux_acces_ens + }] + }]), + redundantAttribute: 'expr0', + selector: '[expr0]', + itemName: 'etablissement', + indexName: null, + evaluate: _scope => _scope.state.items + }]), + name: 'school' +}; + +export { school as default }; diff --git a/javascript/fili-info.js b/javascript/fili-info.js index 7e773b5..c2decda 100644 --- a/javascript/fili-info.js +++ b/javascript/fili-info.js @@ -1,30 +1,30 @@ var filiInfo = { css: null, exports: null, - template: (template, expressionTypes, bindingTypes, getComponent) => template('

BUT / BUT - Production / Informatique

Moyenne des admis19.3

Nombre de formations5

Capacité90

Sélectivité

', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('

BUT / BUT - Production / Informatique

Moyenne des admis19.3

Nombre de formations5

Capacité90

Sélectivité

', [{ type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'line-graph', slots: [], attributes: [], - redundantAttribute: 'expr249', - selector: '[expr249]' + redundantAttribute: 'expr16', + selector: '[expr16]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'line-graph', slots: [], attributes: [], - redundantAttribute: 'expr250', - selector: '[expr250]' + redundantAttribute: 'expr17', + selector: '[expr17]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'line-graph', slots: [], attributes: [], - redundantAttribute: 'expr251', - selector: '[expr251]' + redundantAttribute: 'expr18', + selector: '[expr18]' }]), name: 'fili-info' }; diff --git a/javascript/main-controller.js b/javascript/main-controller.js index f025896..f833054 100644 --- a/javascript/main-controller.js +++ b/javascript/main-controller.js @@ -1,38 +1,38 @@ var mainController = { css: null, exports: {}, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'search', slots: [], attributes: [], - redundantAttribute: 'expr41', - selector: '[expr41]' + redundantAttribute: 'expr0', + selector: '[expr0]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'fili-info', slots: [], attributes: [], - redundantAttribute: 'expr42', - selector: '[expr42]' + redundantAttribute: 'expr1', + selector: '[expr1]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school', slots: [], attributes: [], - redundantAttribute: 'expr43', - selector: '[expr43]' + redundantAttribute: 'expr2', + selector: '[expr2]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school-info', slots: [], attributes: [], - redundantAttribute: 'expr44', - selector: '[expr44]' + redundantAttribute: 'expr3', + selector: '[expr3]' }]), name: 'main-controller' }; diff --git a/javascript/parcoursup-link.js b/javascript/parcoursup-link.js index 29b3247..bfb5e8b 100644 --- a/javascript/parcoursup-link.js +++ b/javascript/parcoursup-link.js @@ -29,6 +29,13 @@ class PAPI { 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"] + } } export default PAPI \ No newline at end of file diff --git a/javascript/school-info.js b/javascript/school-info.js index a3274ed..678ca7e 100644 --- a/javascript/school-info.js +++ b/javascript/school-info.js @@ -10,14 +10,14 @@ var schoolInfo = { this.update(); } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.IF, evaluate: _scope => _scope.state.enabled, - redundantAttribute: 'expr26', - selector: '[expr26]', - template: template('

', [{ - redundantAttribute: 'expr27', - selector: '[expr27]', + redundantAttribute: 'expr19', + selector: '[expr19]', + template: template('

', [{ + redundantAttribute: 'expr20', + selector: '[expr20]', expressions: [{ type: expressionTypes.EVENT, name: 'onclick', @@ -29,8 +29,8 @@ var schoolInfo = { evaluate: _scope => 'line-graph', slots: [], attributes: [], - redundantAttribute: 'expr28', - selector: '[expr28]' + redundantAttribute: 'expr21', + selector: '[expr21]' }]) }]), name: 'school-info' diff --git a/javascript/school.js b/javascript/school.js index 9e66103..6dbc3c4 100644 --- a/javascript/school.js +++ b/javascript/school.js @@ -1,11 +1,119 @@ +/* + 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); +} var school = { css: null, - exports: { - onMounted() { - console.log("Test!"); - } + 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; + }); + }); + } + }; }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
NomVilleDptMoyenneSélectivité
', []), + template: (template, expressionTypes, bindingTypes, getComponent) => template('
NomVilleDptMoyenneSélectivité
', [{ + type: bindingTypes.EACH, + getKey: null, + condition: null, + template: template(' ', [{ + 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 + }]), name: 'school' }; diff --git a/javascript/search.js b/javascript/search.js index a53ed62..5b96d43 100644 --- a/javascript/search.js +++ b/javascript/search.js @@ -22,6 +22,12 @@ class PAPI { 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 fetchFiliere(state) { @@ -114,9 +120,9 @@ var search = { } }; }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ - redundantAttribute: 'expr3', - selector: '[expr3]', + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + redundantAttribute: 'expr48', + selector: '[expr48]', expressions: [{ type: expressionTypes.EVENT, name: 'onkeydown', @@ -127,8 +133,8 @@ var search = { evaluate: _scope => _scope.state.placeholder }] }, { - redundantAttribute: 'expr4', - selector: '[expr4]', + redundantAttribute: 'expr49', + selector: '[expr49]', expressions: [{ type: expressionTypes.EVENT, name: 'onclick', @@ -138,33 +144,33 @@ var search = { type: bindingTypes.EACH, getKey: null, condition: null, - template: template('', [{ - redundantAttribute: 'expr6', - selector: '[expr6]', + template: template('', [{ + redundantAttribute: 'expr51', + selector: '[expr51]', expressions: [{ type: expressionTypes.EVENT, name: 'onclick', evaluate: _scope => () => _scope.filter(_scope.item.name) }] }, { - redundantAttribute: 'expr7', - selector: '[expr7]', + redundantAttribute: 'expr52', + selector: '[expr52]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.name }] }, { - redundantAttribute: 'expr8', - selector: '[expr8]', + redundantAttribute: 'expr53', + selector: '[expr53]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.count }] }]), - redundantAttribute: 'expr5', - selector: '[expr5]', + redundantAttribute: 'expr50', + selector: '[expr50]', itemName: 'item', indexName: null, evaluate: _scope => _scope.state.items