diff --git a/src/lib/components/Course/components/Lesson/functions.ts b/src/lib/components/Course/components/Lesson/functions.ts index 7a2374a3..4edd5e99 100644 --- a/src/lib/components/Course/components/Lesson/functions.ts +++ b/src/lib/components/Course/components/Lesson/functions.ts @@ -27,9 +27,9 @@ export function generateQuestion(questions) { export function getIsLessonComplete( completions: LessonCompletion[], profileId: string | undefined -) { +): boolean { if (!Array.isArray(completions)) return false; - return completions.find((c) => { + return completions.some((c) => { return c.is_complete && c.profile_id === profileId; }); } diff --git a/src/lib/components/Question/CheckboxQuestion/index.svelte b/src/lib/components/Question/CheckboxQuestion/index.svelte index 3ed1226f..5d386984 100644 --- a/src/lib/components/Question/CheckboxQuestion/index.svelte +++ b/src/lib/components/Question/CheckboxQuestion/index.svelte @@ -72,7 +72,7 @@ - + {#if code} diff --git a/src/lib/components/Question/Grade.svelte b/src/lib/components/Question/Grade.svelte index 9f371e19..17ce9c0b 100644 --- a/src/lib/components/Question/Grade.svelte +++ b/src/lib/components/Question/Grade.svelte @@ -5,7 +5,7 @@ export let grade: number | undefined; -{#if typeof grade === 'number'} +{#if typeof grade !== 'undefined'}
- +

{index}

{title}

- +
{#if code} diff --git a/src/lib/components/Question/TextareaQuestion/index.svelte b/src/lib/components/Question/TextareaQuestion/index.svelte index 0612188a..77a32604 100644 --- a/src/lib/components/Question/TextareaQuestion/index.svelte +++ b/src/lib/components/Question/TextareaQuestion/index.svelte @@ -44,7 +44,7 @@ - + {#if code} diff --git a/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte b/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte index 908d72d7..eee0d9de 100644 --- a/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte +++ b/src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte @@ -43,6 +43,7 @@ let isLoading = false; let isSaving = false; let isStudent = true; + let isLessonComplete = false; function getLessonOrder(id: string) { const index = $lessons.findIndex((lesson) => lesson.id === id); @@ -211,6 +212,8 @@ mode = MODES.view; fetchReqData(data.lessonId, data.isMaterialsTabActive); } + + $: isLessonComplete = getIsLessonComplete($lesson.lesson_completion, $profile.id); + {/if} @@ -330,7 +349,7 @@ on:click={() => markLessonComplete(data.lessonId)} disabled={isMarkingComplete} > - {#if getIsLessonComplete($lesson.lesson_completion, $profile.id)} + {#if isLessonComplete} {:else} diff --git a/src/routes/courses/[id]/submissions/+page.svelte b/src/routes/courses/[id]/submissions/+page.svelte index b5c6f628..7eca71e3 100644 --- a/src/routes/courses/[id]/submissions/+page.svelte +++ b/src/routes/courses/[id]/submissions/+page.svelte @@ -156,6 +156,7 @@ }; sendEmail(submissionIdData[itemToWithNewStatus.id]); + updateSubmission({ id: itemToWithNewStatus.id, status_id: itemToWithNewStatus.statusId