PageSourceSearch

https://xterns.ai/assets/XternSprintAssessment-MjKowxR2.js

js xterns.ai collected 2026-10-05 13:24:22 UTC 9,048 bytes, 9 lines download raw bytes

1import{a8 as ne,f as ie,u as ce,r as a,s as o,ae as m,j as e,h as y,m as S,i as R,k as F,e as Q,l as B,B as h,a4 as le,J as oe,P as de}from"./index-DLd_kDlx.js";import{R as me,a as xe}from"./radio-group-BU56MLP7.js";import{L as ue}from"./label-D4-ENrYn.js";import{A as V,a as Y}from"./alert-CyfKy7ls.js";import{u as he}from"./useEnhancedTabSwitchDetection-ClrbZUeT.js";import{C as pe}from"./circle-x-C4PFt3c3.js";import{T as ge}from"./triangle-alert-Chqk_WK7.js";import"./index-lTaZyIGy.js";import"./index-Deh-4PO1.js";function Ae(){var D,I,$,L;const{sprintAssessmentId:i}=ne(),{user:je}=ie(),d=ce(),[p,G]=a.useState(null),[v,O]=a.useState(null),[n,W]=a.useState([]),[c,C]=a.useState(0),[b,X]=a.useState({}),[_,A]=a.useState(!0),[N,E]=a.useState(!1),[x,H]=a.useState(180),[g,J]=a.useState(!1),[u,M]=a.useState(null),[w,z]=a.useState(0);a.useEffect(()=>{K()},[i]),a.useEffect(()=>{if(v&&!g&&x>0){const s=setInterval(()=>{H(t=>t<=1?(T(),0):t-1)},1e3);return()=>clearInterval(s)}},[v,g,x]),he({onTabSwitch:()=>T(),onWarning:z,isEnabled:!g&&!_,warningCount:w,assessmentId:i});const K=async()=>{try{A(!0);const{data:s,error:t}=await o.from("sprint_technical_assessments").select(`
2          *,
3          sprints (
4            sprint_number
5          ),
6          pods (
7            pod_name
8          )
9        `).eq("id",i).single();if(t||!s){m({variant:"destructive",title:"Error",description:"Assessment not found"}),d("/xterns/dashboard");return}if(s.status==="completed"){m({title:"Already Completed",description:"You have already completed this assessment"}),d("/xterns/ei-tracker");return}if(s.status==="expired"||new Date(s.expires_at)<new Date){m({variant:"destructive",title:"Assessment Expired",description:"This assessment has expired"}),d("/xterns/dashboard");return}G(s);const{data:r}=await o.from("sprint_technical_assessment_attempts").select("*").eq("sprint_assessment_id",i).maybeSingle();let f=r;if(!f){const{data:P,error:ae}=await o.from("sprint_technical_assessment_attempts").insert({sprint_assessment_id:i}).select().single();if(ae||!P)throw new Error("Failed to create attempt");f=P,await o.from("sprint_technical_assessments").update({status:"in_progress",started_at:new Date().toISOString()}).eq("id",i)}O(f);const{data:te,error:re}=await o.functions.invoke("generate-tech-assessment-questions",{body:{sprintAssessmentId:i,attemptId:f.id,assessmentType:"sprint"}});if(re)throw new Error("Failed to generate questions");W(te.questions||[]),A(!1)}catch(s){console.error("Error loading assessment:",s),m({variant:"destructive",title:"Error",description:s.message||"Failed to load assessment"}),d("/xterns/dashboard")}},k=(s,t)=>{X(r=>({...r,[s]:t})),o.from("sprint_technical_assessment_questions").update({user_answer:t}).eq("id",s).then(({error:r})=>{r&&console.error("Error saving answer:",r)})},U=()=>{c<n.length-1&&C(s=>s+1)},Z=()=>{c>0&&C(s=>s-1)},T=async()=>{await q(!0)},q=async(s=!1)=>{if(!N){E(!0);try{const{data:t,error:r}=await o.functions.invoke("complete-sprint-assessment",{body:{attemptId:v.id,sprintAssessmentId:i,autoSubmitted:s}});if(r||!t.success)throw new Error((t==null?void 0:t.error)||"Failed to submit assessment");M(t),J(!0),m({title:"Assessment Completed!",description:`You scored ${t.correctAnswers}/${t.totalQuestions} and earned ${t.pointsAwarded} points!`})}catch(t){console.error("Error submitting assessment:",t),m({variant:"destructive",title:"Error",description:t.message||"Failed to submit assessment"})}finally{E(!1)}}},ee=s=>{const t=Math.floor(s/60),r=s%60;return`${t}:${r.toString().padStart(2,"0")}`};if(_)return e.jsx("div",{className:"container max-w-4xl mx-auto py-8",children:e.jsx(y,{children:e.jsx(S,{className:"py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Loading assessment..."})]})})})});if(g&&u)return e.jsx("div",{className:"container max-w-4xl mx-auto py-8",children:e.jsxs(y,{children:[e.jsxs(R,{children:[e.jsxs(F,{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-6 w-6 text-green-600"}),"Assessment Complete!"]}),e.jsxs(B,{children:[(D=p.pods)==null?void 0:D.pod_name," - Sprint ",(I=p.sprints)==null?void 0:I.sprint_number]})]}),e.jsxs(S,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-blue-50 rounded-lg",children:[e.jsx("div",{className:"text-3xl font-bold text-blue-600",children:u.correctAnswers}),e.jsx("div",{className:"text-sm text-gray-600",children:"Correct Answers"})]}),e.jsxs("div",{className:"text-center p-4 bg-green-50 rounded-lg",children:[e.jsxs("div",{className:"text-3xl font-bold text-green-600",children:[u.scorePercentage.toFixed(0),"%"]}),e.jsx("div",{className:"text-sm text-gray-600",children:"Score"})]}),e.jsxs("div",{className:"text-center p-4 bg-purple-50 rounded-lg",children:[e.jsx("div",{className:"text-3xl font-bold text-purple-600",children:u.pointsAwarded}),e.jsx("div",{className:"text-sm text-gray-600",children:"DS Points Earned"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Question Review"}),u.questions.map((s,t)=>e.jsx("div",{className:"p-4 border rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[s.isCorrect?e.jsx(Q,{className:"h-5 w-5 text-green-600 mt-1"}):e.jsx(pe,{className:"h-5 w-5 text-red-600 mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium mb-2",children:s.question}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{className:"text-gray-600",children:["Your answer: ",e.jsx("span",{className:s.isCorrect?"text-green-600 font-medium":"text-red-600 font-medium",children:s.userAnswer})]}),!s.isCorrect&&e.jsxs("p",{className:"text-gray-600",children:["Correct answer: ",e.jsx("span",{className:"text-green-600 font-medium",children:s.correctAnswer})]}),e.jsx("p",{className:"text-gray-700 mt-2 italic",children:s.explanation})]})]})]})},t))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{onClick:()=>d("/xterns/ei-tracker"),className:"flex-1",children:"View Skill Tracker"}),e.jsx(h,{onClick:()=>d("/xterns/dashboard"),variant:"outline",className:"flex-1",children:"Back to Dashboard"})]})]})]})});const l=n[c],se=(c+1)/n.length*100,j=Object.keys(b).length;return e.jsx("div",{className:"container max-w-4xl mx-auto py-8",children:e.jsxs(y,{children:[e.jsxs(R,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(F,{children:["Sprint ",($=p.sprints)==null?void 0:$.sprint_number," Technical Assessment"]}),e.jsx(B,{children:(L=p.pods)==null?void 0:L.pod_name})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:`flex items-center gap-2 text-lg font-mono ${x<120?"text-red-600":"text-gray-700"}`,children:[e.jsx(le,{className:"h-5 w-5"}),ee(x)]}),w>0&&e.jsxs(oe,{variant:"destructive",children:["Security Violations: ",w,"/3"]})]})]}),e.jsxs("div",{className:"space-y-2 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[e.jsxs("span",{children:["Question ",c+1," of ",n.length]}),e.jsxs("span",{children:[j,"/",n.length," answered"]})]}),e.jsx(de,{value:se,className:"h-2"})]})]}),e.jsxs(S,{className:"space-y-6",children:[x<120&&e.jsxs(V,{variant:"destructive",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx(Y,{children:"Less than 2 minutes remaining! The assessment will auto-submit when time expires."})]}),l&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[e.jsxs("p",{className:"text-sm text-gray-600 mb-2",children:["Tech Stack: ",l.question_data.tech_stack]}),e.jsx("p",{className:"text-lg font-medium",children:l.question_data.question})]}),e.jsx(me,{value:b[l.id]||"",onValueChange:s=>k(l.id,s),children:e.jsx("div",{className:"space-y-3",children:l.question_data.options.map((s,t)=>{const r=s.charAt(0);return e.jsxs("div",{className:`flex items-center space-x-3 p-4 border rounded-lg cursor-pointer transition-colors ${b[l.id]===r?"border-primary bg-primary/5":"border-gray-200 hover:border-gray-300"}`,onClick:()=>k(l.id,r),children:[e.jsx(xe,{value:r,id:`option-${t}`}),e.jsx(ue,{htmlFor:`option-${t}`,className:"flex-1 cursor-pointer",children:s})]},t)})})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsx(h,{onClick:Z,disabled:c===0,variant:"outline",children:"Previous"}),e.jsx("div",{className:"flex gap-2",children:c<n.length-1?e.jsx(h,{onClick:U,children:"Next"}):e.jsx(h,{onClick:()=>q(!1),disabled:N||j<n.length,className:"bg-green-600 hover:bg-green-700",children:N?"Submitting...":"Submit Assessment"})})]}),j<n.length&&c===n.length-1&&e.jsx(V,{children:e.jsxs(Y,{children:["Please answer all questions before submitting. ",n.length-j," question(s) remaining."]})})]})]})})}export{Ae 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.