0xV3NOMx
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.144.224.105


Current Path : /var/www/qpms/assets/
Upload File :
Current File : /var/www/qpms/assets/PrepareQuestionPaper-CN23riis.js

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