add assessment feature
This commit is contained in:
@@ -619,9 +619,12 @@ class AdministratorController extends BaseController
|
||||
{
|
||||
$selectedYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
|
||||
$data = service('administratorDirectory')->studentProfiles($selectedYear);
|
||||
$data['assessmentByStudent'] = $this->assessmentActionsForStudents(array_column($data['students'] ?? [], 'id'), $selectedYear);
|
||||
|
||||
return view(
|
||||
'administrator/student_profiles',
|
||||
service('administratorDirectory')->studentProfiles($selectedYear)
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
@@ -676,10 +679,9 @@ class AdministratorController extends BaseController
|
||||
|
||||
public function showNewStudents()
|
||||
{
|
||||
return view(
|
||||
'enroll_withdraw/new-students',
|
||||
service('enrollmentWithdrawal')->newStudents((string) $this->schoolYear)
|
||||
);
|
||||
$data = service('enrollmentWithdrawal')->newStudents((string) $this->schoolYear);
|
||||
$data['assessmentByStudent'] = $this->assessmentActionsForStudents(array_column($data['new_students'] ?? [], 'id'), (string) $this->schoolYear);
|
||||
return view('enroll_withdraw/new-students', $data);
|
||||
}
|
||||
|
||||
public function adminEnrollmentWithdrawalHandler()
|
||||
@@ -694,4 +696,31 @@ class AdministratorController extends BaseController
|
||||
return redirect()->to(base_url('enroll_withdraw/enrollment_withdrawal'))
|
||||
->with(!empty($result['ok']) ? 'success' : 'error', (string) ($result['message'] ?? ''));
|
||||
}
|
||||
|
||||
private function assessmentActionsForStudents(array $studentIds, string $schoolYear): array
|
||||
{
|
||||
$studentIds = array_values(array_unique(array_filter(array_map('intval', $studentIds))));
|
||||
$db = db_connect();
|
||||
if ($studentIds === [] || ! $db->tableExists('student_assessments')) return [];
|
||||
|
||||
$rows = $db->table('student_assessments sa')
|
||||
->select('sa.id, sa.student_id, sa.form_id, sa.status, sa.assigned_at, f.name AS form_name')
|
||||
->join('assessment_forms f', 'f.id = sa.form_id')
|
||||
->whereIn('sa.student_id', $studentIds)
|
||||
->where('f.school_year', $schoolYear)
|
||||
->orderBy('sa.assigned_at', 'DESC')->orderBy('sa.id', 'DESC')->get()->getResultArray();
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$studentId = (int) $row['student_id'];
|
||||
$priority = match ((string) $row['status']) {
|
||||
'completed' => 3, 'not_started', 'in_progress' => 2, 'graded' => 1, default => 0,
|
||||
};
|
||||
$current = $map[$studentId]['status'] ?? null;
|
||||
$currentPriority = match ($current) {
|
||||
'completed' => 3, 'not_started', 'in_progress' => 2, 'graded' => 1, default => -1,
|
||||
};
|
||||
if ($priority > $currentPriority) $map[$studentId] = $row;
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user