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 : 18.116.28.79
Current Path : /var/www/qpms/assets/ |
| Current File : /var/www/qpms/assets/PrepareQuestionPaper-B8rheiYV.js |
import{x as fe,H as pe,Q as ce,r as x,t as e,D as K,L as G,B as i,F as _,G as de,E as g,v as U}from"./index-DNLfgd66.js";import{R as N}from"./quill.snow-amr1B7Us.js";import{g as ie}from"./PrepareQuestionPaper-Ck0OHzrj.js";import{k as ue}from"./sem-D2Wh8RBS.js";import{S as Y}from"./index-Cegtx7Nr.js";import{R as he}from"./ArrowLeftOutlined-GF0uN8JT.js";import{R as me}from"./HomeOutlined-DwpzT65z.js";import{R as H}from"./index-Dpalldti.js";import{R as z,C as y}from"./row-C84ed1oX.js";import{U as F,R as O}from"./UploadOutlined-BJPeH4q9.js";import{R as T}from"./DeleteOutlined-SX1JhiA6.js";import"./index-CdwpRzQe.js";import"./responsiveObserver-DLOaSOjc.js";const ge=d=>{const b=pe(),h=ce(),[j,v]=x.useState([]),[P,S]=x.useState(""),[J,C]=x.useState(""),[V,M]=x.useState(2),[X,A]=x.useState(""),[Z,k]=x.useState(""),[je,w]=x.useState(null),[ye,I]=x.useState(null),[qe,ee]=x.useState(null),[be,ae]=x.useState(null),[ve,te]=x.useState(null),[ke,se]=x.useState(null),E="https://omr-files.s3.ap-south-1.amazonaws.com/";x.useEffect(()=>{d.getTemplateDetails(h)},[]),x.useEffect(()=>{var o,l,s,n,t,a,r;let f=d.templateDetails.map((p,u)=>(p.fdata.map((m,c)=>{let B=0;return m.fqnarr.map((D,Ce)=>(B+=parseInt(D.fmaxmarks),D.ftype=h.type=="THEORY"&&D.ftype==""?"Descriptive":D.ftype,D)),B==m.fmaxmarks&&(m.fqpcomp="Completed"),m}),p));v(f),S((o=d.templateDetails[0])==null?void 0:o.fpartcode),C((s=(l=d.templateDetails[0])==null?void 0:l.fdata[0])==null?void 0:s.fqncode),A((t=(n=d.templateDetails[0])==null?void 0:n.fdata[0])==null?void 0:t.fqnno),k((r=(a=d.templateDetails[0])==null?void 0:a.fdata[0])==null?void 0:r.fqnarr[0].fqncode)},[d.templateDetails]),x.useEffect(()=>{v(j)},[j]);const W=async(f,o,l,s,n,t)=>{const a=j;if(t==="next"){let r=a[l].fdata[s].fmaxmarks,p=0;if(a[l].fdata[s].fqnarr.forEach(m=>{p+=parseInt(m.fmaxmarks)}),p>r){g("info",`Maximum marks is ${r} and marks assigned ${p}`);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 u=new FormData;u.append("usertype",d.user.fusertype),u.append("qncode",o.fqncode),u.append("data",JSON.stringify(a[l].fdata[s].fqnarr[n])),u.append("params",JSON.stringify(h));try{b({type:"SET_BTN_LOADER"});const m=localStorage.getItem("dbname"),c=await U.post("app.php?a=saveSubQnWiseQns&db="+m,u);b({type:"UNSET_BTN_LOADER"}),c.data.error_code===0&&(p==r&&(a[l].fdata[s].fqpcomp="Completed"),f.fdata.length===s+1?(S(a[l+1].fpartcode),C(a[l+1].fdata[0].fqncode),k(a[l+1].fdata[0].fqnarr[0].fqncode),A(a[l+1].fdata[0].fqnno)):(S(a[l].fpartcode),C(a[l].fdata[s+1].fqncode),k(a[l].fdata[s+1].fqnarr[0].fqncode),A(a[l].fdata[s+1].fqnno)),v(a))}catch(m){g("error",m.message)}}else S(a[l].fpartcode),C(a[l].fdata[s].fqncode),k(a[l].fdata[s].fqnarr[0].fqncode),A(a[l].fdata[s].fqnno);M(2)},re=async(f,o,l,s)=>{var p;const n=j;let t=n[o].fdata[l].fmaxmarks,a=0;if(n[o].fdata[l].fqnarr.forEach(u=>{a+=parseInt(u.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",d.user.fusertype),r.append("qncode",f.fqncode),r.append("data",JSON.stringify(n[o].fdata[l].fqnarr[s])),r.append("params",JSON.stringify(h));try{b({type:"SET_ADD_LOADER"});const u=localStorage.getItem("dbname"),m=await U.post("app.php?a=saveSubQnWiseQns&db="+u,r);if(b({type:"UNSET_ADD_LOADER"}),m.data.error_code===0)if(a==t&&(n[o].fdata[l].fqpcomp="Completed",v(n)),((p=n[o].fdata[l].fqnarr[s+1])==null?void 0:p.fqncode)==null){if(a<t){const c={};c.fqncode=f.fqncode+V,c.fquestionno="",c.fquestion="",c.fkeyAns="",c.fmaxmarks="",c.fco="",c.fpo="",c.fblooms="",c.ftype="Descriptive",c.fopta="",c.foptb="",c.foptc="",c.foptd="",c.fqnfile="",c.fkeyansfile="",c.foptafile="",c.foptbfile="",c.foptcfile="",c.foptdfile="";let B=n[o].fdata[l].fqnarr;n[o].fdata[l].fqnarr=[...B,c],v(n),k(f.fqncode+V),M(D=>D+1)}}else S(n[o].fpartcode),C(n[o].fdata[l].fqncode),k(n[o].fdata[l].fqnarr[s+1].fqncode),M(c=>c+1);else g("warning",m.data.data.msg)}catch(u){g("error",u.message)}},oe=(f,o,l,s)=>{var n;console.log(f,o,l,s),S(f.fpartcode),s!=0&&((n=j[l].fdata[s-1].fqnarr)==null?void 0:n.length)>0?(C(j[l].fdata[s-1].fqncode),k(j[l].fdata[s-1].fqncode+1),A(j[l].fdata[s-1].fqnno)):(C(t=>t),k(t=>t))},le=()=>e.jsxs(Y,{children:[e.jsx(i,{size:"small",onClick:()=>{$("bold")},children:"B"}),e.jsx(i,{size:"small",onClick:()=>$("italic"),children:"I"}),e.jsx(i,{size:"small",onClick:()=>$("underline"),children:"U"})]}),$=f=>{document.execCommand(f)},Q=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.`)},R=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"),p=new FormData;p.append("univcode",d.user.funivcode),p.append("qpcode",h.qpcode),p.append("year",h.year),p.append("mode",h.mode),p.append("qnno",n),p.append("field",t),p.append("file",f.file),p.append("noqp",h.set),p.append("teachcode",h.teachcode),p.append("userid",d.user.fregno);try{b({type:"SET_LOADER"});const u=await U.post("app.php?a=uploadQnQpFiles&db="+r,p);if(b({type:"UNSET_LOADER"}),u.data.error_code===0){let m=j;m[o].fdata[l].fqnarr[s][t]=u.data.data.msg,v([...m])}else g("error",u.data.data.msg)}catch{g("error",res.data.data.msg)}},L=async(f,o,l,s,n,t)=>{const a=new FormData;a.append("qpcode",h.qpcode),a.append("year",h.year),a.append("mode",h.mode),a.append("teachcode",h.teachcode),a.append("set",h.set),a.append("fqpno",s),a.append("path",n),a.append("field",t);let r=localStorage.getItem("dbname");b({type:"SET_LOADER"});const p=await U.post("app.php?a=deleteThQpFileDet&db="+r+"&univcode="+d.user.funivcode,a);if(b({type:"UNSET_LOADER"}),p.data.error_code===0){let u=j;u[f].fdata[o].fqnarr[l][t]="",v(u)}else g("error",p.data.data.msg)},ne=async(f,o,l,s)=>{const n=new FormData;n.append("usertype",d.user.fusertype),n.append("qncode",f.fqncode),n.append("data",JSON.stringify(j[o].fdata[l].fqnarr[s])),n.append("params",JSON.stringify(h));try{b({type:"SET_DRAFT_LOADER"});const t=localStorage.getItem("dbname"),a=await U.post("app.php?a=saveSubQnWiseQns&db="+t,n);if(b({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=j;t[o].fdata[l].fqnarr[s][n]=f,console.log(t),v([...t])};return e.jsxs("div",{children:[e.jsx(K,{style:{margin:"6rem 10px 10px"},title:e.jsx("h6",{children:"Prepare Question Paper"}),extra:e.jsxs(Y,{children:[e.jsx(G,{to:d.user.fusertype==="M"?"/qpsettings/mod-qp-online-2":"/qpsettings/prepare-qp-2",children:e.jsxs(i,{style:{background:"green",color:"white"},children:[e.jsx(he,{}),"Back"]})}),e.jsx(G,{to:"/",children:e.jsxs(i,{type:"primary",danger:!0,children:[e.jsx(me,{})," Exit"]})})]}),children:e.jsx("div",{style:{height:"160px",overflowY:"auto"},children:j.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(i,{size:"small",style:{margin:"4px",marginBottom:"3px",background:s.fqpcomp==="Completed"?"green":f.fpartcode==P&&s.fqncode==J&&"orange",color:s.fqpcomp==="Completed"&&"white"},onClick:()=>{W(f,s,o,n,"main")},children:s.fqnno},n))]},o)})})}),e.jsx("div",{children:j.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==P&&l.fqncode==J&&t.fqncode==Z&&e.jsxs(K,{title:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:"500",marginRight:"1rem"},children:P+" - Qn. "+X}),h.type==="THEORY"&&e.jsxs(H.Group,{style:{marginBottom:"10px"},value:t.ftype,onChange:r=>q(r.target.value,o,s,a,"ftype"),children:[e.jsx(H,{value:"Descriptive",children:"Descriptive"}),e.jsx(H,{value:"MCQ",children:"MCQ"})]})]}),style:{margin:" 10px"},extra:e.jsx(le,{}),children:[e.jsxs(z,{gutter:16,style:{marginBottom:"10px"},children:[e.jsxs(y,{span:4,children:[e.jsx("label",{children:"Qn. No."}),e.jsx(_,{value:t.fquestionno,onChange:r=>q(r.target.value,o,s,a,"fquestionno")})]}),e.jsxs(y,{span:4,children:[e.jsx("label",{children:"Max. Marks"}),e.jsx(_,{value:t.fmaxmarks,onChange:r=>q(r.target.value,o,s,a,"fmaxmarks")})]}),e.jsxs(y,{span:4,children:[e.jsx("label",{children:"CO"}),e.jsx(_,{value:t.fco,onChange:r=>q(r.target.value,o,s,a,"fco")})]}),e.jsxs(y,{span:4,children:[e.jsx("label",{children:"PO"}),e.jsx(_,{value:t.fpo,onChange:r=>q(r.target.value,o,s,a,"fpo")})]}),e.jsxs(y,{span:4,children:[e.jsx("label",{children:"Blooms"}),e.jsx(_,{value:t.fblooms,onChange:r=>q(r.target.value,o,s,a,"fblooms")})]}),(h.type==="MCQ"||t.ftype==="MCQ")&&e.jsxs(y,{span:4,children:[e.jsx("label",{children:"Key Answer"}),e.jsx(de,{size:"medium",style:{width:"100%"},value:t.fkeyAns,options:ue,onChange:r=>q(r,o,s,a,"fkeyAns")})]})]}),e.jsxs(z,{gutter:16,children:[e.jsxs(y,{xs:24,sm:24,md:12,lg:12,xl:12,xxl:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{placeholder:"Enter Question",className:"custom-quill-editor",value:t.fquestion,onChange:r=>q(r,o,s,a,"fquestion")})}),e.jsx(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"fqnfile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{w(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.fqnfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.fqnfile,"fqnfile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.fqnfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),h.type==="THEORY"&&t.ftype==="Descriptive"&&e.jsxs(y,{xs:24,sm:24,md:12,lg:12,xl:12,xxl:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{placeholder:"Enter Key Answer",className:"custom-quill-editor",value:t.fkeyAns,onChange:r=>q(r,o,s,a,"fkeyAns")})}),e.jsx(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"fkeyansfile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{I(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.fkeyansfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.fkeyansfile,"fkeyansfile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.fkeyansfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),h.type==="MCQ"||t.ftype==="MCQ"&&e.jsxs(y,{span:12,children:[e.jsxs(z,{gutter:10,style:{marginBottom:"20px"},children:[e.jsxs(y,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{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(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"foptafile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{ee(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptafile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.foptafile,"foptafile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.foptafile,target:"_blank",style:{float:"right"},children:"View"})]})]}),e.jsxs(y,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{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(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"foptbfile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{ae(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptbfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.foptbfile,"foptbfile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.foptbfile,target:"_blank",style:{float:"right"},children:"View"})]})]})]}),e.jsxs(z,{gutter:10,children:[e.jsxs(y,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{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(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"foptcfile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{te(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptcfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.foptcfile,"foptcfile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.foptcfile,target:"_blank",style:{float:"right"},children:"View"})]})]}),e.jsxs(y,{span:12,children:[e.jsx("div",{className:"editor-container",children:e.jsx(N,{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(F,{customRequest:r=>{R(r,o,s,a,t.fqncode,"foptdfile")},onChange:Q,showUploadList:!1,beforeUpload:r=>{se(r)},maxCount:1,children:e.jsxs(i,{size:"small",style:{marginTop:"5px"},children:[e.jsx(O,{})," Upload"]})}),t.foptdfile!==""&&e.jsxs(e.Fragment,{children:[e.jsx(i,{style:{float:"right",marginLeft:"10px"},size:"small",type:"primary",danger:!0,onClick:()=>{L(o,s,a,t.fqncode,t.foptdfile,"foptdfile")},children:e.jsx(T,{})}),e.jsx("a",{href:E+t.foptdfile,target:"_blank",style:{float:"right"},children:"View"})]})]})]})]})]}),e.jsx(z,{gutter:16,children:e.jsx(y,{style:{marginTop:"10px",textAlign:"right"},span:24,children:e.jsxs(Y,{children:[e.jsx(i,{type:"primary",size:"medium",style:{float:"right"},onClick:()=>oe(f,l,o,s),children:"Previous Question"}),e.jsx(i,{type:"primary",size:"medium",loading:d.draftLoading,style:{float:"right",background:"#4285f4",color:"white"},onClick:()=>ne(l,o,s,a),children:"Save as Draft"}),e.jsx(i,{size:"medium",loading:d.addLoading,style:{float:"right"},onClick:()=>re(l,o,s,a),children:"Save & Add / Preview Questions"}),e.jsx(i,{type:"primary",size:"medium",loading:d.btnLoading,style:{float:"right",background:"green"},onClick:()=>{W(f,l,o,s,a,"next")},children:"Save & Next Question"})]})})})]})},a))},s)})},o))})]})},xe=d=>({templateDetails:d.getTemplateDetails,user:d.loginfo.userData,draftLoading:d.loader.draftLoading,addLoading:d.loader.addLoading,btnLoading:d.loader.btnLoading}),ze=fe(xe,{getTemplateDetails:ie})(ge);export{ze as default};
|