import{ao as n,L as h,aQ as w,bq as S,aI as l}from"./app-k0jcl5PQ.js";import{I as R}from"./B8qKg3jw.chunk.js";import{a as A}from"./BzIt8QkE.chunk.js";import{e as N,b as g}from"./Bcve7ust.chunk.js";import{I as y}from"./NRZx5qCo.chunk.js";import{I as M}from"./B31bqZwo.chunk.js";import{I as v}from"./CG1PE8VW.chunk.js";import{I as L}from"./CNtKSILN.chunk.js";import{g as F,a as T}from"./CX9BGBTP.chunk.js";const U="interactives.studentResponseList",o=h.encloseNamespace(U);function B(e){const s=Object.keys(e.markedAnswers).length;return n.jsx("div",{className:"d-flex justify-content-end pt-3",children:n.jsxs("div",{children:[!e.showSubmitButtonSpinner&&n.jsx("button",{className:"btn btn-link",onClick:e.onClickClose,children:o("close")}),!!e.interactionsToMark.length&&n.jsx(n.Fragment,{children:e.isDemo?n.jsx(w,{id:"submitAnswers",title:o("demoOnly"),spanHack:!0,spanHackClassName:"d-inline-flex",children:n.jsx("button",{className:"btn btn-outline-dark pointer-events-none",disabled:!s,children:o("submitAnswers")})}):n.jsx(S,{variant:"outline-dark",onClick:e.onClickSubmit,disabled:!s,showSpinner:e.showSubmitButtonSpinner,children:o("submitAnswers")})})]})})}const D="interactives.studentResponseList",i=h.encloseNamespace(D);function H(e){const s=Object.keys(e.markedAnswers).length;return n.jsxs("div",{className:"d-flex justify-content-between pb-3",children:[n.jsxs("div",{className:"d-flex",children:[!!e.summary.unanswered&&n.jsxs("div",{className:"bg-light rounded p-2 me-2",children:[n.jsx("strong",{className:"me-2",children:i("unanswered")}),e.summary.unanswered]}),n.jsxs("div",{className:"bg-light rounded p-2 me-2",children:[n.jsx("strong",{className:"me-2",children:i("score")}),e.summary.awaitingMarking?n.jsx("em",{children:i("pending")}):`${Math.round(e.summary.percentCorrect*100)}%`]})]}),!!e.interactionsToMark.length&&n.jsx(n.Fragment,{children:e.isDemo?n.jsx(w,{id:"submitAnswers",title:i("demoOnly"),spanHack:!0,children:n.jsx("button",{className:"btn btn-outline-dark pointer-events-none",disabled:!s,children:i("submitAnswers")})}):n.jsx(S,{variant:"outline-dark",onClick:e.onClickSubmit,disabled:!s,showSpinner:e.showSubmitButtonSpinner,children:i("submitAnswers")})})]})}const q="_awaitingMarking_1mjob_1",O={awaitingMarking:q};function $(e,s){return e.filter(r=>L.isInteractionCorrect(r,T(s))===v.AwaitingMarking)}function _(){const e=l.useRef(null),[s,r]=l.useState(!1);return l.useEffect(()=>{!e.current||s||(r(!0),requestAnimationFrame(()=>e.current.scrollIntoView({behavior:"smooth",block:"center"})))},[e.current,s]),e}function X(e){const[s,r]=l.useState(!1),x=_(),f=N(e.interactive,e.studentResults),d=F(e.interactive),c=$(d,e.studentResults);function m(){r(!0),e.submitMarkedAnswers()}return n.jsxs(n.Fragment,{children:[n.jsx(H,{summary:f,interactionsToMark:c,markedAnswers:e.markedAnswers,onClickSubmit:m,showSubmitButtonSpinner:s,isDemo:e.isDemo}),n.jsx("ul",{className:"list-unstyled",children:d.map((t,j)=>{var b;const u=t.id.toString()===((b=e.selectedInteractionId)==null?void 0:b.toString()),C=c.some(I=>I.id===t.id),k=A(e.studentResults.user,e.anonymiseUsers);let a="p-2 mb-3 rounded";return u&&(a+=" border-2 border-info shadow"),C?a+=` ${O.awaitingMarking}`:a+=" border",n.jsxs("li",{className:a,ref:u?x:null,children:[n.jsx("div",{className:"d-flex mb-2",children:n.jsx(M,{interaction:t,iconClassName:"flex-shrink-0"})}),e.reportsStyling?n.jsx(y,{interaction:t,studentResults:e.studentResults,markedStatus:g(t.id,e.studentResults,e.markedAnswers),markInteraction:e.addMarkedAnswers,imageCdnUrl:e.imageCdnUrl,anonymisedUserName:k,className:"bg-light ps-2",showFeedback:!0,reportsStyling:!0,responseComponentClass:"mx-n2"}):n.jsx(R,{interaction:t,studentResults:e.studentResults,markedStatus:g(t.id,e.studentResults,e.markedAnswers),markInteraction:e.addMarkedAnswers,imageCdnUrl:e.imageCdnUrl,anonymisedUserName:k,showFeedback:!0})]},j)})}),n.jsx(B,{interactionsToMark:c,markedAnswers:e.markedAnswers,onClickSubmit:m,onClickClose:e.onClickClose,showSubmitButtonSpinner:s,isDemo:e.isDemo})]})}export{X as S};
//# sourceMappingURL=B_emoU9Y.chunk.js.map
