Files
alrahma_sunday_school/app/Services/Calculators/HomeworkCalculator.php
T
2026-02-10 22:11:06 -05:00

24 lines
676 B
PHP

<?php
namespace App\Services\Calculators;
use App\Interfaces\ScoreCalculatorInterface;
use App\Models\HomeworkModel;
class HomeworkCalculator implements ScoreCalculatorInterface
{
private $homeworkModel;
public function __construct(HomeworkModel $homeworkModel)
{
$this->homeworkModel = $homeworkModel;
}
public function calculate(int $studentId, string $semester, string $schoolYear, ?int $classSectionId = null): array
{
$average = $this->homeworkModel->getAverageHomeworkScore($studentId, $semester, $schoolYear, $classSectionId);
return ['homework_avg' => $average !== null ? (float) $average : null];
}
}