2023-09-29 09:25:32 +01:00
|
|
|
|
<script lang="ts">
|
2023-08-10 12:23:10 +00:00
|
|
|
|
import Learning from '$lib/components/LMS/components/Learning.svelte';
|
|
|
|
|
|
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
|
|
|
|
|
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
|
|
|
|
|
import { goto } from '$app/navigation';
|
2023-09-29 09:25:32 +01:00
|
|
|
|
import { profile } from '$lib/utils/store/user';
|
|
|
|
|
|
import { currentOrg } from '$lib/utils/store/org';
|
2023-09-30 09:56:42 +01:00
|
|
|
|
import { fetchCourses } from '$lib/components/Courses/api';
|
2023-09-29 09:25:32 +01:00
|
|
|
|
import { courses, courseMetaDeta } from '$lib/components/Courses/store';
|
|
|
|
|
|
import type { Course } from '$lib/utils/types';
|
2023-10-22 09:47:13 +01:00
|
|
|
|
import { getGreeting } from '$lib/utils/functions/date';
|
2023-09-29 09:25:32 +01:00
|
|
|
|
|
|
|
|
|
|
let hasFetched = false;
|
|
|
|
|
|
let progressPercentage = 0;
|
|
|
|
|
|
let totalLessons = 0;
|
|
|
|
|
|
let totalComPleted = 0;
|
|
|
|
|
|
|
2023-11-04 17:53:59 +00:00
|
|
|
|
async function getCourses(userId: string | undefined, orgId: string) {
|
2023-09-29 09:25:32 +01:00
|
|
|
|
if (hasFetched || !userId || !orgId) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
$courseMetaDeta.isLoading = true;
|
|
|
|
|
|
|
|
|
|
|
|
const coursesResult = await fetchCourses(userId, orgId);
|
|
|
|
|
|
console.log(`coursesResult`, coursesResult);
|
|
|
|
|
|
|
|
|
|
|
|
$courseMetaDeta.isLoading = false;
|
|
|
|
|
|
if (!coursesResult) return;
|
|
|
|
|
|
|
|
|
|
|
|
courses.set(coursesResult.allCourses);
|
|
|
|
|
|
hasFetched = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function calcTotalProgress(courses: Course[]) {
|
|
|
|
|
|
totalComPleted = courses.reduce((acc, cur) => acc + (cur.progress_rate || 0), 0);
|
|
|
|
|
|
totalLessons = courses.reduce((acc, cur) => acc + (cur.total_lessons || 0), 0);
|
|
|
|
|
|
|
|
|
|
|
|
progressPercentage = Math.round((totalComPleted / totalLessons) * 100);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$: getCourses($profile.id, $currentOrg.id);
|
|
|
|
|
|
$: calcTotalProgress($courses);
|
2023-08-07 19:44:26 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2023-08-10 12:23:10 +00:00
|
|
|
|
<svelte:head>
|
|
|
|
|
|
<title>Student Dashboard - ClassroomIO</title>
|
|
|
|
|
|
</svelte:head>
|
2023-08-07 19:44:26 +00:00
|
|
|
|
|
2023-08-24 14:22:34 +00:00
|
|
|
|
<section class="max-w-6xl gap-5 mx-auto">
|
2023-08-15 14:28:51 +00:00
|
|
|
|
<div class="m-5">
|
2023-11-04 17:53:59 +00:00
|
|
|
|
<h1 class="dark:text-white text-2xl md:text-3xl font-bold mb-3">
|
2023-10-22 09:47:13 +01:00
|
|
|
|
{getGreeting()}
|
|
|
|
|
|
{$profile.fullname}!
|
|
|
|
|
|
</h1>
|
2023-08-15 14:28:51 +00:00
|
|
|
|
<div
|
2023-08-20 20:52:52 +01:00
|
|
|
|
class="w-full h-fit lg:h-[265px] flex md:items-center justify-between flex-col-reverse md:flex-row p-5 lg:p-10 rounded-md bg-primary-900 my-2"
|
2023-08-10 12:23:10 +00:00
|
|
|
|
>
|
2023-08-15 14:28:51 +00:00
|
|
|
|
<span>
|
|
|
|
|
|
<p class="w-full md:w-[75%] lg:w-[80%] text-white text-xs lg:text-xl font-normal mb-5">
|
|
|
|
|
|
Today is another day to bring you closer to your learning goals. Don’t give up, the more
|
|
|
|
|
|
you learn the better you get.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<PrimaryButton
|
2023-10-22 09:47:13 +01:00
|
|
|
|
label="Don't give up"
|
2023-08-15 14:28:51 +00:00
|
|
|
|
variant={VARIANTS.CONTAINED_WHITE}
|
|
|
|
|
|
onClick={() => goto('/lms/mylearning')}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<img
|
|
|
|
|
|
src="/images/student-learning.svg"
|
|
|
|
|
|
alt="student Learning Pictogram"
|
|
|
|
|
|
class="w-28 md:block md:w-1/3 lg:w-[275px] lg:h-[205px] mb-3 md:mb-0"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2023-10-22 09:47:13 +01:00
|
|
|
|
<section class="flex w-full flex-col md:flex-row md:gap-5">
|
|
|
|
|
|
<div class="w-full md:w-[50%] mt-10 xl:mt-2">
|
2023-08-15 14:28:51 +00:00
|
|
|
|
<Learning />
|
|
|
|
|
|
</div>
|
2023-10-22 09:47:13 +01:00
|
|
|
|
<div class="mt-10 xl:mt-2 w-full md:w-[50%]">
|
2023-09-30 09:56:42 +01:00
|
|
|
|
<p class="text-base font-semibold text-[#040F2D] pb-3 dark:text-white">Your Progress</p>
|
2023-08-15 14:28:51 +00:00
|
|
|
|
<div
|
2023-10-22 09:47:13 +01:00
|
|
|
|
class="flex items-center justify-center border border-[#EAEAEA] dark:bg-neutral-800 gap-2 rounded h-fit md:h-[40vh] lg:overflow-y-auto p-3"
|
2023-08-15 14:28:51 +00:00
|
|
|
|
>
|
2023-09-30 09:56:42 +01:00
|
|
|
|
<div
|
|
|
|
|
|
class="w-full h-full flex flex-col sm:flex-row xl:flex-col items-center justify-between md:items-center xl:items-start gap-5 md:justify-around"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<img src="/images/target.svg" alt="student Learning score" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span class="text-center xl:text-start">
|
|
|
|
|
|
<p class="text-base font-semibold py-2 text-[#040F2D] dark:text-white">
|
|
|
|
|
|
Your Progress
|
2023-08-15 14:28:51 +00:00
|
|
|
|
</p>
|
2023-09-30 09:56:42 +01:00
|
|
|
|
{#if totalLessons > 0}
|
|
|
|
|
|
<p class="text-xs font-normal text-[#656565] dark:text-white">
|
|
|
|
|
|
{totalComPleted}/{totalLessons} lessons completed
|
|
|
|
|
|
</p>
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
<p class="text-xs font-normal text-[#656565] dark:text-white">No courses started</p>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
</span>
|
2023-10-22 09:47:13 +01:00
|
|
|
|
<h1
|
|
|
|
|
|
class="text-5xl md:text-6xl font-bold text-[#262626] dark:text-white my-0 whitespace-nowrap"
|
|
|
|
|
|
>
|
2023-09-30 09:56:42 +01:00
|
|
|
|
{progressPercentage} %
|
|
|
|
|
|
</h1>
|
|
|
|
|
|
</div>
|
2023-08-15 14:28:51 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2023-09-30 09:56:42 +01:00
|
|
|
|
</section>
|
2023-08-15 14:28:51 +00:00
|
|
|
|
</div>
|
2023-08-07 19:44:26 +00:00
|
|
|
|
</section>
|