mario-education 2.0.221-staging → 2.0.222-staging
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SurveyDetailAdmin-35x-A8ct.cjs +1 -0
- package/dist/SurveyDetailAdmin-BImnDFd7.js +1771 -0
- package/dist/containers/SurveyDashboard/components/ResponseQuestionModel.d.ts +1 -1
- package/dist/containers/SurveyDashboard/configs/types.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("mario-core"),s=require("./dashboard.module-CMRJ-dMz.cjs"),t=require("@mui/material"),l=require("react"),pe=require("react-redux"),te=require("./surveyService-Lks0sWq4.cjs"),Se=require("react-router-dom"),Lt=require("./SurveyService-Ck-vqqRy.cjs"),Y=require("./constantsFn-DMEZ5_K5.cjs"),A=require("./constants-CWV8HxZo.cjs"),E=require("moment"),Ne=require("./useFontStyles-B5YQSPG6.cjs"),At=require("./ArrowBack-C4WIF8bZ.cjs"),D=require("./OverallDonutChart-Ci4WB47_.cjs"),qt=require("./ArrowForward-D4TtLiX5.cjs"),st=require("./Clear-5zeY3zlA.cjs"),at=require("react-apexcharts"),nt=require("./SimpleDialog-DnPFn_s_.cjs"),Ve=require("./TableCells-BuZ-cUGm.cjs"),lt=require("./formatDate-k0JbqzRZ.cjs"),h=require("./styles.module-DXQD21R4.cjs"),Ot=require("./createSvgIcon-CRp0VXvr.cjs"),Dt=require("./ExpandMore-CF3178RV.cjs"),It=`${p.BASE_URL}/api/ShareSurvey`,Ft=a=>p.api.put(`${It}/external-link`,a),Qt=()=>{const a=pe.useDispatch(),c=Se.useNavigate(),{t:d}=p.useTranslation(),{id:o}=Se.useParams(),[g,T]=l.useState(null),[u,j]=l.useState(!1),[m,f]=l.useState(),[r,v]=l.useState([]),[q,b]=l.useState([]),[x,w]=l.useState([]),[L,_]=l.useState(null),[I,W]=l.useState([]),[C,G]=l.useState([]),[U,ge]=l.useState([]),[K,ne]=l.useState([]),[B,le]=l.useState([]),[re,y]=l.useState([]),[$,V]=l.useState([]),[Z,oe]=l.useState([]),[H,xe]=l.useState(null),[ee,Ie]=l.useState([]),[ie,Te]=l.useState(""),[Fe,Qe]=l.useState([]),[Ee,ce]=l.useState([]),[Ge,we]=l.useState([]),[Ce,_e]=l.useState(""),[Me,$e]=l.useState([]),[de,se]=l.useState([0]),[ve,Re]=l.useState(!1),[fe,Le]=l.useState(!1),ae=l.useRef(null),ue=pe.useSelector(n=>n.common?.user?.roles),[N,ke]=l.useState({searchString:"",startDate:null,endDate:null,optionDate:"",grade:["All"],roles:ue||[]}),X=n=>{ke({...N,...n}),ce([]),V([]),he([]),y([])},He=n=>{X({...N,startDate:n?.valueOf(),currentPage:1,optionDate:""})},Ae=n=>{X({...N,endDate:n?.valueOf(),currentPage:1,optionDate:""})},qe=n=>{X({currentPage:1,grade:n})},Oe=n=>{let i=null,S=null;switch(n.toLocaleLowerCase()){case"weeks":i=E().startOf("week").weekday(1).valueOf(),S=E().endOf("week").weekday(7).valueOf();break;case"months":i=E().startOf("month").valueOf(),S=E().endOf("month").valueOf();break}X({...N,startDate:i,endDate:S,currentPage:1,optionDate:n})},Be=n=>{const i=n.target.value;ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{X({searchString:i,currentPage:1})},800)};l.useEffect(()=>{const n=Array.from(new Set(ee.map(i=>i.templateName))).sort((i,S)=>i.localeCompare(S,void 0,{sensitivity:"base"}));we(n),_e(n[0])},[ee]),l.useEffect(()=>{const n=ee.filter(i=>i.templateName===Ce);$e(n)},[Ce,ee]);const We=n=>{const i=de.includes(n);se(i?de.filter(S=>S!==n):[...de,n])},[De,je]=l.useState(""),[be,he]=l.useState([]),[F,M]=l.useState(""),[k,me]=l.useState([]),[rt,Pe]=l.useState(null);l.useEffect(()=>{M(k[0]);const n=q.find(i=>i.templateName===k[0]);n&&(_(n),Pe(n))},[q,k]);const[ot,ze]=l.useState(""),[it,ct]=l.useState([]);l.useEffect(()=>{const n=Array.from(new Set(Z.map(S=>S.templateName))).sort((S,P)=>S.localeCompare(P,void 0,{sensitivity:"base"}));ct(n),ze(n[0]);const i=Z.find(S=>S.templateName===n[0]);i&&Ye(i)},[Z]);const dt=()=>{c("/admin/survey-dashboard/list-survey")},Ye=n=>{xe(n)},Ze=n=>{const i=[...re];if(i[n]=!i[n],i.filter(S=>S==!0).length>4){a(p.setAlert({type:"danger",message:d(A.tooltipLabel)}));return}y(i)},ut=n=>{const i=[...$];if(i[n]=!i[n],i.filter(S=>S==!0).length>4){a(p.setAlert({type:"danger",message:d(A.tooltipLabel)}));return}V(i)},ht=()=>{a(p.setAlert({type:"danger",message:d(A.tooltipLabel)}))},mt=()=>{j(!u)},yt=n=>{n?T({avatar:n.avatar,studentId:n.studentId,studentName:n.studentName,isExternal:n?.isExternal}):(T(null),v([]))},pt=l.useCallback(()=>{const n=q.findIndex(S=>S.questionId==L?.questionId),i=n||n==0?K[n]:0;return parseFloat(i?.toFixed(2)?.replace(".00","")||"0")},[L,q,K]),gt=l.useCallback(async()=>{a(p.setLoading(!0));try{const n=await te.getDetailSurvey(parseInt(o||"0"),ue||[]);f(n.data||null)}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[o,ue]),xt=l.useCallback(async()=>{a(p.setLoading(!0));try{const i=(g?.isExternal?await Ft({token:"",externalSurveyId:g.studentId}):await Lt.getQuestionTeacherDefault(parseInt(o||"0"),g?.studentId||0))?.data?.studentResult;if(i){const S=i.additionalQuestions||[],P=i.questions||[],J=[];if(S.length>0){const Q=S.map(R=>({questionId:R.id,question:R.text,type:R.type,category:"",date:R.sendDate!="0001-01-01T00:00:00"?R.sendDate:"",answer:R.answer}));J.push(...Q)}P.forEach(Q=>{Q?.questions?.forEach(R=>{const z={answer:R.answer,category:Q.templateName,date:R.sendDate,question:R.text,questionId:R.id,type:R.type};J.push(z)})}),v(J)}}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[o,g]),Ct=l.useCallback(async()=>{a(p.setLoading(!0));try{const i=(await te.getRatingsOfQuestions(parseInt(o||"0"),{...N,grade:N.grade?.includes("All")?[]:N.grade})).data||[],S=i.questions.map(O=>({questionId:O.questionId,templateName:O.templateName,text:Y.removeHTMLTags(O.text),type:O.type}))||[],P=[...S];b(S),_(P.sort((O,ye)=>O.text.localeCompare(ye.text))[0]),w(i.questions.map((O,ye)=>`Q ${ye+1}`)),ne(i.avgQuestionSurvey||[]);const J=O=>O&&(O.type==="Rating"||O.type===10||O.type===A.QuestionType.Rating),Q=S.filter(J),R=Array.from(new Set(S.map(O=>O.templateName))).sort((O,ye)=>O.localeCompare(ye,void 0,{sensitivity:"base"}));me([...R]);const z=Array.from(new Set(Q.map(O=>O.templateName))),Je=z.length?z[0]:R[0];je(Je);const Xe=(Q.length?Q:S).filter(O=>O.templateName===Je);if(Xe.length){const O=Xe.slice(0,1);if(JSON.stringify(be)===JSON.stringify(O)||!be.length){const Ke=S.findIndex(Rt=>Rt.questionId===O[0].questionId);he(O),Ke!==-1&&Ze(Ke)}else y([...re])}}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[o,g,N]),vt=l.useCallback(async n=>{a(p.setLoading(!0));try{const S=(await te.getTotalByQuestion(parseInt(o||"0"),{...N,questionId:n,grade:N.grade?.includes("All")?[]:N.grade})).data,P=[S.totalSent,S.numberOfResponses],J=P.reduce((R,z)=>R+z,0),Q=P.map(R=>parseFloat((R/J*100).toFixed(1)));ge(Q),le(S.studentQuestionResponses)}catch(i){a(p.setAlert({type:"danger",message:i.response?.data?.title||i.message}))}a(p.setLoading(!1))},[o,N]),ft=l.useCallback(async()=>{a(p.setLoading(!0));try{const i=(await te.getResponsesDistribution(parseInt(o||"0"),{...N,grade:N.grade?.includes("All")?[]:N.grade}))?.data||[];G(i.map((Q,R)=>`Q # ${R+1}`)||[]),W(i);const S=Array.from(new Set(i.map(Q=>Q.templateName))).sort((Q,R)=>Q.localeCompare(R,void 0,{sensitivity:"base"}));Qe(S);const P=ie&&S.includes(ie)?ie:S[0]||"";Te(P);const J=i.filter(Q=>Q.templateName===P);if(J.length){const Q=J.slice(0,1);ce(Q);const R=i.findIndex(z=>z.questionText===Q[0].questionText);if(R!==-1){const z=new Array(i.length).fill(!1);z[R]=!0,V(z)}}else ce([]),V([])}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[N]),jt=l.useCallback(async()=>{a(p.setLoading(!0));try{const i=(await te.getAnswerChart(parseInt(o||"0"),{...N,isQuestionDropDown:!0,grade:N.grade?.includes("All")?[]:N.grade})).data??[];oe(i)}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[o,N]),bt=l.useCallback(async()=>{a(p.setLoading(!0));try{const i=(await te.getAnswerChart(parseInt(o||"0"),{...N,isQuestionDropDown:!1,grade:N.grade?.includes("All")?[]:N.grade})).data??[];Ie(i)}catch(n){a(p.setAlert({type:"danger",message:n.response?.data?.title||n.message}))}a(p.setLoading(!1))},[o,N]),St=()=>{Re(!ve)},Nt=()=>{Le(!fe)},Tt=n=>{X({currentPage:1,studentId:n})},wt=n=>{X({currentPage:1,teacherId:n})},_t=l.useMemo(()=>N.teacherId?m?.studentSurveyResults.filter(n=>n.teacherIds?.includes(N.teacherId))||[]:m?.studentSurveyResults||[],[m?.studentSurveyResults,N.teacherId]),$t=l.useMemo(()=>{if(!N.studentId)return m?.teacherStudentSurveyResults||[];const n=m?.studentSurveyResults.find(i=>i.id===N.studentId);return n?m?.teacherStudentSurveyResults.filter(i=>n.teacherIds?.includes(i.id))||[]:m?.teacherStudentSurveyResults||[]},[m?.teacherStudentSurveyResults,m?.studentSurveyResults,N.studentId]);return l.useEffect(()=>{o&>()},[o]),l.useEffect(()=>{o&&(Ct(),ft(),jt(),bt())},[o,N]),l.useEffect(()=>{L?.questionId&&vt(L.questionId)},[L,N]),l.useEffect(()=>{g?.studentId&&xt()},[g]),l.useEffect(()=>{if(k.length>0){const n=k[0];je(n)}},[k]),{detailSurvey:m,onHandleGoBack:dt,studentDetail:g,handleToggleModelConduct:yt,questionResponses:r,avgQuestionRating:K,ratingQuestions:q,selectQuestion:L,totalByQuestion:U,openResponseModel:u,setSelectQuestion:_,handleToggleResponseModel:mt,generateAvrByQuestion:pt,questionRatingConvert:x,activeColumnQuestionRating:re,handleActiveColumnQuestionRating:Ze,studentResponses:B,distributionSeries:I,distributionQuestions:C,activeColumnDistribution:$,handleActiveColumnDistribution:ut,barChartQuestions:Z,response:H,handelChangeOption:Ye,textInputQuestions:ee,setCategoryChose:Te,categoryChose:ie,categoryComparisonsOptions:Fe,handleStopSelect:ht,questionSelected:Ee,setQuestionSelected:ce,setActiveColumnQuestionRating:y,handleClickCollapse:We,openIndexField:de,setOpenIndexField:se,questionsByCategoryField:Me,setQuestionsByCategoryField:$e,categoryFieldChose:Ce,setCategoryFieldChose:_e,categoriesField:Ge,setCategoriesField:we,categoryRatingChose:De,setCategoryRatingChose:je,questionRatingResponseSelected:rt,setQuestionRatingResponseSelected:Pe,categoriesOptions:k,setCategoriesOptions:me,categoryRatingResponseChose:F,setCategoryRatingResponseChose:M,questionRatingSelected:be,setQuestionRatingSelected:he,categoryDropdownOptions:it,categoryDropdownChose:ot,setCategoryDropdownChose:ze,filters:N,handleChangeEndDate:Ae,handleChangeStartDate:He,handleChangeGrade:qe,onChangeOptionDate:Oe,handleChangeInputSearch:Be,inputSearch:ae,handleChangeStudent:Tt,filteredStudents:_t,filteredTeachers:$t,isShowFilter:ve,handleShowFilter:St,isShowFilterCalendar:fe,handleShowFilterCalendar:Nt,handleChangeTeacher:wt}},Et=({selectQuestion:a,avgQuestionRating:c,ratingQuestions:d,totalByQuestion:o,setSelectQuestion:g,generateAvrByQuestion:T,questionRatingConvert:u,activeColumnQuestionRating:j,onActiveColumnQuestionRating:m,onToggleResponseModel:f,isExternal:r,categoryRatingChose:v,setCategoryRatingChose:q,questionRatingResponseSelected:b,setQuestionRatingResponseSelected:x,categoriesOptions:w,categoryRatingResponseChose:L,setCategoryRatingResponseChose:_,questionRatingSelected:I,setQuestionRatingSelected:W})=>{const{t:C}=p.useTranslation(),{classFontSize:G}=Ne.useFontStyles(),U=c.filter((y,$)=>j[$]==!0)||[],ge=u.filter((y,$)=>j[$]==!0).map((y,$)=>`Q${$+1}`),K=d.map(y=>y.text).filter((y,$)=>j[$]==!0)||[],ne=[{data:U||[],name:C("average")}],B=y=>y&&(y.type==="Rating"||y.type===10||y.type===A.QuestionType.Rating),le=d.some(B);return d.length>0?e.jsxs(t.Grid,{className:`${s.styles["ratings-of-questions"]} ${s.styles[G]}`,children:[le&&e.jsxs(e.Fragment,{children:[e.jsx(t.Typography,{className:`${s.styles["title-chart"]}`,children:C("ratings_of_questions")}),e.jsxs(t.Grid,{className:`${s.styles["list-check-question"]}`,children:[e.jsx(t.Autocomplete,{disableCloseOnSelect:!0,id:"combo-box-demo-1",options:w||[],className:`${s.styles["dropdown-select-category"]}`,value:v||null,onChange:(y,$)=>{q($||"")},getOptionLabel:y=>y,renderInput:y=>e.jsx(t.TextField,{...y,label:C("select_category"),variant:"outlined"})}),e.jsx(t.Autocomplete,{fullWidth:!0,multiple:!0,disableCloseOnSelect:!0,id:"combo-box-demo",options:d.filter(y=>y.templateName===v&&B(y))||[],getOptionLabel:y=>y.text&&Y.removeHTMLTags(y.text),value:I,getOptionDisabled:()=>I.length>=4,onChange:(y,$)=>{if($.length>4)return;const V=I.map(H=>H.text),Z=$.map(H=>H.text),oe=$.length>I.length?$.find(H=>!V.includes(H.text)):I.find(H=>!Z.includes(H.text));if(oe){const H=d.findIndex(xe=>xe.text===oe.text);m(H)}W($)},renderTags:(y,$)=>y.map((V,Z)=>e.jsx(t.Chip,{label:V.text?Y.removeHTMLTags(V.text):"",style:{background:"#316CD914",padding:"7px 12px"},...$({index:Z}),deleteIcon:e.jsx(st.ClearIcon,{})})),renderInput:y=>e.jsx(t.TextField,{...y,label:C("select_ratings_of_questions"),variant:"outlined"})})]}),e.jsx(D.AreaChart,{months:ge,activeColumn:[!0],series:ne||[],dayOfWeek:K,colors:A.ratingOfQuestionColors})]}),e.jsxs(t.Grid,{className:`${s.styles["show-result"]}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:C("responses_and_response_rates_per_question")}),e.jsx(t.Autocomplete,{disableCloseOnSelect:!0,id:"combo-box-demo",options:w||[],className:`${s.styles["dropdown-select-category"]}`,value:L||null,onChange:(y,$)=>{_($||"")},getOptionLabel:y=>y,renderInput:y=>e.jsx(t.TextField,{...y,label:C("select_category"),variant:"outlined"})}),e.jsx(t.Autocomplete,{fullWidth:!0,disableClearable:!0,id:"combo-box-demo",options:d.filter(y=>y.templateName===L)||[],getOptionLabel:y=>y.text,value:b,onChange:(y,$)=>{g($),x($)},renderInput:y=>e.jsx(t.TextField,{...y,label:C("select_question"),variant:"outlined"})}),e.jsxs(t.Grid,{className:`${s.styles["chart-result-for-question"]}`,children:[B(b||a)?e.jsxs(t.Grid,{className:`${s.styles.parameter}`,children:[e.jsx(t.Typography,{className:`${s.styles.percent}`,children:`${T()||0}%`}),e.jsxs(t.Typography,{className:`${s.styles.description}`,children:["Avr. ",C("question_rating").toLowerCase()]})]}):e.jsx(t.Grid,{className:`${s.styles.parameter}`}),e.jsxs(t.Grid,{className:`${s.styles.chart}`,children:[e.jsx(D.OverallDonutChart,{series:o?[...o]:[],colors:["#D9EEE4","#0F9655"],textColors:["#242424","#FFFFFF"],label:[C("number_of_not_responses"),C("number_of_responses")]}),e.jsxs(t.Grid,{className:`${s.styles.legend}`,children:[e.jsxs(t.Grid,{className:`${s.styles["legend-item"]}`,children:[e.jsx(t.Grid,{className:`${s.styles["dot-not-response"]}`}),e.jsx(t.Typography,{className:`${s.styles.name}`,children:C("number_of_not_responses")})]}),e.jsxs(t.Typography,{className:`${s.styles.avr}`,children:["AVR. ",o[0]||0,"%"]}),e.jsxs(t.Grid,{className:`${s.styles["legend-item"]}`,children:[e.jsx(t.Grid,{className:`${s.styles["dot-response"]}`}),e.jsx(t.Typography,{className:`${s.styles.name}`,children:C("number_of_responses")})]}),e.jsxs(t.Typography,{className:`${s.styles.avr}`,children:["AVR. ",o[1]||0,"%"]}),e.jsxs(t.Grid,{onClick:()=>f(),className:`${s.styles.action}`,children:[e.jsx(t.Typography,{className:`${s.styles.content}`,children:C(r?"view_list_of_responses":"view_list_of_students")}),e.jsx(qt.ArrowForwardIcon,{className:`${s.styles.icon}`})]})]})]})]})]})]}):null},Gt=({data:a,isPlp:c,print:d,disableSeriesName:o,colors:g,indexActive:T,isStudentResponses:u})=>{const j=Se.useNavigate(),{t:m}=p.useTranslation(),f=l.useRef(null),[r,v]=l.useState(1e3);l.useEffect(()=>{const _=()=>{f.current&&v(f.current.offsetWidth)};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const b=pe.useSelector(_=>_?.common?.user).roles.includes("Student"),x=_=>{c&&j(`/student-detail/overview/${_}`)},w=D.seriesNameBubbleChartCustom(a),L=a.map(_=>Y.removeHTMLTags(_.questionText))||[];return e.jsxs("div",{className:`${D.styles["size-100"]}`,children:[!d&&e.jsxs("div",{className:`${D.styles["header-chart-container"]}`,children:[e.jsx(t.Typography,{className:`${D.styles["title-chart"]}`,children:m("student_distribution")}),e.jsx(t.Typography,{className:`${D.styles["header-chart-description"]}`,children:m("this_is_the_student_score_from_their_last_check_in")})]}),e.jsxs("div",{className:`${D.styles["bubble-chart-custom"]}`,children:[e.jsxs("div",{className:D.styles["chart-custom"],children:[e.jsx("div",{className:`${D.styles["list-percent"]} ${o&&D.styles["percent-survey"]}`,children:D.PERCENT.map((_,I)=>e.jsxs("div",{className:`${D.styles["percent-item"]}`,children:[_,"%"]},I))}),e.jsx("div",{className:D.styles["legend-wrap"],children:!o&&w.map((_,I)=>e.jsxs("div",{className:`${D.styles.item}`,children:[e.jsx("div",{className:`${D.styles["mark-custom"]}`,style:{backgroundColor:D.COLOR_CHART_BUBBLE[I]}}),e.jsx("label",{className:`${D.styles["label-legend-custom"]}`,children:m(_.toLocaleLowerCase())})]},I))}),e.jsx("div",{className:D.styles["chart-buddle"],children:e.jsx("div",{ref:f,id:"chart_survey_bubble_custom",children:e.jsx(at,{options:D.readinesToLearnoptions(w,a,x,b,g,u),type:"scatter",series:D.convertDataToSeriesBullderChart(a,r,u),width:"100%",height:250})})})]}),e.jsx("div",{className:`${D.styles["question-legend-custom"]}`,children:T&&L.map((_,I)=>e.jsx("p",{className:`${D.styles.question}`,children:`${I+1}. ${_}`}))})]})]})};function Mt(a,c){return JSON.stringify(a)===JSON.stringify(c)}const kt=l.memo(Gt,Mt),Ht=({open:a,onClose:c,student:d,surveyName:o,questionResponses:g})=>{const{classFontSize:T}=Ne.useFontStyles();return e.jsxs(nt.SimpleDialog,{open:a,onClose:c,scroll:"body",maxWidth:"md",contentClassName:s.styles[T],children:[e.jsxs(t.Grid,{className:`${s.styles["header-conduct"]}`,children:[e.jsx("img",{src:p.getFileUrl(d?.avatar||"")||A.DEFAULT_USER_AVATAR,alt:d?.studentName,className:`${s.styles.avatar_user}`}),e.jsxs(t.Grid,{className:`${s.styles["student-detail"]}`,children:[e.jsx(t.Typography,{className:`${s.styles["student-name"]}`,children:d?.studentName}),e.jsx(t.Typography,{className:`${s.styles["survey-name"]}`,children:o})]})]}),e.jsx(t.TableContainer,{className:`${s.styles["conduct-body"]}`,children:e.jsxs(t.Table,{stickyHeader:!0,"aria-label":"simple table",className:`${s.styles["table-border"]}`,children:[e.jsx(t.TableHead,{children:e.jsx(Ve.TableCells,{listTableCell:Ve.tableResponseSurvey,filters:{currentPage:1,pageSize:10}})}),e.jsx(t.TableBody,{children:g.map(u=>e.jsxs(t.TableRow,{className:`${s.styles["table-row"]}`,children:[e.jsx(t.TableCell,{align:"left",className:`${s.styles.row_name}`,children:Y.removeHTMLTags(u.question)}),e.jsx(t.TableCell,{align:"center",className:`${s.styles.row_name}`,children:u.category}),e.jsx(t.TableCell,{align:"center",className:`${s.styles.row_name}`,children:lt.formatSortDate(u.date)}),e.jsx(t.TableCell,{align:"left",className:`${s.styles.row_name}`,children:u.answer!="0"&&(u.type=="Rating"&&u.answer?`${u.answer}%`:u.answer)})]},u.questionId))})]})})]})},Bt=({open:a,onClose:c,questionName:d,totalSent:o,totalByQuestion:g,questionRating:T,studentResponses:u,isHiddenContact:j,questionType:m})=>{const{t:f}=p.useTranslation(),{classFontSize:r}=Ne.useFontStyles(),v=x=>x===A.QuestionType.Rating||x==="Rating"||x===10,q=v(m),b=x=>{if(!x.answer)return"";const w=x.type!==void 0&&x.type!==null?x.type:m;return v(w)?`${x.answer}%`:`${x.answer}`};return e.jsx(nt.SimpleDialog,{open:a,onClose:c,scroll:"body",maxWidth:"md",contentClassName:s.styles[r],children:e.jsxs(t.Grid,{className:`${s.styles["response-question"]}`,children:[e.jsx(t.Typography,{className:`${s.styles["title-model"]}`,children:f("question")}),e.jsx(t.Grid,{className:`${s.styles.question}`,dangerouslySetInnerHTML:{__html:d}}),e.jsxs(t.Grid,{className:`${s.styles["total-cards"]}`,children:[e.jsxs(t.Grid,{className:`${s.styles.card}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:f("number_of_not_responses")}),e.jsx(t.Typography,{className:`${s.styles.avr}`,children:`AVR. ${o}%`})]}),e.jsxs(t.Grid,{className:`${s.styles.card}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:f("number_of_responses")}),e.jsx(t.Typography,{className:`${s.styles.avr}`,children:`AVR. ${g}%`})]}),q&&e.jsxs(t.Grid,{className:`${s.styles.card}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:f("question_rating")}),e.jsx(t.Typography,{className:`${s.styles.avr}`,children:`AVR. ${T}%`})]})]}),e.jsx(t.Grid,{className:`${s.styles["response-body"]}`,children:u.map(x=>e.jsxs(t.Grid,{className:`${s.styles.student} ${s.styles[j?"middle":""]}`,children:[e.jsxs(t.Grid,{hidden:!!j,className:`${s.styles["student-detail"]}`,children:[e.jsx("img",{src:p.getFileUrl(x.studentAvatar||"")||A.DEFAULT_USER_AVATAR,alt:x.studentName,className:`${s.styles.avatar_user}`}),e.jsxs(t.Grid,{children:[e.jsx(t.Typography,{className:`${s.styles["student-name"]}`,children:x.studentName}),e.jsx(t.Typography,{className:`${s.styles.date}`,children:lt.formatSortDate(x.date)})]})]}),e.jsx(t.Typography,{hidden:!x.answer,className:`${s.styles.answer}`,children:b(x)}),e.jsx(t.Typography,{hidden:!!x.answer,className:`${s.styles["none-answer"]}`,children:f("no_response_yet")})]},x.id))})]})})};function Wt({categoryChose:a,setCategoryChose:c,categories:d,questionsByCategory:o}){const{classFontSize:g}=Ne.useFontStyles(),{t:T}=p.useTranslation();return e.jsxs(t.Grid,{className:`${s.styles["dropdown-chart-question"]}`,children:[e.jsx(t.Grid,{className:`${s.styles["dropdown-chart-header"]} ${h.styled["student-survey-questions-categories"]}`,children:e.jsx(t.Autocomplete,{disableClearable:!0,id:"combo-box-demo",options:d??[],className:`${s.styles["dropdown-select-category-text-field"]}`,onChange:(u,j)=>{c(j||"")},value:a,getOptionLabel:u=>u,renderInput:u=>e.jsx(t.TextField,{...u,label:T("select_category"),variant:"outlined"})})}),e.jsx(t.Grid,{className:`${h.styled[g]} ${h.styled["all-student-survey"]}`,children:o.map((u,j)=>e.jsxs("div",{className:h.styled["question-student-survey"],children:[e.jsxs("div",{className:h.styled["question-student-survey-number"],children:[j+1,"."]}),e.jsx("div",{className:h.styled["question-student-survey-content"],children:Y.removeHTMLTags(u.text)})]},u.id))})]})}A.LegalGenderType.Male,A.LegalGenderType.Female;A.MtssType.Tier1,A.MtssType.Tier2,A.MtssType.Tier3;const et=()=>{const a=E().utc().quarter()-1,c=a?E().utc().quarter(a).startOf("quarter").valueOf():E().add(-1,"years").utc().quarter(4).startOf("quarter").valueOf(),d=a?E().utc().quarter(a).endOf("quarter").valueOf():E().add(-1,"years").utc().quarter(4).endOf("quarter").valueOf();return{start:c,end:d}};A.FILTER_YEAR.THIS_YEAR,E().utc().startOf("year").valueOf(),E().utc().endOf("day").valueOf(),A.FILTER_YEAR.LAST_YEAR,E().utc().add(-1,"years").startOf("year").valueOf(),E().utc().add(-1,"years").endOf("year").valueOf(),A.FILTER_YEAR.LAST_QUARTER,et().start,et().end,A.FILTER_YEAR.LAST_MONTH,E().utc().add(-30,"days").startOf("day").valueOf(),E().utc().endOf("day").valueOf(),A.FILTER_YEAR.LAST_DAY,E().utc().add(-1,"days").startOf("day").valueOf(),E().utc().add(-1,"days").endOf("day").valueOf();const Ut=(a,c,d,o)=>({legend:{show:!1,fontFamily:"Poppins-Regular !important"},chart:{type:"bar",toolbar:{show:!1}},noData:{text:"No data",align:"center",verticalAlign:"middle"},grid:{show:!0,strokeDashArray:5,borderColor:"#D3D3D3"},plotOptions:{bar:{horizontal:!0,distributed:!0,borderRadius:5,dataLabels:{position:"top"}}},stroke:{show:!1,width:1,colors:["#fff"]},colors:["#316CD9","#5a89e1","#83a7e8","#adc4f0","#eaf0fb"],xaxis:{labels:{show:!1},axisTicks:{show:!1}},labels:a,tooltip:{x:{formatter:function(g){return g.toString()}},y:{formatter:function(g,{seriesIndex:T,dataPointIndex:u}){return(T?c[u]:g).toString()}}},yaxis:{min:0,max:Math.max(...c)+1,labels:{show:!0,align:"left",minWidth:d?400:0,maxWidth:o&&!d?500:400,style:{fontSize:d?"12px":"14px",fontFamily:"Poppins-Regular !important",fontWeight:d?600:400,cssClass:"apexcharts-yaxis-label"},offsetX:d?280:-5,offsetY:d?-10:0,rotate:0}},dataLabels:{enabled:!0,offsetX:30,formatter:function(g){return g?`${g}`:""},style:{colors:["#242424"]}}}),Ue=a=>{var c=document.createElement("span");c.style.visibility="hidden",c.style.position="absolute",c.style.whiteSpace="nowrap",c.innerHTML=a,document.body.appendChild(c);var d=c.offsetWidth;return document.body.removeChild(c),d},Vt=(a,c)=>{for(var d=a.split(" "),o="",g=0,T=[],u=0;u<d.length;u++){var j=d[u],m=Ue(j);g+m<=c?(o+=j+" ",g+=m+Ue(" ")):(T.push(o.trim()),o=j+" ",g=m+Ue(" "))}return T.push(o.trim()),T},Pt=({response:a,isFullScreen:c,onChangeOption:d,questionAnswers:o,categoryDropdownOptions:g,categoryDropdownChose:T,setCategoryDropdownChose:u})=>{const{t:j}=p.useTranslation(),f=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<576,r=l.useMemo(()=>a?.answers.map(b=>b.name)||[],[a]),v=l.useMemo(()=>a?.answers.map(b=>b.numberAnswer)||[],[a]),q=l.useMemo(()=>r.map(b=>Vt(b,c&&!f?250:150)),[r,c,f]);return e.jsxs(t.Grid,{className:`${s.styles["dropdown-chart-question"]}`,children:[e.jsx(t.Typography,{className:`${s.styles["header-bar-description"]}`,children:j("you_can_only_select_1_question_at_a_time")}),e.jsxs(t.Grid,{className:`${s.styles["dropdown-chart-header"]}`,children:[e.jsx(t.Autocomplete,{clearIcon:!1,id:"combo-box-demo",options:g||[],className:`${s.styles["dropdown-select-category"]}`,value:T||null,getOptionLabel:b=>b,onChange:(b,x)=>{d(null),u(x||"")},renderInput:b=>e.jsx(t.TextField,{...b,label:j("select_category"),variant:"outlined"})}),e.jsx(t.Autocomplete,{fullWidth:!0,clearIcon:!1,id:"combo-box-demo",options:o.filter(b=>b.templateName===T)||[],getOptionLabel:b=>{const x=document.createElement("div");return x.innerHTML=b.name,x.textContent||x.innerText||""},value:a??null,onChange:(b,x)=>d(x),renderOption:(b,x)=>e.jsx("li",{...b,children:e.jsx("div",{dangerouslySetInnerHTML:{__html:x.name}})}),renderInput:b=>e.jsx(t.TextField,{...b,label:j("select_question"),variant:"outlined"})})]}),e.jsx(at,{options:Ut(f?r:q,v,f,c),series:[{name:"",data:v}],type:"bar",width:"100%",height:400}),e.jsx(t.Typography,{className:`${s.styles["title-bar-chart"]}`,children:j("number_of_answers")})]})},zt=Ot.createSvgIcon(e.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Yt=p.getStaticFileUrl("/images/image-default.png"),Zt=({handleClickCollapse:a,openIndexField:c,setOpenIndexField:d,questionsByCategoryField:o,categoryFieldChose:g,setCategoryFieldChose:T,categoriesField:u})=>{const{t:j}=p.useTranslation();return e.jsxs(t.Grid,{className:`${s.styles["dropdown-chart-question"]}`,children:[e.jsx(t.Grid,{className:`${s.styles["dropdown-chart-header"]}`,children:e.jsx(t.Autocomplete,{disableClearable:!0,id:"combo-box-demo",options:u??[],className:`${s.styles["dropdown-select-category-text-field"]}`,onChange:(m,f)=>{T(f||""),d([0])},value:g,getOptionLabel:m=>m,renderInput:m=>e.jsx(t.TextField,{...m,label:j("select_category"),variant:"outlined"})})}),e.jsx("div",{className:h.styled["free-field-list-container"],children:o.length?o.map((m,f)=>e.jsxs(t.List,{component:"nav","aria-labelledby":"nested-list-subheader",className:h.styled["free-field-list"],children:[e.jsxs(t.ListItem,{className:h.styled.question,children:[e.jsxs("div",{className:h.styled["question-text"],children:[e.jsxs("div",{className:h.styled["number-index"],children:[f+1,"."]}),e.jsx("div",{className:h.styled.content,children:Y.removeHTMLTags(m.name)})]}),e.jsx("button",{type:"button",className:h.styled["bottom-collapse"],onClick:()=>a(f),children:c.includes(f)?e.jsx(zt,{fontSize:"large"}):e.jsx(Dt.ExpandMoreIcon,{fontSize:"large"})})]}),e.jsx(t.Collapse,{in:c.includes(f),timeout:"auto",unmountOnExit:!0,children:e.jsx(t.List,{component:"div",disablePadding:!0,children:e.jsx(t.ListItem,{children:e.jsx("div",{className:s.styles["list-answer-text"],children:m?.studentAnswers&&m?.studentAnswers.length>0&&m?.studentAnswers.map(r=>e.jsxs("div",{className:s.styles["item-input-answer"],children:[e.jsxs("div",{className:s.styles["answer-head"],children:[e.jsx("img",{src:`${r.profileImageFileName?p.getFileUrl(r.profileImageFileName):Yt}`,alt:"",style:{width:"24px",height:"24px"}}),e.jsx("h6",{style:{fontWeight:600},children:r.studentName}),e.jsxs("p",{children:[" | ",p.utcToLocalTime(r.createdAt,"MMMM do, yyyy")]})]}),e.jsx("div",{className:s.styles["answer-body"],children:e.jsx("p",{children:r.answer})})]},r.createdAt))})})})})]},f)):e.jsx(t.Typography,{className:`${s.styles["header-bar-description"]}`,children:j("please_select_a_category_to_view_data")})})]})},Jt=()=>e.jsx("svg",{width:"32",height:"28",viewBox:"0 0 32 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{opacity:"0.24","fill-rule":"evenodd","clip-rule":"evenodd",d:"M21.4373 5.4475C21.4365 2.42826 19.0066 -0.00250573 15.9925 1.93851e-06C12.9809 0.00250961 10.5577 2.43997 10.5635 5.46087C10.5685 8.45587 13.0018 10.895 15.9917 10.9025C18.9891 10.91 21.4373 8.45754 21.4373 5.4475ZM15.6346 27.9596L14.0195 27.9593H14.0194H14.0194H14.0193C12.6729 27.959 11.3265 27.9586 9.98064 27.9604C9.39232 27.9613 8.84234 27.8476 8.37735 27.4597C7.87903 27.0443 7.57737 26.511 7.57154 25.8615C7.56804 25.5027 7.56335 25.1437 7.55865 24.7846C7.53985 23.3472 7.52103 21.9088 7.57904 20.4742C7.70154 17.4391 9.10067 15.1713 11.8373 13.7929C12.7797 13.3181 13.7947 13.0883 14.8413 13.0264C16.1738 12.947 17.5129 12.9244 18.8171 13.2446C21.7045 13.9551 24.1577 16.7587 24.3569 19.7353C24.4611 21.2949 24.4442 22.8632 24.4274 24.4306L24.4274 24.4309C24.422 24.9325 24.4167 25.434 24.4152 25.9351C24.4145 26.1945 24.3065 26.4613 24.2042 26.7143L24.1702 26.7985C23.9469 27.3553 23.5194 27.7189 22.9311 27.7765C21.867 27.881 20.797 27.9554 19.7279 27.9822C18.7749 28.0061 17.8211 28.0007 16.8673 27.9952L16.8663 27.9952H16.8663H16.8662C16.456 27.9929 16.0457 27.9905 15.6355 27.9905C15.6346 27.9805 15.6346 27.9705 15.6346 27.9596ZM31.9772 24.4445C31.9849 24.4305 31.9925 24.4164 31.9995 24.4022C31.9995 21.8528 31.9995 19.3033 32.0003 16.7538L31.9956 16.7402L31.9933 16.7338C31.9888 16.7214 31.9839 16.7089 31.9791 16.6965C31.9643 16.6584 31.9495 16.6204 31.9428 16.5808C31.6586 14.8781 30.3703 13.4696 28.6854 13.1445C27.5671 12.9288 26.4255 12.9589 25.3013 13.162C24.6697 13.2757 24.1147 13.5691 23.6514 13.9837C23.767 14.1295 23.8826 14.2714 23.9968 14.4115C24.2478 14.7197 24.4921 15.0196 24.7155 15.3345C25.8563 16.9427 26.2613 18.7834 26.3063 20.7126C26.3321 21.8265 26.3255 22.9416 26.3189 24.0567V24.0568V24.0568V24.0569V24.057L26.3189 24.0579C26.3159 24.5608 26.313 25.0637 26.313 25.5666V25.9035C26.3483 25.9105 26.38 25.9183 26.4092 25.9254C26.4639 25.9389 26.5101 25.9503 26.5563 25.9503C26.8932 25.9501 27.2302 25.9518 27.5672 25.9536H27.5672H27.5672H27.5673H27.5673C28.448 25.9581 29.3288 25.9627 30.2087 25.9319C31.067 25.9018 31.6736 25.3643 31.9345 24.5368C31.9447 24.5044 31.961 24.4744 31.9772 24.4445ZM0.0480542 16.5528C0.0322213 16.6198 0.0163884 16.6869 0 16.7538V24.464C0.00583317 24.4721 0.0125922 24.4799 0.0193513 24.4877C0.0328695 24.5033 0.0463876 24.5189 0.0524985 24.5367C0.36249 25.4788 0.970806 25.9419 1.94828 25.9511C2.89404 25.9604 3.83979 25.9586 4.78555 25.9569L5.25819 25.9561C5.35357 25.9561 5.44896 25.944 5.54329 25.9321L5.54334 25.9321C5.58744 25.9266 5.63131 25.921 5.67484 25.9168C5.67484 25.7147 5.67558 25.5165 5.67631 25.3209L5.67631 25.3207C5.67791 24.8939 5.67946 24.4796 5.67317 24.0653L5.66725 23.7042C5.64269 22.2373 5.61814 20.7716 5.81067 19.3116C6.0665 17.3723 6.82231 15.6671 8.16311 14.2335C8.20925 14.1844 8.25349 14.1327 8.30045 14.0777L8.30048 14.0777C8.32305 14.0513 8.34626 14.0241 8.3706 13.9962C7.89478 13.5882 7.38063 13.2597 6.78814 13.1929C5.88317 13.0909 4.96569 13.0349 4.05489 13.0533C2.22077 13.09 0.633316 14.379 0.147496 16.1519C0.111386 16.2845 0.07972 16.4187 0.0480542 16.5528ZM4.98756 4.01217C6.88834 4.00464 8.4308 5.53767 8.43663 7.44015C8.44247 9.34013 6.91251 10.8874 5.01256 10.9016C3.13095 10.9166 1.56933 9.36019 1.56349 7.46523C1.55766 5.56107 3.08678 4.01885 4.98756 4.01217ZM26.9874 10.9016C28.8707 10.9149 30.429 9.36186 30.4357 7.46439C30.4423 5.5594 28.914 4.01969 27.0116 4.01217C25.1125 4.00464 23.5683 5.53934 23.5625 7.44015C23.5567 9.33846 25.09 10.8882 26.9874 10.9016Z",fill:"#242424"})}),Xt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:"16",height:"16",rx:"8",fill:"white"}),e.jsx("circle",{cx:"8",cy:"8",r:"8",fill:"#0F9655"}),e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.7762 4.8349C13.0514 5.07952 13.0762 5.5009 12.8316 5.77609L7.49827 11.7761C7.37629 11.9133 7.20311 11.9942 7.01958 11.9996C6.83605 12.0049 6.65843 11.9344 6.5286 11.8046L4.19526 9.47125C3.93491 9.2109 3.93491 8.78879 4.19526 8.52844C4.45561 8.26809 4.87772 8.26809 5.13807 8.52844L6.97146 10.3618L11.8351 4.89027C12.0797 4.61508 12.5011 4.59029 12.7762 4.8349Z",fill:"white"})]}),Kt=({data:a})=>e.jsx("div",{className:h.styled["total-student-head"],children:a.map((c,d)=>e.jsxs("div",{className:h.styled["item-static"],children:[e.jsxs("div",{className:h.styled["item-static-icon"],children:[e.jsx(Jt,{}),d!==0&&e.jsx("div",{className:h.styled["item-static-icon-sent"],children:e.jsx(Xt,{})})]}),e.jsxs("div",{className:h.styled["item-static-content"],children:[e.jsx("div",{className:h.styled.title,children:d===0?"Total Students":"Students Responded"}),e.jsx("div",{className:h.styled.content,children:c})]})]},`${c}_${d}`))}),es=({color:a="#169490"})=>e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.38838 11.0656L8.38823 9.83087C8.38823 8.70618 8.39031 7.58148 8.38721 6.45678C8.38615 5.97909 8.05998 5.65762 7.5727 5.65053C7.18312 5.64448 6.79354 5.64448 6.40397 5.65053C5.91623 5.65762 5.59057 5.9786 5.59001 6.45728C5.58742 8.70062 5.58742 10.9439 5.59001 13.1873C5.59057 13.67 5.92922 13.9945 6.42426 13.9986C6.69346 14.0009 6.96267 14.0002 7.23187 13.9996L7.47612 13.9991C8.07296 13.9986 8.38823 13.6923 8.38823 13.1104C8.38858 12.4287 8.38848 11.7472 8.38838 11.0656Z",fill:a}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.978 9.8324C12.978 9.50406 12.9781 9.17567 12.9783 8.84726C12.9786 8.06998 12.9789 7.29258 12.9774 6.51543C12.9764 5.95587 12.6606 5.65157 12.0835 5.64954L12.0033 5.64917H11.9991C11.6704 5.64774 11.3412 5.64631 11.0125 5.65004C10.5065 5.65611 10.1829 5.969 10.1824 6.45678C10.1808 8.70013 10.1808 10.9429 10.1824 13.1863C10.1829 13.6705 10.5158 13.9945 11.0119 13.9986C11.2498 14.0003 11.4879 13.9999 11.726 13.9995L11.8223 13.9993C11.8962 13.9992 11.9701 13.9991 12.044 13.9991C12.6689 13.9986 12.9774 13.6998 12.978 13.0928C12.9782 12.7575 12.9782 12.4223 12.9782 12.087L12.978 9.8324Z",fill:a}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.79597 11.1303C3.79607 11.7965 3.79618 12.4627 3.79587 13.1286C3.79536 13.6882 3.48005 13.9965 2.90659 13.9986L2.74436 13.999C2.44787 14.0001 2.15137 14.001 1.85523 13.9981C1.33372 13.993 1.00283 13.6766 1.00232 13.166C0.999226 10.9358 0.999226 8.70566 1.00232 6.47547C1.00283 5.96039 1.32646 5.65357 1.85574 5.64903C2.0172 5.64764 2.17872 5.647 2.34028 5.64693C2.53583 5.64685 2.73143 5.64764 2.92683 5.64903C3.48213 5.65206 3.79536 5.95686 3.79638 6.4947L3.79597 11.1303Z",fill:a}),e.jsx("path",{d:"M11.3653 2.93783H11.5918C11.6032 2.95653 11.6146 2.97574 11.6256 2.99395C11.4713 3.13397 10.9998 3.51148 10.8502 3.65604C10.6362 3.86278 10.6185 4.08318 10.7931 4.25554C10.9682 4.42841 11.1957 4.41276 11.4076 4.20802C11.7764 3.85216 12.4572 3.25326 12.8229 2.89436C13.0571 2.66487 13.0587 2.46722 12.8275 2.24027C12.4618 1.88137 11.7857 1.31146 11.4169 0.955596C11.205 0.751379 10.9733 0.73267 10.7993 0.901C10.6222 1.07185 10.6388 1.29628 10.8502 1.5C10.9314 1.57841 11.0148 1.65456 11.0987 1.73028C11.1636 1.7888 11.5376 2.0596 11.6022 2.11844C11.5968 2.12577 11.5912 2.1331 11.5855 2.14043C11.5799 2.14776 11.5743 2.15509 11.5689 2.16243H1.5641C1.49242 2.16243 1.42024 2.15788 1.35008 2.16748C1.14489 2.19528 0.997382 2.36765 1.00413 2.56276C1.01093 2.75333 1.15479 2.90651 1.35683 2.92976C1.44048 2.93936 1.52565 2.93733 1.6098 2.93733C4.79085 2.93783 8.18429 2.93783 11.3653 2.93783Z",fill:a,stroke:a,strokeWidth:"0.5"})]}),ts=({avr:a,color:c})=>e.jsxs("div",{className:h.styled["avr-comparison"],style:{background:`${c}15`},children:[e.jsx(es,{color:c}),e.jsxs("div",{className:h.styled["avr-comparison-content"],children:["Avr. ",a,"%"]})]},c),ss=/\s*\(\d+\s*questions?\)/i,tt=a=>a?.replace(ss,"").trim(),as=(a,c)=>`${a} (${c} question${c>1?"s":""})`,ns=()=>{const[a,c]=l.useState([]),[d,o]=l.useState([]),[g,T]=l.useState(""),[u,j]=l.useState([]),[m,f]=l.useState([]),[r,v]=l.useState([]),q=pe.useDispatch(),{id:b}=Se.useParams(),x=l.useCallback(async()=>{q(p.setLoading(!0));try{const w=await te.getListQuestionSurvey(parseInt(b||"0"));c(w.data);const L=w.data.filter(C=>C.type===A.QuestionType.MultipleChoice||C.type===A.QuestionType.SingleChoice),_=L.reduce((C,G)=>{const U=tt(G.templateName);return U&&(C[U]=(C[U]||0)+1),C},{}),I=L.map(C=>{const G=tt(C.templateName),U=_[G]||1;return{text:C.text,id:C.id,category:G?as(G,U):C.templateName}});v(Array.from(new Set(I.map(C=>C.category))).sort((C,G)=>C.localeCompare(G,void 0,{sensitivity:"base"}))),f(I);const W=Array.from(new Set(w.data.map(C=>C.templateName))).sort((C,G)=>C.localeCompare(G,void 0,{sensitivity:"base"}));W.length&&(o(W.filter(C=>C!==null&&C!==""&&C!==void 0)),T(W?.[0]||""))}catch(w){q(p.setAlert({type:"danger",message:w.response?.data?.title||w.message}))}q(p.setLoading(!1))},[b]);return l.useEffect(()=>{const w=a.filter(L=>L.templateName===g);j(w)},[g,a]),l.useEffect(()=>{x()},[]),{categoryChose:g,setCategoryChose:T,categories:d,questionsByCategory:u,questionSurveyDropdown:m,categoryDistributionOptions:r}},ls=a=>{const[c,d]=l.useState(0),o=pe.useDispatch(),{id:g}=Se.useParams(),T=pe.useSelector(v=>v.common?.user?.roles),[u,j]=l.useState([]),[m,f]=l.useState(""),r=async()=>{o(p.setLoading(!0));try{const v=await te.getQuestionResponsesDistribution(Number(g),c,a,T),q=v.data.length,b=(w,L)=>{if(L<=5){const I=L>1?Math.round(w*(A.DEFAULT_COLORS.length-1)/(L-1)):2;return A.DEFAULT_COLORS[I]}return`hsl(${Math.round(w/(L-1)*140)}, 70%, 50%)`},x=v.data.map((w,L)=>({label:w.label,value:Math.round(w.value*10)/10,count:w.count,color:b(L,q)}));j(x)}catch(v){console.log(v)}o(p.setLoading(!1))};return l.useEffect(()=>{c&&r()},[c,a]),{questionSelectedId:c,setQuestionSelectedId:d,distributionData:u,categoryChose:m,setCategoryChose:f}},rs=({questionSurveyDropdown:a,filters:c,categoryDistributionOptions:d})=>{const{t:o}=p.useTranslation(),{questionSelectedId:g,setQuestionSelectedId:T,distributionData:u,categoryChose:j,setCategoryChose:m}=ls(c),f=l.useMemo(()=>a.filter(r=>r.category===j)||[],[a,j]);return l.useEffect(()=>{f.length>0&&T(f[0].id)},[f]),l.useEffect(()=>{d?.[0]&&!j&&m(d[0])},[d]),e.jsxs("div",{className:h.styled["responses-distribution-container"],children:[e.jsx(t.Typography,{className:`${h.styled.title}`,style:{textTransform:"capitalize"},children:o("responses_distribution")}),e.jsx(t.Grid,{container:!0,sx:{mb:4,pl:1},alignItems:"center",children:e.jsxs(t.Grid,{item:!0,xs:12,sm:12,lg:12,spacing:3,children:[e.jsx(t.Autocomplete,{clearIcon:!1,id:"combo-box-demo",options:d||[],className:`${h.styled["dropdown-select-category"]}`,value:j||null,getOptionLabel:r=>r,onChange:(r,v)=>{v&&m(v)},renderInput:r=>e.jsx(t.TextField,{...r,label:o("select_category"),variant:"outlined"})}),e.jsx(t.Autocomplete,{clearIcon:!1,id:"select-question-autocomplete",options:f,className:h.styled["dropdown-select-large"],onChange:(r,v)=>{v&&T(v.id)},value:f.find(r=>r.id===g)||null,isOptionEqualToValue:(r,v)=>r.id===v.id,renderOption:(r,v)=>e.jsx("li",{...r,children:Y.removeHTMLTags(v.text)}),getOptionLabel:r=>Y.removeHTMLTags(r.text)||"",renderInput:r=>e.jsx(t.TextField,{...r,label:o("select_question"),variant:"outlined"})})]})}),u.length>0&&e.jsxs("div",{className:h.styled["distribution-chart-wrapper"],children:[e.jsxs("div",{className:h.styled["marker-labels"],children:[u.map((r,v)=>{if(r.value>0&&r.value<8){const q=u.slice(0,v).reduce((b,x)=>b+x.value,0)+r.value/2;return e.jsxs("div",{style:{left:`${q}%`},className:h.styled["top-marker"],children:[e.jsxs("span",{className:h.styled["marker-value"],children:[r.value,"%"]}),e.jsx("div",{className:h.styled["marker-line"]})]},v)}return null}),e.jsxs("div",{style:{left:"50%"},className:h.styled["top-marker"],children:[e.jsx("span",{className:h.styled["marker-value-bottom"],children:"50%"}),e.jsx("div",{className:h.styled["marker-line-dashed"]})]})]}),e.jsx("div",{className:h.styled["distribution-bar"],children:u.map((r,v)=>r.value>0&&e.jsx("div",{className:h.styled["bar-segment"],style:{width:`${r.value}%`,backgroundColor:r.color},children:r.value>=8&&e.jsxs("span",{className:h.styled["segment-percentage"],children:[r.value,"%"]})},v))})]}),e.jsx(t.Grid,{container:!0,className:h.styled["legend-container"],justifyContent:"center",spacing:2,children:u.map((r,v)=>e.jsxs(t.Grid,{item:!0,className:h.styled["legend-item"],children:[e.jsx("div",{className:h.styled["legend-color-box"],style:{backgroundColor:r.color}}),e.jsxs(t.Typography,{className:h.styled["legend-text"],children:[r.label," (",r.count,")"]})]},v))})]})},os=()=>{const{t:a}=p.useTranslation(),{classFontSize:c}=Ne.useFontStyles(),{onHandleGoBack:d,detailSurvey:o,studentDetail:g,handleToggleModelConduct:T,questionResponses:u,avgQuestionRating:j,selectQuestion:m,setSelectQuestion:f,generateAvrByQuestion:r,ratingQuestions:v,totalByQuestion:q,questionRatingConvert:b,activeColumnQuestionRating:x,handleActiveColumnQuestionRating:w,openResponseModel:L,handleToggleResponseModel:_,studentResponses:I,distributionSeries:W,barChartQuestions:C,response:G,handelChangeOption:U,setCategoryChose:ge,categoryChose:K,categoryComparisonsOptions:ne,questionSelected:B,setQuestionSelected:le,setActiveColumnQuestionRating:re,handleClickCollapse:y,openIndexField:$,setOpenIndexField:V,questionsByCategoryField:Z,setQuestionsByCategoryField:oe,categoryFieldChose:H,setCategoryFieldChose:xe,categoriesField:ee,setCategoriesField:Ie,categoryRatingChose:ie,setCategoryRatingChose:Te,questionRatingResponseSelected:Fe,setQuestionRatingResponseSelected:Qe,categoriesOptions:Ee,setCategoriesOptions:ce,categoryRatingResponseChose:Ge,setCategoryRatingResponseChose:we,questionRatingSelected:Ce,setQuestionRatingSelected:_e,categoryDropdownOptions:Me,categoryDropdownChose:$e,setCategoryDropdownChose:de,filters:se,handleChangeEndDate:ve,handleChangeStartDate:Re,handleChangeGrade:fe,onChangeOptionDate:Le,handleChangeInputSearch:ae,handleChangeStudent:ue,isShowFilter:N,handleShowFilter:ke,isShowFilterCalendar:X,handleShowFilterCalendar:He,handleChangeTeacher:Ae,filteredTeachers:qe,filteredStudents:Oe}=Qt(),{categoryChose:Be,setCategoryChose:We,categories:De,questionsByCategory:je,questionSurveyDropdown:be,categoryDistributionOptions:he}=ns();return e.jsxs("div",{className:s.styles["survey-detail-container"],children:[e.jsxs("div",{className:s.styles["header-survey-detail-container"],children:[e.jsxs(t.Grid,{className:`${s.styles["header-survey-detail"]}`,children:[e.jsx(At.ArrowBackIcon,{className:`${s.styles["icon-back-page"]}`,onClick:()=>d()}),e.jsx(t.Typography,{className:`${s.styles["content-header"]}`,children:a("surveys")})]}),e.jsxs(t.Grid,{container:!0,children:[e.jsx(t.Grid,{xs:5,sm:5,children:e.jsx(t.Typography,{className:`${s.styles["survey-title"]}`,children:o?.title})}),e.jsx(t.Grid,{xs:7,sm:7,children:e.jsx(Kt,{data:[o?.allCount??0,o?.completedCount??0]})})]})]}),e.jsx(t.Grid,{className:`${s.styles["filter-desktop"]} ${s.styles["header-survey-detail-container"]}`,children:e.jsx(Ve.CustomFilterComponent,{handleChangeInputSearch:ae,filters:se,handleChangeStartDate:Re,handleChangeEndDate:ve,onChangeGrade:fe,onChangeOptionDate:Le,isSelectMulti:!0,studentList:Oe,onSelectStudent:ue,teacherList:qe,onSelectTeacher:Ae})}),e.jsx(t.Grid,{className:`${s.styles["filter-mobile"]}`,children:e.jsx(h.CustomFilterMobile,{handleChangeInputSearch:ae,filters:se,handleChangeStartDate:Re,handleChangeEndDate:ve,onChangeGrade:fe,onChangeOptionDate:Le,isSelectMulti:!0,isDetailSurvey:!0,studentList:Oe,onSelectStudent:ue,isShowCalendar:X,onShowFilterCalendar:He,onShowFilter:ke,isShowFilter:N,teacherList:qe,onSelectTeacher:Ae})}),e.jsxs(t.Grid,{className:`${s.styles["survey-detail"]} ${s.styles[c]}`,children:[De?.length>0&&e.jsxs(t.Grid,{className:`${s.styles["responses-distribution"]} ${h.styled["student-survey-questions"]}`,children:[e.jsx(t.Typography,{className:`${s.styles.title} ${h.styled["student-survey-questions-title"]}`,style:{textTransform:"capitalize"},children:a("questions")}),e.jsx(Wt,{categoryChose:Be,setCategoryChose:We,categories:De,questionsByCategory:je})]}),he?.length>0&&e.jsx(t.Grid,{className:`${s.styles["responses-distribution"]}`,children:e.jsx(rs,{questionSurveyDropdown:be,filters:se,categoryDistributionOptions:he})}),ne?.length>0&&W?.length>0&&e.jsxs(t.Grid,{className:`${s.styles["responses-distribution"]}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:a("responses_comparisons")}),e.jsx(t.Typography,{className:`${s.styles.description}`,children:a("you_can_only_select_number_kpis_at_a_time",{number:4})}),e.jsxs(t.Grid,{className:`${s.styles["list-check-question"]}`,children:[e.jsx(t.Autocomplete,{disableCloseOnSelect:!0,id:"combo-box-demo",options:ne,className:`${s.styles["dropdown-select-category"]}`,onChange:(F,M)=>{if(M){ge(M);const k=W.filter(me=>me.templateName===M);le(k.slice(0,1))}},value:K||"",getOptionLabel:F=>F,renderInput:F=>e.jsx(t.TextField,{...F,label:a("select_category"),variant:"outlined"})}),e.jsx(t.Autocomplete,{fullWidth:!0,multiple:!0,disableCloseOnSelect:!0,id:"combo-box-demo",options:W.filter(F=>F.templateName===K)||[],getOptionLabel:F=>F.questionText&&Y.removeHTMLTags(F.questionText),getOptionDisabled:()=>B.length>=4,value:B,onChange:(F,M)=>{M.length>4||le(M)},renderTags:(F,M)=>F.map((k,me)=>e.jsx(t.Chip,{label:k.questionText?Y.removeHTMLTags(k.questionText):"",style:{background:"#316CD914",padding:"7px 12px"},...M({index:me}),deleteIcon:e.jsx(st.ClearIcon,{})})),renderInput:F=>e.jsx(t.TextField,{...F,label:a("select_responses_distribution"),variant:"outlined"})})]}),e.jsx("div",{className:h.styled["avr-comparison-container"],children:e.jsx("div",{className:h.styled["avr-comparison-list"],children:A.ratingOfQuestionColors.slice(0,B.length).map((F,M)=>{const k=B[M]?.avr;return e.jsx(ts,{color:F,avr:k},F)})})}),e.jsx(kt,{print:!0,disableSeriesName:!0,colors:A.ratingOfQuestionColors,isStudentResponses:!1,data:B,indexActive:B.map((F,M)=>M+1)})]}),C?.length>0&&e.jsxs(t.Grid,{className:`${s.styles["responses-distribution"]}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:a("dropdown_and_verbal_questions_responses")}),e.jsx(t.Grid,{container:!0,spacing:2,children:e.jsx(t.Grid,{item:!0,xs:12,children:e.jsx(Pt,{isFullScreen:!1,response:G,onChangeOption:U,questionAnswers:C,categoryDropdownOptions:Me,categoryDropdownChose:$e,setCategoryDropdownChose:de})})})]}),e.jsx(t.Grid,{children:e.jsx(Et,{isExternal:!1,totalByQuestion:q,selectQuestion:m,setSelectQuestion:f,generateAvrByQuestion:r,ratingQuestions:v,onToggleResponseModel:_,avgQuestionRating:j,questionRatingConvert:b,activeColumnQuestionRating:x,onActiveColumnQuestionRating:w,setActiveColumnQuestionRating:re,categoryRatingChose:ie,setCategoryRatingChose:Te,questionRatingResponseSelected:Fe,setQuestionRatingResponseSelected:Qe,categoriesOptions:Ee,setCategoriesOptions:ce,categoryRatingResponseChose:Ge,setCategoryRatingResponseChose:we,questionRatingSelected:Ce,setQuestionRatingSelected:_e})}),ee?.length>0&&e.jsxs(t.Grid,{className:`${s.styles["responses-distribution"]}`,children:[e.jsx(t.Typography,{className:`${s.styles.title}`,children:a("free_fields_responses")}),e.jsx(t.Grid,{container:!0,spacing:2,children:e.jsx(t.Grid,{item:!0,xs:12,children:e.jsx(Zt,{isFullScreen:!0,handleClickCollapse:y,openIndexField:$,setOpenIndexField:V,questionsByCategoryField:Z,setQuestionsByCategoryField:oe,categoryFieldChose:H,setCategoryFieldChose:xe,categoriesField:ee,setCategoriesField:Ie})})})]}),e.jsx(Ht,{open:!!g,onClose:T,surveyName:o?.title||"",student:g,questionResponses:u}),e.jsx(Bt,{isHiddenContact:!1,open:L,onClose:_,questionName:m?.text||"",totalSent:q?.[0]||0,totalByQuestion:q?.[1]||0,questionRating:r()||0,studentResponses:I,questionType:m?.type})]})]})};exports.default=os;
|