Skip to content

Commit

Permalink
fix: grading input disappears on change #7 (#8)
Browse files Browse the repository at this point in the history
* fix: grading input disappears on change

* fix: restore mark as complete button
  • Loading branch information
rotimi-best authored Nov 9, 2023
1 parent 32e49bd commit 021fe19
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/Course/components/Lesson/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
2 changes: 1 addition & 1 deletion src/lib/components/Question/CheckboxQuestion/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</span>
</svelte:fragment>
</HtmlRender>
<Grade {gradeMax} {grade} {disableGrading} />
<Grade {gradeMax} bind:grade {disableGrading} />
</div>

{#if code}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Question/Grade.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let grade: number | undefined;
</script>

{#if typeof grade === 'number'}
{#if typeof grade !== 'undefined'}
<div class="flex items-center">
<TextField
placeholder="Points"
Expand Down
6 changes: 2 additions & 4 deletions src/lib/components/Question/RadioQuestion/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@
<div class="flex items-center justify-between">
<HtmlRender className="mt-4">
<svelte:fragment slot="content">
<span
class="dark:text-white flex gap-1 {labelClassName} {typeof grade === 'number' && 'w-3/4'}"
>
<span class="dark:text-white flex items-center gap-1 {labelClassName}">
<h3>{index}</h3>
<h3>{title}</h3>
</span>
</svelte:fragment>
</HtmlRender>
<Grade {gradeMax} {grade} {disableGrading} />
<Grade {gradeMax} bind:grade {disableGrading} />
</div>

{#if code}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Question/TextareaQuestion/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</span>
</svelte:fragment>
</HtmlRender>
<Grade {gradeMax} {grade} {disableGrading} />
<Grade {gradeMax} bind:grade {disableGrading} />
</div>

{#if code}
Expand Down
21 changes: 20 additions & 1 deletion src/routes/courses/[id]/lessons/[...lessonParams]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -211,6 +212,8 @@
mode = MODES.view;
fetchReqData(data.lessonId, data.isMaterialsTabActive);
}
$: isLessonComplete = getIsLessonComplete($lesson.lesson_completion, $profile.id);
</script>

<CourseContainer
Expand Down Expand Up @@ -294,6 +297,22 @@
className="overflow-x-hidden"
>
<Materials lessonId={data.lessonId} {mode} {prevMode} {toggleMode} bind:isSaving />
<div class="w-full hidden lg:flex flex-row-reverse mt-10">
<PrimaryButton
onClick={() => markLessonComplete(data.lessonId)}
isLoading={isMarkingComplete}
isDisabled={isMarkingComplete}
variant={VARIANTS.OUTLINED}
className="mt-10"
>
{#if isLessonComplete}
<CheckmarkFilledIcon size={24} class="carbon-icon text-primary-600 mr-2" />
{:else}
<CheckmarkOutlineIcon size={24} class="carbon-icon mr-2" />
{/if}
Mark as {isLessonComplete ? 'Incomplete' : 'Complete'}
</PrimaryButton>
</div>
</PageBody>
{/if}

Expand Down Expand Up @@ -330,7 +349,7 @@
on:click={() => markLessonComplete(data.lessonId)}
disabled={isMarkingComplete}
>
{#if getIsLessonComplete($lesson.lesson_completion, $profile.id)}
{#if isLessonComplete}
<CheckmarkFilledIcon size={24} class="carbon-icon text-primary-600" />
{:else}
<CheckmarkOutlineIcon size={24} class="carbon-icon" />
Expand Down
1 change: 1 addition & 0 deletions src/routes/courses/[id]/submissions/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
};
sendEmail(submissionIdData[itemToWithNewStatus.id]);
updateSubmission({
id: itemToWithNewStatus.id,
status_id: itemToWithNewStatus.statusId
Expand Down

0 comments on commit 021fe19

Please sign in to comment.