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

24 lines
636 B
PHP

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