recreate project
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Calculators;
|
||||
|
||||
use App\Interfaces\ScoreCalculatorInterface;
|
||||
use App\Models\ProjectModel;
|
||||
|
||||
class ProjectCalculator implements ScoreCalculatorInterface
|
||||
{
|
||||
private $projectModel;
|
||||
|
||||
public function __construct(ProjectModel $projectModel)
|
||||
{
|
||||
$this->projectModel = $projectModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the average project score for a student
|
||||
*
|
||||
* @param int $studentId
|
||||
* @param string $semester
|
||||
* @param string $schoolYear
|
||||
* @return array Returns ['project_avg' => float|null]
|
||||
* @throws \RuntimeException If no project scores are found
|
||||
*/
|
||||
public function calculate(int $studentId, string $semester, string $schoolYear, ?int $classSectionId = null): array
|
||||
{
|
||||
$average = $this->projectModel->getAverageProjectScore($studentId, $semester, $schoolYear, $classSectionId);
|
||||
|
||||
return ['project_avg' => $average !== null ? (float) $average : null];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user