feat: course types - self paced and live class (#309)

* working on the course type

* trying to mark it persist

* almost done here

* fixed sendig emtpy options bug

* created migration file

* created migration file

* made updates based on PR review

* merge

* update course type card

* add redirect logic with classroomio.com/new

* make new course modal only open/close with url

* feat: page active state (#315)

* finished the active link state

* updated the active link state based on review

* simplify code

---------

Co-authored-by: Rotimi Best <best@classroomio.com>

* add type to course card

---------

Co-authored-by: Rotimi Best <best@classroomio.com>
This commit is contained in:
Em_Dev
2024-05-21 00:14:47 +01:00
committed by GitHub
co-authored by Rotimi Best
parent b9bb568f98
commit 49d8539be9
41 changed files with 894 additions and 393 deletions
@@ -0,0 +1,37 @@
create type "public"."COURSE_TYPE" as enum ('SELF_PACED', 'LIVE_CLASS');
alter table "public"."course" add column "type" "COURSE_TYPE" default 'LIVE_CLASS'::"COURSE_TYPE";
drop function if exists "public"."get_courses"(org_id_arg uuid, profile_id_arg uuid);
create
or replace function public.get_courses (org_id_arg uuid, profile_id_arg uuid) returns table (
id uuid,
org_id uuid,
title character varying,
slug character varying,
description character varying,
logo text,
banner_image text,
cost bigint,
currency character varying,
is_published boolean,
profile_id uuid,
role_id bigint,
total_lessons bigint,
total_students bigint,
progress_rate bigint,
type "COURSE_TYPE"
) language plpgsql as $function$
BEGIN
Return query
select course.id, organization.id AS org_id, course.title, course.slug, course.description, course.logo, course.banner_image, course.cost, course.currency, course.is_published, groupmember.profile_id, groupmember.role_id, (select COUNT(*) from lesson as l where l.course_id = course.id) AS total_lessons, (select COUNT(*) from groupmember as gm where gm.group_id = course.group_id AND gm.role_id = 3) as total_students, (select COUNT(*) from lesson_completion as lc join lesson as l on l.id = lc.lesson_id where l.course_id = course.id and lc.is_complete = true and lc.profile_id = profile_id_arg) AS progress_rate, course.type as type
from course
join "group" on "group".id = course.group_id
join groupmember on groupmember.group_id = course.group_id
join organization on organization.id = "group".organization_id
where course.status = 'ACTIVE' AND organization.id = org_id_arg
-- GROUP BY course.id, groupmember.profile_id
ORDER BY course.created_at DESC;
END;
$function$;