feat: grade exercise with AI (#296)

* working on the UI of the grading

* working on the grading function of the radio and checkboxes

* ai grading fully implemented with dummy functions for generating scores

* working on the openai response

* working on the openai response

* finished with the ai_grading

* finished with the ai_grading

* creating new migration file

* working on reviews

* updated the translations

* improvements

---------

Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Em_Dev
2024-05-13 19:35:06 +01:00
committed by GitHub
co-authored by Rotimi Best
parent fc8b8e1898
commit e243564113
37 changed files with 688 additions and 150 deletions
@@ -0,0 +1,53 @@
<script>
import { VARIANTS } from '../PrimaryButton/constants';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { t } from '$lib/utils/functions/translations';
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
export let reason = '';
export let isLoading = false;
export let rejectGrade = () => {};
export let acceptGrade = () => {};
</script>
<div class="border rounded-md">
{#if isLoading}
<div class="flex w-full px-2 py-4">
<div class="w-full flex flex-row items-start space-x-4">
<img src="/ai.svg" alt="alt" class="animate-pulse" />
<div class="w-full">
<SkeletonText width="100%" paragraph lines={3} />
</div>
</div>
<div class="flex space-x-2">
<SkeletonPlaceholder style="height: 2rem; width: 5rem;" />
<SkeletonPlaceholder style="height: 2rem; width: 5rem;" />
</div>
</div>
{:else}
<div class="flex items-start justify-between px-2 py-4">
<div class="flex items-center space-x-4">
<img src="/ai.svg" alt="alt" />
<p class="font-normal text-sm">
{reason}
</p>
</div>
<div class="flex space-x-2">
<PrimaryButton
variant={VARIANTS.CONTAINED_SUCCESS}
label={$t('course.navItem.submissions.grading_modal.accept_grade')}
className="rounded-none py-1 px-2"
disablePadding={true}
onClick={acceptGrade}
/>
<PrimaryButton
variant={VARIANTS.CONTAINED_DANGER}
label={$t('course.navItem.submissions.grading_modal.reject_grade')}
className="rounded-none py-1 px-2"
disablePadding={true}
onClick={rejectGrade}
/>
</div>
</div>
{/if}
</div>