avancee listeEtab et maj PAPI

This commit is contained in:
Haïssous Kayyissa 2023-03-28 16:51:44 +02:00
parent 522214898b
commit 7d6501016e
8 changed files with 340 additions and 54 deletions

View File

@ -1,11 +1,13 @@
<school>
<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>
<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>
@ -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,30 +1,30 @@
var filiInfo = {
css: null,
exports: null,
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr249="expr249" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr250="expr250" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr251="expr251" style="height: 6rem;"></line-graph></div></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr16="expr16" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr17="expr17" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr18="expr18" style="height: 6rem;"></line-graph></div></div>', [{
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'
};

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-2 m-2"><img src="../resources/logo-parcoursup.svg"/></div><search expr41="expr41"></search></div><div class="column"><fili-info expr42="expr42"></fili-info><school expr43="expr43"></school></div></div><school-info expr44="expr44"></school-info>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-2 m-2"><img src="../resources/logo-parcoursup.svg"/></div><search expr0="expr0"></search></div><div class="column"><fili-info expr1="expr1"></fili-info><school expr2="expr2"></school></div></div><school-info expr3="expr3"></school-info>', [{
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'
};

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 expr26="expr26" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr19="expr19" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.state.enabled,
redundantAttribute: 'expr26',
selector: '[expr26]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr27="expr27" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr28="expr28" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr27',
selector: '[expr27]',
redundantAttribute: 'expr19',
selector: '[expr19]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr20="expr20" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr21="expr21" style="height: 90px; margin: 10px;"></line-graph></div>', [{
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'

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 expr3="expr3" class="input" type="input"/><button expr4="expr4" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr5="expr5" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr3',
selector: '[expr3]',
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr48="expr48" class="input" type="input"/><button expr49="expr49" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr50="expr50" class="m-1"></li></ul></div></div>', [{
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('<button expr6="expr6" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr7="expr7"> </strong></span><div style="margin-left: auto;"></div><span expr8="expr8" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr6',
selector: '[expr6]',
template: template('<button expr51="expr51" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr52="expr52"> </strong></span><div style="margin-left: auto;"></div><span expr53="expr53" class="tag is-primary"> </span></button>', [{
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