feat: Permettre à l'enseignant de saisir les notes dans une grille inline
L'enseignant avait besoin d'un moyen rapide de saisir les notes après une évaluation. La grille inline permet de compléter 30 élèves en moins de 3 minutes grâce à la navigation clavier (Tab/Enter/Shift+Tab), la validation temps réel, l'auto-save debounced (500ms) et les raccourcis /abs et /disp pour marquer absents/dispensés. Les notes restent en brouillon jusqu'à publication explicite (avec confirmation modale). Une fois publiées, les élèves les voient immédiatement ; les parents après un délai de 24h (VisibiliteNotesPolicy). Le mode offline stocke les notes en IndexedDB et synchronise automatiquement au retour de la connexion. Chaque modification est auditée dans grade_events via un event subscriber qui écoute NoteSaisie/NoteModifiee sur le bus d'événements.
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Scolarite\Domain\Policy;
|
||||
|
||||
use App\Administration\Domain\Model\SchoolClass\ClassId;
|
||||
use App\Administration\Domain\Model\Subject\SubjectId;
|
||||
use App\Administration\Domain\Model\User\UserId;
|
||||
use App\Scolarite\Domain\Model\Evaluation\Coefficient;
|
||||
use App\Scolarite\Domain\Model\Evaluation\Evaluation;
|
||||
use App\Scolarite\Domain\Model\Evaluation\EvaluationId;
|
||||
use App\Scolarite\Domain\Model\Evaluation\EvaluationStatus;
|
||||
use App\Scolarite\Domain\Model\Evaluation\GradeScale;
|
||||
use App\Scolarite\Domain\Policy\VisibiliteNotesPolicy;
|
||||
use App\Shared\Domain\Clock;
|
||||
use App\Shared\Domain\Tenant\TenantId;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class VisibiliteNotesPolicyTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function eleveVoitNotesPubliees(): void
|
||||
{
|
||||
$policy = $this->createPolicy(new DateTimeImmutable('2026-03-28 10:00:00'));
|
||||
$evaluation = $this->createPublishedEvaluation(new DateTimeImmutable('2026-03-27 14:00:00'));
|
||||
|
||||
self::assertTrue($policy->visiblePourEleve($evaluation));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function eleveNeVoitPasNotesBrouillon(): void
|
||||
{
|
||||
$policy = $this->createPolicy(new DateTimeImmutable('2026-03-27 15:00:00'));
|
||||
$evaluation = $this->createUnpublishedEvaluation();
|
||||
|
||||
self::assertFalse($policy->visiblePourEleve($evaluation));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function parentNeVoitPasAvant24h(): void
|
||||
{
|
||||
$publishedAt = new DateTimeImmutable('2026-03-27 14:00:00');
|
||||
$now = new DateTimeImmutable('2026-03-28 13:59:59'); // 23h59 après
|
||||
$policy = $this->createPolicy($now);
|
||||
$evaluation = $this->createPublishedEvaluation($publishedAt);
|
||||
|
||||
self::assertFalse($policy->visiblePourParent($evaluation));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function parentVoitApres24h(): void
|
||||
{
|
||||
$publishedAt = new DateTimeImmutable('2026-03-27 14:00:00');
|
||||
$now = new DateTimeImmutable('2026-03-28 14:00:00'); // exactement 24h après
|
||||
$policy = $this->createPolicy($now);
|
||||
$evaluation = $this->createPublishedEvaluation($publishedAt);
|
||||
|
||||
self::assertTrue($policy->visiblePourParent($evaluation));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function parentNeVoitPasNotesBrouillon(): void
|
||||
{
|
||||
$policy = $this->createPolicy(new DateTimeImmutable('2026-04-01 10:00:00'));
|
||||
$evaluation = $this->createUnpublishedEvaluation();
|
||||
|
||||
self::assertFalse($policy->visiblePourParent($evaluation));
|
||||
}
|
||||
|
||||
private function createPolicy(DateTimeImmutable $now): VisibiliteNotesPolicy
|
||||
{
|
||||
$clock = new class($now) implements Clock {
|
||||
public function __construct(private readonly DateTimeImmutable $now)
|
||||
{
|
||||
}
|
||||
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return $this->now;
|
||||
}
|
||||
};
|
||||
|
||||
return new VisibiliteNotesPolicy($clock);
|
||||
}
|
||||
|
||||
private function createPublishedEvaluation(DateTimeImmutable $publishedAt): Evaluation
|
||||
{
|
||||
return Evaluation::reconstitute(
|
||||
id: EvaluationId::generate(),
|
||||
tenantId: TenantId::fromString('550e8400-e29b-41d4-a716-446655440001'),
|
||||
classId: ClassId::fromString('550e8400-e29b-41d4-a716-446655440020'),
|
||||
subjectId: SubjectId::fromString('550e8400-e29b-41d4-a716-446655440030'),
|
||||
teacherId: UserId::fromString('550e8400-e29b-41d4-a716-446655440010'),
|
||||
title: 'Test',
|
||||
description: null,
|
||||
evaluationDate: new DateTimeImmutable('2026-04-15'),
|
||||
gradeScale: new GradeScale(20),
|
||||
coefficient: new Coefficient(1.0),
|
||||
status: EvaluationStatus::PUBLISHED,
|
||||
createdAt: new DateTimeImmutable('2026-03-12 10:00:00'),
|
||||
updatedAt: $publishedAt,
|
||||
gradesPublishedAt: $publishedAt,
|
||||
);
|
||||
}
|
||||
|
||||
private function createUnpublishedEvaluation(): Evaluation
|
||||
{
|
||||
return Evaluation::reconstitute(
|
||||
id: EvaluationId::generate(),
|
||||
tenantId: TenantId::fromString('550e8400-e29b-41d4-a716-446655440001'),
|
||||
classId: ClassId::fromString('550e8400-e29b-41d4-a716-446655440020'),
|
||||
subjectId: SubjectId::fromString('550e8400-e29b-41d4-a716-446655440030'),
|
||||
teacherId: UserId::fromString('550e8400-e29b-41d4-a716-446655440010'),
|
||||
title: 'Test',
|
||||
description: null,
|
||||
evaluationDate: new DateTimeImmutable('2026-04-15'),
|
||||
gradeScale: new GradeScale(20),
|
||||
coefficient: new Coefficient(1.0),
|
||||
status: EvaluationStatus::PUBLISHED,
|
||||
createdAt: new DateTimeImmutable('2026-03-12 10:00:00'),
|
||||
updatedAt: new DateTimeImmutable('2026-03-12 10:00:00'),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user