This commit is contained in:
@@ -933,6 +933,7 @@ export interface ExamRoomItem {
|
||||
studentCount: number;
|
||||
paperCount: number;
|
||||
displayStatus: 'draft' | 'ready' | 'active' | 'ended' | 'cancelled';
|
||||
createdByStaffId?: number;
|
||||
}
|
||||
|
||||
export interface ExamPaperResource {
|
||||
@@ -985,8 +986,9 @@ function decodeBase64ToArrayBuffer(b64: string): ArrayBuffer {
|
||||
}
|
||||
|
||||
export const apiExam = {
|
||||
list: async (): Promise<{ data: ExamRoomItem[] }> => {
|
||||
const res = await staffFetch('/exam-rooms');
|
||||
list: async (opts?: { mine?: boolean }): Promise<{ data: ExamRoomItem[] }> => {
|
||||
const q = opts?.mine ? '?mine=1' : '';
|
||||
const res = await staffFetch(`/exam-rooms${q}`);
|
||||
if (!res.ok) await parseError(res, 'Failed');
|
||||
return res.json();
|
||||
},
|
||||
@@ -1031,6 +1033,14 @@ export const apiExam = {
|
||||
if (!res.ok) await parseError(res, 'Hủy phòng thi thất bại');
|
||||
return res.json();
|
||||
},
|
||||
extend: async (id: number, minutes: number) => {
|
||||
const res = await staffFetch(`/exam-rooms/${id}/extend`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ minutes }),
|
||||
});
|
||||
if (!res.ok) await parseError(res, 'Gia hạn thất bại');
|
||||
return res.json() as Promise<{ ok: boolean; endTime: string; addedMinutes: number; displayStatus: string }>;
|
||||
},
|
||||
update: async (id: number, payload: Partial<{ name: string; startTime: string; endTime: string; allowedApps: string; quizUrl: string }>) => {
|
||||
const res = await staffFetch(`/exam-rooms/${id}`, { method: 'PATCH', body: JSON.stringify(payload) });
|
||||
if (!res.ok) await parseError(res, 'Cập nhật thất bại');
|
||||
|
||||
Reference in New Issue
Block a user