feat: hide other course participants from students

This commit is contained in:
Rotimi Best
2024-04-11 10:14:37 +01:00
parent 8e76bebb92
commit 4ef1d7bf6c
5 changed files with 13 additions and 19 deletions
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import { slide } from 'svelte/transition';
import ChevronDownIcon from 'carbon-icons-svelte/lib/ChevronDown.svelte';
import ChevronUpIcon from 'carbon-icons-svelte/lib/ChevronUp.svelte';
@@ -14,7 +14,7 @@
export let handleClick = () => {};
export let label = '';
export let isGroupActive = false;
export let isExpanded = true;
export let isExpanded: boolean | undefined;
export let total = 0;
export let isLoading = true;
export let isLesson = false;
@@ -26,11 +26,10 @@
hideSortIcon: boolean;
isLesson?: boolean;
isPaidFeature: boolean;
isExpanded?: boolean;
show?: () => boolean;
}
let show: boolean = false;
let isLessonActive: boolean = false;
let resize = false;
let isDragging = false;
let startX: number;
@@ -52,11 +51,6 @@
let navItems: NavItem[] = [];
function handleMobileChange(isMobile: boolean) {
if (isMobile) show = false;
else show = true;
}
function handleCursor(event: MouseEvent) {
if (!resize && sidebarRef) {
const isNearLeftBorder = event.clientX - sidebarRef.getBoundingClientRect().left < 8;
@@ -140,10 +134,6 @@
}
});
$: handleMobileChange($isMobile);
$: isLessonActive = $page.url.pathname.includes('/lessons');
$: {
navItems = [
{
@@ -157,7 +147,8 @@
to: getLessonsRoute($course.id),
hideSortIcon: false,
isPaidFeature: false,
isLesson: true
isLesson: true,
isExpanded: isStudent ? true : $page.url.pathname.includes('/lessons')
},
{
label: 'Attendance',
@@ -184,7 +175,10 @@
label: 'People',
to: getNavItemRoute($course.id, 'people'),
isPaidFeature: false,
hideSortIcon: true
hideSortIcon: true,
show() {
return !isStudent;
}
},
{
label: 'Certificates',
@@ -248,11 +242,11 @@
label={navItem.label}
handleClick={handleMainGroupClick(navItem.to)}
isGroupActive={(path || $page.url.pathname) === navItem.to}
isExpanded={isLessonActive}
total={navItem.isLesson ? ($lessons || []).length : 0}
isLoading={!$course.id}
isLesson={navItem.isLesson}
isPaidFeature={navItem.isPaidFeature}
isExpanded={navItem.isExpanded}
{isStudent}
>
{#if navItem.isLesson}