coursekit-lms 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/cli/index.js +8 -4
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/server/index.js +8 -4
  6. package/dist/server/index.js.map +1 -1
  7. package/dist/types/server/config.d.ts +9 -9
  8. package/dist/types/server/context.d.ts +1 -1
  9. package/dist/types/server/db/index.d.ts +2 -4
  10. package/dist/types/server/db/types.d.ts +4 -0
  11. package/dist/types/server/index.d.ts +10 -4
  12. package/dist/types/server/seed/demo.d.ts +3 -3
  13. package/dist/types/server/services/access.d.ts +1 -1
  14. package/dist/types/server/services/courses.d.ts +1 -1
  15. package/dist/types/server/services/notify.d.ts +1 -1
  16. package/dist/types/server/services/progress.d.ts +1 -1
  17. package/dist/types/server/services/quiz.d.ts +1 -1
  18. package/dist/types/server/services/settings.d.ts +1 -1
  19. package/dist/types/server/services/users.d.ts +5 -5
  20. package/dist/web/assets/{ActivityEditor-LKK0d5Mb.js → ActivityEditor-BVSZUV8l.js} +1 -1
  21. package/dist/web/assets/{ActivityPage-BhRtXLwW.js → ActivityPage-DPmSV_mU.js} +1 -1
  22. package/dist/web/assets/{AdminCoursesPage-BT9AQTuZ.js → AdminCoursesPage-uaSHNtzf.js} +1 -1
  23. package/dist/web/assets/{AdminLayout-ChXLxrl_.js → AdminLayout-DqoShZGn.js} +1 -1
  24. package/dist/web/assets/{AdminOverviewPage-BGsUzMXN.js → AdminOverviewPage-DnTrdGbr.js} +1 -1
  25. package/dist/web/assets/{AdminSettingsPage-B4ZeIbVO.js → AdminSettingsPage-B82cX8xU.js} +1 -1
  26. package/dist/web/assets/{AdminUsersPage-BmBSnct8.js → AdminUsersPage-3d2F9AEl.js} +1 -1
  27. package/dist/web/assets/{AnnouncementsPage-KJUA3o7v.js → AnnouncementsPage-BKW30k0Z.js} +1 -1
  28. package/dist/web/assets/{CalendarPage-DQdBEQN-.js → CalendarPage-CLRWyTNT.js} +1 -1
  29. package/dist/web/assets/{CatalogPage-CIFyefBY.js → CatalogPage-BiMgSSBR.js} +1 -1
  30. package/dist/web/assets/{CourseContentPage-CZEP3VMH.js → CourseContentPage-BIDH0UbG.js} +1 -1
  31. package/dist/web/assets/{CourseLayout-CwpWuS7V.js → CourseLayout-ql01LEmj.js} +1 -1
  32. package/dist/web/assets/{CourseSettingsPage-DwEIXO2s.js → CourseSettingsPage-CReoPqOa.js} +1 -1
  33. package/dist/web/assets/{CreateCoursePage-BDfIRStx.js → CreateCoursePage-DFCHlq5M.js} +1 -1
  34. package/dist/web/assets/{DiscussionPage-Dyt0qgUe.js → DiscussionPage-CWwVpFQV.js} +1 -1
  35. package/dist/web/assets/{GradesPage-Brj-Wqu1.js → GradesPage-Bu5vphcG.js} +1 -1
  36. package/dist/web/assets/{MyCoursesPage-GCdSHlYs.js → MyCoursesPage-Dd-Oaygv.js} +1 -1
  37. package/dist/web/assets/{NotFoundPage-CJIpDg1F.js → NotFoundPage-BRquC7-l.js} +1 -1
  38. package/dist/web/assets/{NotificationsPage-Y3shIm5z.js → NotificationsPage-LJvqb6Dj.js} +1 -1
  39. package/dist/web/assets/{ParticipantsPage-OHnKj_8Z.js → ParticipantsPage-wFxiphna.js} +1 -1
  40. package/dist/web/assets/{ProfilePage-Dgj-HYPS.js → ProfilePage-CzfhacAX.js} +1 -1
  41. package/dist/web/assets/{QuizAttemptPage-CiW3E3K0.js → QuizAttemptPage-CEAV6wAL.js} +1 -1
  42. package/dist/web/assets/{QuizEditorPage-bT0jpSFE.js → QuizEditorPage-DS_czQVM.js} +1 -1
  43. package/dist/web/assets/{SubmissionsPage-DXZGSqup.js → SubmissionsPage-CQjcx09G.js} +1 -1
  44. package/dist/web/assets/{context-B5ZaAO90.js → context-BLVW7NB7.js} +1 -1
  45. package/dist/web/assets/{frame-BjgJqbS9.js → frame-CGabirLa.js} +1 -1
  46. package/dist/web/assets/{index-DkBZ18Ts.js → index-B29bTBiJ.js} +2 -2
  47. package/dist/web/assets/{markdown-C1oaAmMK.js → markdown-ykrkPMbn.js} +1 -1
  48. package/dist/web/index.html +1 -1
  49. package/package.json +8 -5
@@ -1 +1 @@
1
- import{At as e,B as t,C as n,D as r,E as i,G as a,H as o,K as s,O as c,Q as l,R as u,Rt as d,S as f,T as p,Tt as m,U as h,V as g,W as _,Z as v,_t as y,g as b,gt as x,k as S,l as C,m as w,n as T,ot as E,q as D,rt as O,t as k,u as A,ut as j,v as M,w as N,xt as P}from"./index-DkBZ18Ts.js";import{D as ee,H as F,M as I,S as te,U as ne,_ as L,dt as re,ft as ie,g as R,h as z,m as B,mt as ae,x as V}from"./hooks-BBARn-DA.js";import{n as H,t as U}from"./arrow-up-LHDup5m4.js";import{n as oe,t as se}from"./ActivityEditor-LKK0d5Mb.js";import{t as W}from"./ellipsis-c2POIN-Y.js";import{t as G}from"./pencil-p0GQmIMo.js";import{T as K,a as ce,t as le}from"./misc-DvgDEI3I.js";import{n as ue}from"./markdown-C1oaAmMK.js";import{a as q,r as de}from"./context-B5ZaAO90.js";var J={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};J.node;var fe=F(J),Y={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};Y.node;var pe=F(Y),X={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};X.node;var me=F(X),Z=ae(ie(),1),Q=re();function he({activity:e,onToggle:t,busy:n}){return e.completion===`none`?null:e.completed?e.completion===`manual`?(0,Q.jsx)(v,{content:`Completed. Click to undo`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-success transition-transform hover:scale-110`,"aria-label":`Mark as not done`,children:(0,Q.jsx)(P,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completed`,children:(0,Q.jsx)(P,{className:`size-5 text-success`})}):e.completion===`manual`?(0,Q.jsx)(v,{content:`Mark as done`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-muted-foreground/50 transition-colors hover:text-success`,"aria-label":`Mark as done`,children:(0,Q.jsx)(oe,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completes automatically`,children:(0,Q.jsx)(pe,{className:`size-5 text-muted-foreground/40`})})}function $({open:e,onOpenChange:t,course:n,section:a}){let[o,s]=(0,Z.useState)(a?.title??``),[l,u]=(0,Z.useState)(a?.summary??``),f=q(),m=d({mutationFn:()=>a?B.patch(`/courses/${n.id}/sections/${a.id}`,{title:o,summary:l}):B.post(`/courses/${n.id}/sections`,{title:o,summary:l}),onSuccess:async()=>{await f(n.slug),t(!1),K.success(a?`Section updated`:`Section added`)},onError:e=>K.error(z(e))});return(0,Q.jsx)(p,{open:e,onOpenChange:t,children:(0,Q.jsx)(r,{children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.mutate()},children:[(0,Q.jsx)(S,{title:a?`Edit section`:`New section`,description:`Sections group activities into weeks, topics or modules.`}),(0,Q.jsxs)(i,{className:`space-y-4`,children:[(0,Q.jsx)(C,{label:`Title`,children:e=>(0,Q.jsx)(A,{...e,autoFocus:!0,required:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Week 3: Working with data`})}),(0,Q.jsx)(C,{label:`Summary`,optional:!0,children:e=>(0,Q.jsx)(w,{...e,rows:3,value:l,onChange:e=>u(e.target.value),placeholder:`What students will do in this section`})})]}),(0,Q.jsxs)(c,{children:[(0,Q.jsx)(R,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(R,{type:`submit`,loading:m.isPending,children:a?`Save`:`Add section`})]})]})})})}function ge({activity:r,course:i,editing:o,isStudent:c,onEdit:p,onMove:v,onMoveTo:b}){let S=q(),C=l(),w=d({mutationFn:()=>r.completed?B.delete(`/activities/${r.id}/complete`):B.post(`/activities/${r.id}/complete`),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),T=d({mutationFn:e=>B.patch(`/activities/${r.id}`,e),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),E=d({mutationFn:()=>B.delete(`/activities/${r.id}`),onSuccess:async()=>{await S(i.slug),K.success(`Activity deleted`)},onError:e=>K.error(z(e))}),k=c&&r.dueAt&&I(r.dueAt)&&!r.completed;return(0,Q.jsxs)(`li`,{className:L(`group relative flex items-center gap-3.5 px-5 py-3 transition-colors hover:bg-accent/40`,!r.visible&&`bg-muted/40`),children:[(0,Q.jsx)(M,{type:r.type,className:L(!r.visible&&`opacity-50`)}),(0,Q.jsxs)(e,{to:N(i.slug,r.id),className:`min-w-0 flex-1 after:absolute after:inset-0`,children:[(0,Q.jsx)(`p`,{className:L(`truncate text-sm font-medium group-hover:text-primary`,!r.visible&&`text-muted-foreground`),children:r.title}),(0,Q.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:n[r.type].label}),r.meta&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsx)(`span`,{children:r.meta})]}),r.dueAt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsxs)(`span`,{className:L(`flex items-center gap-1`,k&&`font-medium text-destructive`),children:[(0,Q.jsx)(m,{className:`size-3`}),V(r.dueAt,!c||r.completed)]})]})]})]}),!r.visible&&(0,Q.jsxs)(f,{variant:`outline`,className:`relative`,children:[(0,Q.jsx)(y,{}),` Hidden`]}),o?(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-0.5`,children:[(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,onClick:p,"aria-label":`Edit activity`,children:(0,Q.jsx)(G,{})}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsxs)(g,{onSelect:()=>v(-1),children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>v(1),children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(_,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(me,{}),` Move to section`]}),(0,Q.jsx)(a,{children:i.sections.filter(e=>e.id!==r.sectionId).map(e=>(0,Q.jsx)(g,{onSelect:()=>b(e.id),children:e.title},e.id))})]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate({visible:!r.visible}),children:[r.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,r.visible?`Hide from students`:`Show to students`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await C({title:`Delete “${r.title}”?`,description:`This removes the activity and all of its submissions, attempts, posts and grades.`,confirmLabel:`Delete`,destructive:!0})&&E.mutate()},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]})]}):c&&(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(he,{activity:r,onToggle:()=>w.mutate(),busy:w.isPending})})]})}function _e({section:e,index:n,course:r,editing:i,isStudent:a,onAddActivity:s,onEditActivity:c}){let[p,m]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(!1),b=q(),S=l(),C=e.activities.filter(e=>e.visible&&e.completion!==`none`),w=C.filter(e=>e.completed).length,T=d({mutationFn:e=>e(),onSuccess:()=>b(r.slug),onError:e=>K.error(z(e))}),A=e=>{let t=r.sections.map(e=>e.id),i=n+e;i<0||i>=t.length||([t[n],t[i]]=[t[i],t[n]],T.mutate(()=>B.put(`/courses/${r.id}/sections/order`,{ids:t})))},j=(t,n)=>{let i=e.activities.map(e=>e.id),a=i.indexOf(t),o=a+n;o<0||o>=i.length||([i[a],i[o]]=[i[o],i[a]],T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:e.id,ids:i})))},M=(e,t)=>{let n=r.sections.find(e=>e.id===t);if(!n)return;let i=[...n.activities.map(e=>e.id),e];T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:t,ids:i}))};return(0,Q.jsxs)(k,{className:L(`overflow-hidden`,!e.visible&&`border-dashed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 px-5 py-4`,children:[(0,Q.jsxs)(`button`,{onClick:()=>m(!p),className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-expanded":p,children:[(0,Q.jsx)(`span`,{className:L(`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full text-xs font-semibold`,a&&C.length>0&&w===C.length?`bg-success text-white`:`bg-muted text-muted-foreground`),children:a&&C.length>0&&w===C.length?(0,Q.jsx)(P,{className:`size-4`}):n+1}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-tight`,children:e.title}),!e.visible&&(0,Q.jsxs)(f,{variant:`outline`,children:[(0,Q.jsx)(y,{}),` Hidden`]})]}),e.summary&&(0,Q.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.summary})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[a&&C.length>0&&(0,Q.jsxs)(`span`,{className:`hidden items-center gap-2 text-xs text-muted-foreground sm:flex`,children:[(0,Q.jsx)(ce,{value:w/C.length*100,className:`w-16`,tone:w===C.length?`success`:`primary`}),w,`/`,C.length]}),i&&(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`Section actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsx)(o,{children:`Section`}),(0,Q.jsxs)(g,{onSelect:()=>v(!0),children:[(0,Q.jsx)(G,{}),` Rename`]}),(0,Q.jsxs)(g,{onSelect:()=>A(-1),disabled:n===0,children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>A(1),disabled:n===r.sections.length-1,children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate(()=>B.patch(`/courses/${r.id}/sections/${e.id}`,{visible:!e.visible})),children:[e.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,e.visible?`Hide section`:`Show section`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await S({title:`Delete “${e.title}”?`,description:`This also deletes its ${e.activities.length} activities and everything students submitted to them.`,confirmLabel:`Delete section`,destructive:!0})&&T.mutate(()=>B.delete(`/courses/${r.id}/sections/${e.id}`))},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]}),(0,Q.jsx)(`button`,{onClick:()=>m(!p),className:`text-muted-foreground`,"aria-label":p?`Collapse section`:`Expand section`,children:(0,Q.jsx)(fe,{className:L(`size-4.5 transition-transform`,!p&&`-rotate-90`)})})]})]}),p&&(0,Q.jsxs)(Q.Fragment,{children:[e.activities.length>0?(0,Q.jsx)(`ul`,{className:`divide-y border-t`,children:e.activities.map(e=>(0,Q.jsx)(ge,{activity:e,course:r,editing:i,isStudent:a,onEdit:()=>c(e.id),onMove:t=>j(e.id,t),onMoveTo:t=>M(e.id,t)},e.id))}):!i&&(0,Q.jsx)(`p`,{className:`border-t px-5 py-4 text-sm text-muted-foreground`,children:`Nothing here yet.`}),i&&(0,Q.jsx)(`div`,{className:`border-t p-2`,children:(0,Q.jsxs)(`button`,{onClick:s,className:`flex w-full items-center justify-center gap-2 rounded-lg border border-dashed py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:bg-primary/[0.03] hover:text-primary`,children:[(0,Q.jsx)(E,{className:`size-4`}),` Add activity`]})})]}),_&&(0,Q.jsx)($,{open:_,onOpenChange:v,course:r,section:e})]})}function ve(){let{course:t,editing:n}=de(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),s=t.myRole===`student`,{data:c}=ne({queryKey:[`announcements`,t.id],queryFn:()=>B.get(`/courses/${t.id}/announcements`)}),l=t.sections.flatMap(e=>e.activities).filter(e=>e.dueAt&&!I(e.dueAt)&&e.visible).sort((e,t)=>e.dueAt.localeCompare(t.dueAt)).slice(0,4);return(0,Q.jsxs)(b,{children:[n&&(0,Q.jsxs)(`div`,{className:`mb-5 flex items-center gap-3 rounded-xl border border-primary/30 bg-primary/[0.05] px-4 py-3 text-sm`,children:[(0,Q.jsx)(G,{className:`size-4 text-primary`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Edit mode is on.`}),` Add, reorder, hide or delete sections and activities.`]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[t.sections.length===0&&(0,Q.jsx)(le,{icon:E,title:`This course is empty`,description:`Turn on edit mode to add the first section.`}),t.sections.map((e,r)=>(0,Q.jsx)(_e,{section:e,index:r,course:t,editing:n,isStudent:s,onAddActivity:()=>i({sectionId:e.id}),onEditActivity:e=>i({activityId:e})},e.id)),n&&(0,Q.jsxs)(R,{variant:`outline`,className:`w-full border-dashed`,size:`lg`,onClick:()=>o(!0),children:[(0,Q.jsx)(E,{}),` Add section`]})]}),(0,Q.jsxs)(`aside`,{className:`space-y-5 lg:sticky lg:top-32`,children:[l.length>0&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Coming up`,icon:(0,Q.jsx)(m,{className:`size-4.5`})}),(0,Q.jsx)(`div`,{className:`space-y-1 px-2 pb-3`,children:l.map(n=>(0,Q.jsxs)(e,{to:N(t.slug,n.id),className:`flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(M,{type:n.type,size:`sm`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:V(n.dueAt)})]})]},n.id))})]}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Latest news`,icon:(0,Q.jsx)(j,{className:`size-4.5`}),action:(0,Q.jsx)(e,{to:`/courses/${t.slug}/announcements`,className:`text-xs font-medium text-primary hover:underline`,children:`View all`})}),(0,Q.jsxs)(`div`,{className:`space-y-1 px-2 pb-3`,children:[(c??[]).slice(0,2).map(n=>(0,Q.jsxs)(e,{to:`/courses/${t.slug}/announcements`,className:`block rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:te(n.body)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:ee(n.createdAt)})]},n.id)),c?.length===0&&(0,Q.jsx)(`p`,{className:`px-3 pb-2 text-sm text-muted-foreground`,children:`No announcements yet.`})]})]}),t.description&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Overview`}),(0,Q.jsx)(`div`,{className:`max-h-72 overflow-hidden px-5 pb-5 [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,Q.jsx)(ue,{source:t.description,className:`prose-sm`})})]})]})]}),r&&(0,Q.jsx)(se,{course:t,open:!!r,onOpenChange:e=>!e&&i(null),sectionId:r.sectionId,activityId:r.activityId}),a&&(0,Q.jsx)($,{open:a,onOpenChange:o,course:t})]})}export{ve as default};
1
+ import{At as e,B as t,C as n,D as r,E as i,G as a,H as o,K as s,O as c,Q as l,R as u,Rt as d,S as f,T as p,Tt as m,U as h,V as g,W as _,Z as v,_t as y,g as b,gt as x,k as S,l as C,m as w,n as T,ot as E,q as D,rt as O,t as k,u as A,ut as j,v as M,w as N,xt as P}from"./index-B29bTBiJ.js";import{D as ee,H as F,M as I,S as te,U as ne,_ as L,dt as re,ft as ie,g as R,h as z,m as B,mt as ae,x as V}from"./hooks-BBARn-DA.js";import{n as H,t as U}from"./arrow-up-LHDup5m4.js";import{n as oe,t as se}from"./ActivityEditor-BVSZUV8l.js";import{t as W}from"./ellipsis-c2POIN-Y.js";import{t as G}from"./pencil-p0GQmIMo.js";import{T as K,a as ce,t as le}from"./misc-DvgDEI3I.js";import{n as ue}from"./markdown-ykrkPMbn.js";import{a as q,r as de}from"./context-BLVW7NB7.js";var J={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};J.node;var fe=F(J),Y={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};Y.node;var pe=F(Y),X={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};X.node;var me=F(X),Z=ae(ie(),1),Q=re();function he({activity:e,onToggle:t,busy:n}){return e.completion===`none`?null:e.completed?e.completion===`manual`?(0,Q.jsx)(v,{content:`Completed. Click to undo`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-success transition-transform hover:scale-110`,"aria-label":`Mark as not done`,children:(0,Q.jsx)(P,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completed`,children:(0,Q.jsx)(P,{className:`size-5 text-success`})}):e.completion===`manual`?(0,Q.jsx)(v,{content:`Mark as done`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-muted-foreground/50 transition-colors hover:text-success`,"aria-label":`Mark as done`,children:(0,Q.jsx)(oe,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completes automatically`,children:(0,Q.jsx)(pe,{className:`size-5 text-muted-foreground/40`})})}function $({open:e,onOpenChange:t,course:n,section:a}){let[o,s]=(0,Z.useState)(a?.title??``),[l,u]=(0,Z.useState)(a?.summary??``),f=q(),m=d({mutationFn:()=>a?B.patch(`/courses/${n.id}/sections/${a.id}`,{title:o,summary:l}):B.post(`/courses/${n.id}/sections`,{title:o,summary:l}),onSuccess:async()=>{await f(n.slug),t(!1),K.success(a?`Section updated`:`Section added`)},onError:e=>K.error(z(e))});return(0,Q.jsx)(p,{open:e,onOpenChange:t,children:(0,Q.jsx)(r,{children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.mutate()},children:[(0,Q.jsx)(S,{title:a?`Edit section`:`New section`,description:`Sections group activities into weeks, topics or modules.`}),(0,Q.jsxs)(i,{className:`space-y-4`,children:[(0,Q.jsx)(C,{label:`Title`,children:e=>(0,Q.jsx)(A,{...e,autoFocus:!0,required:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Week 3: Working with data`})}),(0,Q.jsx)(C,{label:`Summary`,optional:!0,children:e=>(0,Q.jsx)(w,{...e,rows:3,value:l,onChange:e=>u(e.target.value),placeholder:`What students will do in this section`})})]}),(0,Q.jsxs)(c,{children:[(0,Q.jsx)(R,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(R,{type:`submit`,loading:m.isPending,children:a?`Save`:`Add section`})]})]})})})}function ge({activity:r,course:i,editing:o,isStudent:c,onEdit:p,onMove:v,onMoveTo:b}){let S=q(),C=l(),w=d({mutationFn:()=>r.completed?B.delete(`/activities/${r.id}/complete`):B.post(`/activities/${r.id}/complete`),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),T=d({mutationFn:e=>B.patch(`/activities/${r.id}`,e),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),E=d({mutationFn:()=>B.delete(`/activities/${r.id}`),onSuccess:async()=>{await S(i.slug),K.success(`Activity deleted`)},onError:e=>K.error(z(e))}),k=c&&r.dueAt&&I(r.dueAt)&&!r.completed;return(0,Q.jsxs)(`li`,{className:L(`group relative flex items-center gap-3.5 px-5 py-3 transition-colors hover:bg-accent/40`,!r.visible&&`bg-muted/40`),children:[(0,Q.jsx)(M,{type:r.type,className:L(!r.visible&&`opacity-50`)}),(0,Q.jsxs)(e,{to:N(i.slug,r.id),className:`min-w-0 flex-1 after:absolute after:inset-0`,children:[(0,Q.jsx)(`p`,{className:L(`truncate text-sm font-medium group-hover:text-primary`,!r.visible&&`text-muted-foreground`),children:r.title}),(0,Q.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:n[r.type].label}),r.meta&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsx)(`span`,{children:r.meta})]}),r.dueAt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsxs)(`span`,{className:L(`flex items-center gap-1`,k&&`font-medium text-destructive`),children:[(0,Q.jsx)(m,{className:`size-3`}),V(r.dueAt,!c||r.completed)]})]})]})]}),!r.visible&&(0,Q.jsxs)(f,{variant:`outline`,className:`relative`,children:[(0,Q.jsx)(y,{}),` Hidden`]}),o?(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-0.5`,children:[(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,onClick:p,"aria-label":`Edit activity`,children:(0,Q.jsx)(G,{})}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsxs)(g,{onSelect:()=>v(-1),children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>v(1),children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(_,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(me,{}),` Move to section`]}),(0,Q.jsx)(a,{children:i.sections.filter(e=>e.id!==r.sectionId).map(e=>(0,Q.jsx)(g,{onSelect:()=>b(e.id),children:e.title},e.id))})]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate({visible:!r.visible}),children:[r.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,r.visible?`Hide from students`:`Show to students`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await C({title:`Delete “${r.title}”?`,description:`This removes the activity and all of its submissions, attempts, posts and grades.`,confirmLabel:`Delete`,destructive:!0})&&E.mutate()},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]})]}):c&&(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(he,{activity:r,onToggle:()=>w.mutate(),busy:w.isPending})})]})}function _e({section:e,index:n,course:r,editing:i,isStudent:a,onAddActivity:s,onEditActivity:c}){let[p,m]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(!1),b=q(),S=l(),C=e.activities.filter(e=>e.visible&&e.completion!==`none`),w=C.filter(e=>e.completed).length,T=d({mutationFn:e=>e(),onSuccess:()=>b(r.slug),onError:e=>K.error(z(e))}),A=e=>{let t=r.sections.map(e=>e.id),i=n+e;i<0||i>=t.length||([t[n],t[i]]=[t[i],t[n]],T.mutate(()=>B.put(`/courses/${r.id}/sections/order`,{ids:t})))},j=(t,n)=>{let i=e.activities.map(e=>e.id),a=i.indexOf(t),o=a+n;o<0||o>=i.length||([i[a],i[o]]=[i[o],i[a]],T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:e.id,ids:i})))},M=(e,t)=>{let n=r.sections.find(e=>e.id===t);if(!n)return;let i=[...n.activities.map(e=>e.id),e];T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:t,ids:i}))};return(0,Q.jsxs)(k,{className:L(`overflow-hidden`,!e.visible&&`border-dashed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 px-5 py-4`,children:[(0,Q.jsxs)(`button`,{onClick:()=>m(!p),className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-expanded":p,children:[(0,Q.jsx)(`span`,{className:L(`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full text-xs font-semibold`,a&&C.length>0&&w===C.length?`bg-success text-white`:`bg-muted text-muted-foreground`),children:a&&C.length>0&&w===C.length?(0,Q.jsx)(P,{className:`size-4`}):n+1}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-tight`,children:e.title}),!e.visible&&(0,Q.jsxs)(f,{variant:`outline`,children:[(0,Q.jsx)(y,{}),` Hidden`]})]}),e.summary&&(0,Q.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.summary})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[a&&C.length>0&&(0,Q.jsxs)(`span`,{className:`hidden items-center gap-2 text-xs text-muted-foreground sm:flex`,children:[(0,Q.jsx)(ce,{value:w/C.length*100,className:`w-16`,tone:w===C.length?`success`:`primary`}),w,`/`,C.length]}),i&&(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`Section actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsx)(o,{children:`Section`}),(0,Q.jsxs)(g,{onSelect:()=>v(!0),children:[(0,Q.jsx)(G,{}),` Rename`]}),(0,Q.jsxs)(g,{onSelect:()=>A(-1),disabled:n===0,children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>A(1),disabled:n===r.sections.length-1,children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate(()=>B.patch(`/courses/${r.id}/sections/${e.id}`,{visible:!e.visible})),children:[e.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,e.visible?`Hide section`:`Show section`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await S({title:`Delete “${e.title}”?`,description:`This also deletes its ${e.activities.length} activities and everything students submitted to them.`,confirmLabel:`Delete section`,destructive:!0})&&T.mutate(()=>B.delete(`/courses/${r.id}/sections/${e.id}`))},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]}),(0,Q.jsx)(`button`,{onClick:()=>m(!p),className:`text-muted-foreground`,"aria-label":p?`Collapse section`:`Expand section`,children:(0,Q.jsx)(fe,{className:L(`size-4.5 transition-transform`,!p&&`-rotate-90`)})})]})]}),p&&(0,Q.jsxs)(Q.Fragment,{children:[e.activities.length>0?(0,Q.jsx)(`ul`,{className:`divide-y border-t`,children:e.activities.map(e=>(0,Q.jsx)(ge,{activity:e,course:r,editing:i,isStudent:a,onEdit:()=>c(e.id),onMove:t=>j(e.id,t),onMoveTo:t=>M(e.id,t)},e.id))}):!i&&(0,Q.jsx)(`p`,{className:`border-t px-5 py-4 text-sm text-muted-foreground`,children:`Nothing here yet.`}),i&&(0,Q.jsx)(`div`,{className:`border-t p-2`,children:(0,Q.jsxs)(`button`,{onClick:s,className:`flex w-full items-center justify-center gap-2 rounded-lg border border-dashed py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:bg-primary/[0.03] hover:text-primary`,children:[(0,Q.jsx)(E,{className:`size-4`}),` Add activity`]})})]}),_&&(0,Q.jsx)($,{open:_,onOpenChange:v,course:r,section:e})]})}function ve(){let{course:t,editing:n}=de(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),s=t.myRole===`student`,{data:c}=ne({queryKey:[`announcements`,t.id],queryFn:()=>B.get(`/courses/${t.id}/announcements`)}),l=t.sections.flatMap(e=>e.activities).filter(e=>e.dueAt&&!I(e.dueAt)&&e.visible).sort((e,t)=>e.dueAt.localeCompare(t.dueAt)).slice(0,4);return(0,Q.jsxs)(b,{children:[n&&(0,Q.jsxs)(`div`,{className:`mb-5 flex items-center gap-3 rounded-xl border border-primary/30 bg-primary/[0.05] px-4 py-3 text-sm`,children:[(0,Q.jsx)(G,{className:`size-4 text-primary`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Edit mode is on.`}),` Add, reorder, hide or delete sections and activities.`]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[t.sections.length===0&&(0,Q.jsx)(le,{icon:E,title:`This course is empty`,description:`Turn on edit mode to add the first section.`}),t.sections.map((e,r)=>(0,Q.jsx)(_e,{section:e,index:r,course:t,editing:n,isStudent:s,onAddActivity:()=>i({sectionId:e.id}),onEditActivity:e=>i({activityId:e})},e.id)),n&&(0,Q.jsxs)(R,{variant:`outline`,className:`w-full border-dashed`,size:`lg`,onClick:()=>o(!0),children:[(0,Q.jsx)(E,{}),` Add section`]})]}),(0,Q.jsxs)(`aside`,{className:`space-y-5 lg:sticky lg:top-32`,children:[l.length>0&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Coming up`,icon:(0,Q.jsx)(m,{className:`size-4.5`})}),(0,Q.jsx)(`div`,{className:`space-y-1 px-2 pb-3`,children:l.map(n=>(0,Q.jsxs)(e,{to:N(t.slug,n.id),className:`flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(M,{type:n.type,size:`sm`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:V(n.dueAt)})]})]},n.id))})]}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Latest news`,icon:(0,Q.jsx)(j,{className:`size-4.5`}),action:(0,Q.jsx)(e,{to:`/courses/${t.slug}/announcements`,className:`text-xs font-medium text-primary hover:underline`,children:`View all`})}),(0,Q.jsxs)(`div`,{className:`space-y-1 px-2 pb-3`,children:[(c??[]).slice(0,2).map(n=>(0,Q.jsxs)(e,{to:`/courses/${t.slug}/announcements`,className:`block rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:te(n.body)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:ee(n.createdAt)})]},n.id)),c?.length===0&&(0,Q.jsx)(`p`,{className:`px-3 pb-2 text-sm text-muted-foreground`,children:`No announcements yet.`})]})]}),t.description&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Overview`}),(0,Q.jsx)(`div`,{className:`max-h-72 overflow-hidden px-5 pb-5 [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,Q.jsx)(ue,{source:t.description,className:`prose-sm`})})]})]})]}),r&&(0,Q.jsx)(se,{course:t,open:!!r,onOpenChange:e=>!e&&i(null),sectionId:r.sectionId,activityId:r.activityId}),a&&(0,Q.jsx)($,{open:a,onOpenChange:o,course:t})]})}export{ve as default};
@@ -1 +1 @@
1
- import{At as e,C as t,Ct as n,Dt as r,Et as i,Lt as a,M as o,Ot as s,Pt as c,Rt as l,St as u,et as d,g as f,jt as p,n as m,t as h,u as g,ut as _,v,w as y,x as b}from"./index-DkBZ18Ts.js";import{H as x,N as S,_ as C,dt as w,ft as T,g as E,h as D,m as O,mt as k,p as A,r as j,u as M,w as N}from"./hooks-BBARn-DA.js";import{t as P}from"./key-round-B_KI-brR.js";import{t as F}from"./lock-BjbqwA_0.js";import{t as I}from"./pencil-p0GQmIMo.js";import{t as L}from"./settings-DRKWzSHN.js";import{T as R,c as z,n as B,o as V}from"./misc-DvgDEI3I.js";import{n as H}from"./markdown-C1oaAmMK.js";import U from"./NotFoundPage-CJIpDg1F.js";import{a as W,i as G,n as K,t as q}from"./context-B5ZaAO90.js";var J={name:`calendar-range`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M17 13h-6`,key:`1qbiup`}],[`path`,{d:`M13 17H7`,key:`1x38vv`}],[`path`,{d:`M7 13h.01`,key:`1vezk1`}],[`path`,{d:`M17 17h.01`,key:`1sd3ek`}]]};J.node;var Y=x(J),X=k(T(),1),Z=w();function Q({course:e}){return(0,Z.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-white/85`,children:[e.teachers.length>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{users:e.teachers,max:3,size:`xs`}),e.teachers.map(e=>e.name).join(`, `)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(d,{className:`size-4`}),` `,S(e.studentCount,`student`)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(i,{className:`size-4`}),` `,S(e.activityCount,`activity`,`activities`)]}),(e.startDate||e.endDate)&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Y,{className:`size-4`}),` `,N(e.startDate),` – `,N(e.endDate)]})]})}function $({course:t,editing:r,setEditing:i}){let a=t.capabilities.includes(`course:manageContent`),o=q(t).filter(e=>e.visible&&e.completion!==`none`),c=o.filter(e=>e.completed).length,l=t.myRole===`student`?K(t):null;return(0,Z.jsxs)(b,{color:t.coverColor,imageUrl:t.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-6 pb-8 sm:px-6 lg:px-8 lg:pt-8`,children:[(0,Z.jsxs)(`nav`,{className:`flex items-center gap-1.5 text-[13px] text-white/75`,children:[(0,Z.jsx)(e,{to:`/catalog`,className:`hover:text-white`,children:`Courses`}),t.categoryName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3.5`}),(0,Z.jsx)(e,{to:`/catalog?category=${t.categoryId}`,className:`hover:text-white`,children:t.categoryName})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-3xl min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[t.visibility!==`published`&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white px-2.5 py-0.5 text-xs font-semibold text-slate-900 capitalize`,children:t.visibility}),t.myRole&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-medium backdrop-blur`,children:M[t.myRole]})]}),(0,Z.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-balance sm:text-4xl`,children:t.title}),t.summary&&(0,Z.jsx)(`p`,{className:`mt-2.5 max-w-2xl text-[15px] leading-relaxed text-white/85`,children:t.summary}),(0,Z.jsx)(Q,{course:t})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3`,children:[t.progress!=null&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-black/15 py-2.5 pr-4 pl-2.5 ring-1 ring-white/20 backdrop-blur-md`,children:[(0,Z.jsx)(V,{value:t.progress,size:46,className:`text-white`}),(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-semibold`,children:`Your progress`}),(0,Z.jsxs)(`p`,{className:`text-white/75`,children:[c,` of `,o.length,` done`]})]})]}),l&&(0,Z.jsx)(E,{asChild:!0,className:`bg-white text-slate-900 shadow-lg hover:bg-white/90 hover:brightness-100`,size:`lg`,children:(0,Z.jsxs)(e,{to:y(t.slug,l.id),children:[`Continue `,(0,Z.jsx)(s,{})]})}),a&&(0,Z.jsxs)(E,{size:`lg`,onClick:()=>i(!r),className:C(`hover:brightness-100`,r?`bg-white text-slate-900 hover:bg-white/90`:`bg-white/15 text-white ring-1 ring-white/25 backdrop-blur hover:bg-white/25`),children:[r?(0,Z.jsx)(n,{}):(0,Z.jsx)(I,{}),r?`Done editing`:`Edit course`]})]})]})]})]})}function ee({course:e}){let[n,r]=(0,X.useState)(``),i=W(),a=l({mutationFn:()=>O.post(`/courses/${e.id}/enrol`,e.hasEnrolmentKey?{key:n}:{}),onSuccess:async()=>{R.success(`You're enrolled in ${e.title}. Have fun!`),await i(e.slug)},onError:e=>R.error(D(e))});return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(b,{color:e.coverColor,imageUrl:e.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-10 pb-12 sm:px-6 lg:px-8`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-white/75`,children:e.categoryName??`Course`}),(0,Z.jsx)(`h1`,{className:`mt-2 max-w-3xl text-3xl font-semibold tracking-tight sm:text-5xl`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-2xl text-base text-white/85`,children:e.summary}),(0,Z.jsx)(Q,{course:e})]})]}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-8`,children:[e.description&&(0,Z.jsx)(h,{className:`p-6`,children:(0,Z.jsx)(H,{source:e.description})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-lg font-semibold tracking-tight`,children:`Course outline`}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.sections.map((e,n)=>(0,Z.jsxs)(h,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-5 py-3.5`,children:[(0,Z.jsx)(`span`,{className:`grid size-6 place-items-center rounded-full bg-muted text-xs font-semibold`,children:n+1}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:S(e.activities.length,`activity`,`activities`)})]}),(0,Z.jsx)(`ul`,{className:`divide-y`,children:e.activities.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-2.5 text-sm`,children:[(0,Z.jsx)(v,{type:e.type,size:`sm`}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t[e.type].label}),(0,Z.jsx)(F,{className:`size-3.5 text-muted-foreground/60`})]},e.id))})]},e.id))})]})]}),(0,Z.jsxs)(h,{className:`sticky top-20`,children:[(0,Z.jsx)(m,{title:`Join this course`,description:e.canEnrol?`Get instant access to every lesson and activity.`:void 0}),(0,Z.jsx)(`div`,{className:`space-y-3 px-5 pb-5`,children:e.canEnrol?(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.mutate()},className:`space-y-3`,children:[e.hasEnrolmentKey&&(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(P,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(g,{value:n,onChange:e=>r(e.target.value),placeholder:`Enrolment key`,className:`pl-9`,"aria-label":`Enrolment key`})]}),(0,Z.jsx)(E,{type:`submit`,size:`lg`,className:`w-full`,loading:a.isPending,disabled:e.hasEnrolmentKey&&!n.trim(),children:`Enrol now`}),e.hasEnrolmentKey&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Your teacher gives you the key for this course.`})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This course is invite-only. Ask a teacher to add you.`})})]})]})})]})}function te(){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{className:`h-64 rounded-none`}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(z,{className:`h-40`}),(0,Z.jsx)(z,{className:`h-40`})]})})]})}function ne(){let{slug:e}=a(),{data:t,isLoading:n,error:o,refetch:s}=G(e),[l,u]=(0,X.useState)(!1);if(j(t?.title),n)return(0,Z.jsx)(te,{});if(o instanceof A&&o.status===404)return(0,Z.jsx)(U,{});if(o||!t)return(0,Z.jsx)(f,{children:(0,Z.jsx)(B,{error:o,onRetry:()=>s()})});if(t.outlineOnly)return(0,Z.jsx)(ee,{course:t});let m=e=>t.capabilities.includes(e),h=[{to:``,label:`Course`,icon:i,end:!0},{to:`announcements`,label:`Announcements`,icon:_},{to:`participants`,label:`Participants`,icon:d,show:m(`course:viewParticipants`)},{to:`grades`,label:`Grades`,icon:r},{to:`settings`,label:`Settings`,icon:L,show:m(`course:update`)}].filter(e=>e.show!==!1);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)($,{course:t,editing:l,setEditing:u}),(0,Z.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/85 backdrop-blur-lg`,children:(0,Z.jsx)(`nav`,{className:`ck-no-scrollbar mx-auto flex max-w-7xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8`,children:h.map(e=>(0,Z.jsxs)(p,{to:e.to?`/courses/${t.slug}/${e.to}`:`/courses/${t.slug}`,end:e.end,className:({isActive:e})=>C(`relative flex h-12 shrink-0 items-center gap-2 px-3 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,e&&`text-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-primary`),children:[(0,Z.jsx)(e.icon,{className:`size-4`}),e.label]},e.label))})}),(0,Z.jsx)(c,{context:{course:t,editing:l,setEditing:u,can:m}})]})}export{ne as default};
1
+ import{At as e,C as t,Ct as n,Dt as r,Et as i,Lt as a,M as o,Ot as s,Pt as c,Rt as l,St as u,et as d,g as f,jt as p,n as m,t as h,u as g,ut as _,v,w as y,x as b}from"./index-B29bTBiJ.js";import{H as x,N as S,_ as C,dt as w,ft as T,g as E,h as D,m as O,mt as k,p as A,r as j,u as M,w as N}from"./hooks-BBARn-DA.js";import{t as P}from"./key-round-B_KI-brR.js";import{t as F}from"./lock-BjbqwA_0.js";import{t as I}from"./pencil-p0GQmIMo.js";import{t as L}from"./settings-DRKWzSHN.js";import{T as R,c as z,n as B,o as V}from"./misc-DvgDEI3I.js";import{n as H}from"./markdown-ykrkPMbn.js";import U from"./NotFoundPage-BRquC7-l.js";import{a as W,i as G,n as K,t as q}from"./context-BLVW7NB7.js";var J={name:`calendar-range`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M17 13h-6`,key:`1qbiup`}],[`path`,{d:`M13 17H7`,key:`1x38vv`}],[`path`,{d:`M7 13h.01`,key:`1vezk1`}],[`path`,{d:`M17 17h.01`,key:`1sd3ek`}]]};J.node;var Y=x(J),X=k(T(),1),Z=w();function Q({course:e}){return(0,Z.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-white/85`,children:[e.teachers.length>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{users:e.teachers,max:3,size:`xs`}),e.teachers.map(e=>e.name).join(`, `)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(d,{className:`size-4`}),` `,S(e.studentCount,`student`)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(i,{className:`size-4`}),` `,S(e.activityCount,`activity`,`activities`)]}),(e.startDate||e.endDate)&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Y,{className:`size-4`}),` `,N(e.startDate),` – `,N(e.endDate)]})]})}function $({course:t,editing:r,setEditing:i}){let a=t.capabilities.includes(`course:manageContent`),o=q(t).filter(e=>e.visible&&e.completion!==`none`),c=o.filter(e=>e.completed).length,l=t.myRole===`student`?K(t):null;return(0,Z.jsxs)(b,{color:t.coverColor,imageUrl:t.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-6 pb-8 sm:px-6 lg:px-8 lg:pt-8`,children:[(0,Z.jsxs)(`nav`,{className:`flex items-center gap-1.5 text-[13px] text-white/75`,children:[(0,Z.jsx)(e,{to:`/catalog`,className:`hover:text-white`,children:`Courses`}),t.categoryName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3.5`}),(0,Z.jsx)(e,{to:`/catalog?category=${t.categoryId}`,className:`hover:text-white`,children:t.categoryName})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-3xl min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[t.visibility!==`published`&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white px-2.5 py-0.5 text-xs font-semibold text-slate-900 capitalize`,children:t.visibility}),t.myRole&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-medium backdrop-blur`,children:M[t.myRole]})]}),(0,Z.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-balance sm:text-4xl`,children:t.title}),t.summary&&(0,Z.jsx)(`p`,{className:`mt-2.5 max-w-2xl text-[15px] leading-relaxed text-white/85`,children:t.summary}),(0,Z.jsx)(Q,{course:t})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3`,children:[t.progress!=null&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-black/15 py-2.5 pr-4 pl-2.5 ring-1 ring-white/20 backdrop-blur-md`,children:[(0,Z.jsx)(V,{value:t.progress,size:46,className:`text-white`}),(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-semibold`,children:`Your progress`}),(0,Z.jsxs)(`p`,{className:`text-white/75`,children:[c,` of `,o.length,` done`]})]})]}),l&&(0,Z.jsx)(E,{asChild:!0,className:`bg-white text-slate-900 shadow-lg hover:bg-white/90 hover:brightness-100`,size:`lg`,children:(0,Z.jsxs)(e,{to:y(t.slug,l.id),children:[`Continue `,(0,Z.jsx)(s,{})]})}),a&&(0,Z.jsxs)(E,{size:`lg`,onClick:()=>i(!r),className:C(`hover:brightness-100`,r?`bg-white text-slate-900 hover:bg-white/90`:`bg-white/15 text-white ring-1 ring-white/25 backdrop-blur hover:bg-white/25`),children:[r?(0,Z.jsx)(n,{}):(0,Z.jsx)(I,{}),r?`Done editing`:`Edit course`]})]})]})]})]})}function ee({course:e}){let[n,r]=(0,X.useState)(``),i=W(),a=l({mutationFn:()=>O.post(`/courses/${e.id}/enrol`,e.hasEnrolmentKey?{key:n}:{}),onSuccess:async()=>{R.success(`You're enrolled in ${e.title}. Have fun!`),await i(e.slug)},onError:e=>R.error(D(e))});return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(b,{color:e.coverColor,imageUrl:e.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-10 pb-12 sm:px-6 lg:px-8`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-white/75`,children:e.categoryName??`Course`}),(0,Z.jsx)(`h1`,{className:`mt-2 max-w-3xl text-3xl font-semibold tracking-tight sm:text-5xl`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-2xl text-base text-white/85`,children:e.summary}),(0,Z.jsx)(Q,{course:e})]})]}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-8`,children:[e.description&&(0,Z.jsx)(h,{className:`p-6`,children:(0,Z.jsx)(H,{source:e.description})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-lg font-semibold tracking-tight`,children:`Course outline`}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.sections.map((e,n)=>(0,Z.jsxs)(h,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-5 py-3.5`,children:[(0,Z.jsx)(`span`,{className:`grid size-6 place-items-center rounded-full bg-muted text-xs font-semibold`,children:n+1}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:S(e.activities.length,`activity`,`activities`)})]}),(0,Z.jsx)(`ul`,{className:`divide-y`,children:e.activities.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-2.5 text-sm`,children:[(0,Z.jsx)(v,{type:e.type,size:`sm`}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t[e.type].label}),(0,Z.jsx)(F,{className:`size-3.5 text-muted-foreground/60`})]},e.id))})]},e.id))})]})]}),(0,Z.jsxs)(h,{className:`sticky top-20`,children:[(0,Z.jsx)(m,{title:`Join this course`,description:e.canEnrol?`Get instant access to every lesson and activity.`:void 0}),(0,Z.jsx)(`div`,{className:`space-y-3 px-5 pb-5`,children:e.canEnrol?(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.mutate()},className:`space-y-3`,children:[e.hasEnrolmentKey&&(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(P,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(g,{value:n,onChange:e=>r(e.target.value),placeholder:`Enrolment key`,className:`pl-9`,"aria-label":`Enrolment key`})]}),(0,Z.jsx)(E,{type:`submit`,size:`lg`,className:`w-full`,loading:a.isPending,disabled:e.hasEnrolmentKey&&!n.trim(),children:`Enrol now`}),e.hasEnrolmentKey&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Your teacher gives you the key for this course.`})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This course is invite-only. Ask a teacher to add you.`})})]})]})})]})}function te(){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{className:`h-64 rounded-none`}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(z,{className:`h-40`}),(0,Z.jsx)(z,{className:`h-40`})]})})]})}function ne(){let{slug:e}=a(),{data:t,isLoading:n,error:o,refetch:s}=G(e),[l,u]=(0,X.useState)(!1);if(j(t?.title),n)return(0,Z.jsx)(te,{});if(o instanceof A&&o.status===404)return(0,Z.jsx)(U,{});if(o||!t)return(0,Z.jsx)(f,{children:(0,Z.jsx)(B,{error:o,onRetry:()=>s()})});if(t.outlineOnly)return(0,Z.jsx)(ee,{course:t});let m=e=>t.capabilities.includes(e),h=[{to:``,label:`Course`,icon:i,end:!0},{to:`announcements`,label:`Announcements`,icon:_},{to:`participants`,label:`Participants`,icon:d,show:m(`course:viewParticipants`)},{to:`grades`,label:`Grades`,icon:r},{to:`settings`,label:`Settings`,icon:L,show:m(`course:update`)}].filter(e=>e.show!==!1);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)($,{course:t,editing:l,setEditing:u}),(0,Z.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/85 backdrop-blur-lg`,children:(0,Z.jsx)(`nav`,{className:`ck-no-scrollbar mx-auto flex max-w-7xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8`,children:h.map(e=>(0,Z.jsxs)(p,{to:e.to?`/courses/${t.slug}/${e.to}`:`/courses/${t.slug}`,end:e.end,className:({isActive:e})=>C(`relative flex h-12 shrink-0 items-center gap-2 px-3 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,e&&`text-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-primary`),children:[(0,Z.jsx)(e.icon,{className:`size-4`}),e.label]},e.label))})}),(0,Z.jsx)(c,{context:{course:t,editing:l,setEditing:u,can:m}})]})}export{ne as default};
@@ -1 +1 @@
1
- import{Ct as e,Ft as t,I as n,N as r,Q as i,Rt as a,c as o,f as s,g as c,gt as l,l as u,m as d,rt as f,t as p,u as m}from"./index-DkBZ18Ts.js";import{H as h,P as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,i as C,k as w,m as T,mt as E,r as D}from"./hooks-BBARn-DA.js";import{t as O}from"./key-round-B_KI-brR.js";import{T as k}from"./misc-DvgDEI3I.js";import{r as A}from"./constants-DLDWTvvN.js";import{r as j}from"./markdown-C1oaAmMK.js";import{a as M,r as N}from"./context-B5ZaAO90.js";var P={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};P.node;var F=h(P),I={name:`file-lock`,size:24,node:[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]],aliases:[`file-lock-2`]};I.node;var L=h(I),R={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};R.node;var z=h(R),B={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};B.node;var V=h(B),H=E(b(),1),U=y();function W({value:t,onChange:i}){return(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:A.map(a=>(0,U.jsx)(`button`,{type:`button`,title:r[a]?.label,onClick:()=>i(a),className:v(`grid size-10 place-items-center rounded-xl ring-offset-2 ring-offset-background transition-transform hover:scale-105`,t===a&&`ring-2 ring-foreground`),style:n(a),children:t===a&&(0,U.jsx)(e,{className:`size-4 text-white`,strokeWidth:3})},a))})}function G({title:e,description:t,children:n}){return(0,U.jsxs)(`div`,{className:`grid gap-6 border-b py-8 first:pt-0 last:border-0 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,U.jsx)(`div`,{className:`space-y-5`,children:n})]})}function K(e){return{title:e.title,slug:e.slug,summary:e.summary,description:e.description,categoryId:e.categoryId??``,coverColor:e.coverColor,visibility:e.visibility,enrolment:e.enrolment,enrolmentKey:e.enrolmentKey??``,startDate:g(e.startDate),endDate:g(e.endDate)}}function q(){let{course:e}=N();D(`Settings · ${e.title}`);let n=t(),r=M(),h=i(),[g,v]=(0,H.useState)(()=>K(e)),y=JSON.stringify(K(e)),b=JSON.stringify(g)!==y;C(b);let{data:E}=_({queryKey:[`categories`],queryFn:()=>T.get(`/categories`)}),A=a({mutationFn:()=>T.patch(`/courses/${e.id}`,{...g,categoryId:g.categoryId||null,enrolmentKey:g.enrolment===`key`&&g.enrolmentKey.trim()||null,startDate:g.startDate?w(`${g.startDate}T00:00`):null,endDate:g.endDate?w(`${g.endDate}T23:59`):null}),onSuccess:async t=>{k.success(`Course settings saved`),await r(e.slug),t.slug!==e.slug&&n(`/courses/${t.slug}/settings`,{replace:!0})},onError:e=>k.error(S(e))}),P=a({mutationFn:()=>T.delete(`/courses/${e.id}`),onSuccess:async()=>{k.success(`Course deleted`),await r(e.slug),n(`/my-courses`)},onError:e=>k.error(S(e))}),I=(e,t)=>v(n=>({...n,[e]:t}));return(0,U.jsxs)(c,{children:[(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),A.mutate()},children:[(0,U.jsxs)(p,{className:`p-6 sm:p-8`,children:[(0,U.jsxs)(G,{title:`General`,description:`How the course appears in the catalog and on the dashboard.`,children:[(0,U.jsx)(u,{label:`Title`,children:e=>(0,U.jsx)(m,{...e,required:!0,value:g.title,onChange:e=>I(`title`,e.target.value)})}),(0,U.jsx)(u,{label:`Short summary`,hint:`One or two sentences shown on course cards.`,children:e=>(0,U.jsx)(d,{...e,rows:2,value:g.summary,onChange:e=>I(`summary`,e.target.value)})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`URL`,hint:`${window.location.origin}/courses/${g.slug}`,children:e=>(0,U.jsx)(m,{...e,value:g.slug,onChange:e=>I(`slug`,e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`))})}),(0,U.jsx)(u,{label:`Category`,children:e=>(0,U.jsxs)(s,{...e,value:g.categoryId,onChange:e=>I(`categoryId`,e.target.value),children:[(0,U.jsx)(`option`,{value:``,children:`No category`}),E?.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,U.jsx)(u,{label:`Cover`,children:()=>(0,U.jsx)(W,{value:g.coverColor,onChange:e=>I(`coverColor`,e)})})]}),(0,U.jsx)(G,{title:`Description`,description:`The full course overview shown to people before and after they enrol.`,children:(0,U.jsx)(j,{value:g.description,onChange:e=>I(`description`,e),rows:10})}),(0,U.jsxs)(G,{title:`Availability`,description:`Drafts are only visible to teachers. Archived courses are read-only.`,children:[(0,U.jsx)(o,{value:g.visibility,onChange:e=>I(`visibility`,e),options:[{value:`draft`,label:`Draft`,description:`Hidden while you build it.`,icon:(0,U.jsx)(L,{className:`size-4`})},{value:`published`,label:`Published`,description:`Listed in the catalog.`,icon:(0,U.jsx)(z,{className:`size-4`})},{value:`archived`,label:`Archived`,description:`Read-only for students.`,icon:(0,U.jsx)(F,{className:`size-4`})}]}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`Start date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.startDate,onChange:e=>I(`startDate`,e.target.value)})}),(0,U.jsx)(u,{label:`End date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.endDate,onChange:e=>I(`endDate`,e.target.value)})})]})]}),(0,U.jsxs)(G,{title:`Enrolment`,description:`How students join the course.`,children:[(0,U.jsx)(o,{value:g.enrolment,onChange:e=>I(`enrolment`,e),options:[{value:`open`,label:`Open`,description:`Anyone can enrol themselves.`,icon:(0,U.jsx)(l,{className:`size-4`})},{value:`key`,label:`Enrolment key`,description:`Students need a secret key.`,icon:(0,U.jsx)(O,{className:`size-4`})},{value:`invite`,label:`Invite only`,description:`Teachers add students.`,icon:(0,U.jsx)(V,{className:`size-4`})}]}),g.enrolment===`key`&&(0,U.jsx)(u,{label:`Enrolment key`,hint:`Share this with your students.`,children:e=>(0,U.jsx)(m,{...e,value:g.enrolmentKey,onChange:e=>I(`enrolmentKey`,e.target.value),className:`sm:w-72`})})]})]}),(0,U.jsxs)(`div`,{className:`sticky bottom-4 z-10 mt-6 flex items-center justify-end gap-3 rounded-xl border bg-card/90 p-3 shadow-lg backdrop-blur`,children:[b&&(0,U.jsx)(`span`,{className:`mr-auto pl-2 text-sm text-muted-foreground`,children:`You have unsaved changes`}),(0,U.jsx)(x,{type:`button`,variant:`ghost`,disabled:!b,onClick:()=>v(K(e)),children:`Discard`}),(0,U.jsx)(x,{type:`submit`,loading:A.isPending,disabled:!b,children:`Save changes`})]})]}),(0,U.jsx)(p,{className:`mt-8 border-destructive/30 p-6`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`font-semibold`,children:`Delete this course`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Permanently removes the course with all activities, submissions, grades and posts.`})]}),(0,U.jsxs)(x,{variant:`destructive`,loading:P.isPending,onClick:async()=>{await h({title:`Delete “${e.title}”?`,description:`This cannot be undone. Everything in the course, including student work and grades, will be deleted.`,confirmLabel:`Delete course`,destructive:!0})&&P.mutate()},children:[(0,U.jsx)(f,{}),` Delete course`]})]})})]})}export{W as CoverPicker,q as default};
1
+ import{Ct as e,Ft as t,I as n,N as r,Q as i,Rt as a,c as o,f as s,g as c,gt as l,l as u,m as d,rt as f,t as p,u as m}from"./index-B29bTBiJ.js";import{H as h,P as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,i as C,k as w,m as T,mt as E,r as D}from"./hooks-BBARn-DA.js";import{t as O}from"./key-round-B_KI-brR.js";import{T as k}from"./misc-DvgDEI3I.js";import{r as A}from"./constants-DLDWTvvN.js";import{r as j}from"./markdown-ykrkPMbn.js";import{a as M,r as N}from"./context-BLVW7NB7.js";var P={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};P.node;var F=h(P),I={name:`file-lock`,size:24,node:[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]],aliases:[`file-lock-2`]};I.node;var L=h(I),R={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};R.node;var z=h(R),B={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};B.node;var V=h(B),H=E(b(),1),U=y();function W({value:t,onChange:i}){return(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:A.map(a=>(0,U.jsx)(`button`,{type:`button`,title:r[a]?.label,onClick:()=>i(a),className:v(`grid size-10 place-items-center rounded-xl ring-offset-2 ring-offset-background transition-transform hover:scale-105`,t===a&&`ring-2 ring-foreground`),style:n(a),children:t===a&&(0,U.jsx)(e,{className:`size-4 text-white`,strokeWidth:3})},a))})}function G({title:e,description:t,children:n}){return(0,U.jsxs)(`div`,{className:`grid gap-6 border-b py-8 first:pt-0 last:border-0 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,U.jsx)(`div`,{className:`space-y-5`,children:n})]})}function K(e){return{title:e.title,slug:e.slug,summary:e.summary,description:e.description,categoryId:e.categoryId??``,coverColor:e.coverColor,visibility:e.visibility,enrolment:e.enrolment,enrolmentKey:e.enrolmentKey??``,startDate:g(e.startDate),endDate:g(e.endDate)}}function q(){let{course:e}=N();D(`Settings · ${e.title}`);let n=t(),r=M(),h=i(),[g,v]=(0,H.useState)(()=>K(e)),y=JSON.stringify(K(e)),b=JSON.stringify(g)!==y;C(b);let{data:E}=_({queryKey:[`categories`],queryFn:()=>T.get(`/categories`)}),A=a({mutationFn:()=>T.patch(`/courses/${e.id}`,{...g,categoryId:g.categoryId||null,enrolmentKey:g.enrolment===`key`&&g.enrolmentKey.trim()||null,startDate:g.startDate?w(`${g.startDate}T00:00`):null,endDate:g.endDate?w(`${g.endDate}T23:59`):null}),onSuccess:async t=>{k.success(`Course settings saved`),await r(e.slug),t.slug!==e.slug&&n(`/courses/${t.slug}/settings`,{replace:!0})},onError:e=>k.error(S(e))}),P=a({mutationFn:()=>T.delete(`/courses/${e.id}`),onSuccess:async()=>{k.success(`Course deleted`),await r(e.slug),n(`/my-courses`)},onError:e=>k.error(S(e))}),I=(e,t)=>v(n=>({...n,[e]:t}));return(0,U.jsxs)(c,{children:[(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),A.mutate()},children:[(0,U.jsxs)(p,{className:`p-6 sm:p-8`,children:[(0,U.jsxs)(G,{title:`General`,description:`How the course appears in the catalog and on the dashboard.`,children:[(0,U.jsx)(u,{label:`Title`,children:e=>(0,U.jsx)(m,{...e,required:!0,value:g.title,onChange:e=>I(`title`,e.target.value)})}),(0,U.jsx)(u,{label:`Short summary`,hint:`One or two sentences shown on course cards.`,children:e=>(0,U.jsx)(d,{...e,rows:2,value:g.summary,onChange:e=>I(`summary`,e.target.value)})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`URL`,hint:`${window.location.origin}/courses/${g.slug}`,children:e=>(0,U.jsx)(m,{...e,value:g.slug,onChange:e=>I(`slug`,e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`))})}),(0,U.jsx)(u,{label:`Category`,children:e=>(0,U.jsxs)(s,{...e,value:g.categoryId,onChange:e=>I(`categoryId`,e.target.value),children:[(0,U.jsx)(`option`,{value:``,children:`No category`}),E?.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,U.jsx)(u,{label:`Cover`,children:()=>(0,U.jsx)(W,{value:g.coverColor,onChange:e=>I(`coverColor`,e)})})]}),(0,U.jsx)(G,{title:`Description`,description:`The full course overview shown to people before and after they enrol.`,children:(0,U.jsx)(j,{value:g.description,onChange:e=>I(`description`,e),rows:10})}),(0,U.jsxs)(G,{title:`Availability`,description:`Drafts are only visible to teachers. Archived courses are read-only.`,children:[(0,U.jsx)(o,{value:g.visibility,onChange:e=>I(`visibility`,e),options:[{value:`draft`,label:`Draft`,description:`Hidden while you build it.`,icon:(0,U.jsx)(L,{className:`size-4`})},{value:`published`,label:`Published`,description:`Listed in the catalog.`,icon:(0,U.jsx)(z,{className:`size-4`})},{value:`archived`,label:`Archived`,description:`Read-only for students.`,icon:(0,U.jsx)(F,{className:`size-4`})}]}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`Start date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.startDate,onChange:e=>I(`startDate`,e.target.value)})}),(0,U.jsx)(u,{label:`End date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.endDate,onChange:e=>I(`endDate`,e.target.value)})})]})]}),(0,U.jsxs)(G,{title:`Enrolment`,description:`How students join the course.`,children:[(0,U.jsx)(o,{value:g.enrolment,onChange:e=>I(`enrolment`,e),options:[{value:`open`,label:`Open`,description:`Anyone can enrol themselves.`,icon:(0,U.jsx)(l,{className:`size-4`})},{value:`key`,label:`Enrolment key`,description:`Students need a secret key.`,icon:(0,U.jsx)(O,{className:`size-4`})},{value:`invite`,label:`Invite only`,description:`Teachers add students.`,icon:(0,U.jsx)(V,{className:`size-4`})}]}),g.enrolment===`key`&&(0,U.jsx)(u,{label:`Enrolment key`,hint:`Share this with your students.`,children:e=>(0,U.jsx)(m,{...e,value:g.enrolmentKey,onChange:e=>I(`enrolmentKey`,e.target.value),className:`sm:w-72`})})]})]}),(0,U.jsxs)(`div`,{className:`sticky bottom-4 z-10 mt-6 flex items-center justify-end gap-3 rounded-xl border bg-card/90 p-3 shadow-lg backdrop-blur`,children:[b&&(0,U.jsx)(`span`,{className:`mr-auto pl-2 text-sm text-muted-foreground`,children:`You have unsaved changes`}),(0,U.jsx)(x,{type:`button`,variant:`ghost`,disabled:!b,onClick:()=>v(K(e)),children:`Discard`}),(0,U.jsx)(x,{type:`submit`,loading:A.isPending,disabled:!b,children:`Save changes`})]})]}),(0,U.jsx)(p,{className:`mt-8 border-destructive/30 p-6`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`font-semibold`,children:`Delete this course`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Permanently removes the course with all activities, submissions, grades and posts.`})]}),(0,U.jsxs)(x,{variant:`destructive`,loading:P.isPending,onClick:async()=>{await h({title:`Delete “${e.title}”?`,description:`This cannot be undone. Everything in the course, including student work and grades, will be deleted.`,confirmLabel:`Delete course`,destructive:!0})&&P.mutate()},children:[(0,U.jsx)(f,{}),` Delete course`]})]})})]})}export{W as CoverPicker,q as default};
@@ -1 +1 @@
1
- import{Ft as e,Nt as t,Ot as n,Rt as r,a as i,et as a,f as o,g as s,l as c,m as l,t as u,u as d,x as f}from"./index-DkBZ18Ts.js";import{U as p,dt as m,f as h,ft as g,g as _,h as v,m as y,mt as b,r as x,s as S,ut as C}from"./hooks-BBARn-DA.js";import{T as w}from"./misc-DvgDEI3I.js";import{CoverPicker as T}from"./CourseSettingsPage-DwEIXO2s.js";var E=b(g(),1),D=m();function O(){x(`New course`);let m=S(),g=e(),b=C(),[O,k]=(0,E.useState)({title:``,summary:``,categoryId:``,coverColor:`indigo`}),{data:A}=p({queryKey:[`categories`],queryFn:()=>y.get(`/categories`)}),j=r({mutationFn:()=>y.post(`/courses`,{...O,categoryId:O.categoryId||null}),onSuccess:async e=>{await b.invalidateQueries({queryKey:[`courses`]}),w.success(`Course created as a draft. Add your first activities!`),g(`/courses/${e.slug}`)},onError:e=>w.error(v(e))});return h(m?.role)?(0,D.jsxs)(s,{size:`narrow`,children:[(0,D.jsx)(i,{title:`Create a course`,description:`Start with the basics. You can change everything later in course settings.`}),(0,D.jsxs)(`div`,{className:`grid gap-6`,children:[(0,D.jsxs)(u,{className:`overflow-hidden`,children:[(0,D.jsx)(f,{color:O.coverColor,title:O.title||`New course`,className:`h-36`,children:(0,D.jsxs)(`div`,{className:`absolute inset-x-6 bottom-5 text-white`,children:[(0,D.jsx)(`p`,{className:`text-xs font-medium text-white/80`,children:A?.find(e=>e.id===O.categoryId)?.name??`Preview`}),(0,D.jsx)(`p`,{className:`mt-1 truncate text-2xl font-semibold tracking-tight`,children:O.title||`Your course title`})]})}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-3 text-xs text-muted-foreground`,children:[(0,D.jsx)(a,{className:`size-3.5`}),` You'll be the teacher. The course starts as a hidden draft.`]})]}),(0,D.jsx)(u,{className:`p-6`,children:(0,D.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),j.mutate()},children:[(0,D.jsx)(c,{label:`Course title`,children:e=>(0,D.jsx)(d,{...e,autoFocus:!0,required:!0,minLength:3,value:O.title,onChange:e=>k({...O,title:e.target.value}),placeholder:`e.g. Introduction to Psychology`})}),(0,D.jsx)(c,{label:`Short summary`,optional:!0,hint:`One or two sentences for the catalog.`,children:e=>(0,D.jsx)(l,{...e,rows:2,value:O.summary,onChange:e=>k({...O,summary:e.target.value})})}),(0,D.jsx)(c,{label:`Category`,optional:!0,children:e=>(0,D.jsxs)(o,{...e,value:O.categoryId,onChange:e=>k({...O,categoryId:e.target.value}),children:[(0,D.jsx)(`option`,{value:``,children:`No category`}),A?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(c,{label:`Cover`,children:()=>(0,D.jsx)(T,{value:O.coverColor,onChange:e=>k({...O,coverColor:e})})}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,D.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>g(-1),children:`Cancel`}),(0,D.jsxs)(_,{type:`submit`,loading:j.isPending,disabled:O.title.trim().length<3,children:[`Create course `,(0,D.jsx)(n,{})]})]})]})})]})]}):(0,D.jsx)(t,{to:`/`,replace:!0})}export{O as default};
1
+ import{Ft as e,Nt as t,Ot as n,Rt as r,a as i,et as a,f as o,g as s,l as c,m as l,t as u,u as d,x as f}from"./index-B29bTBiJ.js";import{U as p,dt as m,f as h,ft as g,g as _,h as v,m as y,mt as b,r as x,s as S,ut as C}from"./hooks-BBARn-DA.js";import{T as w}from"./misc-DvgDEI3I.js";import{CoverPicker as T}from"./CourseSettingsPage-CReoPqOa.js";var E=b(g(),1),D=m();function O(){x(`New course`);let m=S(),g=e(),b=C(),[O,k]=(0,E.useState)({title:``,summary:``,categoryId:``,coverColor:`indigo`}),{data:A}=p({queryKey:[`categories`],queryFn:()=>y.get(`/categories`)}),j=r({mutationFn:()=>y.post(`/courses`,{...O,categoryId:O.categoryId||null}),onSuccess:async e=>{await b.invalidateQueries({queryKey:[`courses`]}),w.success(`Course created as a draft. Add your first activities!`),g(`/courses/${e.slug}`)},onError:e=>w.error(v(e))});return h(m?.role)?(0,D.jsxs)(s,{size:`narrow`,children:[(0,D.jsx)(i,{title:`Create a course`,description:`Start with the basics. You can change everything later in course settings.`}),(0,D.jsxs)(`div`,{className:`grid gap-6`,children:[(0,D.jsxs)(u,{className:`overflow-hidden`,children:[(0,D.jsx)(f,{color:O.coverColor,title:O.title||`New course`,className:`h-36`,children:(0,D.jsxs)(`div`,{className:`absolute inset-x-6 bottom-5 text-white`,children:[(0,D.jsx)(`p`,{className:`text-xs font-medium text-white/80`,children:A?.find(e=>e.id===O.categoryId)?.name??`Preview`}),(0,D.jsx)(`p`,{className:`mt-1 truncate text-2xl font-semibold tracking-tight`,children:O.title||`Your course title`})]})}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-3 text-xs text-muted-foreground`,children:[(0,D.jsx)(a,{className:`size-3.5`}),` You'll be the teacher. The course starts as a hidden draft.`]})]}),(0,D.jsx)(u,{className:`p-6`,children:(0,D.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),j.mutate()},children:[(0,D.jsx)(c,{label:`Course title`,children:e=>(0,D.jsx)(d,{...e,autoFocus:!0,required:!0,minLength:3,value:O.title,onChange:e=>k({...O,title:e.target.value}),placeholder:`e.g. Introduction to Psychology`})}),(0,D.jsx)(c,{label:`Short summary`,optional:!0,hint:`One or two sentences for the catalog.`,children:e=>(0,D.jsx)(l,{...e,rows:2,value:O.summary,onChange:e=>k({...O,summary:e.target.value})})}),(0,D.jsx)(c,{label:`Category`,optional:!0,children:e=>(0,D.jsxs)(o,{...e,value:O.categoryId,onChange:e=>k({...O,categoryId:e.target.value}),children:[(0,D.jsx)(`option`,{value:``,children:`No category`}),A?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(c,{label:`Cover`,children:()=>(0,D.jsx)(T,{value:O.coverColor,onChange:e=>k({...O,coverColor:e})})}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,D.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>g(-1),children:`Cancel`}),(0,D.jsxs)(_,{type:`submit`,loading:j.isPending,disabled:O.title.trim().length<3,children:[`Create course `,(0,D.jsx)(n,{})]})]})]})})]})]}):(0,D.jsx)(t,{to:`/`,replace:!0})}export{O as default};
@@ -1 +1 @@
1
- import{At as e,B as t,F as n,Ft as r,Lt as i,Q as a,R as o,Rt as s,S as c,U as l,V as u,g as d,j as f,kt as p,q as m,rt as h,t as g,w as _}from"./index-DkBZ18Ts.js";import{D as v,H as y,T as b,U as x,_ as S,dt as C,ft as w,g as T,h as E,m as D,mt as O,p as k,r as A,u as j,ut as M}from"./hooks-BBARn-DA.js";import{t as N}from"./lock-BjbqwA_0.js";import{t as P}from"./ellipsis-c2POIN-Y.js";import{t as F}from"./pencil-p0GQmIMo.js";import{t as I}from"./pin-DlYC3uec.js";import{T as L,c as R,n as z}from"./misc-DvgDEI3I.js";import{n as B,r as V}from"./markdown-C1oaAmMK.js";import H from"./NotFoundPage-CJIpDg1F.js";var U={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};U.node;var W=y(U),G={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};G.node;var K=y(G),q={name:`reply`,size:24,node:[[`path`,{d:`M20 18v-2a4 4 0 0 0-4-4H4`,key:`5vmcpk`}],[`path`,{d:`m9 17-5-5 5-5`,key:`nvlc11`}]]};q.node;var J=y(q),Y=O(w(),1),X=C();function Z({onSubmit:e,onCancel:t,initial:n=``,submitLabel:r=`Reply`,autoFocus:i}){let[a,o]=(0,Y.useState)(n),[s,c]=(0,Y.useState)(!1);return(0,X.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{t.preventDefault(),c(!0);try{await e(a),o(``)}finally{c(!1)}},children:[(0,X.jsx)(V,{value:a,onChange:o,rows:4,autoFocus:i,placeholder:`Write a reply…`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t&&(0,X.jsx)(T,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,X.jsx)(T,{type:`submit`,size:`sm`,loading:s,disabled:!a.trim(),children:r})]})]})}function Q({post:e,childrenOf:n,depth:r,discussion:i,onReply:a,onEdit:s,onDelete:l}){let[d,p]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),y=n.get(e.id)??[],x=e.authorRole===`teacher`||e.authorRole===`assistant`;return(0,X.jsxs)(`div`,{className:S(r>0&&`border-l-2 border-border pl-4 sm:pl-6`),children:[(0,X.jsxs)(`div`,{className:`py-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(f,{user:e.author,size:`sm`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium`,children:[e.author.name,x&&(0,X.jsx)(c,{variant:`violet`,children:j[e.authorRole]})]}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:b(e.createdAt),children:[v(e.createdAt),e.updatedAt!==e.createdAt&&` · edited`]})]}),(e.canEdit||e.canDelete)&&(0,X.jsxs)(o,{children:[(0,X.jsx)(m,{asChild:!0,children:(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Post actions`,children:(0,X.jsx)(P,{})})}),(0,X.jsxs)(t,{children:[e.canEdit&&(0,X.jsxs)(u,{onSelect:()=>_(!0),children:[(0,X.jsx)(F,{}),` Edit`]}),e.canDelete&&(0,X.jsxs)(u,{destructive:!0,onSelect:()=>l(e),children:[(0,X.jsx)(h,{}),` Delete`]})]})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 pl-11`,children:[g?(0,X.jsx)(Z,{initial:e.body,submitLabel:`Save`,autoFocus:!0,onCancel:()=>_(!1),onSubmit:async t=>{await s(e.id,t),_(!1)}}):(0,X.jsx)(B,{source:e.body,className:`prose-sm`}),i.canReply&&!g&&(0,X.jsxs)(`button`,{onClick:()=>p(!d),className:`mt-2 flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-primary`,children:[(0,X.jsx)(J,{className:`size-3.5`}),` Reply`]}),d&&(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Z,{autoFocus:!0,onCancel:()=>p(!1),onSubmit:async t=>{await a(e.id,t),p(!1)}})})]})]}),y.length>0&&(0,X.jsx)(`div`,{className:S(r>=3?``:`ml-4 sm:ml-5`),children:y.map(e=>(0,X.jsx)(Q,{post:e,childrenOf:n,depth:Math.min(r+1,4),discussion:i,onReply:a,onEdit:s,onDelete:l},e.id))})]})}function $(){let{slug:f,discussionId:v}=i(),y=M(),b=r(),S=a(),C=[`discussion`,v],{data:w,isLoading:O,error:j,refetch:P}=x({queryKey:C,queryFn:()=>D.get(`/discussions/${v}`)});A(w?.title);let F=()=>Promise.all([y.invalidateQueries({queryKey:C}),y.invalidateQueries({queryKey:[`discussions`]})]),B=(e,t)=>D.post(`/discussions/${v}/posts`,{body:t,parentId:e}).then(F).catch(e=>{throw L.error(E(e)),e}),V=(e,t)=>D.patch(`/posts/${e}`,{body:t}).then(F).catch(e=>{throw L.error(E(e)),e}),U=s({mutationFn:e=>D.patch(`/discussions/${v}`,e),onSuccess:F,onError:e=>L.error(E(e))});if(O)return(0,X.jsxs)(d,{size:`narrow`,children:[(0,X.jsx)(R,{className:`mb-4 h-10 w-2/3`}),(0,X.jsx)(R,{className:`h-64`})]});if(j instanceof k&&j.status===404)return(0,X.jsx)(H,{});if(j||!w)return(0,X.jsx)(d,{children:(0,X.jsx)(z,{error:j,onRetry:()=>P()})});let G=w.posts.find(e=>e.parentId===null),q=new Map;for(let e of w.posts)e.parentId&&q.set(e.parentId,[...q.get(e.parentId)??[],e]);let J=_(w.course.slug,w.activityId),Y=async e=>{let t=e.parentId===null;if(await S({title:t?`Delete this discussion?`:`Delete this post?`,description:t?`The whole discussion and every reply will be removed.`:`Replies to this post are deleted too.`,confirmLabel:`Delete`,destructive:!0}))try{await D.delete(`/posts/${e.id}`),t?(L.success(`Discussion deleted`),b(J)):await F()}catch(e){L.error(E(e))}};return(0,X.jsxs)(d,{size:`narrow`,children:[(0,X.jsxs)(e,{to:J,className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(p,{className:`size-4`}),` `,w.activityTitle]}),(0,X.jsxs)(`div`,{className:`mt-3 mb-6 flex items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`size-2 rounded-[3px]`,style:n(w.course.coverColor)}),(0,X.jsx)(e,{to:`/courses/${f}`,className:`hover:text-foreground`,children:w.course.title})]}),(0,X.jsx)(`h1`,{className:`mt-1.5 text-2xl font-semibold tracking-tight text-balance sm:text-3xl`,children:w.title}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[w.pinned&&(0,X.jsxs)(c,{variant:`warning`,children:[(0,X.jsx)(I,{}),` Pinned`]}),w.locked&&(0,X.jsxs)(c,{variant:`neutral`,children:[(0,X.jsx)(N,{}),` Locked: no new replies`]}),(0,X.jsxs)(c,{variant:`neutral`,children:[w.replyCount,` `,w.replyCount===1?`reply`:`replies`]})]})]}),w.canModerate&&(0,X.jsxs)(o,{children:[(0,X.jsx)(m,{asChild:!0,children:(0,X.jsx)(T,{variant:`outline`,size:`sm`,children:`Moderate`})}),(0,X.jsxs)(t,{children:[(0,X.jsxs)(u,{onSelect:()=>U.mutate({pinned:!w.pinned}),children:[w.pinned?(0,X.jsx)(K,{}):(0,X.jsx)(I,{}),` `,w.pinned?`Unpin`:`Pin to top`]}),(0,X.jsxs)(u,{onSelect:()=>U.mutate({locked:!w.locked}),children:[w.locked?(0,X.jsx)(W,{}):(0,X.jsx)(N,{}),` `,w.locked?`Unlock`:`Lock replies`]}),G&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{}),(0,X.jsxs)(u,{destructive:!0,onSelect:()=>Y(G),children:[(0,X.jsx)(h,{}),` Delete discussion`]})]})]})]})]}),(0,X.jsx)(g,{className:`px-5 sm:px-6`,children:G&&(0,X.jsx)(`div`,{className:`divide-y`,children:(0,X.jsx)(Q,{post:G,childrenOf:new Map,depth:0,discussion:{...w,canReply:!1},onReply:(e,t)=>B(e,t),onEdit:V,onDelete:Y})})}),(0,X.jsxs)(`div`,{className:`mt-6`,children:[(0,X.jsxs)(`h2`,{className:`mb-2 text-sm font-semibold text-muted-foreground`,children:[w.replyCount,` `,w.replyCount===1?`reply`:`replies`]}),G&&(q.get(G.id)??[]).length>0&&(0,X.jsx)(g,{className:`divide-y px-5 sm:px-6`,children:(q.get(G.id)??[]).map(e=>(0,X.jsx)(Q,{post:e,childrenOf:q,depth:0,discussion:w,onReply:(e,t)=>B(e,t),onEdit:V,onDelete:Y},e.id))})]}),w.canReply?(0,X.jsxs)(g,{className:`mt-6 p-5`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-sm font-semibold`,children:`Join the discussion`}),(0,X.jsx)(Z,{onSubmit:e=>B(null,e),submitLabel:`Post reply`})]}):w.locked&&(0,X.jsx)(`p`,{className:`mt-6 rounded-lg bg-muted px-4 py-3 text-center text-sm text-muted-foreground`,children:`This discussion is locked.`})]})}export{$ as default};
1
+ import{At as e,B as t,F as n,Ft as r,Lt as i,Q as a,R as o,Rt as s,S as c,U as l,V as u,g as d,j as f,kt as p,q as m,rt as h,t as g,w as _}from"./index-B29bTBiJ.js";import{D as v,H as y,T as b,U as x,_ as S,dt as C,ft as w,g as T,h as E,m as D,mt as O,p as k,r as A,u as j,ut as M}from"./hooks-BBARn-DA.js";import{t as N}from"./lock-BjbqwA_0.js";import{t as P}from"./ellipsis-c2POIN-Y.js";import{t as F}from"./pencil-p0GQmIMo.js";import{t as I}from"./pin-DlYC3uec.js";import{T as L,c as R,n as z}from"./misc-DvgDEI3I.js";import{n as B,r as V}from"./markdown-ykrkPMbn.js";import H from"./NotFoundPage-BRquC7-l.js";var U={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};U.node;var W=y(U),G={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};G.node;var K=y(G),q={name:`reply`,size:24,node:[[`path`,{d:`M20 18v-2a4 4 0 0 0-4-4H4`,key:`5vmcpk`}],[`path`,{d:`m9 17-5-5 5-5`,key:`nvlc11`}]]};q.node;var J=y(q),Y=O(w(),1),X=C();function Z({onSubmit:e,onCancel:t,initial:n=``,submitLabel:r=`Reply`,autoFocus:i}){let[a,o]=(0,Y.useState)(n),[s,c]=(0,Y.useState)(!1);return(0,X.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{t.preventDefault(),c(!0);try{await e(a),o(``)}finally{c(!1)}},children:[(0,X.jsx)(V,{value:a,onChange:o,rows:4,autoFocus:i,placeholder:`Write a reply…`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t&&(0,X.jsx)(T,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,X.jsx)(T,{type:`submit`,size:`sm`,loading:s,disabled:!a.trim(),children:r})]})]})}function Q({post:e,childrenOf:n,depth:r,discussion:i,onReply:a,onEdit:s,onDelete:l}){let[d,p]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),y=n.get(e.id)??[],x=e.authorRole===`teacher`||e.authorRole===`assistant`;return(0,X.jsxs)(`div`,{className:S(r>0&&`border-l-2 border-border pl-4 sm:pl-6`),children:[(0,X.jsxs)(`div`,{className:`py-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(f,{user:e.author,size:`sm`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium`,children:[e.author.name,x&&(0,X.jsx)(c,{variant:`violet`,children:j[e.authorRole]})]}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:b(e.createdAt),children:[v(e.createdAt),e.updatedAt!==e.createdAt&&` · edited`]})]}),(e.canEdit||e.canDelete)&&(0,X.jsxs)(o,{children:[(0,X.jsx)(m,{asChild:!0,children:(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Post actions`,children:(0,X.jsx)(P,{})})}),(0,X.jsxs)(t,{children:[e.canEdit&&(0,X.jsxs)(u,{onSelect:()=>_(!0),children:[(0,X.jsx)(F,{}),` Edit`]}),e.canDelete&&(0,X.jsxs)(u,{destructive:!0,onSelect:()=>l(e),children:[(0,X.jsx)(h,{}),` Delete`]})]})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 pl-11`,children:[g?(0,X.jsx)(Z,{initial:e.body,submitLabel:`Save`,autoFocus:!0,onCancel:()=>_(!1),onSubmit:async t=>{await s(e.id,t),_(!1)}}):(0,X.jsx)(B,{source:e.body,className:`prose-sm`}),i.canReply&&!g&&(0,X.jsxs)(`button`,{onClick:()=>p(!d),className:`mt-2 flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-primary`,children:[(0,X.jsx)(J,{className:`size-3.5`}),` Reply`]}),d&&(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Z,{autoFocus:!0,onCancel:()=>p(!1),onSubmit:async t=>{await a(e.id,t),p(!1)}})})]})]}),y.length>0&&(0,X.jsx)(`div`,{className:S(r>=3?``:`ml-4 sm:ml-5`),children:y.map(e=>(0,X.jsx)(Q,{post:e,childrenOf:n,depth:Math.min(r+1,4),discussion:i,onReply:a,onEdit:s,onDelete:l},e.id))})]})}function $(){let{slug:f,discussionId:v}=i(),y=M(),b=r(),S=a(),C=[`discussion`,v],{data:w,isLoading:O,error:j,refetch:P}=x({queryKey:C,queryFn:()=>D.get(`/discussions/${v}`)});A(w?.title);let F=()=>Promise.all([y.invalidateQueries({queryKey:C}),y.invalidateQueries({queryKey:[`discussions`]})]),B=(e,t)=>D.post(`/discussions/${v}/posts`,{body:t,parentId:e}).then(F).catch(e=>{throw L.error(E(e)),e}),V=(e,t)=>D.patch(`/posts/${e}`,{body:t}).then(F).catch(e=>{throw L.error(E(e)),e}),U=s({mutationFn:e=>D.patch(`/discussions/${v}`,e),onSuccess:F,onError:e=>L.error(E(e))});if(O)return(0,X.jsxs)(d,{size:`narrow`,children:[(0,X.jsx)(R,{className:`mb-4 h-10 w-2/3`}),(0,X.jsx)(R,{className:`h-64`})]});if(j instanceof k&&j.status===404)return(0,X.jsx)(H,{});if(j||!w)return(0,X.jsx)(d,{children:(0,X.jsx)(z,{error:j,onRetry:()=>P()})});let G=w.posts.find(e=>e.parentId===null),q=new Map;for(let e of w.posts)e.parentId&&q.set(e.parentId,[...q.get(e.parentId)??[],e]);let J=_(w.course.slug,w.activityId),Y=async e=>{let t=e.parentId===null;if(await S({title:t?`Delete this discussion?`:`Delete this post?`,description:t?`The whole discussion and every reply will be removed.`:`Replies to this post are deleted too.`,confirmLabel:`Delete`,destructive:!0}))try{await D.delete(`/posts/${e.id}`),t?(L.success(`Discussion deleted`),b(J)):await F()}catch(e){L.error(E(e))}};return(0,X.jsxs)(d,{size:`narrow`,children:[(0,X.jsxs)(e,{to:J,className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(p,{className:`size-4`}),` `,w.activityTitle]}),(0,X.jsxs)(`div`,{className:`mt-3 mb-6 flex items-start gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`size-2 rounded-[3px]`,style:n(w.course.coverColor)}),(0,X.jsx)(e,{to:`/courses/${f}`,className:`hover:text-foreground`,children:w.course.title})]}),(0,X.jsx)(`h1`,{className:`mt-1.5 text-2xl font-semibold tracking-tight text-balance sm:text-3xl`,children:w.title}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[w.pinned&&(0,X.jsxs)(c,{variant:`warning`,children:[(0,X.jsx)(I,{}),` Pinned`]}),w.locked&&(0,X.jsxs)(c,{variant:`neutral`,children:[(0,X.jsx)(N,{}),` Locked: no new replies`]}),(0,X.jsxs)(c,{variant:`neutral`,children:[w.replyCount,` `,w.replyCount===1?`reply`:`replies`]})]})]}),w.canModerate&&(0,X.jsxs)(o,{children:[(0,X.jsx)(m,{asChild:!0,children:(0,X.jsx)(T,{variant:`outline`,size:`sm`,children:`Moderate`})}),(0,X.jsxs)(t,{children:[(0,X.jsxs)(u,{onSelect:()=>U.mutate({pinned:!w.pinned}),children:[w.pinned?(0,X.jsx)(K,{}):(0,X.jsx)(I,{}),` `,w.pinned?`Unpin`:`Pin to top`]}),(0,X.jsxs)(u,{onSelect:()=>U.mutate({locked:!w.locked}),children:[w.locked?(0,X.jsx)(W,{}):(0,X.jsx)(N,{}),` `,w.locked?`Unlock`:`Lock replies`]}),G&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{}),(0,X.jsxs)(u,{destructive:!0,onSelect:()=>Y(G),children:[(0,X.jsx)(h,{}),` Delete discussion`]})]})]})]})]}),(0,X.jsx)(g,{className:`px-5 sm:px-6`,children:G&&(0,X.jsx)(`div`,{className:`divide-y`,children:(0,X.jsx)(Q,{post:G,childrenOf:new Map,depth:0,discussion:{...w,canReply:!1},onReply:(e,t)=>B(e,t),onEdit:V,onDelete:Y})})}),(0,X.jsxs)(`div`,{className:`mt-6`,children:[(0,X.jsxs)(`h2`,{className:`mb-2 text-sm font-semibold text-muted-foreground`,children:[w.replyCount,` `,w.replyCount===1?`reply`:`replies`]}),G&&(q.get(G.id)??[]).length>0&&(0,X.jsx)(g,{className:`divide-y px-5 sm:px-6`,children:(q.get(G.id)??[]).map(e=>(0,X.jsx)(Q,{post:e,childrenOf:q,depth:0,discussion:w,onReply:(e,t)=>B(e,t),onEdit:V,onDelete:Y},e.id))})]}),w.canReply?(0,X.jsxs)(g,{className:`mt-6 p-5`,children:[(0,X.jsx)(`p`,{className:`mb-3 text-sm font-semibold`,children:`Join the discussion`}),(0,X.jsx)(Z,{onSubmit:e=>B(null,e),submitLabel:`Post reply`})]}):w.locked&&(0,X.jsx)(`p`,{className:`mt-6 rounded-lg bg-muted px-4 py-3 text-center text-sm text-muted-foreground`,children:`This discussion is locked.`})]})}export{$ as default};
@@ -1 +1 @@
1
- import{At as e,Dt as t,J as n,Rt as r,S as i,X as a,Y as o,at as s,g as c,j as l,l as u,m as d,t as f,u as p,v as m,w as h}from"./index-DkBZ18Ts.js";import{E as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,m as C,mt as w,r as T,ut as E,w as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./message-square-text-fe24gbEU.js";import{T as A,a as j,c as M,n as N,o as P,t as F}from"./misc-DvgDEI3I.js";import{r as I}from"./context-B5ZaAO90.js";var L=w(b(),1),R=y();function z(e){return e==null?`text-muted-foreground`:e>=85?`text-emerald-600 dark:text-emerald-400`:e>=60?`text-foreground`:`text-red-600 dark:text-red-400`}function B({courseId:e,item:t,userId:i,score:s,feedback:c,editable:l}){let f=E(),[m,h]=(0,L.useState)(!1),[_,y]=(0,L.useState)(s?.toString()??``),[b,w]=(0,L.useState)(c??``),T=r({mutationFn:()=>C.put(`/courses/${e}/grades/${t.activityId}/${i}`,{score:_===``?null:Number(_),feedback:b.trim()||null}),onSuccess:async()=>{h(!1),A.success(`Grade saved`),await f.invalidateQueries({queryKey:[`grades`,e]})},onError:e=>A.error(S(e))}),D=s!=null&&t.maxGrade?s/t.maxGrade*100:null,O=(0,R.jsxs)(`span`,{className:v(`inline-flex items-center gap-1 tabular-nums`,z(D)),children:[s==null?(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`–`}):g(s),c&&(0,R.jsx)(k,{className:`size-3 text-muted-foreground`})]});return l?(0,R.jsxs)(n,{open:m,onOpenChange:e=>{h(e),e&&(y(s?.toString()??``),w(c??``))},children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{className:`w-full rounded-md px-2 py-1 text-right transition-colors hover:bg-accent`,children:O})}),(0,R.jsx)(o,{align:`end`,className:`w-72`,children:(0,R.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),T.mutate()},children:[(0,R.jsx)(`p`,{className:`text-sm font-semibold`,children:t.title}),(0,R.jsx)(u,{label:`Score (out of ${g(t.maxGrade)})`,children:e=>(0,R.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:t.maxGrade,autoFocus:!0,value:_,onChange:e=>y(e.target.value)})}),(0,R.jsx)(u,{label:`Feedback`,optional:!0,children:e=>(0,R.jsx)(d,{...e,rows:3,value:b,onChange:e=>w(e.target.value)})}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`}),(0,R.jsx)(x,{type:`submit`,size:`sm`,loading:T.isPending,children:`Save`})]})]})})]}):O}function V({book:n,courseId:r,courseSlug:i,editable:a}){let[o,c]=(0,L.useState)(``),u=(0,L.useMemo)(()=>{let e=o.trim().toLowerCase();return n.rows.filter(t=>!e||t.user.name.toLowerCase().includes(e)||t.user.email.toLowerCase().includes(e))},[n.rows,o]);return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`No graded activities yet`,description:`Assignments and quizzes appear here as soon as you add them.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,R.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,R.jsx)(s,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(p,{value:o,onChange:e=>c(e.target.value),placeholder:`Find a student`,className:`pl-9`,"aria-label":`Find a student`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-4 sm:ml-auto`,children:[(0,R.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Class average`,` `,(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]}),(0,R.jsx)(x,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`a`,{href:`/api/courses/${r}/grades/export.csv`,download:!0,children:[(0,R.jsx)(O,{}),` Export CSV`]})})]})]}),(0,R.jsx)(f,{className:`overflow-hidden`,children:(0,R.jsx)(`div`,{className:`ck-scrollbar overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:[(0,R.jsx)(`th`,{className:`sticky left-0 z-10 min-w-56 border-b bg-card px-5 py-3 font-medium`,children:`Student`}),n.items.map(t=>(0,R.jsx)(`th`,{className:`min-w-32 border-b px-3 py-3 text-right align-bottom font-medium`,children:(0,R.jsxs)(e,{to:h(i,t.activityId),className:`group inline-flex flex-col items-end gap-1.5`,children:[(0,R.jsx)(m,{type:t.type,size:`sm`}),(0,R.jsx)(`span`,{className:`line-clamp-2 max-w-32 text-foreground group-hover:text-primary`,children:t.title}),(0,R.jsxs)(`span`,{className:`font-normal`,children:[`/ `,g(t.maxGrade)]})]})},t.activityId)),(0,R.jsx)(`th`,{className:`min-w-28 border-b bg-muted/40 px-5 py-3 text-right align-bottom font-medium text-foreground`,children:`Total`})]})}),(0,R.jsx)(`tbody`,{children:u.map(e=>(0,R.jsxs)(`tr`,{className:`group`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 border-b bg-card px-5 py-2.5 group-hover:bg-accent`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{user:e.user,size:`sm`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-medium`,children:e.user.name}),(0,R.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.user.email})]})]})}),n.items.map(t=>(0,R.jsx)(`td`,{className:`border-b px-1.5 py-2 text-right group-hover:bg-accent/40`,children:(0,R.jsx)(B,{courseId:r,item:t,userId:e.user.id,score:e.cells[t.activityId]?.score??null,feedback:e.cells[t.activityId]?.feedback??null,editable:a})},t.activityId)),(0,R.jsxs)(`td`,{className:`border-b bg-muted/40 px-5 py-2.5 text-right`,children:[(0,R.jsx)(`span`,{className:v(`font-semibold tabular-nums`,z(e.percentage)),children:e.percentage==null?`–`:`${g(e.percentage)}%`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground tabular-nums`,children:[g(e.total),` / `,g(e.max)]})]})]},e.user.id))}),(0,R.jsx)(`tfoot`,{children:(0,R.jsxs)(`tr`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 bg-muted/60 px-5 py-3 font-medium text-foreground`,children:`Average`}),n.items.map(e=>(0,R.jsx)(`td`,{className:`bg-muted/60 px-3 py-3 text-right tabular-nums`,children:g(n.averages[e.activityId])},e.activityId)),(0,R.jsx)(`td`,{className:`bg-muted/60 px-5 py-3 text-right font-semibold text-foreground tabular-nums`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]})})]})})}),a&&(0,R.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Click any grade to change it or leave feedback. Students are notified when they receive a grade.`})]})}function H({grades:n,courseSlug:r}){return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`Nothing graded yet`,description:`Grades for assignments and quizzes will show up here.`}):(0,R.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,R.jsx)(f,{className:`divide-y overflow-hidden`,children:n.items.map(t=>{let n=t.score!=null&&t.maxGrade?t.score/t.maxGrade*100:null;return(0,R.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(m,{type:t.type}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(e,{to:h(r,t.activityId),className:`truncate text-sm font-medium hover:text-primary`,children:t.title}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.gradedAt?`Graded ${D(t.gradedAt)}`:t.dueAt?`Due ${D(t.dueAt)}`:`Not graded yet`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsxs)(`p`,{className:v(`text-sm font-semibold tabular-nums`,z(n)),children:[t.score==null?`–`:g(t.score),` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`/ `,g(t.maxGrade)]})]}),n!=null&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[g(n),`%`]})]})]}),n!=null&&(0,R.jsx)(j,{value:n,className:`mt-3`,tone:n>=85?`success`:`primary`}),t.feedback&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-lg bg-muted/60 px-3.5 py-2.5 text-sm`,children:[(0,R.jsx)(`p`,{className:`mb-0.5 text-xs font-medium text-muted-foreground`,children:`Feedback`}),t.feedback]})]},t.activityId)})}),(0,R.jsxs)(f,{className:`p-5 text-center lg:sticky lg:top-32`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Course total`}),(0,R.jsx)(P,{value:n.percentage??0,size:120,stroke:9,className:`mx-auto mt-4 text-primary`,label:(0,R.jsx)(`span`,{className:`text-2xl font-semibold`,children:n.percentage==null?`–`:`${g(n.percentage)}%`})}),(0,R.jsxs)(`p`,{className:`mt-4 text-sm tabular-nums`,children:[g(n.total),` of `,g(n.max),` points`]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Based on graded work so far.`}),n.percentage!=null&&(0,R.jsx)(i,{variant:n.percentage>=85?`success`:n.percentage>=60?`info`:`warning`,className:`mt-3`,children:n.percentage>=85?`Excellent work`:n.percentage>=60?`On track`:`Needs attention`})]})]})}function U(){let{course:e,can:t}=I();T(`Grades · ${e.title}`);let{data:n,isLoading:r,error:i,refetch:a}=_({queryKey:[`grades`,e.id],queryFn:()=>C.get(`/courses/${e.id}/grades`)});return(0,R.jsx)(c,{size:`wide`,children:i?(0,R.jsx)(N,{error:i,onRetry:()=>a()}):r||!n?(0,R.jsx)(M,{className:`h-96`}):n.kind===`gradebook`?(0,R.jsx)(V,{book:n.gradebook,courseId:e.id,courseSlug:e.slug,editable:t(`grades:edit`)}):(0,R.jsx)(`div`,{className:`mx-auto max-w-5xl`,children:(0,R.jsx)(H,{grades:n.grades,courseSlug:e.slug})})})}export{U as default};
1
+ import{At as e,Dt as t,J as n,Rt as r,S as i,X as a,Y as o,at as s,g as c,j as l,l as u,m as d,t as f,u as p,v as m,w as h}from"./index-B29bTBiJ.js";import{E as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,m as C,mt as w,r as T,ut as E,w as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./message-square-text-fe24gbEU.js";import{T as A,a as j,c as M,n as N,o as P,t as F}from"./misc-DvgDEI3I.js";import{r as I}from"./context-BLVW7NB7.js";var L=w(b(),1),R=y();function z(e){return e==null?`text-muted-foreground`:e>=85?`text-emerald-600 dark:text-emerald-400`:e>=60?`text-foreground`:`text-red-600 dark:text-red-400`}function B({courseId:e,item:t,userId:i,score:s,feedback:c,editable:l}){let f=E(),[m,h]=(0,L.useState)(!1),[_,y]=(0,L.useState)(s?.toString()??``),[b,w]=(0,L.useState)(c??``),T=r({mutationFn:()=>C.put(`/courses/${e}/grades/${t.activityId}/${i}`,{score:_===``?null:Number(_),feedback:b.trim()||null}),onSuccess:async()=>{h(!1),A.success(`Grade saved`),await f.invalidateQueries({queryKey:[`grades`,e]})},onError:e=>A.error(S(e))}),D=s!=null&&t.maxGrade?s/t.maxGrade*100:null,O=(0,R.jsxs)(`span`,{className:v(`inline-flex items-center gap-1 tabular-nums`,z(D)),children:[s==null?(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`–`}):g(s),c&&(0,R.jsx)(k,{className:`size-3 text-muted-foreground`})]});return l?(0,R.jsxs)(n,{open:m,onOpenChange:e=>{h(e),e&&(y(s?.toString()??``),w(c??``))},children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{className:`w-full rounded-md px-2 py-1 text-right transition-colors hover:bg-accent`,children:O})}),(0,R.jsx)(o,{align:`end`,className:`w-72`,children:(0,R.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),T.mutate()},children:[(0,R.jsx)(`p`,{className:`text-sm font-semibold`,children:t.title}),(0,R.jsx)(u,{label:`Score (out of ${g(t.maxGrade)})`,children:e=>(0,R.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:t.maxGrade,autoFocus:!0,value:_,onChange:e=>y(e.target.value)})}),(0,R.jsx)(u,{label:`Feedback`,optional:!0,children:e=>(0,R.jsx)(d,{...e,rows:3,value:b,onChange:e=>w(e.target.value)})}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`}),(0,R.jsx)(x,{type:`submit`,size:`sm`,loading:T.isPending,children:`Save`})]})]})})]}):O}function V({book:n,courseId:r,courseSlug:i,editable:a}){let[o,c]=(0,L.useState)(``),u=(0,L.useMemo)(()=>{let e=o.trim().toLowerCase();return n.rows.filter(t=>!e||t.user.name.toLowerCase().includes(e)||t.user.email.toLowerCase().includes(e))},[n.rows,o]);return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`No graded activities yet`,description:`Assignments and quizzes appear here as soon as you add them.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,R.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,R.jsx)(s,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(p,{value:o,onChange:e=>c(e.target.value),placeholder:`Find a student`,className:`pl-9`,"aria-label":`Find a student`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-4 sm:ml-auto`,children:[(0,R.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Class average`,` `,(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]}),(0,R.jsx)(x,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`a`,{href:`/api/courses/${r}/grades/export.csv`,download:!0,children:[(0,R.jsx)(O,{}),` Export CSV`]})})]})]}),(0,R.jsx)(f,{className:`overflow-hidden`,children:(0,R.jsx)(`div`,{className:`ck-scrollbar overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:[(0,R.jsx)(`th`,{className:`sticky left-0 z-10 min-w-56 border-b bg-card px-5 py-3 font-medium`,children:`Student`}),n.items.map(t=>(0,R.jsx)(`th`,{className:`min-w-32 border-b px-3 py-3 text-right align-bottom font-medium`,children:(0,R.jsxs)(e,{to:h(i,t.activityId),className:`group inline-flex flex-col items-end gap-1.5`,children:[(0,R.jsx)(m,{type:t.type,size:`sm`}),(0,R.jsx)(`span`,{className:`line-clamp-2 max-w-32 text-foreground group-hover:text-primary`,children:t.title}),(0,R.jsxs)(`span`,{className:`font-normal`,children:[`/ `,g(t.maxGrade)]})]})},t.activityId)),(0,R.jsx)(`th`,{className:`min-w-28 border-b bg-muted/40 px-5 py-3 text-right align-bottom font-medium text-foreground`,children:`Total`})]})}),(0,R.jsx)(`tbody`,{children:u.map(e=>(0,R.jsxs)(`tr`,{className:`group`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 border-b bg-card px-5 py-2.5 group-hover:bg-accent`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{user:e.user,size:`sm`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-medium`,children:e.user.name}),(0,R.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.user.email})]})]})}),n.items.map(t=>(0,R.jsx)(`td`,{className:`border-b px-1.5 py-2 text-right group-hover:bg-accent/40`,children:(0,R.jsx)(B,{courseId:r,item:t,userId:e.user.id,score:e.cells[t.activityId]?.score??null,feedback:e.cells[t.activityId]?.feedback??null,editable:a})},t.activityId)),(0,R.jsxs)(`td`,{className:`border-b bg-muted/40 px-5 py-2.5 text-right`,children:[(0,R.jsx)(`span`,{className:v(`font-semibold tabular-nums`,z(e.percentage)),children:e.percentage==null?`–`:`${g(e.percentage)}%`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground tabular-nums`,children:[g(e.total),` / `,g(e.max)]})]})]},e.user.id))}),(0,R.jsx)(`tfoot`,{children:(0,R.jsxs)(`tr`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 bg-muted/60 px-5 py-3 font-medium text-foreground`,children:`Average`}),n.items.map(e=>(0,R.jsx)(`td`,{className:`bg-muted/60 px-3 py-3 text-right tabular-nums`,children:g(n.averages[e.activityId])},e.activityId)),(0,R.jsx)(`td`,{className:`bg-muted/60 px-5 py-3 text-right font-semibold text-foreground tabular-nums`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]})})]})})}),a&&(0,R.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Click any grade to change it or leave feedback. Students are notified when they receive a grade.`})]})}function H({grades:n,courseSlug:r}){return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`Nothing graded yet`,description:`Grades for assignments and quizzes will show up here.`}):(0,R.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,R.jsx)(f,{className:`divide-y overflow-hidden`,children:n.items.map(t=>{let n=t.score!=null&&t.maxGrade?t.score/t.maxGrade*100:null;return(0,R.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(m,{type:t.type}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(e,{to:h(r,t.activityId),className:`truncate text-sm font-medium hover:text-primary`,children:t.title}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.gradedAt?`Graded ${D(t.gradedAt)}`:t.dueAt?`Due ${D(t.dueAt)}`:`Not graded yet`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsxs)(`p`,{className:v(`text-sm font-semibold tabular-nums`,z(n)),children:[t.score==null?`–`:g(t.score),` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`/ `,g(t.maxGrade)]})]}),n!=null&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[g(n),`%`]})]})]}),n!=null&&(0,R.jsx)(j,{value:n,className:`mt-3`,tone:n>=85?`success`:`primary`}),t.feedback&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-lg bg-muted/60 px-3.5 py-2.5 text-sm`,children:[(0,R.jsx)(`p`,{className:`mb-0.5 text-xs font-medium text-muted-foreground`,children:`Feedback`}),t.feedback]})]},t.activityId)})}),(0,R.jsxs)(f,{className:`p-5 text-center lg:sticky lg:top-32`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Course total`}),(0,R.jsx)(P,{value:n.percentage??0,size:120,stroke:9,className:`mx-auto mt-4 text-primary`,label:(0,R.jsx)(`span`,{className:`text-2xl font-semibold`,children:n.percentage==null?`–`:`${g(n.percentage)}%`})}),(0,R.jsxs)(`p`,{className:`mt-4 text-sm tabular-nums`,children:[g(n.total),` of `,g(n.max),` points`]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Based on graded work so far.`}),n.percentage!=null&&(0,R.jsx)(i,{variant:n.percentage>=85?`success`:n.percentage>=60?`info`:`warning`,className:`mt-3`,children:n.percentage>=85?`Excellent work`:n.percentage>=60?`On track`:`Needs attention`})]})]})}function U(){let{course:e,can:t}=I();T(`Grades · ${e.title}`);let{data:n,isLoading:r,error:i,refetch:a}=_({queryKey:[`grades`,e.id],queryFn:()=>C.get(`/courses/${e.id}/grades`)});return(0,R.jsx)(c,{size:`wide`,children:i?(0,R.jsx)(N,{error:i,onRetry:()=>a()}):r||!n?(0,R.jsx)(M,{className:`h-96`}):n.kind===`gradebook`?(0,R.jsx)(V,{book:n.gradebook,courseId:e.id,courseSlug:e.slug,editable:t(`grades:edit`)}):(0,R.jsx)(`div`,{className:`mx-auto max-w-5xl`,children:(0,R.jsx)(H,{grades:n.grades,courseSlug:e.slug})})})}export{U as default};
@@ -1 +1 @@
1
- import{U as e,dt as t,ft as n,g as r,m as i,mt as a,r as o}from"./hooks-BBARn-DA.js";import{At as s,Et as c,a as l,b as u,g as d,vt as f,y as p}from"./index-DkBZ18Ts.js";import{n as m,s as h,t as g}from"./misc-DvgDEI3I.js";var _=a(n(),1),v=t();function y(){o(`My courses`);let[t,n]=(0,_.useState)(`all`),{data:a,isLoading:y,error:b,refetch:x}=e({queryKey:[`courses`,`mine`],queryFn:()=>i.get(`/courses/mine`)}),S=a??[],C={all:S.length,progress:S.filter(e=>e.myRole===`student`&&(e.progress??0)<100).length,completed:S.filter(e=>e.myRole===`student`&&e.progress===100).length,teaching:S.filter(e=>e.myRole===`teacher`||e.myRole===`assistant`).length},w=S.filter(e=>t===`progress`?e.myRole===`student`&&(e.progress??0)<100:t===`completed`?e.myRole===`student`&&e.progress===100:t!==`teaching`||e.myRole===`teacher`||e.myRole===`assistant`);return(0,v.jsxs)(d,{children:[(0,v.jsx)(l,{title:`My courses`,description:`Everything you're learning and teaching, most recently visited first.`}),(0,v.jsx)(h,{value:t,onChange:n,className:`mb-6`,options:[{value:`all`,label:`All`,count:C.all},{value:`progress`,label:`In progress`,count:C.progress},{value:`completed`,label:`Completed`,count:C.completed},...C.teaching?[{value:`teaching`,label:`Teaching`,count:C.teaching}]:[]]}),b?(0,v.jsx)(m,{error:b,onRetry:()=>x()}):y?(0,v.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:[0,1,2].map(e=>(0,v.jsx)(u,{},e))}):w.length===0?(0,v.jsx)(g,{icon:t===`completed`?c:f,title:t===`completed`?`No completed courses yet`:`No courses here`,description:t===`completed`?`Finish every activity in a course to see it here.`:`Find a course in the catalog to get started.`,action:(0,v.jsx)(r,{asChild:!0,variant:`outline`,children:(0,v.jsx)(s,{to:`/catalog`,children:`Explore courses`})})}):(0,v.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,v.jsx)(p,{course:e},e.id))})]})}export{y as default};
1
+ import{U as e,dt as t,ft as n,g as r,m as i,mt as a,r as o}from"./hooks-BBARn-DA.js";import{At as s,Et as c,a as l,b as u,g as d,vt as f,y as p}from"./index-B29bTBiJ.js";import{n as m,s as h,t as g}from"./misc-DvgDEI3I.js";var _=a(n(),1),v=t();function y(){o(`My courses`);let[t,n]=(0,_.useState)(`all`),{data:a,isLoading:y,error:b,refetch:x}=e({queryKey:[`courses`,`mine`],queryFn:()=>i.get(`/courses/mine`)}),S=a??[],C={all:S.length,progress:S.filter(e=>e.myRole===`student`&&(e.progress??0)<100).length,completed:S.filter(e=>e.myRole===`student`&&e.progress===100).length,teaching:S.filter(e=>e.myRole===`teacher`||e.myRole===`assistant`).length},w=S.filter(e=>t===`progress`?e.myRole===`student`&&(e.progress??0)<100:t===`completed`?e.myRole===`student`&&e.progress===100:t!==`teaching`||e.myRole===`teacher`||e.myRole===`assistant`);return(0,v.jsxs)(d,{children:[(0,v.jsx)(l,{title:`My courses`,description:`Everything you're learning and teaching, most recently visited first.`}),(0,v.jsx)(h,{value:t,onChange:n,className:`mb-6`,options:[{value:`all`,label:`All`,count:C.all},{value:`progress`,label:`In progress`,count:C.progress},{value:`completed`,label:`Completed`,count:C.completed},...C.teaching?[{value:`teaching`,label:`Teaching`,count:C.teaching}]:[]]}),b?(0,v.jsx)(m,{error:b,onRetry:()=>x()}):y?(0,v.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:[0,1,2].map(e=>(0,v.jsx)(u,{},e))}):w.length===0?(0,v.jsx)(g,{icon:t===`completed`?c:f,title:t===`completed`?`No completed courses yet`:`No courses here`,description:t===`completed`?`Finish every activity in a course to see it here.`:`Find a course in the catalog to get started.`,action:(0,v.jsx)(r,{asChild:!0,variant:`outline`,children:(0,v.jsx)(s,{to:`/catalog`,children:`Explore courses`})})}):(0,v.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,v.jsx)(p,{course:e},e.id))})]})}export{y as default};
@@ -1 +1 @@
1
- import{At as e,kt as t,vt as n}from"./index-DkBZ18Ts.js";import{dt as r,g as i,r as a}from"./hooks-BBARn-DA.js";var o=r();function s(){return a(`Not found`),(0,o.jsx)(`div`,{className:`ck-dots grid min-h-[70vh] place-items-center px-6 text-center`,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`p`,{className:`bg-gradient-to-br from-primary to-primary/40 bg-clip-text text-8xl font-black tracking-tighter text-transparent`,children:`404`}),(0,o.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold tracking-tight`,children:`We couldn't find that page`}),(0,o.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`It may have been moved, deleted, or you might not have access to it.`}),(0,o.jsxs)(`div`,{className:`mt-8 flex justify-center gap-3`,children:[(0,o.jsx)(i,{asChild:!0,variant:`outline`,children:(0,o.jsxs)(e,{to:`/`,children:[(0,o.jsx)(t,{}),` Dashboard`]})}),(0,o.jsx)(i,{asChild:!0,children:(0,o.jsxs)(e,{to:`/catalog`,children:[(0,o.jsx)(n,{}),` Explore courses`]})})]})]})})}export{s as default};
1
+ import{At as e,kt as t,vt as n}from"./index-B29bTBiJ.js";import{dt as r,g as i,r as a}from"./hooks-BBARn-DA.js";var o=r();function s(){return a(`Not found`),(0,o.jsx)(`div`,{className:`ck-dots grid min-h-[70vh] place-items-center px-6 text-center`,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`p`,{className:`bg-gradient-to-br from-primary to-primary/40 bg-clip-text text-8xl font-black tracking-tighter text-transparent`,children:`404`}),(0,o.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold tracking-tight`,children:`We couldn't find that page`}),(0,o.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`It may have been moved, deleted, or you might not have access to it.`}),(0,o.jsxs)(`div`,{className:`mt-8 flex justify-center gap-3`,children:[(0,o.jsx)(i,{asChild:!0,variant:`outline`,children:(0,o.jsxs)(e,{to:`/`,children:[(0,o.jsx)(t,{}),` Dashboard`]})}),(0,o.jsx)(i,{asChild:!0,children:(0,o.jsxs)(e,{to:`/catalog`,children:[(0,o.jsx)(n,{}),` Explore courses`]})})]})]})})}export{s as default};
@@ -1 +1 @@
1
- import{Ft as e,Rt as t,_ as n,a as r,g as i,h as a,t as o}from"./index-DkBZ18Ts.js";import{D as s,H as c,T as l,_ as u,dt as d,g as f,m as p,r as m,ut as h}from"./hooks-BBARn-DA.js";import{c as g,n as _,t as v}from"./misc-DvgDEI3I.js";var y={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};y.node;var b=c(y),x={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};x.node;var S=c(x),C=d();function w(){m(`Notifications`);let{data:c,isLoading:d,error:y,refetch:x}=n(),w=h(),T=e(),E=t({mutationFn:e=>p.post(`/notifications/read`,e?{ids:e}:{}),onSuccess:()=>w.invalidateQueries({queryKey:[`notifications`]})});return(0,C.jsxs)(i,{size:`narrow`,children:[(0,C.jsx)(r,{title:`Notifications`,description:`Grades, announcements and replies from your courses.`,actions:!!c?.unreadCount&&(0,C.jsxs)(f,{variant:`outline`,onClick:()=>E.mutate(void 0),loading:E.isPending,children:[(0,C.jsx)(S,{}),` Mark all as read`]})}),y?(0,C.jsx)(_,{error:y,onRetry:()=>x()}):d?(0,C.jsx)(g,{className:`h-96`}):c.items.length===0?(0,C.jsx)(v,{icon:b,title:`No notifications`,description:`You'll see updates from your courses here.`}):(0,C.jsx)(o,{className:`divide-y overflow-hidden`,children:c.items.map(e=>(0,C.jsxs)(`button`,{onClick:()=>{e.readAt||E.mutate([e.id]),e.link&&T(e.link)},className:u(`flex w-full gap-4 px-5 py-4 text-left transition-colors hover:bg-accent/40`,!e.readAt&&`bg-primary/[0.03]`),children:[(0,C.jsx)(a,{type:e.type}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:u(`block text-sm`,!e.readAt&&`font-semibold`),children:e.title}),e.body&&(0,C.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.body}),(0,C.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,title:l(e.createdAt),children:s(e.createdAt)})]}),!e.readAt&&(0,C.jsx)(`span`,{className:`mt-1.5 size-2.5 shrink-0 rounded-full bg-primary`,"aria-label":`Unread`})]},e.id))})]})}export{w as default};
1
+ import{Ft as e,Rt as t,_ as n,a as r,g as i,h as a,t as o}from"./index-B29bTBiJ.js";import{D as s,H as c,T as l,_ as u,dt as d,g as f,m as p,r as m,ut as h}from"./hooks-BBARn-DA.js";import{c as g,n as _,t as v}from"./misc-DvgDEI3I.js";var y={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};y.node;var b=c(y),x={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};x.node;var S=c(x),C=d();function w(){m(`Notifications`);let{data:c,isLoading:d,error:y,refetch:x}=n(),w=h(),T=e(),E=t({mutationFn:e=>p.post(`/notifications/read`,e?{ids:e}:{}),onSuccess:()=>w.invalidateQueries({queryKey:[`notifications`]})});return(0,C.jsxs)(i,{size:`narrow`,children:[(0,C.jsx)(r,{title:`Notifications`,description:`Grades, announcements and replies from your courses.`,actions:!!c?.unreadCount&&(0,C.jsxs)(f,{variant:`outline`,onClick:()=>E.mutate(void 0),loading:E.isPending,children:[(0,C.jsx)(S,{}),` Mark all as read`]})}),y?(0,C.jsx)(_,{error:y,onRetry:()=>x()}):d?(0,C.jsx)(g,{className:`h-96`}):c.items.length===0?(0,C.jsx)(v,{icon:b,title:`No notifications`,description:`You'll see updates from your courses here.`}):(0,C.jsx)(o,{className:`divide-y overflow-hidden`,children:c.items.map(e=>(0,C.jsxs)(`button`,{onClick:()=>{e.readAt||E.mutate([e.id]),e.link&&T(e.link)},className:u(`flex w-full gap-4 px-5 py-4 text-left transition-colors hover:bg-accent/40`,!e.readAt&&`bg-primary/[0.03]`),children:[(0,C.jsx)(a,{type:e.type}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:u(`block text-sm`,!e.readAt&&`font-semibold`),children:e.title}),e.body&&(0,C.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.body}),(0,C.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,title:l(e.createdAt),children:s(e.createdAt)})]}),!e.readAt&&(0,C.jsx)(`span`,{className:`mt-1.5 size-2.5 shrink-0 rounded-full bg-primary`,"aria-label":`Unread`})]},e.id))})]})}export{w as default};
@@ -1 +1 @@
1
- import{B as e,Ct as t,D as n,E as r,H as i,O as a,Q as o,R as s,Rt as c,S as l,T as u,U as d,V as f,at as p,et as ee,f as m,g as te,j as ne,k as h,l as g,m as _,q as re,t as v,tt as y,u as b,z as x}from"./index-DkBZ18Ts.js";import{D as S,H as C,U as ie,dt as w,ft as T,g as E,h as D,m as O,mt as k,r as ae,s as oe,u as A,ut as se}from"./hooks-BBARn-DA.js";import{t as ce}from"./ban-D3Vsxg_g.js";import{t as j}from"./ellipsis-c2POIN-Y.js";import{T as M,a as N,c as P,n as F,s as I,t as L}from"./misc-DvgDEI3I.js";import{a as R,r as z}from"./context-B5ZaAO90.js";var B={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};B.node;var V=C(B),H=k(T(),1),U=w(),W={teacher:`violet`,assistant:`info`,student:`neutral`};function le({open:e,onOpenChange:t,courseId:i,onDone:o}){let[s,l]=(0,H.useState)(``),[d,f]=(0,H.useState)(`student`),p=c({mutationFn:()=>O.post(`/courses/${i}/participants`,{emails:s.split(/[\s,;]+/).filter(Boolean),role:d}),onSuccess:e=>{e.added&&M.success(`Enrolled ${e.added} ${e.added===1?`person`:`people`}`),e.alreadyEnrolled.length&&M.info(`Already enrolled: ${e.alreadyEnrolled.join(`, `)}`),e.notFound.length&&M.warning(`No account found for: ${e.notFound.join(`, `)}`),l(``),o(),t(!1)},onError:e=>M.error(D(e))});return(0,U.jsx)(u,{open:e,onOpenChange:t,children:(0,U.jsx)(n,{children:(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p.mutate()},children:[(0,U.jsx)(h,{icon:(0,U.jsx)(y,{className:`size-5`}),title:`Enrol people`,description:`Add people who already have an account on this site.`}),(0,U.jsxs)(r,{className:`space-y-4`,children:[(0,U.jsx)(g,{label:`Email addresses`,hint:`Separate with commas, spaces or new lines.`,children:e=>(0,U.jsx)(_,{...e,rows:5,autoFocus:!0,value:s,onChange:e=>l(e.target.value),placeholder:`ada@school.edu, grace@school.edu`})}),(0,U.jsx)(g,{label:`Role`,children:e=>(0,U.jsxs)(m,{...e,value:d,onChange:e=>f(e.target.value),children:[(0,U.jsx)(`option`,{value:`student`,children:`Student`}),(0,U.jsx)(`option`,{value:`assistant`,children:`Teaching assistant`}),(0,U.jsx)(`option`,{value:`teacher`,children:`Teacher`})]})})]}),(0,U.jsxs)(a,{children:[(0,U.jsx)(E,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsx)(E,{type:`submit`,loading:p.isPending,disabled:!s.trim(),children:`Enrol`})]})]})})})}function G(){let{course:n,can:r}=z();ae(`Participants · ${n.title}`);let a=oe(),u=se(),m=R(),h=o(),g=r(`course:manageParticipants`),[_,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(`all`),[k,B]=(0,H.useState)(!1),G=[`participants`,n.id],{data:K,isLoading:ue,error:q,refetch:J}=ie({queryKey:G,queryFn:()=>O.get(`/courses/${n.id}/participants`)}),Y=()=>Promise.all([u.invalidateQueries({queryKey:G}),m(n.slug)]),X=c({mutationFn:({id:e,body:t})=>O.patch(`/courses/${n.id}/participants/${e}`,t),onSuccess:Y,onError:e=>M.error(D(e))}),de=c({mutationFn:e=>O.delete(`/courses/${n.id}/participants/${e}`),onSuccess:async()=>{await Y(),M.success(`Removed from the course`)},onError:e=>M.error(D(e))}),Z=(0,H.useMemo)(()=>{let e=_.trim().toLowerCase();return(K??[]).filter(t=>(w===`all`||t.role===w)&&(!e||t.user.name.toLowerCase().includes(e)||t.user.email?.toLowerCase().includes(e)))},[K,_,w]),Q=e=>(K??[]).filter(t=>t.role===e).length,$=!!K?.some(e=>e.user.email);return(0,U.jsxs)(te,{children:[(0,U.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,U.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,U.jsx)(p,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(b,{value:_,onChange:e=>C(e.target.value),placeholder:`Search participants`,className:`pl-9`,"aria-label":`Search participants`})]}),(0,U.jsx)(I,{value:w,onChange:T,options:[{value:`all`,label:`Everyone`,count:K?.length},{value:`teacher`,label:`Teachers`,count:Q(`teacher`)+Q(`assistant`)},{value:`student`,label:`Students`,count:Q(`student`)}]}),g&&(0,U.jsxs)(E,{className:`sm:ml-auto`,onClick:()=>B(!0),children:[(0,U.jsx)(y,{}),` Enrol people`]})]}),q?(0,U.jsx)(F,{error:q,onRetry:()=>J()}):ue?(0,U.jsx)(P,{className:`h-96`}):Z.length===0?(0,U.jsx)(L,{icon:ee,title:`No participants found`}):(0,U.jsx)(v,{className:`overflow-hidden`,children:(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{className:`border-b bg-muted/40 text-left text-xs font-medium text-muted-foreground`,children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,U.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Role`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Progress`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium whitespace-nowrap lg:table-cell`,children:`Last access`}),g&&(0,U.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,U.jsx)(`tbody`,{className:`divide-y`,children:Z.map(n=>(0,U.jsxs)(`tr`,{className:`transition-colors hover:bg-accent/30`,children:[(0,U.jsx)(`td`,{className:`px-5 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(ne,{user:n.user,size:`sm`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`p`,{className:`truncate font-medium`,children:[n.user.name,n.user.id===a?.id&&(0,U.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`(you)`})]}),n.user.email&&(0,U.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.user.email})]})]})}),(0,U.jsx)(`td`,{className:`px-3 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(l,{variant:W[n.role],children:A[n.role]}),n.status===`suspended`&&(0,U.jsx)(l,{variant:`danger`,children:`Suspended`})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:n.progress==null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`–`}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(N,{value:n.progress,className:`w-24`,tone:n.progress===100?`success`:`primary`}),(0,U.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[n.progress,`%`]})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 whitespace-nowrap text-muted-foreground lg:table-cell`,children:n.lastAccessAt?S(n.lastAccessAt):`Never`}),g&&(0,U.jsx)(`td`,{className:`px-3 py-3 text-right`,children:n.user.id!==a?.id&&(0,U.jsxs)(s,{children:[(0,U.jsx)(re,{asChild:!0,children:(0,U.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${n.user.name}`,children:(0,U.jsx)(j,{})})}),(0,U.jsxs)(e,{children:[(0,U.jsx)(i,{children:`Role`}),[`student`,`assistant`,`teacher`].map(e=>(0,U.jsx)(x,{checked:n.role===e,onSelect:()=>X.mutate({id:n.enrolmentId,body:{role:e}}),children:A[e]},e)),(0,U.jsx)(d,{}),(0,U.jsxs)(f,{onSelect:()=>X.mutate({id:n.enrolmentId,body:{status:n.status===`active`?`suspended`:`active`}}),children:[n.status===`active`?(0,U.jsx)(ce,{}):(0,U.jsx)(t,{}),n.status===`active`?`Suspend enrolment`:`Reactivate enrolment`]}),(0,U.jsxs)(f,{destructive:!0,onSelect:async()=>{await h({title:`Remove ${n.user.name}?`,description:`They lose access to the course. Their grades are kept and come back if they re-enrol.`,confirmLabel:`Remove`,destructive:!0})&&de.mutate(n.enrolmentId)},children:[(0,U.jsx)(V,{}),` Remove from course`]})]})]})})]},n.enrolmentId))})]})})}),(0,U.jsx)(le,{open:k,onOpenChange:B,courseId:n.id,onDone:Y})]})}export{G as default};
1
+ import{B as e,Ct as t,D as n,E as r,H as i,O as a,Q as o,R as s,Rt as c,S as l,T as u,U as d,V as f,at as p,et as ee,f as m,g as te,j as ne,k as h,l as g,m as _,q as re,t as v,tt as y,u as b,z as x}from"./index-B29bTBiJ.js";import{D as S,H as C,U as ie,dt as w,ft as T,g as E,h as D,m as O,mt as k,r as ae,s as oe,u as A,ut as se}from"./hooks-BBARn-DA.js";import{t as ce}from"./ban-D3Vsxg_g.js";import{t as j}from"./ellipsis-c2POIN-Y.js";import{T as M,a as N,c as P,n as F,s as I,t as L}from"./misc-DvgDEI3I.js";import{a as R,r as z}from"./context-BLVW7NB7.js";var B={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};B.node;var V=C(B),H=k(T(),1),U=w(),W={teacher:`violet`,assistant:`info`,student:`neutral`};function le({open:e,onOpenChange:t,courseId:i,onDone:o}){let[s,l]=(0,H.useState)(``),[d,f]=(0,H.useState)(`student`),p=c({mutationFn:()=>O.post(`/courses/${i}/participants`,{emails:s.split(/[\s,;]+/).filter(Boolean),role:d}),onSuccess:e=>{e.added&&M.success(`Enrolled ${e.added} ${e.added===1?`person`:`people`}`),e.alreadyEnrolled.length&&M.info(`Already enrolled: ${e.alreadyEnrolled.join(`, `)}`),e.notFound.length&&M.warning(`No account found for: ${e.notFound.join(`, `)}`),l(``),o(),t(!1)},onError:e=>M.error(D(e))});return(0,U.jsx)(u,{open:e,onOpenChange:t,children:(0,U.jsx)(n,{children:(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p.mutate()},children:[(0,U.jsx)(h,{icon:(0,U.jsx)(y,{className:`size-5`}),title:`Enrol people`,description:`Add people who already have an account on this site.`}),(0,U.jsxs)(r,{className:`space-y-4`,children:[(0,U.jsx)(g,{label:`Email addresses`,hint:`Separate with commas, spaces or new lines.`,children:e=>(0,U.jsx)(_,{...e,rows:5,autoFocus:!0,value:s,onChange:e=>l(e.target.value),placeholder:`ada@school.edu, grace@school.edu`})}),(0,U.jsx)(g,{label:`Role`,children:e=>(0,U.jsxs)(m,{...e,value:d,onChange:e=>f(e.target.value),children:[(0,U.jsx)(`option`,{value:`student`,children:`Student`}),(0,U.jsx)(`option`,{value:`assistant`,children:`Teaching assistant`}),(0,U.jsx)(`option`,{value:`teacher`,children:`Teacher`})]})})]}),(0,U.jsxs)(a,{children:[(0,U.jsx)(E,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsx)(E,{type:`submit`,loading:p.isPending,disabled:!s.trim(),children:`Enrol`})]})]})})})}function G(){let{course:n,can:r}=z();ae(`Participants · ${n.title}`);let a=oe(),u=se(),m=R(),h=o(),g=r(`course:manageParticipants`),[_,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(`all`),[k,B]=(0,H.useState)(!1),G=[`participants`,n.id],{data:K,isLoading:ue,error:q,refetch:J}=ie({queryKey:G,queryFn:()=>O.get(`/courses/${n.id}/participants`)}),Y=()=>Promise.all([u.invalidateQueries({queryKey:G}),m(n.slug)]),X=c({mutationFn:({id:e,body:t})=>O.patch(`/courses/${n.id}/participants/${e}`,t),onSuccess:Y,onError:e=>M.error(D(e))}),de=c({mutationFn:e=>O.delete(`/courses/${n.id}/participants/${e}`),onSuccess:async()=>{await Y(),M.success(`Removed from the course`)},onError:e=>M.error(D(e))}),Z=(0,H.useMemo)(()=>{let e=_.trim().toLowerCase();return(K??[]).filter(t=>(w===`all`||t.role===w)&&(!e||t.user.name.toLowerCase().includes(e)||t.user.email?.toLowerCase().includes(e)))},[K,_,w]),Q=e=>(K??[]).filter(t=>t.role===e).length,$=!!K?.some(e=>e.user.email);return(0,U.jsxs)(te,{children:[(0,U.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,U.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,U.jsx)(p,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(b,{value:_,onChange:e=>C(e.target.value),placeholder:`Search participants`,className:`pl-9`,"aria-label":`Search participants`})]}),(0,U.jsx)(I,{value:w,onChange:T,options:[{value:`all`,label:`Everyone`,count:K?.length},{value:`teacher`,label:`Teachers`,count:Q(`teacher`)+Q(`assistant`)},{value:`student`,label:`Students`,count:Q(`student`)}]}),g&&(0,U.jsxs)(E,{className:`sm:ml-auto`,onClick:()=>B(!0),children:[(0,U.jsx)(y,{}),` Enrol people`]})]}),q?(0,U.jsx)(F,{error:q,onRetry:()=>J()}):ue?(0,U.jsx)(P,{className:`h-96`}):Z.length===0?(0,U.jsx)(L,{icon:ee,title:`No participants found`}):(0,U.jsx)(v,{className:`overflow-hidden`,children:(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{className:`border-b bg-muted/40 text-left text-xs font-medium text-muted-foreground`,children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,U.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Role`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Progress`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium whitespace-nowrap lg:table-cell`,children:`Last access`}),g&&(0,U.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,U.jsx)(`tbody`,{className:`divide-y`,children:Z.map(n=>(0,U.jsxs)(`tr`,{className:`transition-colors hover:bg-accent/30`,children:[(0,U.jsx)(`td`,{className:`px-5 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(ne,{user:n.user,size:`sm`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`p`,{className:`truncate font-medium`,children:[n.user.name,n.user.id===a?.id&&(0,U.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`(you)`})]}),n.user.email&&(0,U.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.user.email})]})]})}),(0,U.jsx)(`td`,{className:`px-3 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(l,{variant:W[n.role],children:A[n.role]}),n.status===`suspended`&&(0,U.jsx)(l,{variant:`danger`,children:`Suspended`})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:n.progress==null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`–`}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(N,{value:n.progress,className:`w-24`,tone:n.progress===100?`success`:`primary`}),(0,U.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[n.progress,`%`]})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 whitespace-nowrap text-muted-foreground lg:table-cell`,children:n.lastAccessAt?S(n.lastAccessAt):`Never`}),g&&(0,U.jsx)(`td`,{className:`px-3 py-3 text-right`,children:n.user.id!==a?.id&&(0,U.jsxs)(s,{children:[(0,U.jsx)(re,{asChild:!0,children:(0,U.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${n.user.name}`,children:(0,U.jsx)(j,{})})}),(0,U.jsxs)(e,{children:[(0,U.jsx)(i,{children:`Role`}),[`student`,`assistant`,`teacher`].map(e=>(0,U.jsx)(x,{checked:n.role===e,onSelect:()=>X.mutate({id:n.enrolmentId,body:{role:e}}),children:A[e]},e)),(0,U.jsx)(d,{}),(0,U.jsxs)(f,{onSelect:()=>X.mutate({id:n.enrolmentId,body:{status:n.status===`active`?`suspended`:`active`}}),children:[n.status===`active`?(0,U.jsx)(ce,{}):(0,U.jsx)(t,{}),n.status===`active`?`Suspend enrolment`:`Reactivate enrolment`]}),(0,U.jsxs)(f,{destructive:!0,onSelect:async()=>{await h({title:`Remove ${n.user.name}?`,description:`They lose access to the course. Their grades are kept and come back if they re-enrol.`,confirmLabel:`Remove`,destructive:!0})&&de.mutate(n.enrolmentId)},children:[(0,U.jsx)(V,{}),` Remove from course`]})]})]})})]},n.enrolmentId))})]})})}),(0,U.jsx)(le,{open:k,onOpenChange:B,courseId:n.id,onDone:Y})]})}export{G as default};
@@ -1 +1 @@
1
- import{L as e,Rt as t,S as n,a as r,c as i,g as a,it as o,j as s,l as c,m as l,n as u,rt as d,st as f,t as p,u as m}from"./index-DkBZ18Ts.js";import{H as h,d as g,dt as _,ft as v,g as y,h as b,l as x,m as S,mt as C,r as w,s as T,w as E}from"./hooks-BBARn-DA.js";import{t as D}from"./key-round-B_KI-brR.js";import{T as O}from"./misc-DvgDEI3I.js";var k={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};k.node;var A=h(k),j={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};j.node;var M=h(j),N=C(v(),1),P=_();function F(){w(`Profile`);let h=T(),_=x(),{theme:v,setTheme:C}=e(),k=(0,N.useRef)(null),[j,F]=(0,N.useState)(h.name),[I,L]=(0,N.useState)(h.bio??``),[R,z]=(0,N.useState)({currentPassword:``,newPassword:``}),B=t({mutationFn:e=>S.patch(`/auth/me`,e),onSuccess:e=>{_(e),O.success(`Profile updated`)},onError:e=>O.error(b(e))}),V=t({mutationFn:()=>S.post(`/auth/me/password`,R),onSuccess:()=>{z({currentPassword:``,newPassword:``}),O.success(`Password changed. Other devices have been signed out.`)},onError:e=>O.error(b(e))}),H=async e=>{try{let t=await S.upload(e,{context:`avatar`});B.mutate({avatarUrl:t.url})}catch(e){O.error(b(e))}};return(0,P.jsxs)(a,{size:`narrow`,children:[(0,P.jsx)(r,{title:`Profile`,description:`How you appear to teachers and classmates.`}),(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(p,{children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-5 p-6 sm:flex-row sm:items-center`,children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(s,{user:h,size:`xl`}),(0,P.jsx)(`button`,{onClick:()=>k.current?.click(),className:`absolute -right-1 -bottom-1 grid size-8 place-items-center rounded-full border bg-card shadow-sm transition-colors hover:bg-accent`,"aria-label":`Change photo`,children:(0,P.jsx)(A,{className:`size-4`})}),(0,P.jsx)(`input`,{ref:k,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&H(t),e.target.value=``}})]}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold`,children:h.name}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h.email}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(n,{variant:`default`,children:g[h.role]}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Member since `,E(h.createdAt,{year:`numeric`})]})]})]}),h.avatarUrl&&(0,P.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>B.mutate({avatarUrl:null}),children:[(0,P.jsx)(d,{}),` Remove photo`]})]}),(0,P.jsxs)(`form`,{className:`space-y-4 border-t p-6`,onSubmit:e=>{e.preventDefault(),B.mutate({name:j,bio:I.trim()||null})},children:[(0,P.jsx)(c,{label:`Full name`,children:e=>(0,P.jsx)(m,{...e,required:!0,value:j,onChange:e=>F(e.target.value)})}),(0,P.jsx)(c,{label:`About you`,optional:!0,hint:`A sentence or two for your classmates.`,children:e=>(0,P.jsx)(l,{...e,rows:3,value:I,onChange:e=>L(e.target.value)})}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(y,{type:`submit`,loading:B.isPending,disabled:j===h.name&&I===(h.bio??``),children:`Save profile`})})]})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Appearance`,description:`Choose how the site looks on this device.`}),(0,P.jsx)(`div`,{className:`px-5 pb-5`,children:(0,P.jsx)(i,{value:v,onChange:C,options:[{value:`light`,label:`Light`,icon:(0,P.jsx)(o,{className:`size-4`})},{value:`dark`,label:`Dark`,icon:(0,P.jsx)(f,{className:`size-4`})},{value:`system`,label:`System`,description:`Match your device`,icon:(0,P.jsx)(M,{className:`size-4`})}]})})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Password`,description:`Changing your password signs you out on other devices.`,icon:(0,P.jsx)(D,{className:`size-4.5`})}),(0,P.jsxs)(`form`,{className:`grid gap-4 px-5 pb-5 sm:grid-cols-2`,onSubmit:e=>{e.preventDefault(),V.mutate()},children:[(0,P.jsx)(c,{label:`Current password`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`current-password`,value:R.currentPassword,onChange:e=>z({...R,currentPassword:e.target.value})})}),(0,P.jsx)(c,{label:`New password`,hint:`At least 8 characters.`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`new-password`,value:R.newPassword,onChange:e=>z({...R,newPassword:e.target.value})})}),(0,P.jsx)(`div`,{className:`flex justify-end sm:col-span-2`,children:(0,P.jsx)(y,{type:`submit`,variant:`outline`,loading:V.isPending,disabled:R.newPassword.length<8,children:`Change password`})})]})]})]})]})}export{F as default};
1
+ import{L as e,Rt as t,S as n,a as r,c as i,g as a,it as o,j as s,l as c,m as l,n as u,rt as d,st as f,t as p,u as m}from"./index-B29bTBiJ.js";import{H as h,d as g,dt as _,ft as v,g as y,h as b,l as x,m as S,mt as C,r as w,s as T,w as E}from"./hooks-BBARn-DA.js";import{t as D}from"./key-round-B_KI-brR.js";import{T as O}from"./misc-DvgDEI3I.js";var k={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};k.node;var A=h(k),j={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};j.node;var M=h(j),N=C(v(),1),P=_();function F(){w(`Profile`);let h=T(),_=x(),{theme:v,setTheme:C}=e(),k=(0,N.useRef)(null),[j,F]=(0,N.useState)(h.name),[I,L]=(0,N.useState)(h.bio??``),[R,z]=(0,N.useState)({currentPassword:``,newPassword:``}),B=t({mutationFn:e=>S.patch(`/auth/me`,e),onSuccess:e=>{_(e),O.success(`Profile updated`)},onError:e=>O.error(b(e))}),V=t({mutationFn:()=>S.post(`/auth/me/password`,R),onSuccess:()=>{z({currentPassword:``,newPassword:``}),O.success(`Password changed. Other devices have been signed out.`)},onError:e=>O.error(b(e))}),H=async e=>{try{let t=await S.upload(e,{context:`avatar`});B.mutate({avatarUrl:t.url})}catch(e){O.error(b(e))}};return(0,P.jsxs)(a,{size:`narrow`,children:[(0,P.jsx)(r,{title:`Profile`,description:`How you appear to teachers and classmates.`}),(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(p,{children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-5 p-6 sm:flex-row sm:items-center`,children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(s,{user:h,size:`xl`}),(0,P.jsx)(`button`,{onClick:()=>k.current?.click(),className:`absolute -right-1 -bottom-1 grid size-8 place-items-center rounded-full border bg-card shadow-sm transition-colors hover:bg-accent`,"aria-label":`Change photo`,children:(0,P.jsx)(A,{className:`size-4`})}),(0,P.jsx)(`input`,{ref:k,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&H(t),e.target.value=``}})]}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold`,children:h.name}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h.email}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(n,{variant:`default`,children:g[h.role]}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Member since `,E(h.createdAt,{year:`numeric`})]})]})]}),h.avatarUrl&&(0,P.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>B.mutate({avatarUrl:null}),children:[(0,P.jsx)(d,{}),` Remove photo`]})]}),(0,P.jsxs)(`form`,{className:`space-y-4 border-t p-6`,onSubmit:e=>{e.preventDefault(),B.mutate({name:j,bio:I.trim()||null})},children:[(0,P.jsx)(c,{label:`Full name`,children:e=>(0,P.jsx)(m,{...e,required:!0,value:j,onChange:e=>F(e.target.value)})}),(0,P.jsx)(c,{label:`About you`,optional:!0,hint:`A sentence or two for your classmates.`,children:e=>(0,P.jsx)(l,{...e,rows:3,value:I,onChange:e=>L(e.target.value)})}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(y,{type:`submit`,loading:B.isPending,disabled:j===h.name&&I===(h.bio??``),children:`Save profile`})})]})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Appearance`,description:`Choose how the site looks on this device.`}),(0,P.jsx)(`div`,{className:`px-5 pb-5`,children:(0,P.jsx)(i,{value:v,onChange:C,options:[{value:`light`,label:`Light`,icon:(0,P.jsx)(o,{className:`size-4`})},{value:`dark`,label:`Dark`,icon:(0,P.jsx)(f,{className:`size-4`})},{value:`system`,label:`System`,description:`Match your device`,icon:(0,P.jsx)(M,{className:`size-4`})}]})})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Password`,description:`Changing your password signs you out on other devices.`,icon:(0,P.jsx)(D,{className:`size-4.5`})}),(0,P.jsxs)(`form`,{className:`grid gap-4 px-5 pb-5 sm:grid-cols-2`,onSubmit:e=>{e.preventDefault(),V.mutate()},children:[(0,P.jsx)(c,{label:`Current password`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`current-password`,value:R.currentPassword,onChange:e=>z({...R,currentPassword:e.target.value})})}),(0,P.jsx)(c,{label:`New password`,hint:`At least 8 characters.`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`new-password`,value:R.newPassword,onChange:e=>z({...R,newPassword:e.target.value})})}),(0,P.jsx)(`div`,{className:`flex justify-end sm:col-span-2`,children:(0,P.jsx)(y,{type:`submit`,variant:`outline`,loading:V.isPending,disabled:R.newPassword.length<8,children:`Change password`})})]})]})]})]})}export{F as default};
@@ -1 +1 @@
1
- import{$ as e,At as t,Ct as n,Lt as r,Q as i,Rt as a,S as o,g as s,kt as c,t as l,u,w as d,xt as f}from"./index-DkBZ18Ts.js";import{E as p,H as m,T as h,U as g,V as ee,_,dt as v,ft as y,g as b,h as x,m as S,mt as C,n as w,p as te,r as T,ut as E}from"./hooks-BBARn-DA.js";import{n as D,t as O}from"./trophy-Cch2iF1m.js";import{t as k}from"./send-mxSHcdcD.js";import{T as A,c as j,n as ne,o as M}from"./misc-DvgDEI3I.js";import{n as N,t as P}from"./markdown-C1oaAmMK.js";import re from"./NotFoundPage-CJIpDg1F.js";import{a as ie}from"./context-B5ZaAO90.js";var F={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};F.node;var ae=m(F),I={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};I.node;var L=m(I),R={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};R.node;var z=m(R),B={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};B.node;var V=m(B),H=C(y(),1),U=v(),W={single:`Choose one answer`,multiple:`Select all that apply`,truefalse:`True or false`,short:`Type your answer`,numeric:`Enter a number`};function G(e,t){return t?e.type===`short`||e.type===`numeric`?!!t.text?.trim():!!t.optionIds?.length:!1}function K({question:t,answer:r,onChange:i,review:a,disabled:o}){if(t.type===`short`||t.type===`numeric`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(u,{value:r?.text??``,disabled:o,inputMode:t.type===`numeric`?`decimal`:`text`,onChange:e=>i({text:e.target.value}),placeholder:t.type===`numeric`?`e.g. 42`:`Your answer`,className:`h-11 max-w-md text-[15px]`,"aria-label":`Your answer`}),a&&t.acceptedAnswers&&(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Accepted answer`,t.acceptedAnswers.length>1?`s`:``,`:`,` `,(0,U.jsxs)(`span`,{className:`font-medium text-foreground`,children:[t.acceptedAnswers.join(`, `),t.type===`numeric`&&t.tolerance?` (± ${t.tolerance})`:``]})]})]});let s=t.type===`multiple`,c=new Set(r?.optionIds??[]);return(0,U.jsx)(`div`,{className:`grid gap-2`,role:s?`group`:`radiogroup`,children:t.options.map((t,r)=>{let l=c.has(t.id),u=a?t.correct:void 0;return(0,U.jsxs)(`button`,{type:`button`,disabled:o,role:s?`checkbox`:`radio`,"aria-checked":l,onClick:()=>{if(s){let e=new Set(c);l?e.delete(t.id):e.add(t.id),i({optionIds:[...e]})}else i({optionIds:[t.id]})},className:_(`flex items-center gap-3 rounded-xl border bg-card px-4 py-3 text-left text-[15px] transition-all`,!o&&`hover:border-primary/50 hover:bg-primary/[0.02]`,l&&!a&&`border-primary bg-primary/[0.05] ring-3 ring-primary/10`,a&&u&&`border-emerald-500/50 bg-emerald-500/[0.07]`,a&&l&&!u&&`border-red-500/50 bg-red-500/[0.06]`,o&&`cursor-default`),children:[(0,U.jsx)(`span`,{className:_(`grid size-6 shrink-0 place-items-center border text-xs font-semibold text-muted-foreground`,s?`rounded-md`:`rounded-full`,l&&`border-primary bg-primary text-primary-foreground`,a&&u&&`border-emerald-600 bg-emerald-600 text-white`,a&&l&&!u&&`border-red-500 bg-red-500 text-white`),children:a&&u?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):a&&l?(0,U.jsx)(e,{className:`size-3.5`,strokeWidth:3}):l&&s?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):String.fromCharCode(65+r)}),(0,U.jsx)(P,{source:t.text,className:`flex-1`}),a&&l&&(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Your answer`})]},t.id)})})}function q({deadline:e,onExpire:t}){let n=w(1e3),r=Math.max(0,new Date(e).getTime()-n),i=(0,H.useRef)(!1);(0,H.useEffect)(()=>{r===0&&!i.current&&(i.current=!0,t())},[r,t]);let a=Math.floor(r/6e4),o=Math.floor(r%6e4/1e3);return(0,U.jsxs)(`span`,{className:_(`flex items-center gap-1.5 rounded-lg px-2.5 py-1 font-mono text-sm font-semibold tabular-nums`,r<6e4?`bg-red-500/10 text-red-600`:r<3e5?`bg-amber-500/12 text-amber-600`:`bg-muted`),children:[(0,U.jsx)(D,{className:`size-4`}),String(a).padStart(2,`0`),`:`,String(o).padStart(2,`0`)]})}function J({attempt:e}){let n=e.maxScore?(e.score??0)/e.maxScore*100:0,r=e.passingPercent==null?null:n>=e.passingPercent,i=e.results?Object.values(e.results).filter(e=>e.correct).length:null;return(0,U.jsx)(l,{className:`mb-6 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-6 p-6 sm:flex-row`,children:[(0,U.jsx)(M,{value:n,size:112,stroke:9,className:_(r===!1?`text-red-500`:`text-primary`),label:(0,U.jsxs)(`span`,{className:`text-2xl font-semibold`,children:[Math.round(n),`%`]})}),(0,U.jsxs)(`div`,{className:`flex-1 text-center sm:text-left`,children:[(0,U.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-sm font-medium text-muted-foreground sm:justify-start`,children:[(0,U.jsx)(O,{className:`size-4`}),` Attempt `,e.attemptNumber,` · finished `,h(e.finishedAt)]}),(0,U.jsxs)(`p`,{className:`mt-1 text-3xl font-semibold tracking-tight tabular-nums`,children:[p(e.score),` `,(0,U.jsxs)(`span`,{className:`text-lg font-normal text-muted-foreground`,children:[`/ `,p(e.maxScore),` points`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2 sm:justify-start`,children:[i!=null&&(0,U.jsxs)(o,{variant:`neutral`,children:[i,` of `,e.questions.length,` correct`]}),r!=null&&(0,U.jsx)(o,{variant:r?`success`:`danger`,children:r?`Passed`:`Below the ${e.passingPercent}% pass mark`}),!e.review&&(0,U.jsx)(o,{variant:`outline`,children:`Correct answers are hidden for now`})]})]}),(0,U.jsx)(b,{asChild:!0,variant:`outline`,children:(0,U.jsxs)(t,{to:d(e.course.slug,e.activityId),children:[(0,U.jsx)(c,{}),` Back to quiz`]})})]})})}function Y(){let{attemptId:e}=r(),n=E(),u=i(),m=ie(),h=[`attempt`,e],{data:v,isLoading:y,error:C,refetch:w}=g({queryKey:h,queryFn:()=>S.get(`/attempts/${e}`)});T(v?.quizTitle);let[D,O]=(0,H.useState)({}),[M,F]=(0,H.useState)(null),[I,R]=(0,H.useState)(`idle`),B=(0,H.useRef)(null),Y=(0,H.useRef)(D);Y.current=D,(0,H.useEffect)(()=>{v&&M!==v.id&&(O(v.answers),F(v.id))},[v,M]);let X=v?.status===`in_progress`,oe=(0,H.useCallback)(async()=>{B.current&&clearTimeout(B.current),B.current=null,R(`saving`);try{await S.put(`/attempts/${e}`,{answers:Y.current}),R(`saved`)}catch{R(`error`)}},[e]),se=(e,t)=>{O(n=>({...n,[e]:t})),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>void oe(),700)};(0,H.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]);let Z=a({mutationFn:()=>S.post(`/attempts/${e}/submit`,{answers:Y.current}),onSuccess:async e=>{B.current&&clearTimeout(B.current),n.setQueryData(h,e),window.scrollTo({top:0,behavior:`smooth`}),A.success(`Quiz submitted!`),await m(e.course.slug)},onError:e=>A.error(x(e))}),ce=(0,H.useCallback)(()=>{Z.isPending||(A.info(`Time's up! Submitting your answers.`),Z.mutate())},[Z]);if(y)return(0,U.jsxs)(s,{size:`narrow`,children:[(0,U.jsx)(j,{className:`mb-4 h-24`}),(0,U.jsx)(j,{className:`h-64`})]});if(C instanceof te&&C.status===404)return(0,U.jsx)(re,{});if(C||!v)return(0,U.jsx)(s,{children:(0,U.jsx)(ne,{error:C,onRetry:()=>w()})});let Q=v.questions.filter(e=>G(e,D[e.id])).length,$=async()=>{let e=v.questions.length-Q;await u({title:`Submit your answers?`,description:e?`You haven't answered ${e} question${e===1?``:`s`}. You can't change your answers after submitting.`:`You can't change your answers after submitting.`,confirmLabel:`Submit quiz`})&&Z.mutate()};return(0,U.jsxs)(`div`,{children:[X&&(0,U.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/90 backdrop-blur-lg`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-5xl items-center gap-3 px-4 py-2.5 sm:px-6`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Q,` of `,v.questions.length,` answered`]})]}),(0,U.jsxs)(`span`,{className:`hidden items-center gap-1.5 text-xs text-muted-foreground sm:flex`,children:[I===`saving`?(0,U.jsx)(ee,{className:`size-3.5 animate-spin`}):I===`error`?(0,U.jsx)(L,{className:`size-3.5 text-destructive`}):(0,U.jsx)(z,{className:`size-3.5`}),I===`saving`?`Saving…`:I===`error`?`Not saved`:I===`saved`?`All changes saved`:`Autosave on`]}),v.deadlineAt&&(0,U.jsx)(q,{deadline:v.deadlineAt,onExpire:ce}),(0,U.jsxs)(b,{onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit`]})]})}),(0,U.jsxs)(s,{className:`max-w-5xl`,children:[!X&&(0,U.jsx)(J,{attempt:v}),X&&(0,U.jsxs)(`div`,{className:`mb-6`,children:[(0,U.jsxs)(t,{to:d(v.course.slug,v.activityId),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(c,{className:`size-4`}),` `,v.course.title]}),(0,U.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Attempt `,v.attemptNumber,`. Your answers save automatically as you go.`]})]}),(0,U.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_200px]`,children:[(0,U.jsxs)(`div`,{className:`space-y-4`,children:[v.questions.map((e,t)=>{let n=v.results?.[e.id];return(0,U.jsxs)(l,{id:`q-${e.id}`,className:_(`scroll-mt-32 p-5 sm:p-6`,n&&(n.correct?`border-emerald-500/40`:n.partial?`border-amber-500/40`:`border-red-500/30`)),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`p`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Question `,t+1,` · `,W[e.type]]}),n?(0,U.jsxs)(o,{variant:n.correct?`success`:n.partial?`warning`:`danger`,children:[n.correct?(0,U.jsx)(f,{}):(0,U.jsx)(ae,{}),p(n.points),` / `,p(n.maxPoints)]}):(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p(e.points),` point`,e.points===1?``:`s`]})]}),(0,U.jsx)(N,{source:e.prompt,className:`mb-4 text-[15px] font-medium [&_p]:my-0`}),(0,U.jsx)(K,{question:e,answer:D[e.id],onChange:t=>se(e.id,t),review:!!v.review,disabled:!X}),v.review&&e.explanation&&(0,U.jsxs)(`div`,{className:`mt-4 flex gap-3 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,U.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-sky-600 dark:text-sky-400`}),(0,U.jsx)(P,{source:e.explanation})]})]},e.id)}),X&&(0,U.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,U.jsxs)(b,{size:`lg`,onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit answers`]})})]}),(0,U.jsxs)(l,{className:`hidden p-4 lg:sticky lg:top-36 lg:block`,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs font-semibold text-muted-foreground`,children:`Questions`}),(0,U.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:v.questions.map((e,t)=>{let n=v.results?.[e.id],r=G(e,D[e.id]);return(0,U.jsx)(`a`,{href:`#q-${e.id}`,className:_(`grid aspect-square place-items-center rounded-md border text-xs font-semibold transition-colors hover:border-primary`,r&&!n&&`border-primary bg-primary text-primary-foreground`,n?.correct&&`border-emerald-600 bg-emerald-600 text-white`,n&&!n.correct&&n.partial&&`border-amber-500 bg-amber-500 text-white`,n&&!n.correct&&!n.partial&&`border-red-500 bg-red-500 text-white`),children:t+1},e.id)})})]})]})]})]})}export{Y as default};
1
+ import{$ as e,At as t,Ct as n,Lt as r,Q as i,Rt as a,S as o,g as s,kt as c,t as l,u,w as d,xt as f}from"./index-B29bTBiJ.js";import{E as p,H as m,T as h,U as g,V as ee,_,dt as v,ft as y,g as b,h as x,m as S,mt as C,n as w,p as te,r as T,ut as E}from"./hooks-BBARn-DA.js";import{n as D,t as O}from"./trophy-Cch2iF1m.js";import{t as k}from"./send-mxSHcdcD.js";import{T as A,c as j,n as ne,o as M}from"./misc-DvgDEI3I.js";import{n as N,t as P}from"./markdown-ykrkPMbn.js";import re from"./NotFoundPage-BRquC7-l.js";import{a as ie}from"./context-BLVW7NB7.js";var F={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};F.node;var ae=m(F),I={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};I.node;var L=m(I),R={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};R.node;var z=m(R),B={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};B.node;var V=m(B),H=C(y(),1),U=v(),W={single:`Choose one answer`,multiple:`Select all that apply`,truefalse:`True or false`,short:`Type your answer`,numeric:`Enter a number`};function G(e,t){return t?e.type===`short`||e.type===`numeric`?!!t.text?.trim():!!t.optionIds?.length:!1}function K({question:t,answer:r,onChange:i,review:a,disabled:o}){if(t.type===`short`||t.type===`numeric`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(u,{value:r?.text??``,disabled:o,inputMode:t.type===`numeric`?`decimal`:`text`,onChange:e=>i({text:e.target.value}),placeholder:t.type===`numeric`?`e.g. 42`:`Your answer`,className:`h-11 max-w-md text-[15px]`,"aria-label":`Your answer`}),a&&t.acceptedAnswers&&(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Accepted answer`,t.acceptedAnswers.length>1?`s`:``,`:`,` `,(0,U.jsxs)(`span`,{className:`font-medium text-foreground`,children:[t.acceptedAnswers.join(`, `),t.type===`numeric`&&t.tolerance?` (± ${t.tolerance})`:``]})]})]});let s=t.type===`multiple`,c=new Set(r?.optionIds??[]);return(0,U.jsx)(`div`,{className:`grid gap-2`,role:s?`group`:`radiogroup`,children:t.options.map((t,r)=>{let l=c.has(t.id),u=a?t.correct:void 0;return(0,U.jsxs)(`button`,{type:`button`,disabled:o,role:s?`checkbox`:`radio`,"aria-checked":l,onClick:()=>{if(s){let e=new Set(c);l?e.delete(t.id):e.add(t.id),i({optionIds:[...e]})}else i({optionIds:[t.id]})},className:_(`flex items-center gap-3 rounded-xl border bg-card px-4 py-3 text-left text-[15px] transition-all`,!o&&`hover:border-primary/50 hover:bg-primary/[0.02]`,l&&!a&&`border-primary bg-primary/[0.05] ring-3 ring-primary/10`,a&&u&&`border-emerald-500/50 bg-emerald-500/[0.07]`,a&&l&&!u&&`border-red-500/50 bg-red-500/[0.06]`,o&&`cursor-default`),children:[(0,U.jsx)(`span`,{className:_(`grid size-6 shrink-0 place-items-center border text-xs font-semibold text-muted-foreground`,s?`rounded-md`:`rounded-full`,l&&`border-primary bg-primary text-primary-foreground`,a&&u&&`border-emerald-600 bg-emerald-600 text-white`,a&&l&&!u&&`border-red-500 bg-red-500 text-white`),children:a&&u?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):a&&l?(0,U.jsx)(e,{className:`size-3.5`,strokeWidth:3}):l&&s?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):String.fromCharCode(65+r)}),(0,U.jsx)(P,{source:t.text,className:`flex-1`}),a&&l&&(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Your answer`})]},t.id)})})}function q({deadline:e,onExpire:t}){let n=w(1e3),r=Math.max(0,new Date(e).getTime()-n),i=(0,H.useRef)(!1);(0,H.useEffect)(()=>{r===0&&!i.current&&(i.current=!0,t())},[r,t]);let a=Math.floor(r/6e4),o=Math.floor(r%6e4/1e3);return(0,U.jsxs)(`span`,{className:_(`flex items-center gap-1.5 rounded-lg px-2.5 py-1 font-mono text-sm font-semibold tabular-nums`,r<6e4?`bg-red-500/10 text-red-600`:r<3e5?`bg-amber-500/12 text-amber-600`:`bg-muted`),children:[(0,U.jsx)(D,{className:`size-4`}),String(a).padStart(2,`0`),`:`,String(o).padStart(2,`0`)]})}function J({attempt:e}){let n=e.maxScore?(e.score??0)/e.maxScore*100:0,r=e.passingPercent==null?null:n>=e.passingPercent,i=e.results?Object.values(e.results).filter(e=>e.correct).length:null;return(0,U.jsx)(l,{className:`mb-6 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-6 p-6 sm:flex-row`,children:[(0,U.jsx)(M,{value:n,size:112,stroke:9,className:_(r===!1?`text-red-500`:`text-primary`),label:(0,U.jsxs)(`span`,{className:`text-2xl font-semibold`,children:[Math.round(n),`%`]})}),(0,U.jsxs)(`div`,{className:`flex-1 text-center sm:text-left`,children:[(0,U.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-sm font-medium text-muted-foreground sm:justify-start`,children:[(0,U.jsx)(O,{className:`size-4`}),` Attempt `,e.attemptNumber,` · finished `,h(e.finishedAt)]}),(0,U.jsxs)(`p`,{className:`mt-1 text-3xl font-semibold tracking-tight tabular-nums`,children:[p(e.score),` `,(0,U.jsxs)(`span`,{className:`text-lg font-normal text-muted-foreground`,children:[`/ `,p(e.maxScore),` points`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2 sm:justify-start`,children:[i!=null&&(0,U.jsxs)(o,{variant:`neutral`,children:[i,` of `,e.questions.length,` correct`]}),r!=null&&(0,U.jsx)(o,{variant:r?`success`:`danger`,children:r?`Passed`:`Below the ${e.passingPercent}% pass mark`}),!e.review&&(0,U.jsx)(o,{variant:`outline`,children:`Correct answers are hidden for now`})]})]}),(0,U.jsx)(b,{asChild:!0,variant:`outline`,children:(0,U.jsxs)(t,{to:d(e.course.slug,e.activityId),children:[(0,U.jsx)(c,{}),` Back to quiz`]})})]})})}function Y(){let{attemptId:e}=r(),n=E(),u=i(),m=ie(),h=[`attempt`,e],{data:v,isLoading:y,error:C,refetch:w}=g({queryKey:h,queryFn:()=>S.get(`/attempts/${e}`)});T(v?.quizTitle);let[D,O]=(0,H.useState)({}),[M,F]=(0,H.useState)(null),[I,R]=(0,H.useState)(`idle`),B=(0,H.useRef)(null),Y=(0,H.useRef)(D);Y.current=D,(0,H.useEffect)(()=>{v&&M!==v.id&&(O(v.answers),F(v.id))},[v,M]);let X=v?.status===`in_progress`,oe=(0,H.useCallback)(async()=>{B.current&&clearTimeout(B.current),B.current=null,R(`saving`);try{await S.put(`/attempts/${e}`,{answers:Y.current}),R(`saved`)}catch{R(`error`)}},[e]),se=(e,t)=>{O(n=>({...n,[e]:t})),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>void oe(),700)};(0,H.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]);let Z=a({mutationFn:()=>S.post(`/attempts/${e}/submit`,{answers:Y.current}),onSuccess:async e=>{B.current&&clearTimeout(B.current),n.setQueryData(h,e),window.scrollTo({top:0,behavior:`smooth`}),A.success(`Quiz submitted!`),await m(e.course.slug)},onError:e=>A.error(x(e))}),ce=(0,H.useCallback)(()=>{Z.isPending||(A.info(`Time's up! Submitting your answers.`),Z.mutate())},[Z]);if(y)return(0,U.jsxs)(s,{size:`narrow`,children:[(0,U.jsx)(j,{className:`mb-4 h-24`}),(0,U.jsx)(j,{className:`h-64`})]});if(C instanceof te&&C.status===404)return(0,U.jsx)(re,{});if(C||!v)return(0,U.jsx)(s,{children:(0,U.jsx)(ne,{error:C,onRetry:()=>w()})});let Q=v.questions.filter(e=>G(e,D[e.id])).length,$=async()=>{let e=v.questions.length-Q;await u({title:`Submit your answers?`,description:e?`You haven't answered ${e} question${e===1?``:`s`}. You can't change your answers after submitting.`:`You can't change your answers after submitting.`,confirmLabel:`Submit quiz`})&&Z.mutate()};return(0,U.jsxs)(`div`,{children:[X&&(0,U.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/90 backdrop-blur-lg`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-5xl items-center gap-3 px-4 py-2.5 sm:px-6`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Q,` of `,v.questions.length,` answered`]})]}),(0,U.jsxs)(`span`,{className:`hidden items-center gap-1.5 text-xs text-muted-foreground sm:flex`,children:[I===`saving`?(0,U.jsx)(ee,{className:`size-3.5 animate-spin`}):I===`error`?(0,U.jsx)(L,{className:`size-3.5 text-destructive`}):(0,U.jsx)(z,{className:`size-3.5`}),I===`saving`?`Saving…`:I===`error`?`Not saved`:I===`saved`?`All changes saved`:`Autosave on`]}),v.deadlineAt&&(0,U.jsx)(q,{deadline:v.deadlineAt,onExpire:ce}),(0,U.jsxs)(b,{onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit`]})]})}),(0,U.jsxs)(s,{className:`max-w-5xl`,children:[!X&&(0,U.jsx)(J,{attempt:v}),X&&(0,U.jsxs)(`div`,{className:`mb-6`,children:[(0,U.jsxs)(t,{to:d(v.course.slug,v.activityId),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(c,{className:`size-4`}),` `,v.course.title]}),(0,U.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Attempt `,v.attemptNumber,`. Your answers save automatically as you go.`]})]}),(0,U.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_200px]`,children:[(0,U.jsxs)(`div`,{className:`space-y-4`,children:[v.questions.map((e,t)=>{let n=v.results?.[e.id];return(0,U.jsxs)(l,{id:`q-${e.id}`,className:_(`scroll-mt-32 p-5 sm:p-6`,n&&(n.correct?`border-emerald-500/40`:n.partial?`border-amber-500/40`:`border-red-500/30`)),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`p`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Question `,t+1,` · `,W[e.type]]}),n?(0,U.jsxs)(o,{variant:n.correct?`success`:n.partial?`warning`:`danger`,children:[n.correct?(0,U.jsx)(f,{}):(0,U.jsx)(ae,{}),p(n.points),` / `,p(n.maxPoints)]}):(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p(e.points),` point`,e.points===1?``:`s`]})]}),(0,U.jsx)(N,{source:e.prompt,className:`mb-4 text-[15px] font-medium [&_p]:my-0`}),(0,U.jsx)(K,{question:e,answer:D[e.id],onChange:t=>se(e.id,t),review:!!v.review,disabled:!X}),v.review&&e.explanation&&(0,U.jsxs)(`div`,{className:`mt-4 flex gap-3 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,U.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-sky-600 dark:text-sky-400`}),(0,U.jsx)(P,{source:e.explanation})]})]},e.id)}),X&&(0,U.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,U.jsxs)(b,{size:`lg`,onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit answers`]})})]}),(0,U.jsxs)(l,{className:`hidden p-4 lg:sticky lg:top-36 lg:block`,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs font-semibold text-muted-foreground`,children:`Questions`}),(0,U.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:v.questions.map((e,t)=>{let n=v.results?.[e.id],r=G(e,D[e.id]);return(0,U.jsx)(`a`,{href:`#q-${e.id}`,className:_(`grid aspect-square place-items-center rounded-md border text-xs font-semibold transition-colors hover:border-primary`,r&&!n&&`border-primary bg-primary text-primary-foreground`,n?.correct&&`border-emerald-600 bg-emerald-600 text-white`,n&&!n.correct&&n.partial&&`border-amber-500 bg-amber-500 text-white`,n&&!n.correct&&!n.partial&&`border-red-500 bg-red-500 text-white`),children:t+1},e.id)})})]})]})]})]})}export{Y as default};
@@ -1,3 +1,3 @@
1
- import{$ as e,At as t,B as n,Ct as r,Lt as i,R as a,Rt as o,V as s,d as c,dt as l,f as u,g as d,kt as f,l as p,m,ot as h,q as g,rt as _,t as v,u as y,w as b}from"./index-DkBZ18Ts.js";import{E as x,H as S,U as C,_ as w,dt as T,ft as E,g as D,h as O,i as k,m as A,mt as j,r as M,ut as N}from"./hooks-BBARn-DA.js";import{n as P,t as F}from"./arrow-up-LHDup5m4.js";import{t as I}from"./copy-Bxxjq6zo.js";import{T as L,c as R,n as z,t as B}from"./misc-DvgDEI3I.js";import{a as V}from"./context-B5ZaAO90.js";import{n as H}from"./frame-BjgJqbS9.js";var U={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};U.node;var W=S(U),G=j(E(),1),K=T(),q={single:`Multiple choice (one answer)`,multiple:`Multiple choice (several answers)`,truefalse:`True / false`,short:`Short answer`,numeric:`Numerical`},J=0,Y=()=>`k${Date.now().toString(36)}${J++}`,X=()=>Math.random().toString(36).slice(2,10);function Z(e){let t={key:Y(),id:``,type:e,prompt:``,points:e===`multiple`?2:1,options:[],acceptedAnswers:[],tolerance:null,explanation:null};return e===`single`||e===`multiple`?{...t,options:[0,1,2].map(e=>({id:X(),text:``,correct:e===0}))}:e===`truefalse`?{...t,options:[{id:X(),text:`True`,correct:!0},{id:X(),text:`False`,correct:!1}]}:t}function Q(e,t){let n=Z(t);if(t===e.type)return e;let r=(t===`single`||t===`multiple`)&&(e.type===`single`||e.type===`multiple`)&&e.options.length>=2;return{...n,key:e.key,id:e.id,prompt:e.prompt,explanation:e.explanation,options:r?e.options.map((n,r)=>({...n,correct:t===`single`?r===e.options.findIndex(e=>e.correct):n.correct})):n.options}}function ee({q:t,index:n,total:i,onChange:a,onMove:o,onDuplicate:s,onDelete:l}){let d=(e,n)=>{let r=t.options.map((r,i)=>t.type===`single`&&n.correct?i===e?{...r,...n}:{...r,correct:!1}:i===e?{...r,...n}:r);a({...t,options:r})};return(0,K.jsxs)(v,{className:`overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b bg-muted/30 px-5 py-3`,children:[(0,K.jsx)(`span`,{className:`grid size-7 place-items-center rounded-full bg-primary text-xs font-semibold text-primary-foreground`,children:n+1}),(0,K.jsx)(u,{value:t.type,onChange:e=>a(Q(t,e.target.value)),className:`h-8 w-auto min-w-56 text-[13px]`,"aria-label":`Question type`,children:Object.entries(q).map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`Points`,(0,K.jsx)(y,{type:`number`,min:0,step:`any`,value:t.points,onChange:e=>a({...t,points:Number(e.target.value)}),className:`h-8 w-20`})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(-1),disabled:n===0,"aria-label":`Move up`,children:(0,K.jsx)(F,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(1),disabled:n===i-1,"aria-label":`Move down`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:s,"aria-label":`Duplicate`,children:(0,K.jsx)(I,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:l,"aria-label":`Delete question`,className:`hover:text-destructive`,children:(0,K.jsx)(_,{})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-5 p-5`,children:[(0,K.jsx)(p,{label:`Question`,children:e=>(0,K.jsx)(m,{...e,rows:2,value:t.prompt,onChange:e=>a({...t,prompt:e.target.value}),placeholder:"What would you like to ask? Markdown and `code` work here."})}),(t.type===`single`||t.type===`multiple`)&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(c,{children:[`Options`,` `,t.type===`multiple`?(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(tick every correct option)`}):(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(pick the correct one)`})]}),t.options.map((n,i)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(i,{correct:t.type===`single`||!n.correct}),className:w(`grid size-8 shrink-0 place-items-center border transition-colors`,t.type===`single`?`rounded-full`:`rounded-md`,n.correct?`border-emerald-600 bg-emerald-600 text-white`:`text-muted-foreground hover:border-emerald-600`),"aria-label":n.correct?`Correct answer`:`Mark as correct`,children:n.correct?(0,K.jsx)(r,{className:`size-4`,strokeWidth:3}):(0,K.jsx)(`span`,{className:`text-xs`,children:String.fromCharCode(65+i)})}),(0,K.jsx)(y,{value:n.text,onChange:e=>d(i,{text:e.target.value}),placeholder:`Option ${String.fromCharCode(65+i)}`}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,disabled:t.options.length<=2,onClick:()=>a({...t,options:t.options.filter((e,t)=>t!==i)}),"aria-label":`Remove option`,children:(0,K.jsx)(e,{})})]},n.id)),t.options.length<10&&(0,K.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:()=>a({...t,options:[...t.options,{id:X(),text:``,correct:!1}]}),children:[(0,K.jsx)(h,{}),` Add option`]})]}),t.type===`truefalse`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(c,{children:`The statement is`}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:t.options.map((e,n)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a({...t,options:t.options.map((e,t)=>({...e,correct:t===n}))}),className:w(`flex h-10 items-center gap-2 rounded-lg border px-5 text-sm font-medium transition-colors`,e.correct?`border-emerald-600 bg-emerald-600 text-white`:`hover:border-emerald-600`),children:[e.correct&&(0,K.jsx)(r,{className:`size-4`}),e.text]},e.id))})]}),t.type===`short`&&(0,K.jsx)(p,{label:`Accepted answers`,hint:`One per line. Matching ignores case and extra spaces; use * as a wildcard (e.g. colou*r).`,children:e=>(0,K.jsx)(m,{...e,rows:3,value:(t.acceptedAnswers??[]).join(`
1
+ import{$ as e,At as t,B as n,Ct as r,Lt as i,R as a,Rt as o,V as s,d as c,dt as l,f as u,g as d,kt as f,l as p,m,ot as h,q as g,rt as _,t as v,u as y,w as b}from"./index-B29bTBiJ.js";import{E as x,H as S,U as C,_ as w,dt as T,ft as E,g as D,h as O,i as k,m as A,mt as j,r as M,ut as N}from"./hooks-BBARn-DA.js";import{n as P,t as F}from"./arrow-up-LHDup5m4.js";import{t as I}from"./copy-Bxxjq6zo.js";import{T as L,c as R,n as z,t as B}from"./misc-DvgDEI3I.js";import{a as V}from"./context-BLVW7NB7.js";import{n as H}from"./frame-CGabirLa.js";var U={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};U.node;var W=S(U),G=j(E(),1),K=T(),q={single:`Multiple choice (one answer)`,multiple:`Multiple choice (several answers)`,truefalse:`True / false`,short:`Short answer`,numeric:`Numerical`},J=0,Y=()=>`k${Date.now().toString(36)}${J++}`,X=()=>Math.random().toString(36).slice(2,10);function Z(e){let t={key:Y(),id:``,type:e,prompt:``,points:e===`multiple`?2:1,options:[],acceptedAnswers:[],tolerance:null,explanation:null};return e===`single`||e===`multiple`?{...t,options:[0,1,2].map(e=>({id:X(),text:``,correct:e===0}))}:e===`truefalse`?{...t,options:[{id:X(),text:`True`,correct:!0},{id:X(),text:`False`,correct:!1}]}:t}function Q(e,t){let n=Z(t);if(t===e.type)return e;let r=(t===`single`||t===`multiple`)&&(e.type===`single`||e.type===`multiple`)&&e.options.length>=2;return{...n,key:e.key,id:e.id,prompt:e.prompt,explanation:e.explanation,options:r?e.options.map((n,r)=>({...n,correct:t===`single`?r===e.options.findIndex(e=>e.correct):n.correct})):n.options}}function ee({q:t,index:n,total:i,onChange:a,onMove:o,onDuplicate:s,onDelete:l}){let d=(e,n)=>{let r=t.options.map((r,i)=>t.type===`single`&&n.correct?i===e?{...r,...n}:{...r,correct:!1}:i===e?{...r,...n}:r);a({...t,options:r})};return(0,K.jsxs)(v,{className:`overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b bg-muted/30 px-5 py-3`,children:[(0,K.jsx)(`span`,{className:`grid size-7 place-items-center rounded-full bg-primary text-xs font-semibold text-primary-foreground`,children:n+1}),(0,K.jsx)(u,{value:t.type,onChange:e=>a(Q(t,e.target.value)),className:`h-8 w-auto min-w-56 text-[13px]`,"aria-label":`Question type`,children:Object.entries(q).map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`Points`,(0,K.jsx)(y,{type:`number`,min:0,step:`any`,value:t.points,onChange:e=>a({...t,points:Number(e.target.value)}),className:`h-8 w-20`})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(-1),disabled:n===0,"aria-label":`Move up`,children:(0,K.jsx)(F,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(1),disabled:n===i-1,"aria-label":`Move down`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:s,"aria-label":`Duplicate`,children:(0,K.jsx)(I,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:l,"aria-label":`Delete question`,className:`hover:text-destructive`,children:(0,K.jsx)(_,{})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-5 p-5`,children:[(0,K.jsx)(p,{label:`Question`,children:e=>(0,K.jsx)(m,{...e,rows:2,value:t.prompt,onChange:e=>a({...t,prompt:e.target.value}),placeholder:"What would you like to ask? Markdown and `code` work here."})}),(t.type===`single`||t.type===`multiple`)&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(c,{children:[`Options`,` `,t.type===`multiple`?(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(tick every correct option)`}):(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(pick the correct one)`})]}),t.options.map((n,i)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(i,{correct:t.type===`single`||!n.correct}),className:w(`grid size-8 shrink-0 place-items-center border transition-colors`,t.type===`single`?`rounded-full`:`rounded-md`,n.correct?`border-emerald-600 bg-emerald-600 text-white`:`text-muted-foreground hover:border-emerald-600`),"aria-label":n.correct?`Correct answer`:`Mark as correct`,children:n.correct?(0,K.jsx)(r,{className:`size-4`,strokeWidth:3}):(0,K.jsx)(`span`,{className:`text-xs`,children:String.fromCharCode(65+i)})}),(0,K.jsx)(y,{value:n.text,onChange:e=>d(i,{text:e.target.value}),placeholder:`Option ${String.fromCharCode(65+i)}`}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,disabled:t.options.length<=2,onClick:()=>a({...t,options:t.options.filter((e,t)=>t!==i)}),"aria-label":`Remove option`,children:(0,K.jsx)(e,{})})]},n.id)),t.options.length<10&&(0,K.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:()=>a({...t,options:[...t.options,{id:X(),text:``,correct:!1}]}),children:[(0,K.jsx)(h,{}),` Add option`]})]}),t.type===`truefalse`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(c,{children:`The statement is`}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:t.options.map((e,n)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a({...t,options:t.options.map((e,t)=>({...e,correct:t===n}))}),className:w(`flex h-10 items-center gap-2 rounded-lg border px-5 text-sm font-medium transition-colors`,e.correct?`border-emerald-600 bg-emerald-600 text-white`:`hover:border-emerald-600`),children:[e.correct&&(0,K.jsx)(r,{className:`size-4`}),e.text]},e.id))})]}),t.type===`short`&&(0,K.jsx)(p,{label:`Accepted answers`,hint:`One per line. Matching ignores case and extra spaces; use * as a wildcard (e.g. colou*r).`,children:e=>(0,K.jsx)(m,{...e,rows:3,value:(t.acceptedAnswers??[]).join(`
2
2
  `),onChange:e=>a({...t,acceptedAnswers:e.target.value.split(`
3
3
  `)}),className:`font-mono text-[13px]`})}),t.type===`numeric`&&(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsx)(p,{label:`Correct answer`,children:e=>(0,K.jsx)(y,{...e,inputMode:`decimal`,value:t.acceptedAnswers?.[0]??``,onChange:e=>a({...t,acceptedAnswers:[e.target.value]})})}),(0,K.jsx)(p,{label:`Allowed error (±)`,optional:!0,children:e=>(0,K.jsx)(y,{...e,type:`number`,min:0,step:`any`,value:t.tolerance??``,onChange:e=>a({...t,tolerance:e.target.value?Number(e.target.value):null})})})]}),(0,K.jsx)(p,{label:`Explanation`,optional:!0,hint:`Shown to students when they review their attempt.`,children:e=>(0,K.jsx)(m,{...e,rows:2,value:t.explanation??``,onChange:e=>a({...t,explanation:e.target.value||null})})})]})]})}function $({onAdd:e,variant:t=`outline`}){return(0,K.jsxs)(a,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(D,{variant:t,children:[(0,K.jsx)(h,{}),` Add question`]})}),(0,K.jsx)(n,{align:`start`,className:`w-64`,children:Object.keys(q).map(t=>(0,K.jsx)(s,{onSelect:()=>e(t),children:q[t]},t))})]})}function te(){let{activityId:e}=i(),n=N(),r=V(),{data:a}=H(e);M(a?`Questions · ${a.title}`:`Questions`);let{data:s,isLoading:c,error:u,refetch:p}=C({queryKey:[`questions`,e],queryFn:()=>A.get(`/activities/${e}/questions`)}),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(``);(0,G.useEffect)(()=>{if(s&&m===null){let e=s.map(e=>({...e,key:Y()}));h(e),_(JSON.stringify(s))}},[s,m]);let v=e=>e.map(({key:e,...t})=>t),y=m!==null&&JSON.stringify(v(m))!==g;k(y);let S=o({mutationFn:()=>A.put(`/activities/${e}/questions`,{questions:v(m).map(e=>({...e,id:e.id||void 0,acceptedAnswers:(e.acceptedAnswers??[]).map(e=>e.trim()).filter(Boolean)}))}),onSuccess:async t=>{L.success(`Questions saved`),h(t.map(e=>({...e,key:Y()}))),_(JSON.stringify(t)),n.setQueryData([`questions`,e],t),await r(a?.course.slug)},onError:e=>L.error(O(e),{duration:8e3})}),w=(m??[]).reduce((e,t)=>e+(Number(t.points)||0),0),T=(e,t)=>h(n=>n.map((n,r)=>r===e?t:n)),E=(e,t)=>h(n=>{let r=[...n];return[r[e],r[e+t]]=[r[e+t],r[e]],r});return(0,K.jsxs)(d,{size:`narrow`,className:`pb-28`,children:[a&&(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(t,{to:b(a.course.slug,a.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(f,{className:`size-4`}),` `,a.title]}),(0,K.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Edit questions`}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Students see these questions when they attempt the quiz. Grading is automatic.`})]}),u?(0,K.jsx)(z,{error:u,onRetry:()=>p()}):c||!m?(0,K.jsx)(R,{className:`h-96`}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[m.length===0&&(0,K.jsx)(B,{icon:l,title:`No questions yet`,description:`Add your first question. Mix and match multiple choice, true/false, short answer and numerical questions.`,action:(0,K.jsx)($,{variant:`default`,onAdd:e=>h([Z(e)])})}),m.map((e,t)=>(0,K.jsx)(ee,{q:e,index:t,total:m.length,onChange:e=>T(t,e),onMove:e=>E(t,e),onDuplicate:()=>h(n=>{let r={...structuredClone(e),key:Y(),id:``,options:e.options.map(e=>({...e,id:X()}))};return[...n.slice(0,t+1),r,...n.slice(t+1)]}),onDelete:()=>h(e=>e.filter((e,n)=>n!==t))},e.key)),m.length>0&&(0,K.jsx)($,{onAdd:e=>h(t=>[...t,Z(e)])})]}),m&&(0,K.jsx)(`div`,{className:`fixed inset-x-0 bottom-0 z-30 border-t bg-card/90 backdrop-blur-lg lg:left-64`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.length,` question`,m.length===1?``:`s`,` · `,x(w),` point`,w===1?``:`s`,y&&(0,K.jsx)(`span`,{className:`ml-2 font-medium text-amber-600 dark:text-amber-400`,children:`Unsaved changes`})]}),(0,K.jsxs)(D,{className:`ml-auto`,onClick:()=>S.mutate(),loading:S.isPending,disabled:!y,children:[(0,K.jsx)(W,{}),` Save questions`]})]})})]})}export{te as default};
@@ -1 +1 @@
1
- import{At as e,Lt as t,Rt as n,S as r,St as i,bt as a,g as o,j as s,kt as c,l,m as u,r as d,t as f,u as p,w as m}from"./index-DkBZ18Ts.js";import{D as h,E as g,H as _,T as ee,U as v,_ as y,dt as b,ft as x,g as S,h as C,m as w,mt as T,r as E,ut as D}from"./hooks-BBARn-DA.js";import{T as O,c as k,n as A,s as j,t as M}from"./misc-DvgDEI3I.js";import{n as te}from"./markdown-C1oaAmMK.js";import{n as N}from"./frame-BjgJqbS9.js";var P={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};P.node;var F=_(P),I=T(x(),1),L=b();function R(e){return e.needsGrading?{label:`Needs grading`,variant:`warning`}:e.grade?.score==null?{label:`Not submitted`,variant:`neutral`}:{label:`${g(e.grade.score)} / ${g(e.grade.maxGrade)}`,variant:`success`}}function z(){let{activityId:_}=t(),b=D(),{data:x}=N(_);E(x?`Submissions · ${x.title}`:`Submissions`);let T=[`submissions`,_],{data:P,isLoading:z,error:B,refetch:V}=v({queryKey:T,queryFn:()=>w.get(`/activities/${_}/submissions`)}),[H,U]=(0,I.useState)(`needs`),[W,G]=(0,I.useState)(null),[K,q]=(0,I.useState)(``),[J,Y]=(0,I.useState)(``),X=(0,I.useMemo)(()=>(P??[]).filter(e=>H===`needs`?e.needsGrading:H===`graded`?e.grade?.score!=null&&!e.needsGrading:H!==`missing`||!e.submission),[P,H]);(0,I.useEffect)(()=>{P&&P.length&&!P.some(e=>e.needsGrading)&&H===`needs`&&U(`all`)},[P,H]),(0,I.useEffect)(()=>{!W&&X[0]&&G(X[0].user.id)},[X,W]);let Z=P?.find(e=>e.user.id===W)??null;(0,I.useEffect)(()=>{q(Z?.grade?.score==null?``:String(Z.grade.score)),Y(Z?.grade?.feedback??``)},[Z?.user.id,Z?.grade?.score,Z?.grade?.feedback]);let Q=n({mutationFn:()=>w.put(`/activities/${_}/grades/${Z.user.id}`,{score:K===``?null:Number(K),feedback:J.trim()||null}),onSuccess:async()=>{O.success(`Saved grade for ${Z.user.name}`);let e=(P??[]).filter(e=>e.needsGrading&&e.user.id!==Z.user.id);await Promise.all([b.invalidateQueries({queryKey:T}),b.invalidateQueries({queryKey:[`activity`,_]}),b.invalidateQueries({queryKey:[`dashboard`]})]),e[0]&&G(e[0].user.id)},onError:e=>O.error(C(e))}),$=e=>(P??[]).filter(t=>e===`needs`?t.needsGrading:e===`graded`?t.grade?.score!=null&&!t.needsGrading:e!==`missing`||!t.submission).length;return(0,L.jsxs)(o,{size:`wide`,children:[x&&(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsxs)(e,{to:m(x.course.slug,x.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,L.jsx)(c,{className:`size-4`}),` `,x.title]}),(0,L.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Grade submissions`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[x.course.title,` · out of `,g(x.maxGrade),` points`]})]}),B?(0,L.jsx)(A,{error:B,onRetry:()=>V()}):z||!P?(0,L.jsx)(k,{className:`h-[480px]`}):P.length===0?(0,L.jsx)(M,{icon:F,title:`No students yet`,description:`Students enrolled in this course will appear here.`}):(0,L.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,L.jsxs)(f,{className:`overflow-hidden lg:sticky lg:top-20`,children:[(0,L.jsx)(`div`,{className:`border-b p-3`,children:(0,L.jsx)(j,{value:H,onChange:e=>{U(e),G(null)},className:`w-full`,options:[{value:`needs`,label:`To grade`,count:$(`needs`)},{value:`graded`,label:`Graded`,count:$(`graded`)},{value:`missing`,label:`Missing`,count:$(`missing`)},{value:`all`,label:`All`}]})}),(0,L.jsxs)(`div`,{className:`ck-scrollbar max-h-[65vh] divide-y overflow-y-auto`,children:[X.length===0&&(0,L.jsx)(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Nothing here. 🎉`}),X.map(e=>{let t=R(e);return(0,L.jsxs)(`button`,{onClick:()=>G(e.user.id),className:y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/50`,W===e.user.id&&`bg-primary/[0.06]`),children:[(0,L.jsx)(s,{user:e.user,size:`sm`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.user.name}),(0,L.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.submission?`Submitted ${h(e.submission.submittedAt)}`:`No submission`})]}),(0,L.jsx)(r,{variant:t.variant,children:t.label}),(0,L.jsx)(i,{className:`size-4 text-muted-foreground/50`})]},e.user.id)})]})]}),Z?(0,L.jsxs)(`div`,{className:`space-y-5`,children:[(0,L.jsxs)(f,{className:`p-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(s,{user:Z.user,size:`lg`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`truncate font-semibold`,children:Z.user.name}),(0,L.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:Z.user.email})]}),Z.submission&&(0,L.jsxs)(`div`,{className:`shrink-0 text-right text-sm`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Submitted`}),(0,L.jsx)(`p`,{className:`font-medium`,children:ee(Z.submission.submittedAt)})]}),Z.submission?.late&&(0,L.jsx)(r,{variant:`warning`,children:`Late`})]}),(0,L.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[!Z.submission&&(0,L.jsx)(`p`,{className:`rounded-lg bg-muted/60 p-4 text-sm text-muted-foreground`,children:`This student hasn't submitted anything yet. You can still record a grade.`}),Z.submission?.text&&(0,L.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-5`,children:(0,L.jsx)(te,{source:Z.submission.text,className:`prose-sm`})}),Z.submission&&Z.submission.files.length>0&&(0,L.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Z.submission.files.map(e=>(0,L.jsx)(d,{file:e},e.id))})]})]}),(0,L.jsx)(f,{className:`p-6`,children:(0,L.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Q.mutate()},children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,L.jsx)(a,{className:`size-4 text-primary`}),` Grade and feedback`]}),(0,L.jsx)(l,{label:`Score (out of ${g(x?.maxGrade??0)})`,className:`sm:w-56`,children:e=>(0,L.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:x?.maxGrade??void 0,value:K,onChange:e=>q(e.target.value)})}),(0,L.jsx)(l,{label:`Feedback for the student`,optional:!0,children:e=>(0,L.jsx)(u,{...e,rows:5,value:J,onChange:e=>Y(e.target.value),placeholder:`What went well? What could be better?`})}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Z.grade?.gradedAt?(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last graded `,h(Z.grade.gradedAt),Z.grade.gradedBy&&` by ${Z.grade.gradedBy.name}`]}):(0,L.jsx)(`span`,{}),(0,L.jsx)(S,{type:`submit`,loading:Q.isPending,disabled:K===``,children:`Save grade`})]})]})})]}):(0,L.jsx)(M,{icon:a,title:`Select a student`,description:`Pick someone from the list to review their work.`})]})]})}export{z as default};
1
+ import{At as e,Lt as t,Rt as n,S as r,St as i,bt as a,g as o,j as s,kt as c,l,m as u,r as d,t as f,u as p,w as m}from"./index-B29bTBiJ.js";import{D as h,E as g,H as _,T as ee,U as v,_ as y,dt as b,ft as x,g as S,h as C,m as w,mt as T,r as E,ut as D}from"./hooks-BBARn-DA.js";import{T as O,c as k,n as A,s as j,t as M}from"./misc-DvgDEI3I.js";import{n as te}from"./markdown-ykrkPMbn.js";import{n as N}from"./frame-CGabirLa.js";var P={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};P.node;var F=_(P),I=T(x(),1),L=b();function R(e){return e.needsGrading?{label:`Needs grading`,variant:`warning`}:e.grade?.score==null?{label:`Not submitted`,variant:`neutral`}:{label:`${g(e.grade.score)} / ${g(e.grade.maxGrade)}`,variant:`success`}}function z(){let{activityId:_}=t(),b=D(),{data:x}=N(_);E(x?`Submissions · ${x.title}`:`Submissions`);let T=[`submissions`,_],{data:P,isLoading:z,error:B,refetch:V}=v({queryKey:T,queryFn:()=>w.get(`/activities/${_}/submissions`)}),[H,U]=(0,I.useState)(`needs`),[W,G]=(0,I.useState)(null),[K,q]=(0,I.useState)(``),[J,Y]=(0,I.useState)(``),X=(0,I.useMemo)(()=>(P??[]).filter(e=>H===`needs`?e.needsGrading:H===`graded`?e.grade?.score!=null&&!e.needsGrading:H!==`missing`||!e.submission),[P,H]);(0,I.useEffect)(()=>{P&&P.length&&!P.some(e=>e.needsGrading)&&H===`needs`&&U(`all`)},[P,H]),(0,I.useEffect)(()=>{!W&&X[0]&&G(X[0].user.id)},[X,W]);let Z=P?.find(e=>e.user.id===W)??null;(0,I.useEffect)(()=>{q(Z?.grade?.score==null?``:String(Z.grade.score)),Y(Z?.grade?.feedback??``)},[Z?.user.id,Z?.grade?.score,Z?.grade?.feedback]);let Q=n({mutationFn:()=>w.put(`/activities/${_}/grades/${Z.user.id}`,{score:K===``?null:Number(K),feedback:J.trim()||null}),onSuccess:async()=>{O.success(`Saved grade for ${Z.user.name}`);let e=(P??[]).filter(e=>e.needsGrading&&e.user.id!==Z.user.id);await Promise.all([b.invalidateQueries({queryKey:T}),b.invalidateQueries({queryKey:[`activity`,_]}),b.invalidateQueries({queryKey:[`dashboard`]})]),e[0]&&G(e[0].user.id)},onError:e=>O.error(C(e))}),$=e=>(P??[]).filter(t=>e===`needs`?t.needsGrading:e===`graded`?t.grade?.score!=null&&!t.needsGrading:e!==`missing`||!t.submission).length;return(0,L.jsxs)(o,{size:`wide`,children:[x&&(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsxs)(e,{to:m(x.course.slug,x.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,L.jsx)(c,{className:`size-4`}),` `,x.title]}),(0,L.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Grade submissions`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[x.course.title,` · out of `,g(x.maxGrade),` points`]})]}),B?(0,L.jsx)(A,{error:B,onRetry:()=>V()}):z||!P?(0,L.jsx)(k,{className:`h-[480px]`}):P.length===0?(0,L.jsx)(M,{icon:F,title:`No students yet`,description:`Students enrolled in this course will appear here.`}):(0,L.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,L.jsxs)(f,{className:`overflow-hidden lg:sticky lg:top-20`,children:[(0,L.jsx)(`div`,{className:`border-b p-3`,children:(0,L.jsx)(j,{value:H,onChange:e=>{U(e),G(null)},className:`w-full`,options:[{value:`needs`,label:`To grade`,count:$(`needs`)},{value:`graded`,label:`Graded`,count:$(`graded`)},{value:`missing`,label:`Missing`,count:$(`missing`)},{value:`all`,label:`All`}]})}),(0,L.jsxs)(`div`,{className:`ck-scrollbar max-h-[65vh] divide-y overflow-y-auto`,children:[X.length===0&&(0,L.jsx)(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Nothing here. 🎉`}),X.map(e=>{let t=R(e);return(0,L.jsxs)(`button`,{onClick:()=>G(e.user.id),className:y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/50`,W===e.user.id&&`bg-primary/[0.06]`),children:[(0,L.jsx)(s,{user:e.user,size:`sm`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.user.name}),(0,L.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.submission?`Submitted ${h(e.submission.submittedAt)}`:`No submission`})]}),(0,L.jsx)(r,{variant:t.variant,children:t.label}),(0,L.jsx)(i,{className:`size-4 text-muted-foreground/50`})]},e.user.id)})]})]}),Z?(0,L.jsxs)(`div`,{className:`space-y-5`,children:[(0,L.jsxs)(f,{className:`p-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(s,{user:Z.user,size:`lg`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`truncate font-semibold`,children:Z.user.name}),(0,L.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:Z.user.email})]}),Z.submission&&(0,L.jsxs)(`div`,{className:`shrink-0 text-right text-sm`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Submitted`}),(0,L.jsx)(`p`,{className:`font-medium`,children:ee(Z.submission.submittedAt)})]}),Z.submission?.late&&(0,L.jsx)(r,{variant:`warning`,children:`Late`})]}),(0,L.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[!Z.submission&&(0,L.jsx)(`p`,{className:`rounded-lg bg-muted/60 p-4 text-sm text-muted-foreground`,children:`This student hasn't submitted anything yet. You can still record a grade.`}),Z.submission?.text&&(0,L.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-5`,children:(0,L.jsx)(te,{source:Z.submission.text,className:`prose-sm`})}),Z.submission&&Z.submission.files.length>0&&(0,L.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Z.submission.files.map(e=>(0,L.jsx)(d,{file:e},e.id))})]})]}),(0,L.jsx)(f,{className:`p-6`,children:(0,L.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Q.mutate()},children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,L.jsx)(a,{className:`size-4 text-primary`}),` Grade and feedback`]}),(0,L.jsx)(l,{label:`Score (out of ${g(x?.maxGrade??0)})`,className:`sm:w-56`,children:e=>(0,L.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:x?.maxGrade??void 0,value:K,onChange:e=>q(e.target.value)})}),(0,L.jsx)(l,{label:`Feedback for the student`,optional:!0,children:e=>(0,L.jsx)(u,{...e,rows:5,value:J,onChange:e=>Y(e.target.value),placeholder:`What went well? What could be better?`})}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Z.grade?.gradedAt?(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last graded `,h(Z.grade.gradedAt),Z.grade.gradedBy&&` by ${Z.grade.gradedBy.name}`]}):(0,L.jsx)(`span`,{}),(0,L.jsx)(S,{type:`submit`,loading:Q.isPending,disabled:K===``,children:`Save grade`})]})]})})]}):(0,L.jsx)(M,{icon:a,title:`Select a student`,description:`Pick someone from the list to review their work.`})]})]})}export{z as default};
@@ -1 +1 @@
1
- import{U as e,m as t,ut as n}from"./hooks-BBARn-DA.js";import{It as r}from"./index-DkBZ18Ts.js";function i(n){return e({queryKey:[`course`,n],queryFn:()=>t.get(`/courses/${n}`),enabled:!!n})}function a(){return r()}function o(){let e=n();return t=>Promise.all([e.invalidateQueries({queryKey:[`course`,t]}),e.invalidateQueries({queryKey:[`courses`]}),e.invalidateQueries({queryKey:[`dashboard`]}),e.invalidateQueries({queryKey:[`activity`]})])}function s(e){return e.sections.flatMap(e=>e.activities)}function c(e){return s(e).filter(e=>e.visible).find(e=>e.completion!==`none`&&!e.completed)??null}export{o as a,i,c as n,a as r,s as t};
1
+ import{U as e,m as t,ut as n}from"./hooks-BBARn-DA.js";import{It as r}from"./index-B29bTBiJ.js";function i(n){return e({queryKey:[`course`,n],queryFn:()=>t.get(`/courses/${n}`),enabled:!!n})}function a(){return r()}function o(){let e=n();return t=>Promise.all([e.invalidateQueries({queryKey:[`course`,t]}),e.invalidateQueries({queryKey:[`courses`]}),e.invalidateQueries({queryKey:[`dashboard`]}),e.invalidateQueries({queryKey:[`activity`]})])}function s(e){return e.sections.flatMap(e=>e.activities)}function c(e){return s(e).filter(e=>e.visible).find(e=>e.completion!==`none`&&!e.completed)??null}export{o as a,i,c as n,a as r,s as t};
@@ -1 +1 @@
1
- import{A as e,At as t,C as n,Ct as r,F as i,Ot as a,Rt as o,S as s,St as c,T as l,Tt as u,_t as d,g as f,kt as p,v as m,w as h,xt as g}from"./index-DkBZ18Ts.js";import{H as _,M as v,U as y,_ as b,dt as x,ft as S,g as C,h as w,m as T,mt as E,x as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./ActivityEditor-LKK0d5Mb.js";import{t as A}from"./pencil-p0GQmIMo.js";import{T as j,a as M}from"./misc-DvgDEI3I.js";import{a as N,i as P,t as F}from"./context-B5ZaAO90.js";var I={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};I.node;var L=_(I),R=E(S(),1),z=x();function B(e){return y({queryKey:[`activity`,e],queryFn:()=>T.get(`/activities/${e}`),enabled:!!e})}function V({course:e,currentId:r,onNavigate:a}){let o=F(e).filter(e=>e.visible&&e.completion!==`none`),s=o.filter(e=>e.completed).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`border-b p-4`,children:[(0,z.jsxs)(t,{to:`/courses/${e.slug}`,onClick:a,className:`flex items-center gap-2.5 font-semibold hover:text-primary`,children:[(0,z.jsx)(`span`,{className:`size-3 shrink-0 rounded`,style:i(e.coverColor)}),(0,z.jsx)(`span`,{className:`truncate text-sm`,children:e.title})]}),e.progress!=null&&(0,z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,z.jsx)(M,{value:e.progress,tone:e.progress===100?`success`:`primary`}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s,` of `,o.length,` complete`]})]})]}),(0,z.jsx)(`nav`,{className:`ck-scrollbar flex-1 overflow-y-auto p-2`,children:e.sections.map((i,o)=>(0,z.jsxs)(`div`,{className:`mb-2`,children:[(0,z.jsxs)(`p`,{className:`px-2.5 pt-2 pb-1 text-[11px] font-semibold tracking-wider text-muted-foreground uppercase`,children:[o+1,`. `,i.title]}),i.activities.map(i=>{let o=i.id===r;return(0,z.jsxs)(t,{to:h(e.slug,i.id),onClick:a,className:b(`flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,o&&`bg-primary/10 font-medium text-primary hover:bg-primary/10 hover:text-primary`,!i.visible&&`opacity-60`),children:[e.myRole===`student`&&i.completion!==`none`?i.completed?(0,z.jsx)(g,{className:`size-4 shrink-0 text-success`}):(0,z.jsx)(O,{className:`size-4 shrink-0 opacity-40`}):(()=>{let e=n[i.type].icon;return(0,z.jsx)(e,{className:`size-4 shrink-0`})})(),(0,z.jsx)(`span`,{className:`truncate`,children:i.title})]},i.id)})]},i.id))})]})}function H({activity:e}){let t=N(),n=o({mutationFn:()=>e.completed?T.delete(`/activities/${e.id}/complete`):T.post(`/activities/${e.id}/complete`),onSuccess:async()=>{e.completed||j.success(`Nice work! Marked as done.`),await t(e.course.slug)},onError:e=>j.error(w(e))});return e.myRole!==`student`||e.completion!==`manual`?null:(0,z.jsxs)(C,{variant:e.completed?`outline`:`default`,onClick:()=>n.mutate(),loading:n.isPending,className:b(e.completed&&`border-success/40 text-success hover:bg-success/5`),children:[e.completed?(0,z.jsx)(g,{}):(0,z.jsx)(r,{}),e.completed?`Completed`:`Mark as done`]})}function U({activity:e}){if(!e.prev&&!e.next)return null;let n=(n,r)=>(0,z.jsxs)(t,{to:h(e.course.slug,n.id),className:b(`group flex items-center gap-3 rounded-xl border bg-card p-4 transition-all hover:border-primary/40 hover:shadow-md`,r===`next`&&`flex-row-reverse text-right`),children:[r===`prev`?(0,z.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}):(0,z.jsx)(a,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r===`prev`?`Previous`:`Next up`}),(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium group-hover:text-primary`,children:n.title})]})]});return(0,z.jsxs)(`div`,{className:`mt-10 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`div`,{children:e.prev&&n(e.prev,`prev`)}),(0,z.jsx)(`div`,{children:e.next&&n(e.next,`next`)})]})}function W({activity:e,actions:t}){let r=e.myRole===`student`;return(0,z.jsxs)(`div`,{className:`mb-7 flex flex-col gap-4 sm:flex-row sm:items-start`,children:[(0,z.jsx)(m,{type:e.type,size:`lg`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n[e.type].label,e.sectionTitle&&` · ${e.sectionTitle}`]}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-2xl font-semibold tracking-tight text-balance sm:text-[28px]`,children:e.title}),(0,z.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[e.dueAt&&(0,z.jsxs)(s,{variant:r&&v(e.dueAt)&&!e.completed?`danger`:`neutral`,children:[(0,z.jsx)(u,{}),` `,D(e.dueAt,!r||e.completed)]}),e.maxGrade!=null&&(0,z.jsxs)(s,{variant:`neutral`,children:[e.maxGrade,` points`]}),e.meta&&e.type!==`assignment`&&(0,z.jsx)(s,{variant:`neutral`,children:e.meta}),!e.visible&&(0,z.jsxs)(s,{variant:`warning`,children:[(0,z.jsx)(d,{}),` Hidden from students`]}),r&&e.completed&&(0,z.jsxs)(s,{variant:`success`,children:[(0,z.jsx)(g,{}),` Completed`]})]})]}),t&&(0,z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:t})]})}function G({activity:n,children:r,actions:a}){let{data:o}=P(n.course.slug),[s,u]=(0,R.useState)(!1),[d,p]=(0,R.useState)(!1),m=n.capabilities.includes(`course:manageContent`);return(0,z.jsxs)(`div`,{className:`flex`,children:[o&&(0,z.jsx)(`aside`,{className:`sticky top-14 hidden h-[calc(100dvh-3.5rem)] w-72 shrink-0 border-r bg-sidebar/50 xl:block`,children:(0,z.jsx)(V,{course:o,currentId:n.id})}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsxs)(f,{size:`default`,className:`max-w-5xl`,children:[(0,z.jsxs)(`nav`,{className:`mb-5 flex items-center gap-1.5 text-[13px] text-muted-foreground`,children:[o&&(0,z.jsx)(C,{variant:`ghost`,size:`icon-xs`,className:`mr-1 xl:hidden`,onClick:()=>u(!0),"aria-label":`Course outline`,children:(0,z.jsx)(L,{})}),(0,z.jsxs)(t,{to:`/courses/${n.course.slug}`,className:`flex min-w-0 items-center gap-1.5 hover:text-foreground`,children:[(0,z.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-[3px]`,style:i(n.course.coverColor)}),(0,z.jsx)(`span`,{className:`truncate`,children:n.course.title})]}),(0,z.jsx)(c,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate text-foreground`,children:n.title})]}),(0,z.jsx)(W,{activity:n,actions:(0,z.jsxs)(z.Fragment,{children:[a,m&&(0,z.jsxs)(C,{variant:`outline`,onClick:()=>p(!0),children:[(0,z.jsx)(A,{}),` Edit`]}),(0,z.jsx)(H,{activity:n})]})}),r,(0,z.jsx)(U,{activity:n})]})}),o&&(0,z.jsx)(l,{open:s,onOpenChange:u,children:(0,z.jsx)(e,{className:`w-80 bg-card`,children:(0,z.jsx)(V,{course:o,currentId:n.id,onNavigate:()=>u(!1)})})}),o&&d&&(0,z.jsx)(k,{course:o,open:d,onOpenChange:p,activityId:n.id})]})}export{B as n,G as t};
1
+ import{A as e,At as t,C as n,Ct as r,F as i,Ot as a,Rt as o,S as s,St as c,T as l,Tt as u,_t as d,g as f,kt as p,v as m,w as h,xt as g}from"./index-B29bTBiJ.js";import{H as _,M as v,U as y,_ as b,dt as x,ft as S,g as C,h as w,m as T,mt as E,x as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./ActivityEditor-BVSZUV8l.js";import{t as A}from"./pencil-p0GQmIMo.js";import{T as j,a as M}from"./misc-DvgDEI3I.js";import{a as N,i as P,t as F}from"./context-BLVW7NB7.js";var I={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};I.node;var L=_(I),R=E(S(),1),z=x();function B(e){return y({queryKey:[`activity`,e],queryFn:()=>T.get(`/activities/${e}`),enabled:!!e})}function V({course:e,currentId:r,onNavigate:a}){let o=F(e).filter(e=>e.visible&&e.completion!==`none`),s=o.filter(e=>e.completed).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`border-b p-4`,children:[(0,z.jsxs)(t,{to:`/courses/${e.slug}`,onClick:a,className:`flex items-center gap-2.5 font-semibold hover:text-primary`,children:[(0,z.jsx)(`span`,{className:`size-3 shrink-0 rounded`,style:i(e.coverColor)}),(0,z.jsx)(`span`,{className:`truncate text-sm`,children:e.title})]}),e.progress!=null&&(0,z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,z.jsx)(M,{value:e.progress,tone:e.progress===100?`success`:`primary`}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s,` of `,o.length,` complete`]})]})]}),(0,z.jsx)(`nav`,{className:`ck-scrollbar flex-1 overflow-y-auto p-2`,children:e.sections.map((i,o)=>(0,z.jsxs)(`div`,{className:`mb-2`,children:[(0,z.jsxs)(`p`,{className:`px-2.5 pt-2 pb-1 text-[11px] font-semibold tracking-wider text-muted-foreground uppercase`,children:[o+1,`. `,i.title]}),i.activities.map(i=>{let o=i.id===r;return(0,z.jsxs)(t,{to:h(e.slug,i.id),onClick:a,className:b(`flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,o&&`bg-primary/10 font-medium text-primary hover:bg-primary/10 hover:text-primary`,!i.visible&&`opacity-60`),children:[e.myRole===`student`&&i.completion!==`none`?i.completed?(0,z.jsx)(g,{className:`size-4 shrink-0 text-success`}):(0,z.jsx)(O,{className:`size-4 shrink-0 opacity-40`}):(()=>{let e=n[i.type].icon;return(0,z.jsx)(e,{className:`size-4 shrink-0`})})(),(0,z.jsx)(`span`,{className:`truncate`,children:i.title})]},i.id)})]},i.id))})]})}function H({activity:e}){let t=N(),n=o({mutationFn:()=>e.completed?T.delete(`/activities/${e.id}/complete`):T.post(`/activities/${e.id}/complete`),onSuccess:async()=>{e.completed||j.success(`Nice work! Marked as done.`),await t(e.course.slug)},onError:e=>j.error(w(e))});return e.myRole!==`student`||e.completion!==`manual`?null:(0,z.jsxs)(C,{variant:e.completed?`outline`:`default`,onClick:()=>n.mutate(),loading:n.isPending,className:b(e.completed&&`border-success/40 text-success hover:bg-success/5`),children:[e.completed?(0,z.jsx)(g,{}):(0,z.jsx)(r,{}),e.completed?`Completed`:`Mark as done`]})}function U({activity:e}){if(!e.prev&&!e.next)return null;let n=(n,r)=>(0,z.jsxs)(t,{to:h(e.course.slug,n.id),className:b(`group flex items-center gap-3 rounded-xl border bg-card p-4 transition-all hover:border-primary/40 hover:shadow-md`,r===`next`&&`flex-row-reverse text-right`),children:[r===`prev`?(0,z.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}):(0,z.jsx)(a,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r===`prev`?`Previous`:`Next up`}),(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium group-hover:text-primary`,children:n.title})]})]});return(0,z.jsxs)(`div`,{className:`mt-10 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`div`,{children:e.prev&&n(e.prev,`prev`)}),(0,z.jsx)(`div`,{children:e.next&&n(e.next,`next`)})]})}function W({activity:e,actions:t}){let r=e.myRole===`student`;return(0,z.jsxs)(`div`,{className:`mb-7 flex flex-col gap-4 sm:flex-row sm:items-start`,children:[(0,z.jsx)(m,{type:e.type,size:`lg`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n[e.type].label,e.sectionTitle&&` · ${e.sectionTitle}`]}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-2xl font-semibold tracking-tight text-balance sm:text-[28px]`,children:e.title}),(0,z.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[e.dueAt&&(0,z.jsxs)(s,{variant:r&&v(e.dueAt)&&!e.completed?`danger`:`neutral`,children:[(0,z.jsx)(u,{}),` `,D(e.dueAt,!r||e.completed)]}),e.maxGrade!=null&&(0,z.jsxs)(s,{variant:`neutral`,children:[e.maxGrade,` points`]}),e.meta&&e.type!==`assignment`&&(0,z.jsx)(s,{variant:`neutral`,children:e.meta}),!e.visible&&(0,z.jsxs)(s,{variant:`warning`,children:[(0,z.jsx)(d,{}),` Hidden from students`]}),r&&e.completed&&(0,z.jsxs)(s,{variant:`success`,children:[(0,z.jsx)(g,{}),` Completed`]})]})]}),t&&(0,z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:t})]})}function G({activity:n,children:r,actions:a}){let{data:o}=P(n.course.slug),[s,u]=(0,R.useState)(!1),[d,p]=(0,R.useState)(!1),m=n.capabilities.includes(`course:manageContent`);return(0,z.jsxs)(`div`,{className:`flex`,children:[o&&(0,z.jsx)(`aside`,{className:`sticky top-14 hidden h-[calc(100dvh-3.5rem)] w-72 shrink-0 border-r bg-sidebar/50 xl:block`,children:(0,z.jsx)(V,{course:o,currentId:n.id})}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsxs)(f,{size:`default`,className:`max-w-5xl`,children:[(0,z.jsxs)(`nav`,{className:`mb-5 flex items-center gap-1.5 text-[13px] text-muted-foreground`,children:[o&&(0,z.jsx)(C,{variant:`ghost`,size:`icon-xs`,className:`mr-1 xl:hidden`,onClick:()=>u(!0),"aria-label":`Course outline`,children:(0,z.jsx)(L,{})}),(0,z.jsxs)(t,{to:`/courses/${n.course.slug}`,className:`flex min-w-0 items-center gap-1.5 hover:text-foreground`,children:[(0,z.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-[3px]`,style:i(n.course.coverColor)}),(0,z.jsx)(`span`,{className:`truncate`,children:n.course.title})]}),(0,z.jsx)(c,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate text-foreground`,children:n.title})]}),(0,z.jsx)(W,{activity:n,actions:(0,z.jsxs)(z.Fragment,{children:[a,m&&(0,z.jsxs)(C,{variant:`outline`,onClick:()=>p(!0),children:[(0,z.jsx)(A,{}),` Edit`]}),(0,z.jsx)(H,{activity:n})]})}),r,(0,z.jsx)(U,{activity:n})]})}),o&&(0,z.jsx)(l,{open:s,onOpenChange:u,children:(0,z.jsx)(e,{className:`w-80 bg-card`,children:(0,z.jsx)(V,{course:o,currentId:n.id,onNavigate:()=>u(!1)})})}),o&&d&&(0,z.jsx)(k,{course:o,open:d,onOpenChange:p,activityId:n.id})]})}export{B as n,G as t};