CLASSROOMIO-T-154: Notify tutors when a student submits an exercise

CLASSROOMIO-T-154: Fix textarea grade issue

CLASSROOMIO-T-154: Get it to work properly

Merge branch 'CLASSROOMIO-T-154' of https://gitlab.com/thenextgreat/classroomio into CLASSROOMIO-T-154

CLASSROOMIO-T-154: PR fixes
CLASSROOMIO-T-154:Updated the code

Merge branch 'main' into CLASSROOMIO-T-154

CLASSROOMIO-T-154:Notify tutors when a student submits an exercise


Co-authored-by: Ifeanyi Nwosu <ifeanyi@digdippa.com>
Co-authored-by: Rotimi Best <rotimiibitoyeemma@gmail.com>


Merge-request: CLASSROOMIO-MR-109
Merged-by: Best Admin <best@digdippa.com>
This commit is contained in:
emmanuel
2023-10-20 04:16:07 +00:00
committed by Space Cloud
co-authored by Rotimi Best
parent 91f28a345f
commit 0f2d60534d
15 changed files with 159 additions and 91 deletions
@@ -0,0 +1,38 @@
import { json } from '@sveltejs/kit';
import { getSupabase } from '$lib/utils/functions/supabase';
import { sendEmail } from '$lib/utils/services/notification/send';
const supabase = getSupabase();
export async function POST({ request }) {
const { to, content, orgName, exerciseTitle } = await request.json();
const accessToken = request.headers.get('Authorization') || '';
if (!to || !content || !orgName) {
return json({ success: false, message: 'Missing required fields' }, { status: 400 });
}
let user;
try {
const { data } = await supabase.auth.getUser(accessToken);
user = data.user;
} catch (error) {
console.error(error);
}
if (!user) {
return json({ success: false, message: 'Unauthenticated user' }, { status: 401 });
}
await sendEmail({
from: `"${orgName} (via ClassroomIO.com)" <help@classroomio.com>`,
to,
subject: `[Submitted]: ${exerciseTitle}`,
content
});
return json({
success: true,
message: 'Email sent'
});
}
@@ -27,7 +27,7 @@ export async function POST({ request }) {
await sendEmail({
from: `"${orgName} (via ClassroomIO.com)" <help@classroomio.com>`,
to,
subject: `Submission Update`,
subject: 'Submission Update',
content
});
+2 -3
View File
@@ -33,6 +33,7 @@
import { profile } from '$lib/utils/store/user';
import { snackbar } from '$lib/components/Snackbar/store';
import Avatar from '$lib/components/Avatar/index.svelte';
import type { GroupPerson } from '$lib/utils/types';
export let data;
const { courseId } = data;
@@ -62,9 +63,7 @@
async function deletePerson() {
$group.people = $group.people.filter((person: { id: string }) => person.id !== member.id);
$group.tutors = $group.tutors.filter(
(person: { memberId: string }) => person.memberId !== member.id
);
$group.tutors = $group.tutors.filter((person: GroupPerson) => person.memberId !== member.id);
await deleteGroupMember(member.id);
}
@@ -114,12 +114,9 @@
${
status_id == 3
? `<p>Your score was ${totalMark}/${maxMark}</p>
<div>
<a class="button" href="${exerciseLink}">View your Result</a>
<div>`
: `<div>
<a class="button" href="${exerciseLink}">Open Exercise</a>
<div>`
<a class="button" href="${exerciseLink}">View your Result</a>
`
: `<a class="button" href="${exerciseLink}">Open Exercise</a>`
}
<p>This exercise is for <strong>${
lessonDetails.title
@@ -254,7 +251,7 @@
total: totalPoints
}).then((res) => console.log('Updated submission', res));
snackbar.success();
snackbar.success('Grading saved and student notified');
await Promise.all(updates);
}