CLASSROOMIO-T-227: Exercise Statistics
CLASSROOMIO-T-227: 🔥 🔥 🔥 🔥 Improvements CLASSROOMIO-T-227:Worked on the Exercise Statistics CLASSROOMIO-T-227:Worked on the Exercise Statistics CLASSROOMIO-T-227:Worked on the Exercise Statistics Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> Co-authored-by: Ifeanyi Nwosu <ifeanyi@digdippa.com> Co-authored-by: Rotimi Best <rotimiibitoyeemma@gmail.com> Merge-request: CLASSROOMIO-MR-111 Merged-by: Best Admin <best@digdippa.com>
This commit is contained in:
committed by
Space Cloud
co-authored by
Rotimi Best
Rotimi Best
parent
b21d5923e6
commit
5c8571e571
@@ -25,6 +25,7 @@
|
||||
let comments: LessonComment[] = [];
|
||||
let groupmember: GroupPerson | undefined;
|
||||
let isSaving: boolean = false;
|
||||
let isFetched = false;
|
||||
|
||||
interface FetchComments {
|
||||
comment: string;
|
||||
@@ -155,6 +156,7 @@
|
||||
console.error('error');
|
||||
return;
|
||||
}
|
||||
console.log('fetch comments', data);
|
||||
|
||||
comments = data.map((lessonComment) => {
|
||||
return {
|
||||
@@ -167,6 +169,7 @@
|
||||
: lessonComment.groupmember.profile.fullname
|
||||
};
|
||||
});
|
||||
isFetched = true;
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
@@ -185,7 +188,7 @@
|
||||
supabase.removeChannel(lessonCommentChannel);
|
||||
});
|
||||
|
||||
$: fetchComments($group.people, $lesson.id);
|
||||
$: !isFetched && fetchComments($group.people, $lesson.id);
|
||||
</script>
|
||||
|
||||
<PageNav title="Comments" overidableStyle="padding: 0 10px">
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import { snackbar } from '$lib/components/Snackbar/store';
|
||||
import type { PollType } from './types';
|
||||
import { getSupabase } from '$lib/utils/functions/supabase';
|
||||
import type { GroupPerson } from '$lib/utils/types';
|
||||
|
||||
const supabase = getSupabase();
|
||||
|
||||
export async function createPoll(poll: PollType, groupmember: GroupPerson, courseId: string) {
|
||||
if (!groupmember) return;
|
||||
|
||||
const { data: newPolls, error } = await supabase
|
||||
.from('apps_poll')
|
||||
.insert({
|
||||
question: poll.question,
|
||||
authorId: groupmember.id,
|
||||
isPublic: poll.isPublic,
|
||||
status: poll.question,
|
||||
expiration: poll.expiration,
|
||||
courseId
|
||||
})
|
||||
.select();
|
||||
|
||||
if (!newPolls || error) {
|
||||
snackbar.error('Error creating poll');
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
|
||||
const [newPoll] = newPolls;
|
||||
|
||||
if (!newPoll.id) return;
|
||||
poll = {
|
||||
poll,
|
||||
...newPoll
|
||||
};
|
||||
|
||||
poll.options = await Promise.all(
|
||||
poll.options.map(async (option) => {
|
||||
const { data: newPollOptions, error: newPollOptionsError } = await supabase
|
||||
.from('apps_poll_option')
|
||||
.insert({
|
||||
poll_id: newPoll.id,
|
||||
label: option.label
|
||||
})
|
||||
.select();
|
||||
|
||||
if (!newPollOptions || newPollOptionsError) {
|
||||
return option;
|
||||
}
|
||||
|
||||
const [newPollOption] = newPollOptions;
|
||||
option.id = newPollOption.id;
|
||||
|
||||
return option;
|
||||
})
|
||||
);
|
||||
|
||||
return poll;
|
||||
}
|
||||
|
||||
export async function fetchPolls(courseId: string) {
|
||||
const {} = await supabase
|
||||
.from('app_poll')
|
||||
.select(
|
||||
`
|
||||
id,
|
||||
question,
|
||||
isPublic,
|
||||
status,
|
||||
expiration
|
||||
groupmember:authorId(
|
||||
profile!inner(
|
||||
id,
|
||||
fullname,
|
||||
avatar_url
|
||||
)
|
||||
)
|
||||
apps_poll_option!inner(
|
||||
id,
|
||||
label,
|
||||
)
|
||||
`
|
||||
)
|
||||
.match({
|
||||
courseId
|
||||
});
|
||||
}
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
{#if !!$apps.selectedApp}
|
||||
<div
|
||||
class={`app cursor-auto lg:cursor-ew-resize max-w-[350px] transition ease-in-out delay-150 duration-100`}
|
||||
class="app max-w-[350px] transition ease-in-out delay-150 duration-100"
|
||||
bind:this={appContentRef}
|
||||
>
|
||||
{#key $apps.selectedApp}
|
||||
|
||||
Reference in New Issue
Block a user