2023-06-17 19:11:29 +00:00
|
|
|
<script>
|
|
|
|
|
import pluralize from 'pluralize';
|
2023-08-11 00:19:53 +01:00
|
|
|
import { ImageLoader } from 'carbon-components-svelte';
|
2023-08-02 19:35:27 +01:00
|
|
|
import OverflowMenuHorizontalIcon from 'carbon-icons-svelte/lib/OverflowMenuHorizontal.svelte';
|
|
|
|
|
import { currentOrgPath } from '$lib/utils/store/org';
|
|
|
|
|
import Dropdown from '$lib/components/Dropdown/index.svelte';
|
|
|
|
|
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
|
|
|
|
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
|
|
|
|
import { onRename, onDelete } from '$lib/utils/services/org/quiz';
|
|
|
|
|
import { themeImages } from '$lib/utils/constants/quiz';
|
2023-10-02 04:15:01 +01:00
|
|
|
import { calDateDiff } from '$lib/utils/functions/date';
|
2023-06-17 19:11:29 +00:00
|
|
|
|
|
|
|
|
export let quiz;
|
|
|
|
|
export let totalQuestions;
|
|
|
|
|
|
|
|
|
|
function getOptions() {
|
|
|
|
|
return [
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Edit',
|
|
|
|
|
// onClick: onEdit(quiz),
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Share',
|
|
|
|
|
// onClick: onShare(quiz),
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Report',
|
|
|
|
|
// onClick: onReport(quiz),
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
label: 'Rename',
|
|
|
|
|
onClick() {
|
|
|
|
|
onRename(quiz);
|
2023-08-11 00:19:53 +01:00
|
|
|
}
|
2023-06-17 19:11:29 +00:00
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Make a copy',
|
|
|
|
|
// onClick() {
|
|
|
|
|
// onMakeCopy(quiz);
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
label: 'Delete',
|
|
|
|
|
onClick() {
|
|
|
|
|
onDelete(quiz);
|
2023-08-11 00:19:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-06-17 19:11:29 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startQuiz() {}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if quiz}
|
|
|
|
|
<div
|
2023-09-16 22:44:20 +01:00
|
|
|
class="root w-full border hover:shadow-2xl transition ease-in-out rounded-lg bg-gray-100 dark:bg-black mb-5 relative flex flex-col lg:flex-row p-3"
|
2023-06-17 19:11:29 +00:00
|
|
|
>
|
2023-08-11 00:19:53 +01:00
|
|
|
<ImageLoader
|
2023-06-17 19:11:29 +00:00
|
|
|
src={themeImages[quiz.theme]?.card || themeImages.standard.card}
|
|
|
|
|
alt="quiz-card"
|
2023-09-08 09:17:05 +00:00
|
|
|
style="max-width:300px, min-width: 200px;"
|
2023-06-17 19:11:29 +00:00
|
|
|
/>
|
|
|
|
|
|
2023-09-08 09:17:05 +00:00
|
|
|
<div class="p-2 md:p-5 flex flex-col justify-between w-full">
|
2023-06-17 19:11:29 +00:00
|
|
|
<div class="flex justify-between">
|
2023-09-08 09:17:05 +00:00
|
|
|
<h4 class="dark:text-white title text-md font-bold capitalize">
|
2023-06-17 19:11:29 +00:00
|
|
|
<a href="{$currentOrgPath}/quiz/{quiz.id}">{quiz.title}</a>
|
|
|
|
|
</h4>
|
|
|
|
|
|
2023-08-11 00:19:53 +01:00
|
|
|
<Dropdown options={getOptions()} classNames="absolute top-4 right-4" isIcon={true}>
|
2023-06-17 19:11:29 +00:00
|
|
|
<div class="p-1 rounded-full bg-gray-200 dark:bg-gray-600">
|
2023-08-02 19:35:27 +01:00
|
|
|
<OverflowMenuHorizontalIcon size={20} class="carbon-icon active" />
|
2023-06-17 19:11:29 +00:00
|
|
|
</div>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-09-08 09:17:05 +00:00
|
|
|
<div class="flex md:flex-row flex-col justify-between">
|
2023-06-17 19:11:29 +00:00
|
|
|
<div>
|
|
|
|
|
<p class="mb-2">{pluralize('question', totalQuestions, true)}</p>
|
2023-10-02 04:15:01 +01:00
|
|
|
<p class="mb-2 md:mb-0">Updated {calDateDiff(quiz.updated_at)}</p>
|
2023-06-17 19:11:29 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<PrimaryButton
|
|
|
|
|
className="px-6 py-3"
|
|
|
|
|
variant={VARIANTS.OUTLINED}
|
|
|
|
|
label="Start Quiz"
|
|
|
|
|
onClick={startQuiz}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.root {
|
2023-09-08 09:17:05 +00:00
|
|
|
min-height: 180px;
|
2023-06-17 19:11:29 +00:00
|
|
|
}
|
|
|
|
|
</style>
|