fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -2135,6 +2135,31 @@ class AdministratorController extends BaseController
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
$enrollmentStatusByStudentId = [];
|
||||
$studentIds = array_values(array_unique(array_filter(array_map(
|
||||
static fn (array $row): int => (int) ($row['id'] ?? 0),
|
||||
$students
|
||||
))));
|
||||
if ($selectedYear !== '' && !empty($studentIds)) {
|
||||
$enrollmentRows = $db->table('enrollments')
|
||||
->select('student_id, enrollment_status')
|
||||
->whereIn('student_id', $studentIds)
|
||||
->where('school_year', $selectedYear)
|
||||
->orderBy('student_id', 'ASC')
|
||||
->orderBy('updated_at', 'DESC')
|
||||
->orderBy('enrollment_date', 'DESC')
|
||||
->orderBy('id', 'DESC')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
foreach ($enrollmentRows as $enrollmentRow) {
|
||||
$studentId = (int) ($enrollmentRow['student_id'] ?? 0);
|
||||
if ($studentId > 0 && !isset($enrollmentStatusByStudentId[$studentId])) {
|
||||
$enrollmentStatusByStudentId[$studentId] = (string) ($enrollmentRow['enrollment_status'] ?? '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// === Inject current-year class_section_name from student_class and replace grade ===
|
||||
foreach ($students as $i => $row) {
|
||||
$sid = (int) ($row['id'] ?? 0);
|
||||
@@ -2142,9 +2167,11 @@ class AdministratorController extends BaseController
|
||||
$classSectionName = (string) ($this->studentClassModel->getClassSectionNameByStudentId($sid, $selectedYear) ?? '');
|
||||
|
||||
$students[$i]['class_section_name'] = $classSectionName;
|
||||
$students[$i]['enrollment_status'] = $enrollmentStatusByStudentId[$sid] ?? '';
|
||||
} else {
|
||||
// Keep keys consistent even if id missing
|
||||
$students[$i]['class_section_name'] = '';
|
||||
$students[$i]['enrollment_status'] = '';
|
||||
}
|
||||
|
||||
$studentYear = trim((string) ($row['school_year'] ?? ''));
|
||||
|
||||
@@ -267,9 +267,9 @@ public function showUpdateAttendanceForm()
|
||||
$currentSunday = $sundayDates[2];
|
||||
|
||||
// Students roster for this section/year/semester (try section code, then PK fallback)
|
||||
$students = $this->studentModel->getByClassAndYear($class_section_id, $schoolYear, $semester);
|
||||
$students = $this->studentModel->getActiveByClassAndYear($class_section_id, $schoolYear, $semester);
|
||||
if (empty($students) && $classSectionPk > 0 && $classSectionPk !== $class_section_id) {
|
||||
$students = $this->studentModel->getByClassAndYear($classSectionPk, $schoolYear, $semester);
|
||||
$students = $this->studentModel->getActiveByClassAndYear($classSectionPk, $schoolYear, $semester);
|
||||
}
|
||||
|
||||
// Build student attendance rows
|
||||
@@ -598,11 +598,12 @@ public function showUpdateAttendanceForm()
|
||||
$seenStudentIds[$studentId] = true;
|
||||
|
||||
$student = $this->studentModel
|
||||
->select('id, firstname, lastname, school_id')
|
||||
->select('id, firstname, lastname, school_id, is_active')
|
||||
->where('id', $studentId)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
if (!$student) continue;
|
||||
$student['enrollment_status'] = $sc['enrollment_status'] ?? '';
|
||||
$student['is_withdrawn'] = (int)($sc['is_withdrawn'] ?? 0);
|
||||
|
||||
$studentsBySection[$secCode][] = $student;
|
||||
$hasRoster = true;
|
||||
@@ -1027,9 +1028,11 @@ public function showUpdateAttendanceForm()
|
||||
continue;
|
||||
}
|
||||
$student = $this->studentModel
|
||||
->select('id, firstname, lastname, school_id')
|
||||
->select('id, firstname, lastname, school_id, is_active')
|
||||
->find($studentId);
|
||||
if (!$student) continue;
|
||||
$student['enrollment_status'] = $sc['enrollment_status'] ?? '';
|
||||
$student['is_withdrawn'] = (int)($sc['is_withdrawn'] ?? 0);
|
||||
|
||||
$studentsBySection[$secCode][] = $student;
|
||||
$hasRoster = true;
|
||||
@@ -1603,7 +1606,7 @@ public function showUpdateAttendanceForm()
|
||||
|
||||
// optional score updates (never bubble)
|
||||
try {
|
||||
$studentUserInfo = $this->studentModel->getStudentInfoByClassSectionId(
|
||||
$studentUserInfo = $this->studentModel->getActiveStudentInfoByClassSectionId(
|
||||
$classSectionId,
|
||||
$semester,
|
||||
$schoolYear
|
||||
@@ -1722,6 +1725,19 @@ public function showUpdateAttendanceForm()
|
||||
$semester = (string)($this->semester ?? '');
|
||||
$schoolYear = (string)($this->schoolYear ?? '');
|
||||
|
||||
$activeStudents = $this->studentModel->getActiveByClassAndYear($classSectionId, $schoolYear, $semester);
|
||||
$activeStudentIds = array_fill_keys(array_map(static fn(array $row): int => (int)($row['id'] ?? 0), $activeStudents), true);
|
||||
$attendanceData = array_values(array_filter($attendanceData, static function ($row) use ($activeStudentIds): bool {
|
||||
$sid = (int)($row['student_id'] ?? 0);
|
||||
return $sid > 0 && isset($activeStudentIds[$sid]);
|
||||
}));
|
||||
|
||||
if (empty($attendanceData)) {
|
||||
return redirect()->to('/teacher/showupdate_attendance?class_section_id=' . $classSectionId)
|
||||
->with('status', 'error')
|
||||
->with('message', 'No active student attendance data provided.');
|
||||
}
|
||||
|
||||
// Existing attendance rows for today (used to lock parent/admin submissions)
|
||||
$existingRows = $this->attendanceDataModel
|
||||
->where('class_section_id', $classSectionId)
|
||||
@@ -2027,7 +2043,7 @@ public function showUpdateAttendanceForm()
|
||||
}
|
||||
|
||||
try {
|
||||
$studentUserInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $this->semester, $this->schoolYear);
|
||||
$studentUserInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $this->semester, $this->schoolYear);
|
||||
$this->semesterScoreService->updateScoresForStudents($studentUserInfo);
|
||||
} catch (\Throwable $e) {
|
||||
// ignore
|
||||
|
||||
@@ -386,12 +386,14 @@ class CompetitionScoresController extends BaseController
|
||||
return 0;
|
||||
}
|
||||
|
||||
$builder = $this->db->table($this->classStudentTable)
|
||||
$builder = $this->db->table($this->classStudentTable . ' cs')
|
||||
->select('COUNT(*) AS total')
|
||||
->where('class_section_id', $classSectionId);
|
||||
->join('students s', 's.id = cs.student_id', 'inner')
|
||||
->where('cs.class_section_id', $classSectionId)
|
||||
->where('s.is_active', 1);
|
||||
|
||||
if ($schoolYear && $this->db->fieldExists('school_year', $this->classStudentTable)) {
|
||||
$builder->where('school_year', $schoolYear);
|
||||
$builder->where('cs.school_year', $schoolYear);
|
||||
}
|
||||
|
||||
$row = $builder->get()->getRowArray();
|
||||
@@ -407,7 +409,8 @@ class CompetitionScoresController extends BaseController
|
||||
$builder = $this->db->table('students s')
|
||||
->select('s.id, s.school_id, s.firstname, s.lastname')
|
||||
->join($this->classStudentTable . ' cs', 'cs.student_id = s.id', 'inner')
|
||||
->where('cs.class_section_id', $classSectionId);
|
||||
->where('cs.class_section_id', $classSectionId)
|
||||
->where('s.is_active', 1);
|
||||
|
||||
$hasSchoolYear = $this->db->fieldExists('school_year', $this->classStudentTable);
|
||||
if ($hasSchoolYear && !empty($competition['school_year'])) {
|
||||
|
||||
@@ -131,6 +131,7 @@ class FinalController extends BaseController
|
||||
)
|
||||
->join('(' . $latestFinalSub . ') fl', 'fl.student_id = s.id', 'left', false)
|
||||
->join('final_exam fe', 'fe.id = fl.max_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->orderBy('s.lastname', 'ASC')
|
||||
->orderBy('s.firstname', 'ASC');
|
||||
|
||||
|
||||
@@ -521,6 +521,9 @@ class GradingController extends BaseController
|
||||
'school_id' => $r['school_id'] ?? null,
|
||||
'firstname' => $r['firstname'] ?? null,
|
||||
'lastname' => $r['lastname'] ?? null,
|
||||
'is_active' => (int)($r['is_active'] ?? 1),
|
||||
'enrollment_status' => $r['enrollment_status'] ?? '',
|
||||
'is_withdrawn' => (int)($r['is_withdrawn'] ?? 0),
|
||||
'class_id' => $classId,
|
||||
'ptap' => is_null($ptapScore) ? null : round((float) $ptapScore, 2),
|
||||
'semester_score' => is_null($semesterScore) ? null : round((float) $semesterScore, 2),
|
||||
@@ -997,11 +1000,16 @@ class GradingController extends BaseController
|
||||
private function fetchActiveStudentsWithSection(string $schoolYear): array
|
||||
{
|
||||
return $this->db->table('students s')
|
||||
->select('s.id AS student_id, s.school_id, s.firstname, s.lastname, sc.class_section_id, cs.class_section_name, c.class_name')
|
||||
->select('s.id AS student_id, s.school_id, s.firstname, s.lastname, s.is_active, sc.class_section_id, cs.class_section_name, c.class_name, e.enrollment_status, e.is_withdrawn')
|
||||
->join('student_class sc', 'sc.student_id = s.id AND sc.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('`classSection` cs', 'cs.class_section_id = sc.class_section_id', 'left')
|
||||
->join('classes c', 'c.id = cs.class_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->orderBy('s.lastname', 'ASC')
|
||||
->orderBy('s.firstname', 'ASC')
|
||||
->get()
|
||||
@@ -1032,13 +1040,18 @@ class GradingController extends BaseController
|
||||
}
|
||||
|
||||
$rows = $this->db->table('placement_scores ps')
|
||||
->select('ps.batch_id, ps.score, s.school_id, s.firstname, s.lastname, cs.class_section_name, c.class_name')
|
||||
->select('ps.batch_id, ps.student_id, ps.score, s.school_id, s.firstname, s.lastname, s.is_active, e.enrollment_status, e.is_withdrawn, cs.class_section_name, c.class_name')
|
||||
->join('students s', 's.id = ps.student_id', 'inner')
|
||||
->join('student_class sc', 'sc.student_id = s.id AND sc.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('`classSection` cs', 'cs.class_section_id = sc.class_section_id', 'left')
|
||||
->join('classes c', 'c.id = cs.class_id', 'left')
|
||||
->whereIn('ps.batch_id', $batchIds)
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->orderBy('ps.batch_id', 'ASC')
|
||||
->orderBy('s.lastname', 'ASC')
|
||||
->orderBy('s.firstname', 'ASC')
|
||||
@@ -1621,6 +1634,9 @@ public function belowSixty()
|
||||
's.school_id',
|
||||
's.firstname',
|
||||
's.lastname',
|
||||
's.is_active',
|
||||
'e.enrollment_status',
|
||||
'e.is_withdrawn',
|
||||
'pl.level AS placement_level',
|
||||
|
||||
// Prefer business-id match; fall back to pk match
|
||||
@@ -1640,6 +1656,11 @@ public function belowSixty()
|
||||
->distinct()
|
||||
->join('`classSection` cs', 'cs.class_section_id = sc.class_section_id', 'left')
|
||||
->join('students s', 's.id = sc.student_id', 'inner')
|
||||
->join(
|
||||
'enrollments e',
|
||||
"e.student_id = s.id AND e.school_year = {$yrEsc}",
|
||||
'left'
|
||||
)
|
||||
->join(
|
||||
'placement_levels pl',
|
||||
'pl.student_id = s.id',
|
||||
@@ -1665,7 +1686,11 @@ public function belowSixty()
|
||||
'left'
|
||||
)
|
||||
->where('sc.school_year', $schoolYear)
|
||||
->where('s.is_active', 1); // Exclude removed/inactive students
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd();
|
||||
|
||||
return $builder
|
||||
->orderBy('cs.class_id', 'ASC')
|
||||
@@ -1800,6 +1825,7 @@ public function belowSixty()
|
||||
->select('s.school_id')
|
||||
->select('s.firstname')
|
||||
->select('s.lastname')
|
||||
->select('MAX(s.is_active) AS is_active', false)
|
||||
->select('cs.class_section_name')
|
||||
->select("'year' AS semester", false)
|
||||
->select("MAX(CASE WHEN LOWER(TRIM(ss.semester)) = 'fall' THEN ss.homework_avg END) AS fall_homework_avg", false)
|
||||
@@ -1856,9 +1882,15 @@ public function belowSixty()
|
||||
MAX(CASE WHEN LOWER(TRIM(ss.semester)) = 'fall' THEN ss.final_exam_score END)
|
||||
+ MAX(CASE WHEN LOWER(TRIM(ss.semester)) = 'spring' THEN ss.final_exam_score END)
|
||||
) / 2 AS final_exam_score", false)
|
||||
->select('MAX(e.enrollment_status) AS enrollment_status, MAX(e.is_withdrawn) AS is_withdrawn', false)
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
->where("LOWER(TRIM(ss.semester)) IN ('fall', 'spring')", null, false)
|
||||
@@ -1888,6 +1920,7 @@ public function belowSixty()
|
||||
's.school_id',
|
||||
's.firstname',
|
||||
's.lastname',
|
||||
's.is_active',
|
||||
'cs.class_section_name',
|
||||
'ss.semester',
|
||||
'ss.homework_avg',
|
||||
@@ -1899,10 +1932,17 @@ public function belowSixty()
|
||||
'ss.midterm_exam_score',
|
||||
'ss.final_exam_score',
|
||||
'ss.semester_score',
|
||||
'e.enrollment_status',
|
||||
'e.is_withdrawn',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
->where('ss.semester_score <', 60)
|
||||
@@ -2014,10 +2054,15 @@ public function belowSixty()
|
||||
'ss.semester_score',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->where('ss.student_id', $studentId)
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where("LOWER(TRIM(ss.semester))", $semesterKey)
|
||||
->get()
|
||||
->getRowArray();
|
||||
@@ -2354,13 +2399,21 @@ public function belowSixty()
|
||||
's.lastname',
|
||||
's.age',
|
||||
's.school_id',
|
||||
's.is_active',
|
||||
'cs.class_section_name',
|
||||
'e.enrollment_status',
|
||||
'e.is_withdrawn',
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester_score',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
@@ -3404,16 +3457,24 @@ public function allDecisions()
|
||||
's.lastname',
|
||||
's.gender',
|
||||
's.dob',
|
||||
's.is_active',
|
||||
'ss.class_section_id',
|
||||
'cs.class_section_name',
|
||||
'c.class_name',
|
||||
'e.enrollment_status',
|
||||
'e.is_withdrawn',
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester_score',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->join('classes c', 'c.id = cs.class_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
@@ -3440,6 +3501,9 @@ public function allDecisions()
|
||||
'lastname' => $sr['lastname'] ?? '',
|
||||
'gender' => $sr['gender'] ?? '',
|
||||
'dob' => $sr['dob'] ?? '',
|
||||
'is_active' => (int)($sr['is_active'] ?? 1),
|
||||
'enrollment_status' => $sr['enrollment_status'] ?? '',
|
||||
'is_withdrawn' => (int)($sr['is_withdrawn'] ?? 0),
|
||||
'class_section_id' => (int)($sr['class_section_id'] ?? 0),
|
||||
'class_name' => $sr['class_name'] ?? '',
|
||||
'class_section_name' => $sr['class_section_name'] ?? '',
|
||||
@@ -3538,6 +3602,9 @@ public function allDecisions()
|
||||
'lastname' => $info['lastname'],
|
||||
'gender' => $info['gender'] ?? '',
|
||||
'dob' => $info['dob'] ?? '',
|
||||
'is_active' => (int)($info['is_active'] ?? 1),
|
||||
'enrollment_status' => $info['enrollment_status'] ?? '',
|
||||
'is_withdrawn' => (int)($info['is_withdrawn'] ?? 0),
|
||||
'class_section_id' => (int)($info['class_section_id'] ?? 0),
|
||||
'class_name' => $currentClassName,
|
||||
'class_section_name' => $currentClassSectionName,
|
||||
@@ -3615,13 +3682,19 @@ public function generateAllDecisions()
|
||||
's.id AS student_id',
|
||||
's.firstname',
|
||||
's.lastname',
|
||||
's.is_active',
|
||||
'cs.class_section_name',
|
||||
'LOWER(TRIM(ss.semester)) AS sem_key',
|
||||
'ss.semester_score',
|
||||
])
|
||||
->join('students s', 's.id = ss.student_id', 'inner')
|
||||
->join('enrollments e', 'e.student_id = s.id AND e.school_year = ' . $this->db->escape($schoolYear), 'left')
|
||||
->join('classSection cs', 'cs.class_section_id = ss.class_section_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->groupStart()
|
||||
->where('s.is_active', 1)
|
||||
->orWhere("LOWER(TRIM(e.enrollment_status)) IN ('denied','withdrawn','widthran','widthrawan','withdrawan','waitlist')", null, false)
|
||||
->orWhere('e.is_withdrawn', 1)
|
||||
->groupEnd()
|
||||
->where('ss.school_year', $schoolYear)
|
||||
->whereIn('LOWER(TRIM(ss.semester))', ['fall', 'spring'])
|
||||
->where('ss.semester_score IS NOT NULL', null, false)
|
||||
|
||||
@@ -176,7 +176,7 @@ class HomeworkController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
$studentUserInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentUserInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
@@ -404,7 +404,7 @@ class HomeworkController extends BaseController
|
||||
return $this->showHomeworkMngt($updatedBy);
|
||||
}
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class MidtermController extends BaseController
|
||||
true
|
||||
);
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
@@ -155,7 +155,7 @@ class MidtermController extends BaseController
|
||||
|
||||
session()->setFlashdata('status', 'Midterm exam scores updated successfully.');
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
@@ -288,6 +288,7 @@ class MidtermController extends BaseController
|
||||
// Join the "latest midterm per student" subquery, then the actual midterm row
|
||||
->join('(' . $latestMidtermSub . ') ml', 'ml.student_id = s.id', 'left', false)
|
||||
->join('midterm_exam me', 'me.id = ml.max_id', 'left')
|
||||
->where('s.is_active', 1)
|
||||
->orderBy('s.lastname', 'ASC')
|
||||
->orderBy('s.firstname', 'ASC');
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class ParticipationController extends BaseController
|
||||
true
|
||||
);
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
@@ -156,7 +156,7 @@ class ParticipationController extends BaseController
|
||||
|
||||
session()->setFlashdata('status', 'Participation scores updated successfully.');
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class ProjectController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$studentTeacherInfo = $studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
@@ -361,7 +361,7 @@ class ProjectController extends BaseController
|
||||
return $this->showProjectMngt($updatedBy);
|
||||
}
|
||||
|
||||
$studentTeacherInfo = $studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class QuizController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
@@ -444,7 +444,7 @@ class QuizController extends BaseController
|
||||
return $this->showQuizMngt();
|
||||
}
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId($classSectionId, $semester, $schoolYear);
|
||||
// Call the updateScoresForStudents method
|
||||
try {
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ class ScoreController extends BaseController
|
||||
$classSectionName = $csRow['class_section_name'] ?? '';
|
||||
log_message('debug', "ScoreController::index teacher {$teacherId} classSection {$classSectionId} semester {$effectiveSemester}");
|
||||
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId(
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId(
|
||||
$classSectionId,
|
||||
$effectiveSemester,
|
||||
$effectiveSchoolYear
|
||||
@@ -1179,7 +1179,7 @@ class ScoreController extends BaseController
|
||||
// Ensure semester_scores are re-calculated when midterm/final exams change.
|
||||
if (in_array(strtolower($table), ['final_exam', 'midterm_exam'], true) && $this->semesterScoreService !== null) {
|
||||
try {
|
||||
$studentTeacherInfo = $this->studentModel->getStudentInfoByClassSectionId(
|
||||
$studentTeacherInfo = $this->studentModel->getActiveStudentInfoByClassSectionId(
|
||||
$classSectionId,
|
||||
$semester,
|
||||
$this->schoolYear
|
||||
|
||||
@@ -2783,13 +2783,23 @@ class StudentController extends BaseController
|
||||
return redirect()->back()->with('error', 'Invalid student id.');
|
||||
}
|
||||
|
||||
$roleRaw = session()->get('role');
|
||||
if (is_array($roleRaw)) {
|
||||
$roleRaw = $roleRaw[0] ?? 'guest';
|
||||
}
|
||||
$role = strtolower((string)($roleRaw ?? 'guest'));
|
||||
$isAdminScoreCardAccess = in_array($role, ['administrator', 'admin', 'principal', 'administrative staff'], true);
|
||||
|
||||
$student = $this->studentModel
|
||||
->select('id, firstname, lastname, school_id')
|
||||
->select('id, firstname, lastname, school_id, is_active')
|
||||
->where('id', $studentId)
|
||||
->first();
|
||||
if (!$student) {
|
||||
return $this->response->setStatusCode(404)->setBody('<div class="p-3 text-danger">Student not found.</div>');
|
||||
}
|
||||
if (!$isAdminScoreCardAccess && (int)($student['is_active'] ?? 0) !== 1) {
|
||||
return redirect()->to('/student/score-card/list')->with('error', 'Student score card is not available.');
|
||||
}
|
||||
|
||||
$rows = $this->db->table('semester_scores ss')
|
||||
->select([
|
||||
@@ -3011,14 +3021,14 @@ class StudentController extends BaseController
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$parentId = (int)(session()->get('user_id') ?? 0);
|
||||
if ($parentId > 0 && $schoolYear !== '') {
|
||||
$students = $this->studentModel->getByParentAndYear($parentId, $schoolYear);
|
||||
$students = $this->studentModel->getActiveByParentAndYear($parentId, $schoolYear);
|
||||
}
|
||||
} elseif (in_array($role, ['teacher', 'teacher_assistant', 'teacher_dashboard'], true)) {
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$classSectionId = (int)(session()->get('class_section_id') ?? 0);
|
||||
|
||||
if ($classSectionId > 0 && !empty($schoolYear)) {
|
||||
$students = $this->studentModel->getByClassAndYear($classSectionId, $schoolYear);
|
||||
$students = $this->studentModel->getActiveByClassAndYear($classSectionId, $schoolYear);
|
||||
}
|
||||
|
||||
if (empty($students)) {
|
||||
@@ -3039,10 +3049,10 @@ class StudentController extends BaseController
|
||||
$studentClassModel = new \App\Models\StudentClassModel();
|
||||
$rows = $studentClassModel->getStudentsByClassSectionIds($sectionIds, $schoolYear);
|
||||
$unique = [];
|
||||
foreach ($rows as $r) {
|
||||
$sid = (int)($r['student_id'] ?? 0);
|
||||
if ($sid > 0) {
|
||||
$unique[$sid] = [
|
||||
foreach ($rows as $r) {
|
||||
$sid = (int)($r['student_id'] ?? 0);
|
||||
if ($sid > 0 && (int)($r['is_active'] ?? 0) === 1) {
|
||||
$unique[$sid] = [
|
||||
'id' => $sid,
|
||||
'school_id' => $r['school_id'] ?? '',
|
||||
'firstname' => $r['firstname'] ?? '',
|
||||
|
||||
@@ -125,6 +125,9 @@ class TeacherController extends BaseController
|
||||
if (!empty($classSectionIds)) {
|
||||
// 1) Fetch all students for the selected class sections
|
||||
$students = $this->studentClassModel->getStudentsByClassSectionIds($classSectionIds, (string) $this->schoolYear);
|
||||
$students = array_values(array_filter($students, static function (array $student): bool {
|
||||
return (int)($student['is_active'] ?? 0) === 1;
|
||||
}));
|
||||
|
||||
if (!empty($students)) {
|
||||
// 2) Collect unique student IDs
|
||||
|
||||
Reference in New Issue
Block a user