1import{h as $,u as B,t as q,j as e,W as v,v as j,s as y,K as J,r as A,w as Z,i as P,x as ee,a as se,y as u,X as D,M as K,z as M,A as te,o as k}from"./main.OiFWolAm.js";const ne=({flow:d})=>{const c=$(),{appName:o}=B();q();const f=async()=>{d&&d==j.ReTraining?c(y.RETRAINING_REVIEW_MATERIAL):c(y.REVIEW_MATERIAL)};return e.jsxs("div",{children:[e.jsxs("div",{className:"statusMessage fail",children:[e.jsx("div",{className:"statusIcon",children:e.jsx("i",{className:"fa fa-times"})}),e.jsxs("div",{className:"statusMsg",children:["You did not achieve 100% on the ",o," ",e.jsx("span",{className:"docEmphasis",children:"Knowledge Assessment"})," within the last 3 attempts.",e.jsx("br",{}),e.jsx("br",{}),"You must review the ",o," materials before attempting the ",o," ",e.jsx("span",{className:"docEmphasis",children:"Knowledge Assessment"})," ","again."]})]}),e.jsx("div",{className:"btnContainer",children:e.jsx(v,{identifier:"BtnReviewMaterials",css:"lg",onButtonClick:f,children:e.jsx("span",{"data-ubc-action-text":"*",children:"Review Materials"})})})]})},S=3,re=J(({moveToNextPage:d,viewMode:c,setViewMode:o,flow:f})=>{const[m,b]=A.useState(null),h=$(),{kAResult:V}=Z(),{appName:Y}=B(),{container:i,ref:w}=P(),[L,E]=A.useState([]),[Q,R]=A.useState(!1),x=ee(),{userProfile:s}=q(),{isReEnrollment:C}=se(),I=A.useRef(!1),[p,O]=A.useState([]),[T,W]=A.useState(0),_=A.useRef(!0);A.useEffect(()=>{(p==null||p.length==0)&&(async()=>{const t=await x.getCourseVersionList((s==null?void 0:s.StakeholderTypeIdentity)??0);if(t!=null&&t.Result&&t.Result==k.Success){const l=t.Data;l&&O(l)}})();const a=async()=>{const n=await x.getStakeholderCourseAssessmentByStakeholder((s==null?void 0:s.StakeholderTypeIdentity)??0,(s==null?void 0:s.StakeholderIdentity)??0);if(n!=null&&n.Result&&n.Result==k.Success){const t=n.Data;if(t&&t.AssessmentQuestionIdentity&&t.AssessmentQuestionIdentity>0?(R(!0),E([{name:"Answers",key:t.AssessmentQuestionIdentity.toString()}])):(R(!1),E([])),I.current=!1,!t)return;const{AssessmentPassed:l,AttemptNumber:r,CompletedDate:N}=t;if(l&&N&&!C){d==null||d();return}if(r&&r>0){o==null||o(u.RetakeAssessment),b(t);return}o==null||o(u.InitialAssessment),b(t)}else{h(y.ERROR);return}};s!=null&&s.StakeholderIdentity?a():h(y.ERROR)},[s==null?void 0:s.StakeholderTypeIdentity,s==null?void 0:s.StakeholderIdentity]),A.useEffect(()=>{if(_.current&&i!=null&&c!==u.ReadonlyView)if(p!=null&&p.length>0){let a=i==null?void 0:i.fetchContainerInstance("$.CourseVersionIdentity");if(a!=null&&a.value!=null&&a.value!=T){W(a.value);const n=p.find(t=>t.CourseVersionIdentity==a.value);if((n==null?void 0:n.AssessmentQuestionIdentity)!=null){R(!0),E([{name:"Answers",key:n==null?void 0:n.AssessmentQuestionIdentity.toString()}]);let t=i==null?void 0:i.fetchContainerInstance("$.AssessmentQuestionIdentity");t!=null&&t.setValue(n==null?void 0:n.AssessmentQuestionIdentity)}else R(!1),E([])}}else{let a=i==null?void 0:i.fetchContainerInstance("$.AssessmentQuestionIdentity");a!=null&&a.value!=null?(R(!0),E([{name:"Answers",key:a.value.toString()}])):(R(!1),E([]))}return()=>{_.current=!1}},[i,c,p,T]);const F=A.useCallback(a=>{var n;if(i&&((n=a.metadataKey.parent)==null?void 0:n.name)==="Answers"&&!I.current){const t=i.fetchContainerInstance("$.Answers");if(t&&t.children.length>0){let l=!1;C&&(l=t.children.every(r=>r.metadata.custom.CorrectAnswer!=null&&r.value!=null&&r.metadata.custom.CorrectAnswer===r.value)),t.children.forEach(r=>{C&&(c===u.InitialAssessment||l)?(r.classes=["lmsQuestion"],r.active=!0,r.setValue(null)):r.metadata.custom.CorrectAnswer!=null&&r.value!=null&&(r.metadata.custom.CorrectAnswer!==r.value&&(r.classes=["lmsQuestion"],r.active=!0,r.setValue(null)),r.metadata.custom.CorrectAnswer===r.value&&(r.classes=["lmsQuestion","lmsQuestionCorrect"],r.active=!1))}),I.current=!0}}return null},[i,C,c]),X=A.useCallback(a=>{var n;if(i&&((n=a.metadataKey.parent)==null?void 0:n.name)==="Answers"&&!I.current){const t=i.fetchContainerInstance("$.Answers");t&&t.children.length>0&&(t.children.forEach(l=>{l.metadata.custom.CorrectAnswer!=null&&l.value!=null&&(l.metadata.custom.CorrectAnswer!==l.value&&(l.classes=["lmsQuestion","lmsQuestionError"]),l.metadata.custom.CorrectAnswer===l.value&&(l.classes=["lmsQuestion","lmsQuestionCorrect"]))}),I.current=!0)}return null},[i]),U=()=>
1{f==j.ReTraining?h(y.RETRAINING_REVIEW_MATERIAL):f==j.Assessment?h(y.ASSESSMENT_REVIEW_MATERIAL):h(y.REVIEW_MATERIAL)},g=async(a,n)=>{const t=a;if(!t){o==null||o(u.InitialAssessment),b(null);return}const{AssessmentPassed:l,AttemptNumber:r,CompletedDate:N}=t;if(l&&N){d==null||d();return}if(r&&r%S==0){f==j.ReTraining?h(`${y.RETRAINING_KA_ALL_QUESTIONS_EXCEEDED_ATTEMPTS}`):f==j.Assessment?h(`${y.ASSESSMENT_KA_ALL_QUESTIONS_EXCEEDED_ATTEMPTS}`):h(`${y.KA_ALL_QUESTIONS_EXCEEDED_ATTEMPTS}`);return}o==null||o(n),b(t)},z=async()=>{const a=await x.getStakeholderCourseAssessmentByStakeholder((s==null?void 0:s.StakeholderTypeIdentity)??0,(s==null?void 0:s.StakeholderIdentity)??0);a!=null&&a.Result&&a.Result==k.Success&&(I.current=!1,await g(a.Data,u.RetakeAssessment))},G=async()=>{if(i===void 0||!i.valid)return;let a=i==null?void 0:i.fetchContainerInstance("$.Answers");if(a!=null&&a.children!=null&&a.children.length>0){const n=a.children.filter(t=>t.hasData==!1);if(n==null||n.length==0){const t=await x.getStakeholderCourseAssessmentByStakeholder((s==null?void 0:s.StakeholderTypeIdentity)??0,(s==null?void 0:s.StakeholderIdentity)??0);if(t!=null&&t.Result&&t.Result==k.Success){const l=t.Data;if(l&&l.AssessmentPassed&&l.CompletedDate&&!C){d==null||d();return}x.SaveLms(i).then(async r=>{r.Result===k.Success&&(I.current=!1,await g(r.Data,u.ReadonlyView))})}}}},H=A.useMemo(()=>Q?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"frmContainer",children:[e.jsxs("div",{className:"frmTitle",children:[Y,e.jsx("br",{}),"Knowledge Assessment"]}),c===u.ReadonlyView&&m&&e.jsxs("div",{className:"txtInstructionsQuestions",id:"errorMsg",children:["Please review the ",e.jsx("span",{className:"errNum",children:m.IncorrectAnswers}),' question(s) answered incorrectly, marked in red and denoted with an "x".',e.jsx("br",{}),"You have"," ",e.jsx("span",{className:"attemptNum",children:(()=>{const n=((m==null?void 0:m.AttemptNumber)??0)%S;return n===0?S:S-n})()})," ",'attempt(s) to correctly answer all questions. You may click "Review Materials" to return to view the necessary resources. At the end of the review, you will be able to retake the assessment. Or, you may immediately retake the assessment by clicking "Retake Assessment".']}),c===u.InitialAssessment&&e.jsxs("div",{className:"txtInstructionsQuestions",children:["You have ",e.jsx("span",{className:"attemptNum",children:S})," attempt(s) to correctly answer all questions. You will be given the opportunity to retake any questions you answer incorrectly."]}),c===u.RetakeAssessment&&m&&e.jsxs("div",{className:"txtInstructionsQuestions",children:["You are required to answer all questions correctly in order to pass the assessment.",e.jsx("br",{}),"You have"," ",e.jsx("span",{className:"attemptNum",children:(()=>{const n=((m==null?void 0:m.AttemptNumber)??0)%S;return n===0?S:S-n})()})," ","attempt(s) to correctly answer all questions. You will be given the opportunity to retake any questions you answer incorrectly."]}),e.jsx("div",{className:"playerContent","data-ubc-player-mode":"assessment",children:e.jsx("div",{className:"formContainer",id:"formContainer","data-ubc-form-container":"*",children:e.jsxs("div",{className:"questionContainer",children:[c!==u.ReadonlyView&&e.jsx(D,{metadataKey:`Model/${K.LMS.AddLMSModel}`,ref:w,context:L,uriFragment:`LMS/PPApi/beginAddLms/${s==null?void 0:s.StakeholderTypeIdentity}/${(s==null?void 0:s.StakeholderIdentity)??0}`,children:e.jsx("div",{className:"retake-lms",children:e.jsx(M,{name:"Answers",isArray:!1,onAfterCreatingMetaDataElement:F})})}),c===u.ReadonlyView&&e.jsx(D,{metadataKey:`Model/${K.LMS.ViewLMSModel}`,ref:w,context:L,uriFragment:`LMS/PPApi/viewLMS/${(m==null?void 0:m.StakeholderCourseAssessmentIdentity)??0}`,children:e.jsx("div",{className:"view-lms",children:e.jsx(M,{name:"Answers",isArray:!1,onAfterCreatingMetaDataElement:X})})})]})})})]}),e.jsx("div",{className:"playerActions","data-ubc-player-actions":"submit",children:e.jsx("div",{className:"col-xs-12 col-md-8",children:e.jsxs("div",{className:"form-btn-container",children:[c===u.ReadonlyView&&e.jsxs("div",{children:[e.jsx(v,{identifier:"BtnReviewMaterials",css:"btn btn-info",onButtonClick:U,children:e.jsx("span",{"data-ubc-action-text":"*",children:"Review Materials"})}),e.jsx(v,{identifier:"BtnRetakeAssessment",css:"btn btn-success",onButtonClick:z,children:e.jsx("span",{"data-ubc-action-text":"*",children:"Retake Assessment"})})]}),(c===u.InitialAssessment||c===u.RetakeAssessment)&&e.jsx("div",{children:e.jsx(v,{identifier:"BtnSubmit",css:"btn btn-info",onButtonClick:G,children:e.jsx("span",{"data-ubc-action-text":"*",children:"Submit"})})})]})})})]}):e.jsx("div",{}),[Q,i,c,m,s==null?void 0:s.StakeholderTypeIdentity,s==null?void 0:s.StakeholderIdentity]);return V==te.ExceededAttempts?e.jsx(ne,{flow:f}):H});export{re as default};
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.