Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/final-recovery-calculation #905

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/domain/grades/usecases/CalculateFinalMediaUsecase.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ private function shouldApplyFinalRecovery($gradeRule, $finalMedia)
private function applyFinalRecovery($gradesResult, $gradesFinalRecovery)
{
$result = null;
array_push($gradesFinalRecovery, $gradesResult->rec_final);
$finalRecovery = $this->getFinalRevovery($gradesResult->enrollment_fk, $gradesResult->discipline_fk);
$finalRecoveryGrade = $this->getFinalRevoveryGrade($gradesResult->enrollment_fk, $gradesResult->discipline_fk, $finalRecovery->id);
array_push($gradesFinalRecovery, $finalRecoveryGrade);
if ($finalRecovery->gradeCalculationFk->name == "Média Semestral") {
$calculation = GradeCalculation::model()->findByAttributes(["name" => "Média"]);
$result = $this->applyCalculation($calculation, $gradesFinalRecovery);
Expand All @@ -130,6 +131,23 @@ private function getFinalRevovery($enrollmentId, $discipline)
$criteria->order = "gu.id";
return GradeUnity::model()->find($criteria);
}
private function getFinalRevoveryGrade($enrollmentId, $discipline, $finalRecoveryId)
{
$criteria = new CDbCriteria();
$criteria->alias = "g";
$criteria->select = "distinct g.id, g.*";
$criteria->join = " join grade_unity_modality gum1 on g.grade_unity_modality_fk = gum1.id";
$criteria->join .= " join grade_unity gu on gum1.grade_unity_fk = gu.id"; // Corrigido o alias e referência
$criteria->condition = "g.discipline_fk = :discipline_fk and g.enrollment_fk = :enrollment_fk and gu.id = :finalRecoveryId";
$criteria->params = array(
":discipline_fk" => $discipline,
":enrollment_fk" => $enrollmentId,
":finalRecoveryId" => $finalRecoveryId
);
$criteria->order = "g.id";
return Grade::model()->find($criteria)->grade;

}

private function applyCalculation($calculation, $grades)
{
Expand Down
Loading