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,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Administration\Application\Query\HasGradesForYear;
|
||||
|
||||
use App\Administration\Application\Port\GradeExistenceChecker;
|
||||
use App\Administration\Application\Query\HasGradesForYear\HasGradesForYearHandler;
|
||||
use App\Administration\Application\Query\HasGradesForYear\HasGradesForYearQuery;
|
||||
use App\Administration\Domain\Model\SchoolClass\AcademicYearId;
|
||||
use App\Administration\Domain\Model\SchoolClass\SchoolId;
|
||||
use App\Shared\Domain\Tenant\TenantId;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class HasGradesForYearHandlerTest extends TestCase
|
||||
{
|
||||
private const string TENANT_ID = '550e8400-e29b-41d4-a716-446655440001';
|
||||
private const string SCHOOL_ID = '550e8400-e29b-41d4-a716-446655440002';
|
||||
private const string ACADEMIC_YEAR_ID = '550e8400-e29b-41d4-a716-446655440003';
|
||||
|
||||
#[Test]
|
||||
public function itReturnsFalseWhenNoGradesExist(): void
|
||||
{
|
||||
$handler = new HasGradesForYearHandler($this->createChecker(hasGrades: false));
|
||||
|
||||
$result = $handler(new HasGradesForYearQuery(
|
||||
tenantId: self::TENANT_ID,
|
||||
schoolId: self::SCHOOL_ID,
|
||||
academicYearId: self::ACADEMIC_YEAR_ID,
|
||||
));
|
||||
|
||||
self::assertFalse($result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function itReturnsTrueWhenGradesExist(): void
|
||||
{
|
||||
$handler = new HasGradesForYearHandler($this->createChecker(hasGrades: true));
|
||||
|
||||
$result = $handler(new HasGradesForYearQuery(
|
||||
tenantId: self::TENANT_ID,
|
||||
schoolId: self::SCHOOL_ID,
|
||||
academicYearId: self::ACADEMIC_YEAR_ID,
|
||||
));
|
||||
|
||||
self::assertTrue($result);
|
||||
}
|
||||
|
||||
private function createChecker(bool $hasGrades): GradeExistenceChecker
|
||||
{
|
||||
return new class($hasGrades) implements GradeExistenceChecker {
|
||||
public function __construct(private bool $hasGrades)
|
||||
{
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function hasGradesInPeriod(TenantId $tenantId, AcademicYearId $academicYearId, int $periodSequence): bool
|
||||
{
|
||||
return $this->hasGrades;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function hasGradesForYear(TenantId $tenantId, SchoolId $schoolId, AcademicYearId $academicYearId): bool
|
||||
{
|
||||
return $this->hasGrades;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user