@extends('backend.teacher_backend.teacher_dashboard') @section('teacher') @php /* |-------------------------------------------------------------------------- | ================================================================ | AGM SMARTSCHOOL - TEACHER DASHBOARD | ================================================================ | | This dashboard contains: | | 1. Teacher assignment summary | 2. Result analysis | 3. Student performance analysis | 4. Class performance analysis | 5. Subject performance analysis | 6. Grade distribution | 7. Score-band distribution | 8. Top and bottom students | 9. Result publication analysis | 10. CBT analysis | | IMPORTANT: | | All result analysis is restricted to the classes and subjects | assigned to the currently logged-in teacher. | |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | IMPORT MODELS |-------------------------------------------------------------------------- */ use App\Models\Teacher; use App\Models\Student; use App\Models\StudentClasses; use App\Models\Subject; use App\Models\Result; use App\Models\AssignedClassSubjectTeacher; use App\Models\AssignClassSubjectStudent; use App\Models\CbtAttempt; use App\Models\CbtTest; use Illuminate\Support\Facades\DB; /* |-------------------------------------------------------------------------- | CURRENT TEACHER |-------------------------------------------------------------------------- | | We identify the Teacher record using the logged-in user's ID. |-------------------------------------------------------------------------- */ $teacher = Teacher::where('user_id', Auth::id())->first(); $teacherId = $teacher->id ?? null; /* |-------------------------------------------------------------------------- | CURRENT TERM AND SESSION |-------------------------------------------------------------------------- */ $currentTerm = DB::table('terms') ->where('is_current', 1) ->value('name'); $currentSession = DB::table('academic_sessions') ->where('is_current', 1) ->value('name'); /* |-------------------------------------------------------------------------- | ANALYSIS FILTER DATA |-------------------------------------------------------------------------- | | The teacher can change the analysis using: | | Session | Term | Class | Subject | |-------------------------------------------------------------------------- */ $analysisTerms = DB::table('terms') ->orderBy('id') ->get(); $analysisSessions = DB::table('academic_sessions') ->orderByDesc('name') ->get(); $analysisClasses = collect(); $analysisSubjects = collect(); /* |-------------------------------------------------------------------------- | GET TEACHER'S ASSIGNMENTS |-------------------------------------------------------------------------- | | This is very important. | | We DO NOT simply load all classes and all subjects. | | We first get the combinations assigned to this teacher. | | Example: | | Teacher teaches: | | JSS 1 - Mathematics | JSS 1 - English | JSS 2 - Mathematics | | The teacher should only analyse these combinations. |-------------------------------------------------------------------------- */ $teacherAssignments = collect(); if ($teacherId) { $teacherAssignments = AssignedClassSubjectTeacher::where( 'teacher_id', $teacherId ) ->where('term', $currentTerm) ->where('session', $currentSession) ->with(['class', 'subject']) ->get(); } /* |-------------------------------------------------------------------------- | GET UNIQUE CLASS IDs ASSIGNED TO TEACHER |-------------------------------------------------------------------------- */ $teacherClassIds = $teacherAssignments ->pluck('student_classes_id') ->unique() ->values() ->toArray(); /* |-------------------------------------------------------------------------- | GET UNIQUE SUBJECT IDs ASSIGNED TO TEACHER |-------------------------------------------------------------------------- */ $teacherSubjectIds = $teacherAssignments ->pluck('subject_id') ->unique() ->values() ->toArray(); /* |-------------------------------------------------------------------------- | LOAD ASSIGNED CLASSES |-------------------------------------------------------------------------- */ if (!empty($teacherClassIds)) { $analysisClasses = StudentClasses::whereIn( 'id', $teacherClassIds ) ->orderBy('class_name') ->get(); } /* |-------------------------------------------------------------------------- | LOAD ASSIGNED SUBJECTS |-------------------------------------------------------------------------- */ if (!empty($teacherSubjectIds)) { $analysisSubjects = Subject::whereIn( 'id', $teacherSubjectIds ) ->orderBy('subject_name') ->get(); } /* |-------------------------------------------------------------------------- | FILTER VALUES |-------------------------------------------------------------------------- | | If no filter is supplied, we use the current term/session. |-------------------------------------------------------------------------- */ $selectedTerm = request( 'analysis_term', $currentTerm ); $selectedSession = request( 'analysis_session', $currentSession ); $selectedClass = request( 'analysis_class', 'all' ); $selectedSubject = request( 'analysis_subject', 'all' ); /* |-------------------------------------------------------------------------- | ================================================================ | GET ASSIGNMENTS FOR THE SELECTED TERM AND SESSION | ================================================================ |-------------------------------------------------------------------------- | | We repeat the assignment lookup because the teacher may analyse | an older term/session. |-------------------------------------------------------------------------- */ $selectedTeacherAssignments = collect(); if ($teacherId) { $selectedTeacherAssignments = AssignedClassSubjectTeacher::where( 'teacher_id', $teacherId ) ->where('term', $selectedTerm) ->where('session', $selectedSession) ->get(); } /* |-------------------------------------------------------------------------- | ALLOWED CLASS/SUBJECT COMBINATIONS |-------------------------------------------------------------------------- | | Example: | | 1-2 | 1-5 | 2-2 | | This means: | | class 1 + subject 2 | class 1 + subject 5 | class 2 + subject 2 | |-------------------------------------------------------------------------- */ $allowedTeacherCombinations = []; foreach ($selectedTeacherAssignments as $assignment) { $allowedTeacherCombinations[ $assignment->student_classes_id . '-' . $assignment->subject_id ] = true; } /* |-------------------------------------------------------------------------- | GET STUDENTS ASSIGNED TO TEACHER |-------------------------------------------------------------------------- | | Students are also checked against: | | - class | - subject | - term | - session | |-------------------------------------------------------------------------- */ $teacherStudentAssignments = collect(); if ($teacherId && $selectedTeacherAssignments->count() > 0) { $assignedClassIds = $selectedTeacherAssignments ->pluck('student_classes_id') ->unique() ->values() ->toArray(); $teacherStudentAssignments = AssignClassSubjectStudent::whereIn( 'student_classes_id', $assignedClassIds ) ->where('term', $selectedTerm) ->where('session', $selectedSession) ->get(); } /* |-------------------------------------------------------------------------- | BUILD ALLOWED STUDENT/CLASS/SUBJECT COMBINATIONS |-------------------------------------------------------------------------- | | This gives us very precise control over which result rows the | teacher is allowed to analyse. |-------------------------------------------------------------------------- */ $allowedStudentResultKeys = []; foreach ($teacherStudentAssignments as $studentAssignment) { $combinationKey = $studentAssignment->student_classes_id . '-' . $studentAssignment->subject_id; /* |-------------------------------------------------------------------------- | Only accept the student if the teacher actually teaches that | class + subject combination. |-------------------------------------------------------------------------- */ if (isset($allowedTeacherCombinations[$combinationKey])) { $studentKey = $studentAssignment->student_id . '-' . $studentAssignment->student_classes_id . '-' . $studentAssignment->subject_id; $allowedStudentResultKeys[$studentKey] = true; } } /* |-------------------------------------------------------------------------- | ================================================================ | GET RESULT DATA | ================================================================ |-------------------------------------------------------------------------- | | Results are stored separately for: | | Student | Class | Subject | Term | Session | | We therefore retrieve the selected term/session and then make | sure each result belongs to an actual teacher assignment. |-------------------------------------------------------------------------- */ $analysisResults = collect(); if ($teacherId && count($allowedStudentResultKeys) > 0) { $analysisResults = Result::with([ 'student', 'subject', 'studentClass' ]) ->where('term', $selectedTerm) ->where('session', $selectedSession) ->get() ->filter(function ($result) use ( $allowedStudentResultKeys, $selectedClass, $selectedSubject ) { /* |-------------------------------------------------------------------------- | Student + Class + Subject key |-------------------------------------------------------------------------- */ $key = $result->student_id . '-' . $result->student_classes_id . '-' . $result->subject_id; /* |-------------------------------------------------------------------------- | Teacher must actually be assigned to this combination. |-------------------------------------------------------------------------- */ if (!isset($allowedStudentResultKeys[$key])) { return false; } /* |-------------------------------------------------------------------------- | CLASS FILTER |-------------------------------------------------------------------------- */ if ( $selectedClass !== 'all' && (string) $result->student_classes_id !== (string) $selectedClass ) { return false; } /* |-------------------------------------------------------------------------- | SUBJECT FILTER |-------------------------------------------------------------------------- */ if ( $selectedSubject !== 'all' && (string) $result->subject_id !== (string) $selectedSubject ) { return false; } return true; }) ->values(); } /* |-------------------------------------------------------------------------- | ================================================================ | BASIC RESULT STATISTICS | ================================================================ |-------------------------------------------------------------------------- */ $resultEntryCount = $analysisResults->count(); /* |-------------------------------------------------------------------------- | TOTAL UNIQUE STUDENTS WITH RESULTS |-------------------------------------------------------------------------- */ $studentsWithResults = $analysisResults ->pluck('student_id') ->unique() ->count(); /* |-------------------------------------------------------------------------- | TOTAL UNIQUE SUBJECTS WITH RESULTS |-------------------------------------------------------------------------- */ $subjectsWithResults = $analysisResults ->pluck('subject_id') ->unique() ->count(); /* |-------------------------------------------------------------------------- | PASS MARK |-------------------------------------------------------------------------- | | AGM SmartSchool currently treats 40 as the pass mark. |-------------------------------------------------------------------------- */ $passMark = 40; /* |-------------------------------------------------------------------------- | RAW RESULT AVERAGE |-------------------------------------------------------------------------- | | This calculates the average of all result entries. | | Example: | | Mathematics = 70 | English = 60 | Science = 80 | | Average = (70 + 60 + 80) / 3 |-------------------------------------------------------------------------- */ $rawResultAverage = round( (float) ($analysisResults->avg('total') ?? 0), 1 ); /* |-------------------------------------------------------------------------- | ================================================================ | STUDENT PERFORMANCE | ================================================================ |-------------------------------------------------------------------------- | | We calculate each student's average across the subjects available | in the selected analysis. | | This is more useful than simply averaging every result row when | comparing students. |-------------------------------------------------------------------------- */ $studentPerformance = $analysisResults ->groupBy('student_id') ->map(function ($studentResults) use ($passMark) { $firstResult = $studentResults->first(); $average = (float) ( $studentResults->avg('total') ?? 0 ); $passCount = $studentResults ->filter(function ($result) use ($passMark) { return (float) $result->total >= $passMark; }) ->count(); $failCount = $studentResults ->filter(function ($result) use ($passMark) { return (float) $result->total < $passMark; }) ->count(); return (object) [ 'student_id' => $firstResult->student_id, 'student' => $firstResult->student, 'student_class' => $firstResult->studentClass, 'average' => round($average, 1), 'subjects' => $studentResults ->pluck('subject_id') ->unique() ->count(), 'highest' => round( (float) ($studentResults->max('total') ?? 0), 1 ), 'lowest' => round( (float) ($studentResults->min('total') ?? 0), 1 ), 'pass_count' => $passCount, 'fail_count' => $failCount, 'result_count' => $studentResults->count(), ]; }) ->values(); /* |-------------------------------------------------------------------------- | OVERALL STUDENT PERFORMANCE |-------------------------------------------------------------------------- | | Instead of allowing a student with many result rows to dominate | the overall calculation, we first calculate each student's | average and then average those student averages. |-------------------------------------------------------------------------- */ $overallStudentAverage = round( (float) ($studentPerformance->avg('average') ?? 0), 1 ); /* |-------------------------------------------------------------------------- | PERFORMANCE PERCENTAGE |-------------------------------------------------------------------------- | | Since the final result total is out of 100, | | Average 72 = 72% |-------------------------------------------------------------------------- */ $overallPerformancePercentage = $overallStudentAverage; /* |-------------------------------------------------------------------------- | STUDENT PASS RATE |-------------------------------------------------------------------------- | | A student is counted as passing when the student's overall | average is at least 40%. |-------------------------------------------------------------------------- */ $passingStudents = $studentPerformance ->filter(function ($student) use ($passMark) { return $student->average >= $passMark; }) ->count(); $failedStudents = $studentPerformance ->filter(function ($student) use ($passMark) { return $student->average < $passMark; }) ->count(); $studentPassRate = $studentsWithResults > 0 ? round( ($passingStudents / $studentsWithResults) * 100, 1 ) : 0; /* |-------------------------------------------------------------------------- | ABOVE / BELOW OVERALL AVERAGE |-------------------------------------------------------------------------- */ $aboveAverageStudents = $studentPerformance ->filter(function ($student) use ($overallStudentAverage) { return $student->average > $overallStudentAverage; }) ->values(); $belowAverageStudents = $studentPerformance ->filter(function ($student) use ($overallStudentAverage) { return $student->average < $overallStudentAverage; }) ->values(); $equalAverageStudents = $studentPerformance ->filter(function ($student) use ($overallStudentAverage) { return $student->average == $overallStudentAverage; }) ->values(); /* |-------------------------------------------------------------------------- | TOP STUDENTS |-------------------------------------------------------------------------- */ $topStudents = $studentPerformance ->sortByDesc('average') ->take(10) ->values(); /* |-------------------------------------------------------------------------- | STUDENTS NEEDING ATTENTION |-------------------------------------------------------------------------- */ $bottomStudents = $studentPerformance ->sortBy('average') ->take(10) ->values(); /* |-------------------------------------------------------------------------- | HIGHEST AND LOWEST STUDENT |-------------------------------------------------------------------------- */ $highestStudent = $studentPerformance ->sortByDesc('average') ->first(); $lowestStudent = $studentPerformance ->sortBy('average') ->first(); /* |-------------------------------------------------------------------------- | ================================================================ | CLASS PERFORMANCE | ================================================================ |-------------------------------------------------------------------------- | | Every class gets its own student averages first. | | Then: | | Class Average = | Average of all student averages in that class. |-------------------------------------------------------------------------- */ $classPerformance = $analysisResults ->groupBy('student_classes_id') ->map(function ($classResults, $classId) use ($passMark) { $classStudents = $classResults ->groupBy('student_id') ->map(function ($studentResults) { return (float) ( $studentResults->avg('total') ?? 0 ); }) ->values(); $classAverage = (float) ( $classStudents->avg() ?? 0 ); $classPassingStudents = $classStudents ->filter(function ($average) use ($passMark) { return $average >= $passMark; }) ->count(); $classPassRate = $classStudents->count() > 0 ? ( $classPassingStudents / $classStudents->count() ) * 100 : 0; $first = $classResults->first(); return (object) [ 'class_id' => $classId, 'class_name' => optional($first->studentClass)->class_name ?? 'Unknown Class', 'students' => $classStudents->count(), 'average' => round($classAverage, 1), 'pass_rate' => round($classPassRate, 1), 'highest' => round( (float) ($classStudents->max() ?? 0), 1 ), 'lowest' => round( (float) ($classStudents->min() ?? 0), 1 ), ]; }) ->sortByDesc('average') ->values(); /* |-------------------------------------------------------------------------- | ================================================================ | SUBJECT PERFORMANCE | ================================================================ |-------------------------------------------------------------------------- | | This tells the teacher which subjects are performing strongly | and which subjects may need more attention. |-------------------------------------------------------------------------- */ $subjectPerformance = $analysisResults ->groupBy('subject_id') ->map(function ($subjectResults, $subjectId) use ($passMark) { $subjectAverage = (float) ( $subjectResults->avg('total') ?? 0 ); $passCount = $subjectResults ->filter(function ($result) use ($passMark) { return (float) $result->total >= $passMark; }) ->count(); $passRate = $subjectResults->count() > 0 ? ( $passCount / $subjectResults->count() ) * 100 : 0; $first = $subjectResults->first(); return (object) [ 'subject_id' => $subjectId, 'subject_name' => optional($first->subject)->subject_name ?? 'Unknown Subject', 'students' => $subjectResults ->pluck('student_id') ->unique() ->count(), 'average' => round($subjectAverage, 1), 'pass_rate' => round($passRate, 1), 'highest' => round( (float) ($subjectResults->max('total') ?? 0), 1 ), 'lowest' => round( (float) ($subjectResults->min('total') ?? 0), 1 ), ]; }) ->sortByDesc('average') ->values(); /* |-------------------------------------------------------------------------- | ================================================================ | GRADE DISTRIBUTION | ================================================================ |-------------------------------------------------------------------------- */ $gradeDistribution = $analysisResults ->groupBy(function ($result) { return $result->grade ?: 'Not Graded'; }) ->map(function ($rows) { return $rows->count(); }); /* |-------------------------------------------------------------------------- | ================================================================ | SCORE BAND DISTRIBUTION | ================================================================ |-------------------------------------------------------------------------- | | This groups scores into easy-to-understand performance bands. | | 80 - 100 = Excellent | 70 - 79 = Very Good | 60 - 69 = Good | 50 - 59 = Average | 40 - 49 = Pass | 0 - 39 = Fail |-------------------------------------------------------------------------- */ $scoreBands = [ '80 - 100' => 0, '70 - 79' => 0, '60 - 69' => 0, '50 - 59' => 0, '40 - 49' => 0, '0 - 39' => 0, ]; foreach ($analysisResults as $result) { $score = (float) $result->total; if ($score >= 80) { $scoreBands['80 - 100']++; } elseif ($score >= 70) { $scoreBands['70 - 79']++; } elseif ($score >= 60) { $scoreBands['60 - 69']++; } elseif ($score >= 50) { $scoreBands['50 - 59']++; } elseif ($score >= 40) { $scoreBands['40 - 49']++; } else { $scoreBands['0 - 39']++; } } /* |-------------------------------------------------------------------------- | ================================================================ | RESULT PUBLICATION ANALYSIS |-------------------------------------------------------------------------- | | A result is considered fully published when the old whole-result | publish flag is true. | | This is useful for teachers to know how much of their result | work has already been released by the administrator. |-------------------------------------------------------------------------- */ $publishedResults = $analysisResults ->filter(function ($result) { return (int) $result->publish === 1; }) ->count(); $unpublishedResults = $resultEntryCount - $publishedResults; $publicationPercentage = $resultEntryCount > 0 ? round( ($publishedResults / $resultEntryCount) * 100, 1 ) : 0; /* |-------------------------------------------------------------------------- | ================================================================ | RESULT QUALITY / COVERAGE |-------------------------------------------------------------------------- |-------------------------------------------------------------------------- | | Count the students who are assigned to the selected teacher | combinations. |-------------------------------------------------------------------------- */ $assignedStudentIds = $teacherStudentAssignments ->filter(function ($assignment) use ( $allowedTeacherCombinations, $selectedClass, $selectedSubject ) { $combination = $assignment->student_classes_id . '-' . $assignment->subject_id; if (!isset($allowedTeacherCombinations[$combination])) { return false; } if ( $selectedClass !== 'all' && (string) $assignment->student_classes_id !== (string) $selectedClass ) { return false; } if ( $selectedSubject !== 'all' && (string) $assignment->subject_id !== (string) $selectedSubject ) { return false; } return true; }) ->pluck('student_id') ->unique() ->count(); $assessmentCoverage = $assignedStudentIds > 0 ? round( ($studentsWithResults / $assignedStudentIds) * 100, 1 ) : 0; /* |-------------------------------------------------------------------------- | ================================================================ | TEACHER ASSIGNMENT COUNTS |-------------------------------------------------------------------------- */ $assignedClassCount = $selectedTeacherAssignments ->pluck('student_classes_id') ->unique() ->count(); $assignedSubjectCount = $selectedTeacherAssignments ->pluck('subject_id') ->unique() ->count(); $assignedStudentCount = $assignedStudentIds; /* |-------------------------------------------------------------------------- | ================================================================ | CBT ANALYSIS | ================================================================ |-------------------------------------------------------------------------- | | We preserve the existing CBT dashboard functionality. |-------------------------------------------------------------------------- */ $teacherTestIds = []; if ($teacherId) { $teacherTestIds = CbtTest::where( 'teacher_id', $teacherId ) ->where('term', $selectedTerm) ->where('session', $selectedSession) ->pluck('id') ->toArray(); } /* |-------------------------------------------------------------------------- | CBT TOTAL TESTS |-------------------------------------------------------------------------- */ $teacherCbtTestCount = count($teacherTestIds); /* |-------------------------------------------------------------------------- | CBT COMPLETED ATTEMPTS |-------------------------------------------------------------------------- */ $teacherCbtAttempts = CbtAttempt::whereIn( 'cbt_test_id', $teacherTestIds ) ->where('status', 'completed') ->get(); $teacherCbtAttemptCount = $teacherCbtAttempts->count(); /* |-------------------------------------------------------------------------- | CBT AVERAGE SCORE |-------------------------------------------------------------------------- */ $teacherCbtAverage = round( (float) ( $teacherCbtAttempts->avg('score') ?? 0 ), 1 ); /* |-------------------------------------------------------------------------- | CBT PASS RATE |-------------------------------------------------------------------------- */ $teacherCbtPassCount = $teacherCbtAttempts ->filter(function ($attempt) { return (float) $attempt->score >= 40; }) ->count(); $teacherCbtPassRate = $teacherCbtAttemptCount > 0 ? round( ($teacherCbtPassCount / $teacherCbtAttemptCount) * 100, 1 ) : 0; /* |-------------------------------------------------------------------------- | CBT PERFORMANCE BY SUBJECT + CLASS |-------------------------------------------------------------------------- */ $performanceData = CbtAttempt::whereIn( 'cbt_test_id', $teacherTestIds ) ->where('status', 'completed') ->join( 'cbt_tests', 'cbt_attempts.cbt_test_id', '=', 'cbt_tests.id' ) ->select( 'cbt_tests.subject_id', 'cbt_tests.student_classes_id', DB::raw( 'SUM(CASE WHEN cbt_attempts.score >= 40 THEN 1 ELSE 0 END) as pass_count' ), DB::raw( 'SUM(CASE WHEN cbt_attempts.score < 40 THEN 1 ELSE 0 END) as fail_count' ), DB::raw( 'AVG(cbt_attempts.score) as average_score' ) ) ->groupBy( 'cbt_tests.subject_id', 'cbt_tests.student_classes_id' ) ->get(); $performanceLabels = []; $passCounts = []; $failCounts = []; $cbtAverageCounts = []; foreach ($performanceData as $row) { $subject = Subject::find( $row->subject_id ); $className = DB::table('student_classes') ->where('id', $row->student_classes_id) ->value('class_name'); $label = ($subject ? $subject->subject_name : 'Unknown Subject') . ' - ' . ($className ?? 'Unknown Class'); $performanceLabels[] = $label; $passCounts[] = (int) $row->pass_count; $failCounts[] = (int) $row->fail_count; $cbtAverageCounts[] = round((float) $row->average_score, 1); } /* |-------------------------------------------------------------------------- | CBT MOST ATTEMPTED TESTS |-------------------------------------------------------------------------- */ $mostAttempted = CbtAttempt::whereIn( 'cbt_test_id', $teacherTestIds ) ->where('status', 'completed') ->select( 'cbt_test_id', DB::raw('count(*) as total') ) ->groupBy('cbt_test_id') ->orderByDesc('total') ->get(); $topTestNames = []; $topTestCounts = []; foreach ($mostAttempted as $item) { $test = CbtTest::find( $item->cbt_test_id ); if ($test) { $subject = Subject::find( $test->subject_id ); $class = DB::table('student_classes') ->where( 'id', $test->student_classes_id ) ->value('class_name'); $topTestNames[] = ( $subject && $class ) ? $subject->subject_name . ' - ' . $class : $test->title; $topTestCounts[] = (int) $item->total; } } /* |-------------------------------------------------------------------------- | ================================================================ | STUDENT NAME HELPER | ================================================================ */ $getStudentName = function ($performance) { if (!$performance || !$performance->student) { return 'Unknown Student'; } return $performance->student->name ?? optional($performance->student->user)->user_name ?? 'Unknown Student'; }; /* |-------------------------------------------------------------------------- | PREPARE TOP STUDENT CHART DATA |-------------------------------------------------------------------------- */ $topStudentLabels = $topStudents ->map(function ($student) use ($getStudentName) { return $getStudentName($student); }) ->values(); $topStudentAverages = $topStudents ->pluck('average') ->values(); /* |-------------------------------------------------------------------------- | PREPARE BOTTOM STUDENT CHART DATA |-------------------------------------------------------------------------- */ $bottomStudentLabels = $bottomStudents ->map(function ($student) use ($getStudentName) { return $getStudentName($student); }) ->values(); $bottomStudentAverages = $bottomStudents ->pluck('average') ->values(); /* |-------------------------------------------------------------------------- | CLASS CHART DATA |-------------------------------------------------------------------------- */ $classChartLabels = $classPerformance ->pluck('class_name') ->values(); $classChartAverages = $classPerformance ->pluck('average') ->values(); $classChartPassRates = $classPerformance ->pluck('pass_rate') ->values(); /* |-------------------------------------------------------------------------- | SUBJECT CHART DATA |-------------------------------------------------------------------------- */ $subjectChartLabels = $subjectPerformance ->take(15) ->pluck('subject_name') ->values(); $subjectChartAverages = $subjectPerformance ->take(15) ->pluck('average') ->values(); /* |-------------------------------------------------------------------------- | BASIC COUNTS FOR DASHBOARD |-------------------------------------------------------------------------- */ $totalStudents = Student::count(); $totalTeachers = Teacher::count(); $totalClasses = StudentClasses::count(); $totalSubjects = Subject::count(); @endphp
Result performance and academic analytics
Classes Assigned
Subjects Assigned
Assigned Students
Result Entries
| # | Student | Class | Subjects | Average | Highest | Lowest | Status |
|---|---|---|---|---|---|---|---|
| {{ $loop->iteration }} | {{ $getStudentName($student) }} | {{ optional($student->student_class)->class_name ?? 'N/A' }} | {{ $student->subjects }} | {{ number_format( $student->average, 1 ) }}% | {{ number_format( $student->highest, 1 ) }} | {{ number_format( $student->lowest, 1 ) }} | @if( $student->average > $overallStudentAverage ) Above Average @elseif( $student->average < $overallStudentAverage ) Below Average @else Average @endif |
|
No result data is available for the selected analysis. |
|||||||
| Class | Students | Average | Pass Rate | Highest | Lowest |
|---|---|---|---|---|---|
| {{ $class->class_name }} | {{ $class->students }} | {{ number_format( $class->average, 1 ) }}% |
|
{{ $class->highest }}% | {{ $class->lowest }}% |
| No class result available. | |||||
| Subject | Avg. | Pass |
|---|---|---|
| {{ $subject->subject_name }} | {{ $subject->average }}% | {{ $subject->pass_rate }}% |
| No subject result available. | ||