Files
classroomio/apps/dashboard/src/lib/features/ui/question/grade.svelte
T

41 lines
1.0 KiB
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;
}
if (grade && grade < 0) {
snackbar.error('grade cant be less than 0');
grade = 0;
}
2025-11-01 15:49:29 +01:00
});
</script>
2026-03-09 11:18:22 +01:00
<div class="flex items-center">
<InputField
2024-05-13 19:35:06 +01:00
placeholder={$t('course.navItem.lessons.exercises.new_exercise_modal.points')}
bind:value={grade}
max={gradeMax}
min={0}
2024-05-13 19:35:06 +01:00
type="number"
2026-03-09 11:18:22 +01:00
inputClassName="!w-16"
2024-05-13 19:35:06 +01:00
isDisabled={disableGrading}
/>
2026-03-09 11:18:22 +01:00
<p class="ml-2 flex items-center text-base dark:text-white">
2024-05-13 19:35:06 +01:00
<span class="mr-1">/</span> <span>{gradeMax}</span>
</p>
</div>