Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.15.223.129
import{x as de,H as pe,Q as ie,r as x,t as e,D as G,L as X,B as u,F as U,G as ue,E as g,v as z,O as he}from"./index-BXGyQmrS.js";import{R as A}from"./quill.snow-DiPQVbXP.js";import{P as Q,g as me}from"./PrepareQuestionPaper-ncsYRwIg.js";import{k as ge}from"./sem-CXAFzSxe.js";import{S as H}from"./index-Dmdyjymp.js";import{R as xe}from"./ArrowLeftOutlined-CtcP-jIh.js";import{R as ye}from"./FilePdfOutlined-b1LLwQaT.js";import{R as je}from"./HomeOutlined-DXLVvpRw.js";import{R as J}from"./index-BLFlp97X.js";import{R as P,C as j}from"./row-BC5PwUrl.js";import{U as R,R as O}from"./UploadOutlined-fJC8KsRE.js";import{R as F}from"./DeleteOutlined-CHQ1I1e1.js";import"./index-DA_qcuNc.js";import"./responsiveObserver-BnSpyoMt.js";const qe=p=>{const C=pe(),c=ie(),[y,b]=x.useState([]),[B,E]=x.useState(""),[V,v]=x.useState(""),[W,M]=x.useState(2),[Z,_]=x.useState(""),[w,k]=x.useState(""),[be,I]=x.useState(null),[ke,ee]=x.useState(null),[ve,ae]=x.useState(null),[De,te]=x.useState(null),[Ee,se]=x.useState(null),[Se,re]=x.useState(null),S="https://omr-files.s3.ap-south-1.amazonaws.com/";x.useEffect(()=>{p.getTemplateDetails(c)},[]),x.useEffect(()=>{var o,l,s,n,t,a,r;let f=p.templateDetails.map((i,h)=>(i.fdata.map((m,d)=>{let Y=0;return m.fqnarr.map((D,Le)=>(Y+=parseInt(D.fmaxmarks),D.ftype=c.type=="THEORY"&&D.ftype==""?"Descriptive":D.ftype,D)),Y==m.fmaxmarks&&(m.fqpcomp="Completed"),m}),i));b(f),E((o=p.templateDetails[0])==null?void 0:o.fpartcode),v((s=(l=p.templateDetails[0])==null?void 0:l.fdata[0])==null?void 0:s.fqncode),_((t=(n=p.templateDetails[0])==null?void 0:n.fdata[0])==null?void 0:t.fqnno),k((r=(a=p.templateDetails[0])==null?void 0:a.fdata[0])==null?void 0:r.fqnarr[0].fqncode)},[p.templateDetails]),x.useEffect(()=>{b(y)},[y]);const K=async(f,o,l,s,n,t)=>{const a=y;if(t==="next"){let r=a[l].fdata[s].fmaxmarks,i=0;if(a[l].fdata[s].fqnarr.forEach(m=>{i+=parseInt(m.fmaxmarks)}),i>r){g("info",`Maximum marks is ${r} and marks assigned ${i}`);return}if(a[l].fdata[s].fqnarr[n].fquestionno==""){g("info","Enter Question No.");return}if(a[l].fdata[s].fqnarr[n].fquestion==""){g("info","Enter Question");return}const h=new FormData;h.append("usertype",p.user.fusertype),h.append("qncode",o.fqncode),h.append("data",JSON.stringify(a[l].fdata[s].fqnarr[n])),h.append("params",JSON.stringify(c));try{C({type:"SET_BTN_LOADER"});const m=localStorage.getItem("dbname"),d=await z.post("app.php?a=saveSubQnWiseQns&db="+m,h);if(C({type:"UNSET_BTN_LOADER"}),d.data.error_code===0)i==r&&(a[l].fdata[s].fqpcomp="Completed"),f.fdata.length===s+1?(E(a[l+1].fpartcode),v(a[l+1].fdata[0].fqncode),k(a[l+1].fdata[0].fqnarr[0].fqncode),_(a[l+1].fdata[0].fqnno)):(E(a[l].fpartcode),v(a[l].fdata[s+1].fqncode),k(a[l].fdata[s+1].fqnarr[0].fqncode),_(a[l].fdata[s+1].fqnno)),b(a);else{g("warning",d.data.data.msg);return}}catch(m){console.log("error",m.message)}}else E(a[l].fpartcode),v(a[l].fdata[s].fqncode),k(a[l].fdata[s].fqnarr[0].fqncode),_(a[l].fdata[s].fqnno);M(2)},oe=async(f,o,l,s)=>{var i;const n=y;let t=n[o].fdata[l].fmaxmarks,a=0;if(n[o].fdata[l].fqnarr.forEach(h=>{a+=parseInt(h.fmaxmarks)}),a>t){g("info",`Maximum marks is ${t} and marks assigned ${a}`);return}if(n[o].fdata[l].fqnarr[s].fquestionno==""){g("info","Enter Question Number");return}if(n[o].fdata[l].fqnarr[s].fquestion==""){g("info","Enter Question");return}const r=new FormData;r.append("usertype",p.user.fusertype),r.append("qncode",f.fqncode),r.append("data",JSON.stringify(n[o].fdata[l].fqnarr[s])),r.append("params",JSON.stringify(c));try{C({type:"SET_ADD_LOADER"});const h=localStorage.getItem("dbname"),m=await z.post("app.php?a=saveSubQnWiseQns&db="+h,r);if(C({type:"UNSET_ADD_LOADER"}),m.data.error_code===0)if(a==t&&(n[o].fdata[l].fqpcomp="Completed",b(n)),((i=n[o].fdata[l].fqnarr[s+1])==null?void 0:i.fqncode)==null){if(a<t){const d={};d.fqncode=f.fqncode+W,d.fquestionno="",d.fquestion="",d.fkeyAns="",d.fmaxmarks="",d.fco="",d.fpo="",d.fblooms="",d.ftype="Descriptive",d.fopta="",d.foptb="",d.foptc="",d.foptd="",d.fqnfile="",d.fkeyansfile="",d.foptafile="",d.foptbfile="",d.foptcfile="",d.foptdfile="";let Y=n[o].fdata[l].fqnarr;n[o].fdata[l].fqnarr=[...Y,d],b(n),k(f.fqncode+W),M(D=>D+1)}}else E(n[o].fpartcode),v(n[o].fdata[l].fqncode),k(n[o].fdata[l].fqnarr[s+1].fqncode),M(d=>d+1);else{g("warning",m.data.data.msg);return}}catch(h){g("error",h.message)}},le=(f,o,l,s)=>{var n;console.log(f,o,l,s),E(f.fpartcode),s!=0&&((n=y[l].fdata[s-1].fqnarr)==null?void 0:n.length)>0?(v(y[l].fdata[s-1].fqncode),k(y[l].fdata[s-1].fqncode+1),_(y[l].fdata[s-1].fqnno)):(v(t=>t),k(t=>t))},ne=()=>e.jsxs(H,{children:[e.jsx(u,{size:"small",onClick:()=>{$("bold")},children:"B"}),e.jsx(u,{size:"small",onClick:()=>$("italic"),children:"I"}),e.jsx(u,{size:"small",onClick:()=>$("underline"),children:"U"})]}),$=f=>{document.execCommand(f)},L=f=>{f.file.status==="done"?message.success(`${f.file.name} file uploaded successfully`):f.file.status==="error"&&message.error(`${f.file.name} file upload failed.`)},T=async(f,o,l,s,n,t)=>{let a=f.file.name.split(".").pop();if(a!=="jpg"&&a!=="png"&&a!=="jpeg"){g("info","only jpg or png files allowed");return}const r=localStorage.getItem("dbname"),i=new FormData;i.append("univcode",p.user.funivcode),i.append("qpcode",c.qpcode),i.append("year",c.year),i.append("mode",c.mode),i.append("qnno",n),i.append("field",t),i.append("file",f.file),i.append("noqp",c.set),i.append("teachcode",c.teachcode),i.append("userid",p.user.fregno);try{C({type:"SET_LOADER"});const h=await z.post("app.php?a=uploadQnQpFiles&db="+r,i);if(C({type:"UNSET_LOADER"}),h.data.error_code===0){let m=y;m[o].fdata[l].fqnarr[s][t]=h.data.data.msg,b([...m])}else g("error",h.data.data.msg)}catch{g("error",res.data.data.msg)}},N=async(f,o,l,s,n,t)=>{const a=new FormData;a.append("qpcode",c.qpcode),a.append("year",c.year),a.append("mode",c.mode),a.append("teachcode",c.teachcode),a.append("set",c.set),a.append("fqpno",s),a.append("path",n),a.append("field",t);let r=localStorage.getItem("dbname");C({type:"SET_LOADER"});const i=await z.post("app.php?a=deleteThQpFileDet&db="+r+"&univcode="+p.user.funivcode,a);if(C({type:"UNSET_LOADER"}),i.data.error_code===0){let h=y;h[f].fdata[o].fqnarr[l][t]="",b(h)}else g("error",i.data.data.msg)},fe=async(f,o,l,s)=>{const n=new FormData;n.append("usertype",p.user.fusertype),n.append("qncode",f.fqncode),n.append("data",JSON.stringify(y[o].fdata[l].fqnarr[s])),n.append("params",JSON.stringify(c));try{C({type:"SET_DRAFT_LOADER"});const t=localStorage.getItem("dbname"),a=await z.post("app.php?a=saveSubQnWiseQns&db="+t,n);if(C({type:"UNSET_DRAFT_LOADER"}),a.data.error_code===0)g("success",a.data.data.msg);else{g("warning",a.data.data.msg);return}}catch(t){g("error",t.message);return}},q=(f,o,l,s,n)=>{let t=y;t[o].fdata[l].fqnarr[s][n]=f,console.log(t),b([...t])},ce=()=>{window.open(he+"/app.php?a=getOmrQpReport&db="+localStorage.getItem("dbname")+"&univcode="+p.user.funivcode+"&qpcode="+c.qpcode+"&year="+c.year+"&mode="+c.mode+"&teachcode="+c.teachcode+"&noqp="+c.set+"&type="+c.type+"&teachtype="+p.user.fusertype)};return e.jsxs("div",{children:[e.jsx(G,{style:{margin:"6rem 10px 10px"},title:e.jsx("h6",{children:"Prepare Question Paper"}),extra:e.jsxs(H,{children:[e.jsx(X,{to:p.user.fusertype==="M"?"/qpsettings/mod-qp-online-2":"/qpsettings/prepare-qp-2",children:e.jsxs(u,{style:{background:"green",color:"white"},children:[e.jsx(xe,{}),"Back"]})}),e.jsxs(u,{type:"primary",onClick:()=>ce(),children:[e.jsx(ye,{})," Preview"]}),e.jsx(X,{to:"/",children:e.jsxs(u,{type:"primary",danger:!0,children:[e.jsx(je,{})," Exit"]})})]}),children:e.jsx("div",{style:{height:"160px",overflowY:"auto"},children:y.map((f,o)=>{var l;return e.jsxs("div",{children:[e.jsx("span",{children:e.jsxs("b",{children:[f.fpartcode+" - "+f.fpartdesc,":"]})}),(l=f.fdata)==null?void 0:l.map((s,n)=>e.jsx(u,{size:"small",style:{margin:"4px",marginBottom:"3px",background:s.fqpcomp==="Completed"?"green":f.fpartcode==B&&s.fqncode==V&&"orange",color:s.fqpcomp==="Completed"&&"white"},onClick:()=>{K(f,s,o,n,"main")},children:s.fqnno},n))]},o)})})}),e.jsx("div",{children:y.map((f,o)=>e.jsx("div",{children:f.fdata.map((l,s)=>{var n;return e.jsx("div",{children:(n=l.fqnarr)==null?void 0:n.map((t,a)=>e.jsx("div",{children:f.fpartcode==B&&l.fqncode==V&&t.fqncode==w&&e.jsxs(G,{title:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"500",marginRight:"1rem"},children:B+" - Qn. "+Z}),c.type==="THEORY"&&e.jsxs(J.Group,{style:{marginBottom:"10px"},value:t.ftype,onChange:r=>q(r.target.value,o,s,a,"ftype"),children:[e.jsx(J,{value:"Descriptive",children:"Descriptive"}),e.jsx(J,{value:"MCQ",children:"MCQ"})]})]}),style:{margin:" 10px"},extra:e.jsx(ne,{}),children:[e.jsxs(P,{gutter:16,style:{marginBottom:"10px"},children:[e.jsxs(j,{span:4,children:[e.jsx("label",{children:"Qn. No."}),e.jsx(U,{value:t.fquestionno,onChange:r=>q(r.target.value,o,s,a,"fquestionno")})]}),e.jsxs(j,{span:4,children:[e.jsx("label",{children:"Max. Marks"}),e.jsx(U,{value:t.fmaxmarks,onChange:r=>q(r.target.value,o,s,a,"fmaxmarks")})]}),e.jsxs(j,{span:4,children:[e.jsx("label",{children:"CO"}),e.jsx(U,{value:t.fco,onChange:r=>q(r.target.value,o,s,a,"fco")})]}),e.jsxs(j,{span:4,children:[e.jsx("label",{children:"PO"}),e.jsx(U,{value:t.fpo,onChange:r=>q(r.target.value,o,s,a,"fpo")})]}),e.jsxs(j,{span:4,children:[e.jsx("label",{children:"Blooms"}),e.jsx(U,{value:t.fblooms,onChange:r=>q(r.target.value,o,s,a,"fblooms")})]}),(c.type==="MCQ"||t.ftype==="MCQ")&&e.jsxs(j,{span:4,children:[e.jsx("label",{children:"Key Answer"}),e.jsx(ue,{size:"medium",style:{width:"100%"},value:t.fkeyAns,options:ge,onChange:r=>q(r,o,s,a,"fkeyAns")})]})]}),e.jsxs(P,{gutter:16,children:[e.jsxs(j,{xs:24,sm:24,md:12,lg:12,xl:12,xxl:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Enter Question",className:"custom-quill-editor",value:t.fquestion,onChange:r=>q(r,o,s,a,"fquestion")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"fqnfile")},onChange:L,showUploadList:!1,beforeUpload:r=>{I(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.fqnfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.fqnfile,"fqnfile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.fqnfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),c.type==="THEORY"&&t.ftype==="Descriptive"&&e.jsxs(j,{xs:24,sm:24,md:12,lg:12,xl:12,xxl:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Enter Key Answer",className:"custom-quill-editor",value:t.fkeyAns,onChange:r=>q(r,o,s,a,"fkeyAns")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"fkeyansfile")},onChange:L,showUploadList:!1,beforeUpload:r=>{ee(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.fkeyansfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.fkeyansfile,"fkeyansfile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.fkeyansfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),(c.type==="MCQ"||t.ftype==="MCQ")&&e.jsxs(j,{span:12,children:[e.jsxs(P,{gutter:10,style:{marginBottom:"20px"},children:[e.jsxs(j,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Option A",style:{height:"60px",overflowY:"auto"},className:"custom-quill-editor",value:t.fopta,onChange:r=>q(r,o,s,a,"fopta")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"foptafile")},onChange:L,showUploadList:!1,beforeUpload:r=>{ae(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptafile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.foptafile,"foptafile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.foptafile,target:"_blank",style:{float:"right"},children:"View"})]})]}),e.jsxs(j,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Option B",style:{height:"60px",overflowY:"auto"},className:"custom-quill-editor",value:t.foptb,onChange:r=>q(r,o,s,a,"foptb")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"foptbfile")},onChange:L,showUploadList:!1,beforeUpload:r=>{te(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptbfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.foptbfile,"foptbfile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.foptbfile,target:"_blank",style:{float:"right"},children:"View"})]})]})]}),e.jsxs(P,{gutter:10,children:[e.jsxs(j,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Option C",style:{height:"60px",overflowY:"auto"},className:"custom-quill-editor",value:t.foptc,onChange:r=>q(r,o,s,a,"foptc")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"foptcfile")},onChange:L,showUploadList:!1,beforeUpload:r=>{se(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptcfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.foptcfile,"foptcfile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.foptcfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),e.jsxs(j,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(A,{placeholder:"Option D",style:{height:"60px",overflowY:"auto"},className:"custom-quill-editor",value:t.foptd,onChange:r=>q(r,o,s,a,"foptd")})}),e.jsx(R,{customRequest:r=>{T(r,o,s,a,t.fqncode,"foptdfile")},onChange:L,showUploadList:!1,beforeUpload:r=>{re(r)},maxCount:1,children:e.jsxs(u,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptdfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{title:"Delete the task",description:"Are you sure to delete this image?",onConfirm:()=>{N(o,s,a,t.fqncode,t.foptdfile,"foptdfile")},onCancel:()=>console.log("CANCELLED"),okText:"Yes",cancelText:"No",children:e.jsx(u,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,children:e.jsx(F,{})})}),e.jsx("a",{href:S+t.foptdfile,target:"_blank",style:{float:"right"},children:"View"})]})]})]})]})]}),e.jsx(P,{gutter:16,children:e.jsx(j,{style:{marginTop:"10px",textAlign:"right"},span:24,children:e.jsxs(H,{children:[e.jsx(u,{type:"primary",size:"medium",style:{float:"right"},onClick:()=>le(f,l,o,s),children:"Previous Question"}),e.jsx(u,{disabled:c.disabled=="T",type:"primary",size:"medium",loading:p.draftLoading,style:{float:"right",background:"#4285f4",color:"white"},onClick:()=>fe(l,o,s,a),children:"Save as Draft"}),c.type!=="MCQ"&&e.jsx(u,{disabled:c.disabled=="T",size:"medium",loading:p.addLoading,style:{float:"right"},onClick:()=>oe(l,o,s,a),children:"Save & Add / Preview Questions"}),e.jsx(u,{disabled:c.disabled=="T",type:"primary",size:"medium",loading:p.btnLoading,style:{float:"right",background:"green"},onClick:()=>{K(f,l,o,s,a,"next")},children:"Save & Next Question"})]})})})]})},a))},s)})},o))})]})},Ce=p=>({templateDetails:p.getTemplateDetails,user:p.loginfo.userData,draftLoading:p.loader.draftLoading,addLoading:p.loader.addLoading,btnLoading:p.loader.btnLoading}),$e=de(Ce,{getTemplateDetails:me})(qe);export{$e as default};
|