feat(exam): S4-11 marking flow and class results
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
ArrowBack, PersonAdd, PersonRemove, CheckCircle, Cancel, School,
|
||||
} from '@mui/icons-material';
|
||||
import { useAuth } from '../../contexts/AuthContext';
|
||||
import { ResultsWidget } from '../exam';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || import.meta.env.VITE_API_URL || '/api';
|
||||
|
||||
@@ -131,10 +132,20 @@ const ClassDetailPage: React.FC = () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const clsRes = await fetch(`${API_BASE}/classes/${classId}`, {
|
||||
const clsRes = await fetch(`${API_BASE}/database/timetable/classes/${classId}`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
}).then(r => r.json());
|
||||
if (clsRes.id) setCls(clsRes);
|
||||
if (clsRes.id) {
|
||||
setCls({
|
||||
...clsRes,
|
||||
class_code: clsRes.class_code || clsRes.code,
|
||||
year_group: clsRes.year_group || clsRes.school_year,
|
||||
teachers: clsRes.teachers || [],
|
||||
students: clsRes.students || [],
|
||||
enrollment_requests: clsRes.enrollment_requests || [],
|
||||
student_count: clsRes.student_count ?? clsRes.students?.length ?? 0,
|
||||
});
|
||||
}
|
||||
else setError(clsRes.detail || 'Class not found');
|
||||
const role = bootstrapData?.active_institute?.membership_role || '';
|
||||
setIsAdmin(role === 'school_admin' || role === 'department_head');
|
||||
@@ -174,20 +185,20 @@ const ClassDetailPage: React.FC = () => {
|
||||
|
||||
const handleAddStudent = async (studentId: string) => {
|
||||
setActionError(null);
|
||||
const res = await apiPost(`/classes/${classId}/students`, { student_id: studentId });
|
||||
const res = await apiPost(`/database/timetable/classes/${classId}/students`, { student_id: studentId });
|
||||
if (res.status === 'ok') load();
|
||||
else setActionError(res.detail || 'Failed to add student');
|
||||
};
|
||||
|
||||
const handleRemoveStudent = async (studentId: string) => {
|
||||
setActionError(null);
|
||||
await apiDelete(`/classes/${classId}/students/${studentId}`);
|
||||
await apiDelete(`/database/timetable/classes/${classId}/students/${studentId}`);
|
||||
load();
|
||||
};
|
||||
|
||||
const handleEnrollmentResponse = async (requestId: string, action: 'approve' | 'reject') => {
|
||||
setActionError(null);
|
||||
const res = await apiPatch(`/classes/${classId}/enrollment-requests/${requestId}`, { action });
|
||||
const res = await apiPost(`/database/timetable/enrollment-requests/${requestId}/respond`, { status: action === 'approve' ? 'approved' : 'rejected' });
|
||||
if (res.status === 'ok') load();
|
||||
else setActionError(res.detail || 'Action failed');
|
||||
};
|
||||
@@ -254,6 +265,8 @@ const ClassDetailPage: React.FC = () => {
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<ResultsWidget classId={cls.id} className={cls.name} />
|
||||
|
||||
{/* Tabs */}
|
||||
<Tabs value={tab} onChange={(_, v) => setTab(v)} sx={{ borderBottom: 1, borderColor: 'divider', mb: 2 }}>
|
||||
<Tab label={`Students (${cls.student_count})`} />
|
||||
|
||||
Reference in New Issue
Block a user