Compare commits

..

No commits in common. "e17629a9ba48a8618d9e739242722694534b6b33" and "08bd2d245d17c3b1f7d255216b45d2335e26b8de" have entirely different histories.

11 changed files with 20 additions and 48 deletions

View File

@ -8,7 +8,6 @@
border: max(1.5px, 0.1vw) dashed #a9c3f1; border: max(1.5px, 0.1vw) dashed #a9c3f1;
margin-block: 10px; margin-block: 10px;
border-radius: 5px; border-radius: 5px;
z-index: 9999999 !important;
.ImageBoxIcon { .ImageBoxIcon {
cursor: pointer; cursor: pointer;
} }

View File

@ -29,7 +29,6 @@ const FormikFormModel: React.FC<FormikFormProps> = ({
initialValues={initialValues} initialValues={initialValues}
validationSchema={validationSchema} validationSchema={validationSchema}
onSubmit={handleSubmit} onSubmit={handleSubmit}
> >
{(formik) => { {(formik) => {
useEffect(() => { useEffect(() => {

View File

@ -8,7 +8,6 @@
border: max(1.5px, 0.1vw) dashed #a9c3f1; border: max(1.5px, 0.1vw) dashed #a9c3f1;
margin-block: 10px; margin-block: 10px;
border-radius: 5px; border-radius: 5px;
z-index: 9999999 !important;
.ImageBoxIcon { .ImageBoxIcon {
cursor: pointer; cursor: pointer;
} }

View File

@ -91,11 +91,11 @@ const Row: React.FC<RowProps> = (props) => {
}; };
const DrapableTable: React.FC = () => { const DrapableTable: React.FC = () => {
const { unit_id } = useParams<ParamsEnum>(); const { subject_id } = useParams<ParamsEnum>();
const { filterState } = useFilterState(); const { filterState } = useFilterState();
const response = useGetAllLesson({ const response = useGetAllLesson({
unit_id: unit_id, subject_id: subject_id,
pagination: false, pagination: false,
...filterState, ...filterState,
}); });

View File

@ -19,6 +19,7 @@ import { Question } from "../../../types/Item";
import BaseForm from "./Model/Malty/Form"; import BaseForm from "./Model/Malty/Form";
import ModelForm from "./Model/ModelForm"; import ModelForm from "./Model/ModelForm";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import { useFormikContext } from "formik";
const AcceptModal = lazy(() => import("./Model/AcceptModal")); const AcceptModal = lazy(() => import("./Model/AcceptModal"));
const AddPage: React.FC = () => { const AddPage: React.FC = () => {
@ -39,16 +40,14 @@ const AddPage: React.FC = () => {
console.log(objectToEdit,"objectToEdit"); console.log(objectToEdit,"objectToEdit");
const handleSubmit = ( const handleSubmit = (
values: any, values: any,
{ resetForm }: { resetForm: () => void }, { resetForm }: { resetForm: () => void },
) => { ) => {
const DataToSend = structuredClone(values); const DataToSend = structuredClone(values);
setTagsSearch(null); setTagsSearch(null);
const canAnswersBeShuffled = DataToSend?.canAnswersBeShuffled ? 1 : 0; const canAnswersBeShuffled = DataToSend?.canAnswersBeShuffled ? 1 : 0;
if (isBseQuestion || DataToSend?.isBase === 1) { if (isBseQuestion || DataToSend?.isBase === 1) {
const newBseQuestion = { const newBseQuestion = {
subject_id: subject_id, subject_id: subject_id,
@ -139,11 +138,7 @@ console.log(objectToEdit,"objectToEdit");
useEffect(() => { useEffect(() => {
console.log("all api success"); console.log("all api success");
if(isSuccess){ if(isSuccess){
@ -151,8 +146,6 @@ console.log(objectToEdit,"objectToEdit");
} }
}, [isSuccess]) }, [isSuccess])
if (isBseQuestion) { if (isBseQuestion) {
return ( return (
<div className="exercise_add"> <div className="exercise_add">

View File

@ -93,7 +93,7 @@ const EditPage: React.FC = () => {
console.log(item); console.log(item);
if (item?.id) { if (item?.id) {
const itemToSend = structuredClone(item); const itemToSend = structuredClone(item);
const keysToRemove = ["content_image","hint"]; const keysToRemove = ["content_image"];
const updatedObject = removeStringKeys(itemToSend, keysToRemove); const updatedObject = removeStringKeys(itemToSend, keysToRemove);
console.log(updatedObject, "updatedObject"); console.log(updatedObject, "updatedObject");
@ -143,7 +143,7 @@ const EditPage: React.FC = () => {
}); });
} else { } else {
const keysToRemove = ["content_image","hint"]; const keysToRemove = ["content_image"];
console.log(DataToSend); console.log(DataToSend);
const updatedObject = removeStringKeys(DataToSend, keysToRemove); const updatedObject = removeStringKeys(DataToSend, keysToRemove);
delete updatedObject["parent_id"]; delete updatedObject["parent_id"];
@ -156,11 +156,9 @@ const EditPage: React.FC = () => {
const newAnswers = [] as any; const newAnswers = [] as any;
if(updatedObject?.answers?.length > 0){ if(updatedObject?.answers?.length > 0){
const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1 || answer?.isCorrect === true) const isValidAnswers = updatedObject?.answers?.some((answer:any) => answer?.isCorrect === 1)
const isValidAnswers2 = updatedObject?.answers?.filter((answer: any) => answer?.isCorrect === 1 || answer?.isCorrect === true ).length > 1;
console.log(isValidAnswers2);
if(!isValidAnswers || isValidAnswers2){ if(!isValidAnswers){
toast.error(t("validation.at_least_one_answer_should_be_correct")); toast.error(t("validation.at_least_one_answer_should_be_correct"));
return; return;
} }

View File

@ -16,7 +16,7 @@ const CheckboxField = ({
const [t] = useTranslation(); const [t] = useTranslation();
const CheckboxhandleChange = (value: any, index: number) => { const CheckboxhandleChange = (value: any, index: number) => {
const allAreZero = formik?.values?.answers?.some( const allAreZero = formik?.values?.answers?.some(
(item: any) => item.isCorrect === 1 || item.isCorrect === true, (item: any) => item.isCorrect === 1,
); );
if (allAreZero) { if (allAreZero) {
@ -35,7 +35,7 @@ const CheckboxField = ({
<Checkbox <Checkbox
onChange={onChange || CheckboxhandleChange} onChange={onChange || CheckboxhandleChange}
disabled={isDisabled} disabled={isDisabled}
checked={formik.values?.answers?.[name]?.isCorrect === 1 || formik.values?.answers?.[name]?.isCorrect === true} checked={formik.values?.answers?.[name]?.isCorrect === 1}
className={className} className={className}
> >
{t(`input.${label ? label : name}`)} {t(`input.${label ? label : name}`)}

View File

@ -1,6 +1,5 @@
import * as Yup from "yup"; import * as Yup from "yup";
import { Question } from "../../../../types/Item"; import { Question } from "../../../../types/Item";
import { toast } from "react-toastify";
export const getInitialValues = (objectToEdit: Question): any => { export const getInitialValues = (objectToEdit: Question): any => {
@ -14,7 +13,7 @@ export const getInitialValues = (objectToEdit: Question): any => {
content_image: objectToEdit?.content_image ?? "", content_image: objectToEdit?.content_image ?? "",
subject_id: objectToEdit?.subject_id ?? "", subject_id: objectToEdit?.subject_id ?? "",
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
hint: objectToEdit?.hint ?? null, hint: objectToEdit?.hint ?? "",
isBase: 0, isBase: 0,
parent_id: objectToEdit?.parent_id ?? "", parent_id: objectToEdit?.parent_id ?? "",
answers: objectToEdit?.answers ?? [], answers: objectToEdit?.answers ?? [],
@ -34,13 +33,7 @@ export const getValidationSchema = () => {
content_image: Yup.string().nullable(), content_image: Yup.string().nullable(),
isCorrect: Yup.boolean(), 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);
}
),
}); });
}; };
@ -51,7 +44,7 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
id: tag?.id, id: tag?.id,
name: tag?.name, name: tag?.name,
})); }));
console.log(item,"item"); console.log(tags);
return { return {
...item, ...item,
@ -72,7 +65,7 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
isBase: 1, isBase: 1,
parent_id: objectToEdit?.parent_id ?? "", parent_id: objectToEdit?.parent_id ?? "",
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
hint: objectToEdit?.hint ?? null, hint: objectToEdit?.hint ?? "",
Questions: questions, Questions: questions,
}; };
}; };
@ -94,15 +87,7 @@ export const getValidationSchemaBase = () => {
isCorrect: Yup.boolean(), isCorrect: Yup.boolean(),
}), }),
) )
.test( .nullable("required"),
'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);
}
),
}), }),
), ),
}); });

View File

@ -6,11 +6,11 @@ import { ParamsEnum } from "../../../../enums/params";
import { useFilterState } from "../../../../Components/Utils/Filter/FilterState"; import { useFilterState } from "../../../../Components/Utils/Filter/FilterState";
const TablePage: React.FC = () => { const TablePage: React.FC = () => {
const { grade_id } = useParams<ParamsEnum>(); const { course_id } = useParams<ParamsEnum>();
const { filterState } = useFilterState(); const { filterState } = useFilterState();
const response = useGetAllSubject({ const response = useGetAllSubject({
grade_id: grade_id, course_id: course_id,
pagination: true, pagination: true,
...filterState, ...filterState,
}); });

View File

@ -212,6 +212,5 @@
.HolderQuestion{ .HolderQuestion{
transform: translateY(55px); transform: translateY(25px);
z-index: -1;
} }

View File

@ -46,7 +46,7 @@
"grade_to_pass_must_be_less_than_max_grade": "يجب أن تكون درجة النجاح أقل من الحد الأقصى للدرجة", "grade_to_pass_must_be_less_than_max_grade": "يجب أن تكون درجة النجاح أقل من الحد الأقصى للدرجة",
"max_mark_must_be_greater_than_min_mark_to_pass": "يجب ان تكون اكبر من علامة النجاح", "max_mark_must_be_greater_than_min_mark_to_pass": "يجب ان تكون اكبر من علامة النجاح",
"Sorry, the question must have at least one option": "عذرًا، يجب أن يحتوي السؤال على خيار واحد على الأقل", "Sorry, the question must have at least one option": "عذرًا، يجب أن يحتوي السؤال على خيار واحد على الأقل",
"at_least_one_answer_should_be_correct":"يجب أن تكون إجابة واحدة صحيحة" "at_least_one_answer_should_be_correct":"يجب أن تكون إجابة واحدة على الأقل صحيحة"
}, },
"header": { "header": {
"register_students": "تسجيل الطلاب", "register_students": "تسجيل الطلاب",