diff --git a/src/components/Partner_Config_Formulaires.js b/src/components/Partner_Config_Formulaires.js index 88d69c7..6ffffbe 100644 --- a/src/components/Partner_Config_Formulaires.js +++ b/src/components/Partner_Config_Formulaires.js @@ -44,7 +44,10 @@ import Autocomplete from '@mui/material/Autocomplete'; import { gridClasses } from '@mui/x-data-grid'; import { PiDotsThree } from "react-icons/pi"; import Link from '@mui/material/Link'; +import { CiCircleMinus } from "react-icons/ci"; +import { LiaSave } from "react-icons/lia"; +import { IoMdAddCircleOutline } from "react-icons/io"; const Partner_Config_Formulaires = (props) => { @@ -74,7 +77,7 @@ const Partner_Config_Formulaires = (props) => { const columns = [ { field: '_id', headerName: '_id', hide: true }, { field: 'id', headerName: 'id', hide: true }, - { field: 'code', headerName: 'code', flex: 1, hide: false, editable: false , renderCell: (params) => , }, + { field: 'code', headerName: 'code', flex: 1, hide: false, editable: false, renderCell: (params) => , }, { field: 'nom', headerName: 'nom', flex: 1, hide: false, editable: false, renderCell: (params) => , }, { field: 'type', headerName: 'Type', flex: 1, hide: false, editable: false, renderCell: (params) => , }, { field: 'description', headerName: 'description', flex: 1, hide: true, editable: false, renderCell: (params) => , }, @@ -178,8 +181,9 @@ const Partner_Config_Formulaires = (props) => { const columns_question = [ - { field: '_id', headerName: '_id', hide: true }, + { field: '_id', headerName: '_id', hide: true }, { field: 'id', headerName: 'id', hide: true }, + { field: 'list_choix', headerName: 'list_choix', hide: true }, { field: 'question', headerName: 'question', flex: 1, hide: false, editable: false, renderCell: (params) => , }, { field: 'type', headerName: 'type', flex: 1, hide: false, editable: false, renderCell: (params) => , }, { field: 'max_note', headerName: 'max_note', flex: 1, hide: true, editable: false, renderCell: (params) => , }, @@ -726,6 +730,7 @@ const Partner_Config_Formulaires = (props) => { { "id": "note", "label": "Note ", "value": "note" }, { "id": "bool", "label": "Oui/Non", "value": "bool" }, { "id": "entier", "label": "Entier", "value": "entier" }, + { "id": "qcm", "label": "Qcm", "value": "qcm" }, { "id": "", "label": "", "value": "" }, ] @@ -951,6 +956,8 @@ const Partner_Config_Formulaires = (props) => { setquestion_max_note(""); setDialog_Question_open(true); + settab_qcm_choix([]); + } const [Add_Update_One_Question_api, setAdd_Update_One_Question_api] = useState(); @@ -975,6 +982,16 @@ const Partner_Config_Formulaires = (props) => { form.append("question", question_question); form.append("type", question_type); form.append("max_note", question_max_note); + + var local_list_choix = [] + for(let i = 0; i < tab_qcm_choix.length; i++){ + var choix = "reponse"; + var val = String(tab_qcm_choix[i]) + var node = {}; + node[choix] = val; + local_list_choix.push(node); + } + form.append("list_choix", JSON.stringify(local_list_choix)); if (String(selected_question_id).length > 2) { form.append("question_id", selected_question_id); @@ -997,6 +1014,9 @@ const Partner_Config_Formulaires = (props) => { setquestion_question(""); setquestion_type(""); setquestion_max_note(""); + settab_qcm_choix([]); + setadd_new_qcm_choix(""); + setnew_qcm_choix_value(""); Get_Given_Formulaire_Data(selected_id); @@ -1108,6 +1128,35 @@ const Partner_Config_Formulaires = (props) => { }) } + + const [nb_qcm_choix, setnb_qcm_choix] = useState(3); + + const [tab_qcm_choix, settab_qcm_choix] = useState([]); + const [add_new_qcm_choix, setadd_new_qcm_choix] = useState(""); + const [new_qcm_choix_value, setnew_qcm_choix_value] = useState(""); + + function add_new_list_to_qcm() { + var current_tab_qcm_choix = tab_qcm_choix; + current_tab_qcm_choix.push(new_qcm_choix_value); + settab_qcm_choix(current_tab_qcm_choix); + setnew_qcm_choix_value(""); + } + + + function remove_last_list_to_qcm() { + var current_tab_qcm_choix = tab_qcm_choix; + + var new_current_tab_qcm_choix = []; + for (let i = 0; i < current_tab_qcm_choix.length - 1; i++) + new_current_tab_qcm_choix.push(current_tab_qcm_choix[i]); + + current_tab_qcm_choix.pop(); + setnew_qcm_choix_value(""); + settab_qcm_choix(new_current_tab_qcm_choix); + } + + + return (
{isLoading &&
@@ -1201,6 +1250,66 @@ const Partner_Config_Formulaires = (props) => {
} + {String(question_type) === "qcm" &&
QCM + + {tab_qcm_choix && + tab_qcm_choix.map((choix) => ( +
+ + { + // setquestion_max_note(e.target.value); + + } + } + /> +
+ ))} + + + + + {add_new_qcm_choix && String(add_new_qcm_choix) === "1" && + +
+ { + setnew_qcm_choix_value(e.target.value); + + } + } + /> + { + setadd_new_qcm_choix(""); + add_new_list_to_qcm(); + }} className="icone_bton_add_reduce"> record +
+ } + +
} + @@ -1780,7 +1889,7 @@ const Partner_Config_Formulaires = (props) => {
- +
- +