<?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];
    }
}
