CLASSROOMIO-T-168: Mark lesson as complete
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { supabase } from '$lib/utils/functions/supabase';
|
||||
import { isUUID } from '$lib/utils/functions/isUUID';
|
||||
import { QUESTION_TYPE } from '$lib/components/Question/constants';
|
||||
import type { Lesson, Course, Group, Groupmember, Exercise } from '$lib/utils/types';
|
||||
import type {
|
||||
Lesson,
|
||||
Course,
|
||||
Group,
|
||||
Groupmember,
|
||||
Exercise,
|
||||
LessonCompletion
|
||||
} from '$lib/utils/types';
|
||||
import { STATUS } from '$lib/utils/constants/course';
|
||||
|
||||
export async function fetchCourse(courseId?: Course['id'], slug?: Course['slug']) {
|
||||
@@ -36,9 +43,10 @@ export async function fetchCourse(courseId?: Course['id'], slug?: Course['slug']
|
||||
is_certificate_downloadable,
|
||||
certificate_theme,
|
||||
lessons:lesson(
|
||||
id, title,public, lesson_at, call_url, is_unlocked, is_complete, order, created_at,
|
||||
id, title,public, lesson_at, call_url, is_unlocked, order, created_at,
|
||||
note, videos, slide_url, call_url, totalExercises:exercise(count),
|
||||
profile:teacher_id(id, avatar_url, fullname)
|
||||
profile:teacher_id(id, avatar_url, fullname),
|
||||
lesson_completion(id, profile_id, is_complete)
|
||||
),
|
||||
attendance:group_attendance(*)
|
||||
`
|
||||
@@ -138,7 +146,9 @@ export function deleteGroupMember(groupMemberId: Groupmember['id']) {
|
||||
export function fetchLesson(lessonId: Lesson['id']) {
|
||||
return supabase
|
||||
.from('lesson')
|
||||
.select(`id, note, videos, slide_url, call_url, totalExercises:exercise(count)`)
|
||||
.select(
|
||||
`id, note, videos, slide_url, call_url, totalExercises:exercise(count), lesson_completion(id, profile_id, is_complete)`
|
||||
)
|
||||
.eq('id', lessonId)
|
||||
.single();
|
||||
}
|
||||
@@ -154,6 +164,10 @@ export function updateLesson(lesson: any, lessonId: Lesson['id']) {
|
||||
.match({ id: lessonId });
|
||||
}
|
||||
|
||||
export function updateLessonCompletion(completion: LessonCompletion) {
|
||||
return supabase.from('lesson_completion').upsert(completion);
|
||||
}
|
||||
|
||||
export function deleteLesson(lessonId: Lesson['id']) {
|
||||
// Need to implement soft delete
|
||||
return supabase.from('lesson').delete().match({ id: lessonId });
|
||||
|
||||
@@ -143,14 +143,14 @@ export interface Group_attendance {
|
||||
groupmember?: Groupmember;
|
||||
}
|
||||
|
||||
enum VideoType {
|
||||
export enum VideoType {
|
||||
youtube,
|
||||
muse
|
||||
}
|
||||
|
||||
export interface LessonPage {
|
||||
id?: string | null;
|
||||
totalExercises: Number;
|
||||
is_complete: Boolean;
|
||||
isSaving: Boolean;
|
||||
materials: {
|
||||
note: string;
|
||||
@@ -162,6 +162,16 @@ export interface LessonPage {
|
||||
}>;
|
||||
};
|
||||
exercises: [];
|
||||
lesson_completion: LessonCompletion[];
|
||||
}
|
||||
|
||||
export interface LessonCompletion {
|
||||
id?: number;
|
||||
lesson_id: string;
|
||||
profile_id: string;
|
||||
is_complete: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface Lesson {
|
||||
@@ -169,19 +179,19 @@ export interface Lesson {
|
||||
videos?: []; // type unknown;
|
||||
slide_url?: any; // type unknown;
|
||||
course_id: string /* foreign key to course.id */;
|
||||
id?: string /* primary key */;
|
||||
id: string /* primary key */;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
title: any; // type unknown;
|
||||
title: string; // type unknown;
|
||||
public?: boolean;
|
||||
lesson_at?: string;
|
||||
teacher_id?: string /* foreign key to profile.id */;
|
||||
is_unlocked?: boolean;
|
||||
is_complete?: boolean;
|
||||
call_url?: string;
|
||||
order?: number;
|
||||
course?: Course;
|
||||
profile?: Profile;
|
||||
lesson_completion: LessonCompletion[];
|
||||
}
|
||||
|
||||
export interface Exercise {
|
||||
|
||||
Reference in New Issue
Block a user