ProjetRIOT/components/school.riot

76 lines
2.8 KiB
Plaintext

<school>
<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 each={etablissement in this.state.items}>
<td>{etablissement.fields.g_ea_lib_vx}</td>
<td>{etablissement.fields.ville_etab}</td>
<td>{etablissement.fields.dep}</td>
<td>{etablissement.fields.moyenne}</td>
<td>{etablissement.fields.taux_acces_ens}</td>
</tr>
</tbody>
</table>
<script>
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.moyenne=moyenne
console.log(etablissement.fields)
})
this.update()
})
}
}
}
</script>
</school>