PageSourceSearch

https://app.century.tech/assets/AssessmentImportRoute-Bb3P3nGq.js

js century.tech collected 2026-09-24 09:17:47 UTC 5,530 bytes, 1 lines download raw bytes

1import{bs as F,a as _,r as S,j as a,bu as B,ac as D,bx as N,fX as Q}from"./index-D83OPrL5.js";import{N as O,a as q}from"./CMS-Blxz3T4x.js";import{u as J,R as L,f as U,I as H,L as Y,p as f,d as G,e as K,b as W,t as j}from"./useAssessmentImport-CrE8uyJC.js";import{C as z}from"./ConfirmationModal-y-7JsILa.js";import{c as V,d as X,B as Z,e as ee}from"./AppTemplate-4nKKFM5k.js";import"./courses-BjYIX6Vx.js";import"./cloneDeep-BhFfLBmY.js";import"./ErrorBoundary-DV-Wud-8.js";import"./s3-DKhxaHfb.js";import"./TitleControlGroup-CiZL5DgM.js";import"./Hr-CMZCqcmk.js";import"./Checkbox-CigYn4mg.js";import"./index-B1NIE-OO.js";import"./RadioGroup-DhM3F-7a.js";import"./questionGroup-DEmpVdVN.js";import"./useLogin-gOhnuXe5.js";import"./Panel-DhmKHTTx.js";import"./Collapsible-BP7gHssi.js";import"./StickyShelf-NS3RV94-.js";import"./PageSubheader-ivRL64C2.js";import"./SwitchRow-BvVtEOlR.js";import"./AccessIllustration-C-K-QNH4.js";import"./SessionError-Ct87nne5.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"[email protected]"};var r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="fa61411b-94c7-4226-8076-4a0b7e51c190",s._sentryDebugIdIdentifier="sentry-dbid-fa61411b-94c7-4226-8076-4a0b7e51c190")}catch{}})();const A="assessment-import-records",E=(s,r)=>`${s}:${r}`,C=()=>{try{return JSON.parse(localStorage.getItem(A)||"{}")}catch{return{}}},te=s=>{try{localStorage.setItem(A,JSON.stringify(s))}catch{}},w=(s,r)=>C()[E(s,r)],se=(s,r,d)=>{const u=C();u[E(s,r)]=d,te(u)};function I(s){const r=`${s.size}-${s.lastModified}`;let d=0;for(const u of r)d=d*31+u.charCodeAt(0)|0;return`f${(d>>>0).toString(16)}`}async function re(s){if(!crypto?.subtle)return I(s);try{const r=await crypto.subtle.digest("SHA-256",await s.arrayBuffer());return Array.from(new Uint8Array(r)).map(d=>d.toString(16).padStart(2,"0")).join("").slice(0,16)}catch{return I(s)}}const oe={color:U.muted,textAlign:"center",padding:"3rem 0"},ne=1500,Pe=()=>{const{courseId:s,nuggetId:r}=F(),d=_(),u=S.useContext(O),e=J({flow:"cms",courseId:s,nuggetId:r}),{getToken:v,orgId:R,mountedRef:m,jobs:p}=e,y=`/cms/courses/${s}/nuggets/${r}?tab=assessments`,g=()=>d(y),h=S.useRef(!1),M=()=>!h.current&&f(p).length>0,x=()=>window.setTimeout(()=>{m.current&&(h.current=!0,g())},ne),P=t=>{e.handleFiles(t).forEach(async o=>{try{const n=await re(o.file),c=r?w(r,n):void 0;m.current&&e.setJobs(i=>i.map(l=>l.id===o.id?{...l,hash:n,imported:c}:l))}catch{const n=I(o.file),c=r?w(r,n):void 0;m.current&&e.setJobs(i=>i.map(l=>l.id===o.id?{...l,hash:n,imported:c}:l))}})},$=(t,o)=>{if(!t.hash||!r)return;const n=j(o);se(r,t.hash,n),m.current&&e.setJobs(c=>c.map(i=>i.id===t.id?{...i,imported:n}:i))},b=async t=>{const o=G(t.result),n=await K(v(),R,o,{mode:"nugget",name:W(t.name),nuggetId:r});return $(t,n),e.trackCommitted(t,n),n},k=async t=>{if(!(!t.result||!r)){e.setBusy("importing"),e.setImportError(null),e.setImportMessage(null);try{const o=await b(t);if(!m.current)return;e.setImportMessage(`Imported "${t.name}" — created an assessment with ${o.summary.exported} question(s), attached to this nugget.`),f(p).some(c=>c.id!==t.id)||x()}catch(o){if(!m.current)return;e.setImportError(`Import failed for "${t.name}": ${o.message||"unknown error"}. Some content may have been partially created — check this nugget before retrying.`)}finally{m.current&&e.setBusy("idle")}}},T=async()=>{const t=f(p);if(!t.length||!r)return;e.setBusy("importing"),e.setImportError(null),e.setImportMessage(null),e.setImportProgress({done:0,total:t.length});let o=0,n=0;const c=[];for(let i=0;i<t.length;i++){try{const l=await b(t[i]);o+=1,n+=l.summary.exported}catch{c.push(t[i].name)}m.current&&e.setImportProgress({done:i+1,total:t.length})}m.current&&(e.setBusy("idle"),e.setImportProgress(null),o>0&&e.setImportMessage(`Imported ${o} file(s) — created ${o} assessment(s) (${n} question(s)) attached to this nugget.`),c.length?e.setImportError(`${c.length} file(s) could not be imported: ${c.join(", ")}. Content for a failed file may have been partially created — check this nugget before retrying.`):o>0&&x())};return a.jsxs(B,{children:[a.jsx(V,{children:a.jsxs(X,{children:[a.jsx(Z,{children:a.jsx(D,{to:y,"data-testid":"back-btn",children:"Back to assessments"})}),a.jsx(ee,{children:a.jsx("h1",{children:u?.name?`Import questions into "${u.name}"`:"Import questions"})})]})}),a.jsx(N,{children:a.jsx(Q,{pageContentWidth:"xxlarge",children:e.phase==="review"?a.jsx(L,{jobs:p,selectedId:e.selectedId,busy:e.busy,importMessage:e.importMessage,importError:e.importError,importProgress:e.importProgress,onSelect:e.setSelectedId,onQuestionChange:e.handleQuestionChange,onSuggestFix:e.handleSuggestFix,onAdapt:e.handleAdapt,onAcceptSuggestion:e.handleAcceptSuggestion,onDeclineSuggestion:e.handleDeclineSuggestion,onToggleSkip:e.handleToggleSkip,onRemoveQuestion:e.handleRemoveQuestion,focusQuestion:e.focusTarget,onAddQuestion:e.handleAddQuestion,onRegenerate:e.handleRegenerate,onImportFile:k,onImportAll:T,onDone:g,requireConfirm:!0,focusOnMount:!0}):a.jsx("p",{style:oe,children:"Choose worksheets to import…"})})}),a.jsx(H,{modalActive:e.phase!=="review",jobs:p,phase:e.phase,error:e.error,onFilesChosen:P,onRemoveFile:e.removeJob,onProcess:()=>e.processAll(),onExit:g}),a.jsx(q,{unsavedChangesPresent:M,renderModal:(t,o)=>a.jsx(z,{modalMessage:Y,loading:!1,onConfirm:()=>{h.current=!0,o(),d(t)},onCancel:o})})]})};export{Pe 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.