Mise à jour ergonomique et fonctionnelle

This commit is contained in:
2023-07-19 01:34:21 +02:00
parent b51010cd7c
commit a0ba368ff9
11 changed files with 773 additions and 1898 deletions

89
res/calcul.js Normal file
View File

@ -0,0 +1,89 @@
function arrondi_dixieme(nombre) {
return Math.ceil(10*nombre) / 10;
}
function arrondi_centieme(nombre) {
return Math.ceil(100*nombre) / 100;
}
function representer(nombre) {
return (isNaN(nombre)) ? '–' : nombre.toLocaleString();
}
function calcul_section(data) {
/* data est de la forme array[object] avec object de la forme
{ 'code': str,
'coef': int,
'entries': array }
Sortie : object de la forme { 'points': float, 'coefficients': int }
*/
let points= 0, coefficients= 0;
data.forEach(epreuve => {
let points_epreuve= 0;
let caduque = true;
epreuve.entries.forEach(entry => {
let field = document.getElementById(entry + "-note");
if (field.value) caduque = false;
if (field.value || field.required) {
points_epreuve += epreuve.coef * arrondi_dixieme(parseFloat((field.value) ? field.value : 0));
coefficients += epreuve.coef;
}
});
document.getElementById(epreuve.code + '-points').innerHTML = representer((caduque) ? NaN : points_epreuve);
points += points_epreuve;
})
return {"points": points, "coefficients": coefficients};
}
function decider(points, coefficients) {
let valide = document.getElementById("simulateur").checkValidity();
document.getElementById("total-points").innerHTML = representer((valide) ? points : NaN);
document.getElementById("total-coef").innerHTML = representer(coefficients);
let note_brute = (valide) ? points/coefficients : NaN;
let note_finale = arrondi_centieme(note_brute);
document.getElementById("note-finale").innerHTML = representer(note_finale);
let decision;
let sup_mention_actuelle;
if (note_finale < 8) {
decision = "Ajourné"
sup_mention_actuelle = 7.99*coefficients
} else if (note_finale < 10) {
decision = "Passe le second groupe";
sup_mention_actuelle = 9.99*coefficients
} else if (note_finale < 12) {
decision = "Admis";
sup_mention_actuelle = 11.99*coefficients
} else if (note_finale < 14) {
decision = "Admis Mention Assez Bien";
sup_mention_actuelle = 13.99*coefficients
} else if (note_finale < 16) {
decision = "Admis Mention Bien";
sup_mention_actuelle = 15.99*coefficients
} else if (note_finale < 18) {
decision = "Admis Mention Très Bien";
sup_mention_actuelle = 17.99*coefficients
} else if (note_finale >= 18) {
decision = "Admis Mention Très Bien avec les félicitations du jury";
sup_mention_actuelle = NaN
} else {
decision = "&ndash;"
}
if (note_finale < 18) {
let points_mention_suivante = arrondi_dixieme(sup_mention_actuelle - points + .01)
document.getElementById("points-manquants").innerHTML = representer(points_mention_suivante);
} else {
document.getElementById("points-manquants").innerHTML = "&ndash;";
}
document.getElementById("decision-jury").innerHTML = decision;
}

View File

@ -13,14 +13,21 @@ a:link, a:visited {
}
h1 {
margin: 10px 0;
text-align: center;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 15px;
}
p {
margin-bottom: 1em;
}
del {
color: #888;
}
header {
margin: 10px;
}
@ -68,8 +75,9 @@ header {
}
div.content {
width: clamp(400px, 70%, 1200px);
width: clamp(800px, 55%, 1200px);
margin: 30px auto;
padding: 10px;
}
#resultat {
@ -119,9 +127,88 @@ div.content {
margin-bottom: 0;
}
@media screen and (max-width: 1000px) {
.info {
padding: 10px;
background-color: lightyellow;
margin: 20px 0;
}
form input[type="number"] {
width: 100%;
padding: 5px;
border: none;
background-color: #eee;
font: large monospace;
}
form input[type="number"]:invalid {
background-color: #fdebd0;
}
footer {
margin-top: 20px;
padding: 10px;
text-align: center;
}
div.ln {
margin: 5px 0;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 5px;
}
div.head {
text-align: center;
font-weight: bold;
}
div.head div {
background-color: #eeeeee;
}
div.ln div {
padding: 5px;
}
div.ln div:nth-child(1) {
padding: 5px 0;
flex-grow: 1;
}
div.ln div:nth-child(2) {
font-weight: bold;
}
div.ln div:nth-child(2), div.ln div:nth-child(5) {
width: 5em;
text-align: center;
}
div.ln div:nth-child(3), div.ln div:nth-child(4) {
padding: 5px;
width: 6em;
align-self: stretch;
}
div.ln div:nth-child(3) {
background-color: #DBC4F0;
}
div.ln div:nth-child(4) {
background-color: #FFCACC;
}
div.ln div.null {
background-color: #eeeeee;
}
@media screen and (max-width: 800px) {
div.content {
width: 100vw;
width: 100%;
margin: 0;
}
#resultat, .choix-appli-wrapper {
@ -138,91 +225,19 @@ div.content {
width: 100%;
}
div.table_wrapper {
width: calc(100vw - 50px);
div.ln div {
flex-grow: 1;
}
fieldset {
width: calc(100vw - 40px);
div.ln {
margin-top: 10px;
}
}
.info {
padding: 10px;
background-color: lightyellow;
margin: 10px 10px;
border: 1px solid #ddd;
}
div.ln div:nth-child(1) {
width: calc(70vw + 10px);
}
form {
margin: 10px;
}
fieldset {
padding: 10px;
margin: 20px 0;
overflow: auto;
}
div.table_wrapper {
overflow-x: auto;
white-space: nowrap;
}
table {
border-collapse: collapse;
}
td, th {
padding: 5px;
}
th, tr.total td {
border: 2px solid black;
}
td {
border-top: 1px solid #bbb;
border-bottom: 1px solid #bbb;
border-left: 2px solid black;
border-right: 2px solid black;
}
td.null {
background-color: #bbb
}
tr.total {
font-weight: bold;
text-align: center;
}
tr:hover {
background-color: #ffffdd;
}
.note {
width: 60px;
padding: 5px;
border: none;
background-color: #eee;
font: large monospace;
}
.note:invalid, .note[value=""] {
background-color: #ffdddd;
}
label {
display: none;
}
footer {
margin-top: 20px;
padding: 10px;
text-align: center;
}
del {
color: #888;
div.ln div:nth-child(3), div.ln div:nth-child(4) {
width: 35vw;
}
}