feat: Configuration du mode de notation par établissement
Les établissements scolaires utilisent des systèmes d'évaluation variés (notes /20, /10, lettres, compétences, sans notes). Jusqu'ici l'application imposait implicitement le mode notes /20, ce qui ne correspondait pas à la réalité pédagogique de nombreuses écoles. Cette configuration permet à chaque établissement de choisir son mode de notation par année scolaire, avec verrouillage automatique dès que des notes ont été saisies pour éviter les incohérences. Le Score Sérénité adapte ses pondérations selon le mode choisi (les compétences sont converties via un mapping, le mode sans notes exclut la composante notes).
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Scolarite\Domain\Service;
|
||||
|
||||
use App\Scolarite\Domain\Model\GradingMode;
|
||||
use App\Scolarite\Domain\Service\SerenityScoreWeights;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SerenityScoreWeightsTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function numericModeUsesStandardWeights(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::NUMERIC_20);
|
||||
|
||||
self::assertSame(0.4, $weights->notesWeight);
|
||||
self::assertSame(0.3, $weights->absencesWeight);
|
||||
self::assertSame(0.3, $weights->devoirsWeight);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function competencyModeUsesAdaptedWeights(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::COMPETENCIES);
|
||||
|
||||
self::assertSame(0.4, $weights->notesWeight);
|
||||
self::assertSame(0.3, $weights->absencesWeight);
|
||||
self::assertSame(0.3, $weights->devoirsWeight);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function noGradesModeExcludesNotesComponent(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::NO_GRADES);
|
||||
|
||||
self::assertSame(0.0, $weights->notesWeight);
|
||||
self::assertSame(0.5, $weights->absencesWeight);
|
||||
self::assertSame(0.5, $weights->devoirsWeight);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function lettersModeUsesStandardWeights(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::LETTERS);
|
||||
|
||||
self::assertSame(0.4, $weights->notesWeight);
|
||||
self::assertSame(0.3, $weights->absencesWeight);
|
||||
self::assertSame(0.3, $weights->devoirsWeight);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function weightsAlwaysSumToOne(): void
|
||||
{
|
||||
foreach (GradingMode::cases() as $mode) {
|
||||
$weights = SerenityScoreWeights::forMode($mode);
|
||||
$sum = $weights->notesWeight + $weights->absencesWeight + $weights->devoirsWeight;
|
||||
self::assertEqualsWithDelta(1.0, $sum, 0.001, "Weights for {$mode->value} must sum to 1.0");
|
||||
}
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function competencyMappingConvertsToPercentage(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::COMPETENCIES);
|
||||
|
||||
self::assertSame(100, $weights->competencyToScore('acquired'));
|
||||
self::assertSame(50, $weights->competencyToScore('in_progress'));
|
||||
self::assertSame(0, $weights->competencyToScore('not_acquired'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function nonCompetencyModesReturnNullForMapping(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::NUMERIC_20);
|
||||
|
||||
self::assertNull($weights->competencyToScore('acquired'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function competencyMappingThrowsOnUnknownLevel(): void
|
||||
{
|
||||
$weights = SerenityScoreWeights::forMode(GradingMode::COMPETENCIES);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage("Niveau de compétence inconnu : 'unknown_level'");
|
||||
|
||||
$weights->competencyToScore('unknown_level');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user