import{ao as s,a_ as N,bl as F,bb as M,aC as v,L as A,ah as I,aJ as U,c4 as E,bc as $,m as H}from"./app-k0jcl5PQ.js";import{I as l}from"./uoUaCILN.chunk.js";import{a as m,I as D}from"./CNtKSILN.chunk.js";import{E as _}from"./BzIt8QkE.chunk.js";import{a as L,b as O,N as P,c as T}from"./NRZx5qCo.chunk.js";import{a as q,b as W}from"./CX9BGBTP.chunk.js";import{I as B}from"./s-4A5pEU.chunk.js";import{d as J}from"./Bcve7ust.chunk.js";function g(e){const{answer:t}=e;function o(i){switch(i){case m.Correct:return"bg-light-green";case m.Incorrect:return"bg-light-red";case m.PendingReview:return"bg-light-blue"}}return s.jsxs("div",{className:`${o(t.status)} rounded p-2 mb-2`,children:[s.jsxs("div",{className:"d-flex align-items-center gap-2",children:[t.status===m.Correct&&s.jsx(N,{svg:F,className:"svg-container flex-shrink-0 text-success"}),t.status===m.Incorrect&&s.jsx(N,{svg:M,className:"svg-container flex-shrink-0 text-danger"}),!e.customAnswer&&s.jsx("span",{className:e.textClassName,children:t.text})]}),e.children]},t.id)}const z="shared.interactionResponses",G=A.encloseNamespace(z);function K(e){const t=v.first(e.answers);return t?s.jsxs(g,{answer:t,customAnswer:!0,children:[s.jsx("div",{className:"ratio ratio-16x9",children:s.jsx("img",{className:"img-fluid bg-white border rounded h-100 w-100",src:t.text,alt:`${G("illustrationAlt")}: ${e.interaction.name}`})}),e.children]}):s.jsx(s.Fragment,{})}function Q(e){return e.answers.length?s.jsx("ul",{className:"list-unstyled",children:e.answers.map(t=>s.jsx("li",{children:s.jsx(g,{answer:t,textClassName:"bg-white p-1 border border-gray-300 rounded"})},t.id))}):s.jsx(s.Fragment,{})}function V(e){return e.answers.length?s.jsx("ul",{className:"list-unstyled",children:e.answers.map(t=>s.jsx("li",{children:s.jsx(g,{answer:t})},t.id))}):s.jsx(s.Fragment,{})}function X(e){const t=v.first(e.answers);return t?s.jsx(g,{answer:t,children:e.children}):s.jsx(s.Fragment,{})}function Y(e){const t=v.first(e.answers);return t?s.jsx(g,{answer:t}):s.jsx(s.Fragment,{})}const R=()=>s.jsx(s.Fragment,{}),Z={[l.Annotation]:R,[l.Image]:R,[l.MissingWord]:Q,[l.MultipleChoice]:V,[l.TrueOrFalse]:Y,[l.ShortAnswer]:X,[l.Illustration]:K},p="_avatarContainer_1h05x_1",ee={avatarContainer:p};function le(e){var h,d,x,f,c,n;const t=Z[e.interaction.typeId];if(!t)return s.jsx(s.Fragment,{});const o=q(e.studentResults),i=W(e.interaction.id,o),u=D.isInteractionCorrect(e.interaction,o);return s.jsx("div",{className:"position-relative",children:s.jsx("div",{className:`rounded ${e.className??""}`,children:s.jsxs("div",{className:"d-flex",children:[!!e.showStudentDetails&&s.jsx("div",{className:"me-2",children:s.jsx("div",{className:ee.avatarContainer,children:s.jsx(_,{imageCdnUrl:e.imageCdnUrl,initials:e.anonymisedUserName?I.getInitialsFromFullName(e.anonymisedUserName):I.getInitials((h=e.studentResults.user)==null?void 0:h.name,(d=e.studentResults.user)==null?void 0:d.surname),imageUrl:e.anonymisedUserName?null:(f=(x=e.studentResults.user)==null?void 0:x.avatar)==null?void 0:f.url,type:(n=(c=e.studentResults)==null?void 0:c.user)!=null&&n.sessionId?"anon":void 0})})}),s.jsxs("div",{className:"flex-grow-1",children:[!!e.showStudentDetails&&s.jsx(L,{studentResults:e.studentResults,correctness:u,anonymisedUserName:e.anonymisedUserName}),s.jsxs("div",{className:"d-flex justify-content-between",children:[s.jsx("div",{className:`flex-grow-1 mb-2 ${e.responseComponentClass?e.responseComponentClass:""}`,children:i?s.jsx(t,{interaction:e.interaction,answers:i.answers,imageCdnUrl:e.imageCdnUrl,user:e.studentResults.user,showFeedback:e.showFeedback,showAvatar:e.showAvatar,children:s.jsx(O,{studentAttempt:i,correctness:u,markInteraction:e.markInteraction,markedStatus:e.markedStatus})}):s.jsx(P,{})}),!e.showStudentDetails&&s.jsx(T,{correctness:u})]})]})]})})})}const w=A.encloseNamespace("reportsShared.dataHooks"),ue=(e,t,o)=>{const[i,u]=U.useState({}),h=E(),d=$();function x(c,n){c.forEach(a=>{u(C=>({...C,[J(a)]:{...a,status:n}}))})}function f(){const c=Object.keys(i).map(r=>i[r]);if(!c.length)return;let n=0,a=0;function C(){a++}function b(){n++,n===c.length&&k()}function k(){let r="",j=!1;a===0&&(r=w("error",{smartCount:c.length}),j=!0),a<n&&(r=w("success",{smartCount:a})+` ${w("partialError",{smartCount:n-a})}`),a===n&&(r=w("success",{smartCount:a})),j?d.error(r):d.success(r),u({}),o&&o()}c.forEach(({id:r,resultId:j,questionId:S,status:y})=>{H(h,B.mark(e,t,r,{id:r,resultId:j,questionId:S,status:y},C,null,b))})}return{markedAnswers:i,addMarkedAnswers:x,submitMarkedAnswers:f}};export{le as I,ue as u};
//# sourceMappingURL=B8qKg3jw.chunk.js.map
