This commit is contained in:
HORVILLE 2023-03-28 16:54:48 +02:00
commit 38648dad13
7 changed files with 333 additions and 47 deletions

View File

@ -1,5 +1,5 @@
<school>
<div class="box p-2 m-2">
<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">
@ -7,6 +7,8 @@
</span>
</div>
<table class="table is-fullwidth is-hoverable">
<thead>
<tr>
@ -17,11 +19,52 @@
<th><abbr title="selectivite">Sélectivité</abbr></th>
</tr>
</thead>
</div>
<tbody>
<tr each={etablissement in this.state.items}>
<td>{etablissement.g_ea_lib_vx}</td>
<td>{etablissement.ville_etab}</td>
<td>{etablissement.dep}</td>
<td>{etablissement.list_com}</td>
<td>{etablissement.taux_acces_ens}</td>
</tr>
</tbody>
</table>
<script>
export default {
onMounted() {
console.log("Test!")
import PAPI from '../javascript/parcoursup-link.js'
async function fetchEtablissement(state) {
return PAPI.fetchEtablissement(state.fili, state.sousfili, state.soussousfili);
}
export default 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
})
}
}
}
</script>

View File

@ -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('<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 expr0="expr0"></tr></tbody></table></main>', [{
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<td expr1="expr1"> </td><td expr2="expr2"> </td><td expr3="expr3"> </td><td expr4="expr4"> </td><td expr5="expr5"> </td>', [{
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 };

View File

@ -1,38 +1,38 @@
var mainController = {
css: null,
exports: {},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr12="expr12"></search></div><div class="column"><fili-info expr13="expr13"></fili-info><school expr14="expr14"></school></div></div><school-info expr15="expr15"></school-info>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr3="expr3"></search></div><div class="column"><fili-info expr4="expr4"></fili-info><school expr5="expr5"></school></div></div><school-info expr6="expr6"></school-info>', [{
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'search',
slots: [],
attributes: [],
redundantAttribute: 'expr12',
selector: '[expr12]'
redundantAttribute: 'expr3',
selector: '[expr3]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'fili-info',
slots: [],
attributes: [],
redundantAttribute: 'expr13',
selector: '[expr13]'
redundantAttribute: 'expr4',
selector: '[expr4]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'school',
slots: [],
attributes: [],
redundantAttribute: 'expr14',
selector: '[expr14]'
redundantAttribute: 'expr5',
selector: '[expr5]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'school-info',
slots: [],
attributes: [],
redundantAttribute: 'expr15',
selector: '[expr15]'
redundantAttribute: 'expr6',
selector: '[expr6]'
}]),
name: 'main-controller'
};

View File

@ -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

View File

@ -10,14 +10,14 @@ var schoolInfo = {
this.update();
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr3="expr3" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr7="expr7" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.state.enabled,
redundantAttribute: 'expr3',
selector: '[expr3]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr4="expr4" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr5="expr5" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr4',
selector: '[expr4]',
redundantAttribute: 'expr7',
selector: '[expr7]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr8="expr8" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr9="expr9" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr8',
selector: '[expr8]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
@ -29,8 +29,8 @@ var schoolInfo = {
evaluate: _scope => 'line-graph',
slots: [],
attributes: [],
redundantAttribute: 'expr5',
selector: '[expr5]'
redundantAttribute: 'expr9',
selector: '[expr9]'
}])
}]),
name: 'school-info'

View File

@ -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('<div class="box p-2 m-2"><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></table></div>', []),
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
}]),
name: 'school'
};

View File

@ -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('<div class="box p-1 m-2"><div class="columns m-1"><input expr6="expr6" class="input" type="input"/><button expr7="expr7" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr8="expr8" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr6',
selector: '[expr6]',
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr10="expr10" class="input" type="input"/><button expr11="expr11" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr12="expr12" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr10',
selector: '[expr10]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onkeydown',
@ -127,8 +133,8 @@ var search = {
evaluate: _scope => _scope.state.placeholder
}]
}, {
redundantAttribute: 'expr7',
selector: '[expr7]',
redundantAttribute: 'expr11',
selector: '[expr11]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
@ -138,33 +144,33 @@ var search = {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<button expr9="expr9" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr10="expr10"> </strong></span><div style="margin-left: auto;"></div><span expr11="expr11" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr9',
selector: '[expr9]',
template: template('<button expr13="expr13" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr14="expr14"> </strong></span><div style="margin-left: auto;"></div><span expr15="expr15" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr13',
selector: '[expr13]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
evaluate: _scope => () => _scope.filter(_scope.item.name)
}]
}, {
redundantAttribute: 'expr10',
selector: '[expr10]',
redundantAttribute: 'expr14',
selector: '[expr14]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.name
}]
}, {
redundantAttribute: 'expr11',
selector: '[expr11]',
redundantAttribute: 'expr15',
selector: '[expr15]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.count
}]
}]),
redundantAttribute: 'expr8',
selector: '[expr8]',
redundantAttribute: 'expr12',
selector: '[expr12]',
itemName: 'item',
indexName: null,
evaluate: _scope => _scope.state.items