feat: restrict access to courses
This commit is contained in:
@@ -31,11 +31,11 @@
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import Analytics from './Submissions/index.svelte';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { globalStore } from '$lib/utils/store/app';
|
||||
|
||||
export let exerciseId = '';
|
||||
export let path = '';
|
||||
export let goBack = () => {};
|
||||
export let isStudent = true;
|
||||
export let isFetching = false;
|
||||
|
||||
let preview: boolean = false;
|
||||
@@ -44,7 +44,7 @@
|
||||
let selectedIndex = 0;
|
||||
|
||||
async function handleSave() {
|
||||
if (isStudent) return;
|
||||
if ($globalStore.isStudent) return;
|
||||
|
||||
const errors = validateQuestionnaire($questionnaire.questions);
|
||||
if (Object.values(errors).length > 0) {
|
||||
@@ -81,7 +81,7 @@
|
||||
$: $questionnaire?.questions?.length < 1 && handleAddQuestion();
|
||||
</script>
|
||||
|
||||
<PageBody bind:isPageNavHidden={isStudent} padding="px-4 overflow-x-hidden">
|
||||
<PageBody bind:isPageNavHidden={$globalStore.isStudent} padding="px-4 overflow-x-hidden">
|
||||
<div class="bg-gray-100 dark:bg-neutral-800 top-0 z-10 sticky p-2 mb-3">
|
||||
<Breadcrumb noTrailingSlash>
|
||||
<BreadcrumbItem href={path}
|
||||
@@ -154,7 +154,7 @@
|
||||
<RoleBasedSecurity allowedRoles={[1, 2]}>
|
||||
<UpdateDescription {preview} />
|
||||
</RoleBasedSecurity>
|
||||
{#if !isStudent && !preview}
|
||||
{#if !$globalStore.isStudent && !preview}
|
||||
<EditMode bind:shouldDeleteExercise {exerciseId} {goBack} />
|
||||
{:else}
|
||||
<ViewMode {preview} {exerciseId} isFetchingExercise={isFetching} />
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
import type { ExerciseTemplate } from '$lib/utils/types';
|
||||
import { formatDate } from '$lib/utils/functions/routes/dashboard';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { globalStore } from '$lib/utils/store/app';
|
||||
|
||||
export let path = '';
|
||||
export let exerciseId = '';
|
||||
export let lessonId = '';
|
||||
export let isStudent = true;
|
||||
|
||||
let open = false;
|
||||
let isFetching = false;
|
||||
@@ -151,7 +151,7 @@
|
||||
{/if}
|
||||
|
||||
{#if exerciseId}
|
||||
<Exercise {exerciseId} {goBack} bind:path bind:isStudent {isFetching} />
|
||||
<Exercise {exerciseId} {goBack} bind:path {isFetching} />
|
||||
{:else}
|
||||
<NewExerciseModal
|
||||
bind:open
|
||||
@@ -161,7 +161,7 @@
|
||||
bind:title={newExercise.title}
|
||||
/>
|
||||
|
||||
<PageBody bind:isPageNavHidden={isStudent}>
|
||||
<PageBody bind:isPageNavHidden={$globalStore.isStudent}>
|
||||
<slot:fragment slot="header">
|
||||
<Breadcrumb class="my-2">
|
||||
<BreadcrumbItem href={path}>{$t('course.navItem.lessons.exercises.heading')}</BreadcrumbItem
|
||||
@@ -193,7 +193,7 @@
|
||||
{$t('course.navItem.lessons.exercises.no_exercises')}
|
||||
</h2>
|
||||
<p class="text-sm text-center text-slate-500">
|
||||
{#if isStudent}
|
||||
{#if $globalStore.isStudent}
|
||||
{$t('course.navItem.lessons.exercises.no_assigned_exercises')}
|
||||
<strong> {$t('course.navItem.lessons.exercises.chill')} :)</strong>
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user