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;
margin-block: 10px;
border-radius: 5px;
z-index: 9999999 !important;
.ImageBoxIcon {
cursor: pointer;
}

View File

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

View File

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

View File

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

View File

@ -19,6 +19,7 @@ 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 = () => {
@ -39,16 +40,14 @@ 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,
@ -139,11 +138,7 @@ console.log(objectToEdit,"objectToEdit");
useEffect(() => {
console.log("all api success");
if(isSuccess){
@ -151,8 +146,6 @@ console.log(objectToEdit,"objectToEdit");
}
}, [isSuccess])
if (isBseQuestion) {
return (
<div className="exercise_add">

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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": "تسجيل الطلاب",