coursekit-lms 0.1.1 → 0.2.0
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.
- package/CHANGELOG.md +82 -1
- package/README.md +128 -27
- package/dist/cli/index.js +7140 -1634
- package/dist/cli/index.js.map +1 -1
- package/dist/server/index.js +7129 -1656
- package/dist/server/index.js.map +1 -1
- package/dist/types/server/config.d.ts +4 -0
- package/dist/types/server/db/migrations/002_email.d.ts +8 -0
- package/dist/types/server/db/migrations/003_groups_cohorts.d.ts +7 -0
- package/dist/types/server/db/migrations/004_completion_badges.d.ts +8 -0
- package/dist/types/server/db/migrations/005_question_bank.d.ts +11 -0
- package/dist/types/server/db/migrations/006_grade_categories.d.ts +11 -0
- package/dist/types/server/db/schema-completion.d.ts +79 -0
- package/dist/types/server/db/schema.d.ts +165 -5
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/lib/events.d.ts +105 -0
- package/dist/types/server/routes/badges.d.ts +4 -0
- package/dist/types/server/routes/certificates.d.ts +3 -0
- package/dist/types/server/routes/cohorts.d.ts +6 -0
- package/dist/types/server/routes/completion.d.ts +4 -0
- package/dist/types/server/routes/email.d.ts +13 -0
- package/dist/types/server/routes/grade-categories.d.ts +4 -0
- package/dist/types/server/routes/groups.d.ts +4 -0
- package/dist/types/server/routes/question-bank.d.ts +4 -0
- package/dist/types/server/seed/demo-completion.d.ts +2 -0
- package/dist/types/server/seed/demo-email.d.ts +2 -0
- package/dist/types/server/seed/demo-grade-categories.d.ts +6 -0
- package/dist/types/server/seed/demo-groups.d.ts +6 -0
- package/dist/types/server/seed/demo-question-bank.d.ts +20 -0
- package/dist/types/server/seed/demo.d.ts +2 -1
- package/dist/types/server/services/badges.d.ts +39 -0
- package/dist/types/server/services/certificates.d.ts +42 -0
- package/dist/types/server/services/cohorts.d.ts +64 -0
- package/dist/types/server/services/completion.d.ts +63 -0
- package/dist/types/server/services/course-total.d.ts +107 -0
- package/dist/types/server/services/email/config.d.ts +55 -0
- package/dist/types/server/services/email/digests.d.ts +57 -0
- package/dist/types/server/services/email/outbox.d.ts +61 -0
- package/dist/types/server/services/email/preferences.d.ts +25 -0
- package/dist/types/server/services/email/service.d.ts +116 -0
- package/dist/types/server/services/email/templates.d.ts +74 -0
- package/dist/types/server/services/email/tokens.d.ts +11 -0
- package/dist/types/server/services/email/transport.d.ts +29 -0
- package/dist/types/server/services/enrolments.d.ts +32 -0
- package/dist/types/server/services/grade-categories.d.ts +31 -0
- package/dist/types/server/services/gradebook.d.ts +18 -0
- package/dist/types/server/services/groups.d.ts +90 -0
- package/dist/types/server/services/notify.d.ts +4 -1
- package/dist/types/server/services/question-bank.d.ts +53 -0
- package/dist/types/server/services/question-types.d.ts +146 -0
- package/dist/types/server/services/quiz-slots.d.ts +33 -0
- package/dist/types/server/services/quiz.d.ts +45 -14
- package/dist/types/shared/completion.d.ts +214 -0
- package/dist/types/shared/email.d.ts +117 -0
- package/dist/types/shared/grades.d.ts +18 -0
- package/dist/types/shared/groups.d.ts +17 -0
- package/dist/types/shared/permissions.d.ts +1 -1
- package/dist/types/shared/types.d.ts +268 -2
- package/dist/web/assets/{ActivityEditor-BVSZUV8l.js → ActivityEditor-BNG3aTQa.js} +2 -2
- package/dist/web/assets/ActivityPage-i0XHYD2Q.js +1 -0
- package/dist/web/assets/AdminBadgesPage-DvpxIg1P.js +1 -0
- package/dist/web/assets/AdminCohortsPage-B5PWBkjp.js +3 -0
- package/dist/web/assets/AdminCoursesPage-Dm1ECbS-.js +1 -0
- package/dist/web/assets/AdminEmailPage-D3E_Db1_.js +1 -0
- package/dist/web/assets/AdminLayout-BVeduyCQ.js +1 -0
- package/dist/web/assets/{AdminOverviewPage-DnTrdGbr.js → AdminOverviewPage-BaCKvhgr.js} +1 -1
- package/dist/web/assets/{AdminSettingsPage-B82cX8xU.js → AdminSettingsPage-B5Ag5K15.js} +1 -1
- package/dist/web/assets/AdminUsersPage-BVCG65EK.js +1 -0
- package/dist/web/assets/{AnnouncementsPage-BKW30k0Z.js → AnnouncementsPage-C0OAzyvW.js} +1 -1
- package/dist/web/assets/BadgePage-B3Ecudas.js +1 -0
- package/dist/web/assets/CalendarPage-CEks5F4m.js +1 -0
- package/dist/web/assets/{CatalogPage-BiMgSSBR.js → CatalogPage-e7lVtwUN.js} +1 -1
- package/dist/web/assets/CertificatePage-_eSGt8R-.js +9 -0
- package/dist/web/assets/CompletionPage-Dxp-ulA_.js +1 -0
- package/dist/web/assets/CourseBadgesPage-Vi3P1Lnc.js +1 -0
- package/dist/web/assets/CourseContentPage-IFlhVsO5.js +1 -0
- package/dist/web/assets/CourseLayout-BqwXol8L.js +1 -0
- package/dist/web/assets/CourseSettingsPage-BIagLirb.js +1 -0
- package/dist/web/assets/CreateCoursePage-BBcdiTtz.js +1 -0
- package/dist/web/assets/{DiscussionPage-CWwVpFQV.js → DiscussionPage-C23QoCSw.js} +1 -1
- package/dist/web/assets/GradebookSetupPage-a5GH4xIk.js +1 -0
- package/dist/web/assets/GradesPage-CY6MtJxs.js +1 -0
- package/dist/web/assets/GroupsPage-DS3HFeC4.js +1 -0
- package/dist/web/assets/{MyCoursesPage-Dd-Oaygv.js → MyCoursesPage-Ckj-1SCA.js} +1 -1
- package/dist/web/assets/{NotFoundPage-BRquC7-l.js → NotFoundPage-BmwVsGAy.js} +1 -1
- package/dist/web/assets/NotificationsPage-DBRM37F1.js +1 -0
- package/dist/web/assets/ParticipantsPage-DV4Mjfxo.js +1 -0
- package/dist/web/assets/ProfilePage-BqG55_02.js +1 -0
- package/dist/web/assets/QuestionAnswer-CJIoWSz2.js +1 -0
- package/dist/web/assets/QuestionBankPage-BkI44c4K.js +1 -0
- package/dist/web/assets/QuizAttemptPage-DQVfbLKI.js +1 -0
- package/dist/web/assets/QuizEditorPage-muk-KVG1.js +1 -0
- package/dist/web/assets/SubmissionsPage-Dx97JOzE.js +1 -0
- package/dist/web/assets/UnsubscribePage-BPLiTiaG.js +1 -0
- package/dist/web/assets/VerifyCertificatePage-Cw9iXN3C.js +1 -0
- package/dist/web/assets/achievements-DaIfUTKU.js +1 -0
- package/dist/web/assets/{arrow-up-LHDup5m4.js → arrow-up-lI30bvj5.js} +1 -1
- package/dist/web/assets/badge-art-QPo-pYql.js +1 -0
- package/dist/web/assets/badge-card-ByT0wR6q.js +1 -0
- package/dist/web/assets/badge-dialog-p2zTk4h0.js +1 -0
- package/dist/web/assets/{ban-D3Vsxg_g.js → ban-DEiI8npI.js} +1 -1
- package/dist/web/assets/bank-S3XEFPfe.js +3 -0
- package/dist/web/assets/bell-off-Bo2RE0kn.js +1 -0
- package/dist/web/assets/calendar-range-Cfg-P4Md.js +1 -0
- package/dist/web/assets/certificate-sheet-DzW0lfzR.js +2 -0
- package/dist/web/assets/chevron-left-Bu6IJANV.js +1 -0
- package/dist/web/assets/circle-dashed-D34ZjnSx.js +1 -0
- package/dist/web/assets/clock-DPBmdKAi.js +1 -0
- package/dist/web/assets/cohorts-DL0Dsxva.js +1 -0
- package/dist/web/assets/completion-2z7I-ypT.js +1 -0
- package/dist/web/assets/contact-NCWQa7wc.js +1 -0
- package/dist/web/assets/{context-BLVW7NB7.js → context-D8W_QqNi.js} +1 -1
- package/dist/web/assets/{copy-Bxxjq6zo.js → copy-B5IKRMFo.js} +1 -1
- package/dist/web/assets/download-BrtK5sVk.js +1 -0
- package/dist/web/assets/{ellipsis-c2POIN-Y.js → ellipsis-BDmYLoyn.js} +1 -1
- package/dist/web/assets/email-BZ3kGs-R.js +1 -0
- package/dist/web/assets/flag-DOzXVys0.js +1 -0
- package/dist/web/assets/folder-input-M2p_UJZX.js +1 -0
- package/dist/web/assets/{library-3WG9oLCb.js → folder-tree-B-DoLXMB.js} +1 -1
- package/dist/web/assets/frame-DZh5g5b3.js +1 -0
- package/dist/web/assets/globe-DDTr53UY.js +1 -0
- package/dist/web/assets/grades-ogaD0MDO.js +1 -0
- package/dist/web/assets/groups-CrYV_AFp.js +1 -0
- package/dist/web/assets/{hooks-BBARn-DA.js → hooks-EFhyJ5yU.js} +1 -1
- package/dist/web/assets/hourglass-BKca6Cje.js +1 -0
- package/dist/web/assets/inbox-x1U4YU-c.js +1 -0
- package/dist/web/assets/index-BdPmMS6n.css +2 -0
- package/dist/web/assets/index-CEZdqKdi.js +50 -0
- package/dist/web/assets/{key-round-B_KI-brR.js → key-round-fzvV-etw.js} +1 -1
- package/dist/web/assets/library-Bcm33ouq.js +1 -0
- package/dist/web/assets/lightbulb-CjSpJ1_v.js +1 -0
- package/dist/web/assets/{lock-BjbqwA_0.js → lock-C2edVDOc.js} +1 -1
- package/dist/web/assets/mail-CQ9yiBph.js +1 -0
- package/dist/web/assets/mail-x-B6oBqlcw.js +1 -0
- package/dist/web/assets/{markdown-ykrkPMbn.js → markdown-HNlXovsL.js} +3 -3
- package/dist/web/assets/message-square-text-wvO9_guT.js +1 -0
- package/dist/web/assets/{misc-DvgDEI3I.js → misc-CyGhN6HT.js} +1 -1
- package/dist/web/assets/{pencil-p0GQmIMo.js → pencil-DFUpj3YP.js} +1 -1
- package/dist/web/assets/{pin-DlYC3uec.js → pin-DNUQ6-WX.js} +1 -1
- package/dist/web/assets/revoke-dialog-DjBKaFTV.js +1 -0
- package/dist/web/assets/rotate-ccw-yBj9Ri49.js +1 -0
- package/dist/web/assets/scroll-text-RmPlZi3F.js +1 -0
- package/dist/web/assets/{send-mxSHcdcD.js → send-BnVkFV8w.js} +1 -1
- package/dist/web/assets/{settings-DRKWzSHN.js → settings-BxdCrDf8.js} +1 -1
- package/dist/web/assets/shield-x-RpNHS0o8.js +1 -0
- package/dist/web/assets/shuffle-C1aB_4dp.js +1 -0
- package/dist/web/assets/target-G9Q_WQLB.js +1 -0
- package/dist/web/assets/trophy-BFFngFEh.js +1 -0
- package/dist/web/assets/user-minus-CkOPT3ak.js +1 -0
- package/dist/web/assets/users-round-CNhv0Whm.js +1 -0
- package/dist/web/index.html +4 -4
- package/package.json +6 -1
- package/dist/web/assets/ActivityPage-DPmSV_mU.js +0 -1
- package/dist/web/assets/AdminCoursesPage-uaSHNtzf.js +0 -1
- package/dist/web/assets/AdminLayout-DqoShZGn.js +0 -1
- package/dist/web/assets/AdminUsersPage-3d2F9AEl.js +0 -1
- package/dist/web/assets/CalendarPage-CLRWyTNT.js +0 -1
- package/dist/web/assets/CourseContentPage-BIDH0UbG.js +0 -1
- package/dist/web/assets/CourseLayout-ql01LEmj.js +0 -1
- package/dist/web/assets/CourseSettingsPage-CReoPqOa.js +0 -1
- package/dist/web/assets/CreateCoursePage-DFCHlq5M.js +0 -1
- package/dist/web/assets/GradesPage-Bu5vphcG.js +0 -1
- package/dist/web/assets/NotificationsPage-LJvqb6Dj.js +0 -1
- package/dist/web/assets/ParticipantsPage-wFxiphna.js +0 -1
- package/dist/web/assets/ProfilePage-CzfhacAX.js +0 -1
- package/dist/web/assets/QuizAttemptPage-CEAV6wAL.js +0 -1
- package/dist/web/assets/QuizEditorPage-DS_czQVM.js +0 -3
- package/dist/web/assets/SubmissionsPage-CQjcx09G.js +0 -1
- package/dist/web/assets/chevron-left-D6IMQD6N.js +0 -1
- package/dist/web/assets/frame-CGabirLa.js +0 -1
- package/dist/web/assets/index-B29bTBiJ.js +0 -50
- package/dist/web/assets/index-WxCvsbJq.css +0 -2
- package/dist/web/assets/message-square-text-fe24gbEU.js +0 -1
- package/dist/web/assets/trophy-Cch2iF1m.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ft as e,It as t,wt as n}from"./index-CEZdqKdi.js";import{dt as r,g as i,r as a}from"./hooks-EFhyJ5yU.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)(t,{to:`/`,children:[(0,o.jsx)(e,{}),` Dashboard`]})}),(0,o.jsx)(i,{asChild:!0,children:(0,o.jsxs)(t,{to:`/catalog`,children:[(0,o.jsx)(n,{}),` Explore courses`]})})]})]})})}export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Gt as e,Ht as t,It as n,_ as r,a as i,g as a,t as o,v as s}from"./index-CEZdqKdi.js";import{D as c,H as l,T as u,_ as d,dt as f,g as p,m,r as h,ut as g}from"./hooks-EFhyJ5yU.js";import{t as _}from"./bell-off-Bo2RE0kn.js";import{t as v}from"./mail-CQ9yiBph.js";import{c as y,n as b,t as x}from"./misc-CyGhN6HT.js";var S={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`}]]};S.node;var C=l(S),w=f();function T(){h(`Notifications`);let{data:l,isLoading:f,error:S,refetch:T}=s(),E=g(),D=t(),O=e({mutationFn:e=>m.post(`/notifications/read`,e?{ids:e}:{}),onSuccess:()=>E.invalidateQueries({queryKey:[`notifications`]})});return(0,w.jsxs)(r,{size:`narrow`,children:[(0,w.jsx)(i,{title:`Notifications`,description:`Grades, announcements and replies from your courses.`,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p,{asChild:!0,variant:`ghost`,children:(0,w.jsxs)(n,{to:`/profile?section=email`,children:[(0,w.jsx)(v,{}),` Email settings`]})}),!!l?.unreadCount&&(0,w.jsxs)(p,{variant:`outline`,onClick:()=>O.mutate(void 0),loading:O.isPending,children:[(0,w.jsx)(C,{}),` Mark all as read`]})]})}),S?(0,w.jsx)(b,{error:S,onRetry:()=>T()}):f?(0,w.jsx)(y,{className:`h-96`}):l.items.length===0?(0,w.jsx)(x,{icon:_,title:`No notifications`,description:`You'll see updates from your courses here.`}):(0,w.jsx)(o,{className:`divide-y overflow-hidden`,children:l.items.map(e=>(0,w.jsxs)(`button`,{onClick:()=>{e.readAt||O.mutate([e.id]),e.link&&D(e.link)},className:d(`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,w.jsx)(a,{type:e.type}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`span`,{className:d(`block text-sm`,!e.readAt&&`font-semibold`),children:e.title}),e.body&&(0,w.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.body}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,title:u(e.createdAt),children:c(e.createdAt)})]}),!e.readAt&&(0,w.jsx)(`span`,{className:`mt-1.5 size-2.5 shrink-0 rounded-full bg-primary`,"aria-label":`Unread`})]},e.id))})]})}export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,Gt as o,H as s,It as c,J as l,M as u,O as d,U as f,V as p,W as ee,_ as te,dt as m,f as h,gt as g,k as _,kt as ne,l as v,lt as re,m as y,nt as b,t as ie,tt as ae,u as oe,z as se}from"./index-CEZdqKdi.js";import{D as x,U as S,dt as C,ft as w,g as T,h as E,m as D,mt as O,r as k,s as ce,u as A,ut as j,w as M}from"./hooks-EFhyJ5yU.js";import{t as le}from"./ban-DEiI8npI.js";import{t as ue}from"./ellipsis-BDmYLoyn.js";import{t as de}from"./user-minus-CkOPT3ak.js";import{E as N,a as fe,c as P,n as pe,s as F,t as I}from"./misc-CyGhN6HT.js";import{n as L,r as R}from"./cohorts-DL0Dsxva.js";import{n as z,o as me,t as B}from"./groups-CrYV_AFp.js";import{n as V,t as H}from"./achievements-DaIfUTKU.js";import{r as U}from"./badge-art-QPo-pYql.js";import{a as he,r as ge}from"./context-D8W_QqNi.js";var W=O(w(),1),G=C(),K=null,q=new Set,J={set(e){K=e;for(let e of q)e()},subscribe(e){return q.add(e),()=>q.delete(e)},get:()=>K};function _e({course:e,participant:t}){return e.capabilities.includes(`badges:award`)?(0,G.jsxs)(s,{onSelect:()=>J.set(t),children:[(0,G.jsx)(g,{}),` Badges…`]}):null}function Y({badge:e,course:t,participant:n}){let r=j(),i=()=>Promise.all([r.invalidateQueries({queryKey:[`course`,t.slug,`badges`]}),r.invalidateQueries({queryKey:H.badge(e.id)})]),a=o({mutationFn:()=>e.earnedAt?D.delete(`/badges/${e.id}/awards/${n.user.id}`):D.post(`/badges/${e.id}/awards`,{userIds:[n.user.id]}),onSuccess:async()=>{N.success(e.earnedAt?`Revoked “${e.name}” from ${n.user.name}`:`Awarded “${e.name}” to ${n.user.name}`),await i()},onError:e=>N.error(E(e))});return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,children:[(0,G.jsx)(U,{icon:e.icon,color:e.color,size:40,locked:!e.earnedAt}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,G.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.earnedAt?`Awarded ${M(e.earnedAt,{year:`numeric`})}`:V(e)})]}),(0,G.jsx)(T,{size:`sm`,variant:e.earnedAt?`ghost`:`outline`,className:e.earnedAt?`text-destructive hover:bg-destructive/10`:void 0,loading:a.isPending,onClick:()=>a.mutate(),"aria-label":`${e.earnedAt?`Revoke`:`Award`} ${e.name}`,children:e.earnedAt?`Revoke`:`Award`})]})}function X({course:e,participant:t}){let{data:n,isLoading:r}=S({queryKey:[`course`,e.slug,`badges`,`for`,t.user.id],queryFn:()=>D.get(`/courses/${e.id}/badges?for=${t.user.id}`)});return r||!n?(0,G.jsx)(P,{className:`h-32`}):n.length===0?(0,G.jsxs)(`div`,{className:`rounded-xl border border-dashed px-4 py-8 text-center text-sm text-muted-foreground`,children:[`This course has no badges yet.`,e.capabilities.includes(`badges:manage`)&&(0,G.jsx)(T,{asChild:!0,size:`sm`,className:`mt-3 flex w-fit mx-auto`,children:(0,G.jsxs)(c,{to:`/courses/${e.slug}/badges`,onClick:()=>J.set(null),children:[(0,G.jsx)(m,{}),` Create a badge`]})})]}):(0,G.jsx)(`ul`,{className:`divide-y`,children:n.map(n=>(0,G.jsx)(Y,{badge:n,course:e,participant:t},n.id))})}function ve({course:e}){let n=(0,W.useSyncExternalStore)(J.subscribe,J.get);return(0,W.useEffect)(()=>()=>J.set(null),[]),(0,G.jsx)(a,{open:!!n,onOpenChange:e=>!e&&J.set(null),children:n&&(0,G.jsxs)(d,{children:[(0,G.jsx)(t,{icon:(0,G.jsx)(g,{className:`size-5`}),title:`Badges for ${n.user.name}`,description:`Award or revoke this course’s badges. They get a notification when they receive one.`}),(0,G.jsx)(i,{children:(0,G.jsx)(X,{course:e,participant:n})}),(0,G.jsx)(_,{children:(0,G.jsx)(T,{variant:`outline`,onClick:()=>J.set(null),children:`Done`})})]})})}var ye={teacher:`violet`,assistant:`info`,student:`neutral`};function be({open:e,onOpenChange:n,courseId:r,onDone:s}){let[c,l]=(0,W.useState)(``),[u,f]=(0,W.useState)(`student`),p=o({mutationFn:()=>D.post(`/courses/${r}/participants`,{emails:c.split(/[\s,;]+/).filter(Boolean),role:u}),onSuccess:e=>{e.added&&N.success(`Enrolled ${e.added} ${e.added===1?`person`:`people`}`),e.alreadyEnrolled.length&&N.info(`Already enrolled: ${e.alreadyEnrolled.join(`, `)}`),e.notFound.length&&N.warning(`No account found for: ${e.notFound.join(`, `)}`),l(``),s(),n(!1)},onError:e=>N.error(E(e))});return(0,G.jsx)(a,{open:e,onOpenChange:n,children:(0,G.jsx)(d,{children:(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p.mutate()},children:[(0,G.jsx)(t,{icon:(0,G.jsx)(b,{className:`size-5`}),title:`Enrol people`,description:`Add people who already have an account on this site.`}),(0,G.jsxs)(i,{className:`space-y-4`,children:[(0,G.jsx)(v,{label:`Email addresses`,hint:`Separate with commas, spaces or new lines.`,children:e=>(0,G.jsx)(y,{...e,rows:5,autoFocus:!0,value:c,onChange:e=>l(e.target.value),placeholder:`ada@school.edu, grace@school.edu`})}),(0,G.jsx)(v,{label:`Role`,children:e=>(0,G.jsxs)(h,{...e,value:u,onChange:e=>f(e.target.value),children:[(0,G.jsx)(`option`,{value:`student`,children:`Student`}),(0,G.jsx)(`option`,{value:`assistant`,children:`Teaching assistant`}),(0,G.jsx)(`option`,{value:`teacher`,children:`Teacher`})]})})]}),(0,G.jsxs)(_,{children:[(0,G.jsx)(T,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,G.jsx)(T,{type:`submit`,loading:p.isPending,disabled:!c.trim(),children:`Enrol`})]})]})})})}function Z(){let{course:t,can:i}=ge();k(`Participants · ${t.title}`);let a=ce(),c=j(),d=he(),m=e(),h=i(`course:manageParticipants`),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(`all`),[C,w]=(0,W.useState)(!1),O=me(t.id),M=[`participants`,t.id],{data:V,isLoading:H,error:U,refetch:K}=S({queryKey:M,queryFn:()=>D.get(`/courses/${t.id}/participants`)}),q=()=>Promise.all([c.invalidateQueries({queryKey:M}),d(t.slug)]),J=o({mutationFn:({id:e,body:n})=>D.patch(`/courses/${t.id}/participants/${e}`,n),onSuccess:q,onError:e=>N.error(E(e))}),Y=o({mutationFn:e=>D.delete(`/courses/${t.id}/participants/${e}`),onSuccess:async()=>{await q(),N.success(`Removed from the course`)},onError:e=>N.error(E(e))}),X=(0,W.useMemo)(()=>{let e=g.trim().toLowerCase();return(V??[]).filter(t=>(v===`all`||t.role===v)&&O.matches(t.user.id)&&(!e||t.user.name.toLowerCase().includes(e)||t.user.email?.toLowerCase().includes(e)))},[V,g,v,O.matches]),Z=e=>(V??[]).filter(t=>t.role===e).length,Q=!!V?.some(e=>e.user.email),$=!!V?.some(e=>e.groups?.length);return(0,G.jsxs)(te,{children:[(0,G.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,G.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,G.jsx)(re,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(oe,{value:g,onChange:e=>_(e.target.value),placeholder:`Search participants`,className:`pl-9`,"aria-label":`Search participants`})]}),(0,G.jsx)(F,{value:v,onChange:y,options:[{value:`all`,label:`Everyone`,count:V?.length},{value:`teacher`,label:`Teachers`,count:Z(`teacher`)+Z(`assistant`)},{value:`student`,label:`Students`,count:Z(`student`)}]}),(0,G.jsx)(z,{filter:O}),h&&(0,G.jsxs)(T,{className:`sm:ml-auto`,onClick:()=>w(!0),children:[(0,G.jsx)(b,{}),` Enrol people`]}),h&&(0,G.jsx)(L,{course:t,onLinked:q})]}),h&&(0,G.jsx)(R,{course:t,onChange:q}),U?(0,G.jsx)(pe,{error:U,onRetry:()=>K()}):H?(0,G.jsx)(P,{className:`h-96`}):X.length===0?(0,G.jsx)(I,{icon:ae,title:`No participants found`}):(0,G.jsx)(ie,{className:`overflow-hidden`,children:(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{className:`border-b bg-muted/40 text-left text-xs font-medium text-muted-foreground`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,G.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Role`}),$&&(0,G.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Groups`}),Q&&(0,G.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Progress`}),Q&&(0,G.jsx)(`th`,{className:`hidden px-3 py-3 font-medium whitespace-nowrap lg:table-cell`,children:`Last access`}),h&&(0,G.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y`,children:X.map(e=>(0,G.jsxs)(`tr`,{className:`transition-colors hover:bg-accent/30`,children:[(0,G.jsx)(`td`,{className:`px-5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(u,{user:e.user,size:`sm`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`p`,{className:`truncate font-medium`,children:[e.user.name,e.user.id===a?.id&&(0,G.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`(you)`})]}),e.user.email&&(0,G.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.user.email}),$&&(0,G.jsx)(B,{groups:e.groups,className:`mt-1 md:hidden`})]})]})}),(0,G.jsx)(`td`,{className:`px-3 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(r,{variant:ye[e.role],children:A[e.role]}),e.status===`suspended`&&(0,G.jsx)(r,{variant:`danger`,children:`Suspended`})]})}),$&&(0,G.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:(0,G.jsx)(B,{groups:e.groups})}),Q&&(0,G.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:e.progress==null?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`–`}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(fe,{value:e.progress,className:`w-24`,tone:e.progress===100?`success`:`primary`}),(0,G.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[e.progress,`%`]})]})}),Q&&(0,G.jsx)(`td`,{className:`hidden px-3 py-3 whitespace-nowrap text-muted-foreground lg:table-cell`,children:e.lastAccessAt?x(e.lastAccessAt):`Never`}),h&&(0,G.jsx)(`td`,{className:`px-3 py-3 text-right`,children:e.user.id!==a?.id&&(0,G.jsxs)(se,{children:[(0,G.jsx)(l,{asChild:!0,children:(0,G.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${e.user.name}`,children:(0,G.jsx)(ue,{})})}),(0,G.jsxs)(p,{children:[(0,G.jsx)(f,{children:`Role`}),[`student`,`assistant`,`teacher`].map(t=>(0,G.jsx)(n,{checked:e.role===t,onSelect:()=>J.mutate({id:e.enrolmentId,body:{role:t}}),children:A[t]},t)),(0,G.jsx)(ee,{}),(0,G.jsx)(_e,{course:t,participant:e}),(0,G.jsxs)(s,{onSelect:()=>J.mutate({id:e.enrolmentId,body:{status:e.status===`active`?`suspended`:`active`}}),children:[e.status===`active`?(0,G.jsx)(le,{}):(0,G.jsx)(ne,{}),e.status===`active`?`Suspend enrolment`:`Reactivate enrolment`]}),(0,G.jsxs)(s,{destructive:!0,onSelect:async()=>{await m({title:`Remove ${e.user.name}?`,description:`They lose access to the course. Their grades are kept and come back if they re-enrol.`,confirmLabel:`Remove`,destructive:!0})&&Y.mutate(e.enrolmentId)},children:[(0,G.jsx)(de,{}),` Remove from course`]})]})]})})]},e.enrolmentId))})]})})}),(0,G.jsx)(be,{open:C,onOpenChange:w,courseId:t.id,onDone:q}),(0,G.jsx)(ve,{course:t})]})}export{Z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,C as t,Gt as n,I as r,It as i,M as a,Ot as o,R as s,Rt as c,_ as l,a as u,at as d,c as f,ft as p,gt as m,l as h,m as g,n as _,ot as v,p as y,t as b,u as x}from"./index-CEZdqKdi.js";import{H as S,U as C,_ as w,d as T,dt as E,ft as D,g as O,h as k,l as A,m as j,mt as M,r as N,s as P,ut as F,w as I}from"./hooks-EFhyJ5yU.js";import{t as L}from"./key-round-fzvV-etw.js";import{E as R,c as z,n as B}from"./misc-CyGhN6HT.js";import{t as V}from"./bell-off-Bo2RE0kn.js";import{t as ee}from"./calendar-range-Cfg-P4Md.js";import{t as te}from"./mail-CQ9yiBph.js";import{i as ne,r as re}from"./badge-art-QPo-pYql.js";import{t as H}from"./email-BZ3kGs-R.js";import{t as U}from"./scroll-text-RmPlZi3F.js";import{t as W}from"./achievements-DaIfUTKU.js";var G={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`}]]};G.node;var K=S(G),q={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};q.node;var J=S(q),Y={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`}]]};Y.node;var X=S(Y),Z=M(D(),1),Q=E(),$=[`email`,`preferences`];function ie(e){let t=e=>new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(e)),n=new Intl.DateTimeFormat(void 0,{weekday:`long`}).format(new Date(e.weekly));return{daily:`One summary a day, around ${t(e.daily)}`,weekly:`One summary every ${n}, around ${t(e.weekly)}`}}function ae(){let t=F(),[r]=c(),i=(0,Z.useRef)(null),{data:a,isLoading:o,error:s,refetch:l}=C({queryKey:$,queryFn:()=>j.get(`/email/preferences`)}),[u,d]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),h=!!a;(0,Z.useEffect)(()=>{h&&r.get(`section`)===`email`&&i.current?.scrollIntoView({block:`start`})},[h,r]);let g=n({mutationFn:e=>j.put(`/email/preferences`,e),onSuccess:e=>{t.setQueryData($,e),d(null),m(null),R.success(`Email preferences saved`)},onError:e=>R.error(k(e))}),v=(0,Q.jsx)(_,{title:`Email notifications`,description:`Choose whether we email you about activity in your courses, and how often.`,icon:(0,Q.jsx)(te,{className:`size-4.5`})});if(s)return(0,Q.jsxs)(b,{ref:i,id:`email`,className:`scroll-mt-20`,children:[v,(0,Q.jsx)(`div`,{className:`px-5 pb-5`,children:(0,Q.jsx)(B,{error:s,onRetry:()=>l()})})]});if(o||!a)return(0,Q.jsxs)(b,{ref:i,id:`email`,className:`scroll-mt-20`,children:[v,(0,Q.jsxs)(`div`,{className:`space-y-3 px-5 pb-5`,children:[(0,Q.jsx)(z,{className:`h-28`}),(0,Q.jsx)(z,{className:`h-40`})]})]});let x=u??a.frequency,S=p??a.disabledCategories,w=x!==a.frequency||S.length!==a.disabledCategories.length||S.some(e=>!a.disabledCategories.includes(e)),T=ie(a.nextDigests),E=x===`off`;return(0,Q.jsxs)(b,{ref:i,id:`email`,className:`scroll-mt-20`,children:[v,(0,Q.jsxs)(`form`,{className:`space-y-5 px-5 pb-5`,onSubmit:e=>{e.preventDefault(),g.mutate({frequency:x,disabledCategories:S})},children:[!a.deliveryEnabled&&(0,Q.jsxs)(`p`,{className:`flex gap-2.5 rounded-lg bg-muted px-3.5 py-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(J,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:`This site isn't sending email yet, so for now you'll see notifications here in the app. Your choices apply as soon as email is turned on.`})]}),(0,Q.jsxs)(`fieldset`,{className:`space-y-2.5`,children:[(0,Q.jsx)(`legend`,{className:`mb-2.5 text-sm font-medium`,children:`How often`}),(0,Q.jsx)(f,{value:x,onChange:d,columns:2,options:[{value:`immediately`,label:`Immediately`,description:`An email for each new notification`,icon:(0,Q.jsx)(ne,{className:`size-4`})},{value:`daily`,label:`Daily digest`,description:T.daily,icon:(0,Q.jsx)(e,{className:`size-4`})},{value:`weekly`,label:`Weekly digest`,description:T.weekly,icon:(0,Q.jsx)(ee,{className:`size-4`})},{value:`off`,label:`Off`,description:`Only see notifications in the app`,icon:(0,Q.jsx)(V,{className:`size-4`})}]}),a.isDefault&&u===null&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This is your site's default.`})]}),(0,Q.jsxs)(`fieldset`,{className:`space-y-2`,disabled:E,children:[(0,Q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`What to email you about`}),(0,Q.jsx)(`p`,{className:`mb-2.5 text-xs text-muted-foreground`,children:E?`Turn email on to choose what it covers.`:`Switch off anything you would rather only see in the app.`}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:H.map(e=>(0,Q.jsx)(y,{label:e.label,description:e.description,checked:!E&&!S.includes(e.id),disabled:E,onCheckedChange:t=>m(t?S.filter(t=>t!==e.id):[...S,e.id])},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse gap-3 border-t pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0 text-xs break-words text-muted-foreground`,children:[`Emails go to `,(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:a.address}),`.`]}),(0,Q.jsx)(O,{type:`submit`,loading:g.isPending,disabled:!w,className:`self-end sm:self-auto`,children:`Save email preferences`})]})]})]})}function oe(){let{data:e,isLoading:n,error:a,refetch:s}=C({queryKey:W.myCertificates,queryFn:()=>j.get(`/me/certificates`)});return(0,Q.jsxs)(b,{children:[(0,Q.jsx)(_,{title:`Certificates`,description:`Earned by completing courses.`,icon:(0,Q.jsx)(U,{className:`size-4.5`})}),(0,Q.jsx)(`div`,{className:`px-2 pb-3`,children:a?(0,Q.jsx)(B,{error:a,onRetry:()=>s()}):n||!e?(0,Q.jsx)(z,{className:`mx-3 mb-2 h-16`}):e.length===0?(0,Q.jsx)(`p`,{className:`px-3 pb-2 text-sm text-muted-foreground`,children:`When you complete a course that gives certificates, yours will appear here.`}):(0,Q.jsx)(`ul`,{children:e.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(i,{to:`/certificates/${e.id}`,className:`flex items-center gap-3 rounded-lg px-3 py-2.5 transition-colors hover:bg-accent/50`,children:[(0,Q.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg text-white`,style:e.course?r(e.course.coverColor):{background:`var(--color-muted-foreground)`},children:(0,Q.jsx)(U,{className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:w(`block truncate text-sm font-medium`,e.revokedAt&&`text-muted-foreground`),children:e.courseTitle}),(0,Q.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[`Completed `,I(e.completedAt,{year:`numeric`}),` · `,(0,Q.jsx)(`span`,{className:`font-mono`,children:e.code})]})]}),e.revokedAt&&(0,Q.jsx)(t,{variant:`danger`,children:`Revoked`}),(0,Q.jsx)(o,{className:`size-4 shrink-0 text-muted-foreground`})]})},e.id))})})]})}function se(){let{data:e,isLoading:t,error:n,refetch:r}=C({queryKey:W.myBadges,queryFn:()=>j.get(`/me/badges`)});return(0,Q.jsxs)(b,{children:[(0,Q.jsx)(_,{title:`Badges`,description:`Awarded by teachers and for completing courses.`,icon:(0,Q.jsx)(m,{className:`size-4.5`})}),(0,Q.jsx)(`div`,{className:`px-5 pb-5`,children:n?(0,Q.jsx)(B,{error:n,onRetry:()=>r()}):t||!e?(0,Q.jsx)(z,{className:`h-28`}):e.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No badges yet. Teachers award them for great work, and some courses give one when you finish.`}):(0,Q.jsx)(`ul`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:e.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(i,{to:`/badges/${e.badge.id}`,className:`flex h-full flex-col items-center rounded-xl border px-3 py-4 text-center transition-colors hover:border-primary/40 hover:bg-accent/40`,children:[(0,Q.jsx)(re,{icon:e.badge.icon,color:e.badge.color,size:56}),(0,Q.jsx)(`span`,{className:`mt-2 line-clamp-2 text-sm font-medium break-words`,children:e.badge.name}),(0,Q.jsx)(`span`,{className:`mt-0.5 line-clamp-1 text-xs text-muted-foreground`,children:e.badge.course?.title??`Site badge`}),(0,Q.jsx)(`span`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:I(e.awardedAt,{year:`numeric`})})]})},e.badge.id))})})]})}function ce(){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(oe,{})]})}function le(){N(`Profile`);let e=P(),r=A(),{theme:i,setTheme:o}=s(),c=(0,Z.useRef)(null),[m,y]=(0,Z.useState)(e.name),[S,C]=(0,Z.useState)(e.bio??``),[w,E]=(0,Z.useState)({currentPassword:``,newPassword:``}),D=n({mutationFn:e=>j.patch(`/auth/me`,e),onSuccess:e=>{r(e),R.success(`Profile updated`)},onError:e=>R.error(k(e))}),M=n({mutationFn:()=>j.post(`/auth/me/password`,w),onSuccess:()=>{E({currentPassword:``,newPassword:``}),R.success(`Password changed. Other devices have been signed out.`)},onError:e=>R.error(k(e))}),F=async e=>{try{let t=await j.upload(e,{context:`avatar`});D.mutate({avatarUrl:t.url})}catch(e){R.error(k(e))}};return(0,Q.jsxs)(l,{size:`narrow`,children:[(0,Q.jsx)(u,{title:`Profile`,description:`How you appear to teachers and classmates.`}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(b,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5 p-6 sm:flex-row sm:items-center`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(a,{user:e,size:`xl`}),(0,Q.jsx)(`button`,{onClick:()=>c.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,Q.jsx)(K,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:c,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&F(t),e.target.value=``}})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-lg font-semibold`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.email}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(t,{variant:`default`,children:T[e.role]}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Member since `,I(e.createdAt,{year:`numeric`})]})]})]}),e.avatarUrl&&(0,Q.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>D.mutate({avatarUrl:null}),children:[(0,Q.jsx)(d,{}),` Remove photo`]})]}),(0,Q.jsxs)(`form`,{className:`space-y-4 border-t p-6`,onSubmit:e=>{e.preventDefault(),D.mutate({name:m,bio:S.trim()||null})},children:[(0,Q.jsx)(h,{label:`Full name`,children:e=>(0,Q.jsx)(x,{...e,required:!0,value:m,onChange:e=>y(e.target.value)})}),(0,Q.jsx)(h,{label:`About you`,optional:!0,hint:`A sentence or two for your classmates.`,children:e=>(0,Q.jsx)(g,{...e,rows:3,value:S,onChange:e=>C(e.target.value)})}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(O,{type:`submit`,loading:D.isPending,disabled:m===e.name&&S===(e.bio??``),children:`Save profile`})})]})]}),(0,Q.jsx)(ce,{}),(0,Q.jsxs)(b,{children:[(0,Q.jsx)(_,{title:`Appearance`,description:`Choose how the site looks on this device.`}),(0,Q.jsx)(`div`,{className:`px-5 pb-5`,children:(0,Q.jsx)(f,{value:i,onChange:o,options:[{value:`light`,label:`Light`,icon:(0,Q.jsx)(v,{className:`size-4`})},{value:`dark`,label:`Dark`,icon:(0,Q.jsx)(p,{className:`size-4`})},{value:`system`,label:`System`,description:`Match your device`,icon:(0,Q.jsx)(X,{className:`size-4`})}]})})]}),(0,Q.jsx)(ae,{}),(0,Q.jsxs)(b,{children:[(0,Q.jsx)(_,{title:`Password`,description:`Changing your password signs you out on other devices.`,icon:(0,Q.jsx)(L,{className:`size-4.5`})}),(0,Q.jsxs)(`form`,{className:`grid gap-4 px-5 pb-5 sm:grid-cols-2`,onSubmit:e=>{e.preventDefault(),M.mutate()},children:[(0,Q.jsx)(h,{label:`Current password`,children:e=>(0,Q.jsx)(x,{...e,type:`password`,autoComplete:`current-password`,value:w.currentPassword,onChange:e=>E({...w,currentPassword:e.target.value})})}),(0,Q.jsx)(h,{label:`New password`,hint:`At least 8 characters.`,children:e=>(0,Q.jsx)(x,{...e,type:`password`,autoComplete:`new-password`,value:w.newPassword,onChange:e=>E({...w,newPassword:e.target.value})})}),(0,Q.jsx)(`div`,{className:`flex justify-end sm:col-span-2`,children:(0,Q.jsx)(O,{type:`submit`,variant:`outline`,loading:M.isPending,disabled:w.newPassword.length<8,children:`Change password`})})]})]})]})]})}export{le as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e,S as t,_ as n,dt as r,ft as i,g as a,mt as o}from"./hooks-EFhyJ5yU.js";import{n as s,t as c}from"./arrow-up-lI30bvj5.js";import{t as l}from"./markdown-HNlXovsL.js";import{t as u}from"./shuffle-C1aB_4dp.js";import{et as d,f,kt as p,m,u as h}from"./index-CEZdqKdi.js";var g={name:`arrow-down-up`,size:24,node:[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]};g.node;var _=e(g),v={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};v.node;var y=e(v),b={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`]};b.node;var x=e(b),S={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};S.node;var C=e(S),w={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};w.node;var T=e(w),E={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};E.node;var D=e(E),O={name:`square-check-big`,size:24,node:[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-square`]};O.node;var k=e(O),A={name:`text-cursor-input`,size:24,node:[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]};A.node;var j=e(A),M={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};M.node;var N=e(M),P=o(i(),1),F=[`single`,`multiple`,`truefalse`,`short`,`numeric`,`essay`,`matching`,`ordering`],I={single:{label:`Multiple choice (one answer)`,short:`Single choice`,hint:`Choose one answer`,icon:y,tint:`bg-violet-500/10 text-violet-600 dark:text-violet-400`},multiple:{label:`Multiple choice (several answers)`,short:`Multiple choice`,hint:`Select all that apply`,icon:k,tint:`bg-indigo-500/10 text-indigo-600 dark:text-indigo-400`},truefalse:{label:`True / false`,short:`True / false`,hint:`True or false`,icon:N,tint:`bg-sky-500/10 text-sky-600 dark:text-sky-400`},short:{label:`Short answer`,short:`Short answer`,hint:`Type your answer`,icon:j,tint:`bg-teal-500/10 text-teal-600 dark:text-teal-400`},numeric:{label:`Numerical`,short:`Numerical`,hint:`Enter a number`,icon:T,tint:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`},essay:{label:`Essay (marked by a teacher)`,short:`Essay`,hint:`Write your answer`,icon:D,tint:`bg-amber-500/10 text-amber-600 dark:text-amber-400`},matching:{label:`Matching`,short:`Matching`,hint:`Match each item to an answer`,icon:u,tint:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},ordering:{label:`Ordering`,short:`Ordering`,hint:`Put the items in order`,icon:_,tint:`bg-fuchsia-500/10 text-fuchsia-600 dark:text-fuchsia-400`}};function L(e){return e==null||Number.isNaN(e)?`–`:String(Math.round(e*100)/100)}function R(e){let t=(e??``).trim();return t?t.split(/\s+/).length:0}function z(e,t){let n=R(t);return n===0?null:e.maxWords&&n>e.maxWords?`long`:e.minWords&&n<e.minWords?`short`:null}function B(e,t){switch(e.type){case`short`:case`numeric`:case`essay`:return!!t?.text?.trim();case`matching`:return(e.pairs??[]).length>0&&(e.pairs??[]).every(e=>!!t?.matches?.[e.id]);case`ordering`:return!0;default:return!!t?.optionIds?.length}}function V(e){let t=new Map(e.map(e=>[e.id,e])),n=(e,r=new Set)=>{let i=e.parentId?t.get(e.parentId):void 0;return!i||r.has(i.id)?0:(r.add(i.id),n(i,r)+1)};return e.map(e=>({...e,depth:n(e)}))}function H(e,t){let n=[t];for(let t=0;t<n.length;t++)for(let r of e)r.parentId===n[t]&&!n.includes(r.id)&&n.push(r.id);return n}function U(e){return`${`\xA0\xA0\xA0`.repeat(e.depth)}${e.depth?`└ `:``}${e.name}`}var W=r();function G({question:e,answer:t,onChange:r,review:i,disabled:a}){let o=e.type===`multiple`,s=new Set(t?.optionIds??[]);return(0,W.jsx)(`div`,{className:`grid gap-2`,role:o?`group`:`radiogroup`,"aria-label":`Answer options`,children:e.options.map((e,t)=>{let c=s.has(e.id),u=i?e.correct:void 0;return(0,W.jsxs)(`button`,{type:`button`,disabled:a,role:o?`checkbox`:`radio`,"aria-checked":c,onClick:()=>{if(o){let t=new Set(s);c?t.delete(e.id):t.add(e.id),r({optionIds:[...t]})}else r({optionIds:[e.id]})},className:n(`flex items-center gap-3 rounded-xl border bg-card px-4 py-3 text-left text-[15px] transition-all`,!a&&`hover:border-primary/50 hover:bg-primary/[0.02]`,c&&!i&&`border-primary bg-primary/[0.05] ring-3 ring-primary/10`,i&&u&&`border-emerald-500/50 bg-emerald-500/[0.07]`,i&&c&&!u&&`border-red-500/50 bg-red-500/[0.06]`,a&&`cursor-default`),children:[(0,W.jsx)(`span`,{className:n(`grid size-6 shrink-0 place-items-center border text-xs font-semibold text-muted-foreground`,o?`rounded-md`:`rounded-full`,c&&`border-primary bg-primary text-primary-foreground`,i&&u&&`border-emerald-600 bg-emerald-600 text-white`,i&&c&&!u&&`border-red-500 bg-red-500 text-white`),children:i&&u?(0,W.jsx)(p,{className:`size-3.5`,strokeWidth:3}):i&&c?(0,W.jsx)(d,{className:`size-3.5`,strokeWidth:3}):c&&o?(0,W.jsx)(p,{className:`size-3.5`,strokeWidth:3}):String.fromCharCode(65+t)}),(0,W.jsx)(l,{source:e.text,className:`flex-1`}),i&&c&&(0,W.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Your answer`})]},e.id)})})}function K({question:e,answer:t,onChange:n,review:r,disabled:i}){return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(h,{value:t?.text??``,disabled:i,inputMode:e.type===`numeric`?`decimal`:`text`,onChange:e=>n({text:e.target.value}),placeholder:e.type===`numeric`?`e.g. 42`:`Your answer`,className:`h-11 max-w-md text-[15px]`,"aria-label":`Your answer`}),r&&e.acceptedAnswers&&(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Accepted answer`,e.acceptedAnswers.length>1?`s`:``,`:`,` `,(0,W.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.acceptedAnswers.join(`, `),e.type===`numeric`&&e.tolerance?` (± ${e.tolerance})`:``]})]})]})}function q(e){return e.minWords&&e.maxWords?`${e.minWords}–${e.maxWords} words`:e.maxWords?`up to ${e.maxWords} words`:e.minWords?`at least ${e.minWords} words`:null}function J({question:e,answer:t,onChange:r,disabled:i}){let a=(0,P.useId)(),o=t?.text??``,s=R(o),c=z(e,o),l=q(e),u=(0,W.jsxs)(`p`,{id:`${a}-count`,className:n(`text-xs text-muted-foreground tabular-nums`,c&&`font-medium text-amber-700 dark:text-amber-400`),children:[s,` word`,s===1?``:`s`,l&&` · ${c===`long`?`over the limit of`:c===`short`?`aim for`:`suggested length:`} ${l}`]});return i?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[o.trim()?(0,W.jsx)(`div`,{className:`rounded-lg border bg-muted/30 px-4 py-3 text-[15px] leading-relaxed whitespace-pre-wrap`,children:o}):(0,W.jsx)(`p`,{className:`rounded-lg border border-dashed px-4 py-3 text-sm text-muted-foreground`,children:`No answer was given.`}),o.trim()&&u]}):(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(m,{value:o,onChange:e=>r({text:e.target.value}),rows:8,placeholder:`Write your answer here.`,"aria-label":`Your answer`,"aria-describedby":`${a}-count`,className:`text-[15px]`}),u]})}function Y({question:e,answer:r,onChange:i,review:a,disabled:o}){let s=(0,P.useId)(),c=r?.matches??{},u=e.choices??[],m=e=>u.find(t=>t.id===e)?.text;return(0,W.jsx)(`div`,{className:`divide-y rounded-xl border bg-card`,children:(e.pairs??[]).map(e=>{let r=c[e.id],h=a&&!!r&&r===e.answerId;return(0,W.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] sm:items-center sm:gap-4`,children:[(0,W.jsx)(`label`,{htmlFor:`${s}-${e.id}`,className:`text-[15px] font-medium`,children:(0,W.jsx)(l,{source:e.text})}),a||o?(0,W.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,W.jsxs)(`p`,{className:n(`flex items-start gap-2`,a&&(h?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`)),children:[a&&(h?(0,W.jsx)(p,{className:`mt-0.5 size-4 shrink-0`,strokeWidth:3,"aria-label":`Right`}):(0,W.jsx)(d,{className:`mt-0.5 size-4 shrink-0`,strokeWidth:3,"aria-label":`Wrong`})),(0,W.jsx)(`span`,{id:`${s}-${e.id}`,className:n(!r&&`text-muted-foreground italic`),children:r?(0,W.jsx)(l,{source:m(r)??``}):`No answer`})]}),a&&!h&&e.answer&&(0,W.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Right answer: `,(0,W.jsx)(l,{source:e.answer,className:`font-medium text-foreground`})]})]}):(0,W.jsxs)(f,{id:`${s}-${e.id}`,value:r??``,onChange:t=>{let n={...c};t.target.value?n[e.id]=t.target.value:delete n[e.id],i({matches:n})},className:`h-10`,children:[(0,W.jsx)(`option`,{value:``,children:`Choose a match…`}),u.map(e=>(0,W.jsx)(`option`,{value:e.id,children:t(e.text,120)},e.id))]})]},e.id)})})}function X({question:e,answer:r,onChange:i,disabled:o}){let u=new Map(e.options.map(e=>[e.id,e])),d=(r?.order??e.options.map(e=>e.id)).filter(e=>u.has(e)),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(null),g=(0,P.useRef)({id:null,over:null}),_=()=>{g.current={id:null,over:null},p(null),h(null)},[v,y]=(0,P.useState)(``),b=(0,P.useRef)(new Map),x=e=>t(u.get(e)?.text??``,60),S=(e,t,n)=>{let r=d.indexOf(e);if(r<0||t<0||t>=d.length||t===r)return;let a=[...d];if(a.splice(r,1),a.splice(t,0,e),i({order:a}),y(`“${x(e)}” moved to position ${t+1} of ${d.length}.`),n){let r=n===`up`&&t===0?`down`:n===`down`&&t===d.length-1?`up`:n;requestAnimationFrame(()=>b.current.get(`${e}:${r}`)?.focus())}};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o?`Your order:`:`Drag the items, or use the arrow buttons, to put them in order.`}),(0,W.jsx)(`ol`,{className:`space-y-2`,"aria-label":`Items to put in order`,children:d.map((e,t)=>{let r=u.get(e);return(0,W.jsxs)(`li`,{draggable:!o,onDragStart:t=>{g.current={id:e,over:null},p(e),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e)},onDragOver:e=>{if(!g.current.id)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=e.clientY>n.top+n.height/2?t+1:t;g.current.over=r,h(r)},onDrop:e=>{e.preventDefault();let{id:t,over:n}=g.current;if(t&&n!=null){let e=d.indexOf(t);S(t,n>e?n-1:n)}_()},onDragEnd:_,className:n(`relative flex items-center gap-2.5 rounded-xl border bg-card py-2 pr-2 pl-2.5 text-[15px] transition-shadow`,!o&&`cursor-grab active:cursor-grabbing`,f===e&&`opacity-50`,m===t&&f!==e&&`shadow-[0_-3px_0_0_var(--primary)]`,m===t+1&&t===d.length-1&&f!==e&&`shadow-[0_3px_0_0_var(--primary)]`),children:[!o&&(0,W.jsx)(C,{className:`size-4 shrink-0 text-muted-foreground/60`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`grid size-6 shrink-0 place-items-center rounded-full bg-muted text-xs font-semibold tabular-nums`,children:t+1}),(0,W.jsx)(l,{source:r.text,className:`min-w-0 flex-1 py-1`}),!o&&(0,W.jsxs)(`span`,{className:`flex shrink-0`,children:[(0,W.jsx)(a,{ref:t=>{b.current.set(`${e}:up`,t)},type:`button`,variant:`ghost`,size:`icon-sm`,disabled:t===0,onClick:()=>S(e,t-1,`up`),"aria-label":`Move “${x(e)}” up`,children:(0,W.jsx)(c,{})}),(0,W.jsx)(a,{ref:t=>{b.current.set(`${e}:down`,t)},type:`button`,variant:`ghost`,size:`icon-sm`,disabled:t===d.length-1,onClick:()=>S(e,t+1,`down`),"aria-label":`Move “${x(e)}” down`,children:(0,W.jsx)(s,{})})]})]},e)})}),(0,W.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,children:v})]})}function Z({question:e,answer:t}){let n=new Map(e.options.map(e=>[e.id,e])),r=e.options.map(e=>e.id),i=new Map(r.map((e,t)=>[e,t])),a=(t?.order??[]).filter(e=>n.has(e)),o=e=>e>0&&i.get(a[e])===(i.get(a[e-1])??-9)+1,s=a.reduce((e,t,n)=>e+ +!!o(n),0);return(0,W.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:[`Your order · `,s,` of `,Math.max(0,r.length-1),` pairs in the right order`]}),(0,W.jsx)(`ol`,{className:`space-y-1.5`,children:a.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex items-start gap-2.5 rounded-lg border bg-card px-3 py-2 text-sm`,children:[(0,W.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-full bg-muted text-[11px] font-semibold tabular-nums`,children:t+1}),(0,W.jsx)(l,{source:n.get(e).text,className:`min-w-0 flex-1`}),t>0&&(o(t)?(0,W.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:3,"aria-label":`Follows the item above correctly`}):(0,W.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`,strokeWidth:3,"aria-label":`Doesn't belong after the item above`}))]},e))}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`A tick means the item rightly follows the one above it.`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`Right order`}),(0,W.jsx)(`ol`,{className:`space-y-1.5`,children:e.options.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex items-start gap-2.5 rounded-lg bg-emerald-500/[0.07] px-3 py-2 text-sm`,children:[(0,W.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-full bg-emerald-600 text-[11px] font-semibold text-white tabular-nums`,children:t+1}),(0,W.jsx)(l,{source:e.text,className:`min-w-0 flex-1`})]},e.id))})]})]})}function Q(e){switch(e.question.type){case`short`:case`numeric`:return(0,W.jsx)(K,{...e});case`essay`:return(0,W.jsx)(J,{...e});case`matching`:return(0,W.jsx)(Y,{...e});case`ordering`:return e.review?(0,W.jsx)(Z,{...e}):(0,W.jsx)(X,{...e});default:return(0,W.jsx)(G,{...e})}}export{U as a,V as c,L as i,z as l,F as n,B as o,I as r,H as s,Q as t,x as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e,H as t,N as n,Q as r,U as i,_ as a,dt as o,ft as s,g as c,h as l,m as u,mt as d,r as f,t as p}from"./hooks-EFhyJ5yU.js";import{$ as m,A as h,C as g,D as _,E as v,G as ee,Gt as y,H as b,J as x,K as te,O as S,Ot as ne,St as C,V as w,W as T,_ as E,at as D,dt as re,f as ie,k as O,l as k,lt as ae,m as oe,n as A,p as se,q as ce,t as le,u as ue,z as de}from"./index-CEZdqKdi.js";import{t as fe}from"./chevron-left-Bu6IJANV.js";import{t as pe}from"./copy-B5IKRMFo.js";import{t as me}from"./folder-input-M2p_UJZX.js";import{t as he}from"./library-Bcm33ouq.js";import{t as j}from"./ellipsis-BDmYLoyn.js";import{t as M}from"./pencil-DFUpj3YP.js";import{E as N,c as P,n as F,t as I}from"./misc-CyGhN6HT.js";import{i as ge,n as _e,o as ve,r as ye,s as L,t as R}from"./bank-S3XEFPfe.js";import{c as be,i as xe,n as Se,r as Ce,s as z}from"./QuestionAnswer-CJIoWSz2.js";import{r as we}from"./context-D8W_QqNi.js";var B={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};B.node;var V=t(B),H={name:`search-x`,size:24,node:[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]};H.node;var Te=t(H),U=d(s(),1),W=o(),G=20;function Ee({courseId:e,edit:t,categories:n,onClose:r}){let i=L(),[a,o]=(0,U.useState)(``),[s,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(``);(0,U.useEffect)(()=>{t&&(o(t.mode===`edit`?t.category.name:``),d(t.mode===`edit`?t.category.description:``),p((t.mode===`edit`?t.category.parentId:t.parentId)??``))},[t]);let m=t?.mode===`edit`?z(n,t.category.id):[],g=y({mutationFn:()=>{let n={name:a,description:s,parentId:f||null};return t?.mode===`edit`?u.patch(`/question-categories/${t.category.id}`,n):u.post(`/courses/${e}/question-categories`,n)},onSuccess:async()=>{N.success(t?.mode===`edit`?`Category saved`:`Category created`),r(),await i(e)},onError:e=>N.error(l(e))});return(0,W.jsx)(v,{open:!!t,onOpenChange:e=>!e&&r(),children:(0,W.jsx)(S,{size:`sm`,children:(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g.mutate()},children:[(0,W.jsx)(h,{icon:(0,W.jsx)(V,{className:`size-5`}),title:t?.mode===`edit`?`Edit category`:`New category`}),(0,W.jsxs)(_,{className:`space-y-4`,children:[(0,W.jsx)(k,{label:`Name`,children:e=>(0,W.jsx)(ue,{...e,autoFocus:!0,value:a,maxLength:100,onChange:e=>o(e.target.value)})}),(0,W.jsx)(k,{label:`Description`,optional:!0,children:e=>(0,W.jsx)(oe,{...e,rows:2,value:s,maxLength:1e3,onChange:e=>d(e.target.value)})}),(0,W.jsx)(k,{label:`Inside`,children:e=>(0,W.jsx)(R,{...e,categories:n,allLabel:`Top level`,exclude:m,value:f,onChange:e=>p(e.target.value)})})]}),(0,W.jsxs)(O,{children:[(0,W.jsx)(c,{type:`button`,variant:`outline`,onClick:r,children:`Cancel`}),(0,W.jsx)(c,{type:`submit`,loading:g.isPending,disabled:!a.trim(),children:t?.mode===`edit`?`Save`:`Create category`})]})]})})})}function De({courseId:e,category:t,categories:r,onClose:i,onDeleted:a}){let o=L(),s=t?r.filter(e=>!z(r,t.id).includes(e.id)):[],[d,f]=(0,U.useState)(``),p=t?t.parentId??s[0]?.id??``:``;(0,U.useEffect)(()=>f(p),[p]);let m=!!t&&(t.questionCount>0||r.some(e=>e.parentId===t.id)),g=y({mutationFn:()=>u.delete(`/question-categories/${t.id}${d?`?moveTo=${encodeURIComponent(d)}`:``}`),onSuccess:async()=>{N.success(`Deleted “${t.name}”`),a(d),i(),await o(e)},onError:e=>N.error(l(e),{duration:8e3})});return(0,W.jsx)(v,{open:!!t,onOpenChange:e=>!e&&i(),children:(0,W.jsxs)(S,{size:`sm`,children:[(0,W.jsx)(h,{icon:(0,W.jsx)(D,{className:`size-5`}),title:`Delete “${t?.name??``}”?`}),(0,W.jsx)(_,{className:`space-y-4`,children:s.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the bank's only category. Create another one before deleting it.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m?`Its ${n(t.questionCount,`question`)}, any subcategories and random quiz questions drawn from it move to the category you pick.`:`It has no questions. Random quiz questions drawn from it, if any, move to the category you pick.`}),(0,W.jsx)(k,{label:`Move contents to`,children:e=>(0,W.jsx)(R,{...e,categories:s,value:d,onChange:e=>f(e.target.value)})})]})}),(0,W.jsxs)(O,{children:[(0,W.jsx)(c,{type:`button`,variant:`outline`,onClick:i,children:`Cancel`}),(0,W.jsx)(c,{variant:`destructive`,onClick:()=>g.mutate(),loading:g.isPending,disabled:s.length===0||!d,children:`Delete category`})]})]})})}function Oe({categories:e,total:t,selected:n,onSelect:r,onNew:i,onEdit:o,onDelete:s}){let l=be(e),u=e=>a(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,e&&`bg-primary/10 font-medium text-primary hover:bg-primary/10 hover:text-primary`);return(0,W.jsxs)(le,{className:`overflow-hidden lg:sticky lg:top-32`,children:[(0,W.jsx)(A,{title:`Categories`,className:`pb-2`,action:(0,W.jsx)(c,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(null),"aria-label":`New category`,children:(0,W.jsx)(V,{})})}),(0,W.jsxs)(`nav`,{"aria-label":`Question categories`,className:`ck-scrollbar max-h-72 overflow-y-auto px-2 pb-3 lg:max-h-[calc(100dvh-14rem)]`,children:[(0,W.jsxs)(`button`,{type:`button`,className:u(n===``),"aria-current":n===``?`true`:void 0,onClick:()=>r(``),children:[(0,W.jsx)(`span`,{className:`flex-1 truncate`,children:`All questions`}),(0,W.jsx)(`span`,{className:`text-[11px] tabular-nums`,children:t})]}),l.map(e=>(0,W.jsxs)(`div`,{className:`group flex items-center`,style:{paddingLeft:`${e.depth*14}px`},children:[(0,W.jsxs)(`button`,{type:`button`,className:u(n===e.id),"aria-current":n===e.id?`true`:void 0,onClick:()=>r(e.id),children:[(0,W.jsx)(`span`,{className:`flex-1 truncate`,title:e.description||void 0,children:e.name}),(0,W.jsx)(`span`,{className:`text-[11px] tabular-nums`,children:e.questionCount})]}),(0,W.jsxs)(de,{children:[(0,W.jsx)(x,{asChild:!0,children:(0,W.jsx)(c,{variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-muted-foreground`,"aria-label":`Actions for ${e.name}`,children:(0,W.jsx)(j,{})})}),(0,W.jsxs)(w,{children:[(0,W.jsxs)(b,{onSelect:()=>o(e),children:[(0,W.jsx)(M,{}),` Edit`]}),(0,W.jsxs)(b,{onSelect:()=>i(e.id),children:[(0,W.jsx)(V,{}),` Add subcategory`]}),(0,W.jsx)(T,{}),(0,W.jsxs)(b,{destructive:!0,onSelect:()=>s(e),children:[(0,W.jsx)(D,{}),` Delete`]})]})]})]},e.id))]})]})}function K(){let{course:t,can:o}=we();f(`Question bank · ${t.title}`);let s=o(`questionbank:manage`),d=m(),h=L(),[_,v]=(0,U.useState)(``),[S,O]=(0,U.useState)(!0),[k,oe]=(0,U.useState)(``),A=p(k.trim(),250),[R,z]=(0,U.useState)(``),[B,V]=(0,U.useState)(1),[H,K]=(0,U.useState)(null),[ke,q]=(0,U.useState)(null),[Ae,J]=(0,U.useState)(null),[je,Me]=(0,U.useState)(null),Y=ve(t.id,s),X=(0,U.useMemo)(()=>Y.data??[],[Y.data]),Z=X.find(e=>e.id===_)??null,Ne=!!Z&&X.some(e=>e.parentId===Z.id),Pe={categoryId:_,includeSub:S&&Ne,term:A,type:R,page:B};(0,U.useEffect)(()=>V(1),[_,S,A,R]);let Q=i({queryKey:[`bank-questions`,t.id,Pe],queryFn:()=>{let e=new URLSearchParams({page:String(B),pageSize:String(G)});return _&&e.set(`categoryId`,_),Pe.includeSub&&e.set(`subcategories`,`1`),A&&e.set(`q`,A),R&&e.set(`type`,R),u.get(`/courses/${t.id}/questions?${e}`)},enabled:s,placeholderData:r}),Fe=y({mutationFn:e=>u.post(`/questions/${e}/duplicate`),onSuccess:async()=>{N.success(`Question duplicated`),await h(t.id)},onError:e=>N.error(l(e))}),Ie=y({mutationFn:({id:e,to:n})=>u.post(`/courses/${t.id}/questions/move`,{ids:[e],categoryId:n}),onSuccess:async(e,{to:n})=>{N.success(`Moved to “${X.find(e=>e.id===n)?.name}”`),await h(t.id)},onError:e=>N.error(l(e))}),Le=y({mutationFn:e=>u.delete(`/questions/${e}`),onSuccess:async()=>{N.success(`Question deleted`),await h(t.id)},onError:e=>N.error(l(e),{duration:1e4})});if(!s)return(0,W.jsx)(E,{children:(0,W.jsx)(I,{icon:he,title:`Only teachers can open the question bank`})});let Re=X.reduce((e,t)=>e+t.questionCount,0),$=Q.data,ze=!!A||!!R,Be=$?Math.max(1,Math.ceil($.total/G)):1,Ve=async e=>{await d({title:`Delete this question?`,description:e.quizCount>0?`It's used in ${n(e.quizCount,`quiz`,`quizzes`)}. Remove it from ${e.quizCount===1?`that quiz`:`those quizzes`} first.`:`Attempts that already used it keep their own copy. This cannot be undone.`,confirmLabel:`Delete question`,destructive:!0})&&Le.mutate(e.id)};return(0,W.jsxs)(E,{children:[(0,W.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Question bank`}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Every question for this course's quizzes lives here. Organise them in categories, then add them to quizzes one by one or as random picks.`})]}),(0,W.jsxs)(c,{onClick:()=>K({questionId:null}),children:[(0,W.jsx)(re,{}),` New question`]})]}),(0,W.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[Y.error?(0,W.jsx)(F,{error:Y.error,onRetry:()=>Y.refetch()}):Y.isLoading?(0,W.jsx)(P,{className:`h-64`}):(0,W.jsx)(Oe,{categories:X,total:Re,selected:_,onSelect:v,onNew:e=>J({mode:`new`,parentId:e}),onEdit:e=>J({mode:`edit`,category:e}),onDelete:Me}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,W.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,W.jsx)(ae,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,W.jsx)(ue,{value:k,onChange:e=>oe(e.target.value),placeholder:`Search questions`,className:`pl-9`,"aria-label":`Search questions`})]}),(0,W.jsxs)(ie,{value:R,onChange:e=>z(e.target.value),className:`sm:w-56`,"aria-label":`Question type`,children:[(0,W.jsx)(`option`,{value:``,children:`All types`}),Se.map(e=>(0,W.jsx)(`option`,{value:e,children:Ce[e].short},e))]}),Ne&&(0,W.jsx)(`div`,{className:`sm:ml-auto`,children:(0,W.jsx)(se,{label:`Include subcategories`,checked:S,onCheckedChange:O})})]}),Z?.description&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z.description}),Q.error?(0,W.jsx)(F,{error:Q.error,onRetry:()=>Q.refetch()}):$?$.items.length===0?ze?(0,W.jsx)(I,{icon:Te,title:`No questions match`,description:`Try another search or question type.`}):(0,W.jsx)(I,{icon:he,title:Z?`No questions in “${Z.name}” yet`:`The question bank is empty`,description:`Write questions once and reuse them in any quiz in this course.`,action:(0,W.jsxs)(c,{onClick:()=>K({questionId:null}),children:[(0,W.jsx)(re,{}),` New question`]})}):(0,W.jsxs)(le,{className:a(`overflow-hidden transition-opacity`,Q.isPlaceholderData&&`opacity-60`),children:[(0,W.jsx)(`ul`,{className:`divide-y`,"aria-label":`Questions`,children:$.items.map(t=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3 px-4 py-3.5 sm:px-5`,children:[(0,W.jsx)(ge,{type:t.type,className:`mt-0.5`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>K({questionId:t.id}),className:`block max-w-full text-left text-sm font-medium break-words hover:text-primary focus-visible:text-primary`,children:t.name||t.excerpt}),t.name&&(0,W.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:t.excerpt}),(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[(0,W.jsx)(g,{variant:`neutral`,children:Ce[t.type].short}),(0,W.jsxs)(g,{variant:`outline`,children:[xe(t.points),` mark`,t.points===1?``:`s`]}),(!_||_!==t.categoryId)&&(0,W.jsx)(g,{variant:`outline`,children:t.categoryName}),t.quizCount>0&&(0,W.jsxs)(g,{variant:`info`,children:[`In `,n(t.quizCount,`quiz`,`quizzes`)]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Updated `,e(t.updatedAt)]})]})]}),(0,W.jsx)(c,{variant:`ghost`,size:`icon-sm`,onClick:()=>q(t.id),"aria-label":`Preview`,className:`hidden sm:inline-flex`,children:(0,W.jsx)(C,{})}),(0,W.jsxs)(de,{children:[(0,W.jsx)(x,{asChild:!0,children:(0,W.jsx)(c,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${t.name||t.excerpt}`,children:(0,W.jsx)(j,{})})}),(0,W.jsxs)(w,{className:`w-52`,children:[(0,W.jsxs)(b,{onSelect:()=>q(t.id),children:[(0,W.jsx)(C,{}),` Preview`]}),(0,W.jsxs)(b,{onSelect:()=>K({questionId:t.id}),children:[(0,W.jsx)(M,{}),` Edit`]}),(0,W.jsxs)(b,{onSelect:()=>Fe.mutate(t.id),children:[(0,W.jsx)(pe,{}),` Duplicate`]}),(0,W.jsxs)(ee,{children:[(0,W.jsxs)(ce,{children:[(0,W.jsx)(me,{className:`size-4 text-muted-foreground`}),` Move to`]}),(0,W.jsx)(te,{className:`ck-scrollbar max-h-72 overflow-y-auto`,children:be(X).map(e=>(0,W.jsx)(b,{disabled:e.id===t.categoryId,onSelect:()=>Ie.mutate({id:t.id,to:e.id}),style:{paddingLeft:`${10+e.depth*12}px`},children:e.name},e.id))})]}),(0,W.jsx)(T,{}),(0,W.jsxs)(b,{destructive:!0,onSelect:()=>void Ve(t),children:[(0,W.jsx)(D,{}),` Delete`]})]})]})]},t.id))}),$.total>G&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t px-4 py-2.5 text-xs text-muted-foreground sm:px-5`,children:[(0,W.jsxs)(`span`,{children:[(B-1)*G+1,`–`,Math.min(B*G,$.total),` of `,$.total]}),(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsx)(c,{variant:`outline`,size:`icon-sm`,onClick:()=>V(B-1),disabled:B<=1,"aria-label":`Previous page`,children:(0,W.jsx)(fe,{})}),(0,W.jsx)(c,{variant:`outline`,size:`icon-sm`,onClick:()=>V(B+1),disabled:B>=Be,"aria-label":`Next page`,children:(0,W.jsx)(ne,{})})]})]})]}):(0,W.jsx)(P,{className:`h-96`})]})]}),(0,W.jsx)(_e,{courseId:t.id,open:!!H,onOpenChange:e=>!e&&K(null),questionId:H?.questionId,defaultCategoryId:_||null}),(0,W.jsx)(ye,{questionId:ke,open:!!ke,onOpenChange:e=>!e&&q(null)}),(0,W.jsx)(Ee,{courseId:t.id,edit:Ae,categories:X,onClose:()=>J(null)}),(0,W.jsx)(De,{courseId:t.id,category:je,categories:X,onClose:()=>Me(null),onDeleted:()=>{je?.id===_&&v(``)}})]})}export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,C as t,Dt as n,Et as r,Ft as i,Gt as a,It as o,Pt as s,T as c,Wt as l,_ as u,l as d,m as f,t as p,u as m}from"./index-CEZdqKdi.js";import{D as h,H as g,N as _,T as v,U as y,V as b,_ as x,dt as S,ft as C,g as w,h as T,m as E,mt as D,n as O,p as ee,r as te,ut as k}from"./hooks-EFhyJ5yU.js";import{i as A,l as ne,o as j,r as re,t as ie,u as M}from"./QuestionAnswer-CJIoWSz2.js";import{t as N}from"./clock-DPBmdKAi.js";import{t as P}from"./hourglass-BKca6Cje.js";import{t as ae}from"./lightbulb-CjSpJ1_v.js";import{t as F}from"./send-BnVkFV8w.js";import{t as I}from"./trophy-BFFngFEh.js";import{E as L,c as R,n as oe,o as z}from"./misc-CyGhN6HT.js";import{n as se,t as ce}from"./markdown-HNlXovsL.js";import{t as B}from"./message-square-text-wvO9_guT.js";import V from"./NotFoundPage-BmwVsGAy.js";import{a as H}from"./context-D8W_QqNi.js";var U={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`}]]};U.node;var W=g(U),G={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`}]]};G.node;var le=g(G),K={name:`notebook-pen`,size:24,node:[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]};K.node;var q=g(K),J=D(C(),1),Y=S();function ue({attempt:e,question:t,onSaved:n}){let i=(0,J.useId)(),o=e.results?.[t.id],s=!!o&&!o.pending&&!!o.gradedAt,c=s?String(o.points):``,l=o?.comment??``,[u,p]=(0,J.useState)(c),[g,_]=(0,J.useState)(l);(0,J.useEffect)(()=>{p(c),_(l)},[c,l]);let v=Number(u),y=u===``||!Number.isFinite(v)||v<0||v>t.points,b=a({mutationFn:()=>E.put(`/attempts/${e.id}/questions/${t.id}/grade`,{points:v,comment:g.trim()||null}),onSuccess:t=>{n(t),L.success(e.status===`needs_grading`&&t.status===`finished`?`All answers are marked. The grade is recorded and the student has been told.`:`Mark saved`)},onError:e=>L.error(T(e))});return(0,Y.jsxs)(`form`,{className:`mt-4 space-y-3 rounded-xl border bg-muted/25 p-4`,"aria-labelledby":`${i}-title`,onSubmit:e=>{e.preventDefault(),y||b.mutate()},children:[(0,Y.jsxs)(`p`,{id:`${i}-title`,className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,Y.jsx)(r,{className:`size-4 text-primary`}),` `,s?`Marked`:o?.pending?`Mark this answer`:`No answer given: scored 0. You can still give a mark.`]}),t.graderNotes&&(0,Y.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 px-3.5 py-2.5 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-semibold text-amber-800 dark:text-amber-300`,children:[(0,Y.jsx)(q,{className:`size-3.5`}),` Notes for graders`]}),(0,Y.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:t.graderNotes})]}),(0,Y.jsx)(d,{label:`Mark (out of ${A(t.points)})`,className:`w-44`,error:u!==``&&y?`Enter 0 to ${A(t.points)}`:null,children:e=>(0,Y.jsx)(m,{...e,type:`number`,min:0,max:t.points,step:`any`,inputMode:`decimal`,value:u,onChange:e=>p(e.target.value)})}),(0,Y.jsx)(d,{label:`Comment for the student`,optional:!0,children:e=>(0,Y.jsx)(f,{...e,rows:3,value:g,onChange:e=>_(e.target.value),placeholder:`What was good, what was missing?`})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[s?(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Marked `,h(o.gradedAt),o.gradedBy&&` by ${o.gradedBy.name}`]}):(0,Y.jsx)(`span`,{}),(0,Y.jsx)(w,{type:`submit`,size:`sm`,loading:b.isPending,disabled:y,children:s?`Update mark`:`Save mark`})]})]})}function de({result:e}){return e?e.pending?(0,Y.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-amber-500/[0.08] px-4 py-3 text-sm text-amber-900 dark:text-amber-200`,children:[(0,Y.jsx)(P,{className:`size-4 shrink-0`}),` Waiting for your teacher to mark this answer.`]}):e.comment?(0,Y.jsxs)(`div`,{className:`mt-4 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-semibold text-sky-800 dark:text-sky-300`,children:[(0,Y.jsx)(B,{className:`size-3.5`}),` `,e.gradedBy?`${e.gradedBy.name}'s comment`:`Your teacher's comment`]}),(0,Y.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.comment})]}):null:null}function fe({deadline:e,onExpire:t}){let n=O(1e3),r=Math.max(0,new Date(e).getTime()-n),i=(0,J.useRef)(!1);(0,J.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,Y.jsxs)(`span`,{className:x(`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`),role:`timer`,"aria-label":`${a} minutes ${o} seconds left`,children:[(0,Y.jsx)(N,{className:`size-4`}),String(a).padStart(2,`0`),`:`,String(o).padStart(2,`0`)]})}function pe({attempt:e,next:n}){let r=e.status===`needs_grading`,a=e.maxScore?(e.score??0)/e.maxScore*100:0,l=r||e.passingPercent==null?null:a>=e.passingPercent,u=e.results&&e.review?Object.values(e.results).filter(e=>e.correct).length:null;return(0,Y.jsx)(p,{className:`mb-6 overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-6 p-6 sm:flex-row`,children:[r?(0,Y.jsx)(`span`,{className:`grid size-28 shrink-0 place-items-center rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:(0,Y.jsx)(P,{className:`size-10`,"aria-hidden":!0})}):(0,Y.jsx)(z,{value:a,size:112,stroke:9,className:x(l===!1?`text-red-500`:`text-primary`),label:(0,Y.jsxs)(`span`,{className:`text-2xl font-semibold`,children:[Math.round(a),`%`]})}),(0,Y.jsxs)(`div`,{className:`flex-1 text-center sm:text-left`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-sm font-medium text-muted-foreground sm:justify-start`,children:[(0,Y.jsx)(I,{className:`size-4`}),e.user&&e.canGrade?`${e.user.name} · `:``,`Attempt `,e.attemptNumber,` · handed in`,` `,v(e.finishedAt)]}),r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-1 text-2xl font-semibold tracking-tight`,children:`Score pending`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.canGrade?`${_(e.pendingCount,`written answer`)} to mark below. The grade is recorded when every answer has a mark.`:`Your written answers are waiting to be marked. Your score appears once your teacher has graded them.`})]}):(0,Y.jsxs)(`p`,{className:`mt-1 text-3xl font-semibold tracking-tight tabular-nums`,children:[A(e.score),` `,(0,Y.jsxs)(`span`,{className:`text-lg font-normal text-muted-foreground`,children:[`/ `,A(e.maxScore),` points`]})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2 sm:justify-start`,children:[r&&(0,Y.jsxs)(t,{variant:`warning`,children:[(0,Y.jsx)(P,{}),` Waiting for grading`]}),u!=null&&!r&&(0,Y.jsxs)(t,{variant:`neutral`,children:[u,` of `,e.questions.length,` correct`]}),l!=null&&(0,Y.jsx)(t,{variant:l?`success`:`danger`,children:l?`Passed`:`Below the ${e.passingPercent}% pass mark`}),!e.review&&(0,Y.jsx)(t,{variant:`outline`,children:`Correct answers are hidden for now`})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[n&&(0,Y.jsx)(w,{asChild:!0,children:(0,Y.jsxs)(o,{to:`/courses/${e.course.slug}/attempts/${n.attemptId}`,children:[`Next to mark: `,n.user.name.split(` `)[0],` `,(0,Y.jsx)(s,{})]})}),(0,Y.jsx)(w,{asChild:!0,variant:`outline`,children:(0,Y.jsxs)(o,{to:c(e.course.slug,e.activityId),children:[(0,Y.jsx)(i,{}),` Back to quiz`]})})]})]})})}function X(){let{attemptId:r}=l(),s=k(),d=e(),f=H(),m=[`attempt`,r],{data:h,isLoading:g,error:v,refetch:S}=y({queryKey:m,queryFn:()=>E.get(`/attempts/${r}`)});te(h?.quizTitle);let C=y({queryKey:[`grading`,h?.activityId],queryFn:()=>E.get(`/activities/${h.activityId}/grading`),enabled:!!h?.canGrade}),D=h?.canGrade?C.data?.find(e=>e.attemptId!==h.id)??null:null,[O,N]=(0,J.useState)({}),[I,z]=(0,J.useState)(null),[B,U]=(0,J.useState)(`idle`),G=(0,J.useRef)(null),K=(0,J.useRef)(O);K.current=O,(0,J.useEffect)(()=>{h&&I!==h.id&&(N(h.answers),z(h.id))},[h,I]);let q=h?.status===`in_progress`,X=(0,J.useCallback)(async()=>{G.current&&clearTimeout(G.current),G.current=null,U(`saving`);try{await E.put(`/attempts/${r}`,{answers:K.current}),U(`saved`)}catch{U(`error`)}},[r]),me=(e,t)=>{N(n=>({...n,[e]:t})),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>void X(),700)};(0,J.useEffect)(()=>()=>{G.current&&clearTimeout(G.current)},[]);let Z=a({mutationFn:()=>E.post(`/attempts/${r}/submit`,{answers:K.current}),onSuccess:async e=>{G.current&&clearTimeout(G.current),s.setQueryData(m,e),window.scrollTo({top:0,behavior:`smooth`}),L.success(e.status===`needs_grading`?`Quiz handed in. Your written answers will be marked soon.`:`Quiz submitted!`),await f(e.course.slug)},onError:e=>L.error(T(e))}),he=(0,J.useCallback)(()=>{Z.isPending||(L.info(`Time's up! Submitting your answers.`),Z.mutate())},[Z]),ge=async e=>{s.setQueryData(m,e),await Promise.all([s.invalidateQueries({queryKey:[`grading`,e.activityId]}),s.invalidateQueries({queryKey:[`attempts`,e.activityId]}),s.invalidateQueries({queryKey:[`activity`,e.activityId]})])};if(g)return(0,Y.jsxs)(u,{size:`narrow`,children:[(0,Y.jsx)(R,{className:`mb-4 h-24`}),(0,Y.jsx)(R,{className:`h-64`})]});if(v instanceof ee&&v.status===404)return(0,Y.jsx)(V,{});if(v||!h)return(0,Y.jsx)(u,{children:(0,Y.jsx)(oe,{error:v,onRetry:()=>S()})});let Q=h.questions.filter(e=>j(e,O[e.id])).length,$=async()=>{let e=h.questions.length-Q,t=h.questions.map((e,t)=>({i:t,issue:e.type===`essay`?ne(e,O[e.id]?.text):null})).filter(e=>e.issue),n=[e?`You haven't answered ${_(e,`question`)}.`:``,...t.map(e=>`Your answer to question ${e.i+1} is ${e.issue===`long`?`over the word limit`:`shorter than suggested`}.`),`You can't change your answers after submitting.`].filter(Boolean);await d({title:`Submit your answers?`,description:n.join(` `),confirmLabel:`Submit quiz`})&&Z.mutate()};return(0,Y.jsxs)(`div`,{children:[q&&(0,Y.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/90 backdrop-blur-lg`,children:(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-5xl items-center gap-3 px-4 py-2.5 sm:px-6`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`truncate text-sm font-semibold`,children:h.quizTitle}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Q,` of `,h.questions.length,` answered`]})]}),(0,Y.jsxs)(`span`,{className:`hidden items-center gap-1.5 text-xs text-muted-foreground sm:flex`,"aria-live":`polite`,children:[B===`saving`?(0,Y.jsx)(b,{className:`size-3.5 animate-spin`}):B===`error`?(0,Y.jsx)(W,{className:`size-3.5 text-destructive`}):(0,Y.jsx)(le,{className:`size-3.5`}),B===`saving`?`Saving…`:B===`error`?`Not saved`:B===`saved`?`All changes saved`:`Autosave on`]}),h.deadlineAt&&(0,Y.jsx)(fe,{deadline:h.deadlineAt,onExpire:he}),(0,Y.jsxs)(w,{onClick:$,loading:Z.isPending,children:[(0,Y.jsx)(F,{}),` Submit`]})]})}),(0,Y.jsxs)(u,{className:`max-w-5xl`,children:[!q&&(0,Y.jsx)(pe,{attempt:h,next:D}),q&&(0,Y.jsxs)(`div`,{className:`mb-6`,children:[(0,Y.jsxs)(o,{to:c(h.course.slug,h.activityId),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,Y.jsx)(i,{className:`size-4`}),` `,h.course.title]}),(0,Y.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:h.quizTitle}),(0,Y.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Attempt `,h.attemptNumber,`. Your answers save automatically as you go.`]})]}),(0,Y.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_200px]`,children:[(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[h.questions.map((e,r)=>{let i=h.results?.[e.id],a=!!i?.pending;return(0,Y.jsxs)(p,{id:`q-${e.id}`,className:x(`scroll-mt-32 p-5 sm:p-6`,i&&!a&&(i.correct?`border-emerald-500/40`:i.partial?`border-amber-500/40`:`border-red-500/30`),a&&`border-amber-500/40 border-dashed`),children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`p`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Question `,r+1,` · `,re[e.type].hint]}),a?(0,Y.jsxs)(t,{variant:`warning`,children:[(0,Y.jsx)(P,{}),` `,h.canGrade?`Needs marking`:`Being marked`,` · `,A(e.points),` pt`,e.points===1?``:`s`]}):i?(0,Y.jsxs)(t,{variant:i.correct?`success`:i.partial?`warning`:`danger`,children:[i.correct?(0,Y.jsx)(n,{}):(0,Y.jsx)(M,{}),A(i.points),` / `,A(i.maxPoints)]}):(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[A(e.points),` point`,e.points===1?``:`s`]})]}),(0,Y.jsx)(se,{source:e.prompt,className:`mb-4 text-[15px] font-medium [&_p]:my-0`}),(0,Y.jsx)(ie,{question:e,answer:O[e.id],onChange:t=>me(e.id,t),review:!!h.review,disabled:!q}),e.type===`essay`&&!q&&(h.canGrade?(0,Y.jsx)(ue,{attempt:h,question:e,onSaved:ge}):(0,Y.jsx)(de,{result:i})),h.review&&e.explanation&&(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-3 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,Y.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-sky-600 dark:text-sky-400`}),(0,Y.jsx)(ce,{source:e.explanation})]})]},e.id)}),q&&(0,Y.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,Y.jsxs)(w,{size:`lg`,onClick:$,loading:Z.isPending,children:[(0,Y.jsx)(F,{}),` Submit answers`]})})]}),(0,Y.jsxs)(p,{className:`hidden p-4 lg:sticky lg:top-36 lg:block`,children:[(0,Y.jsx)(`p`,{className:`mb-3 text-xs font-semibold text-muted-foreground`,children:`Questions`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:h.questions.map((e,t)=>{let n=h.results?.[e.id],r=j(e,O[e.id]);return(0,Y.jsx)(`a`,{href:`#q-${e.id}`,"aria-label":`Question ${t+1}`,className:x(`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?.pending&&`border-dashed border-amber-500 bg-amber-500/15 text-amber-700 dark:text-amber-300`,n&&!n.pending&&n.correct&&`border-emerald-600 bg-emerald-600 text-white`,n&&!n.pending&&!n.correct&&n.partial&&`border-amber-500 bg-amber-500 text-white`,n&&!n.pending&&!n.correct&&!n.partial&&`border-red-500 bg-red-500 text-white`),children:t+1},e.id)})})]})]})]})]})}export{X as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,C as t,D as n,E as r,Ft as i,Gt as a,It as o,O as s,Ot as c,St as l,T as u,Wt as d,_ as f,_t as p,at as m,dt as h,f as g,it as _,k as v,l as y,lt as b,p as x,s as S,t as C,u as w}from"./index-CEZdqKdi.js";import{H as T,N as E,Q as D,U as O,_ as k,dt as A,ft as j,g as M,h as N,i as ee,m as P,mt as F,r as I,t as L,ut as te}from"./hooks-EFhyJ5yU.js";import{n as R,t as z}from"./arrow-up-lI30bvj5.js";import{t as B}from"./library-Bcm33ouq.js";import{t as ne}from"./pencil-DFUpj3YP.js";import{t as V}from"./shuffle-C1aB_4dp.js";import{E as re,c as H,n as ie,t as ae}from"./misc-CyGhN6HT.js";import{a as oe,i as U,n as se,o as W,r as ce,t as G}from"./bank-S3XEFPfe.js";import{i as le,n as K,r as q,s as ue}from"./QuestionAnswer-CJIoWSz2.js";import{t as de}from"./chevron-left-Bu6IJANV.js";import{a as fe}from"./context-D8W_QqNi.js";import{n as pe}from"./frame-DZh5g5b3.js";var J={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`}]]};J.node;var me=T(J),Y=F(j(),1),X=A(),Z=25;function he({courseId:i,open:a,onOpenChange:o,inQuiz:l,onAdd:u}){let d=W(i,a),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),_=L(m.trim(),250),[y,x]=(0,Y.useState)(``),[C,T]=(0,Y.useState)(1),[A,j]=(0,Y.useState)(new Map);(0,Y.useEffect)(()=>{a&&j(new Map)},[a]),(0,Y.useEffect)(()=>T(1),[f,_,y]);let N=O({queryKey:[`bank-questions`,i,`picker`,{categoryId:f,term:_,type:y,page:C}],queryFn:()=>{let e=new URLSearchParams({page:String(C),pageSize:String(Z),subcategories:`1`});return f&&e.set(`categoryId`,f),_&&e.set(`q`,_),y&&e.set(`type`,y),P.get(`/courses/${i}/questions?${e}`)},enabled:a,placeholderData:D}),ee=e=>j(t=>{let n=new Map(t);return n.has(e.id)?n.delete(e.id):n.set(e.id,e),n}),F=N.data,I=F?Math.max(1,Math.ceil(F.total/Z)):1;return(0,X.jsx)(r,{open:a,onOpenChange:o,children:(0,X.jsxs)(s,{size:`lg`,children:[(0,X.jsx)(e,{icon:(0,X.jsx)(B,{className:`size-5`}),title:`Add from the question bank`,description:`Tick the questions to add. They go at the end of the quiz.`}),(0,X.jsxs)(`div`,{className:`grid gap-2 px-6 pb-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(b,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(w,{value:m,onChange:e=>h(e.target.value),placeholder:`Search`,className:`pl-9`,"aria-label":`Search questions`})]}),(0,X.jsx)(G,{categories:d.data??[],allLabel:`All categories`,value:f,onChange:e=>p(e.target.value),"aria-label":`Category`}),(0,X.jsxs)(g,{value:y,onChange:e=>x(e.target.value),"aria-label":`Question type`,children:[(0,X.jsx)(`option`,{value:``,children:`All types`}),K.map(e=>(0,X.jsx)(`option`,{value:e,children:q[e].short},e))]})]}),(0,X.jsx)(n,{className:`border-t px-0 pb-0`,children:N.error?(0,X.jsx)(`div`,{className:`p-6`,children:(0,X.jsx)(ie,{error:N.error,onRetry:()=>N.refetch()})}):F?F.items.length===0?(0,X.jsx)(`div`,{className:`p-6`,children:(0,X.jsx)(ae,{icon:B,title:`No questions found`,description:`Create questions in the bank, or change the filters.`})}):(0,X.jsx)(`ul`,{className:k(`divide-y`,N.isPlaceholderData&&`opacity-60`),children:F.items.map(e=>{let n=l.has(e.id),r=`pick-${e.id}`;return(0,X.jsxs)(`li`,{className:k(`flex items-start gap-3 px-6 py-3`,n&&`opacity-60`),children:[(0,X.jsx)(S,{id:r,checked:n||A.has(e.id),disabled:n,onCheckedChange:()=>ee(e),className:`mt-2`}),(0,X.jsx)(U,{type:e.type}),(0,X.jsxs)(`label`,{htmlFor:r,className:k(`min-w-0 flex-1`,!n&&`cursor-pointer`),children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium break-words`,children:e.name||e.excerpt}),(0,X.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[q[e.type].short,` · `,e.categoryName,` · `,le(e.points),` mark`,e.points===1?``:`s`,n&&(0,X.jsx)(t,{variant:`info`,children:`In this quiz`})]})]})]},e.id)})}):(0,X.jsxs)(`div`,{className:`space-y-2 p-6`,children:[(0,X.jsx)(H,{className:`h-12`}),(0,X.jsx)(H,{className:`h-12`}),(0,X.jsx)(H,{className:`h-12`})]})}),F&&F.total>Z&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t px-6 py-2 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[`Page `,C,` of `,I]}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[(0,X.jsx)(M,{variant:`outline`,size:`icon-xs`,onClick:()=>T(C-1),disabled:C<=1,"aria-label":`Previous page`,children:(0,X.jsx)(de,{})}),(0,X.jsx)(M,{variant:`outline`,size:`icon-xs`,onClick:()=>T(C+1),disabled:C>=I,"aria-label":`Next page`,children:(0,X.jsx)(c,{})})]})]}),(0,X.jsxs)(v,{className:`border-t sm:items-center`,children:[(0,X.jsxs)(`span`,{className:`mr-auto hidden text-sm text-muted-foreground sm:block`,children:[E(A.size,`question`),` selected`]}),(0,X.jsx)(M,{variant:`outline`,onClick:()=>o(!1),children:`Cancel`}),(0,X.jsxs)(M,{disabled:A.size===0,onClick:()=>{u([...A.values()]),o(!1)},children:[`Add `,A.size||``,` to quiz`]})]})]})})}function ge({courseId:t,open:i,onOpenChange:a,fixed:o,onAdd:c}){let l=W(t,i),u=(0,Y.useMemo)(()=>l.data??[],[l.data]),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(`1`),[b,S]=(0,Y.useState)(`1`);(0,Y.useEffect)(()=>{i&&(g(`1`),S(`1`),m(!1))},[i]),(0,Y.useEffect)(()=>{i&&u.length&&!u.some(e=>e.id===d)&&f(u.find(e=>e.questionCount>0)?.id??u[0].id)},[i,u,d]);let C=d?p?ue(u,d):[d]:[],T=u.filter(e=>C.includes(e.id)).reduce((e,t)=>e+t.questionCount,0),D=o.filter(e=>C.includes(e.categoryId)).length,O=Math.max(0,T-D),A=Number(h),j=u.some(e=>e.parentId===d),N=!!d&&Number.isInteger(A)&&A>=1&&A<=200&&Number(b)>=0&&b!==``;return(0,X.jsx)(r,{open:i,onOpenChange:a,children:(0,X.jsx)(s,{size:`sm`,children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=u.find(e=>e.id===d);c({category:{id:t.id,name:t.name},questionCount:A,includeSubcategories:p&&j,points:Number(b),available:O}),a(!1)},children:[(0,X.jsx)(e,{icon:(0,X.jsx)(V,{className:`size-5`}),title:`Add random questions`,description:`Each attempt gets its own pick from the category, never repeating a question already in the quiz.`}),(0,X.jsx)(n,{className:`space-y-4`,children:l.isLoading?(0,X.jsx)(H,{className:`h-40`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(y,{label:`Category`,children:e=>(0,X.jsx)(G,{...e,categories:u,value:d,onChange:e=>f(e.target.value)})}),j&&(0,X.jsx)(x,{label:`Include subcategories`,checked:p,onCheckedChange:m}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(y,{label:`Questions`,children:e=>(0,X.jsx)(w,{...e,type:`number`,min:1,max:200,step:1,value:h,onChange:e=>g(e.target.value)})}),(0,X.jsx)(y,{label:`Mark for each`,children:e=>(0,X.jsx)(w,{...e,type:`number`,min:0,step:`any`,value:b,onChange:e=>S(e.target.value)})})]}),(0,X.jsxs)(`p`,{className:k(`flex items-start gap-2 text-sm`,A>O?`text-amber-700 dark:text-amber-400`:`text-muted-foreground`),children:[A>O&&(0,X.jsx)(_,{className:`mt-0.5 size-4 shrink-0`}),(0,X.jsxs)(`span`,{children:[E(O,`question`),` to pick from`,D>0&&` (${D} already in the quiz ${D===1?`isn't`:`aren't`} counted)`,`.`,A>O&&` Add more questions to the category, or students won’t be able to start the quiz.`]})]})]})}),(0,X.jsxs)(v,{children:[(0,X.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>a(!1),children:`Cancel`}),(0,X.jsx)(M,{type:`submit`,disabled:!N,children:`Add to quiz`})]})]})})})}var _e=0,Q=()=>`s${Date.now().toString(36)}${_e++}`;function $(e){return e.map(e=>e.kind===`question`?{id:e.id||void 0,kind:e.kind,questionId:e.question?.id,points:Number(e.points)}:{id:e.id||void 0,kind:e.kind,categoryId:e.category?.id,questionCount:Number(e.questionCount),includeSubcategories:e.includeSubcategories,points:Number(e.points)})}function ve({slot:e,index:t,total:n,first:r,onChange:i,onMove:a,onRemove:o,onEdit:s,onPreview:c}){let u=e.question,d=e.kind===`random`&&e.questionCount>1?`${r}–${r+e.questionCount-1}`:String(r),f=u?u.name||u.excerpt:``,p=e.kind===`random`&&e.available!=null&&e.needed!=null&&e.needed>e.available;return(0,X.jsxs)(C,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`span`,{className:`grid h-7 min-w-7 shrink-0 place-items-center rounded-full bg-primary px-2 text-xs font-semibold text-primary-foreground tabular-nums`,children:d}),e.kind===`question`?u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{type:u.type,className:`hidden sm:grid`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium break-words`,children:f}),u.name&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:u.excerpt}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[q[u.type].short,` · `,u.categoryName]})]})]}):(0,X.jsx)(`p`,{className:`flex-1 text-sm text-muted-foreground`,children:`This question is no longer in the bank.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`hidden size-8 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary sm:grid`,children:(0,X.jsx)(V,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`text-sm font-medium break-words`,children:[E(e.questionCount,`random question`),` from “`,e.category?.name,`”`,e.includeSubcategories&&` and its subcategories`]}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[`Picked for each attempt, never repeating a question.`,e.available!=null&&` ${E(e.available,`question`)} to choose from.`]}),p&&(0,X.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400`,children:[(0,X.jsx)(_,{className:`mt-px size-3.5 shrink-0`}),` Not enough questions: random slots need `,e.needed,` from here. Students can't start the quiz until there are more.`]})]})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-3 sm:pl-10`,children:[e.kind===`random`&&(0,X.jsxs)(`label`,{className:`space-y-1 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`block`,children:`Questions`}),(0,X.jsx)(w,{type:`number`,min:1,max:200,step:1,value:e.questionCount,onChange:t=>i({...e,questionCount:Number(t.target.value)}),className:`h-8 w-20`})]}),(0,X.jsxs)(`label`,{className:`space-y-1 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`block`,children:e.kind===`random`?`Mark each`:`Mark`}),(0,X.jsx)(w,{type:`number`,min:0,step:`any`,value:e.points,onChange:t=>i({...e,points:Number(t.target.value)}),className:`h-8 w-20`})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,X.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:()=>a(-1),disabled:t===0,"aria-label":`Move ${d} up`,children:(0,X.jsx)(z,{})}),(0,X.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:()=>a(1),disabled:t===n-1,"aria-label":`Move ${d} down`,children:(0,X.jsx)(R,{})}),e.kind===`question`&&u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:c,"aria-label":`Preview question ${d}`,children:(0,X.jsx)(l,{})}),(0,X.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:s,"aria-label":`Edit question ${d}`,children:(0,X.jsx)(ne,{})})]}),(0,X.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:o,"aria-label":`Remove ${d} from the quiz`,className:`hover:text-destructive`,children:(0,X.jsx)(m,{})})]})]})]})}function ye(){let{activityId:e}=d(),t=te(),n=fe(),{data:r}=pe(e);I(r?`Questions · ${r.title}`:`Questions`);let s=r?.courseId??``,{data:c}=W(s,!!s),l=O({queryKey:[`slots`,e],queryFn:()=>P.get(`/activities/${e}/slots`)}),[m,g]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)([]),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)(null),[A,j]=(0,Y.useState)(null),F=e=>{let t=e.slots.map(e=>({...e,key:Q()}));g(t),y(JSON.stringify($(t))),x(e.problems)};(0,Y.useEffect)(()=>{l.data&&m===null&&F(l.data)},[l.data,m]);let L=m!==null&&JSON.stringify($(m))!==v;ee(L);let R=a({mutationFn:()=>P.put(`/activities/${e}/slots`,{slots:$(m)}),onSuccess:async i=>{re.success(i.problems.length?`Saved, but some random questions need attention`:`Quiz questions saved`),F(i),t.setQueryData([`slots`,e],i),await n(r?.course.slug)},onError:e=>re.error(N(e),{duration:8e3})}),z=(0,Y.useMemo)(()=>m??[],[m]),ne=z.reduce((e,t,n)=>[...e,n===0?1:e[n-1]+z[n-1].questionCount],[]),U=z.reduce((e,t)=>e+(Number(t.questionCount)||0),0),G=z.reduce((e,t)=>e+(Number(t.points)||0)*(Number(t.questionCount)||0),0),K=z.flatMap(e=>e.kind===`question`&&e.question?[e.question]:[]),q=new Set(K.map(e=>e.id)),ue=(e,t)=>g(n=>n.map((n,r)=>r===e?t:n)),de=(e,t)=>g(n=>{let r=[...n];return[r[e],r[e+t]]=[r[e+t],r[e]],r}),J=e=>g(t=>[...t,...e.map(e=>({key:Q(),id:``,kind:`question`,points:e.points,questionCount:1,question:e,category:null,includeSubcategories:!1,available:null,needed:null}))]),Z=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(M,{variant:`outline`,onClick:()=>C(!0),children:[(0,X.jsx)(B,{}),` Add from bank`]}),(0,X.jsxs)(M,{variant:`outline`,onClick:()=>T(!0),children:[(0,X.jsx)(V,{}),` Add random questions`]}),(0,X.jsxs)(M,{variant:`outline`,onClick:()=>k({questionId:null}),children:[(0,X.jsx)(h,{}),` Create new question`]})]});return(0,X.jsxs)(f,{size:`narrow`,className:`pb-28 lg:pb-28`,children:[r&&(0,X.jsxs)(`div`,{className:`mb-6`,children:[(0,X.jsxs)(o,{to:u(r.course.slug,r.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(i,{className:`size-4`}),` `,r.title]}),(0,X.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Quiz questions`}),(0,X.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Questions come from the course's`,` `,(0,X.jsx)(o,{to:`/courses/${r.course.slug}/question-bank`,className:`font-medium text-primary hover:underline`,children:`question bank`}),`. Add specific questions, or random ones picked for each attempt. Essays are marked by hand; everything else is graded automatically.`]})]}),l.error?(0,X.jsx)(ie,{error:l.error,onRetry:()=>l.refetch()}):!m||!r?(0,X.jsx)(H,{className:`h-96`}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[!L&&b.length>0&&(0,X.jsxs)(`div`,{role:`alert`,className:`flex gap-3 rounded-xl border border-amber-500/30 bg-amber-500/[0.07] px-4 py-3 text-sm`,children:[(0,X.jsx)(_,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`Students can't start this quiz yet`}),b.map(e=>(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e},e))]})]}),m.length===0&&(0,X.jsx)(ae,{icon:p,title:`No questions yet`,description:`Pick questions from the bank, draw random ones from a category, or write a new one.`,action:Z}),m.map((e,t)=>(0,X.jsx)(ve,{slot:e,index:t,total:m.length,first:ne[t],onChange:e=>ue(t,e),onMove:e=>de(t,e),onRemove:()=>g(e=>e.filter((e,n)=>n!==t)),onEdit:()=>k({questionId:e.question.id,slotKey:e.key}),onPreview:()=>j(e.question.id)},e.key)),m.length>0&&Z]}),m&&(0,X.jsx)(`div`,{className:`fixed inset-x-0 bottom-0 z-30 border-t bg-card/90 backdrop-blur-lg lg:left-64`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[E(U,`question`),` · `,le(G),` point`,G===1?``:`s`,L&&(0,X.jsx)(`span`,{className:`ml-2 font-medium text-amber-600 dark:text-amber-400`,children:`Unsaved changes`})]}),(0,X.jsxs)(M,{className:`ml-auto`,onClick:()=>R.mutate(),loading:R.isPending,disabled:!L,children:[(0,X.jsx)(me,{}),` Save`]})]})}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(he,{courseId:s,open:S,onOpenChange:C,inQuiz:q,onAdd:J}),(0,X.jsx)(ge,{courseId:s,open:w,onOpenChange:T,fixed:K,onAdd:e=>g(t=>[...t,{key:Q(),id:``,kind:`random`,points:e.points,questionCount:e.questionCount,question:null,category:e.category,includeSubcategories:e.includeSubcategories,available:e.available,needed:e.questionCount}])}),(0,X.jsx)(se,{courseId:s,open:!!D,onOpenChange:e=>!e&&k(null),questionId:D?.questionId,defaultCategoryId:K.at(-1)?.categoryId??null,onSaved:e=>{let t=oe(e,c);D?.slotKey?g(e=>e.map(e=>e.key===D.slotKey?{...e,question:t}:e)):J([t])}}),(0,X.jsx)(ce,{questionId:A,open:!!A,onOpenChange:e=>!e&&j(null)})]})]})}export{ye as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,Et as t,Ft as n,Gt as ee,It as r,M as i,Ot as a,T as o,Wt as s,_ as te,l as c,m as l,r as u,t as d,u as ne}from"./index-CEZdqKdi.js";import{D as f,E as p,T as m,U as h,_ as re,dt as g,ft as _,g as v,h as y,m as b,mt as x,r as S,ut as C}from"./hooks-EFhyJ5yU.js";import{t as w}from"./inbox-x1U4YU-c.js";import{E as T,c as E,n as D,s as ie,t as O}from"./misc-CyGhN6HT.js";import{n as k,o as A}from"./groups-CrYV_AFp.js";import{n as j}from"./markdown-HNlXovsL.js";import{n as M}from"./frame-DZh5g5b3.js";var N=x(_(),1),P=g();function F(e){return e.needsGrading?{label:`Needs grading`,variant:`warning`}:e.grade?.score==null?{label:`Not submitted`,variant:`neutral`}:{label:`${p(e.grade.score)} / ${p(e.grade.maxGrade)}`,variant:`success`}}function I(){let{activityId:g}=s(),_=C(),{data:x}=M(g);S(x?`Submissions · ${x.title}`:`Submissions`);let I=[`submissions`,g],{data:L,isLoading:R,error:z,refetch:B}=h({queryKey:I,queryFn:()=>b.get(`/activities/${g}/submissions`)}),[V,H]=(0,N.useState)(`needs`),[U,W]=(0,N.useState)(null),[G,K]=(0,N.useState)(``),[q,J]=(0,N.useState)(``),Y=A(x?.course.id),X=(0,N.useMemo)(()=>(L??[]).filter(e=>Y.matches(e.user.id)&&(V===`needs`?e.needsGrading:V===`graded`?e.grade?.score!=null&&!e.needsGrading:V!==`missing`||!e.submission)),[L,V,Y.matches]);(0,N.useEffect)(()=>{L&&L.length&&!L.some(e=>e.needsGrading)&&V===`needs`&&H(`all`)},[L,V]),(0,N.useEffect)(()=>{!U&&X[0]&&W(X[0].user.id)},[X,U]);let Z=L?.find(e=>e.user.id===U)??null;(0,N.useEffect)(()=>{K(Z?.grade?.score==null?``:String(Z.grade.score)),J(Z?.grade?.feedback??``)},[Z?.user.id,Z?.grade?.score,Z?.grade?.feedback]);let Q=ee({mutationFn:()=>b.put(`/activities/${g}/grades/${Z.user.id}`,{score:G===``?null:Number(G),feedback:q.trim()||null}),onSuccess:async()=>{T.success(`Saved grade for ${Z.user.name}`);let e=(L??[]).filter(e=>e.needsGrading&&e.user.id!==Z.user.id&&Y.matches(e.user.id));await Promise.all([_.invalidateQueries({queryKey:I}),_.invalidateQueries({queryKey:[`activity`,g]}),_.invalidateQueries({queryKey:[`dashboard`]})]),e[0]&&W(e[0].user.id)},onError:e=>T.error(y(e))}),$=e=>(L??[]).filter(t=>Y.matches(t.user.id)&&(e===`needs`?t.needsGrading:e===`graded`?t.grade?.score!=null&&!t.needsGrading:e!==`missing`||!t.submission)).length;return(0,P.jsxs)(te,{size:`wide`,children:[x&&(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsxs)(r,{to:o(x.course.slug,x.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,P.jsx)(n,{className:`size-4`}),` `,x.title]}),(0,P.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Grade submissions`}),(0,P.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[x.course.title,` · out of `,p(x.maxGrade),` points`]})]}),z?(0,P.jsx)(D,{error:z,onRetry:()=>B()}):R||!L?(0,P.jsx)(E,{className:`h-[480px]`}):L.length===0?(0,P.jsx)(O,{icon:w,title:`No students yet`,description:`Students enrolled in this course will appear here.`}):(0,P.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,P.jsxs)(d,{className:`overflow-hidden lg:sticky lg:top-20`,children:[(0,P.jsxs)(`div`,{className:`border-b p-3`,children:[(0,P.jsx)(ie,{value:V,onChange:e=>{H(e),W(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,P.jsx)(k,{filter:Y,onChange:()=>W(null),className:`mt-2 sm:w-full`})]}),(0,P.jsxs)(`div`,{className:`ck-scrollbar max-h-[65vh] divide-y overflow-y-auto`,children:[X.length===0&&(0,P.jsx)(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Nothing here. 🎉`}),X.map(t=>{let n=F(t);return(0,P.jsxs)(`button`,{onClick:()=>W(t.user.id),className:re(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/50`,U===t.user.id&&`bg-primary/[0.06]`),children:[(0,P.jsx)(i,{user:t.user,size:`sm`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:t.user.name}),(0,P.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t.submission?`Submitted ${f(t.submission.submittedAt)}`:`No submission`})]}),(0,P.jsx)(e,{variant:n.variant,children:n.label}),(0,P.jsx)(a,{className:`size-4 text-muted-foreground/50`})]},t.user.id)})]})]}),Z?(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsxs)(d,{className:`p-6`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(i,{user:Z.user,size:`lg`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`truncate font-semibold`,children:Z.user.name}),(0,P.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:Z.user.email})]}),Z.submission&&(0,P.jsxs)(`div`,{className:`shrink-0 text-right text-sm`,children:[(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Submitted`}),(0,P.jsx)(`p`,{className:`font-medium`,children:m(Z.submission.submittedAt)})]}),Z.submission?.late&&(0,P.jsx)(e,{variant:`warning`,children:`Late`})]}),(0,P.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[!Z.submission&&(0,P.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,P.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-5`,children:(0,P.jsx)(j,{source:Z.submission.text,className:`prose-sm`})}),Z.submission&&Z.submission.files.length>0&&(0,P.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Z.submission.files.map(e=>(0,P.jsx)(u,{file:e},e.id))})]})]}),(0,P.jsx)(d,{className:`p-6`,children:(0,P.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Q.mutate()},children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,P.jsx)(t,{className:`size-4 text-primary`}),` Grade and feedback`]}),(0,P.jsx)(c,{label:`Score (out of ${p(x?.maxGrade??0)})`,className:`sm:w-56`,children:e=>(0,P.jsx)(ne,{...e,type:`number`,step:`any`,min:0,max:x?.maxGrade??void 0,value:G,onChange:e=>K(e.target.value)})}),(0,P.jsx)(c,{label:`Feedback for the student`,optional:!0,children:e=>(0,P.jsx)(l,{...e,rows:5,value:q,onChange:e=>J(e.target.value),placeholder:`What went well? What could be better?`})}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Z.grade?.gradedAt?(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last graded `,f(Z.grade.gradedAt),Z.grade.gradedBy&&` by ${Z.grade.gradedBy.name}`]}):(0,P.jsx)(`span`,{}),(0,P.jsx)(v,{type:`submit`,loading:Q.isPending,disabled:G===``,children:`Save grade`})]})]})})]}):(0,P.jsx)(O,{icon:t,title:`Select a student`,description:`Pick someone from the list to review their work.`})]})]})}export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dt as e,Gt as t,It as n,Rt as r,h as i,t as a}from"./index-CEZdqKdi.js";import{U as o,_ as s,c,dt as l,ft as u,g as d,h as f,m as p,mt as m,r as h,ut as g}from"./hooks-EFhyJ5yU.js";import{E as _,l as v,w as y}from"./misc-CyGhN6HT.js";import{t as b}from"./mail-x-B6oBqlcw.js";var x=m(u(),1),S=l(),C=`/profile?section=email`;function w({icon:e,tone:t,title:n,children:r}){return(0,S.jsxs)(a,{className:`w-full p-6 sm:p-8`,children:[(0,S.jsx)(`span`,{className:s(`mb-5 grid size-11 place-items-center rounded-full`,t===`primary`&&`bg-primary/10 text-primary`,t===`success`&&`bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,t===`danger`&&`bg-red-500/12 text-red-600 dark:text-red-400`),"aria-hidden":!0,children:e}),(0,S.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-balance`,children:n}),(0,S.jsx)(`div`,{className:`mt-2 space-y-5 text-sm text-muted-foreground`,children:r})]})}function T(){h(`Unsubscribe`);let[s]=r(),l=s.get(`token`)?.trim()??``,{data:u}=c(),m=g(),[T,E]=(0,x.useState)(null),D=[`unsubscribe`,l],O=o({queryKey:D,queryFn:()=>p.get(`/email/unsubscribe?token=${encodeURIComponent(l)}`),enabled:!!l,retry:!1}),k=t({mutationFn:e=>p.post(`/email/unsubscribe`,{token:l,scope:e}),onSuccess:(e,t)=>{m.setQueryData(D,e),E(t)},onError:e=>_.error(f(e))}),A=O.data?.siteName??u?.site.name??`Coursekit`,j=(0,S.jsx)(d,{asChild:!0,variant:`outline`,children:(0,S.jsx)(n,{to:C,children:`Manage email preferences`})}),M;if(!l||O.error)M=(0,S.jsxs)(w,{icon:(0,S.jsx)(y,{className:`size-5`}),tone:`danger`,title:`This link doesn't work`,children:[(0,S.jsx)(`p`,{children:l?f(O.error):`The unsubscribe link is incomplete. Use the link from a recent email.`}),(0,S.jsx)(`p`,{children:`You can also change which emails you get from your profile after signing in.`}),j]});else if(!O.data)M=(0,S.jsxs)(a,{className:`grid w-full place-items-center p-10`,"aria-busy":!0,children:[(0,S.jsx)(v,{className:`size-6`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Loading`})]});else if(T||O.data.unsubscribed){let t=T===`category`&&O.data.category;M=(0,S.jsxs)(w,{icon:(0,S.jsx)(e,{className:`size-5`}),tone:`success`,title:t?`${O.data.category.label} emails are off`:T?`You're unsubscribed`:`You're already unsubscribed`,children:[(0,S.jsx)(`p`,{children:t?`You won't get emails about ${O.data.category.label.toLowerCase()} from ${A} any more. Other emails continue as before.`:`${A} won't email ${O.data.maskedEmail} any more. You'll still see notifications when you sign in.`}),(0,S.jsx)(`p`,{children:`Changed your mind? You can turn emails back on from your profile.`}),j]})}else{let{category:e}=O.data;M=(0,S.jsxs)(w,{icon:(0,S.jsx)(b,{className:`size-5`}),tone:`primary`,title:`Unsubscribe from ${A} emails?`,children:[(0,S.jsxs)(`p`,{children:[`We'll stop emailing `,(0,S.jsx)(`span`,{className:`font-medium text-foreground`,children:O.data.maskedEmail}),`. You'll still see notifications when you sign in.`]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[(0,S.jsx)(d,{onClick:()=>k.mutate(`all`),loading:k.isPending&&k.variables===`all`,disabled:k.isPending,children:`Unsubscribe from all emails`}),e&&!O.data.categoryDisabled&&(0,S.jsxs)(d,{variant:`outline`,onClick:()=>k.mutate(`category`),loading:k.isPending&&k.variables===`category`,disabled:k.isPending,children:[`Only stop `,e.label.toLowerCase(),` emails`]})]}),(0,S.jsxs)(`p`,{className:`text-xs`,children:[`Or`,` `,(0,S.jsx)(n,{to:C,className:`font-medium text-primary underline-offset-4 hover:underline`,children:`choose which emails you get`}),`.`]})]})}return(0,S.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-background px-4 py-7 sm:px-12`,children:[(0,S.jsx)(i,{name:A}),(0,S.jsx)(`main`,{className:`mx-auto flex w-full max-w-md flex-1 items-center py-12`,children:M})]})}export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e,U as t,_ as n,c as r,dt as i,ft as a,g as o,h as s,m as c,mt as l,p as u,r as d}from"./hooks-EFhyJ5yU.js";import{Ht as f,It as p,Wt as m,ct as h,d as g,h as _,t as v,u as y}from"./index-CEZdqKdi.js";import{t as b}from"./shield-x-RpNHS0o8.js";import{a as x,i as S}from"./completion-2z7I-ypT.js";import{n as C}from"./certificate-sheet-DzW0lfzR.js";import{l as w}from"./misc-CyGhN6HT.js";var T={name:`search-check`,size:24,node:[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]};T.node;var E=e(T),D={name:`shield-exclamation-point`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]],aliases:[`shield-alert`]};D.node;var O=e(D),k=l(a(),1),A=i();function j({label:e,children:t}){return(0,A.jsxs)(`div`,{className:`grid gap-0.5 sm:grid-cols-[120px_minmax(0,1fr)] sm:gap-3`,children:[(0,A.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground sm:text-sm`,children:e}),(0,A.jsx)(`dd`,{className:`text-sm font-medium break-words`,children:t})]})}function M({code:e}){let r=x(e),{data:i,isLoading:a,error:o}=t({queryKey:[`verify`,r],queryFn:()=>c.get(`/certificates/verify/${r}`),enabled:!!r,retry:!1});if(r&&a)return(0,A.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground`,role:`status`,children:[(0,A.jsx)(w,{className:`size-4`}),` Checking…`]});if(!r||o instanceof u&&o.status===404)return(0,A.jsxs)(`div`,{role:`status`,className:`flex gap-3 rounded-xl border border-amber-500/30 bg-amber-500/[0.07] p-4`,children:[(0,A.jsx)(O,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,A.jsxs)(`div`,{className:`text-sm`,children:[(0,A.jsx)(`p`,{className:`font-semibold`,children:`No certificate matches this code`}),(0,A.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Check that you typed all 12 characters as printed on the certificate, for example 7QK2-M9XD-4TPA.`})]})]});if(o||!i)return(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:s(o)});let l=i.valid;return(0,A.jsxs)(`div`,{role:`status`,className:n(`rounded-xl border p-4 sm:p-5`,l?`border-success/35 bg-success/[0.07]`:`border-destructive/35 bg-destructive/[0.06]`),children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:n(`grid size-10 shrink-0 place-items-center rounded-full`,l?`bg-success/15 text-success`:`bg-destructive/12 text-destructive`),children:l?(0,A.jsx)(h,{className:`size-5`}):(0,A.jsx)(b,{className:`size-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-semibold`,children:l?`Valid certificate`:`This certificate has been revoked`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l?`Issued by this site for completing a course.`:`It no longer counts as proof of completion.`})]})]}),(0,A.jsxs)(`dl`,{className:`mt-4 space-y-2.5 border-t pt-4`,children:[(0,A.jsx)(j,{label:`Awarded to`,children:i.recipientName}),(0,A.jsx)(j,{label:`Course`,children:i.courseTitle}),(0,A.jsx)(j,{label:`Completed`,children:C(i.completedAt)}),(0,A.jsx)(j,{label:`Code`,children:(0,A.jsx)(`span`,{className:`font-mono`,children:i.code})})]})]})}function N(){let{code:e}=m(),t=f(),{data:n}=r(),[i,a]=(0,k.useState)(e??``);d(`Verify a certificate`);let s=n?.site.name??`Coursekit`;return(0,A.jsx)(`div`,{className:`ck-dots grid min-h-dvh place-items-center bg-background px-4 py-10`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,A.jsx)(p,{to:`/`,className:`mx-auto flex w-fit`,children:(0,A.jsx)(_,{name:s})}),(0,A.jsxs)(v,{className:`mt-6 p-5 sm:p-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary`,children:(0,A.jsx)(E,{className:`size-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Verify a certificate`}),(0,A.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:`Enter the code printed at the bottom of the certificate.`})]})]}),(0,A.jsxs)(`form`,{className:`mt-5 flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:n=>{n.preventDefault();let r=x(i);t(`/verify/${r?S(r):encodeURIComponent(i.trim())}`,{replace:!!e})},children:[(0,A.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,A.jsx)(g,{htmlFor:`certificate-code`,children:`Certificate code`}),(0,A.jsx)(y,{id:`certificate-code`,value:i,onChange:e=>a(e.target.value),placeholder:`XXXX-XXXX-XXXX`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`characters`,className:`font-mono tracking-wider uppercase placeholder:normal-case placeholder:tracking-normal`,required:!0})]}),(0,A.jsx)(o,{type:`submit`,disabled:!i.trim(),children:`Verify`})]}),e&&(0,A.jsx)(`div`,{className:`mt-5`,"aria-live":`polite`,children:(0,A.jsx)(M,{code:e},e)})]}),(0,A.jsxs)(`p`,{className:`mt-6 text-center text-sm text-muted-foreground`,children:[`Certificates are issued by `,s,`.`,` `,(0,A.jsx)(p,{to:`/`,className:`font-medium text-primary hover:underline`,children:`Go to the site`})]})]})})}export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={status:e=>[`course`,e,`completion`],report:e=>[`course`,e,`completion`,`report`],settings:e=>[`course`,e,`completion`,`settings`],certificates:e=>[`course`,e,`certificates`],courseBadges:e=>[`course`,e,`badges`],badge:e=>[`badge`,e],siteBadges:[`badges`,`site`],myBadges:[`me`,`badges`],myCertificates:[`me`,`certificates`]};function t(e){if(e.criteria===`completion`)return`Earned by completing the course`;if(e.criteria===`courses`){let t=e.criteriaCourses.map(e=>e.title);return t.length===0?`Earned by completing a set of courses`:`Earned by completing ${t.length===1?t[0]:`${t.slice(0,-1).join(`, `)} and ${t.at(-1)}`}`}return e.course?`Awarded by teachers`:`Awarded by administrators`}function n(e){return e==null?`–`:`${Number.isInteger(e)?e:e.toFixed(1).replace(/\.0$/,``)}%`}export{t as n,n as r,e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e}from"./hooks-
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};t.node;var n=e(t),r={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};r.node;var i=e(r);export{n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Mt as e,Nt as t,bt as n,gt as r,mt as i,st as a,ut as o}from"./index-CEZdqKdi.js";import{H as s,_ as c,dt as l,ft as u,mt as d}from"./hooks-EFhyJ5yU.js";import{t as f}from"./globe-DDTr53UY.js";import{t as p}from"./lightbulb-CjSpJ1_v.js";import{t as m}from"./target-G9Q_WQLB.js";import{t as h}from"./trophy-BFFngFEh.js";var g={name:`brain`,size:24,node:[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4`,key:`5nuw1p`}],[`path`,{d:`M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294`,key:`18ldcf`}],[`path`,{d:`M17.996 5.125a4 4 0 012.526 5.77`,key:`1sdu8q`}],[`path`,{d:`M18 18a4 4 0 002-7.465`,key:`7xqqvr`}],[`path`,{d:`M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517`,key:`t46ysz`}],[`path`,{d:`M6 18a4 4 0 01-2-7.465`,key:`1y2m15`}],[`path`,{d:`M6.004 5.125a4 4 0 00-2.526 5.77`,key:`3cw1ss`}]]};g.node;var _=s(g),v={name:`code-xml`,size:24,node:[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],aliases:[`code-2`]};v.node;var y=s(v),b={name:`crown`,size:24,node:[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};b.node;var x=s(b),S={name:`flame`,size:24,node:[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]};S.node;var C=s(S),w={name:`gem`,size:24,node:[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]};w.node;var T=s(w),E={name:`heart`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]};E.node;var D=s(E),O={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};O.node;var k=s(O),A={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};A.node;var j=s(A),M={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};M.node;var N=s(M),P=d(u(),1),F=l(),I={award:{icon:t,label:`Rosette`},medal:{icon:r,label:`Medal`},trophy:{icon:h,label:`Trophy`},star:{icon:j,label:`Star`},rocket:{icon:o,label:`Rocket`},flame:{icon:C,label:`Flame`},zap:{icon:N,label:`Lightning`},crown:{icon:x,label:`Crown`},gem:{icon:T,label:`Gem`},heart:{icon:D,label:`Heart`},lightbulb:{icon:p,label:`Light bulb`},target:{icon:m,label:`Target`},"graduation-cap":{icon:n,label:`Graduation cap`},"book-open":{icon:e,label:`Book`},code:{icon:y,label:`Code`},puzzle:{icon:k,label:`Puzzle`},brain:{icon:_,label:`Brain`},sparkles:{icon:a,label:`Sparkles`},"message-circle":{icon:i,label:`Speech bubble`},globe:{icon:f,label:`Globe`}},L={gold:{from:`#fcd34d`,to:`#d97706`,edge:`#b45309`,label:`Gold`},silver:{from:`#e2e8f0`,to:`#64748b`,edge:`#475569`,label:`Silver`},bronze:{from:`#f0a868`,to:`#9a4a1c`,edge:`#7a3a16`,label:`Bronze`},indigo:{from:`#a5b4fc`,to:`#4f46e5`,edge:`#3730a3`,label:`Indigo`},violet:{from:`#c4b5fd`,to:`#7c3aed`,edge:`#5b21b6`,label:`Violet`},sky:{from:`#7dd3fc`,to:`#0284c7`,edge:`#075985`,label:`Sky`},teal:{from:`#5eead4`,to:`#0d9488`,edge:`#115e59`,label:`Teal`},emerald:{from:`#6ee7b7`,to:`#059669`,edge:`#065f46`,label:`Emerald`},rose:{from:`#fda4af`,to:`#e11d48`,edge:`#9f1239`,label:`Rose`},fuchsia:{from:`#f0abfc`,to:`#c026d3`,edge:`#86198f`,label:`Fuchsia`}},R=Array.from({length:48},(e,t)=>{let n=Math.PI*t/24-Math.PI/2,r=t%2==0?45:40.5;return`${(50+r*Math.cos(n)).toFixed(2)},${(48+r*Math.sin(n)).toFixed(2)}`}).join(` `);function z({icon:e,color:t,size:n=64,locked:r,label:i,className:a}){let o=`ck-badge-${(0,P.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,s=L[t]??L.gold,l=(I[e]??I.award).icon;return(0,F.jsxs)(`svg`,{viewBox:`0 0 100 112`,width:n,height:n*112/100,className:c(`shrink-0 drop-shadow-sm`,r&&`opacity-45 grayscale`,a),role:i?`img`:void 0,"aria-label":i,"aria-hidden":!i||void 0,children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`${o}-fill`,x1:`0.2`,y1:`0`,x2:`0.8`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0`,stopColor:s.from}),(0,F.jsx)(`stop`,{offset:`1`,stopColor:s.to})]}),(0,F.jsxs)(`linearGradient`,{id:`${o}-ribbon`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0`,stopColor:s.to}),(0,F.jsx)(`stop`,{offset:`1`,stopColor:s.edge})]})]}),(0,F.jsx)(`path`,{d:`M31 78 L22 108 L34 102 L40 111 L47 84 Z`,fill:`url(#${o}-ribbon)`}),(0,F.jsx)(`path`,{d:`M69 78 L78 108 L66 102 L60 111 L53 84 Z`,fill:`url(#${o}-ribbon)`}),(0,F.jsx)(`polygon`,{points:R,fill:s.edge,strokeLinejoin:`round`,stroke:s.edge,strokeWidth:`1.5`}),(0,F.jsx)(`circle`,{cx:`50`,cy:`48`,r:`37`,fill:`url(#${o}-fill)`}),(0,F.jsx)(`circle`,{cx:`50`,cy:`48`,r:`31`,fill:`none`,stroke:`white`,strokeOpacity:`0.45`,strokeWidth:`1.5`}),(0,F.jsx)(`ellipse`,{cx:`40`,cy:`30`,rx:`18`,ry:`9`,fill:`white`,opacity:`0.18`,transform:`rotate(-24 40 30)`}),(0,F.jsx)(l,{x:32,y:30,width:36,height:36,color:`#ffffff`,strokeWidth:2.1})]})}export{N as i,I as n,z as r,L as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dt as e,It as t,t as n,tt as r}from"./index-CEZdqKdi.js";import{c as i}from"./misc-CyGhN6HT.js";import{n as a}from"./achievements-DaIfUTKU.js";import{N as o,_ as s,dt as c,w as l}from"./hooks-EFhyJ5yU.js";import{r as u}from"./badge-art-QPo-pYql.js";var d=c();function f({badge:i,staff:c,actions:f}){let p=!c&&!i.earnedAt;return(0,d.jsxs)(n,{className:`group relative flex flex-col items-center p-5 text-center transition-shadow hover:shadow-md`,children:[f&&(0,d.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:f}),(0,d.jsx)(u,{icon:i.icon,color:i.color,size:76,locked:p,className:`transition-transform group-hover:scale-105`}),(0,d.jsx)(t,{to:`/badges/${i.id}`,className:`mt-3 font-semibold tracking-tight after:absolute after:inset-0 hover:text-primary`,children:i.name}),i.description&&(0,d.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-muted-foreground`,children:i.description}),(0,d.jsxs)(`div`,{className:`mt-auto flex flex-col items-center gap-1.5 pt-4 text-xs text-muted-foreground`,children:[(0,d.jsx)(`span`,{children:a(i)}),c?(0,d.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[(0,d.jsx)(r,{className:`size-3.5 text-muted-foreground`}),` `,o(i.recipientCount??0,`recipient`)]}):(0,d.jsx)(`span`,{className:s(`flex items-center gap-1 font-medium`,i.earnedAt?`text-success`:`text-muted-foreground`),children:i.earnedAt?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e,{className:`size-3.5`}),` Earned `,l(i.earnedAt)]}):`Not earned yet`})]})]})}function p({count:e=4}){return(0,d.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,children:Array.from({length:e},(e,t)=>(0,d.jsx)(i,{className:`h-60`},t))})}export{p as n,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,D as t,E as n,Gt as r,I as i,O as a,c as o,gt as s,k as c,l,lt as u,m as d,s as f,u as p}from"./index-CEZdqKdi.js";import{H as m,U as h,_ as g,dt as _,ft as v,g as y,h as b,m as x,mt as S}from"./hooks-EFhyJ5yU.js";import{t as C}from"./flag-DOzXVys0.js";import{t as w}from"./library-Bcm33ouq.js";import{E as T,c as E}from"./misc-CyGhN6HT.js";import{n as D,t as O}from"./completion-2z7I-ypT.js";import{n as k,r as A,t as j}from"./badge-art-QPo-pYql.js";var M={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};M.node;var N=m(M),P=S(v(),1),F=_();function I({value:e,onChange:t}){let n=(0,P.useId)();return(0,F.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,F.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`Icon`}),(0,F.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5 sm:grid-cols-10`,children:D.map(r=>{let i=k[r],a=r===e;return(0,F.jsxs)(`label`,{title:i.label,className:g(`grid aspect-square cursor-pointer place-items-center rounded-lg border bg-card text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-primary/25`,a&&`border-primary bg-primary/[0.06] text-primary`),children:[(0,F.jsx)(`input`,{type:`radio`,name:n,className:`sr-only`,checked:a,onChange:()=>t(r),"aria-label":i.label}),(0,F.jsx)(i.icon,{className:`size-4.5`,"aria-hidden":!0})]},r)})})]})}function L({value:e,onChange:t}){let n=(0,P.useId)();return(0,F.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,F.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`Colour`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:O.map(r=>{let i=j[r],a=r===e;return(0,F.jsx)(`label`,{title:i.label,className:g(`size-8 cursor-pointer rounded-full ring-offset-2 ring-offset-popover transition-transform hover:scale-110 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-primary`,a&&`ring-2 ring-foreground`),style:{backgroundImage:`linear-gradient(135deg, ${i.from}, ${i.to})`},children:(0,F.jsx)(`input`,{type:`radio`,name:n,className:`sr-only`,checked:a,onChange:()=>t(r),"aria-label":i.label})},r)})})]})}function R({selected:e,onToggle:t}){let[n,r]=(0,P.useState)(``),{data:a,isLoading:o}=h({queryKey:[`admin`,`courses`,`all`],queryFn:()=>x.get(`/admin/courses?pageSize=100`)}),s=new Set(e),c=(0,P.useMemo)(()=>{let e=n.trim().toLowerCase();return(a?.items??[]).filter(t=>!e||t.title.toLowerCase().includes(e))},[a,n]);return(0,F.jsxs)(`fieldset`,{className:`min-w-0 space-y-2`,children:[(0,F.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`Courses to complete`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(u,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,F.jsx)(p,{value:n,onChange:e=>r(e.target.value),placeholder:`Find a course`,className:`pl-9`,"aria-label":`Find a course`})]}),o?(0,F.jsx)(E,{className:`h-32`}):(0,F.jsxs)(`ul`,{className:`ck-scrollbar max-h-52 divide-y overflow-y-auto rounded-lg border`,children:[c.map(e=>{let n=`badge-course-${e.id}`;return(0,F.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,F.jsx)(f,{id:n,checked:s.has(e.id),onCheckedChange:n=>t(e.id,n===!0)}),(0,F.jsx)(`span`,{className:`size-3 shrink-0 rounded-[4px]`,style:i(e.coverColor)}),(0,F.jsx)(`label`,{htmlFor:n,className:`min-w-0 flex-1 cursor-pointer truncate text-sm`,children:e.title}),e.visibility!==`published`&&(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground capitalize`,children:e.visibility})]},e.id)}),c.length===0&&(0,F.jsx)(`li`,{className:`px-3 py-4 text-center text-sm text-muted-foreground`,children:`No courses match.`})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length===0?`Choose at least one course.`:`Awarded once someone completes all ${e.length} of them.`})]})}function z({open:i,onOpenChange:u,scope:f,badge:m,onSaved:h}){let[g,_]=(0,P.useState)(m?.name??``),[v,S]=(0,P.useState)(m?.description??``),[E,D]=(0,P.useState)(m?.icon??`award`),[O,k]=(0,P.useState)(m?.color??`gold`),[j,M]=(0,P.useState)(m?.criteria??`manual`),[z,B]=(0,P.useState)(m?.criteriaCourses.map(e=>e.id)??[]),V=f.kind===`site`,H=r({mutationFn:()=>{let e={name:g,description:v,icon:E,color:O,criteria:j,courseIds:j===`courses`?z:[]};return m?x.patch(`/badges/${m.id}`,e):x.post(f.kind===`course`?`/courses/${f.courseId}/badges`:`/badges`,e)},onSuccess:e=>{let t=e.recipientCount&&e.criteria!==`manual`&&e.recipientCount>(m?.recipientCount??0);T.success(m?`Badge saved`:`Created “${e.name}”`,{description:t?`Awarded to ${e.recipientCount} ${e.recipientCount===1?`person`:`people`} who already qualify.`:void 0}),h?.(e),u(!1)},onError:e=>T.error(b(e))}),U=V?[{value:`manual`,label:`Awarded by administrators`,description:`You give it to people by hand.`,icon:(0,F.jsx)(N,{className:`size-4`})},{value:`courses`,label:`On completing courses`,description:`Automatic, once someone completes every course you choose.`,icon:(0,F.jsx)(w,{className:`size-4`})}]:[{value:`manual`,label:`Awarded by teachers`,description:`From the badge page or the participants list.`,icon:(0,F.jsx)(N,{className:`size-4`})},{value:`completion`,label:`On course completion`,description:`Automatic, when a student completes this course.`,icon:(0,F.jsx)(C,{className:`size-4`})}];return(0,F.jsx)(n,{open:i,onOpenChange:u,children:(0,F.jsx)(a,{size:`lg`,children:(0,F.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),H.mutate()},children:[(0,F.jsx)(e,{icon:(0,F.jsx)(s,{className:`size-5`}),title:m?`Edit badge`:V?`New site badge`:`New course badge`,description:V?`Site badges recognise achievements across courses.`:`Celebrate achievements in this course.`}),(0,F.jsxs)(t,{className:`space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-5 sm:flex-row sm:items-start`,children:[(0,F.jsxs)(`div`,{className:`flex w-32 shrink-0 flex-col items-center rounded-xl border bg-muted/40 px-3 py-4 text-center`,children:[(0,F.jsx)(A,{icon:E,color:O,size:84}),(0,F.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs font-semibold break-words`,children:g.trim()||`Badge name`})]}),(0,F.jsxs)(`div`,{className:`w-full min-w-0 flex-1 space-y-4`,children:[(0,F.jsx)(l,{label:`Name`,children:e=>(0,F.jsx)(p,{...e,autoFocus:!0,required:!0,maxLength:80,value:g,onChange:e=>_(e.target.value),placeholder:`Bug hunter`})}),(0,F.jsx)(l,{label:`Description`,optional:!0,hint:`What someone did to earn it.`,children:e=>(0,F.jsx)(d,{...e,rows:2,maxLength:500,value:v,onChange:e=>S(e.target.value),className:`min-h-0`})})]})]}),(0,F.jsx)(I,{value:E,onChange:D}),(0,F.jsx)(L,{value:O,onChange:k}),(0,F.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,F.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`How it’s earned`}),(0,F.jsx)(o,{columns:2,value:j,onChange:M,options:U})]}),V&&j===`courses`&&(0,F.jsx)(R,{selected:z,onToggle:(e,t)=>B(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))}),j!==`manual`&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Anyone who already qualifies receives it when you save. Staff can also award it by hand.`})]}),(0,F.jsxs)(c,{children:[(0,F.jsx)(y,{type:`button`,variant:`outline`,onClick:()=>u(!1),children:`Cancel`}),(0,F.jsx)(y,{type:`submit`,loading:H.isPending,disabled:!g.trim()||j===`courses`&&z.length===0,children:m?`Save badge`:`Create badge`})]})]})})})}export{N as n,z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e}from"./hooks-
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{$ as e,A as t,C as n,D as r,Dt as i,E as a,Gt as o,O as s,St as c,d as l,dt as u,et as d,f,k as p,kt as m,l as h,m as g,u as _}from"./index-CEZdqKdi.js";import{S 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,ut as D}from"./hooks-EFhyJ5yU.js";import{a as O,c as k,i as A,n as j,r as M,t as N,u as P}from"./QuestionAnswer-CJIoWSz2.js";import{t as ee}from"./hourglass-BKca6Cje.js";import{t as F}from"./lightbulb-CjSpJ1_v.js";import{t as I}from"./library-Bcm33ouq.js";import{t as te}from"./rotate-ccw-yBj9Ri49.js";import{E as L,c as R,n as z}from"./misc-CyGhN6HT.js";import{n as B,t as ne}from"./markdown-HNlXovsL.js";import{n as re,t as ie}from"./arrow-up-lI30bvj5.js";var V=E(S(),1),H=x(),U=()=>Math.random().toString(36).slice(2,10);function W(e){switch(e){case`single`:case`multiple`:return{points:e===`multiple`?2:1,pairs:[],options:[0,1,2].map(e=>({id:U(),text:``,correct:e===0}))};case`truefalse`:return{points:1,pairs:[],options:[{id:U(),text:`True`,correct:!0},{id:U(),text:`False`,correct:!1}]};case`ordering`:return{points:2,pairs:[],options:[0,1,2].map(()=>({id:U(),text:``,correct:!1}))};case`matching`:return{points:2,options:[],pairs:[0,1,2].map(()=>({id:U(),text:``,answer:``}))};case`essay`:return{points:5,options:[],pairs:[]};default:return{points:1,options:[],pairs:[]}}}function G(e=`single`){return{type:e,name:``,prompt:``,distractors:[],acceptedAnswers:[],tolerance:null,explanation:null,minWords:null,maxWords:null,graderNotes:null,...W(e)}}function K(e){return{type:e.type,name:e.name??``,prompt:e.prompt,points:e.points,options:e.options.map(e=>({id:e.id,text:e.text,correct:!!e.correct})),pairs:(e.pairs??[]).map(e=>({id:e.id,text:e.text,answer:e.answer??``})),distractors:e.distractors??[],acceptedAnswers:e.acceptedAnswers??[],tolerance:e.tolerance??null,explanation:e.explanation??null,minWords:e.minWords??null,maxWords:e.maxWords??null,graderNotes:e.graderNotes??null}}function q(e,t){if(t===e.type)return e;let n=G(t),r=e=>e===`single`||e===`multiple`,i=n.options;if(r(t)&&r(e.type)&&e.options.length>=2){let n=e.options.findIndex(e=>e.correct);i=e.options.map((e,r)=>({...e,correct:t===`single`?r===Math.max(0,n):e.correct}))}else t===`ordering`&&(r(e.type)||e.type===`ordering`)&&e.options.length>=2?i=e.options.map(e=>({...e,correct:!1})):r(t)&&e.type===`ordering`&&e.options.length>=2&&(i=e.options.map((e,t)=>({...e,correct:t===0})));return{...n,name:e.name,prompt:e.prompt,explanation:e.explanation,options:i}}function J(e){return{...e,name:e.name.trim(),points:Number(e.points)||0,acceptedAnswers:e.acceptedAnswers.map(e=>e.trim()).filter(Boolean),distractors:e.distractors.map(e=>e.trim()).filter(Boolean),explanation:e.explanation?.trim()||null,graderNotes:e.graderNotes?.trim()||null}}var Y=e=>e===``?null:Number(e);function ae({index:e,total:t,onMove:n,label:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>n(-1),disabled:e===0,"aria-label":`Move ${r} up`,children:(0,H.jsx)(ie,{})}),(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>n(1),disabled:e===t-1,"aria-label":`Move ${r} down`,children:(0,H.jsx)(re,{})})]})}function oe(e,t,n){let r=[...e],i=t+n;return i<0||i>=r.length?e:([r[t],r[i]]=[r[i],r[t]],r)}function X({draft:e,onChange:t,showType:n=!0}){let r=n=>t({...e,...n}),i=(t,n)=>r({options:e.options.map((r,i)=>e.type===`single`&&n.correct?i===t?{...r,...n}:{...r,correct:!1}:i===t?{...r,...n}:r)});return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_8rem]`,children:[n?(0,H.jsx)(h,{label:`Question type`,children:n=>(0,H.jsx)(f,{...n,value:e.type,onChange:n=>t(q(e,n.target.value)),children:j.map(e=>(0,H.jsx)(`option`,{value:e,children:M[e].label},e))})}):(0,H.jsx)(`div`,{}),(0,H.jsx)(h,{label:`Default mark`,hint:`Used when it's added to a quiz.`,children:t=>(0,H.jsx)(_,{...t,type:`number`,min:0,step:`any`,value:e.points,onChange:e=>r({points:Number(e.target.value)})})})]}),(0,H.jsx)(h,{label:`Question`,children:t=>(0,H.jsx)(g,{...t,rows:3,value:e.prompt,onChange:e=>r({prompt:e.target.value}),placeholder:"What would you like to ask? Markdown and `code` work here."})}),(e.type===`single`||e.type===`multiple`)&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(l,{children:[`Options`,` `,(0,H.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:e.type===`multiple`?`(tick every correct option)`:`(pick the correct one)`})]}),e.options.map((t,n)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(n,{correct:e.type===`single`||!t.correct}),className:b(`grid size-8 shrink-0 place-items-center border transition-colors`,e.type===`single`?`rounded-full`:`rounded-md`,t.correct?`border-emerald-600 bg-emerald-600 text-white`:`text-muted-foreground hover:border-emerald-600`),"aria-pressed":t.correct,"aria-label":t.correct?`Option ${String.fromCharCode(65+n)} is correct`:`Mark option ${String.fromCharCode(65+n)} as correct`,children:t.correct?(0,H.jsx)(m,{className:`size-4`,strokeWidth:3}):(0,H.jsx)(`span`,{className:`text-xs`,children:String.fromCharCode(65+n)})}),(0,H.jsx)(_,{value:t.text,onChange:e=>i(n,{text:e.target.value}),placeholder:`Option ${String.fromCharCode(65+n)}`,"aria-label":`Option ${String.fromCharCode(65+n)}`}),(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.options.length<=2,onClick:()=>r({options:e.options.filter((e,t)=>t!==n)}),"aria-label":`Remove option ${String.fromCharCode(65+n)}`,children:(0,H.jsx)(d,{})})]},t.id)),e.options.length<10&&(0,H.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r({options:[...e.options,{id:U(),text:``,correct:!1}]}),children:[(0,H.jsx)(u,{}),` Add option`]})]}),e.type===`truefalse`&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(l,{children:`The statement is`}),(0,H.jsx)(`div`,{className:`flex gap-2`,role:`radiogroup`,"aria-label":`The statement is`,children:e.options.map((t,n)=>(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t.correct,onClick:()=>r({options:e.options.map((e,t)=>({...e,correct:t===n}))}),className:b(`flex h-10 items-center gap-2 rounded-lg border px-5 text-sm font-medium transition-colors`,t.correct?`border-emerald-600 bg-emerald-600 text-white`:`hover:border-emerald-600`),children:[t.correct&&(0,H.jsx)(m,{className:`size-4`}),t.text]},t.id))})]}),e.type===`short`&&(0,H.jsx)(h,{label:`Accepted answers`,hint:`One per line. Matching ignores case and extra spaces; use * as a wildcard (e.g. colou*r).`,children:t=>(0,H.jsx)(g,{...t,rows:3,value:e.acceptedAnswers.join(`
|
|
2
|
+
`),onChange:e=>r({acceptedAnswers:e.target.value.split(`
|
|
3
|
+
`)}),className:`font-mono text-[13px]`})}),e.type===`numeric`&&(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(h,{label:`Correct answer`,children:t=>(0,H.jsx)(_,{...t,inputMode:`decimal`,value:e.acceptedAnswers[0]??``,onChange:e=>r({acceptedAnswers:[e.target.value]})})}),(0,H.jsx)(h,{label:`Allowed error (±)`,optional:!0,children:t=>(0,H.jsx)(_,{...t,type:`number`,min:0,step:`any`,value:e.tolerance??``,onChange:e=>r({tolerance:Y(e.target.value)})})})]}),e.type===`essay`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(h,{label:`Minimum words`,optional:!0,children:t=>(0,H.jsx)(_,{...t,type:`number`,min:1,step:1,value:e.minWords??``,onChange:e=>r({minWords:Y(e.target.value)})})}),(0,H.jsx)(h,{label:`Maximum words`,optional:!0,children:t=>(0,H.jsx)(_,{...t,type:`number`,min:1,step:1,value:e.maxWords??``,onChange:e=>r({maxWords:Y(e.target.value)})})})]}),(0,H.jsx)(`p`,{className:`-mt-2 text-xs text-muted-foreground`,children:`Students see a live word count. Limits are guidance: answers outside them can still be handed in, and graders see the count.`}),(0,H.jsx)(h,{label:`Notes for graders`,optional:!0,hint:`Only teachers see these, while marking. Students never do.`,children:t=>(0,H.jsx)(g,{...t,rows:3,value:e.graderNotes??``,onChange:e=>r({graderNotes:e.target.value||null}),placeholder:`What a good answer includes, how to split the marks…`})})]}),e.type===`matching`&&(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(l,{children:`Items and their matches`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Students pick a match for each item from a shuffled list of all the answers. Each right match earns an equal share of the marks.`}),e.pairs.map((t,n)=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border bg-muted/20 p-2.5 sm:flex-row sm:items-center sm:border-0 sm:bg-transparent sm:p-0`,children:[(0,H.jsx)(_,{value:t.text,onChange:t=>r({pairs:e.pairs.map((e,r)=>r===n?{...e,text:t.target.value}:e)}),placeholder:`Item ${n+1}`,"aria-label":`Item ${n+1}`}),(0,H.jsx)(`span`,{className:`hidden text-muted-foreground sm:block`,"aria-hidden":!0,children:`→`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 sm:contents`,children:[(0,H.jsx)(_,{value:t.answer,onChange:t=>r({pairs:e.pairs.map((e,r)=>r===n?{...e,answer:t.target.value}:e)}),placeholder:`Its match`,"aria-label":`Match for item ${n+1}`}),(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.pairs.length<=2,onClick:()=>r({pairs:e.pairs.filter((e,t)=>t!==n)}),"aria-label":`Remove item ${n+1}`,children:(0,H.jsx)(d,{})})]})]},t.id)),e.pairs.length<20&&(0,H.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r({pairs:[...e.pairs,{id:U(),text:``,answer:``}]}),children:[(0,H.jsx)(u,{}),` Add item`]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(l,{children:[`Distractors `,(0,H.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(extra wrong answers, optional)`})]}),e.distractors.map((t,n)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(_,{value:t,onChange:t=>r({distractors:e.distractors.map((e,r)=>r===n?t.target.value:e)}),placeholder:`A wrong answer`,"aria-label":`Distractor ${n+1}`}),(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>r({distractors:e.distractors.filter((e,t)=>t!==n)}),"aria-label":`Remove distractor ${n+1}`,children:(0,H.jsx)(d,{})})]},n)),e.distractors.length<10&&(0,H.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r({distractors:[...e.distractors,``]}),children:[(0,H.jsx)(u,{}),` Add distractor`]})]})]}),e.type===`ordering`&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(l,{children:`Items in the right order`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Students see them shuffled. Each neighbouring pair they put in the right order earns an equal share of the marks (5 items make 4 pairs).`}),(0,H.jsx)(`ol`,{className:`space-y-2`,children:e.options.map((t,n)=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-full bg-muted text-xs font-semibold tabular-nums`,children:n+1}),(0,H.jsx)(_,{value:t.text,onChange:e=>i(n,{text:e.target.value}),placeholder:`Item ${n+1}`,"aria-label":`Item ${n+1}`}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,H.jsx)(ae,{index:n,total:e.options.length,label:`item ${n+1}`,onMove:t=>r({options:oe(e.options,n,t)})}),(0,H.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.options.length<=2,onClick:()=>r({options:e.options.filter((e,t)=>t!==n)}),"aria-label":`Remove item ${n+1}`,children:(0,H.jsx)(d,{})})]})]},t.id))}),e.options.length<20&&(0,H.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r({options:[...e.options,{id:U(),text:``,correct:!1}]}),children:[(0,H.jsx)(u,{}),` Add item`]})]}),(0,H.jsx)(h,{label:`Explanation`,optional:!0,hint:`Shown to students when they review their attempt.`,children:t=>(0,H.jsx)(g,{...t,rows:2,value:e.explanation??``,onChange:e=>r({explanation:e.target.value||null})})}),(0,H.jsx)(h,{label:`Name in the question bank`,optional:!0,hint:`A short label for finding it later. The question text is shown when it's empty.`,children:t=>(0,H.jsx)(_,{...t,value:e.name,maxLength:200,onChange:e=>r({name:e.target.value})})})]})}function Z(e,t=!0){return y({queryKey:[`question-categories`,e],queryFn:()=>T.get(`/courses/${e}/question-categories`),enabled:t})}function Q(){let e=D();return t=>Promise.all([e.invalidateQueries({queryKey:[`question-categories`,t]}),e.invalidateQueries({queryKey:[`bank-questions`,t]}),e.invalidateQueries({queryKey:[`bank-question`]}),e.invalidateQueries({queryKey:[`slots`]})])}function se(e,t=[]){return{id:e.id,type:e.type,name:e.name,excerpt:v(e.prompt,160),points:e.points,categoryId:e.categoryId,categoryName:t.find(t=>t.id===e.categoryId)?.name??``,quizCount:new Set(e.usage.filter(e=>e.kind===`question`).map(e=>e.activityId)).size,updatedAt:e.updatedAt}}function $({categories:e,allLabel:t,exclude:n,...r}){let i=(0,V.useMemo)(()=>k(e).filter(e=>!n?.includes(e.id)),[e,n]);return(0,H.jsxs)(f,{...r,children:[t&&(0,H.jsx)(`option`,{value:``,children:t}),i.map(e=>(0,H.jsx)(`option`,{value:e.id,children:O(e)},e.id))]})}function ce({type:e,className:t}){let n=M[e];return(0,H.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg ${n.tint} ${t??``}`,title:n.short,children:(0,H.jsx)(n.icon,{className:`size-4`,"aria-hidden":!0})})}function le({courseId:n,open:i,onOpenChange:c,questionId:l,defaultCategoryId:u,onSaved:d}){let f=!!l,m=D(),g=e(),_=Q(),{data:v}=Z(n,i),b=y({queryKey:[`bank-question`,l],queryFn:()=>T.get(`/questions/${l}`),enabled:i&&f}),[x,S]=(0,V.useState)(null),[E,O]=(0,V.useState)(``),[k,A]=(0,V.useState)(``);(0,V.useEffect)(()=>{if(!i)S(null);else if(!x){if(f&&b.data){let e=K(b.data);S(e),O(b.data.categoryId),A(JSON.stringify([e,b.data.categoryId]))}else if(!f&&v){let e=G(`single`),t=u&&v.some(e=>e.id===u)?u:v[0]?.id??``;S(e),O(t),A(JSON.stringify([e,t]))}}},[i,f,b.data,v,u,x]);let j=!!x&&JSON.stringify([x,E])!==k,M=async()=>{(!j||await g({title:`Discard your changes?`,description:`The question hasn't been saved.`,confirmLabel:`Discard`,destructive:!0}))&&c(!1)},N=o({mutationFn:()=>f?T.put(`/questions/${l}`,{...J(x),categoryId:E}):T.post(`/courses/${n}/questions`,{...J(x),categoryId:E}),onSuccess:async e=>{L.success(f?`Question saved`:`Question added to the bank`),m.setQueryData([`bank-question`,e.id],e),d?.(e),c(!1),await _(n)},onError:e=>L.error(w(e),{duration:8e3})}),P=b.data?.usage??[];return(0,H.jsx)(a,{open:i,onOpenChange:e=>e?c(!0):void M(),children:(0,H.jsx)(s,{size:`lg`,children:(0,H.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),N.mutate()},children:[(0,H.jsx)(t,{icon:(0,H.jsx)(I,{className:`size-5`}),title:f?`Edit question`:`New question`,description:f?`Changes apply wherever this question is used.`:`Saved to the course question bank.`}),(0,H.jsx)(r,{className:`space-y-5`,children:b.error?(0,H.jsx)(z,{error:b.error,onRetry:()=>b.refetch()}):!x||!v?(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(R,{className:`h-9`}),(0,H.jsx)(R,{className:`h-24`}),(0,H.jsx)(R,{className:`h-32`})]}):(0,H.jsxs)(H.Fragment,{children:[P.length>0&&(0,H.jsxs)(`p`,{className:`rounded-lg bg-sky-500/[0.08] px-3.5 py-2.5 text-[13px] text-sky-900 dark:text-sky-200`,children:[`Used in `,P.map(e=>`“${e.title}”`).join(`, `),`. Attempts already started keep the version they began with.`]}),(0,H.jsx)(h,{label:`Category`,children:e=>(0,H.jsx)($,{...e,categories:v,value:E,onChange:e=>O(e.target.value)})}),(0,H.jsx)(X,{draft:x,onChange:S})]})}),(0,H.jsxs)(p,{className:`border-t`,children:[(0,H.jsx)(C,{type:`button`,variant:`outline`,onClick:()=>void M(),children:`Cancel`}),(0,H.jsx)(C,{type:`submit`,loading:N.isPending,disabled:!x||!E,children:f?`Save question`:`Add to bank`})]})]})})})}function ue({result:e}){return e.pending?(0,H.jsxs)(n,{variant:`warning`,children:[(0,H.jsx)(ee,{}),` Marked by a teacher`]}):(0,H.jsxs)(n,{variant:e.correct?`success`:e.partial?`warning`:`danger`,children:[e.correct?(0,H.jsx)(i,{}):(0,H.jsx)(P,{}),A(e.points),` / `,A(e.maxPoints)]})}function de({questionId:e,open:n,onOpenChange:i}){let l=y({queryKey:[`question-preview`,e],queryFn:()=>T.get(`/questions/${e}/preview`),enabled:n&&!!e,gcTime:0}),[u,d]=(0,V.useState)(),[f,m]=(0,V.useState)(null);(0,V.useEffect)(()=>{d(l.data?.answer??void 0),m(null)},[l.data]);let h=o({mutationFn:()=>T.post(`/questions/${e}/check`,{answer:u??{}}),onSuccess:m,onError:e=>L.error(w(e))}),g=f?.question??l.data?.question;return(0,H.jsx)(a,{open:n,onOpenChange:i,children:(0,H.jsxs)(s,{size:`lg`,children:[(0,H.jsx)(t,{icon:(0,H.jsx)(c,{className:`size-5`}),title:`Preview`,description:`This is how students see the question. Try answering it.`}),(0,H.jsx)(r,{className:`space-y-4 pb-4`,children:l.error?(0,H.jsx)(z,{error:l.error,onRetry:()=>l.refetch()}):g?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:M[g.type].hint}),f?(0,H.jsx)(ue,{result:f.result}):(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[A(g.points),` point`,g.points===1?``:`s`]})]}),(0,H.jsx)(B,{source:g.prompt,className:`text-[15px] font-medium [&_p]:my-0`}),(0,H.jsx)(N,{question:g,answer:u,onChange:d,review:!!f,disabled:!!f}),f?.result.pending&&(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Essay answers are marked by hand after the attempt is handed in.`}),f&&g.explanation&&(0,H.jsxs)(`div`,{className:`flex gap-3 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,H.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-sky-600 dark:text-sky-400`}),(0,H.jsx)(ne,{source:g.explanation})]})]}):(0,H.jsx)(R,{className:`h-48`})}),(0,H.jsxs)(p,{className:`border-t`,children:[(0,H.jsxs)(C,{type:`button`,variant:`outline`,onClick:()=>l.refetch(),disabled:!g||l.isFetching,children:[(0,H.jsx)(te,{}),` Start over`]}),(0,H.jsx)(C,{type:`button`,onClick:()=>h.mutate(),loading:h.isPending,disabled:!g||!!f,children:`Check answer`})]})]})})}export{se as a,ce as i,le as n,Z as o,de as r,Q as s,$ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Nt as e,bt as t}from"./index-CEZdqKdi.js";import{_ as n,dt as r}from"./hooks-EFhyJ5yU.js";var i=r();function a(e){return new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`long`,day:`numeric`}).format(new Date(e))}function o(e){return`${window.location.origin}/verify/${e}`}var s=`'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif`,c=`var(--brand-light)`,l=/(\{(?:name|course|date|code|site)\})/g,u={sheet:{aspectRatio:`297 / 210`,containerType:`inline-size`,WebkitPrintColorAdjust:`exact`,printColorAdjust:`exact`,backgroundImage:`radial-gradient(circle at 0% 0%, color-mix(in oklab, ${c} 9%, transparent) 0, transparent 32%), radial-gradient(circle at 100% 100%, color-mix(in oklab, ${c} 9%, transparent) 0, transparent 32%)`},outerFrame:{inset:`1.7cqw`,border:`0.28cqw solid ${c}`},innerFrame:{inset:`2.5cqw`,border:`0.09cqw solid color-mix(in oklab, ${c} 40%, transparent)`},content:{padding:`5.2cqw 7.5cqw 4.6cqw`},site:{fontSize:`1.2cqw`,letterSpacing:`0.28em`,gap:`1cqw`},logo:{width:`2.6cqw`,height:`2.6cqw`,borderRadius:`0.7cqw`,background:c},title:{fontFamily:s,fontSize:`4.5cqw`,marginTop:`2.3cqw`,lineHeight:1.1},ornament:{marginTop:`1.4cqw`,gap:`1cqw`},rule:{width:`7cqw`,height:`0.12cqw`,background:`color-mix(in oklab, ${c} 55%, transparent)`},diamond:{width:`0.9cqw`,height:`0.9cqw`,background:c,transform:`rotate(45deg)`},text:{fontSize:`1.65cqw`,lineHeight:1.55,marginTop:`0.5cqw`},name:{fontFamily:s,fontStyle:`italic`,fontSize:`5cqw`,lineHeight:1.15,margin:`0.9cqw 0 0.7cqw`,padding:`0 3cqw 0.5cqw`,borderBottom:`0.1cqw solid #cbd5e1`},course:{fontSize:`2.5cqw`,lineHeight:1.25,color:c,margin:`0.6cqw 0`},footer:{gap:`3cqw`},signatureLine:{borderTop:`0.1cqw solid #94a3b8`,paddingTop:`0.8cqw`,width:`22cqw`},small:{fontSize:`1.05cqw`},medium:{fontSize:`1.35cqw`},code:{fontSize:`1.45cqw`,letterSpacing:`0.08em`},seal:{width:`8.5cqw`,height:`8.5cqw`},watermark:{fontSize:`13cqw`,letterSpacing:`0.1em`}};function d({text:e,values:t}){let n=e.trim();if(n===`{name}`)return(0,i.jsx)(`p`,{className:`text-slate-900`,style:u.name,children:t.name});if(n===`{course}`)return(0,i.jsx)(`p`,{style:{...u.course,fontWeight:600},children:t.course});let r=n.split(l).map((e,n)=>{let r=/^\{(name|course|date|code|site)\}$/.exec(e)?.[1];return r?(0,i.jsx)(`strong`,{className:`font-semibold text-slate-800`,children:t[r]},n):e});return(0,i.jsx)(`p`,{style:u.text,children:r})}function f(){return(0,i.jsxs)(`svg`,{viewBox:`0 0 100 100`,style:u.seal,"aria-hidden":!0,children:[(0,i.jsx)(`circle`,{cx:`50`,cy:`50`,r:`48`,fill:c}),(0,i.jsx)(`circle`,{cx:`50`,cy:`50`,r:`41`,fill:`none`,stroke:`white`,strokeOpacity:`0.55`,strokeWidth:`1.5`,strokeDasharray:`3 3`}),(0,i.jsx)(`circle`,{cx:`50`,cy:`50`,r:`34`,fill:`white`,fillOpacity:`0.14`}),(0,i.jsx)(e,{x:28,y:26,width:44,height:44,color:`#ffffff`,strokeWidth:1.8})]})}function p({content:e,revoked:r,className:o}){let s={name:e.recipientName,course:e.courseTitle,date:a(e.completedAt),code:e.code,site:e.siteName},c=e.body.split(`
|
|
2
|
+
`).filter(e=>e.trim());return(0,i.jsxs)(`div`,{className:n(`ck-certificate relative w-full overflow-hidden rounded-sm bg-white text-slate-600 shadow-xl ring-1 ring-black/5`,o),style:u.sheet,children:[(0,i.jsx)(`div`,{className:`pointer-events-none absolute`,style:u.outerFrame}),(0,i.jsx)(`div`,{className:`pointer-events-none absolute`,style:u.innerFrame}),(0,i.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center text-center`,style:u.content,children:[(0,i.jsxs)(`div`,{className:`flex items-center font-semibold text-slate-500 uppercase`,style:u.site,children:[(0,i.jsx)(`span`,{className:`grid place-items-center text-white`,style:u.logo,children:(0,i.jsx)(t,{style:{width:`60%`,height:`60%`}})}),e.siteName]}),(0,i.jsx)(`h2`,{className:`font-medium text-slate-900`,style:u.title,children:e.title}),(0,i.jsxs)(`div`,{className:`flex items-center`,style:u.ornament,"aria-hidden":!0,children:[(0,i.jsx)(`span`,{style:u.rule}),(0,i.jsx)(`span`,{style:u.diamond}),(0,i.jsx)(`span`,{style:u.rule})]}),(0,i.jsx)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col items-center justify-center overflow-hidden`,children:c.map((e,t)=>(0,i.jsx)(d,{text:e,values:s},t))}),(0,i.jsxs)(`div`,{className:`grid w-full grid-cols-[1fr_auto_1fr] items-end`,style:u.footer,children:[(0,i.jsx)(`div`,{className:`justify-self-start text-left`,children:(e.signatureName||e.signatureTitle)&&(0,i.jsxs)(`div`,{style:u.signatureLine,children:[(0,i.jsx)(`p`,{className:`font-semibold text-slate-800`,style:u.medium,children:e.signatureName}),(0,i.jsx)(`p`,{className:`text-slate-500`,style:u.small,children:e.signatureTitle})]})}),(0,i.jsx)(f,{}),(0,i.jsxs)(`div`,{className:`justify-self-end text-right`,children:[(0,i.jsx)(`p`,{className:`font-semibold tracking-widest text-slate-400 uppercase`,style:u.small,children:`Certificate code`}),(0,i.jsx)(`p`,{className:`font-mono font-semibold text-slate-800`,style:u.code,children:e.code}),(0,i.jsxs)(`p`,{className:`text-slate-500`,style:u.small,children:[`Verify at `,window.location.host,`/verify`]})]})]})]}),r&&(0,i.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center`,"aria-hidden":!0,children:(0,i.jsx)(`span`,{className:`-rotate-12 font-black text-red-600/15 uppercase`,style:u.watermark,children:`Revoked`})})]})}export{a as n,o as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,A as t,D as n,E as r,Gt as i,H as a,J as o,O as s,V as c,W as l,f as u,k as d,l as f,lt as p,t as m,u as h,vt as g,z as _}from"./index-CEZdqKdi.js";import{H as v,N as y,U as b,_ as x,dt as S,ft as C,g as w,h as T,m as E,mt as D,u as O,ut as k}from"./hooks-EFhyJ5yU.js";import{t as A}from"./contact-NCWQa7wc.js";import{t as j}from"./ellipsis-BDmYLoyn.js";import{E as M,l as N}from"./misc-CyGhN6HT.js";var P={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};P.node;var F=v(P),I={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};I.node;var L=v(I),R=D(C(),1),z=S(),B=e=>[`cohort-links`,e],V=e=>y(e,`person`,`people`);function H({value:e,onChange:t,...n}){return(0,z.jsxs)(u,{...n,value:e,onChange:e=>t(e.target.value),children:[(0,z.jsx)(`option`,{value:`student`,children:`Student`}),(0,z.jsx)(`option`,{value:`assistant`,children:`Teaching assistant`}),(0,z.jsx)(`option`,{value:`teacher`,children:`Teacher`})]})}var U=`Everyone in the cohort is enrolled now, and people added to it later are enrolled automatically. People who are already enrolled keep their role. Unlinking keeps everyone's enrolment.`;function W({course:e,open:a,onOpenChange:o,onLinked:c}){let l=k(),[u,m]=(0,R.useState)(``),[_,v]=(0,R.useState)(`student`),[S,C]=(0,R.useState)(``),{data:D,isLoading:O,error:A}=b({queryKey:[`cohort-links`,e.id,`available`],queryFn:()=>E.get(`/courses/${e.id}/cohorts/available`),enabled:a}),j=S.trim().toLowerCase(),P=(D??[]).filter(e=>!j||e.name.toLowerCase().includes(j)),F=D?.find(e=>e.id===u)??null,I=i({mutationFn:()=>E.post(`/courses/${e.id}/cohorts`,{cohortId:u,role:_}),onSuccess:async t=>{M.success(`Linked ${t.link.cohort.name}. ${t.enrolled?`Enrolled ${V(t.enrolled)}.`:`Everyone in it was already enrolled.`}`),await l.invalidateQueries({queryKey:[`cohort-links`,e.id]}),c(),o(!1),m(``)},onError:e=>M.error(T(e))});return(0,z.jsx)(r,{open:a,onOpenChange:o,children:(0,z.jsx)(s,{children:(0,z.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),F&&I.mutate()},children:[(0,z.jsx)(t,{icon:(0,z.jsx)(g,{className:`size-5`}),title:`Link a cohort`,description:U}),(0,z.jsx)(n,{className:`space-y-4`,children:A?(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:T(A)}):O||!D?(0,z.jsx)(`div`,{className:`grid place-items-center py-8`,children:(0,z.jsx)(N,{})}):D.length===0?(0,z.jsx)(`p`,{className:`rounded-lg bg-muted/60 p-4 text-sm text-muted-foreground`,children:`There are no cohorts to link. Administrators create cohorts in Administration, under Cohorts.`}):(0,z.jsxs)(z.Fragment,{children:[D.length>6&&(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)(h,{value:S,onChange:e=>C(e.target.value),placeholder:`Search cohorts`,"aria-label":`Search cohorts`,className:`pl-9`})]}),(0,z.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Cohort`,className:`ck-scrollbar max-h-64 divide-y overflow-y-auto rounded-lg border`,children:[P.length===0&&(0,z.jsx)(`p`,{className:`p-4 text-center text-sm text-muted-foreground`,children:`No cohorts match your search.`}),P.map(e=>(0,z.jsxs)(`label`,{className:x(`flex cursor-pointer items-center gap-3 px-3 py-2.5 transition-colors hover:bg-accent/40`,e.id===u&&`bg-primary/[0.06]`),children:[(0,z.jsx)(`input`,{type:`radio`,name:`cohort`,value:e.id,checked:e.id===u,onChange:()=>m(e.id),className:`size-4 accent-[var(--primary)]`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:y(e.memberCount,`member`)})]},e.id))]}),(0,z.jsx)(f,{label:`Enrol them as`,children:e=>(0,z.jsx)(H,{...e,value:_,onChange:v})})]})}),(0,z.jsxs)(d,{children:[(0,z.jsx)(w,{type:`button`,variant:`outline`,onClick:()=>o(!1),children:`Cancel`}),(0,z.jsx)(w,{type:`submit`,loading:I.isPending,disabled:!F,children:F?`Link and enrol ${V(F.memberCount)}`:`Link cohort`})]})]})})})}function G({course:e,onLinked:t}){let[n,r]=(0,R.useState)(!1);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(w,{variant:`outline`,onClick:()=>r(!0),children:[(0,z.jsx)(g,{}),` Link cohort`]}),(0,z.jsx)(W,{course:e,open:n,onOpenChange:r,onLinked:t})]})}function K({course:t,onChange:n}){let r=k(),s=e(),{data:u}=b({queryKey:B(t.id),queryFn:()=>E.get(`/courses/${t.id}/cohorts`)}),d=()=>r.invalidateQueries({queryKey:[`cohort-links`,t.id]}),f=i({mutationFn:e=>E.post(`/courses/${t.id}/cohorts/${e.id}/sync`),onSuccess:(e,t)=>{M.success(e.enrolled?`Enrolled ${V(e.enrolled)} from ${t.cohort.name}`:`Everyone in ${t.cohort.name} is enrolled`),e.enrolled&&n()},onError:e=>M.error(T(e))}),p=i({mutationFn:e=>E.delete(`/courses/${t.id}/cohorts/${e.id}`),onSuccess:async(e,t)=>{await d(),M.success(`Unlinked ${t.cohort.name}. Everyone stays enrolled.`)},onError:e=>M.error(T(e))});return u?.length?(0,z.jsxs)(m,{className:`mb-5 flex flex-col gap-3 p-4 sm:flex-row sm:items-center`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm font-medium`,children:[(0,z.jsx)(A,{className:`size-4 text-primary`}),` Linked cohorts`]}),(0,z.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap`,"aria-label":`Linked cohorts`,children:u.map(e=>(0,z.jsxs)(`li`,{className:`flex max-w-full min-w-0 items-center gap-1.5 rounded-lg border bg-card py-1.5 pr-1 pl-3 text-sm shadow-xs sm:rounded-full sm:py-1`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 sm:flex sm:items-baseline sm:gap-1.5`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e.cohort.name}),(0,z.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[y(e.cohort.memberCount,`member`),` · `,O[e.role]]})]}),(0,z.jsxs)(_,{children:[(0,z.jsx)(o,{asChild:!0,children:(0,z.jsx)(w,{variant:`ghost`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Options for ${e.cohort.name}`,children:f.isPending&&f.variables?.id===e.id?(0,z.jsx)(N,{className:`size-3.5`}):(0,z.jsx)(j,{})})}),(0,z.jsxs)(c,{className:`w-60`,children:[(0,z.jsxs)(a,{onSelect:()=>f.mutate(e),children:[(0,z.jsx)(L,{}),` Enrol missing members`]}),(0,z.jsx)(l,{}),(0,z.jsxs)(a,{destructive:!0,onSelect:async()=>{await s({title:`Unlink ${e.cohort.name}?`,description:`Everyone it enrolled stays enrolled. People added to the cohort later are no longer enrolled here.`,confirmLabel:`Unlink`,destructive:!0})&&p.mutate(e)},children:[(0,z.jsx)(F,{}),` Unlink cohort`]})]})]})]},e.id))})]}):null}export{F as a,H as i,G as n,K as r,U as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[`award`,`medal`,`trophy`,`star`,`rocket`,`flame`,`zap`,`crown`,`gem`,`heart`,`lightbulb`,`target`,`graduation-cap`,`book-open`,`code`,`puzzle`,`brain`,`sparkles`,`message-circle`,`globe`],t=[`gold`,`silver`,`bronze`,`indigo`,`violet`,`sky`,`teal`,`emerald`,`rose`,`fuchsia`],n=[{key:`{name}`,label:`Student's name`},{key:`{course}`,label:`Course title`},{key:`{date}`,label:`Completion date`},{key:`{code}`,label:`Verification code`},{key:`{site}`,label:`Site name`}];function r(e){return e.replace(/(.{4})(?=.)/g,`$1-`)}var i=/^[0-9A-HJKMNP-TV-Z]{12}$/;function a(e){let t=e.toUpperCase().replace(/[^0-9A-Z]/g,``).replace(/O/g,`0`).replace(/[IL]/g,`1`);return i.test(t)?t:null}export{a,r as i,e as n,n as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`contact`,size:24,node:[[`path`,{d:`M16 2v2`,key:`scm5qe`}],[`path`,{d:`M7 21v-2a2 2 0 012-2h6a2 2 0 012 2v2`,key:`k82dct`}],[`path`,{d:`M8 2v2`,key:`pbkmx`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{U as e,m as t,ut as n}from"./hooks-
|
|
1
|
+
import{U as e,m as t,ut as n}from"./hooks-EFhyJ5yU.js";import{Ut as r}from"./index-CEZdqKdi.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{H as e}from"./hooks-
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e}from"./hooks-
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[`off`,`immediately`,`daily`,`weekly`],t={off:`Off`,immediately:`Immediately`,daily:`Daily digest`,weekly:`Weekly digest`},n=[{id:`announcements`,label:`Announcements`,description:`News and updates your teachers post to a course.`},{id:`discussions`,label:`Discussions`,description:`Replies in forum discussions you take part in.`},{id:`grades`,label:`Grades and feedback`,description:`When your work is graded or gets feedback.`},{id:`courses`,label:`Courses and enrolment`,description:`When you are added to a course, and other course updates.`},{id:`achievements`,label:`Badges and certificates`,description:`Badges, certificates and completed courses.`}];n.map(e=>e.id);var r=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];export{r as i,e as n,t as r,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e}from"./hooks-
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={name:`folder-tree`,size:24,node:[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,Ct as t,Dt as n,E as r,Ft as i,Gt as a,I as o,It as s,Ot as c,Pt as l,T as u,_ as d,j as f,jt as p,kt as m,w as h,y as g}from"./index-CEZdqKdi.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-EFhyJ5yU.js";import{n as O,t as k}from"./ActivityEditor-BNG3aTQa.js";import{t as A}from"./pencil-DFUpj3YP.js";import{E as j,a as M}from"./misc-CyGhN6HT.js";import{a as N,i as P,t as F}from"./context-D8W_QqNi.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:t,onNavigate:r}){let i=F(e).filter(e=>e.visible&&e.completion!==`none`),a=i.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)(s,{to:`/courses/${e.slug}`,onClick:r,className:`flex items-center gap-2.5 font-semibold hover:text-primary`,children:[(0,z.jsx)(`span`,{className:`size-3 shrink-0 rounded`,style:o(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:[a,` of `,i.length,` complete`]})]})]}),(0,z.jsx)(`nav`,{className:`ck-scrollbar flex-1 overflow-y-auto p-2`,children:e.sections.map((i,a)=>(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:[a+1,`. `,i.title]}),i.activities.map(i=>{let a=i.id===t;return(0,z.jsxs)(s,{to:u(e.slug,i.id),onClick:r,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`,a&&`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)(n,{className:`size-4 shrink-0 text-success`}):(0,z.jsx)(O,{className:`size-4 shrink-0 opacity-40`}):(()=>{let e=h[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(),r=a({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:()=>r.mutate(),loading:r.isPending,className:b(e.completed&&`border-success/40 text-success hover:bg-success/5`),children:[e.completed?(0,z.jsx)(n,{}):(0,z.jsx)(m,{}),e.completed?`Completed`:`Mark as done`]})}function U({activity:e}){if(!e.prev&&!e.next)return null;let t=(t,n)=>(0,z.jsxs)(s,{to:u(e.course.slug,t.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`,n===`next`&&`flex-row-reverse text-right`),children:[n===`prev`?(0,z.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}):(0,z.jsx)(l,{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:n===`prev`?`Previous`:`Next up`}),(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium group-hover:text-primary`,children:t.title})]})]});return(0,z.jsxs)(`div`,{className:`mt-10 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`div`,{children:e.prev&&t(e.prev,`prev`)}),(0,z.jsx)(`div`,{children:e.next&&t(e.next,`next`)})]})}function W({activity:r,actions:i}){let a=r.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)(g,{type:r.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:[h[r.type].label,r.sectionTitle&&` · ${r.sectionTitle}`]}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-2xl font-semibold tracking-tight text-balance sm:text-[28px]`,children:r.title}),(0,z.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[r.dueAt&&(0,z.jsxs)(e,{variant:a&&v(r.dueAt)&&!r.completed?`danger`:`neutral`,children:[(0,z.jsx)(p,{}),` `,D(r.dueAt,!a||r.completed)]}),r.maxGrade!=null&&(0,z.jsxs)(e,{variant:`neutral`,children:[r.maxGrade,` points`]}),r.meta&&r.type!==`assignment`&&(0,z.jsx)(e,{variant:`neutral`,children:r.meta}),!r.visible&&(0,z.jsxs)(e,{variant:`warning`,children:[(0,z.jsx)(t,{}),` Hidden from students`]}),a&&r.completed&&(0,z.jsxs)(e,{variant:`success`,children:[(0,z.jsx)(n,{}),` Completed`]})]})]}),i&&(0,z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:i})]})}function G({activity:e,children:t,actions:n}){let{data:i}=P(e.course.slug),[a,l]=(0,R.useState)(!1),[u,p]=(0,R.useState)(!1),m=e.capabilities.includes(`course:manageContent`);return(0,z.jsxs)(`div`,{className:`flex`,children:[i&&(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:i,currentId:e.id})}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsxs)(d,{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:[i&&(0,z.jsx)(C,{variant:`ghost`,size:`icon-xs`,className:`mr-1 xl:hidden`,onClick:()=>l(!0),"aria-label":`Course outline`,children:(0,z.jsx)(L,{})}),(0,z.jsxs)(s,{to:`/courses/${e.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:o(e.course.coverColor)}),(0,z.jsx)(`span`,{className:`truncate`,children:e.course.title})]}),(0,z.jsx)(c,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate text-foreground`,children:e.title})]}),(0,z.jsx)(W,{activity:e,actions:(0,z.jsxs)(z.Fragment,{children:[n,m&&(0,z.jsxs)(C,{variant:`outline`,onClick:()=>p(!0),children:[(0,z.jsx)(A,{}),` Edit`]}),(0,z.jsx)(H,{activity:e})]})}),t,(0,z.jsx)(U,{activity:e})]})}),i&&(0,z.jsx)(r,{open:a,onOpenChange:l,children:(0,z.jsx)(f,{className:`w-80 bg-card`,children:(0,z.jsx)(V,{course:i,currentId:e.id,onNavigate:()=>l(!1)})})}),i&&u&&(0,z.jsx)(k,{course:i,open:u,onOpenChange:p,activityId:e.id})]})}export{B as n,G as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e}from"./hooks-EFhyJ5yU.js";var t={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`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e.aggregation===`weighted`||e.categories.some(e=>!e.isDefault)}function t(e,t){let n=new Map;for(let e of t)n.set(e.categoryId,(n.get(e.categoryId)??0)+1);return e.filter(e=>n.has(e.id)).map(e=>({...e,itemCount:n.get(e.id)}))}function n(e){return e==null||Number.isNaN(e)?`–`:`${Number(e.toFixed(2))}%`}function r(e){return`${Number(e.toFixed(2))}%`}function i(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`}var a=new WeakMap;function o(n){let r=a.get(n);return r||(r=e(n)?t(n.categories,n.items):[],a.set(n,r)),r}export{t as a,o as i,r as n,e as o,i as r,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{U as e,_ as t,dt as n,ft as r,j as i,m as a,mt as o,v as s}from"./hooks-EFhyJ5yU.js";import{t as c}from"./users-round-CNhv0Whm.js";import{C as l,f as u}from"./index-CEZdqKdi.js";var d=o(r(),1),f=n(),p=e=>[`groups`,e];function m(t){return e({queryKey:p(t),queryFn:()=>a.get(`/courses/${t}/groups`),enabled:!!t})}function h({group:e,className:n}){return(0,f.jsx)(`span`,{"aria-hidden":!0,className:t(`grid size-9 shrink-0 place-items-center rounded-xl text-xs font-semibold text-white shadow-xs`,s(e.id),n),children:i(e.name)})}function g({groups:e,className:n}){return e?.length?(0,f.jsx)(`span`,{className:t(`flex flex-wrap gap-1`,n),children:e.map(e=>(0,f.jsxs)(l,{variant:`outline`,className:`max-w-44`,title:e.name,children:[(0,f.jsx)(c,{}),(0,f.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function _(e){let{data:t}=m(e),[n,r]=(0,d.useState)(``),i=(0,d.useMemo)(()=>t?.groups??[],[t]),a=i.find(e=>e.id===n)??null,o=(0,d.useMemo)(()=>a?new Set(a.members.map(e=>e.id)):null,[a]),s=(0,d.useCallback)(e=>!o||o.has(e),[o]);return{groups:i,groupId:a?n:``,setGroupId:r,active:a,matches:s}}function v({filter:e,onChange:n,className:r}){return e.groups.length===0?null:(0,f.jsxs)(u,{"aria-label":`Filter by group`,value:e.groupId,onChange:t=>{e.setGroupId(t.target.value),n?.(t.target.value)},className:t(`sm:w-52`,r),children:[(0,f.jsx)(`option`,{value:``,children:`All groups`}),e.groups.map(e=>(0,f.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.members.length,`)`]},e.id))]})}export{m as a,p as i,v as n,_ as o,h as r,g as t};
|