fix exam grading

This commit is contained in:
root
2026-06-04 13:25:41 -04:00
parent 1af02dadd3
commit ad7b13f4d8
17 changed files with 853 additions and 46 deletions
+43
View File
@@ -123,6 +123,49 @@ export async function fetchBelowSixty(searchParams: URLSearchParams): Promise<un
return apiFetch(`${BASE}/below-sixty${q(searchParams)}`)
}
export async function fetchBelowSixtyDecisions(
searchParams: URLSearchParams,
): Promise<unknown> {
return apiFetch(`${BASE}/below-sixty/decisions${q(searchParams)}`)
}
export async function postBelowSixtyDecision(body: Record<string, unknown>): Promise<unknown> {
return apiFetch(`${BASE}/below-sixty/decisions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
}
export async function fetchBelowSixtyDecisionDetails(
searchParams: URLSearchParams,
): Promise<unknown> {
return apiFetch(`${BASE}/below-sixty/decisions/details${q(searchParams)}`)
}
export async function fetchBelowSixtyDecisionEmailEditor(
searchParams: URLSearchParams,
): Promise<{
student_id?: number
student_name?: string
school_year?: string
semester?: string
decision?: string
subject?: string
html?: string
year_score?: number | string | null
}> {
return apiFetch(`${BASE}/below-sixty/decisions/email${q(searchParams)}`)
}
export async function postBelowSixtyDecisionEmail(body: Record<string, unknown>): Promise<unknown> {
return apiFetch(`${BASE}/below-sixty/decisions/email`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
}
export async function fetchBelowSixtyEmailEditor(searchParams: URLSearchParams): Promise<{
studentId?: number
studentName?: string
+8 -4
View File
@@ -6,10 +6,14 @@ import { ApiHttpError, apiFetch } from './http'
const BASE = '/api/v1/role-permission'
function unwrapData<T>(body: T): T {
if (!body || typeof body !== 'object') return body
const maybeEnvelope = body as { data?: unknown }
return (maybeEnvelope.data as T | undefined) ?? body
type DataEnvelope<T> = { data?: T }
function unwrapData<T>(body: T | DataEnvelope<T>): T {
if (body && typeof body === 'object' && 'data' in body) {
const data = (body as DataEnvelope<T>).data
if (data !== undefined) return data
}
return body as T
}
export type RoleRow = {
+24 -2
View File
@@ -99,7 +99,7 @@ export async function loginRequest(
email: string,
password: string,
): Promise<LoginResponse> {
const body = await apiFetch<LoginResponse>(
const body = await apiFetch<unknown>(
'/api/v1/auth/login',
{
method: 'POST',
@@ -109,7 +109,11 @@ export async function loginRequest(
{ attachAuth: false },
)
if (body.status === false) {
if (!body || typeof body !== 'object' || !('status' in body)) {
throw new Error('Invalid login response from API.')
}
if ((body as { status?: boolean }).status === false) {
const fail = body as LoginFailure
return { status: false, message: fail.message }
}
@@ -1465,6 +1469,24 @@ export async function submitFamilyLegacyImport(formData: FormData): Promise<Fami
return raw as FamilyLegacyImportResult
}
export async function importLegacySecondParents(): Promise<{
message?: string
data?: {
ok?: boolean
message?: string
created_users?: number
guardians_linked?: number
skipped?: number
total_source?: number
} | null
}> {
return apiFetch('/api/v1/families/import-legacy-second-parents', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({}),
})
}
export async function fetchPaypalTransactions(params?: {
q?: string
perPage?: number
+12 -5
View File
@@ -931,15 +931,22 @@ export type TeacherSubmissionTeacherRow = {
role_key?: string | null
}
export type TeacherSubmissionStatus = {
label?: string | null
badge?: string | null
detail?: string | null
completed?: boolean
}
export type TeacherSubmissionReportRow = {
class_section?: string | null
class_section_id?: number
teachers?: TeacherSubmissionTeacherRow[]
midterm_score_status?: string | null
midterm_comment_status?: string | null
participation_status?: string | null
ptap_comment_status?: string | null
attendance_status?: string | null
midterm_score_status?: TeacherSubmissionStatus | null
midterm_comment_status?: TeacherSubmissionStatus | null
participation_status?: TeacherSubmissionStatus | null
ptap_comment_status?: TeacherSubmissionStatus | null
attendance_status?: TeacherSubmissionStatus | null
missing_items?: string[]
student_count?: number
}