fix gitlab tests
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\Calendar;
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\ScoreComment;
|
||||
use App\Models\SemesterScore;
|
||||
use App\Models\StudentClass;
|
||||
use App\Models\TeacherClass;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
@@ -15,7 +16,9 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LandingPageTeacherSummaryService
|
||||
{
|
||||
public function __construct(private LandingPageContextService $context) {}
|
||||
public function __construct(private LandingPageContextService $context)
|
||||
{
|
||||
}
|
||||
|
||||
public function summary(int $teacherId, ?int $requestedClassSectionId = null): array
|
||||
{
|
||||
@@ -32,7 +35,7 @@ class LandingPageTeacherSummaryService
|
||||
$activeId = null;
|
||||
if ($requestedClassSectionId && in_array($requestedClassSectionId, $availableIds, true)) {
|
||||
$activeId = $requestedClassSectionId;
|
||||
} elseif (! empty($availableIds)) {
|
||||
} elseif (!empty($availableIds)) {
|
||||
$activeId = $availableIds[0];
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ class LandingPageTeacherSummaryService
|
||||
}
|
||||
|
||||
$normalizedSemester = ucfirst(strtolower(trim((string) $semester)));
|
||||
if (! in_array($normalizedSemester, ['Fall', 'Spring'], true)) {
|
||||
if (!in_array($normalizedSemester, ['Fall', 'Spring'], true)) {
|
||||
$normalizedSemester = 'Fall';
|
||||
}
|
||||
|
||||
@@ -111,7 +114,7 @@ class LandingPageTeacherSummaryService
|
||||
];
|
||||
|
||||
$uniqueStudentIds = [];
|
||||
if (! empty($classSectionIds)) {
|
||||
if (!empty($classSectionIds)) {
|
||||
$studentRows = DB::table('student_class as sc')
|
||||
->select('sc.student_id', 'sc.class_section_id')
|
||||
->join('students as s', 's.id', '=', 'sc.student_id')
|
||||
@@ -133,7 +136,7 @@ class LandingPageTeacherSummaryService
|
||||
$summary['attendanceSummary']['students'] = $totalStudents;
|
||||
|
||||
$scoreRows = [];
|
||||
if (! empty($classSectionIds)) {
|
||||
if (!empty($classSectionIds)) {
|
||||
$scoreRows = SemesterScore::query()
|
||||
->select(['student_id', 'class_section_id', 'midterm_exam_score', 'final_exam_score', 'participation_score'])
|
||||
->whereIn('class_section_id', $classSectionIds)
|
||||
@@ -211,7 +214,7 @@ class LandingPageTeacherSummaryService
|
||||
];
|
||||
|
||||
$commentRows = [];
|
||||
if (! empty($uniqueStudentIds)) {
|
||||
if (!empty($uniqueStudentIds)) {
|
||||
$commentRows = ScoreComment::query()
|
||||
->select(['student_id', 'score_type', 'comment', 'comment_review'])
|
||||
->whereIn('student_id', $uniqueStudentIds)
|
||||
@@ -235,7 +238,7 @@ class LandingPageTeacherSummaryService
|
||||
if ($type === '') {
|
||||
$type = 'general';
|
||||
}
|
||||
if (! isset($commentStats[$type])) {
|
||||
if (!isset($commentStats[$type])) {
|
||||
$commentStats[$type] = ['pending' => 0, 'reviewed' => 0];
|
||||
}
|
||||
|
||||
@@ -258,7 +261,7 @@ class LandingPageTeacherSummaryService
|
||||
}
|
||||
|
||||
foreach ($expectedCommentTypes as $type) {
|
||||
if (! isset($commentStats[$type])) {
|
||||
if (!isset($commentStats[$type])) {
|
||||
$commentStats[$type] = ['pending' => 0, 'reviewed' => 0];
|
||||
}
|
||||
}
|
||||
@@ -282,7 +285,7 @@ class LandingPageTeacherSummaryService
|
||||
$completionPct = $totalStudents > 0 ? (int) round(min(100, ($filled / $totalStudents) * 100)) : 0;
|
||||
|
||||
$commentTypes[$type] = [
|
||||
'label' => ucfirst($type).' comments',
|
||||
'label' => ucfirst($type) . ' comments',
|
||||
'pending' => $stats['pending'],
|
||||
'reviewed' => $stats['reviewed'],
|
||||
'filled' => $filled,
|
||||
@@ -309,7 +312,7 @@ class LandingPageTeacherSummaryService
|
||||
];
|
||||
|
||||
$attendanceRows = [];
|
||||
if (! empty($classSectionIds)) {
|
||||
if (!empty($classSectionIds)) {
|
||||
$attendanceRows = AttendanceRecord::query()
|
||||
->select(['student_id', 'class_section_id', 'total_absence'])
|
||||
->whereIn('class_section_id', $classSectionIds)
|
||||
@@ -359,7 +362,7 @@ class LandingPageTeacherSummaryService
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
if ($attendanceStatus['submitted'] === false && ! empty($classSectionIds)) {
|
||||
if ($attendanceStatus['submitted'] === false && !empty($classSectionIds)) {
|
||||
$summary['attendanceSummary']['completionPct'] = 0;
|
||||
$summary['attendanceSummary']['recorded'] = 0;
|
||||
}
|
||||
@@ -374,22 +377,20 @@ class LandingPageTeacherSummaryService
|
||||
$notifications = [];
|
||||
$buildScoreLink = static function (?string $focus): string {
|
||||
$base = '/teacher/scores';
|
||||
|
||||
return $focus ? $base.'?focus='.urlencode($focus) : $base;
|
||||
return $focus ? $base . '?focus=' . urlencode($focus) : $base;
|
||||
};
|
||||
$determineFocus = static function (array $event): string {
|
||||
$eventTypeText = strtolower(trim((string) ($event['event_type'] ?? '')));
|
||||
if ($eventTypeText !== '' && str_contains($eventTypeText, 'draft')) {
|
||||
return 'comments';
|
||||
}
|
||||
$text = strtolower(trim(($event['title'] ?? '').' '.($event['description'] ?? '')));
|
||||
$text = strtolower(trim(($event['title'] ?? '') . ' ' . ($event['description'] ?? '')));
|
||||
if ($text === '') {
|
||||
return 'scores';
|
||||
}
|
||||
if (str_contains($text, 'comment') || str_contains($text, 'ptap')) {
|
||||
return 'comments';
|
||||
}
|
||||
|
||||
return 'scores';
|
||||
};
|
||||
$calendarLink = '/teacher/calendar';
|
||||
@@ -442,13 +443,12 @@ class LandingPageTeacherSummaryService
|
||||
$notifications[] = [
|
||||
'type' => 'danger',
|
||||
'message' => sprintf(
|
||||
'Deadline today: %s is due. Submit the remaining entries before the day ends.',
|
||||
"Deadline today: %s is due. Submit the remaining entries before the day ends.",
|
||||
$matchedType
|
||||
),
|
||||
'link' => $buildScoreLink($eventFocus),
|
||||
'linkText' => 'Submit now',
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ class LandingPageTeacherSummaryService
|
||||
$notifications[] = [
|
||||
'type' => 'warning',
|
||||
'message' => sprintf(
|
||||
'%s is due on %s%s. Review it on the calendar so you don’t miss it.',
|
||||
"%s is due on %s%s. Review it on the calendar so you don’t miss it.",
|
||||
$matchedType,
|
||||
$eventDateTime->format('M j, Y'),
|
||||
$relativeText
|
||||
@@ -470,13 +470,13 @@ class LandingPageTeacherSummaryService
|
||||
];
|
||||
}
|
||||
|
||||
if (! $activeDeadline) {
|
||||
if (!$activeDeadline) {
|
||||
$scoreLabel = $summary['scoreSummary']['fieldLabel'] ?? 'Score';
|
||||
if (! empty($summary['scoreSummary']['missing'] ?? 0)) {
|
||||
if (!empty($summary['scoreSummary']['missing'] ?? 0)) {
|
||||
$notifications[] = [
|
||||
'type' => 'warning',
|
||||
'message' => sprintf(
|
||||
'You have %s %s entries missing on the scores page. Please finish submitting them.',
|
||||
"You have %s %s entries missing on the scores page. Please finish submitting them.",
|
||||
(int) $summary['scoreSummary']['missing'],
|
||||
$scoreLabel
|
||||
),
|
||||
@@ -493,20 +493,20 @@ class LandingPageTeacherSummaryService
|
||||
$notifications[] = [
|
||||
'type' => 'warning',
|
||||
'message' => sprintf(
|
||||
'%s comment missing for %s student(s). Leave comments on the scores page.',
|
||||
"%s comment missing for %s student(s). Leave comments on the scores page.",
|
||||
ucfirst($type),
|
||||
$count
|
||||
),
|
||||
'link' => $buildScoreLink('comments'),
|
||||
'linkText' => ucfirst($type).' comments',
|
||||
'linkText' => ucfirst($type) . ' comments',
|
||||
];
|
||||
}
|
||||
|
||||
if (! empty($summary['participationSummary']['missing'] ?? 0)) {
|
||||
if (!empty($summary['participationSummary']['missing'] ?? 0)) {
|
||||
$notifications[] = [
|
||||
'type' => 'warning',
|
||||
'message' => sprintf(
|
||||
'Participation entries are still missing for %s student(s). Please add them from the scores page.',
|
||||
"Participation entries are still missing for %s student(s). Please add them from the scores page.",
|
||||
(int) $summary['participationSummary']['missing']
|
||||
),
|
||||
'link' => $buildScoreLink('scores'),
|
||||
@@ -515,11 +515,11 @@ class LandingPageTeacherSummaryService
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($summary['attendanceStatus']['missingSections'] ?? [])) {
|
||||
if (!empty($summary['attendanceStatus']['missingSections'] ?? [])) {
|
||||
$missingNames = $summary['attendanceStatus']['missingNames'] ?? [];
|
||||
$label = '';
|
||||
if (! empty($missingNames)) {
|
||||
$label = ' ('.implode(', ', array_slice($missingNames, 0, 3)).(count($missingNames) > 3 ? '…' : '').')';
|
||||
if (!empty($missingNames)) {
|
||||
$label = ' (' . implode(', ', array_slice($missingNames, 0, 3)) . (count($missingNames) > 3 ? '…' : '') . ')';
|
||||
}
|
||||
$notifications[] = [
|
||||
'type' => 'danger',
|
||||
@@ -564,13 +564,13 @@ class LandingPageTeacherSummaryService
|
||||
$missingSections = [];
|
||||
foreach ($classSectionIds as $classSectionId) {
|
||||
$status = $statusMap[$classSectionId] ?? '';
|
||||
if (! in_array($status, ['submitted', 'published', 'finalized'], true)) {
|
||||
if (!in_array($status, ['submitted', 'published', 'finalized'], true)) {
|
||||
$missingSections[] = $classSectionId;
|
||||
}
|
||||
}
|
||||
|
||||
$missingNames = [];
|
||||
if (! empty($missingSections)) {
|
||||
if (!empty($missingSections)) {
|
||||
$sectionRows = ClassSection::query()
|
||||
->select(['class_section_id', 'class_section_name'])
|
||||
->whereIn('class_section_id', $missingSections)
|
||||
|
||||
Reference in New Issue
Block a user