feat: add managed learning paths
This commit is contained in:
@@ -148,6 +148,34 @@ export const courseRoutes: FastifyPluginAsync = async (app) => {
|
||||
return { data: authenticated ? result.rows : result.rows.map(withoutProtectedMedia) };
|
||||
});
|
||||
|
||||
// Paths intentionally reference existing courses instead of copying them.
|
||||
// Only a path and its published courses are visible to visitors.
|
||||
app.get('/paths', async () => {
|
||||
const result = await pool.query(
|
||||
`select
|
||||
p.id, p.title, p.description,
|
||||
coalesce(p.cover_image_url, (
|
||||
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
|
||||
)) as "coverImageUrl",
|
||||
p.cover_image_zoom as "coverImageZoom",
|
||||
p.cover_image_position_x as "coverImagePositionX",
|
||||
p.cover_image_position_y as "coverImagePositionY",
|
||||
coalesce(jsonb_agg(jsonb_build_object(
|
||||
'id', c.id, 'title', c.title, 'category', c.category,
|
||||
'coverImageUrl', coalesce(c.cover_image_url, (
|
||||
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
|
||||
)), 'position', pc.position
|
||||
) order by pc.position) filter (where c.id is not null), '[]'::jsonb) as courses
|
||||
from learning_paths p
|
||||
join learning_path_courses pc on pc.learning_path_id = p.id
|
||||
join courses c on c.id = pc.course_id and c.status = 'published'
|
||||
where p.status = 'published'
|
||||
group by p.id
|
||||
order by p.published_at desc`,
|
||||
);
|
||||
return { data: result.rows };
|
||||
});
|
||||
|
||||
app.get('/me/learning', { preHandler: app.authenticate }, async (request) => {
|
||||
const result = await pool.query(
|
||||
`select base.*, coalesce(progress.progress, 0)::int as progress, progress."lastActivity"
|
||||
|
||||
Reference in New Issue
Block a user