PageSourceSearch

https://classmate-vuive.com/assets/DictationAssessmentPage-82cc8534.js

js classmate-vuive.com collected 2026-10-08 16:08:29 UTC 5,669 bytes, 1 lines download raw bytes

1import{aP as X,j as e,a as s,F as _}from"./index-7a84a097.js";import{u as ee,l as te,r as c,n as T,B as n,a0 as I,C as R,T as d,f as se,R as B,z as U,ag as H,Z as M,h as re,af as O,k as D}from"./vendor-56877fa0.js";import{u as ne}from"./useDictationQueries-e2b56716.js";import{A as oe,a as ie,b as ae,c as le}from"./AssessmentResult-41551fce.js";import"./chart-libs-b4df5823.js";import"./index-8c3a6718.js";import"./Close-5eb20111.js";import"./createSvgIcon-d4243c27.js";import"./processOpenAIRequest-45bb506f.js";import"./_commonjs-dynamic-modules-302442b1.js";import"./promptData-73e71fd1.js";import"./ParseJson-15086b54.js";const ce=()=>{const{id:E}=ee(),Y=te(),{user:$}=c.useContext(X),{getDictationAssessment:N,submitAssessmentMutation:C}=ne(),{data:o,isLoading:Q,isError:V,error:w}=N(E),[x,j]=c.useState({}),[v,g]=c.useState(!1),[u,F]=c.useState(null),[y,W]=c.useState(""),[P,Z]=c.useState(!1);c.useEffect(()=>{if(o!=null&&o.blankItems){const t={};o.blankItems.forEach(i=>{t[i.id]=""}),j(t),P||(g(!1),F(null))}},[o,P]);const q=(t,i)=>{j(r=>({...r,[t]:i}))},G=async()=>{try{if(!$){W("You must be logged in to submit this assessment");return}const t=Object.keys(x).map(l=>{const m=x[l]||"",p=o.blankItems.find(A=>A.id===l),b=p?p.answer:"";return{blankItemId:l,userAnswer:m,correctAnswer:b}}),i={assessmentId:E,userAnswers:t.map(({blankItemId:l,userAnswer:m})=>({blankItemId:l,userAnswer:m}))};Z(!0);const r=await C.mutateAsync(i),a=r.userAnswers.map(l=>{const m=t.find(f=>f.blankItemId===l.blankItemId),p=m.userAnswer,b=m.correctAnswer,A=[];if(!l.isCorrect&&p&&b){const f=p.trim().split(/\s+/),S=b.trim().split(/\s+/),J=Math.max(f.length,S.length);for(let h=0;h<J;h++){const L=h<f.length?f[h]:"",z=h<S.length?S[h]:"",K=L.toLowerCase()===z.toLowerCase();A.push({userWord:L,correctWord:z,isWordCorrect:K})}}return{...l,wordByWordComparison:A}}),k={...r,userAnswers:a};F(k),g(!0)}catch(t){W(t.message||"An error occurred while submitting your answers")}};return c.useEffect(()=>{if(y){const t=setTimeout(()=>{W("")},5e3);return()=>clearTimeout(t)}},[y]),Q?e(n,{display:"flex",justifyContent:"center",p:3,children:e(T,{})}):V?e(R,{children:s(I,{severity:"error",children:["Error loading assessment: ",(w==null?void 0:w.message)||"Unknown error"]})}):o?(console.log({result:u}),s(R,{children:[s(n,{my:4,children:[s(n,{mb:3,children:[e(d,{variant:"h4",component:"h1",gutterBottom:!0,children:o.title}),o.description&&e(d,{variant:"body1",color:"textSecondary",paragraph:!0,children:o.description})]}),y&&e(I,{severity:"error",sx:{mb:2},children:y}),s(se,{elevation:1,sx:{p:3,mb:3},children:[e(d,{variant:"body1",paragraph:!0,children:"Fill in each blank with the correct word or phrase. After submitting, you'll see your results."}),s(n,{component:"form",noValidate:!0,autoComplete:"off",onSubmit:t=>{t.preventDefault()},children:[e(O,{sx:{display:"flex",flexDirection:"column"},children:o.blankItems.map((t,i)=>s(B.Fragment,{children:[i>0&&e(U,{component:"li",sx:{my:2}}),s(H,{sx:{display:"block",py:2},children:[s(n,{mb:1,children:[e(d,{variant:"subtitle1",children:t.name||`Blank ${i+1}`}),t.tags&&t.tags.length>0&&e(n,{mt:1,children:t.tags.map((r,a)=>e(M,{label:r,size:"small",sx:{mr:.5,mb:.5},color:"primary",variant:"outlined"},a))})]}),e(re,{fullWidth:!0,variant:"outlined",placeholder:"Enter your answer",value:x[t.id]||"",onChange:r=>q(t.id,r.target.value),disabled:v})]})]},t.id))}),e(n,{mt:3,display:"flex",justifyContent:"flex-end",children:e(D,{variant:"contained",color:"primary",onClick:G,disabled:v||C.isPending,size:"large",type:"button",children:C.isPending?e(T,{size:24}):"Submit"})})]})]})]}),v&&u&&s(oe,{result:u,processedResult:{overallScore:u.score,criteria:[{name:"Overall Score",score:u.score}]},onClose:()=>g(!1),children:[s(ie,{children:[e(ae,{}),s(n,{p:3,children:[e(d,{variant:"h6",gutterBottom:!0,children:"Your Answers:"}),e(O,{children:u.userAnswers.map((t,i)=>{const r=o.blankItems.find(a=>a.id===t.blankItemId);return s(B.Fragment,{children:[i>0&&e(U,{component:"li"}),e(H,{children:s(n,{width:"100%",children:[s(n,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[e(d,{variant:"subtitle1",children:(r==null?void 0:r.name)||`Blank ${i+1}`}),e(M,{label:t.isCorrect?"Correct":"Incorrect",color:t.isCorrect?"success":"error",size:"small"})]}),e(n,{mt:1,children:t.isCorrect?e(d,{variant:"body2",children:e("span",{style:{fontWeight:"medium",color:"#10b981"},children:t.userAnswer||"(empty)"})}
1):e(n,{children:e(d,{variant:"body2",component:"div",sx:{display:"flex",flexWrap:"wrap",alignItems:"center",mb:1,gap:1},children:t.wordByWordComparison?t.wordByWordComparison.map((a,k)=>e(B.Fragment,{children:a.isWordCorrect?s("span",{style:{color:"#10b981",fontWeight:"medium"},children:[a.userWord," "]}):s("span",{style:{display:"inline-flex",alignItems:"center"},children:[s("span",{style:{color:"red",fontWeight:"medium"},children:["(",a.correctWord,")"]})," ",s("span",{style:{textDecoration:"line-through",color:"gray"},children:[a.userWord||"(missing)"," "]})]})},k)):s(_,{children:[s("span",{style:{color:"red",fontWeight:"medium"},children:["(",r==null?void 0:r.answer,")"]}),e("span",{style:{textDecoration:"line-through",color:"gray"},children:t.userAnswer||"(empty)"})]})})})})]})})]},t.blankItemId)})}),s(n,{display:"flex",justifyContent:"flex-end",mt:3,children:[e(D,{variant:"outlined",color:"primary",onClick:()=>Y("/dictation-assessments"),sx:{mr:1},children:"Return to Assessments"}),e(D,{variant:"contained",color:"primary",onClick:()=>g(!1),children:"Close"})]})]})]}),e(le,{})]})]})):e(R,{children:e(I,{severity:"warning",children:"Assessment not found"})})},xe=()=>e(ce,{});export{xe 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.