CLASSROOMIO-T-108: Add grading score to Graded column
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// import paystack from 'paystack';
|
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import { observeIntersection } from './components/IntersectionObserver';
|
import { observeIntersection } from './components/IntersectionObserver';
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
import Notebook from 'carbon-icons-svelte/lib/Notebook.svelte'; //note
|
import Notebook from 'carbon-icons-svelte/lib/Notebook.svelte'; //note
|
||||||
import PresentationFile from 'carbon-icons-svelte/lib/PresentationFile.svelte'; // exercise
|
import PresentationFile from 'carbon-icons-svelte/lib/PresentationFile.svelte'; // exercise
|
||||||
import Video from 'carbon-icons-svelte/lib/Video.svelte'; //video
|
import Video from 'carbon-icons-svelte/lib/Video.svelte'; //video
|
||||||
@@ -24,8 +21,7 @@
|
|||||||
import { reviewsModalStore } from './store';
|
import { reviewsModalStore } from './store';
|
||||||
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
||||||
import HtmlRender from '$lib/components/HTMLRender/HTMLRender.svelte';
|
import HtmlRender from '$lib/components/HTMLRender/HTMLRender.svelte';
|
||||||
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
export let editMode = false;
|
export let editMode = false;
|
||||||
export let courseData: Course;
|
export let courseData: Course;
|
||||||
@@ -378,7 +374,7 @@
|
|||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<img src="/images/rating-full.svg" alt="" class="mr-2" />
|
<img src="/images/rating-full.svg" alt="" class="mr-2" />
|
||||||
<p class="text-xs text-gray-600">
|
<p class="text-xs text-gray-600">
|
||||||
{dayjs(review.created_at).fromNow(true)} ago
|
{calDateDiff(review.created_at)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
import AddCommentIcon from 'carbon-icons-svelte/lib/AddComment.svelte';
|
import AddCommentIcon from 'carbon-icons-svelte/lib/AddComment.svelte';
|
||||||
import CommunityLoader from './Loader.svelte';
|
import CommunityLoader from './Loader.svelte';
|
||||||
import Vote from '$lib/components/Vote/index.svelte';
|
import Vote from '$lib/components/Vote/index.svelte';
|
||||||
@@ -10,14 +8,13 @@
|
|||||||
import Space from '$lib/components/Space/index.svelte';
|
import Space from '$lib/components/Space/index.svelte';
|
||||||
import { currentOrgPath, currentOrg } from '$lib/utils/store/org';
|
import { currentOrgPath, currentOrg } from '$lib/utils/store/org';
|
||||||
import { supabase } from '$lib/utils/functions/supabase';
|
import { supabase } from '$lib/utils/functions/supabase';
|
||||||
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
|
|
||||||
export let isLMS = false;
|
export let isLMS = false;
|
||||||
|
|
||||||
let isLoading = false;
|
let isLoading = false;
|
||||||
let discussions = [];
|
let discussions = [];
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
async function fetchCommunityQuestions(orgId) {
|
async function fetchCommunityQuestions(orgId) {
|
||||||
if (!orgId) return;
|
if (!orgId) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@@ -54,7 +51,7 @@
|
|||||||
author: discussion?.author?.profile?.fullname,
|
author: discussion?.author?.profile?.fullname,
|
||||||
comments: discussion.comments?.[0]?.count || 0,
|
comments: discussion.comments?.[0]?.count || 0,
|
||||||
votes: discussion.votes,
|
votes: discussion.votes,
|
||||||
createdAt: dayjs(discussion.created_at).fromNow(true)
|
createdAt: calDateDiff(discussion.created_at)
|
||||||
})) || [];
|
})) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,13 @@
|
|||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import { ImageLoader } from 'carbon-components-svelte';
|
import { ImageLoader } from 'carbon-components-svelte';
|
||||||
import OverflowMenuHorizontalIcon from 'carbon-icons-svelte/lib/OverflowMenuHorizontal.svelte';
|
import OverflowMenuHorizontalIcon from 'carbon-icons-svelte/lib/OverflowMenuHorizontal.svelte';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
import { currentOrgPath } from '$lib/utils/store/org';
|
import { currentOrgPath } from '$lib/utils/store/org';
|
||||||
import Dropdown from '$lib/components/Dropdown/index.svelte';
|
import Dropdown from '$lib/components/Dropdown/index.svelte';
|
||||||
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
||||||
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
||||||
import { onRename, onDelete } from '$lib/utils/services/org/quiz';
|
import { onRename, onDelete } from '$lib/utils/services/org/quiz';
|
||||||
import { themeImages } from '$lib/utils/constants/quiz';
|
import { themeImages } from '$lib/utils/constants/quiz';
|
||||||
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
export let quiz;
|
export let quiz;
|
||||||
export let totalQuestions;
|
export let totalQuestions;
|
||||||
@@ -80,7 +77,7 @@
|
|||||||
<div class="flex md:flex-row flex-col justify-between">
|
<div class="flex md:flex-row flex-col justify-between">
|
||||||
<div>
|
<div>
|
||||||
<p class="mb-2">{pluralize('question', totalQuestions, true)}</p>
|
<p class="mb-2">{pluralize('question', totalQuestions, true)}</p>
|
||||||
<p class="mb-2 md:mb-0">Updated {dayjs(quiz.updated_at).fromNow(true)} ago</p>
|
<p class="mb-2 md:mb-0">Updated {calDateDiff(quiz.updated_at)}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||||
|
|
||||||
|
dayjs.extend(relativeTime);
|
||||||
|
|
||||||
|
export const calDateDiff = (date: string | number | Date): string => {
|
||||||
|
return dayjs(date).fromNow(true) + ` ago`;
|
||||||
|
};
|
||||||
@@ -5,9 +5,13 @@ export interface LMSExercise {
|
|||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
questions: {
|
||||||
|
points: number;
|
||||||
|
}[];
|
||||||
submission: {
|
submission: {
|
||||||
status_id: number;
|
status_id: number;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
total: number;
|
||||||
groupmember: {
|
groupmember: {
|
||||||
id: string;
|
id: string;
|
||||||
profile: {
|
profile: {
|
||||||
@@ -53,9 +57,11 @@ export async function fetchLMSExercises(
|
|||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
updated_at,
|
updated_at,
|
||||||
|
questions:question(points),
|
||||||
submission (
|
submission (
|
||||||
status_id,
|
status_id,
|
||||||
updated_at,
|
updated_at,
|
||||||
|
total,
|
||||||
groupmember:submitted_by!inner (
|
groupmember:submitted_by!inner (
|
||||||
id,
|
id,
|
||||||
profile!inner (
|
profile!inner (
|
||||||
@@ -90,7 +96,7 @@ export async function fetchLMSExercises(
|
|||||||
.eq('submission.groupmember.profile.id', profileId);
|
.eq('submission.groupmember.profile.id', profileId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
exercises: data,
|
exercises: data as LMSExercise[] | null,
|
||||||
error
|
error
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
|
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
|
||||||
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
|
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
|
||||||
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
||||||
@@ -24,8 +22,7 @@
|
|||||||
import TextField from '$lib/components/Form/TextField.svelte';
|
import TextField from '$lib/components/Form/TextField.svelte';
|
||||||
import DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
import DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
||||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||||
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
const { slug } = data;
|
const { slug } = data;
|
||||||
@@ -59,7 +56,7 @@
|
|||||||
avatar: data?.author?.profile?.avatar_url || ''
|
avatar: data?.author?.profile?.avatar_url || ''
|
||||||
},
|
},
|
||||||
body: data.body,
|
body: data.body,
|
||||||
createdAt: dayjs(data.created_at).fromNow(true),
|
createdAt: calDateDiff(data.created_at),
|
||||||
comments: data.comments.map((c) => ({
|
comments: data.comments.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
authorId: c.author?.profile?.id || '',
|
authorId: c.author?.profile?.id || '',
|
||||||
@@ -67,7 +64,7 @@
|
|||||||
avatar: c.author?.profile?.avatar_url || '',
|
avatar: c.author?.profile?.avatar_url || '',
|
||||||
votes: c.votes,
|
votes: c.votes,
|
||||||
comment: c.body,
|
comment: c.body,
|
||||||
createdAt: dayjs(c.created_at).fromNow(true)
|
createdAt: calDateDiff(c.created_at)
|
||||||
})),
|
})),
|
||||||
totalComments: 0
|
totalComments: 0
|
||||||
};
|
};
|
||||||
@@ -148,7 +145,7 @@
|
|||||||
avatar: $profile?.avatar_url || '',
|
avatar: $profile?.avatar_url || '',
|
||||||
votes: 0,
|
votes: 0,
|
||||||
comment: _c.body,
|
comment: _c.body,
|
||||||
createdAt: dayjs(_c.created_at).fromNow(true)
|
createdAt: calDateDiff(_c.created_at)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
import { snackbar } from '$lib/components/Snackbar/store';
|
import { snackbar } from '$lib/components/Snackbar/store';
|
||||||
import { fetchLMSExercises } from '$lib/utils/services/lms/exercises';
|
import { fetchLMSExercises } from '$lib/utils/services/lms/exercises';
|
||||||
import type { LMSExercise } from '$lib/utils/services/lms/exercises';
|
import type { LMSExercise } from '$lib/utils/services/lms/exercises';
|
||||||
import dayjs from 'dayjs';
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
const defaultSections = [
|
const defaultSections = [
|
||||||
{
|
{
|
||||||
@@ -27,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Grading',
|
title: 'Grading In Progress',
|
||||||
items: [],
|
items: [],
|
||||||
className: 'text-yellow-700 bg-yellow-200'
|
className: 'text-yellow-700 bg-yellow-200'
|
||||||
},
|
},
|
||||||
@@ -51,9 +48,10 @@
|
|||||||
interface ExerciseItem {
|
interface ExerciseItem {
|
||||||
courseTitle: string;
|
courseTitle: string;
|
||||||
courseURL: string;
|
courseURL: string;
|
||||||
exerciseTitle: string;
|
|
||||||
exerciseId: string;
|
exerciseId: string;
|
||||||
|
exerciseTitle: string;
|
||||||
exerciseURL: string;
|
exerciseURL: string;
|
||||||
|
grade: string;
|
||||||
lessonNo: string;
|
lessonNo: string;
|
||||||
lessonURL: string;
|
lessonURL: string;
|
||||||
submissionStatus: number;
|
submissionStatus: number;
|
||||||
@@ -64,17 +62,23 @@
|
|||||||
const _sections: Section[] = cloneDeep(defaultSections);
|
const _sections: Section[] = cloneDeep(defaultSections);
|
||||||
|
|
||||||
for (const exercise of exercises) {
|
for (const exercise of exercises) {
|
||||||
const { id, title, updated_at, submission, lesson } = exercise;
|
const { id, title, updated_at, submission, lesson, questions } = exercise;
|
||||||
|
|
||||||
const submissionItem = submission[0] || {
|
const submissionItem = submission[0] || {
|
||||||
status_id: 0,
|
status_id: 0,
|
||||||
updated_at
|
updated_at,
|
||||||
|
total: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const courseURL = `/courses/${lesson.course.id}`;
|
const courseURL = `/courses/${lesson.course.id}`;
|
||||||
const lessonURL = `${courseURL}/lessons/${lesson.id}`;
|
const lessonURL = `${courseURL}/lessons/${lesson.id}`;
|
||||||
const exerciseURL = `${lessonURL}/exercises/${id}`;
|
const exerciseURL = `${lessonURL}/exercises/${id}`;
|
||||||
|
|
||||||
|
const grade = `${submissionItem.total}/${questions.reduce(
|
||||||
|
(acc, cur) => (acc += cur.points),
|
||||||
|
0
|
||||||
|
)}`;
|
||||||
|
|
||||||
const item: ExerciseItem = {
|
const item: ExerciseItem = {
|
||||||
exerciseId: id,
|
exerciseId: id,
|
||||||
courseTitle: lesson.course.title,
|
courseTitle: lesson.course.title,
|
||||||
@@ -84,7 +88,8 @@
|
|||||||
lessonNo: lesson.order < 9 ? '0' + (lesson.order + 1) : `${lesson.order}`,
|
lessonNo: lesson.order < 9 ? '0' + (lesson.order + 1) : `${lesson.order}`,
|
||||||
lessonURL,
|
lessonURL,
|
||||||
submissionStatus: submissionItem.status_id,
|
submissionStatus: submissionItem.status_id,
|
||||||
submissionUpdatedAt: dayjs(submissionItem.updated_at).fromNow(true) + ` ago`
|
submissionUpdatedAt: calDateDiff(submissionItem.updated_at),
|
||||||
|
grade
|
||||||
};
|
};
|
||||||
|
|
||||||
_sections[submissionItem.status_id].items.push(item);
|
_sections[submissionItem.status_id].items.push(item);
|
||||||
@@ -106,6 +111,7 @@
|
|||||||
if (!exercises) return;
|
if (!exercises) return;
|
||||||
|
|
||||||
sections = generateSections(exercises);
|
sections = generateSections(exercises);
|
||||||
|
console.log('sections', sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (browser && $profile.id && $currentOrg.id) {
|
$: if (browser && $profile.id && $currentOrg.id) {
|
||||||
@@ -121,7 +127,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center w-full">
|
<div class="flex items-center w-full">
|
||||||
{#each sections as { title, items, className }}
|
{#each sections as { title, items, className, id }}
|
||||||
<div
|
<div
|
||||||
class="min-w-[355px] max-w-[355px] h-[70vh] rounded-md bg-gray-100 dark:bg-black border border-gray-50 dark:border-neutral-700 p-3 mr-3 overflow-hidden"
|
class="min-w-[355px] max-w-[355px] h-[70vh] rounded-md bg-gray-100 dark:bg-black border border-gray-50 dark:border-neutral-700 p-3 mr-3 overflow-hidden"
|
||||||
>
|
>
|
||||||
@@ -139,6 +145,9 @@
|
|||||||
<p class="text-xs">{item.courseTitle}</p>
|
<p class="text-xs">{item.courseTitle}</p>
|
||||||
</a>
|
</a>
|
||||||
<a class="text-black dark:text-white text-md font-bold" href={item.exerciseURL}>
|
<a class="text-black dark:text-white text-md font-bold" href={item.exerciseURL}>
|
||||||
|
{#if id === 3}
|
||||||
|
({item.grade}) -
|
||||||
|
{/if}
|
||||||
{item.exerciseTitle}
|
{item.exerciseTitle}
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
||||||
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
|
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
|
||||||
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
|
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
|
||||||
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
||||||
@@ -23,8 +21,7 @@
|
|||||||
import TextField from '$lib/components/Form/TextField.svelte';
|
import TextField from '$lib/components/Form/TextField.svelte';
|
||||||
import DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
import DeleteCommentModal from '$lib/components/Org/Community/DeleteCommentModal.svelte';
|
||||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||||
|
import { calDateDiff } from '$lib/utils/functions/date';
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
const { slug } = data;
|
const { slug } = data;
|
||||||
@@ -58,7 +55,7 @@
|
|||||||
avatar: data?.author?.profile?.avatar_url || ''
|
avatar: data?.author?.profile?.avatar_url || ''
|
||||||
},
|
},
|
||||||
body: data.body,
|
body: data.body,
|
||||||
createdAt: dayjs(data.created_at).fromNow(true),
|
createdAt: calDateDiff(data.created_at),
|
||||||
comments: data.comments.map((c) => ({
|
comments: data.comments.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
authorId: c.author?.profile?.id || '',
|
authorId: c.author?.profile?.id || '',
|
||||||
@@ -66,7 +63,7 @@
|
|||||||
avatar: c.author?.profile?.avatar_url || '',
|
avatar: c.author?.profile?.avatar_url || '',
|
||||||
votes: c.votes,
|
votes: c.votes,
|
||||||
comment: c.body,
|
comment: c.body,
|
||||||
createdAt: dayjs(c.created_at).fromNow(true)
|
createdAt: calDateDiff(c.created_at)
|
||||||
})),
|
})),
|
||||||
totalComments: 0
|
totalComments: 0
|
||||||
};
|
};
|
||||||
@@ -147,7 +144,7 @@
|
|||||||
avatar: $profile?.avatar_url || '',
|
avatar: $profile?.avatar_url || '',
|
||||||
votes: 0,
|
votes: 0,
|
||||||
comment: _c.body,
|
comment: _c.body,
|
||||||
createdAt: dayjs(_c.created_at).fromNow(true)
|
createdAt: calDateDiff(_c.created_at)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user