diff --git a/src/Components/CustomFields/ImageBoxField/ImageBoxField.scss b/src/Components/CustomFields/ImageBoxField/ImageBoxField.scss index 20a6418..66e2f2f 100644 --- a/src/Components/CustomFields/ImageBoxField/ImageBoxField.scss +++ b/src/Components/CustomFields/ImageBoxField/ImageBoxField.scss @@ -8,6 +8,7 @@ border: max(1.5px, 0.1vw) dashed #a9c3f1; margin-block: 10px; border-radius: 5px; + z-index: 9999999 !important; .ImageBoxIcon { cursor: pointer; } diff --git a/src/Layout/Dashboard/FormikFormModel.tsx b/src/Layout/Dashboard/FormikFormModel.tsx index 6019065..c12a9cc 100644 --- a/src/Layout/Dashboard/FormikFormModel.tsx +++ b/src/Layout/Dashboard/FormikFormModel.tsx @@ -29,6 +29,7 @@ const FormikFormModel: React.FC = ({ initialValues={initialValues} validationSchema={validationSchema} onSubmit={handleSubmit} + > {(formik) => { useEffect(() => { diff --git a/src/Pages/Admin/Reseller/Form/ImageBoxField/ImageBoxField.scss b/src/Pages/Admin/Reseller/Form/ImageBoxField/ImageBoxField.scss index 20a6418..66e2f2f 100644 --- a/src/Pages/Admin/Reseller/Form/ImageBoxField/ImageBoxField.scss +++ b/src/Pages/Admin/Reseller/Form/ImageBoxField/ImageBoxField.scss @@ -8,6 +8,7 @@ border: max(1.5px, 0.1vw) dashed #a9c3f1; margin-block: 10px; border-radius: 5px; + z-index: 9999999 !important; .ImageBoxIcon { cursor: pointer; } diff --git a/src/Pages/Admin/lesson/DrapableTable.tsx b/src/Pages/Admin/lesson/DrapableTable.tsx index 6a0014b..337cdbb 100644 --- a/src/Pages/Admin/lesson/DrapableTable.tsx +++ b/src/Pages/Admin/lesson/DrapableTable.tsx @@ -91,11 +91,11 @@ const Row: React.FC = (props) => { }; const DrapableTable: React.FC = () => { - const { subject_id } = useParams(); + const { unit_id } = useParams(); const { filterState } = useFilterState(); const response = useGetAllLesson({ - subject_id: subject_id, + unit_id: unit_id, pagination: false, ...filterState, }); diff --git a/src/Pages/Admin/question/AddPage.tsx b/src/Pages/Admin/question/AddPage.tsx index 87f983c..295391e 100644 --- a/src/Pages/Admin/question/AddPage.tsx +++ b/src/Pages/Admin/question/AddPage.tsx @@ -19,7 +19,6 @@ import { Question } from "../../../types/Item"; import BaseForm from "./Model/Malty/Form"; import ModelForm from "./Model/ModelForm"; import { toast } from "react-toastify"; -import { useFormikContext } from "formik"; const AcceptModal = lazy(() => import("./Model/AcceptModal")); const AddPage: React.FC = () => { @@ -40,14 +39,16 @@ const AddPage: React.FC = () => { console.log(objectToEdit,"objectToEdit"); - const handleSubmit = ( values: any, { resetForm }: { resetForm: () => void }, ) => { + const DataToSend = structuredClone(values); setTagsSearch(null); + const canAnswersBeShuffled = DataToSend?.canAnswersBeShuffled ? 1 : 0; + if (isBseQuestion || DataToSend?.isBase === 1) { const newBseQuestion = { subject_id: subject_id, @@ -137,8 +138,12 @@ console.log(objectToEdit,"objectToEdit"); }; + + useEffect(() => { + + console.log("all api success"); if(isSuccess){ @@ -146,6 +151,8 @@ console.log(objectToEdit,"objectToEdit"); } }, [isSuccess]) + + if (isBseQuestion) { return (
diff --git a/src/Pages/Admin/question/EditPage.tsx b/src/Pages/Admin/question/EditPage.tsx index fc4a811..8bea085 100644 --- a/src/Pages/Admin/question/EditPage.tsx +++ b/src/Pages/Admin/question/EditPage.tsx @@ -93,7 +93,7 @@ const EditPage: React.FC = () => { console.log(item); if (item?.id) { const itemToSend = structuredClone(item); - const keysToRemove = ["content_image"]; + const keysToRemove = ["content_image","hint"]; const updatedObject = removeStringKeys(itemToSend, keysToRemove); console.log(updatedObject, "updatedObject"); @@ -143,7 +143,7 @@ const EditPage: React.FC = () => { }); } else { - const keysToRemove = ["content_image"]; + const keysToRemove = ["content_image","hint"]; console.log(DataToSend); const updatedObject = removeStringKeys(DataToSend, keysToRemove); delete updatedObject["parent_id"]; @@ -156,9 +156,11 @@ const EditPage: React.FC = () => { const newAnswers = [] as any; if(updatedObject?.answers?.length > 0){ - const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1) + const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1 || answer?.isCorrect === true) + const isValidAnswers2 = updatedObject?.answers?.filter((answer: any) => answer?.isCorrect === 1 || answer?.isCorrect === true ).length > 1; + console.log(isValidAnswers2); - if(!isValidAnswers){ + if(!isValidAnswers || isValidAnswers2){ toast.error(t("validation.at_least_one_answer_should_be_correct")); return; } diff --git a/src/Pages/Admin/question/Model/Field/CheckboxField.tsx b/src/Pages/Admin/question/Model/Field/CheckboxField.tsx index d758345..1503497 100644 --- a/src/Pages/Admin/question/Model/Field/CheckboxField.tsx +++ b/src/Pages/Admin/question/Model/Field/CheckboxField.tsx @@ -16,7 +16,7 @@ const CheckboxField = ({ const [t] = useTranslation(); const CheckboxhandleChange = (value: any, index: number) => { const allAreZero = formik?.values?.answers?.some( - (item: any) => item.isCorrect === 1, + (item: any) => item.isCorrect === 1 || item.isCorrect === true, ); if (allAreZero) { @@ -35,7 +35,7 @@ const CheckboxField = ({ {t(`input.${label ? label : name}`)} diff --git a/src/Pages/Admin/question/Model/formUtil.ts b/src/Pages/Admin/question/Model/formUtil.ts index 9352a46..0fb15d9 100644 --- a/src/Pages/Admin/question/Model/formUtil.ts +++ b/src/Pages/Admin/question/Model/formUtil.ts @@ -1,5 +1,6 @@ import * as Yup from "yup"; import { Question } from "../../../../types/Item"; +import { toast } from "react-toastify"; export const getInitialValues = (objectToEdit: Question): any => { @@ -13,7 +14,7 @@ export const getInitialValues = (objectToEdit: Question): any => { content_image: objectToEdit?.content_image ?? "", subject_id: objectToEdit?.subject_id ?? "", canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, - hint: objectToEdit?.hint ?? "", + hint: objectToEdit?.hint ?? null, isBase: 0, parent_id: objectToEdit?.parent_id ?? "", answers: objectToEdit?.answers ?? [], @@ -33,7 +34,13 @@ export const getValidationSchema = () => { content_image: Yup.string().nullable(), isCorrect: Yup.boolean(), }), - ) + ).test( + 'at-least-one-correct', + 'At least one answer must be correct', + (answers:any) => { + return answers.some((answer:any) => answer.isCorrect === true); + } + ), }); }; @@ -44,8 +51,8 @@ export const getInitialValuesBase = (objectToEdit: Question): any => { id: tag?.id, name: tag?.name, })); - console.log(tags); - + console.log(item,"item"); + return { ...item, canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, @@ -65,7 +72,7 @@ export const getInitialValuesBase = (objectToEdit: Question): any => { isBase: 1, parent_id: objectToEdit?.parent_id ?? "", canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, - hint: objectToEdit?.hint ?? "", + hint: objectToEdit?.hint ?? null, Questions: questions, }; }; @@ -87,7 +94,15 @@ export const getValidationSchemaBase = () => { isCorrect: Yup.boolean(), }), ) - .nullable("required"), + .test( + 'at-least-one-correct', + 'At least one answer must be correct', + (answers:any) => { + console.log(answers,"answers"); + + return answers.some((answer:any) => answer.isCorrect === true); + } + ), }), ), }); diff --git a/src/Pages/Admin/subject/Table/TablePage.tsx b/src/Pages/Admin/subject/Table/TablePage.tsx index e3b9089..0e8a0c7 100644 --- a/src/Pages/Admin/subject/Table/TablePage.tsx +++ b/src/Pages/Admin/subject/Table/TablePage.tsx @@ -6,11 +6,11 @@ import { ParamsEnum } from "../../../../enums/params"; import { useFilterState } from "../../../../Components/Utils/Filter/FilterState"; const TablePage: React.FC = () => { - const { course_id } = useParams(); + const { grade_id } = useParams(); const { filterState } = useFilterState(); const response = useGetAllSubject({ - course_id: course_id, + grade_id: grade_id, pagination: true, ...filterState, }); diff --git a/src/Styles/Pages/exercise.scss b/src/Styles/Pages/exercise.scss index d4debd3..b4662fc 100644 --- a/src/Styles/Pages/exercise.scss +++ b/src/Styles/Pages/exercise.scss @@ -212,5 +212,6 @@ .HolderQuestion{ - transform: translateY(25px); + transform: translateY(55px); + z-index: -1; } \ No newline at end of file diff --git a/src/translate/ar.json b/src/translate/ar.json index 3ca9b5d..824db3d 100644 --- a/src/translate/ar.json +++ b/src/translate/ar.json @@ -46,7 +46,7 @@ "grade_to_pass_must_be_less_than_max_grade": "يجب أن تكون درجة النجاح أقل من الحد الأقصى للدرجة", "max_mark_must_be_greater_than_min_mark_to_pass": "يجب ان تكون اكبر من علامة النجاح", "Sorry, the question must have at least one option": "عذرًا، يجب أن يحتوي السؤال على خيار واحد على الأقل", - "at_least_one_answer_should_be_correct":"يجب أن تكون إجابة واحدة على الأقل صحيحة" + "at_least_one_answer_should_be_correct":"يجب أن تكون إجابة واحدة صحيحة" }, "header": { "register_students": "تسجيل الطلاب",