Merge branch 'dev' of https://git.point-dev.net/Karimaldeen/Quiz_dashboard into dev
This commit is contained in:
commit
55f854129e
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ const FormikFormModel: React.FC<FormikFormProps> = ({
|
|||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={handleSubmit}
|
||||
|
||||
>
|
||||
{(formik) => {
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ const Row: React.FC<RowProps> = (props) => {
|
|||
};
|
||||
|
||||
const DrapableTable: React.FC = () => {
|
||||
const { subject_id } = useParams<ParamsEnum>();
|
||||
const { unit_id } = useParams<ParamsEnum>();
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllLesson({
|
||||
subject_id: subject_id,
|
||||
unit_id: unit_id,
|
||||
pagination: false,
|
||||
...filterState,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -138,7 +139,11 @@ console.log(objectToEdit,"objectToEdit");
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
console.log("all api success");
|
||||
if(isSuccess){
|
||||
|
||||
|
|
@ -146,6 +151,8 @@ console.log(objectToEdit,"objectToEdit");
|
|||
}
|
||||
}, [isSuccess])
|
||||
|
||||
|
||||
|
||||
if (isBseQuestion) {
|
||||
return (
|
||||
<div className="exercise_add">
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = ({
|
|||
<Checkbox
|
||||
onChange={onChange || CheckboxhandleChange}
|
||||
disabled={isDisabled}
|
||||
checked={formik.values?.answers?.[name]?.isCorrect === 1}
|
||||
checked={formik.values?.answers?.[name]?.isCorrect === 1 || formik.values?.answers?.[name]?.isCorrect === true}
|
||||
className={className}
|
||||
>
|
||||
{t(`input.${label ? label : name}`)}
|
||||
|
|
|
|||
|
|
@ -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,7 +51,7 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
|
|||
id: tag?.id,
|
||||
name: tag?.name,
|
||||
}));
|
||||
console.log(tags);
|
||||
console.log(item,"item");
|
||||
|
||||
return {
|
||||
...item,
|
||||
|
|
@ -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);
|
||||
}
|
||||
),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import { ParamsEnum } from "../../../../enums/params";
|
|||
import { useFilterState } from "../../../../Components/Utils/Filter/FilterState";
|
||||
|
||||
const TablePage: React.FC = () => {
|
||||
const { course_id } = useParams<ParamsEnum>();
|
||||
const { grade_id } = useParams<ParamsEnum>();
|
||||
const { filterState } = useFilterState();
|
||||
|
||||
const response = useGetAllSubject({
|
||||
course_id: course_id,
|
||||
grade_id: grade_id,
|
||||
pagination: true,
|
||||
...filterState,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -212,5 +212,6 @@
|
|||
|
||||
|
||||
.HolderQuestion{
|
||||
transform: translateY(25px);
|
||||
transform: translateY(55px);
|
||||
z-index: -1;
|
||||
}
|
||||
|
|
@ -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": "تسجيل الطلاب",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user