fix is_active student flag and apply it in all pages
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user