add test batches
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Services\Reports\ReportCards;
|
||||
|
||||
use App\Models\Calendar;
|
||||
use App\Models\AttendanceData;
|
||||
use App\Models\AttendanceRecord;
|
||||
use App\Models\Calendar;
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\ReportCardAcknowledgement;
|
||||
use App\Models\ScoreComment;
|
||||
@@ -12,12 +13,13 @@ use App\Models\SemesterScore;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudentClass;
|
||||
use App\Models\TeacherClass;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportCardService
|
||||
{
|
||||
private string $schoolYear;
|
||||
|
||||
private string $semester;
|
||||
|
||||
public function __construct()
|
||||
@@ -54,7 +56,7 @@ class ReportCardService
|
||||
->get();
|
||||
foreach ($q2->all() as $r) {
|
||||
$val = (string) ($r->school_year ?? '');
|
||||
if ($val !== '' && ! in_array($val, $schoolYears, true)) {
|
||||
if ($val !== '' && !in_array($val, $schoolYears, true)) {
|
||||
$schoolYears[] = $val;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +84,7 @@ class ReportCardService
|
||||
->get();
|
||||
foreach ($rs2->all() as $r) {
|
||||
$val = (string) ($r->semester ?? '');
|
||||
if ($val !== '' && ! in_array($val, $semesters, true)) {
|
||||
if ($val !== '' && !in_array($val, $semesters, true)) {
|
||||
$semesters[] = $val;
|
||||
}
|
||||
}
|
||||
@@ -91,14 +93,14 @@ class ReportCardService
|
||||
|
||||
$defaults = array_values(array_filter([(string) ($this->semester ?? ''), 'Fall', 'Spring'], static fn ($v) => $v !== ''));
|
||||
foreach ($defaults as $d) {
|
||||
if (! in_array($d, $semesters, true)) {
|
||||
if (!in_array($d, $semesters, true)) {
|
||||
$semesters[] = $d;
|
||||
}
|
||||
}
|
||||
$semesters = array_values(array_unique($semesters));
|
||||
if ($sem === '' && ! empty($semesters)) {
|
||||
if ($sem === '' && !empty($semesters)) {
|
||||
$sem = $semesters[0];
|
||||
} elseif ($sem !== '' && ! in_array($sem, $semesters, true)) {
|
||||
} elseif ($sem !== '' && !in_array($sem, $semesters, true)) {
|
||||
array_unshift($semesters, $sem);
|
||||
$semesters = array_values(array_unique($semesters));
|
||||
}
|
||||
@@ -126,7 +128,7 @@ class ReportCardService
|
||||
->get()
|
||||
->map(fn ($r) => (array) $r)
|
||||
->all();
|
||||
if (! empty($stuRows)) {
|
||||
if (!empty($stuRows)) {
|
||||
$students = $stuRows;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
@@ -252,7 +254,7 @@ class ReportCardService
|
||||
$students = $this->fetchStudentsByClass($sectionId, $year);
|
||||
}
|
||||
$rosterSemester = '';
|
||||
$usedFallback = ! empty($students);
|
||||
$usedFallback = !empty($students);
|
||||
}
|
||||
|
||||
if (empty($students)) {
|
||||
@@ -299,7 +301,7 @@ class ReportCardService
|
||||
$scoreByStudent = [];
|
||||
foreach ($scoreRows as $row) {
|
||||
$sid = (int) ($row['student_id'] ?? 0);
|
||||
if ($sid > 0 && ! isset($scoreByStudent[$sid])) {
|
||||
if ($sid > 0 && !isset($scoreByStudent[$sid])) {
|
||||
$scoreByStudent[$sid] = $row;
|
||||
}
|
||||
}
|
||||
@@ -324,7 +326,7 @@ class ReportCardService
|
||||
->all();
|
||||
foreach ($otherRows as $row) {
|
||||
$sid = (int) ($row['student_id'] ?? 0);
|
||||
if ($sid > 0 && ! isset($firstScoreByStudent[$sid])) {
|
||||
if ($sid > 0 && !isset($firstScoreByStudent[$sid])) {
|
||||
$firstScoreByStudent[$sid] = $row;
|
||||
}
|
||||
}
|
||||
@@ -387,7 +389,7 @@ class ReportCardService
|
||||
->all();
|
||||
foreach ($ackRows as $row) {
|
||||
$sid = (int) ($row['student_id'] ?? 0);
|
||||
if ($sid > 0 && ! isset($ackMap[$sid])) {
|
||||
if ($sid > 0 && !isset($ackMap[$sid])) {
|
||||
$ackMap[$sid] = $row;
|
||||
}
|
||||
}
|
||||
@@ -400,7 +402,7 @@ class ReportCardService
|
||||
$warningCount = 0;
|
||||
foreach ($students as $student) {
|
||||
$sid = (int) ($student['id'] ?? 0);
|
||||
$name = trim(((string) ($student['firstname'] ?? '')).' '.((string) ($student['lastname'] ?? '')));
|
||||
$name = trim(((string) ($student['firstname'] ?? '')) . ' ' . ((string) ($student['lastname'] ?? '')));
|
||||
$missing = [];
|
||||
$warnings = [];
|
||||
|
||||
@@ -415,7 +417,7 @@ class ReportCardService
|
||||
$semesterScore = null;
|
||||
$hasAllComponents = false;
|
||||
|
||||
if (! $score) {
|
||||
if (!$score) {
|
||||
$missing[] = 'Score record';
|
||||
} else {
|
||||
$attendanceScore = $score['attendance_score'] ?? null;
|
||||
@@ -428,11 +430,11 @@ class ReportCardService
|
||||
$score['project_avg'] ?? null,
|
||||
$score['test_avg'] ?? null,
|
||||
];
|
||||
$hasAllComponents = ! in_array(false, array_map($isNumeric, $components), true);
|
||||
$hasAllComponents = !in_array(false, array_map($isNumeric, $components), true);
|
||||
|
||||
if ($isSecond) {
|
||||
$examScore = $score['final_exam_score'] ?? null;
|
||||
if (! $isNumeric($examScore) && $isNumeric($score['midterm_exam_score'] ?? null)) {
|
||||
if (!$isNumeric($examScore) && $isNumeric($score['midterm_exam_score'] ?? null)) {
|
||||
$examScore = $score['midterm_exam_score'];
|
||||
$warnings[] = 'Final exam stored as midterm';
|
||||
}
|
||||
@@ -442,13 +444,13 @@ class ReportCardService
|
||||
$examScore = $score['final_exam_score'] ?? ($score['midterm_exam_score'] ?? null);
|
||||
}
|
||||
|
||||
if (! $isNumeric($examScore)) {
|
||||
if (!$isNumeric($examScore)) {
|
||||
$missing[] = $isSecond ? 'Final exam score' : ($isFirst ? 'Midterm exam score' : 'Exam score');
|
||||
}
|
||||
if (! $isNumeric($attendanceScore)) {
|
||||
if (!$isNumeric($attendanceScore)) {
|
||||
$missing[] = 'Attendance score';
|
||||
}
|
||||
if (! $isNumeric($ptapScore)) {
|
||||
if (!$isNumeric($ptapScore)) {
|
||||
if ($hasAllComponents) {
|
||||
$warnings[] = 'PTAP computed from components';
|
||||
} else {
|
||||
@@ -457,7 +459,7 @@ class ReportCardService
|
||||
}
|
||||
|
||||
$canComputeSemester = $isNumeric($examScore) && $isNumeric($attendanceScore) && ($isNumeric($ptapScore) || $hasAllComponents);
|
||||
if (! $isNumeric($semesterScore)) {
|
||||
if (!$isNumeric($semesterScore)) {
|
||||
if ($canComputeSemester) {
|
||||
$warnings[] = 'Semester score computed';
|
||||
} else {
|
||||
@@ -467,7 +469,7 @@ class ReportCardService
|
||||
|
||||
if ($isSecond) {
|
||||
$firstScore = $firstScoreByStudent[$sid]['semester_score'] ?? null;
|
||||
if (! $isNumeric($firstScore)) {
|
||||
if (!$isNumeric($firstScore)) {
|
||||
$missing[] = 'First semester score';
|
||||
}
|
||||
}
|
||||
@@ -480,7 +482,7 @@ class ReportCardService
|
||||
? ($commentSet[$commentKey] ?? '')
|
||||
: ($commentSet['final'] ?? ($commentSet['midterm'] ?? ''));
|
||||
if (trim((string) $examComment) === '') {
|
||||
$missing[] = $commentLabel.' comment';
|
||||
$missing[] = $commentLabel . ' comment';
|
||||
}
|
||||
if (trim((string) ($commentSet['ptap'] ?? '')) === '') {
|
||||
$missing[] = 'PTAP comment';
|
||||
@@ -493,7 +495,7 @@ class ReportCardService
|
||||
if ($isComplete) {
|
||||
$completeCount++;
|
||||
}
|
||||
if (! empty($warnings)) {
|
||||
if (!empty($warnings)) {
|
||||
$warningCount++;
|
||||
}
|
||||
|
||||
@@ -562,7 +564,7 @@ class ReportCardService
|
||||
$reportDate = $this->sanitizeReportDate((string) ($params['report_date'] ?? ''));
|
||||
$data = $this->prepareStudentReportData($studentId, $schoolYear, $semester);
|
||||
|
||||
if (! $data) {
|
||||
if (!$data) {
|
||||
return ['ok' => false, 'message' => 'Student not found or missing scores.'];
|
||||
}
|
||||
|
||||
@@ -572,7 +574,7 @@ class ReportCardService
|
||||
$pdf = new \FPDF('P', 'mm', 'Letter');
|
||||
$this->formatReportPDF($pdf, $data);
|
||||
|
||||
$filename = 'ReportCard_'.($data['student']['lastname'] ?? 'student').'.pdf';
|
||||
$filename = 'ReportCard_' . ($data['student']['lastname'] ?? 'student') . '.pdf';
|
||||
|
||||
$pdfContent = $pdf->Output('S');
|
||||
|
||||
@@ -594,10 +596,10 @@ class ReportCardService
|
||||
->join('students as s', 's.id', '=', 'semester_scores.student_id')
|
||||
->where('s.is_active', 1)
|
||||
->where('semester_scores.class_section_id', $classSectionId);
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$q->where('semester_scores.school_year', $schoolYear);
|
||||
}
|
||||
if (! empty($semester)) {
|
||||
if (!empty($semester)) {
|
||||
$this->applySemesterFilter($q, $semester, 'semester_scores.semester');
|
||||
}
|
||||
$scores = $q
|
||||
@@ -607,7 +609,7 @@ class ReportCardService
|
||||
->map(fn ($r) => $r->toArray())
|
||||
->all();
|
||||
|
||||
if (! $scores) {
|
||||
if (!$scores) {
|
||||
return ['ok' => false, 'message' => 'No students found for this class section.'];
|
||||
}
|
||||
|
||||
@@ -623,7 +625,7 @@ class ReportCardService
|
||||
}
|
||||
}
|
||||
|
||||
$filename = 'ClassReport_Section_'.$classSectionId.'.pdf';
|
||||
$filename = 'ClassReport_Section_' . $classSectionId . '.pdf';
|
||||
$pdfContent = $pdf->Output('S');
|
||||
|
||||
return [
|
||||
@@ -665,7 +667,7 @@ class ReportCardService
|
||||
->orderBy('s.firstname', 'ASC')
|
||||
->orderBy('s.lastname', 'ASC');
|
||||
|
||||
if (! empty($schoolYear)) {
|
||||
if (!empty($schoolYear)) {
|
||||
$query->where('student_class.school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -681,7 +683,6 @@ class ReportCardService
|
||||
if ($s === 'spring' || $s === 'second' || str_contains($s, 'spring') || str_contains($s, '2')) {
|
||||
return 'spring';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -708,7 +709,7 @@ class ReportCardService
|
||||
private function applySemesterFilter($builder, ?string $semester, string $field = 'semester'): void
|
||||
{
|
||||
$vals = $this->semesterVariants($semester);
|
||||
if (! empty($vals)) {
|
||||
if (!empty($vals)) {
|
||||
$builder->whereIn($field, $vals);
|
||||
}
|
||||
}
|
||||
@@ -716,7 +717,7 @@ class ReportCardService
|
||||
private function applySemesterExclusion($builder, ?string $semester, string $field = 'semester'): void
|
||||
{
|
||||
$vals = $this->semesterVariants($semester);
|
||||
if (! empty($vals)) {
|
||||
if (!empty($vals)) {
|
||||
$builder->whereNotIn($field, $vals);
|
||||
}
|
||||
}
|
||||
@@ -760,7 +761,6 @@ class ReportCardService
|
||||
if ($weekday === 0) {
|
||||
return $now->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $now->modify('next sunday')->format('Y-m-d');
|
||||
}
|
||||
|
||||
@@ -788,14 +788,13 @@ class ReportCardService
|
||||
$sundays[] = $cursor->format('Y-m-d');
|
||||
$cursor = $cursor->modify('+7 days');
|
||||
}
|
||||
|
||||
return $sundays;
|
||||
}
|
||||
|
||||
private function prepareStudentReportData(int $studentId, ?string $schoolYear = null, ?string $semester = null)
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (! $student || (int) ($student->is_active ?? 1) !== 1) {
|
||||
if (!$student || (int) ($student->is_active ?? 1) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -816,7 +815,7 @@ class ReportCardService
|
||||
$this->applySemesterFilter($qb, $refSemester, 'semester');
|
||||
}
|
||||
$score = $qb->orderBy('updated_at', 'DESC')->orderBy('id', 'DESC')->first();
|
||||
if (! $score) {
|
||||
if (!$score) {
|
||||
return null;
|
||||
}
|
||||
$score = $score->toArray();
|
||||
@@ -846,7 +845,7 @@ class ReportCardService
|
||||
}
|
||||
}
|
||||
|
||||
if (! $sectionId || $sectionCode <= 0) {
|
||||
if (!$sectionId || $sectionCode <= 0) {
|
||||
try {
|
||||
$scRow = DB::table('student_class')
|
||||
->select('class_section_id')
|
||||
@@ -855,7 +854,7 @@ class ReportCardService
|
||||
->orderByRaw('COALESCE(updated_at, created_at) DESC')
|
||||
->limit(1)
|
||||
->first();
|
||||
if (! empty($scRow->class_section_id)) {
|
||||
if (!empty($scRow->class_section_id)) {
|
||||
$sectionCode = (int) $scRow->class_section_id;
|
||||
$row = DB::table('classSection')
|
||||
->select('id')
|
||||
@@ -888,7 +887,7 @@ class ReportCardService
|
||||
if (empty($taNames)) {
|
||||
$taNames = $names['ta_names'];
|
||||
}
|
||||
if (empty($teacherNamesList) && ! empty($names['teacher_names'])) {
|
||||
if (empty($teacherNamesList) && !empty($names['teacher_names'])) {
|
||||
$teacherNamesList = $names['teacher_names'];
|
||||
}
|
||||
}
|
||||
@@ -916,22 +915,22 @@ class ReportCardService
|
||||
if ($commentVal === '') {
|
||||
continue;
|
||||
}
|
||||
if (! isset($commentMap[$typeRaw])) {
|
||||
if (!isset($commentMap[$typeRaw])) {
|
||||
$commentMap[$typeRaw] = $commentVal;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($commentMap['attendance']) && ! isset($score['attendance_comment'])) {
|
||||
if (isset($commentMap['attendance']) && !isset($score['attendance_comment'])) {
|
||||
$score['attendance_comment'] = $commentMap['attendance'];
|
||||
}
|
||||
|
||||
$att = $score['attendance_score'] ?? null;
|
||||
$attendanceCommentVal = $commentMap['attendance'] ?? $score['attendance_comment'] ?? null;
|
||||
if ((! is_string($attendanceCommentVal) || trim($attendanceCommentVal) === '') && is_numeric($att) && function_exists('attendance_comment_from_score')) {
|
||||
if ((!is_string($attendanceCommentVal) || trim($attendanceCommentVal) === '') && is_numeric($att) && function_exists('attendance_comment_from_score')) {
|
||||
$autoAttendance = attendance_comment_from_score((float) $att, (string) ($student->firstname ?? ''));
|
||||
if (is_string($autoAttendance) && $autoAttendance !== '') {
|
||||
$commentMap['attendance'] = $autoAttendance;
|
||||
if (! isset($score['attendance_comment'])) {
|
||||
if (!isset($score['attendance_comment'])) {
|
||||
$score['attendance_comment'] = $autoAttendance;
|
||||
}
|
||||
}
|
||||
@@ -943,7 +942,7 @@ class ReportCardService
|
||||
if ($normSemester !== '') {
|
||||
$events = Calendar::getEventsBySchoolYearAndSemester($refYear, $normSemester);
|
||||
$dates = array_values(array_filter(array_map(static fn ($r) => (string) ($r['date'] ?? ''), $events)));
|
||||
if (! empty($dates)) {
|
||||
if (!empty($dates)) {
|
||||
$start = min($dates);
|
||||
$end = max($dates);
|
||||
$sundays = $this->listSundays($start, $end);
|
||||
@@ -968,7 +967,7 @@ class ReportCardService
|
||||
static fn ($r) => isset($r['total_attendance']) ? (int) $r['total_attendance'] : null,
|
||||
$attRows
|
||||
), static fn ($v) => $v !== null));
|
||||
if (! empty($vals)) {
|
||||
if (!empty($vals)) {
|
||||
$totalSemesterDays = max($vals);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
@@ -1025,8 +1024,7 @@ class ReportCardService
|
||||
$withPrefix = static function (array $row): string {
|
||||
$first = trim((string) ($row['firstname'] ?? ''));
|
||||
$last = trim((string) ($row['lastname'] ?? ''));
|
||||
$name = trim($last.', '.$first, ' ,');
|
||||
|
||||
$name = trim($last . ', ' . $first, ' ,');
|
||||
return $name !== '' ? $name : 'N/A';
|
||||
};
|
||||
$normalizePos = static function (?string $pos): string {
|
||||
@@ -1034,7 +1032,6 @@ class ReportCardService
|
||||
if ($pos === 'ta' || $pos === 'assistant') {
|
||||
return 'ta';
|
||||
}
|
||||
|
||||
return 'main';
|
||||
};
|
||||
|
||||
@@ -1068,7 +1065,7 @@ class ReportCardService
|
||||
|
||||
$ids = [$sectionIdOrCode];
|
||||
$rows = $runner($ids, (string) $schoolYear, (string) $semester);
|
||||
if (! empty($rows)) {
|
||||
if (!empty($rows)) {
|
||||
$consume($rows);
|
||||
}
|
||||
|
||||
@@ -1123,7 +1120,6 @@ class ReportCardService
|
||||
if (is_numeric($val)) {
|
||||
return number_format((float) $val, 1);
|
||||
}
|
||||
|
||||
return (string) $val;
|
||||
};
|
||||
$splitText = static function ($text, int $limit = 55): array {
|
||||
@@ -1133,7 +1129,6 @@ class ReportCardService
|
||||
}
|
||||
$lines = explode("\n", wordwrap($text, $limit));
|
||||
$lines[] = '';
|
||||
|
||||
return $lines;
|
||||
};
|
||||
$drawLabeledCell = static function (\FPDF $pdf, string $label, string $value, float $width = 95) {
|
||||
@@ -1148,7 +1143,6 @@ class ReportCardService
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
$wrapLinesToWidth = static function (\FPDF $pdf, string $text, float $width) {
|
||||
@@ -1159,19 +1153,18 @@ class ReportCardService
|
||||
if ($width <= 0) {
|
||||
return [$text];
|
||||
}
|
||||
$segments = preg_split('/\\r?\\n+/', $text);
|
||||
$segments = preg_split("/\\r?\\n+/", $text);
|
||||
$lines = [];
|
||||
foreach ($segments as $seg) {
|
||||
$seg = trim($seg);
|
||||
if ($seg === '') {
|
||||
$lines[] = ' ';
|
||||
|
||||
continue;
|
||||
}
|
||||
$words = preg_split('/\\s+/u', $seg);
|
||||
$current = '';
|
||||
foreach ($words as $word) {
|
||||
$trial = trim($current === '' ? $word : ($current.' '.$word));
|
||||
$trial = trim($current === '' ? $word : ($current . ' ' . $word));
|
||||
if ($pdf->GetStringWidth($trial) <= $width) {
|
||||
$current = $trial;
|
||||
} else {
|
||||
@@ -1185,7 +1178,6 @@ class ReportCardService
|
||||
$lines[] = $current;
|
||||
}
|
||||
}
|
||||
|
||||
return $lines;
|
||||
};
|
||||
$draw3ColumnRow = static function (\FPDF $pdf, string $label, $score, $feedback) use ($wrapLinesToWidth) {
|
||||
@@ -1243,13 +1235,12 @@ class ReportCardService
|
||||
$seg = trim($seg);
|
||||
if ($seg === '') {
|
||||
$out[] = ' ';
|
||||
|
||||
continue;
|
||||
}
|
||||
$words = preg_split('/\\s+/u', $seg);
|
||||
$current = '';
|
||||
foreach ($words as $word) {
|
||||
$trial = $current === '' ? $word : ($current.' '.$word);
|
||||
$trial = $current === '' ? $word : ($current . ' ' . $word);
|
||||
if ($pdf->GetStringWidth($trial) <= ($width - 2)) {
|
||||
$current = $trial;
|
||||
} else {
|
||||
@@ -1263,15 +1254,14 @@ class ReportCardService
|
||||
$out[] = $current;
|
||||
}
|
||||
}
|
||||
|
||||
return ! empty($out) ? $out : [' '];
|
||||
return !empty($out) ? $out : [' '];
|
||||
};
|
||||
|
||||
if ($startY !== null) {
|
||||
$pdf->SetY($startY);
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
if (! is_array($row) || count($row) < 4) {
|
||||
if (!is_array($row) || count($row) < 4) {
|
||||
continue;
|
||||
}
|
||||
[$labelLeft, $valueLeft, $labelRight, $valueRight] = $row;
|
||||
@@ -1326,7 +1316,6 @@ class ReportCardService
|
||||
$currentY += $rowHeight;
|
||||
$pdf->SetY($currentY);
|
||||
}
|
||||
|
||||
return $currentY;
|
||||
};
|
||||
|
||||
@@ -1343,7 +1332,7 @@ class ReportCardService
|
||||
}
|
||||
|
||||
$teacherNamesList = $data['teacher_names'] ?? [];
|
||||
if (empty($teacherNamesList) && ! empty($data['teacher_name'])) {
|
||||
if (empty($teacherNamesList) && !empty($data['teacher_name'])) {
|
||||
$teacherNamesList = [trim((string) $data['teacher_name'])];
|
||||
}
|
||||
$teacherNamesList = array_values(array_filter(
|
||||
@@ -1376,9 +1365,9 @@ class ReportCardService
|
||||
|
||||
$schoolYear = (string) ($data['score']['school_year'] ?? ($data['score']['year'] ?? 'N/A'));
|
||||
if (preg_match('/^(\\d{4})-(\\d{4})$/', $schoolYear, $m)) {
|
||||
$schoolYear = $m[1].'/'.$m[2];
|
||||
$schoolYear = $m[1] . '/' . $m[2];
|
||||
}
|
||||
$studentName = trim(($data['student']['firstname'] ?? '').' '.($data['student']['lastname'] ?? ''));
|
||||
$studentName = trim(($data['student']['firstname'] ?? '') . ' ' . ($data['student']['lastname'] ?? ''));
|
||||
$gradeLabel = (string) ($data['grade'] ?? ($data['class_section_name'] ?? 'N/A'));
|
||||
$today = (string) ($data['report_date_display'] ?? date('m-d-Y'));
|
||||
$firstSemScore = $data['first_semester_score'] ?? null;
|
||||
@@ -1407,9 +1396,9 @@ class ReportCardService
|
||||
};
|
||||
|
||||
$afterInfoY = $drawInfoRows($pdf, [
|
||||
["Teachers' Names: ", ' '.($teacherNames !== '' ? $teacherNames : 'N/A'), 'School Year: ', ' '.$schoolYear],
|
||||
['Student Name: ', ' '.($studentName !== '' ? $studentName : 'N/A'), 'Grade: ', ' '.($gradeLabel !== '' ? $gradeLabel : 'N/A')],
|
||||
['Term: ', ' '.$semFriendly, 'Date: ', ' '.$today],
|
||||
["Teachers' Names: ", ' ' . ($teacherNames !== '' ? $teacherNames : 'N/A'), 'School Year: ', ' ' . $schoolYear],
|
||||
['Student Name: ', ' ' . ($studentName !== '' ? $studentName : 'N/A'), 'Grade: ', ' ' . ($gradeLabel !== '' ? $gradeLabel : 'N/A')],
|
||||
['Term: ', ' ' . $semFriendly, 'Date: ', ' ' . $today],
|
||||
]);
|
||||
$pdf->SetY($afterInfoY);
|
||||
|
||||
@@ -1486,7 +1475,7 @@ class ReportCardService
|
||||
$pdf->Rect($x, $startY, $statW, $statH);
|
||||
$pdf->SetXY($x + 2, $startY + 3);
|
||||
$pdf->SetFont('Helvetica', 'B', 11);
|
||||
$pdf->Write(5, $lbl.' ');
|
||||
$pdf->Write(5, $lbl . ' ');
|
||||
$pdf->SetFont('Helvetica', '', 11);
|
||||
$pdf->Write(5, $val);
|
||||
}
|
||||
@@ -1494,7 +1483,7 @@ class ReportCardService
|
||||
|
||||
$effectiveSecond = $secondSemScore ?? $data['score']['semester_score'] ?? $data['total_score'] ?? null;
|
||||
$finalScoreVal = $finalAverage;
|
||||
if (! is_numeric($finalScoreVal)) {
|
||||
if (!is_numeric($finalScoreVal)) {
|
||||
$finalScoreVal = (is_numeric($firstSemScore) && is_numeric($effectiveSecond))
|
||||
? number_format(((float) $firstSemScore + (float) $effectiveSecond) / 2, 1)
|
||||
: $numFmt($effectiveSecond);
|
||||
@@ -1509,8 +1498,8 @@ class ReportCardService
|
||||
$pdf->Rect($x, $y, $w, $h);
|
||||
$pdf->SetXY($x + $pad, $y + 3);
|
||||
$pdf->SetFont('Helvetica', 'B', 11);
|
||||
$pdf->Write(5, $label.' ');
|
||||
$labelWidth = $pdf->GetStringWidth($label.' ');
|
||||
$pdf->Write(5, $label . ' ');
|
||||
$labelWidth = $pdf->GetStringWidth($label . ' ');
|
||||
$pdf->SetFont('Helvetica', '', 12);
|
||||
$pdf->SetXY($x + 2 + $labelWidth, $y + 3);
|
||||
$pdf->Write(5, $value);
|
||||
@@ -1518,14 +1507,14 @@ class ReportCardService
|
||||
|
||||
if ($semNum === 2) {
|
||||
$firstLabel = ' 1st Semester Grade:';
|
||||
$firstValue = $numFmt($firstSemScore).'/100';
|
||||
$firstValue = $numFmt($firstSemScore) . '/100';
|
||||
$secondLabel = ' 2nd Semester Grade:';
|
||||
$secondValue = $numFmt($effectiveSecond).'/100';
|
||||
$secondValue = $numFmt($effectiveSecond) . '/100';
|
||||
$drawGradeCell($pdf, $gradeX, $gradeY, $gradeCellWidth, $gradeCellHeight, $firstLabel, $firstValue, $gradePad);
|
||||
$drawGradeCell($pdf, $gradeX + $gradeCellWidth, $gradeY, $gradeCellWidth, $gradeCellHeight, $secondLabel, $secondValue, $gradePad);
|
||||
} else {
|
||||
$gradeLabel = ' 1st Semester Grade:';
|
||||
$gradeValue = $numFmt($effectiveSecond).'/100';
|
||||
$gradeValue = $numFmt($effectiveSecond) . '/100';
|
||||
$drawGradeCell($pdf, $gradeX, $gradeY, $gradeCellWidth, $gradeCellHeight, $gradeLabel, $gradeValue, $gradePad);
|
||||
}
|
||||
$pdf->SetY($gradeY + $gradeCellHeight);
|
||||
@@ -1534,7 +1523,7 @@ class ReportCardService
|
||||
$finalScoreEndY = null;
|
||||
if ($semNum === 2) {
|
||||
$finalLabel = 'Final Score****:';
|
||||
$finalValue = (is_string($finalScoreVal) ? $finalScoreVal : $numFmt($finalScoreVal)).'/100';
|
||||
$finalValue = (is_string($finalScoreVal) ? $finalScoreVal : $numFmt($finalScoreVal)) . '/100';
|
||||
$finalCellWidth = 65;
|
||||
$finalCellHeight = $finalScoreRowHeight;
|
||||
$finalX = $pdf->GetX();
|
||||
@@ -1543,8 +1532,8 @@ class ReportCardService
|
||||
$finalPad = max(0, 2 - (4 * 0.3528));
|
||||
$pdf->SetXY($finalX + $finalPad, $finalY + 3);
|
||||
$pdf->SetFont('Helvetica', 'B', 11);
|
||||
$pdf->Write(5, ' '.$finalLabel.' ');
|
||||
$finalLabelWidth = $pdf->GetStringWidth(' '.$finalLabel.' ');
|
||||
$pdf->Write(5, ' ' . $finalLabel . ' ');
|
||||
$finalLabelWidth = $pdf->GetStringWidth(' ' . $finalLabel . ' ');
|
||||
$pdf->SetFont('Helvetica', '', 12);
|
||||
$pdf->SetXY($finalX + 2 + $finalLabelWidth, $finalY + 3);
|
||||
$pdf->Write(5, $finalValue);
|
||||
@@ -1556,11 +1545,11 @@ class ReportCardService
|
||||
$examLegendLabel = ($semNum === 1) ? 'Midterm Exam' : 'Final Exam';
|
||||
$legendLines = [
|
||||
"(*) {$examLegendLabel} (Weight: 60% of semester score)",
|
||||
'(**) PTAP - Participation, Tests, Assignments, Projects (Weight: 20%)',
|
||||
"(**) PTAP - Participation, Tests, Assignments, Projects (Weight: 20%)",
|
||||
"(***) Attendance = ({$totalDays} - Total Absences + One Sick Day) / {$totalDays} ) x 100 (Weight: 20%)",
|
||||
];
|
||||
if ($semNum === 2) {
|
||||
$legendLines[] = '(****) Final Score = (1st Semester Score + 2nd Semester Score) / 2';
|
||||
$legendLines[] = "(****) Final Score = (1st Semester Score + 2nd Semester Score) / 2";
|
||||
}
|
||||
$legendLines[] = ['text' => 'If you have any questions, please contact the school via email at alrahma.isgl@gmail.com', 'bold' => true];
|
||||
$lineHeight = 4;
|
||||
@@ -1619,7 +1608,6 @@ class ReportCardService
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user