test : changed test format + added playwright support
Check Deno code / Check Deno code (pull_request) Has been cancelled
Tests / Unit tests (pull_request) Has been cancelled
Tests / Integration tests (pull_request) Has been cancelled
Check Deno code / Check Deno code (push) Has been cancelled
Tests / Unit tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled

This commit was merged in pull request #153.
This commit is contained in:
2026-05-03 21:52:02 +02:00
parent ed2fe69f54
commit 951c9c1fea
52 changed files with 3576 additions and 5212 deletions
+9 -28
View File
@@ -1,4 +1,9 @@
import { useEffect, useState } from "preact/hooks";
import {
applyAjustement,
calculateWeightedAverage,
getEffectiveNote,
} from "$root/logic/grades.ts";
type Note = {
numEtud: number;
@@ -6,6 +11,7 @@ type Note = {
note: number;
noteSession2: number | null;
};
// ... rest of types unchanged ...
type UE = { id: number; nom: string };
type UEModule = {
idModule: string;
@@ -36,11 +42,6 @@ function avgClass(avg: number | null): string {
return avg >= 10 ? "avg-good" : "avg-warn";
}
/** Returns the effective note (session 2 if exists, otherwise session 1). */
function effectiveNote(n: Note): number {
return n.noteSession2 ?? n.note;
}
export default function NotesView({ numEtud, prenom }: Props) {
const [notes, setNotes] = useState<Note[]>([]);
const [ues, setUes] = useState<UE[]>([]);
@@ -175,29 +176,9 @@ export default function NotesView({ numEtud, prenom }: Props) {
if (!ue) return null;
const ueModsForUE = filteredUeModules.filter((um) => um.idUE === ueId);
let weightedSum = 0;
let coveredCoeff = 0;
ueModsForUE.forEach((um) => {
const noteObj = noteMap[um.idModule];
if (noteObj) {
const val = effectiveNote(noteObj);
weightedSum += val * um.coeff;
coveredCoeff += um.coeff;
}
});
const avg = coveredCoeff > 0 ? weightedSum / coveredCoeff : null;
const avg = calculateWeightedAverage(ueModsForUE, noteMap);
const ajust = ajMap[ueId] ?? null;
// If ajust.valeur exists, it replaces the calculated average
// Then malus is subtracted
let finalAvg: number | null = avg;
if (ajust) {
finalAvg = ajust.valeur;
if (ajust.malus > 0) {
finalAvg = (finalAvg ?? 0) - ajust.malus;
}
}
const finalAvg = applyAjustement(avg, ajust);
return (
<div key={ueId} class="ue-card">
@@ -218,7 +199,7 @@ export default function NotesView({ numEtud, prenom }: Props) {
{ueModsForUE.map((um) => {
const mod = moduleMap[um.idModule];
const noteObj = noteMap[um.idModule] ?? null;
const effective = noteObj ? effectiveNote(noteObj) : null;
const effective = noteObj ? getEffectiveNote(noteObj) : null;
const hasS2 = noteObj?.noteSession2 != null;
return (