Skip to content

Commit

Permalink
chore: marking scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Drish-xD committed Jul 29, 2024
1 parent f0e481c commit 1d15f6a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/Constants/Options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthType, Grades, Option, Platform, Subjects } from '@/types';
import { AuthType, Grades, MARKING_SCHEMES, Option, Platform, Subjects } from '@/types';

export const TestTypeOptions: Option[] = [
{ value: 'assessment', label: 'Assessment' },
Expand Down Expand Up @@ -41,10 +41,10 @@ export const TestPlatformOptions = Object.values(Platform).map((value) => ({
label: value.toString(),
}));

export const MarkingSchemeOptions: Option[] = [
{ value: '4,-1', label: '4,-1' },
{ value: '1,0', label: '1,0' },
];
export const MarkingSchemeOptions: Option[] = Object.values(MARKING_SCHEMES).map((value) => ({
value: value.toString(),
label: value.toString(),
}));

export const OptionalLimitOptions: Option[] = [
{ value: 'N/A', label: 'N/A' },
Expand Down
2 changes: 1 addition & 1 deletion src/app/(home)/ModalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const displayData = (data: Session, formOptions: Option[]) => {
value: data.meta_data?.shortened_link
? absoluteLink(data.meta_data?.shortened_link)
: 'N/A',
isLink: !!data.portal_link,
isLink: !!data.meta_data?.shortened_link,
},
{
label: 'Admin Link',
Expand Down
1 change: 0 additions & 1 deletion src/app/(home)/Table/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const LinkAction = ({ value, pending }: { value: string; pending: boolean }) =>
>
<LinkIcon className="size-4 mx-auto cursor-pointer" />
</Link>
<CopyBtn value={memoLink} />
</div>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/app/session/[type]/Steps/Platform/Quiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FormBuilder } from '@/components/FormBuilder';
import { useFormContext } from '@/hooks/useFormContext';
import {
FieldSchema,
MARKING_SCHEMES,
Session,
SessionParams,
SessionType,
Expand Down Expand Up @@ -72,6 +73,7 @@ const QuizForm: FC = () => {
placeholder: 'Select a marking scheme',
label: 'Marking Scheme',
disabled: type === SessionType.EDIT,
hide: true,
},
optionalLimit: {
type: 'select',
Expand Down Expand Up @@ -104,14 +106,16 @@ const QuizForm: FC = () => {
);

const onSubmit = useCallback((data: quizFields) => {
const isHomework = data.testType === 'homework';

const addedData: Session = {
meta_data: {
course: data.course,
stream: data.stream,
test_format: data.testFormat,
test_purpose: data.testPurpose,
test_type: data.testType,
marking_scheme: data.markingScheme,
marking_scheme: isHomework ? MARKING_SCHEMES['1, 0'] : MARKING_SCHEMES['4,-1'],
optional_limits: data.optionalLimit,
cms_test_id: data.cmsUrl,
show_answers: data.showAnswers,
Expand Down
5 changes: 5 additions & 0 deletions src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ export enum Subjects {
}

export const Grades = [9, 10, 11, 12, 13] as const;

export const MARKING_SCHEMES = {
'4,-1': '4,-1',
'1, 0': '1, 0',
} as const;
7 changes: 1 addition & 6 deletions src/types/form.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ export const quizSchema = z.object({
(value) => TestTypeOptions.some((option) => option.value === value),
'Invalid option selected'
),
markingScheme: z
.string({ required_error: 'This field is required' })
.refine(
(value) => MarkingSchemeOptions.some((option) => option.value === value),
'Invalid option selected'
),
markingScheme: z.string().optional(),
optionalLimit: z
.string({ required_error: 'This field is required' })
.refine(
Expand Down

0 comments on commit 1d15f6a

Please sign in to comment.