Files
classroomio/apps/dashboard/src/lib/components/Question/Grade.svelte
T

37 lines
989 B
Svelte
Raw Normal View History

<script lang="ts">
import { InputField } from '@cio/ui/custom/input-field';
2024-04-19 05:45:48 +01:00
import { t } from '$lib/utils/functions/translations';
import { snackbar } from '$features/ui/snackbar/store';
2024-04-19 05:45:48 +01:00
2025-11-01 15:49:29 +01:00
interface Props {
gradeMax?: number;
disableGrading?: boolean;
grade?: number | undefined;
2024-05-13 19:35:06 +01:00
}
2025-11-01 15:49:29 +01:00
let { gradeMax = 0, disableGrading = false, grade = $bindable(0) }: Props = $props();
$effect(() => {
if (grade && grade > gradeMax) {
snackbar.error('grade cant be more than max value');
grade = gradeMax;
}
});
</script>
2024-05-13 19:35:06 +01:00
<div class="flex items-center font-semibold">
<InputField
2024-05-13 19:35:06 +01:00
placeholder={$t('course.navItem.lessons.exercises.new_exercise_modal.points')}
bind:value={grade}
max={gradeMax}
type="number"
className="w-12"
inputClassName="h-10"
isDisabled={disableGrading}
/>
2025-11-01 15:49:29 +01:00
<p class="ml-2 flex items-center text-base font-semibold dark:text-white">
2024-05-13 19:35:06 +01:00
<span class="mr-1">/</span> <span>{gradeMax}</span>
</p>
</div>