CLASSROOMIO-T-108: Attendance improvement + complete lms exercise

This commit is contained in:
Rotimi Best
2023-10-01 19:31:18 +01:00
parent 6812895488
commit 21305c5d65
20 changed files with 316 additions and 145 deletions
+96
View File
@@ -0,0 +1,96 @@
import { supabase } from '$lib/utils/functions/supabase';
import type { PostgrestError } from '@supabase/supabase-js';
export interface LMSExercise {
id: string;
title: string;
updated_at: string;
submission: {
status_id: number;
updated_at: string;
groupmember: {
id: string;
profile: {
id: string;
}[];
}[];
}[];
lesson: {
id: string;
title: string;
order: number;
course: {
id: string;
title: string;
group: {
organisation: {
id: string;
}[];
}[];
groupmember: {
id: string;
profile: {
id: string;
}[];
}[];
};
};
}
interface FetchLMSExercisesResponse {
exercises: LMSExercise[] | null;
error: PostgrestError | null;
}
export async function fetchLMSExercises(
profileId: string,
orgId: string
): Promise<FetchLMSExercisesResponse> {
const { data, error } = await supabase
.from('exercise')
.select(
`
id,
title,
updated_at,
submission (
status_id,
updated_at,
groupmember:submitted_by!inner (
id,
profile!inner (
id
)
)
),
lesson!inner (
id,
title,
order,
course!inner (
id,
title,
group:group_id!inner (
organisation:organization_id!inner (
id
)
),
groupmember:group_id!inner(
id,
profile!inner (
id
)
)
)
)
`
)
.eq('lesson.course.group.organisation.id', orgId)
.eq('lesson.course.groupmember.profile.id', profileId)
.eq('submission.groupmember.profile.id', profileId);
return {
exercises: data,
error
};
}