1(this.webpackJsonpstatstudio=this.webpackJsonpstatstudio||[]).push([[50],{1114:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(1);function s(e,t){const[n,s]=Object(i.useState)(!0),[o,a]=Object(i.useState)(null),[l,r]=Object(i.useState)(null);return{data:l,setData:r,loadingData:n,error:o,fetchData:async()=>{s(!0);try{const n=await e(t);r(n)}catch(o){a(o)}s(!1)}}}},1327:function(e,t,n){},1376:function(e,t,n){"use strict";n.d(t,"c",(function(){return O})),n.d(t,"e",(function(){return y})),n.d(t,"a",(function(){return q})),n.d(t,"d",(function(){return _})),n.d(t,"b",(function(){return N}));var i=n(1),s=n(29),o=n(869),a=n(8),l=n(68),r=n(31),c=n(212),d=n(1114),u=n(43),m=n(137),h=n(972),p=n(923),f=n(383),b=n(3);function g(e){let{quizId:t,staffId:n}=e;const{data:s,setData:o,loadingData:a,fetchData:l,error:r}=Object(d.a)(u.a.getQuizResponses,{quizId:t,staffId:n});return Object(i.useEffect)((()=>{l()}),[]),Object(b.jsx)(b.Fragment,{children:a?Object(b.jsx)(h.a,{}):0===(null===s||void 0===s?void 0:s.length)?Object(b.jsx)("p",{className:"text-center",children:"No responses found"}):Object(b.jsx)("ul",{children:null===s||void 0===s?void 0:s.map((e=>Object(b.jsx)("li",{children:e.quiz_question_info.type===p.c?Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("h5",{className:"font-weight-bold",children:"Open Text"}),Object(b.jsx)("div",{class:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.quiz_question_info.question}}),Object(b.jsx)("p",{className:"text-muted mt-1",children:"Response:"}),Object(b.jsx)(m.a,{value:e.text,onChange:e=>{},readOnly:!0,height:100,minHeight:100,enableAI:!1}),Object(b.jsx)("hr",{})]}):e.quiz_question_info.type===p.f?Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("h5",{className:"font-weight-bold",children:"Submission"}),Object(b.jsx)("div",{className:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.quiz_question_info.question}}),e.text&&Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("p",{className:"text-muted mt-1",children:"Text Response:"}),Object(b.jsx)(m.a,{value:e.text,onChange:()=>{},readOnly:!0,height:100,minHeight:100,enableAI:!1})]}),e.files&&e.files.length>0&&Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("p",{className:"text-muted mt-3",children:"Submitted Files:"}),Object(b.jsx)(f.a,{uploadedFiles:e.files,setUploadedFiles:()=>{},callbackFunc:null,disableDelete:!0})]}),Object(b.jsx)("hr",{})]}):Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("h5",{className:"font-weight-bold",children:e.quiz_question_info.type===p.b?"Multiple Choice":"Single Choice"}),Object(b.jsx)("div",{class:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.quiz_question_info.question}}),Object(b.jsx)("p",{className:"text-muted mt-1",children:Object(b.jsx)("em",{children:"Choices:"})}),Object(b.jsx)("div",{className:"mt-2",children:e.quiz_question_info.choices.map(((t,n)=>{const i=e.selected_choices_info.some((e=>e.id===t.id));return Object(b.jsxs)("li",{className:"d-flex align-items-center my-1",children:[Object(b.jsxs)("span",{className:"mr-2",children:[n+1,". "]}),Object(b.jsx)("div",{className:"mr-2 "+(i?"font-weight-bold":""),dangerouslySetInnerHTML:{__html:t.text}}),i&&Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)("span",{className:"ml-2 text-primary",children:"(Chosen)"}),t.is_correct?Object(b.jsx)(c.b,{className:"text-success ml-2"}):Object(b.jsx)(c.j,{className:"text-danger ml-2"})]})]},t.id)}))}),Object(b.jsx)("hr",{})]})})))})})}function j(e){let{quizId:t,staffId:n,quizTitle:s}=e;const[o,a]=Object(i.useState)(!1);return Object(b.jsxs)(b.Fragment,{children:[Object(b.jsx)(l.a,{variant:"primary",size:"sm",onClick:()=>a(!0),children:"View Response"}),Object(b.jsxs)(r.a,{backdrop:"static",size:"lg",enforceFocus:!1,show:o,onHide:()=>a(!1),children:[Object(b.jsx)(r.a.Header,{closeButton:!0,children:Object(b.jsxs)(r.a.Title,{children:["Quiz Responses: ",s||""]})}),Object(b.jsx)(r.a.Body,{children:Object(b.jsx)(g,{quizId:t,staffId:n})})]})]})}var x=n(6),v=n(900);const O=e=>{var t,n,i,o,a,l,r;const c=`/knowledgebase/articles/${null===(t=e.data)||void 0===t||null===(n=t.article_info)||void 0===n?void 0:n.id}`,d=`/knowledgebase/courses/${null===(i=e.data)||void 0===i||null===(o=i.course_info)||void 0===o?void 0:o.id}`,u=e.data.acknowledgement_type,m="ARTICLE_ACKNOWLEDGEMENT"===u?c:d,h=(null===(r={ARTICLE_ACKNOWLEDGEMENT:e.data.article_info,COURSE_ACKNOWLEDGEMENT:{...e.data.course_info,title:null===(a=e.data)||void 0===a||null===(l=a.course_info)||void 0===l?void 0:l.name},QUIZ_ACKNOWLEDGEMENT:e.data.quiz_info,ARTICLE_VIEWED:e.data.article_info,COURSE_VIEWED:e.data.course_info}
1[u])||void 0===r?void 0:r.title)||"None";return"QUIZ_ACKNOWLEDGEMENT"===u?h:"ARTICLE_VIEWED"===u?Object(b.jsx)(s.b,{to:c,children:h}):Object(b.jsx)(s.b,{to:m,children:h})},y=e=>{if(null==e.value)return"";return{ARTICLE_ACKNOWLEDGEMENT:"ARTICLE",COURSE_ACKNOWLEDGEMENT:"COURSE",QUIZ_ACKNOWLEDGEMENT:"QUIZ",ARTICLE_VIEWED:"VIEWED",COURSE_VIEWED:"COURSE"}[e.value]},q=e=>{var t,n,i,s,o,a,l,r,c,d,u,m;return{ARTICLE_ACKNOWLEDGEMENT:null===(t=e.data)||void 0===t||null===(n=t.article_info)||void 0===n||null===(i=n.article_category)||void 0===i?void 0:i.category,ARTICLE_VIEWED:null===(s=e.data)||void 0===s||null===(o=s.article_info)||void 0===o||null===(a=o.article_category)||void 0===a?void 0:a.category,COURSE_ACKNOWLEDGEMENT:null===(l=e.data)||void 0===l||null===(r=l.course_info)||void 0===r||null===(c=r.category)||void 0===c?void 0:c.name,COURSE_VIEWED:null===(d=e.data)||void 0===d||null===(u=d.course_info)||void 0===u||null===(m=u.category)||void 0===m?void 0:m.name}[e.data.acknowledgement_type]||"None"},_=e=>Object(b.jsx)(j,{quizId:e.data.quiz_info.id,staffId:e.data.staff,quizTitle:e.data.quiz_info.title}),N=e=>{var t,n,s,l,r,c,d;const[m,h]=Object(i.useState)(!1),p="ARTICLE_ACKNOWLEDGEMENT"===(null===(t=e.data)||void 0===t?void 0:t.acknowledgement_type),f=(null===(n=e.data)||void 0===n||null===(s=n.article_info)||void 0===s?void 0:s.id)||(null===(l=e.data)||void 0===l?void 0:l.article),g=(null===(r=e.data)||void 0===r||null===(c=r.staff_info)||void 0===c?void 0:c.id)||(null===(d=e.data)||void 0===d?void 0:d.staff);return p?Object(b.jsx)("span",{className:"cursor-pointer d-inline-flex align-items-center",onClick:m?void 0:async()=>{if(f&&g){h(!0);try{const e=await u.a.getArticleAttestationData(g,f);if(!e)return void a.b.error("Could not load attestation data.");const{articleContent:t,acknowledgement:n,staffName:i,companyName:s,isVersionContent:o}=e;await Object(v.b)(t,n,i,s,((null===t||void 0===t?void 0:t.title)||"attestation").replace(/[^a-z0-9]/gi,"-"),x.a,o)}catch(e){console.error("Print attestation error:",e),a.b.error("Error generating attestation PDF.")}finally{h(!1)}}},title:"Print attestation",role:"button","aria-label":"Print attestation",style:m?{pointerEvents:"none"}:{},children:m?Object(b.jsx)(o.a,{animation:"border",size:"sm"}):Object(b.jsx)("i",{className:"feather icon-printer"})}):null}},1962:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return h}));n(331);var i=n(905),s=n(63),o=n(1),a=n(837),l=(n(1327),n(1376)),r=n(893),c=n(43),d=n(33),u=n(34),m=n(3);function h(){const e=Object(o.useMemo)((()=>({height:"500px",width:"100%"})),[]),t=[{field:"title_name",headerName:"Title",filter:"agTextColumnFilter",cellRenderer:"CourseNameOrTitleRenderer",minWidth:350,flex:2,sortable:!0,filter:"agTextColumnFilter",filterParams:{buttons:["apply","clear","reset","cancel"],debounceMs:500,caseSensitive:!1,closeOnApply:!0,filterOptions:["contains"],filterPlaceholder:"Search quiz title...",maxNumConditions:1}},{field:"acknowledgement_type",filter:"agSetColumnFilter",headerName:"Type",sortable:!1,valueFormatter:l.e},{field:"staff_info.get_full_name",filter:"agSetColumnFilter",headerName:"Employee",sortable:!1,filterParams:{buttons:["apply","clear","reset"],closeOnApply:!0,values:async e=>{const t=await d.g.getAllUsersSimple();if(t){const n=Object(u.r)(t,"full_name_or_email"),i=null===n||void 0===n?void 0:n.map((e=>JSON.stringify({id:e.id,full_name_or_email:e.full_name_or_email})));e.success(i)}},keyCreator:e=>JSON.parse(e.value).id,valueFormatter:e=>JSON.parse(e.value).full_name_or_email}},{field:"timestamp",filter:"agDateColumnFilter",headerName:"Date",sortable:!0,filterParams:{filterOptions:["inRange"],buttons:["apply","clear","reset"],suppressAndOrCondition:!0},valueFormatter:r.b},{field:"response",headerName:"View Response",cellRenderer:"QuizResponseActionRenderer",filter:"agTextColumnFilter"}],n=Object(o.useRef)(null),h=Object(o.useCallback)((e=>e.value),[]),p=Object(o.useMemo)((()=>({editable:!1,enableRowGroup:!1,enablePivot:!1,enableValue:!1,sortable:!1,resizable:!0,flex:1,minWidth:100,menuTabs:["filterMenuTab","generalMenuTab"]})),[]);return Object(m.jsxs)(a.a,{children:[Object(m.jsx)(a.a.Header,{children:Object(m.jsx)("h5",{children:"Qu
1iz Acknowledgement Timeline"})}),Object(m.jsx)(a.a.Body,{children:Object(m.jsx)("div",{style:e,className:"ag-theme-alpine",children:Object(m.jsx)(i.AgGridReact,{ref:n,columnDefs:null===t||void 0===t?void 0:t.map((e=>({...e,headerTooltip:e.headerName,tooltipValueGetter:h}))),defaultColDef:p,rowModelType:"serverSide",suppressServerSideInfiniteScroll:!1,pagination:!1,enableCharts:!0,enableRangeSelection:!0,cacheBlockSize:10,cacheOverflowSize:10,paginationPageSize:10,onGridReady:e=>{e.api.setServerSideDatasource({getRows:async e=>{var t,n,i,o;const a=Math.floor(e.request.endRow/10)||1;let l="";e.request.sortModel&&(l=Object(u.b)(e.request.sortModel)),console.log("title name filter ",e.request.filterModel.title_name);const r=null===(t=e.request.filterModel["staff_info.get_full_name"])||void 0===t||null===(n=t.values)||void 0===n?void 0:n.map((e=>JSON.parse(e).id)),d=e.request.filterModel.timestamp,m=null===(i=e.request.filterModel.acknowledgement_type)||void 0===i?void 0:i.values,h=(null===(o=e.request.filterModel.title_name)||void 0===o?void 0:o.filter)||"";let p="",f="";"inRange"==(null===d||void 0===d?void 0:d.type)&&(p=Object(s.a)(d.dateFrom).format("YYYY-MM-DD"),f=Object(s.a)(d.dateTo).format("YYYY-MM-DD"));let b={paginate:!0,page:a,page_size:10,ordering:l,action:"QUIZ_COMPLETED",start_date:p,end_date:f,title_name:h};r&&(b.employees_ids=r),m&&(null===m||void 0===m?void 0:m.length)>0&&(b.content_type=m[0]),await c.a.getAcknowledgements(b).then((t=>{t?e.success({rowData:t.results,rowCount:t.count}):e.fail()}))}})},rowBuffer:0,maxBlocksInCache:10,components:{CourseNameOrTitleRenderer:l.c,QuizResponseActionRenderer:l.d},rowHeight:42})})})]})}},893:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(63);function s(e){return null==e?"":Object(i.a)(e).format("L")}t.b=function(e){return null==e.value?"":Object(i.a)(e.value).format("ll")}},900:function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return r}));n(961);var i=n(1005);function s(){document.querySelectorAll(".printhide").forEach((function(e){e.classList.contains("d-none")?e.classList.remove("d-none"):e.classList.add("d-none")}))}const o=(e,t)=>{const n=new i.jsPDF("landscape","mm","letter");n.addFileToVFS("FontAwesome.ttf","base64-encoded-font-string"),n.addFont("FontAwesome.ttf","FontAwesome","normal"),n.setFont("FontAwesome"),n.text(20,20,"\uf002"),n.html(e,{callback:function(e){const n=t||"generated";e.save(`${n}.pdf`)},x:10,y:10,width:259.4,windowWidth:1056})},a=async(e,t,n)=>{s();try{var o;const a=new i.jsPDF("p","mm","a4"),r=l(t.innerHTML),c=`\n <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; max-width: 100%; padding: 0; background: white;">\n <div style="padding: 10px; margin-bottom: 0;">\n <div style="border-left: 4px solid #04a9f5; margin-left: -15px;">\n <h1 style="margin: 0 0 10px 0; font-size: 30px; padding-left: 10px; font-weight: 700; color: #212529; line-height: 1.2;">${(null===e||void 0===e?void 0:e.title)||"Article"}</h1>\n </div>\n <div style="color: #6c757d; font-size: 18px;">\n ${null!==e&&void 0!==e&&e.author?`<span>${e.author}</span>`:""}\n ${null!==e&&void 0!==e&&e.published_on?`<span> | ${new Date(e.published_on).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"2-digit"})}</span>`:""}\n ${null!==e&&void 0!==e&&e.version?`<span> | Version ${e.version}</span>`:""}\n ${(null===e||void 0===e?void 0:e.version)>1&&null!==e&&void 0!==e&&e.last_edited_on?`<span> | Last updated: ${new Date(e.last_edited_on).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"2-digit"})}</span>`:""}\n ${null!==e&&void 0!==e&&null!==(o=e.type_info)&&void 0!==o&&o.type?`<span> | <span style="color: ${e.type_info.color||"#007bff"};">${e.type_info.type}</span></span>`:""}\n </div>\n </div>\n <div style="padding: 10px; line-height: 1.6; color: #333; background: white;">\n ${r}\n </div>\n </div>\n `;await a.html(c,{callback:function(e){const t=n||"article";e.save(`${t}.pdf`)},x:10,y:10,width:170,windowWidth:800,margin:[10,10,10,10],autoPaging:"text",html2canvas:{allowTaint:!0,useCORS:!0}})}catch(a){console.error("Error generating PDF:",a),alert("Error generating PDF. Please try again.")}finally{s()}};function l(e){return e?e.replace(/<ul>/g,'<ul style="list-style-type: disc; padding-left: 2em; margin: 1em 0;">').replace(/<ol>/g,'<ol style="list-style-type: decimal; padding-left: 2em; margin: 1em 0;">').replace(/<li>/g,'<li style="display: list-item; margin: 0.5em 0;">').replace(/<table>/g,'<table style="border-collapse: collapse; width: 100%; margin: 1em 0;">').replace(/<th>/g,'<th style="border: 1px solid #ddd; padding: 8px; text-align: left; background-color: #f8f9fa; font-weight: bold;">').replace(/<td>/g,'<td style="border: 1px solid #ddd; padding: 8px; text-align: left;">').replace(/<p>/g,'<p style="margin: 1em 0;">').replace(/<h1>/g,'<h1 style="margin: 1em 0; font-size: 2em; font-weight: bold;">').replace(/<h2>/g,'<h2 style="margin: 1em 0; font-size: 1.6em; font-weight: bold;">').replace(/<h3>/g,'<h3 style="margin: 1em 0; font-size: 1.17em; font-weight: bold;">').replace(/<h4>/g,'<h4 style="margin: 1em 0; font-weight: bold;">').replace(/<h5>/g,'<h5 style="margin: 1em 0; font-size: 0.83em; font-weight: bold;">').replace(/<h6>/g,'<h6 style="margin: 1em 0; font-size: 0.67em; font-weight: bold;">'):""}const r=async function(e,t,n,o,a){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",c=arguments.length>6&&void 0!==arguments[6]&&arguments[6];s();const d=(new Date).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),u=null!==e&&void 0!==e&&e.published_on?new Date(e.published_on).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}):"",m=null!==t&&void 0!==t&&t.timestamp?new Date(t.timestamp).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}
1):"",h=null!==e&&void 0!==e&&e.version?`Version ${e.version}`:"",p=c?`This attestation applies to the version of the policy edited on ${u}${h?` (${h})`:""}.`:`This attestation applies to the policy${u?` edited on ${u}`:""}.`;let f="";if(1===(null===t||void 0===t?void 0:t.question_type)&&null!==t&&void 0!==t&&t.signature_image){f=`<img src="${t.signature_image.startsWith("http")?t.signature_image:((null===r||void 0===r?void 0:r.replace(/\/$/,""))||"")+t.signature_image}" width="120" alt="signature" style="display:block;margin:8px 0;" />`}else if(2===(null===t||void 0===t?void 0:t.question_type)&&null!==t&&void 0!==t&&t.question){const e=(t.answer||"").split(",").map((e=>e.trim())).filter(Boolean);f=`\n <p style="margin:0 0 4px 0;font-weight:bold;">${t.question}</p>\n <div style="margin-bottom:12px;">\n ${e.map((e=>`<p style="margin:0 0 2px 0;font-size:11px;">${e}</p>`)).join("")}\n </div>\n `}const b=l((null===e||void 0===e?void 0:e.body)||""),g=`\n <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; max-width: 100%; padding: 0; background: white;">\n <div style="padding: 10px; margin-bottom: 0;">\n <div style="border-left: 4px solid #04a9f5; margin-left: -15px;">\n <h1 style="margin: 0 0 10px 0; font-size: 30px; padding-left: 10px; font-weight: 700; color: #212529; line-height: 1.2;">Certificate of Acknowledgement</h1>\n </div>\n <div style="color: #6c757d; font-size: 16px; margin-bottom: 10px;">\n <span>${o||""}</span>\n <span style="float:right;">${d}</span>\n </div>\n <div style="clear: both;"></div>\n <h2 style="margin: 12px 0 10px 0; font-size: 24px; font-weight: 600; color: #212529; line-height: 1.3;">${(null===e||void 0===e?void 0:e.title)||""}</h2>\n <p style="margin: 0 0 15px 0; font-size: 12px; color: #555;">${p}</p>\n </div>\n <hr style="margin: 15px 0; border: 0; border-top: 1px solid #eee;" />\n <p style="margin: 0 0 14px 0; font-weight: bold; font-size: 12px;">FULL ARTICLE CONTENT (as attested)</p>\n <div style="margin-top: 6px; padding: 12px 10px; line-height: 1.6; color: #333; background: white;">\n ${b}\n </div>\n <hr style="margin: 20px 0; border: 0; border-top: 1px solid #ddd;" />\n <p style="margin: 0 0 12px 0; font-weight: bold; font-size: 12px;">ATTESTATION</p>\n <div style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #eee;">\n ${f}\n <p style="margin: 8px 0;">\n User ${n||""} Acknowledged and Marked as Read on : ${m}\n </p>\n <small style="color: #666;">\n Certified by Humanagement.io on ${d}\n for the version of the policy edited on ${u}\n </small>\n </div>\n </div>\n `;try{const e=new i.jsPDF("p","mm","a4");await e.html(g,{callback:function(e){const t=a||"attestation";e.save(`${t}.pdf`)},x:10,y:10,width:170,windowWidth:800,margin:[10,10,10,10],autoPaging:"text",html2canvas:{allowTaint:!0,useCORS:!0}})}catch(j){throw console.error("Error generating attestation PDF:",j),j}finally{s()}}},923:function(e,t,n){"use strict";n.d(t,"b",(function(){return O})),n.d(t,"e",(function(){return y})),n.d(t,"a",(function(){return q})),n.d(t,"c",(function(){return _})),n.d(t,"f",(function(){return N})),n.d(t,"d",(function(){return w})),n.d(t,"g",(function(){return C}));var i=n(38),s=n(1),o=n(550),a=n(112),l=n(68),r=n(1095),c=n(212),d=n(1094),u=n(53),m=n(43),h=n(41),p=n(114),f=n.n(p),b=n(137),g=n(977),j=n(3);const x=e=>{if(!e)return"";const t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""};var v=e=>{let{field:t,form:n,...i}=e;const o=(e=>null===e||void 0===e?"":"string"===typeof e?e:String(e))(t.value),[a,l]=Object(s.useState)(!!(r=o)&&/<([a-z][a-z0-9]*)\b[^>]*>|<\/([a-z][a-z0-9]*)\b[^>]*>/i.test(r));var r;const{onChange:c,type:d,value:u,...m}=i;return Object(j.jsxs)("div",{children:[Object(j.jsx)("div",{className:"d-flex justify-content-end mb-1",children:Object(j.jsxs)("div",{className:"custom-control custom-switch",children:[Object(j.jsx)("input",{type:"checkbox",className:"custom-control-input",id:`richtext-toggle-${t.name}`,checked:a,onChange:()=>{a?f.a.fire({title:"Warning",text:"Switching to plain text will remove all formatting. Are you sure?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, switch",cancelButtonText:"Cancel"}).then((e=>{if(e.isConfirmed){const e=x(o);n.setFieldValue(t.name,e),l(!1)}})):l(!0)}}),Object(j.jsx)("label",{className:"custom-control-label",htmlFor:`richtext-toggle-${t.name}`,children:"Rich Text"})]})}),a?Object(j.jsx)(b.a,{value:o,onChange:e=>n.setFieldValue(t.name,e),height:100,minHeight:100,enableAI:!1,simple:!0,inline:!0,...m}):Object(j.jsx)(g.default,{className:"form-control",value:o,onChange:e=>n.setFieldValue(t.name,e.target.value),minRows:4,style:{minHeight:"100px"},...m})]})};const O="MULTIPLE_CHOICE",y="SINGLE_CHOICE",q="INSTRUCTION",_="OPEN_TEXT",N="SUBMISSION",w=[q,_,N];function C(e){let{instance:t,callbackFunc:n,aiGeneratedData:p}=e;const f=Object(s.useMemo)((()=>[{text:"Single Choice",value:y},{text:"Multiple Choice",value:O},{text:"Instruction",value:q},{text:"Open Text",value:_},{text:"Submission",value:N}]),[]),b=u.f().shape({questions:u.a().of(u.f().shape({question:u.h().required("Please enter a question"),type:u.h().required("This field is required"),
1choices:u.a().of(u.f().shape({text:u.h().required("Please enter an answer"),is_correct:u.c().required("This field is required")})).min(1,"A question must have at least one choice").test("at-least-one-correct-choice","A question must have at least one correct choice",(e=>e.some((e=>e.is_correct))))}))}),g={question:"",order:1,type:f[0].value,choices:[{text:"",is_correct:!1}]},C=Object(s.useMemo)((()=>{var e,n;return{title:(null===p||void 0===p?void 0:p.title)||(null===t||void 0===t?void 0:t.title)||"",passing_grade:null!==(e=null!==(n=null===p||void 0===p?void 0:p.passing_grade)&&void 0!==n?n:null===t||void 0===t?void 0:t.passing_grade)&&void 0!==e?e:100,questions:(null===p||void 0===p?void 0:p.questions)||(null===t||void 0===t?void 0:t.questions)||[g]}}),[p,t]);return Object(j.jsx)(i.e,{validationSchema:b,initialValues:C,enableReinitialize:!0,onSubmit:async(e,i)=>{try{let i;console.log("Submitting quiz data:",e),""===e.title&&(e.title=e.questions[0].question),i=t?await m.a.updateQuiz(null===t||void 0===t?void 0:t.id,e):await m.a.createQuiz(e),console.log("Response from quiz creation/update:",i),i?"function"===typeof n&&n(i):console.error("No data returned from quiz service")}catch(s){console.error("Error submitting quiz:",s)}i.setSubmitting(!1)},children:e=>{let{errors:t,values:n,isSubmitting:s,setFieldValue:u}=e;return Object(j.jsxs)(i.d,{children:[Object(j.jsxs)("div",{className:"row",children:[Object(j.jsxs)("div",{className:"col-12",children:[Object(j.jsx)("p",{children:"Fill in the form below to create a quiz. A quiz can have multiple questions to it."}),Object(j.jsxs)("div",{className:"form-group "+(1===n.questions.length?" d-none":""),children:[Object(j.jsx)("label",{htmlFor:"name",children:"Quiz Title"}),Object(j.jsx)(i.b,{className:"form-control",name:"title",type:"text",placeholder:"Enter title...",onChange:e=>{u("title",e.target.value),1===n.questions.length&&u("questions.0.question",e.target.value)},"data-testid":"quiz-form-title-input"}),t.title&&Object(j.jsx)("span",{className:"text-danger","data-testid":"quiz-form-title-error",children:t.title})]}),Object(j.jsxs)("div",{className:"form-group",children:[Object(j.jsx)("label",{htmlFor:"passing_grade",children:"Passing Grade (%)"}),Object(j.jsx)(i.b,{className:"form-control",name:"passing_grade",type:"number",min:"0",max:"100",placeholder:"100","data-testid":"quiz-form-passing-grade-input"}),Object(j.jsx)("small",{className:"text-muted",children:"Percent required to pass (e.g. 80). Default 100 = all correct."})]})]}),Object(j.jsx)("hr",{}),Object(j.jsx)("div",{className:" col-12",children:Object(j.jsxs)("div",{className:"form-group",children:[Object(j.jsx)(o.a,{children:Object(j.jsx)(a.a,{xs:12,children:Object(j.jsx)("p",{className:"font-weight-bold",children:"Add Questions to this quiz:"})})}),n.questions.map(((e,s)=>{var l;return Object(j.jsxs)(o.a,{className:"mb-1",noGutters:!0,children:[Object(j.jsx)(a.a,{xs:12,className:"",children:Object(j.jsxs)(o.a,{className:" p-3 rounded",children:[Object(j.jsx)(a.a,{md:12,xs:12,children:Object(j.jsxs)(o.a,{className:"mb-2",children:[Object(j.jsx)(a.a,{md:1,children:Object(j.jsxs)("h4",{className:"mr-1",children:[s+1,". "]})}),Object(j.jsx)(a.a,{md:n.questions.length>1?10:11,xs:11,children:Object(j.jsx)(i.b,{as:"select",name:`questions.${s}.type`,className:"form-control form-control-sm",style:{height:"calc(1.5em + 0.5rem + 2px)",padding:"0.25rem 0.5rem",fontSize:"0.875rem",lineHeight:"1.5",bordeRadius:"0.2rem"},onChange:e=>{const t=n.questions[s].type,i=e.target.value,o=[{text:"instruction",is_correct:!0}];if(!w.includes(i)&&w.includes(t)){const e=n.questions[s].choices.map((e=>({...e,text:""}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else if(i===y&&t===O){const e=n.questions[s].choices.map((e=>({...e,is_correct:!1}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else if(w.includes(i)){const e=n.questions.filter(((e,t)=>t===s))[0];let t=[...n.questions];t[s]={...e,choices:o},u("questions",t)}u(`questions.${s}.type`,e.target.value)},"data-testid":`quiz-form-question-type-select-${s}`,children:null===f||void 0===f?void 0:f.map((e=>Object(j.jsx)("option",{value:e.value,"data-testid":`quiz-form-question-type-select-option-${s}-${e.value}`,children:e.text},e.value)))})}),n.questions.length>1&&Object(j.jsx)(a.a,{md:1,xs:1,children:Object(j.jsx)(h.a,{id:`remove-text-tooltip-${s}`,position:"right",title:"Remove question",children:Object(j.jsx)(d.a,{className:"cursor-pointer float-right my-1",style:{fontSize:"18px"},onClick:()=>{const e=n.questions.filter(((e,t)=>t!==s));u("questions",e),1===e.length&&u("title",x(e[0].question))},"data-testid":`quiz-form-remove-question-button-${s}`})})})]})}),Object(j.jsxs)(a.a,{md:12,xs:12,children:[Object(j.jsx)(i.b,{className:"form-control form-control-sm w-100",name:`questions.${s}.question`,type:"textarea",component:v,placeholder:`Enter ${e.type===q?"instruction":"question"}...`,onChange:e=>{u(`questions.${s}.question`,e),1===n.questions.length&&u("title",x(e))},"data-testid":`quiz-form-question-input-${s}`}),t.questions&&t.questions[s]&&t.questions[s].question&&Object(j.jsx)("div",{className:"text-danger ml-1","data-testid":`quiz-form-question-error-${s}`,children:t.questions[s].question})]})]})}),Object(j.jsx)(a.a,{xs:12,className:"",children:!w.includes(e.type)&&Object(j.jsxs)("div",{className:"ml-3 mt-1",children:[e.choices.map(((l,c)=>{var d,m,p,f;return Object(j.jsxs)(o.a,{className:"mb-1 p-3 rounded",children:[Object(j.jsxs)(a.a,{xs:1,children:["Choice: # ",c+1]}),Object(j.jsx)(a.a,{xs:e.choices.length>1?10:11,children:Object(j.jsxs)(o.a,{children:[Object(j.jsxs)(a.a,{xs:12,children:[Object(j.jsx)(i.b,{className:"form-control form-control-sm w-100 ",name:`questions.${s}.choices.${c}.text`,type:"textarea",height:100,component:v,placeholder:"Enter choice text...","data-testid":`quiz-form-question-choice-text-input-${s}-${c}`}),t.questions&&(null===(d=t.questions[s])||void 0===d?void 0:d.choices)&&(null===(m=t.questions[s])||void 0===m?void 0:m.choices[c])&&(null===(p=t.questions[s])||void 0===p||null===(f=p.choices[c])||void 0===f?void 0:f.text)&&Object(j.jsx)("span",{className:"text-danger","data-testid":`quiz-form-question-choice-text-error-${s}-${c}`,children:t.questions[s].choices[c].text})]}),Object(j.jsx)(a.a,{xs:12,children:Object(j.jsx)(i.b,{as:"select",name:`questions.${s}.choices.${c}.is_correct`,className:"form-control form-control-sm mt-2",style:{height:"calc(1.5em + 0.5rem + 2px)",padding:"0.25rem 0.5rem",fontSize:"0.875rem",lineHeight:"1.5",bordeRadius:"0.2rem"},onChange:e=>{if("true"===e.target.value&&"SINGLE_CHOICE"===n.questions[s].type){const e=n.questions[s].choices.map(((e,t)=>({...e,is_correct:t===c}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else u(`questions.${s}.choices.${c}.is_correct`,"true"===e.target.value)},"data-testid":`quiz-form-question-choice-is-correct-select-${s}-${c}`,children:[{text:"Correct",value:!0},{text:"Incorrect",value:!1}].map((e=>Object(j.jsx)("option",{value:e.value,"data-testid":`quiz-form-question-choice-is-correct-select-option-${s}-${c}-${e.value}`,children:e.text},e.value)))})})]})}),e.choices.length>1&&Object(j.jsx)(a.a,{xs:1,children:Object(j.jsx)(h.a,{id:`remove-choice-tooltip-${c}`,position:"right",title:"Remove choice",children:Object(j.jsx)(r.a,{className:"cursor-pointer my-1",style:{fontSize:"14px"},onClick:()=>{const t=e.choices.filter(((e,t)=>t!==c)),i=n.questions.filter(((e,t)=>t===s))[0];let o=[...n.questions];o[s]={...i,choices:t},u("questions",o)},"data-testid":`quiz-form-remove-choice-button-${s}-${c}`})})})]},c)})),Object(j.jsxs)(o.a,{children:[Object(j.jsx)(a.a,{xs:12,children:t.questions&&(null===(l=t.questions[s])||void 0===l?void 0:l.choices)&&"string"===typeof t.questions[s].choices&&Object(j.jsx)("span",{className:"text-danger","data-testid":`quiz-form-question-choices-error-${s}`,children:t.questions[s].choices})}),Object(j.jsx)(a.a,{md:12,children:Object(j.jsxs)("span",{className:"font-weight-bold cursor-pointer",onClick:()=>{u(`questions.${s}.choices`,[...e.choices,{text:"",is_correct:!1}])},"data-testid":`quiz-form-add-choice-button-${s}`,children:[Object(j.jsx)(c.h,{style:{fontSize:"20px"}})," Add Choice"]})})]})]})})]},s)})),Object(j.jsx)("div",{className:"mt-4",children:Object(j.jsxs)("span",{className:"font-weight-bold cursor-pointer",onClick:()=>{const e=n.questions[n.questions.length-1];u("questions",[...n.questions,{...g,order:e.order+1}])},children:[Object(j.jsx)(c.h,{style:{fontSize:"20px"},"data-testid":"quiz-form-add-question-button-icon"})," ","Add another question"]})})]})})]}),Object(j.jsx)(l.a,{className:"float-right",type:"submit",disabled:s,children:s?"Saving....":"Save"})]})}})}},972:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));n(1);var i=n(76),s=n(3);function o(){return Object(s.jsxs)(s.Fragment,{children:[Object(s.jsx)(i.a,{variant:"rect",width:"60%",className:"mb-3"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"})]})}function a(){return Object(s.jsxs)(s.Fragment,{children:[Object(s.jsx)(o,{}),Object(s.jsx)("br",{}),Object(s.jsx)(o,{}),Object(s.jsx)("br",{}),Object(s.jsx)(o,{})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.