Skip to content

Commit

Permalink
Merge branch 'dev-channel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Truiteseche committed Apr 8, 2024
2 parents f98a9db + 1765586 commit d1da845
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Canardman from "./components/Canardman/Canardman";
import AppLoading from "./components/generic/Loading/AppLoading";
import EdpUnblock from "./components/EdpUnblock/EdpUnblock"
import { useCreateNotification } from "./components/generic/PopUps/Notification";
import { getGradeValue, calcAverage, findCategory, calcCategoryAverage, calcGeneralAverage, formatSkills } from "./utils/gradesTools";
import { getGradeValue, calcAverage, findCategory, calcCategoryAverage, calcGeneralAverage, formatSkills, safeParseFloat } from "./utils/gradesTools";
import { areOccurenciesEqual, createUserLists, encrypt, decrypt, getBrowser } from "./utils/utils";
import { getCurrentSchoolYear } from "./utils/date";
import { getProxiedURL } from "./utils/requests";
Expand Down Expand Up @@ -695,9 +695,9 @@ export default function App() {
newSubject.elementType = "subject";
newSubject.id = matiere.id.toString();
newSubject.name = matiere.discipline.replace(". ", ".").replace(".", ". ");
newSubject.classAverage = !isNaN(parseFloat(matiere.moyenneClasse?.replace(",", "."))) ? parseFloat(matiere.moyenneClasse?.replace(",", ".")) : "N/A";
newSubject.minAverage = !isNaN(parseFloat(matiere.moyenneMin?.replace(",", "."))) ? parseFloat(matiere.moyenneMin?.replace(",", ".")) : "N/A";
newSubject.maxAverage = !isNaN(parseFloat(matiere.moyenneMax?.replace(",", "."))) ? parseFloat(matiere.moyenneMax?.replace(",", ".")) : "N/A";
newSubject.classAverage = safeParseFloat(matiere.moyenneClasse);
newSubject.minAverage = safeParseFloat(matiere.moyenneMin);
newSubject.maxAverage = safeParseFloat(matiere.moyenneMax);
newSubject.coef = matiere.coef;
newSubject.size = matiere.effectif;
newSubject.rank = matiere.rang;
Expand Down Expand Up @@ -781,12 +781,12 @@ export default function App() {
newGrade.type = grade.typeDevoir;
newGrade.date = new Date(grade.date);
newGrade.entryDate = new Date(grade.dateSaisie);
newGrade.coef = parseFloat(grade.coef);
newGrade.scale = isNaN(parseFloat(grade.noteSur)) ? "N/A" : parseFloat(grade.noteSur);
newGrade.coef = safeParseFloat(grade.coef);
newGrade.scale = safeParseFloat(grade.noteSur);
newGrade.value = getGradeValue(grade.valeur);
newGrade.classMin = isNaN(parseFloat(grade.minClasse?.replace(",", "."))) ? "N/A" : parseFloat(grade.minClasse?.replace(",", "."));
newGrade.classMax = isNaN(parseFloat(grade.maxClasse?.replace(",", "."))) ? "N/A" : parseFloat(grade.maxClasse?.replace(",", "."));
newGrade.classAverage = isNaN(parseFloat(grade.moyenneClasse?.replace(",", "."))) ? "N/A" : parseFloat(grade.moyenneClasse?.replace(",", "."));
newGrade.classMin = safeParseFloat(grade.minClasse);
newGrade.classMax = safeParseFloat(grade.maxClasse);
newGrade.classAverage = safeParseFloat(grade.moyenneClasse);
newGrade.subjectName = grade.libelleMatiere;
newGrade.isSignificant = !grade.nonSignificatif;
newGrade.examSubjectSRC = grade.uncSujet;
Expand Down
4 changes: 4 additions & 0 deletions src/utils/gradesTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function getGradeValue(gradeValue) {
return isNaN(output) ? "N/A" : output;
}

export function safeParseFloat(value) {
return isNaN(parseFloat(value?.replace(",", "."))) ? "N/A" : parseFloat(value?.replace(",", "."))
}

export function calcAverage(list) {
let average = 0;
let coef = 0;
Expand Down

0 comments on commit d1da845

Please sign in to comment.