Merge branch 'main' of https://gitlab.com/thenextgreat/classroomio
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
Toggle,
|
Toggle,
|
||||||
} from 'carbon-components-svelte';
|
} from 'carbon-components-svelte';
|
||||||
import { goto } from '@sapper/app';
|
import { goto } from '@sapper/app';
|
||||||
|
import { updateCourse } from '../../../../utils/services/courses';
|
||||||
import PrimaryButton from '../../../PrimaryButton/index.svelte';
|
import PrimaryButton from '../../../PrimaryButton/index.svelte';
|
||||||
import TextArea from '../../../Form/TextArea.svelte';
|
import TextArea from '../../../Form/TextArea.svelte';
|
||||||
import Professional from './certificates/Professional.svelte';
|
import Professional from './certificates/Professional.svelte';
|
||||||
@@ -13,24 +14,26 @@
|
|||||||
import { currentOrg } from '../../../../utils/store/org';
|
import { currentOrg } from '../../../../utils/store/org';
|
||||||
|
|
||||||
const studentNamePlaceholder = 'Name of student';
|
const studentNamePlaceholder = 'Name of student';
|
||||||
|
|
||||||
const themes = ['professional', 'plain'];
|
const themes = ['professional', 'plain'];
|
||||||
|
|
||||||
let isSaving = false;
|
let isSaving = false;
|
||||||
|
let Saved = false;
|
||||||
|
let errors = {};
|
||||||
|
|
||||||
const saveCertificate = () => {
|
const saveCertificate = async () => {
|
||||||
// set isSaving to true
|
isSaving = true;
|
||||||
// Validation - make sure description isn't empty
|
if (!$course.description) {
|
||||||
/**
|
errors.description = 'Description cannot be empty';
|
||||||
* Update course description, is_certificate_downloadable and certificate_theme (like in src/components/Course/components/Settings/index.svelte)
|
isSaving = false;
|
||||||
*
|
return;
|
||||||
* await updateCourse($course.id, undefined, {
|
}
|
||||||
description: $course.description,
|
await updateCourse($course.id, undefined, {
|
||||||
is_certificate_downloadable: $course.is_certificate_downloadable,
|
description: $course.description,
|
||||||
certificate_theme: $course.certificate_theme
|
is_certificate_downloadable: $course.is_certificate_downloadable,
|
||||||
});
|
certificate_theme: $course.certificate_theme,
|
||||||
* */
|
});
|
||||||
// set isSaving to false
|
Saved = true;
|
||||||
|
isSaving = false;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -82,6 +85,7 @@
|
|||||||
placeholder="a little description about the course"
|
placeholder="a little description about the course"
|
||||||
bgColor="bg-gray-100"
|
bgColor="bg-gray-100"
|
||||||
bind:value={$course.description}
|
bind:value={$course.description}
|
||||||
|
errorMessage={errors.description}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<Toggle
|
<Toggle
|
||||||
@@ -109,7 +113,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="h-1/5">
|
<div class="h-1/5">
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
label="Save Changes"
|
label={Saved == true ? 'Saved' : 'Save Changes'}
|
||||||
className="rounded-md"
|
className="rounded-md"
|
||||||
onClick={saveCertificate}
|
onClick={saveCertificate}
|
||||||
isLoading={isSaving}
|
isLoading={isSaving}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
import { course } from '../../../store';
|
||||||
|
import UnlockedCertificate from './UnlockedCertificate.svelte';
|
||||||
|
import LockedCertificate from './LockedCertificate.svelte';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{#if $course.is_certificate_downloadable == true}
|
||||||
|
<UnlockedCertificate />
|
||||||
|
{:else}
|
||||||
|
<LockedCertificate />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
<script>
|
||||||
|
import { course } from '../../../store';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="studentContainer flex items-center justify-center w-full">
|
||||||
|
<div class="flex flex-col items-center justify-center w-max h-full gap-2">
|
||||||
|
<img src={`./${$course.certificate_theme}.svg`} alt="Certificate" />
|
||||||
|
<p class="text-xl font-normal text-center">Certificates not available</p>
|
||||||
|
<p class="text-sm font-normal text-center">
|
||||||
|
Your instructor needs to unlock your certificate. <br /> If you need your certificate,
|
||||||
|
please contact your instructor.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.studentContainer {
|
||||||
|
height: 80vh;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
<script>
|
||||||
|
import { course } from '../../../store';
|
||||||
|
import { currentOrg } from '../../../../../utils/store/org';
|
||||||
|
import { profile } from '../../../../../utils/store/user';
|
||||||
|
import PrimaryButton from '../../../../PrimaryButton/index.svelte';
|
||||||
|
|
||||||
|
let isLoading = false;
|
||||||
|
|
||||||
|
const downLoadCertificate = async () => {
|
||||||
|
isLoading = true;
|
||||||
|
const response = await fetch(
|
||||||
|
'https://classroomio-server.fly.dev/downloadCertificate',
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
theme: `${$course.certificate_theme}`,
|
||||||
|
studentName: `${$profile.fullname}`,
|
||||||
|
courseName: `${$course.title}`,
|
||||||
|
courseDescription: `${$course.description}`,
|
||||||
|
orgLogoUrl: `${$currentOrg.avatar_url}`,
|
||||||
|
orgName: `${$currentOrg.name}`,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const data = await response.blob();
|
||||||
|
console.log(data);
|
||||||
|
const file = new Blob([data], { type: 'application/pdf' });
|
||||||
|
const fileURL = URL.createObjectURL(file);
|
||||||
|
isLoading = false;
|
||||||
|
window.open(fileURL);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="studentContainer flex items-center justify-center w-full">
|
||||||
|
<div class="flex flex-col items-center justify-center w-max h-full gap-5">
|
||||||
|
<img src={`./${$course.certificate_theme}.svg`} alt="Certificate" />
|
||||||
|
<p class="text-xl font-normal text-center">Certificate is now available</p>
|
||||||
|
<PrimaryButton
|
||||||
|
label="DownLoad Certificate"
|
||||||
|
className="rounded-md"
|
||||||
|
onClick={downLoadCertificate}
|
||||||
|
{isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.studentContainer {
|
||||||
|
height: 80vh;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<p class="text-xs text-black font-medium">
|
<p class="text-xs text-black font-medium">
|
||||||
has successfully completed a courses in
|
has successfully completed the course
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<p
|
<p
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// import { issueCertificateModal } from '../../../components/Course/components/Ceritficate/store';
|
// import { issueCertificateModal } from '../../../components/Course/components/Ceritficate/store';
|
||||||
// import { Tabs, Tab } from 'carbon-components-svelte';
|
// import { Tabs, Tab } from 'carbon-components-svelte';
|
||||||
// import TabContent from 'carbon-components-svelte/src/Tabs/TabContent.svelte';
|
// import TabContent from 'carbon-components-svelte/src/Tabs/TabContent.svelte';
|
||||||
|
import StudentCertificate from '../../../components/Course/components/Ceritficate/StudentCertificate/Index.svelte';
|
||||||
export let courseId: string = '';
|
export let courseId: string = '';
|
||||||
let isStudent = false;
|
let isStudent = false;
|
||||||
|
|
||||||
@@ -48,7 +48,13 @@
|
|||||||
</PageNav>
|
</PageNav>
|
||||||
|
|
||||||
<PageBody className="w-full mx-0" padding="px-3">
|
<PageBody className="w-full mx-0" padding="px-3">
|
||||||
<Design />
|
<RoleBasedSecurity allowedRoles={[1, 2]}>
|
||||||
|
<Design />
|
||||||
|
</RoleBasedSecurity>
|
||||||
|
<RoleBasedSecurity allowedRoles={[3]}>
|
||||||
|
<StudentCertificate />
|
||||||
|
</RoleBasedSecurity>
|
||||||
|
|
||||||
<!-- <Tabs autoWidth class="border-b border-gray-200">
|
<!-- <Tabs autoWidth class="border-b border-gray-200">
|
||||||
<Tab label="Design" />
|
<Tab label="Design" />
|
||||||
<Tab label="Reports" />
|
<Tab label="Reports" />
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export async function fetchCourse(
|
|||||||
cost,
|
cost,
|
||||||
currency,
|
currency,
|
||||||
metadata,
|
metadata,
|
||||||
|
is_certificate_downloadable,
|
||||||
|
certificate_theme,
|
||||||
lessons:lesson(
|
lessons:lesson(
|
||||||
id, title,public, lesson_at, call_url, is_complete, order, created_at,
|
id, title,public, lesson_at, call_url, is_complete, order, created_at,
|
||||||
note, video_url, slide_url, call_url, totalExercises:exercise(count),
|
note, video_url, slide_url, call_url, totalExercises:exercise(count),
|
||||||
|
|||||||
Reference in New Issue
Block a user