coursekit-lms 0.1.2 → 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 +76 -0
- package/README.md +127 -26
- package/dist/cli/index.js +7139 -1633
- package/dist/cli/index.js.map +1 -1
- package/dist/server/index.js +7128 -1655
- 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/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
package/dist/web/index.html
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
} catch (e) {}
|
|
16
16
|
})();
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/hooks-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/misc-
|
|
21
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-CEZdqKdi.js"></script>
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/hooks-EFhyJ5yU.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/misc-CyGhN6HT.js">
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BdPmMS6n.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|
|
24
24
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coursekit-lms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Open-source learning management system for Node.js: courses, lessons, assignments, quizzes, forums and a gradebook, with a modern web UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lms",
|
|
@@ -68,9 +68,13 @@
|
|
|
68
68
|
"zod": "^4.6.7"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
+
"nodemailer": ">=6.0.0",
|
|
71
72
|
"pg": "^8.0.0"
|
|
72
73
|
},
|
|
73
74
|
"peerDependenciesMeta": {
|
|
75
|
+
"nodemailer": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
74
78
|
"pg": {
|
|
75
79
|
"optional": true
|
|
76
80
|
}
|
|
@@ -92,6 +96,7 @@
|
|
|
92
96
|
"dompurify": "^3.5.0",
|
|
93
97
|
"lucide-react": "^1.79.0",
|
|
94
98
|
"marked": "^18.3.0",
|
|
99
|
+
"nodemailer": "^10.4.1",
|
|
95
100
|
"pg": "^8.23.1",
|
|
96
101
|
"prettier": "^3.10.1",
|
|
97
102
|
"radix-ui": "^1.8.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./message-square-text-fe24gbEU.js";import{C as n,D as r,E as i,H as a,M as o,T as s,U as c,_ as l,dt as u,ft as d,g as f,h as p,m,mt as h,n as g,p as _,r as v}from"./hooks-BBARn-DA.js";import{At as y,D as b,Dt as ee,E as te,Ft as ne,Lt as re,O as ie,Rt as x,S,T as ae,Tt as oe,bt as se,ct as C,d as w,et as T,g as ce,ht as E,i as le,j as D,k as ue,l as O,lt as de,n as k,nt as A,ot as j,r as M,t as N,u as fe,w as P,xt as F}from"./index-B29bTBiJ.js";import{i as pe,n as I,r as L}from"./markdown-ykrkPMbn.js";import{T as R,a as me,c as z,n as B,t as V}from"./misc-DvgDEI3I.js";import he from"./NotFoundPage-BRquC7-l.js";import{n as H,t as ge}from"./trophy-Cch2iF1m.js";import{t as _e}from"./pencil-p0GQmIMo.js";import{t as ve}from"./send-mxSHcdcD.js";import{a as U}from"./context-BLVW7NB7.js";import{n as ye,t as W}from"./frame-CGabirLa.js";import{t as be}from"./lock-BjbqwA_0.js";import{t as xe}from"./pin-DlYC3uec.js";var G={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};G.node;var Se=a(G),K={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};K.node;var q=a(K),J={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};J.node;var Y=a(J),Ce={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};Ce.node;var we=a(Ce),Te={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Te.node;var Ee=a(Te),X=h(d(),1),Z=u();function Q({icon:e,label:t,children:n}){return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 py-3 text-sm first:pt-0 last:pb-0`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 text-muted-foreground [&_svg]:size-4`,children:e}),(0,Z.jsx)(`span`,{className:`w-24 shrink-0 text-muted-foreground`,children:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:n})]})}function De({dueAt:e}){let t=g(3e4),n=new Date(e).getTime()-t;if(n<=0)return(0,Z.jsx)(`span`,{className:`text-destructive`,children:`Past due`});let r=Math.floor(n/864e5),i=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4);return(0,Z.jsx)(`span`,{className:l(n<864e5&&`text-amber-600 dark:text-amber-400`),children:r>0?`${r}d ${i}h left`:`${i}h ${a}m left`})}function Oe({activity:e}){let t=e.settings,n=e.submission??null,i=U(),[a,s]=(0,X.useState)(!n),[c,l]=(0,X.useState)(n?.text??``),[u,d]=(0,X.useState)(n?.files??[]),h=!!e.dueAt&&o(e.dueAt)&&!t.allowLate,g=t.submissionTypes.includes(`text`),_=t.submissionTypes.includes(`file`),v=x({mutationFn:()=>m.put(`/activities/${e.id}/submission`,{text:g?c:null,fileIds:u.map(e=>e.id)}),onSuccess:async()=>{R.success(n?`Submission updated`:`Submitted! Your teacher will review it soon.`),s(!1),await i(e.course.slug)},onError:e=>R.error(p(e))});return n&&!a?(0,Z.jsxs)(N,{children:[(0,Z.jsx)(k,{title:`Your submission`,description:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Submitted `,r(n.submittedAt),n.late&&(0,Z.jsx)(S,{variant:`warning`,children:`Late`})]}),icon:(0,Z.jsx)(F,{className:`size-4.5 text-success`}),action:!h&&(0,Z.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>{l(n.text??``),d(n.files),s(!0)},children:[(0,Z.jsx)(_e,{}),` Edit submission`]})}),(0,Z.jsxs)(`div`,{className:`space-y-4 px-5 pb-5`,children:[n.text&&(0,Z.jsx)(`div`,{className:`rounded-lg border bg-muted/30 p-4`,children:(0,Z.jsx)(I,{source:n.text,className:`prose-sm`})}),n.files.length>0&&(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:n.files.map(e=>(0,Z.jsx)(M,{file:e},e.id))})]})]}):h&&!n?(0,Z.jsxs)(N,{className:`p-6 text-center`,children:[(0,Z.jsx)(H,{className:`mx-auto size-6 text-muted-foreground`}),(0,Z.jsx)(`p`,{className:`mt-2 font-medium`,children:`Submissions are closed`}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`The due date has passed and this assignment doesn't accept late work.`})]}):(0,Z.jsxs)(N,{children:[(0,Z.jsx)(k,{title:n?`Edit your submission`:`Submit your work`,description:n?`Your previous submission will be replaced.`:void 0,icon:(0,Z.jsx)(A,{className:`size-4.5`})}),(0,Z.jsxs)(`form`,{className:`space-y-5 px-5 pb-5`,onSubmit:e=>{e.preventDefault(),v.mutate()},children:[g&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(w,{children:`Online text`}),(0,Z.jsx)(L,{value:c,onChange:l,rows:8,placeholder:`Write your answer, or paste a link to your work…`})]}),_&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(w,{children:[`Files`,` `,(0,Z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,u.length,`/`,t.maxFiles,`)`]})]}),u.length>0&&(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:u.map(e=>(0,Z.jsx)(M,{file:e,onRemove:()=>d(u.filter(t=>t.id!==e.id))},e.id))}),u.length<t.maxFiles&&(0,Z.jsx)(le,{context:`submission`,courseId:e.course.id,multiple:!0,onUploaded:e=>d(n=>[...n,e].slice(0,t.maxFiles))})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[n&&(0,Z.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>s(!1),children:`Cancel`}),(0,Z.jsxs)(f,{type:`submit`,loading:v.isPending,disabled:!c.trim()&&u.length===0,children:[(0,Z.jsx)(ve,{}),` `,n?`Update submission`:`Submit assignment`]})]})]})]})}function ke({activity:e}){let n=e.settings,a=e.capabilities.includes(`assignment:submit`),o=e.capabilities.includes(`grades:viewAll`),c=e.grade,l=e.submissionStats,u=c?.score!=null,d=u?`Graded`:e.submission?e.submission.late?`Submitted late`:`Submitted`:`Not submitted`;return(0,Z.jsx)(W,{activity:e,children:(0,Z.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[u&&a&&(0,Z.jsxs)(N,{className:`overflow-hidden border-success/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 bg-success/[0.06] px-5 py-4`,children:[(0,Z.jsx)(`span`,{className:`grid size-12 place-items-center rounded-full bg-success text-white`,children:(0,Z.jsx)(F,{className:`size-6`})}),(0,Z.jsxs)(`div`,{className:`flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your grade`}),(0,Z.jsxs)(`p`,{className:`text-2xl font-semibold tabular-nums`,children:[i(c.score),` `,(0,Z.jsxs)(`span`,{className:`text-base font-normal text-muted-foreground`,children:[`/ `,i(c.maxGrade)]})]})]}),(0,Z.jsxs)(`span`,{className:`text-2xl font-semibold text-success tabular-nums`,children:[Math.round(c.score/(c.maxGrade||1)*100),`%`]})]}),c.feedback&&(0,Z.jsxs)(`div`,{className:`flex gap-3 border-t px-5 py-4`,children:[c.gradedBy?(0,Z.jsx)(D,{user:c.gradedBy,size:`sm`}):(0,Z.jsx)(t,{className:`size-5 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium`,children:[c.gradedBy?.name??`Feedback`,` `,(0,Z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,r(c.gradedAt)]})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm whitespace-pre-wrap`,children:c.feedback})]})]})]}),(0,Z.jsxs)(N,{className:`p-6 sm:p-8`,children:[(0,Z.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,Z.jsx)(E,{className:`size-4`}),` Instructions`]}),e.description.trim()?(0,Z.jsx)(I,{source:e.description}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`No instructions provided.`})]}),a&&(0,Z.jsx)(Oe,{activity:e})]}),(0,Z.jsxs)(`div`,{className:`space-y-5 lg:sticky lg:top-20`,children:[a&&(0,Z.jsxs)(N,{className:`p-5`,children:[(0,Z.jsx)(Q,{icon:(0,Z.jsx)(oe,{}),label:`Due`,children:e.dueAt?s(e.dueAt):`No due date`}),e.dueAt&&!e.submission&&(0,Z.jsx)(Q,{icon:(0,Z.jsx)(H,{}),label:`Time left`,children:(0,Z.jsx)(De,{dueAt:e.dueAt})}),(0,Z.jsx)(Q,{icon:(0,Z.jsx)(A,{}),label:`Status`,children:(0,Z.jsx)(S,{variant:u?`success`:e.submission?`info`:`neutral`,children:d})}),(0,Z.jsx)(Q,{icon:(0,Z.jsx)(se,{}),label:`Grade`,children:u?`${i(c.score)} / ${i(c.maxGrade)}`:(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Not graded yet`})}),(0,Z.jsxs)(`div`,{className:`mt-3 border-t pt-3 text-xs text-muted-foreground`,children:[`Accepts`,` `,n.submissionTypes.map(e=>e===`text`?`online text`:`up to ${n.maxFiles} files`).join(` and `),`.`,n.allowLate?` Late work is accepted.`:` Late work is not accepted.`]})]}),o&&l&&(0,Z.jsxs)(N,{className:`p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:`Submissions`}),(0,Z.jsx)(`div`,{className:`mt-4 grid grid-cols-3 gap-2 text-center`,children:[[`Students`,l.participants],[`Submitted`,l.submitted],[`To grade`,l.needsGrading]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-muted/60 px-2 py-3`,children:[(0,Z.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e})]},e))}),(0,Z.jsx)(me,{value:l.participants?l.submitted/l.participants*100:0,className:`mt-4`}),(0,Z.jsx)(f,{asChild:!0,className:`mt-4 w-full`,children:(0,Z.jsxs)(y,{to:`${P(e.course.slug,e.id)}/submissions`,children:[(0,Z.jsx)(T,{}),` `,l.needsGrading?`Grade ${l.needsGrading} submission${l.needsGrading===1?``:`s`}`:`View submissions`]})})]})]})]})})}function Ae({activity:e,open:t,onOpenChange:n}){let[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),s=ne(),c=U(),l=x({mutationFn:()=>m.post(`/activities/${e.id}/discussions`,{title:r,body:a}),onSuccess:async t=>{await c(e.course.slug),n(!1),s(`/courses/${e.course.slug}/discussions/${t.id}`)},onError:e=>R.error(p(e))});return(0,Z.jsx)(ae,{open:t,onOpenChange:n,children:(0,Z.jsx)(b,{size:`lg`,children:(0,Z.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),l.mutate()},children:[(0,Z.jsx)(ue,{icon:(0,Z.jsx)(C,{className:`size-5`}),title:`Start a discussion`,description:`Post in ${e.title}.`}),(0,Z.jsxs)(te,{className:`space-y-4`,children:[(0,Z.jsx)(O,{label:`Subject`,children:e=>(0,Z.jsx)(fe,{...e,autoFocus:!0,required:!0,value:r,onChange:e=>i(e.target.value),placeholder:`What's this about?`})}),(0,Z.jsx)(O,{label:`Message`,children:e=>(0,Z.jsx)(L,{id:e.id,value:a,onChange:o,rows:8})})]}),(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Z.jsx)(f,{type:`submit`,loading:l.isPending,disabled:!r.trim()||!a.trim(),children:`Post discussion`})]})]})})})}function je({activity:e}){let t=e.settings,[n,i]=(0,X.useState)(!1),a=e.capabilities.includes(`forum:post`)&&(e.capabilities.includes(`forum:moderate`)||t.studentsCanStartDiscussions),{data:o,isLoading:s,error:l,refetch:u}=c({queryKey:[`discussions`,e.id],queryFn:()=>m.get(`/activities/${e.id}/discussions`)});return(0,Z.jsxs)(W,{activity:e,actions:a&&(0,Z.jsxs)(f,{onClick:()=>i(!0),children:[(0,Z.jsx)(j,{}),` New discussion`]}),children:[e.description&&(0,Z.jsx)(N,{className:`mb-6 p-5`,children:(0,Z.jsx)(I,{source:e.description,className:`prose-sm`})}),l?(0,Z.jsx)(B,{error:l,onRetry:()=>u()}):s?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(z,{className:`h-24`}),(0,Z.jsx)(z,{className:`h-24`})]}):o.length===0?(0,Z.jsx)(V,{icon:C,title:`No discussions yet`,description:a?`Be the first to start a conversation.`:`Discussions started by your teachers will appear here.`,action:a&&(0,Z.jsxs)(f,{onClick:()=>i(!0),children:[(0,Z.jsx)(j,{}),` Start a discussion`]})}):(0,Z.jsx)(`div`,{className:`space-y-3`,children:o.map(t=>(0,Z.jsxs)(y,{to:`/courses/${e.course.slug}/discussions/${t.id}`,className:`group flex gap-4 rounded-xl border bg-card p-5 shadow-xs transition-all hover:border-primary/30 hover:shadow-md`,children:[(0,Z.jsx)(D,{user:t.author}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold tracking-tight group-hover:text-primary`,children:t.title}),t.pinned&&(0,Z.jsxs)(S,{variant:`warning`,children:[(0,Z.jsx)(xe,{}),` Pinned`]}),t.locked&&(0,Z.jsxs)(S,{variant:`neutral`,children:[(0,Z.jsx)(be,{}),` Locked`]})]}),(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-muted-foreground`,children:t.excerpt}),(0,Z.jsxs)(`p`,{className:`mt-2.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:t.author.name}),` · started `,r(t.createdAt),t.replyCount>0&&` · last reply ${r(t.lastPostAt)}`]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center justify-center rounded-lg bg-muted/60 px-3 text-center`,children:[(0,Z.jsx)(de,{className:`size-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`mt-0.5 text-sm font-semibold tabular-nums`,children:t.replyCount})]})]},t.id))}),(0,Z.jsx)(Ae,{activity:e,open:n,onOpenChange:i})]})}function $({icon:e,label:t,value:n}){return(0,Z.jsxs)(`div`,{className:`rounded-xl border bg-card p-4`,children:[(0,Z.jsx)(e,{className:`size-4 text-muted-foreground`}),(0,Z.jsx)(`p`,{className:`mt-2 text-lg font-semibold tabular-nums`,children:n}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}var Me={highest:`Highest attempt counts`,last:`Last attempt counts`,average:`Average of attempts`};function Ne({activity:e}){let t=ne(),n=e.quiz,a=e.settings,l=e.capabilities.includes(`course:manageContent`),u=e.capabilities.includes(`quiz:viewAllAttempts`),d=n.attempts.filter(e=>e.status===`finished`),h=a.attemptsAllowed?Math.max(0,a.attemptsAllowed-d.length):null,g=!!e.dueAt&&o(e.dueAt),_=x({mutationFn:()=>m.post(`/activities/${e.id}/attempts`),onSuccess:n=>t(`/courses/${e.course.slug}/attempts/${n.id}`),onError:e=>R.error(p(e))}),{data:v}=c({queryKey:[`attempts`,e.id,`all`],queryFn:()=>m.get(`/activities/${e.id}/attempts?all=1`),enabled:u}),b=n.questionCount===0?`This quiz has no questions yet.`:g?`This quiz has closed.`:h===0?`You've used all of your attempts.`:null;return(0,Z.jsx)(W,{activity:e,actions:l&&(0,Z.jsx)(f,{asChild:!0,variant:`outline`,children:(0,Z.jsxs)(y,{to:`${P(e.course.slug,e.id)}/questions`,children:[(0,Z.jsx)(pe,{}),` Questions`]})}),children:(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4`,children:[(0,Z.jsx)($,{icon:Se,label:`Questions`,value:String(n.questionCount)}),(0,Z.jsx)($,{icon:Ee,label:`Points`,value:i(n.totalPoints)}),(0,Z.jsx)($,{icon:H,label:`Time limit`,value:a.timeLimitMinutes?`${a.timeLimitMinutes} min`:`None`}),(0,Z.jsx)($,{icon:we,label:`Attempts`,value:a.attemptsAllowed?`${d.length} / ${a.attemptsAllowed}`:`${d.length} / ∞`})]}),(0,Z.jsxs)(N,{className:`overflow-hidden`,children:[e.description&&(0,Z.jsx)(`div`,{className:`border-b p-6`,children:(0,Z.jsx)(I,{source:e.description})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 p-6 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1 text-sm text-muted-foreground`,children:[(0,Z.jsxs)(`p`,{children:[Me[a.gradingMethod],`.`]}),e.dueAt&&(0,Z.jsxs)(`p`,{children:[g?`Closed`:`Closes`,` `,s(e.dueAt),`.`]}),a.passingPercent!=null&&(0,Z.jsxs)(`p`,{children:[`You need `,a.passingPercent,`% to pass.`]}),a.reviewMode!==`immediate`&&(0,Z.jsx)(`p`,{children:a.reviewMode===`after_due`?`Correct answers are shown after the quiz closes.`:`Only your score is shown after each attempt.`})]}),n.inProgressAttemptId?(0,Z.jsxs)(f,{size:`lg`,onClick:()=>t(`/courses/${e.course.slug}/attempts/${n.inProgressAttemptId}`),children:[(0,Z.jsx)(Y,{}),` Continue attempt`]}):n.canAttempt?(0,Z.jsxs)(f,{size:`lg`,onClick:()=>_.mutate(),loading:_.isPending,children:[(0,Z.jsx)(Y,{}),` `,l?`Preview quiz`:d.length?`Try again`:`Start quiz`]}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-muted px-4 py-2.5 text-sm text-muted-foreground`,children:b??`You cannot attempt this quiz.`})]})]}),e.grade?.score!=null&&e.myRole===`student`&&(0,Z.jsxs)(N,{className:`flex items-center gap-4 p-5`,children:[(0,Z.jsx)(`span`,{className:`grid size-11 place-items-center rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400`,children:(0,Z.jsx)(ge,{className:`size-5`})}),(0,Z.jsxs)(`div`,{className:`flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your grade for this quiz`}),(0,Z.jsxs)(`p`,{className:`text-xl font-semibold tabular-nums`,children:[i(e.grade.score),` `,(0,Z.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`/ `,i(e.grade.maxGrade)]})]})]}),(0,Z.jsxs)(S,{variant:`success`,children:[Math.round(e.grade.score/(e.grade.maxGrade||1)*100),`%`]})]}),n.attempts.length>0&&(0,Z.jsxs)(N,{children:[(0,Z.jsx)(k,{title:l?`Your previews`:`Your attempts`,icon:(0,Z.jsx)(ee,{className:`size-4.5`})}),(0,Z.jsx)(`div`,{className:`divide-y border-t`,children:n.attempts.map(t=>(0,Z.jsxs)(y,{to:`/courses/${e.course.slug}/attempts/${t.id}`,className:`flex items-center gap-4 px-5 py-3 text-sm transition-colors hover:bg-accent/40`,children:[(0,Z.jsx)(`span`,{className:`grid size-8 place-items-center rounded-full bg-muted text-xs font-semibold`,children:t.attemptNumber}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[(0,Z.jsxs)(`span`,{className:`block font-medium`,children:[`Attempt `,t.attemptNumber]}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t.status===`finished`?`Finished ${r(t.finishedAt)}`:`Started ${r(t.startedAt)}`})]}),t.status===`finished`?(0,Z.jsxs)(`span`,{className:`text-right`,children:[(0,Z.jsxs)(`span`,{className:`block font-semibold tabular-nums`,children:[i(t.score),` / `,i(t.maxScore)]}),(0,Z.jsxs)(`span`,{className:`block text-xs text-muted-foreground tabular-nums`,children:[t.maxScore?Math.round((t.score??0)/t.maxScore*100):0,`%`]})]}):(0,Z.jsx)(S,{variant:`info`,children:`In progress`})]},t.id))})]}),u&&(0,Z.jsxs)(N,{children:[(0,Z.jsx)(k,{title:`Student attempts`,description:`Every attempt, newest first.`,icon:(0,Z.jsx)(T,{className:`size-4.5`})}),v&&v.filter(e=>e.status===`finished`).length>0?(0,Z.jsx)(`div`,{className:`divide-y border-t`,children:v.filter(e=>e.status===`finished`).slice(0,50).map(t=>(0,Z.jsxs)(y,{to:`/courses/${e.course.slug}/attempts/${t.id}`,className:`flex items-center gap-3 px-5 py-2.5 text-sm hover:bg-accent/40`,children:[t.user&&(0,Z.jsx)(D,{user:t.user,size:`sm`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium`,children:t.user?.name}),(0,Z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Attempt `,t.attemptNumber,` · `,r(t.finishedAt)]})]}),(0,Z.jsxs)(`span`,{className:`font-semibold tabular-nums`,children:[i(t.score),` / `,i(t.maxScore)]})]},t.id))}):(0,Z.jsx)(`div`,{className:`px-5 pb-5`,children:(0,Z.jsx)(V,{icon:T,title:`No attempts yet`,className:`py-8`})})]})]})})}function Pe(e){let t=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);if(t)return{kind:`iframe`,src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let n=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return n?{kind:`iframe`,src:`https://player.vimeo.com/video/${n[1]}`}:/\.(mp4|webm|ogg)(\?|$)/i.test(e)?{kind:`video`,src:e}:{kind:`link`,src:e}}function Fe({activity:e}){let t=e.settings,n=t.videoUrl?Pe(t.videoUrl):null;return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[n&&n.kind!==`link`&&(0,Z.jsx)(`div`,{className:`overflow-hidden rounded-2xl border bg-black shadow-lg`,children:n.kind===`iframe`?(0,Z.jsx)(`iframe`,{src:n.src,title:e.title,className:`aspect-video w-full`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):(0,Z.jsx)(`video`,{src:n.src,controls:!0,className:`aspect-video w-full`})}),n?.kind===`link`&&(0,Z.jsxs)(`a`,{href:n.src,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-2 text-sm font-medium text-primary hover:underline`,children:[(0,Z.jsx)(q,{className:`size-4`}),` Watch the video`]}),(0,Z.jsx)(N,{className:`px-6 py-8 sm:px-10 sm:py-10`,children:t.body.trim()?(0,Z.jsx)(I,{source:t.body,className:`mx-auto max-w-3xl`}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`This lesson has no content yet.`})})]})}function Ie({activity:t}){let r=t.settings,i=t.file;return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[t.description&&(0,Z.jsx)(N,{className:`p-6`,children:(0,Z.jsx)(I,{source:t.description})}),r.kind===`link`&&r.url?(0,Z.jsxs)(N,{className:`flex flex-col gap-4 p-6 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center rounded-xl bg-slate-500/10 text-slate-600 dark:text-slate-300`,children:(0,Z.jsx)(q,{className:`size-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:new URL(r.url).hostname.replace(/^www\./,``)}),(0,Z.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:r.url})]}),(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsxs)(`a`,{href:r.url,target:`_blank`,rel:`noopener noreferrer`,children:[`Open link `,(0,Z.jsx)(q,{})]})})]}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{className:`flex flex-col gap-4 p-6 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary`,children:(0,Z.jsx)(E,{className:`size-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`truncate font-medium`,children:i.name}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(i.size),` · `,i.mime]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(f,{asChild:!0,variant:`outline`,children:(0,Z.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,children:[`Open `,(0,Z.jsx)(q,{})]})}),(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsxs)(`a`,{href:`${i.url}?download=1`,children:[(0,Z.jsx)(e,{}),` Download`]})})]})]}),i.mime.startsWith(`image/`)&&(0,Z.jsx)(`img`,{src:i.url,alt:i.name,className:`max-h-[70vh] rounded-xl border object-contain`}),i.mime===`application/pdf`&&(0,Z.jsx)(`iframe`,{src:i.url,title:i.name,className:`h-[75vh] w-full rounded-xl border bg-white`}),i.mime.startsWith(`video/`)&&(0,Z.jsx)(`video`,{src:i.url,controls:!0,className:`w-full rounded-xl border`})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The file for this resource is missing.`})]})}function Le(){let{activityId:e}=re(),{data:t,isLoading:n,error:r,refetch:i}=ye(e);if(v(t?.title),n)return(0,Z.jsxs)(ce,{className:`max-w-5xl`,children:[(0,Z.jsx)(z,{className:`mb-6 h-16`}),(0,Z.jsx)(z,{className:`h-96`})]});if(r instanceof _&&r.status===404)return(0,Z.jsx)(he,{});if(r||!t)return(0,Z.jsx)(ce,{children:(0,Z.jsx)(B,{error:r,onRetry:()=>i()})});switch(t.type){case`lesson`:return(0,Z.jsx)(W,{activity:t,children:(0,Z.jsx)(Fe,{activity:t})});case`resource`:return(0,Z.jsx)(W,{activity:t,children:(0,Z.jsx)(Ie,{activity:t})});case`assignment`:return(0,Z.jsx)(ke,{activity:t});case`quiz`:return(0,Z.jsx)(Ne,{activity:t});case`forum`:return(0,Z.jsx)(je,{activity:t})}}export{Le as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as e,U as t,dt as n,ft as r,g as i,h as a,m as o,mt as s,r as c,t as l,ut as u,w as d}from"./hooks-BBARn-DA.js";import{At as f,D as p,E as m,F as h,M as g,O as _,Q as v,Rt as y,S as b,St as x,T as S,at as C,k as w,l as T,m as E,ot as D,rt as O,t as k,u as A}from"./index-B29bTBiJ.js";import{t as j}from"./chevron-left-D6IMQD6N.js";import{n as M,t as N}from"./library-3WG9oLCb.js";import{t as P}from"./pencil-p0GQmIMo.js";import{t as F}from"./settings-DRKWzSHN.js";import{T as I,c as L,n as R,t as z}from"./misc-DvgDEI3I.js";var B=s(r(),1),V=n(),H={draft:`warning`,published:`success`,archived:`neutral`};function U(){c(`All courses`);let[n,r]=(0,B.useState)(``),[a,s]=(0,B.useState)(1),u=l(n.trim(),300),{data:p,isLoading:m,error:_,refetch:v}=t({queryKey:[`admin`,`courses`,u,a],queryFn:()=>o.get(`/admin/courses?${new URLSearchParams({...u?{q:u}:{},page:String(a),pageSize:`20`})}`),placeholderData:e}),y=p?Math.max(1,Math.ceil(p.total/20)):1;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,V.jsxs)(`div`,{className:`relative sm:w-80`,children:[(0,V.jsx)(C,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,V.jsx)(A,{value:n,onChange:e=>{r(e.target.value),s(1)},placeholder:`Search courses`,className:`pl-9`,"aria-label":`Search courses`})]}),(0,V.jsx)(i,{asChild:!0,className:`sm:ml-auto`,children:(0,V.jsxs)(f,{to:`/courses/new`,children:[(0,V.jsx)(D,{}),` New course`]})})]}),_?(0,V.jsx)(R,{error:_,onRetry:()=>v()}):m||!p?(0,V.jsx)(L,{className:`h-96`}):p.items.length===0?(0,V.jsx)(z,{icon:N,title:`No courses found`}):(0,V.jsxs)(k,{className:`overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,V.jsx)(`thead`,{className:`border-b bg-muted/40 text-left text-xs text-muted-foreground`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Course`}),(0,V.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Status`}),(0,V.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Teachers`}),(0,V.jsx)(`th`,{className:`hidden px-3 py-3 font-medium sm:table-cell`,children:`Students`}),(0,V.jsx)(`th`,{className:`hidden px-3 py-3 font-medium lg:table-cell`,children:`Created`}),(0,V.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,V.jsx)(`tbody`,{className:`divide-y`,children:p.items.map(e=>(0,V.jsxs)(`tr`,{className:`hover:bg-accent/30`,children:[(0,V.jsx)(`td`,{className:`px-5 py-3`,children:(0,V.jsxs)(f,{to:`/courses/${e.slug}`,className:`flex items-center gap-3 hover:text-primary`,children:[(0,V.jsx)(`span`,{className:`size-8 shrink-0 rounded-lg`,style:h(e.coverColor)}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),(0,V.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.categoryName??`Uncategorised`})]})]})}),(0,V.jsx)(`td`,{className:`px-3 py-3`,children:(0,V.jsx)(b,{variant:H[e.visibility],className:`capitalize`,children:e.visibility})}),(0,V.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(g,{users:e.teachers,max:3}),(0,V.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.teachers.map(e=>e.name).join(`, `)})]})}),(0,V.jsx)(`td`,{className:`hidden px-3 py-3 text-muted-foreground tabular-nums sm:table-cell`,children:e.studentCount}),(0,V.jsx)(`td`,{className:`hidden px-3 py-3 text-muted-foreground lg:table-cell`,children:d(e.createdAt)}),(0,V.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,V.jsx)(i,{asChild:!0,variant:`ghost`,size:`icon-sm`,"aria-label":`Settings for ${e.title}`,children:(0,V.jsx)(f,{to:`/courses/${e.slug}/settings`,children:(0,V.jsx)(F,{})})})})]},e.id))})]})}),y>1&&(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-5 py-3 text-sm text-muted-foreground`,children:[(0,V.jsx)(i,{variant:`outline`,size:`icon-sm`,disabled:a<=1,onClick:()=>s(a-1),"aria-label":`Previous page`,children:(0,V.jsx)(j,{})}),(0,V.jsxs)(`span`,{className:`tabular-nums`,children:[a,` / `,y]}),(0,V.jsx)(i,{variant:`outline`,size:`icon-sm`,disabled:a>=y,onClick:()=>s(a+1),"aria-label":`Next page`,children:(0,V.jsx)(x,{})})]})]})]})}function W({category:e,open:t,onOpenChange:n,onDone:r}){let[s,c]=(0,B.useState)(e?.name??``),[l,u]=(0,B.useState)(e?.description??``),d=y({mutationFn:()=>e?o.patch(`/categories/${e.id}`,{name:s,description:l}):o.post(`/categories`,{name:s,description:l}),onSuccess:()=>{I.success(e?`Category updated`:`Category created`),r(),n(!1)},onError:e=>I.error(a(e))});return(0,V.jsx)(S,{open:t,onOpenChange:n,children:(0,V.jsx)(p,{children:(0,V.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d.mutate()},children:[(0,V.jsx)(w,{icon:(0,V.jsx)(M,{className:`size-5`}),title:e?`Edit category`:`New category`}),(0,V.jsxs)(m,{className:`space-y-4`,children:[(0,V.jsx)(T,{label:`Name`,children:e=>(0,V.jsx)(A,{...e,autoFocus:!0,required:!0,value:s,onChange:e=>c(e.target.value)})}),(0,V.jsx)(T,{label:`Description`,optional:!0,children:e=>(0,V.jsx)(E,{...e,rows:3,value:l,onChange:e=>u(e.target.value)})})]}),(0,V.jsxs)(_,{children:[(0,V.jsx)(i,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,V.jsx)(i,{type:`submit`,loading:d.isPending,children:`Save`})]})]})})})}function G(){c(`Categories`);let e=u(),n=v(),[r,s]=(0,B.useState)(null),{data:l,isLoading:d,error:f,refetch:p}=t({queryKey:[`categories`],queryFn:()=>o.get(`/categories`)}),m=()=>e.invalidateQueries({queryKey:[`categories`]}),h=y({mutationFn:e=>o.delete(`/categories/${e}`),onSuccess:async()=>{await m(),I.success(`Category deleted`)},onError:e=>I.error(a(e))});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`mb-5 flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Categories organise the course catalog.`}),(0,V.jsxs)(i,{onClick:()=>s(`new`),children:[(0,V.jsx)(D,{}),` New category`]})]}),f?(0,V.jsx)(R,{error:f,onRetry:()=>p()}):d||!l?(0,V.jsx)(L,{className:`h-64`}):l.length===0?(0,V.jsx)(z,{icon:M,title:`No categories yet`,description:`Create categories like “Science” or “Languages” to organise the catalog.`}):(0,V.jsx)(k,{className:`divide-y overflow-hidden`,children:l.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-4 px-5 py-4`,children:[(0,V.jsx)(`span`,{className:`grid size-10 place-items-center rounded-xl bg-primary/10 text-primary`,children:(0,V.jsx)(M,{className:`size-4.5`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:e.name}),(0,V.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:e.description||`No description`})]}),(0,V.jsxs)(b,{variant:`neutral`,children:[e.courseCount,` published course`,e.courseCount===1?``:`s`]}),(0,V.jsx)(i,{variant:`ghost`,size:`icon-sm`,onClick:()=>s(e),"aria-label":`Edit ${e.name}`,children:(0,V.jsx)(P,{})}),(0,V.jsx)(i,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:async()=>{await n({title:`Delete “${e.name}”?`,description:`Courses in this category are kept and become uncategorised.`,confirmLabel:`Delete`,destructive:!0})&&h.mutate(e.id)},children:(0,V.jsx)(O,{})})]},e.id))}),r&&(0,V.jsx)(W,{category:r===`new`?void 0:r,open:!!r,onOpenChange:e=>!e&&s(null),onDone:m})]})}export{G as AdminCategoriesPage,U as AdminCoursesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./library-3WG9oLCb.js";import{Nt as n,Pt as r,a as i,et as a,g as o,jt as s,pt as c}from"./index-B29bTBiJ.js";import{t as l}from"./settings-DRKWzSHN.js";import{_ as u,dt as d,s as f}from"./hooks-BBARn-DA.js";var p=d(),m=[{to:`/admin`,label:`Overview`,icon:c,end:!0},{to:`/admin/users`,label:`Users`,icon:a},{to:`/admin/courses`,label:`Courses`,icon:t},{to:`/admin/categories`,label:`Categories`,icon:e},{to:`/admin/settings`,label:`Site settings`,icon:l}];function h(){return f()?.role===`admin`?(0,p.jsxs)(o,{children:[(0,p.jsx)(i,{title:`Administration`,description:`Manage people, courses and how your site looks.`}),(0,p.jsx)(`nav`,{className:`ck-no-scrollbar mb-7 flex gap-1 overflow-x-auto border-b`,children:m.map(e=>(0,p.jsxs)(s,{to:e.to,end:e.end,className:({isActive:e})=>u(`relative -mb-px flex h-10 shrink-0 items-center gap-2 border-b-2 border-transparent px-3 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,e&&`border-primary text-foreground`),children:[(0,p.jsx)(e.icon,{className:`size-4`}),e.label]},e.to))}),(0,p.jsx)(r,{})]}):(0,p.jsx)(n,{to:`/`,replace:!0})}export{h as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as e,H as t,Q as n,U as r,d as i,dt as a,ft as o,g as s,h as c,m as l,mt as u,r as d,s as ee,t as te,ut as ne}from"./hooks-BBARn-DA.js";import{B as f,Ct as p,D as m,E as h,Ft as re,H as ie,Mt as ae,O as g,Q as _,R as v,Rt as y,S as b,St as x,T as S,U as C,V as w,at as oe,et as se,f as T,j as ce,k as E,l as D,q as le,rt as O,t as k,tt as A,u as j,z as M}from"./index-B29bTBiJ.js";import{t as N}from"./ban-D3Vsxg_g.js";import{t as P}from"./chevron-left-D6IMQD6N.js";import{t as F}from"./copy-Bxxjq6zo.js";import{t as I}from"./ellipsis-c2POIN-Y.js";import{T as L,c as R,n as z,s as B,t as V}from"./misc-DvgDEI3I.js";var H={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};H.node;var U=t(H),W=u(o(),1),G=a(),ue={admin:`violet`,instructor:`info`,student:`neutral`},K=20;function de({open:e,onOpenChange:t,onDone:n}){let[r,i]=(0,W.useState)({name:``,email:``,role:`student`,password:``}),[a,o]=(0,W.useState)(null),u=y({mutationFn:()=>l.post(`/admin/users`,{...r,password:r.password||void 0}),onSuccess:e=>{n(),e.temporaryPassword?o(e.temporaryPassword):(L.success(`Created ${e.user.name}`),t(!1)),i({name:``,email:``,role:`student`,password:``})},onError:e=>L.error(c(e))});return(0,G.jsx)(S,{open:e,onOpenChange:e=>{t(e),e||o(null)},children:(0,G.jsx)(m,{children:a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E,{icon:(0,G.jsx)(p,{className:`size-5`}),title:`Account created`,description:`Share this temporary password securely. It won't be shown again.`}),(0,G.jsx)(h,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border bg-muted/50 p-3 font-mono text-sm`,children:[(0,G.jsx)(`span`,{className:`flex-1 break-all`,children:a}),(0,G.jsx)(s,{variant:`ghost`,size:`icon-sm`,"aria-label":`Copy password`,onClick:()=>{navigator.clipboard.writeText(a),L.success(`Copied`)},children:(0,G.jsx)(F,{})})]})}),(0,G.jsx)(g,{children:(0,G.jsx)(s,{onClick:()=>t(!1),children:`Done`})})]}):(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.mutate()},children:[(0,G.jsx)(E,{icon:(0,G.jsx)(A,{className:`size-5`}),title:`Add a person`}),(0,G.jsxs)(h,{className:`space-y-4`,children:[(0,G.jsx)(D,{label:`Full name`,children:e=>(0,G.jsx)(j,{...e,autoFocus:!0,required:!0,value:r.name,onChange:e=>i({...r,name:e.target.value})})}),(0,G.jsx)(D,{label:`Email`,children:e=>(0,G.jsx)(j,{...e,type:`email`,required:!0,value:r.email,onChange:e=>i({...r,email:e.target.value})})}),(0,G.jsx)(D,{label:`Site role`,hint:`Instructors can create courses. Administrators manage the whole site.`,children:e=>(0,G.jsxs)(T,{...e,value:r.role,onChange:e=>i({...r,role:e.target.value}),children:[(0,G.jsx)(`option`,{value:`student`,children:`Student`}),(0,G.jsx)(`option`,{value:`instructor`,children:`Instructor`}),(0,G.jsx)(`option`,{value:`admin`,children:`Administrator`})]})}),(0,G.jsx)(D,{label:`Password`,optional:!0,hint:`Leave empty to generate a temporary password.`,children:e=>(0,G.jsx)(j,{...e,type:`password`,autoComplete:`new-password`,value:r.password,onChange:e=>i({...r,password:e.target.value})})})]}),(0,G.jsxs)(g,{children:[(0,G.jsx)(s,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsx)(s,{type:`submit`,loading:u.isPending,children:`Create account`})]})]})})})}function q(){d(`Users`);let t=ee(),a=ne(),o=re(),u=_(),[m]=ae(),[h,g]=(0,W.useState)(m.get(`q`)??``),[S,T]=(0,W.useState)(``),[E,D]=(0,W.useState)(1),[F,H]=(0,W.useState)(!1),q=te(h.trim(),300),{data:J,isLoading:fe,error:Y,refetch:X}=r({queryKey:[`admin`,`users`,q,S,E],queryFn:()=>l.get(`/admin/users?${new URLSearchParams({...q?{q}:{},...S?{role:S}:{},page:String(E),pageSize:String(K)})}`),placeholderData:n}),Z=()=>a.invalidateQueries({queryKey:[`admin`]}),Q=y({mutationFn:({id:e,body:t})=>l.patch(`/admin/users/${e}`,t),onSuccess:async()=>{await Z(),L.success(`User updated`)},onError:e=>L.error(c(e))}),pe=y({mutationFn:e=>l.delete(`/admin/users/${e}`),onSuccess:async()=>{await Z(),L.success(`User deleted`)},onError:e=>L.error(c(e))}),me=y({mutationFn:e=>l.post(`/admin/users/${e}/impersonate`),onSuccess:async()=>{a.clear(),o(`/`)},onError:e=>L.error(c(e))}),$=J?Math.max(1,Math.ceil(J.total/K)):1;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,G.jsxs)(`div`,{className:`relative sm:w-80`,children:[(0,G.jsx)(oe,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(j,{value:h,onChange:e=>{g(e.target.value),D(1)},placeholder:`Search by name or email`,className:`pl-9`,"aria-label":`Search users`})]}),(0,G.jsx)(B,{value:S,onChange:e=>{T(e),D(1)},options:[{value:``,label:`Everyone`},{value:`student`,label:`Students`},{value:`instructor`,label:`Instructors`},{value:`admin`,label:`Admins`}]}),(0,G.jsxs)(s,{className:`sm:ml-auto`,onClick:()=>H(!0),children:[(0,G.jsx)(A,{}),` Add person`]})]}),Y?(0,G.jsx)(z,{error:Y,onRetry:()=>X()}):fe||!J?(0,G.jsx)(R,{className:`h-96`}):J.items.length===0?(0,G.jsx)(V,{icon:se,title:`No people found`}):(0,G.jsxs)(k,{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 text-muted-foreground`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Person`}),(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:`Courses`}),(0,G.jsx)(`th`,{className:`hidden px-3 py-3 font-medium lg:table-cell`,children:`Last sign-in`}),(0,G.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y`,children:J.items.map(n=>(0,G.jsxs)(`tr`,{className:`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)(ce,{user:n,size:`sm`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.id===t?.id&&(0,G.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`(you)`})]}),(0,G.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.email})]})]})}),(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)(b,{variant:ue[n.role],children:i[n.role]}),n.status===`suspended`&&(0,G.jsx)(b,{variant:`danger`,children:`Suspended`})]})}),(0,G.jsx)(`td`,{className:`hidden px-3 py-3 text-muted-foreground tabular-nums md:table-cell`,children:n.courseCount}),(0,G.jsx)(`td`,{className:`hidden px-3 py-3 text-muted-foreground lg:table-cell`,children:n.lastLoginAt?e(n.lastLoginAt):`Never`}),(0,G.jsx)(`td`,{className:`px-3 py-3 text-right`,children:n.id!==t?.id&&(0,G.jsxs)(v,{children:[(0,G.jsx)(le,{asChild:!0,children:(0,G.jsx)(s,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${n.name}`,children:(0,G.jsx)(I,{})})}),(0,G.jsxs)(f,{className:`w-56`,children:[n.role!==`admin`&&n.status===`active`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(w,{onSelect:()=>me.mutate(n.id),children:[(0,G.jsx)(U,{}),` Log in as `,n.name.split(` `)[0]]}),(0,G.jsx)(C,{})]}),(0,G.jsx)(ie,{children:`Site role`}),[`student`,`instructor`,`admin`].map(e=>(0,G.jsx)(M,{checked:n.role===e,onSelect:()=>Q.mutate({id:n.id,body:{role:e}}),children:i[e]},e)),(0,G.jsx)(C,{}),(0,G.jsxs)(w,{onSelect:()=>Q.mutate({id:n.id,body:{status:n.status===`active`?`suspended`:`active`}}),children:[n.status===`active`?(0,G.jsx)(N,{}):(0,G.jsx)(p,{}),n.status===`active`?`Suspend account`:`Reactivate account`]}),(0,G.jsxs)(w,{destructive:!0,onSelect:async()=>{await u({title:`Delete ${n.name}?`,description:`Their account, enrolments, submissions, grades and posts are permanently deleted.`,confirmLabel:`Delete account`,destructive:!0})&&pe.mutate(n.id)},children:[(0,G.jsx)(O,{}),` Delete account`]})]})]})})]},n.id))})]})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t px-5 py-3 text-sm text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[J.total,` `,J.total===1?`person`:`people`]}),$>1&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(s,{variant:`outline`,size:`icon-sm`,disabled:E<=1,onClick:()=>D(E-1),"aria-label":`Previous page`,children:(0,G.jsx)(P,{})}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[E,` / `,$]}),(0,G.jsx)(s,{variant:`outline`,size:`icon-sm`,disabled:E>=$,onClick:()=>D(E+1),"aria-label":`Next page`,children:(0,G.jsx)(x,{})})]})]})]}),(0,G.jsx)(de,{open:F,onOpenChange:H,onDone:Z})]})}export{q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,D as t,E as n,J as r,O as i,P as a,Rt as o,St as s,T as c,X as l,Y as u,a as d,f,g as p,k as m,l as h,m as g,n as _,ot as v,rt as y,t as b,u as x,wt as S,yt as C}from"./index-B29bTBiJ.js";import{F as w,H as T,O as E,T as D,U as O,_ as k,dt as A,ft as j,g as M,h as N,k as P,m as F,mt as I,r as L,ut as R}from"./hooks-BBARn-DA.js";import{t as z}from"./chevron-left-D6IMQD6N.js";import{T as B,c as V}from"./misc-DvgDEI3I.js";var H={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`}]]};H.node;var U=T(H),W={name:`video`,size:24,node:[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]};W.node;var G=T(W),K=I(j(),1),q=A(),J=Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(void 0,{weekday:`short`}).format(new Date(2024,0,1+t)));function Y(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7;return new Date(t.getFullYear(),t.getMonth(),1-n)}var X=e=>`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;function Z(e){if(e.kind===`personal`)return{background:`color-mix(in oklab, var(--primary) 14%, transparent)`,color:`var(--primary)`};let t=a(e.course?.coverColor??`slate`);return{background:`color-mix(in oklab, ${t.from} 16%, transparent)`,color:`color-mix(in oklab, ${t.to} 80%, var(--foreground))`}}function Q({kind:e}){return e===`due`?(0,q.jsx)(C,{className:`size-3 shrink-0`}):e===`course-start`||e===`course-end`?(0,q.jsx)(U,{className:`size-3 shrink-0`}):(0,q.jsx)(G,{className:`size-3 shrink-0`})}function $({event:t,onDeleted:n}){let r=o({mutationFn:()=>F.delete(`/calendar/events/${t.id}`),onSuccess:n,onError:e=>B.error(N(e))});return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`font-semibold leading-snug`,children:t.title}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[D(t.startsAt),t.endsAt&&` – ${E(t.endsAt)}`]}),t.course&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.course.title}),t.description&&(0,q.jsx)(`p`,{className:`text-sm`,children:t.description}),(0,q.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[t.link&&(0,q.jsx)(M,{asChild:!0,size:`xs`,variant:`outline`,children:(0,q.jsx)(e,{to:t.link,children:`Open`})}),t.canDelete&&(0,q.jsxs)(M,{size:`xs`,variant:`ghost`,className:`text-destructive`,onClick:()=>r.mutate(),loading:r.isPending,children:[(0,q.jsx)(y,{}),` Delete`]})]})]})}function ee({open:e,onOpenChange:r,onCreated:a,defaultDate:s}){let{data:l}=O({queryKey:[`courses`,`mine`],queryFn:()=>F.get(`/courses/mine`)}),u=(l??[]).filter(e=>e.myRole===`teacher`),d=new Date(s);d.setHours(17,0,0,0);let[p,_]=(0,K.useState)({title:``,description:``,startsAt:w(d.toISOString()),endsAt:``,courseId:``}),v=o({mutationFn:()=>F.post(`/calendar/events`,{title:p.title,description:p.description||null,startsAt:P(p.startsAt),endsAt:P(p.endsAt),courseId:p.courseId||null}),onSuccess:()=>{B.success(`Event added`),a(),r(!1)},onError:e=>B.error(N(e))});return(0,q.jsx)(c,{open:e,onOpenChange:r,children:(0,q.jsx)(t,{children:(0,q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v.mutate()},children:[(0,q.jsx)(m,{icon:(0,q.jsx)(S,{className:`size-5`}),title:`New event`,description:`Personal events are only visible to you. Course events are shown to everyone in the course.`}),(0,q.jsxs)(n,{className:`space-y-4`,children:[(0,q.jsx)(h,{label:`Title`,children:e=>(0,q.jsx)(x,{...e,autoFocus:!0,required:!0,value:p.title,onChange:e=>_({...p,title:e.target.value})})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsx)(h,{label:`Starts`,children:e=>(0,q.jsx)(x,{...e,type:`datetime-local`,required:!0,value:p.startsAt,onChange:e=>_({...p,startsAt:e.target.value})})}),(0,q.jsx)(h,{label:`Ends`,optional:!0,children:e=>(0,q.jsx)(x,{...e,type:`datetime-local`,value:p.endsAt,onChange:e=>_({...p,endsAt:e.target.value})})})]}),u.length>0&&(0,q.jsx)(h,{label:`Visible to`,children:e=>(0,q.jsxs)(f,{...e,value:p.courseId,onChange:e=>_({...p,courseId:e.target.value}),children:[(0,q.jsx)(`option`,{value:``,children:`Only me`}),u.map(e=>(0,q.jsxs)(`option`,{value:e.id,children:[`Everyone in `,e.title]},e.id))]})}),(0,q.jsx)(h,{label:`Notes`,optional:!0,children:e=>(0,q.jsx)(g,{...e,rows:3,value:p.description,onChange:e=>_({...p,description:e.target.value})})})]}),(0,q.jsxs)(i,{children:[(0,q.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,q.jsx)(M,{type:`submit`,loading:v.isPending,children:`Add event`})]})]})})})}function te(){L(`Calendar`);let t=R(),[n,i]=(0,K.useState)(()=>new Date(new Date().getFullYear(),new Date().getMonth(),1)),[a,o]=(0,K.useState)(null),c=Y(n),f=new Date(c.getFullYear(),c.getMonth(),c.getDate()+42),m={from:c.toISOString(),to:f.toISOString()},h=[`calendar`,m.from,m.to],{data:g,isLoading:y}=O({queryKey:h,queryFn:()=>F.get(`/calendar?${new URLSearchParams(m)}`)}),x=()=>t.invalidateQueries({queryKey:[`calendar`]}),S=(0,K.useMemo)(()=>{let e=new Map;for(let t of g??[]){let n=X(new Date(t.startsAt));e.set(n,[...e.get(n)??[],t])}return e},[g]),C=new Date,w=Array.from({length:42},(e,t)=>new Date(c.getFullYear(),c.getMonth(),c.getDate()+t)),T=(g??[]).filter(e=>new Date(e.startsAt)>=new Date(C.getFullYear(),C.getMonth(),C.getDate())).slice(0,8),D=new Intl.DateTimeFormat(void 0,{month:`long`,year:`numeric`}).format(n);return(0,q.jsxs)(p,{size:`wide`,children:[(0,q.jsx)(d,{title:`Calendar`,description:`Due dates, course events and your own reminders in one place.`,actions:(0,q.jsxs)(M,{onClick:()=>o(new Date),children:[(0,q.jsx)(v,{}),` New event`]})}),(0,q.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,q.jsxs)(b,{className:`overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-5 py-3`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:D}),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,q.jsx)(M,{variant:`outline`,size:`sm`,onClick:()=>i(new Date(C.getFullYear(),C.getMonth(),1)),children:`Today`}),(0,q.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(new Date(n.getFullYear(),n.getMonth()-1,1)),"aria-label":`Previous month`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:()=>i(new Date(n.getFullYear(),n.getMonth()+1,1)),"aria-label":`Next month`,children:(0,q.jsx)(s,{})})]})]}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 border-b bg-muted/40 text-center text-xs font-medium text-muted-foreground`,children:J.map(e=>(0,q.jsx)(`div`,{className:`py-2`,children:e},e))}),y?(0,q.jsx)(V,{className:`h-[540px] rounded-none`}):(0,q.jsx)(`div`,{className:`grid grid-cols-7`,children:w.map((e,t)=>{let i=e.getMonth()===n.getMonth(),a=X(e)===X(C),s=S.get(X(e))??[];return(0,q.jsxs)(`div`,{onDoubleClick:()=>o(e),className:k(`group min-h-24 border-r border-b p-1.5 sm:min-h-28`,(t+1)%7==0&&`border-r-0`,!i&&`bg-muted/30`),children:[(0,q.jsx)(`div`,{className:`mb-1 flex items-center justify-between`,children:(0,q.jsx)(`span`,{className:k(`grid size-6 place-items-center rounded-full text-xs tabular-nums`,!i&&`text-muted-foreground/60`,a&&`bg-primary font-semibold text-primary-foreground`),children:e.getDate()})}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[s.slice(0,3).map(e=>(0,q.jsxs)(r,{children:[(0,q.jsx)(l,{asChild:!0,children:(0,q.jsxs)(`button`,{className:`flex w-full items-center gap-1 truncate rounded-md px-1.5 py-0.5 text-left text-[11px] font-medium transition-opacity hover:opacity-80`,style:Z(e),children:[(0,q.jsx)(Q,{kind:e.kind}),(0,q.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,q.jsx)(u,{className:`w-64`,children:(0,q.jsx)($,{event:e,onDeleted:x})})]},e.id)),s.length>3&&(0,q.jsxs)(`p`,{className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,s.length-3,` more`]})]})]},t)})})]}),(0,q.jsxs)(b,{children:[(0,q.jsx)(_,{title:`Coming up`,description:`The next things on your calendar.`}),(0,q.jsxs)(`div`,{className:`space-y-1 px-2 pb-3`,children:[T.length===0&&(0,q.jsx)(`p`,{className:`px-3 pb-3 text-sm text-muted-foreground`,children:`Nothing scheduled in this view.`}),T.map(t=>{let n=new Date(t.startsAt),r=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`flex w-11 shrink-0 flex-col items-center rounded-lg border bg-card py-1`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase`,children:new Intl.DateTimeFormat(void 0,{month:`short`}).format(n)}),(0,q.jsx)(`span`,{className:`text-base leading-tight font-semibold tabular-nums`,children:n.getDate()})]}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:t.title}),(0,q.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[E(t.startsAt),t.course&&` · ${t.course.title}`]})]})]});return t.link?(0,q.jsx)(e,{to:t.link,className:`flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50`,children:r},t.id):(0,q.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg px-3 py-2`,children:r},t.id)})]})]})]}),a&&(0,q.jsx)(ee,{open:!!a,onOpenChange:e=>!e&&o(null),onCreated:x,defaultDate:a})]})}export{te as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,B as t,C as n,D as r,E as i,G as a,H as o,K as s,O as c,Q as l,R as u,Rt as d,S as f,T as p,Tt as m,U as h,V as g,W as _,Z as v,_t as y,g as b,gt as x,k as S,l as C,m as w,n as T,ot as E,q as D,rt as O,t as k,u as A,ut as j,v as M,w as N,xt as P}from"./index-B29bTBiJ.js";import{D as ee,H as F,M as I,S as te,U as ne,_ as L,dt as re,ft as ie,g as R,h as z,m as B,mt as ae,x as V}from"./hooks-BBARn-DA.js";import{n as H,t as U}from"./arrow-up-LHDup5m4.js";import{n as oe,t as se}from"./ActivityEditor-BVSZUV8l.js";import{t as W}from"./ellipsis-c2POIN-Y.js";import{t as G}from"./pencil-p0GQmIMo.js";import{T as K,a as ce,t as le}from"./misc-DvgDEI3I.js";import{n as ue}from"./markdown-ykrkPMbn.js";import{a as q,r as de}from"./context-BLVW7NB7.js";var J={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};J.node;var fe=F(J),Y={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};Y.node;var pe=F(Y),X={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};X.node;var me=F(X),Z=ae(ie(),1),Q=re();function he({activity:e,onToggle:t,busy:n}){return e.completion===`none`?null:e.completed?e.completion===`manual`?(0,Q.jsx)(v,{content:`Completed. Click to undo`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-success transition-transform hover:scale-110`,"aria-label":`Mark as not done`,children:(0,Q.jsx)(P,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completed`,children:(0,Q.jsx)(P,{className:`size-5 text-success`})}):e.completion===`manual`?(0,Q.jsx)(v,{content:`Mark as done`,children:(0,Q.jsx)(`button`,{onClick:t,disabled:n,className:`text-muted-foreground/50 transition-colors hover:text-success`,"aria-label":`Mark as done`,children:(0,Q.jsx)(oe,{className:`size-5`})})}):(0,Q.jsx)(v,{content:`Completes automatically`,children:(0,Q.jsx)(pe,{className:`size-5 text-muted-foreground/40`})})}function $({open:e,onOpenChange:t,course:n,section:a}){let[o,s]=(0,Z.useState)(a?.title??``),[l,u]=(0,Z.useState)(a?.summary??``),f=q(),m=d({mutationFn:()=>a?B.patch(`/courses/${n.id}/sections/${a.id}`,{title:o,summary:l}):B.post(`/courses/${n.id}/sections`,{title:o,summary:l}),onSuccess:async()=>{await f(n.slug),t(!1),K.success(a?`Section updated`:`Section added`)},onError:e=>K.error(z(e))});return(0,Q.jsx)(p,{open:e,onOpenChange:t,children:(0,Q.jsx)(r,{children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.mutate()},children:[(0,Q.jsx)(S,{title:a?`Edit section`:`New section`,description:`Sections group activities into weeks, topics or modules.`}),(0,Q.jsxs)(i,{className:`space-y-4`,children:[(0,Q.jsx)(C,{label:`Title`,children:e=>(0,Q.jsx)(A,{...e,autoFocus:!0,required:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Week 3: Working with data`})}),(0,Q.jsx)(C,{label:`Summary`,optional:!0,children:e=>(0,Q.jsx)(w,{...e,rows:3,value:l,onChange:e=>u(e.target.value),placeholder:`What students will do in this section`})})]}),(0,Q.jsxs)(c,{children:[(0,Q.jsx)(R,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(R,{type:`submit`,loading:m.isPending,children:a?`Save`:`Add section`})]})]})})})}function ge({activity:r,course:i,editing:o,isStudent:c,onEdit:p,onMove:v,onMoveTo:b}){let S=q(),C=l(),w=d({mutationFn:()=>r.completed?B.delete(`/activities/${r.id}/complete`):B.post(`/activities/${r.id}/complete`),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),T=d({mutationFn:e=>B.patch(`/activities/${r.id}`,e),onSuccess:()=>S(i.slug),onError:e=>K.error(z(e))}),E=d({mutationFn:()=>B.delete(`/activities/${r.id}`),onSuccess:async()=>{await S(i.slug),K.success(`Activity deleted`)},onError:e=>K.error(z(e))}),k=c&&r.dueAt&&I(r.dueAt)&&!r.completed;return(0,Q.jsxs)(`li`,{className:L(`group relative flex items-center gap-3.5 px-5 py-3 transition-colors hover:bg-accent/40`,!r.visible&&`bg-muted/40`),children:[(0,Q.jsx)(M,{type:r.type,className:L(!r.visible&&`opacity-50`)}),(0,Q.jsxs)(e,{to:N(i.slug,r.id),className:`min-w-0 flex-1 after:absolute after:inset-0`,children:[(0,Q.jsx)(`p`,{className:L(`truncate text-sm font-medium group-hover:text-primary`,!r.visible&&`text-muted-foreground`),children:r.title}),(0,Q.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:n[r.type].label}),r.meta&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsx)(`span`,{children:r.meta})]}),r.dueAt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`•`}),(0,Q.jsxs)(`span`,{className:L(`flex items-center gap-1`,k&&`font-medium text-destructive`),children:[(0,Q.jsx)(m,{className:`size-3`}),V(r.dueAt,!c||r.completed)]})]})]})]}),!r.visible&&(0,Q.jsxs)(f,{variant:`outline`,className:`relative`,children:[(0,Q.jsx)(y,{}),` Hidden`]}),o?(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-0.5`,children:[(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,onClick:p,"aria-label":`Edit activity`,children:(0,Q.jsx)(G,{})}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsxs)(g,{onSelect:()=>v(-1),children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>v(1),children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(_,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(me,{}),` Move to section`]}),(0,Q.jsx)(a,{children:i.sections.filter(e=>e.id!==r.sectionId).map(e=>(0,Q.jsx)(g,{onSelect:()=>b(e.id),children:e.title},e.id))})]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate({visible:!r.visible}),children:[r.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,r.visible?`Hide from students`:`Show to students`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await C({title:`Delete “${r.title}”?`,description:`This removes the activity and all of its submissions, attempts, posts and grades.`,confirmLabel:`Delete`,destructive:!0})&&E.mutate()},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]})]}):c&&(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(he,{activity:r,onToggle:()=>w.mutate(),busy:w.isPending})})]})}function _e({section:e,index:n,course:r,editing:i,isStudent:a,onAddActivity:s,onEditActivity:c}){let[p,m]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(!1),b=q(),S=l(),C=e.activities.filter(e=>e.visible&&e.completion!==`none`),w=C.filter(e=>e.completed).length,T=d({mutationFn:e=>e(),onSuccess:()=>b(r.slug),onError:e=>K.error(z(e))}),A=e=>{let t=r.sections.map(e=>e.id),i=n+e;i<0||i>=t.length||([t[n],t[i]]=[t[i],t[n]],T.mutate(()=>B.put(`/courses/${r.id}/sections/order`,{ids:t})))},j=(t,n)=>{let i=e.activities.map(e=>e.id),a=i.indexOf(t),o=a+n;o<0||o>=i.length||([i[a],i[o]]=[i[o],i[a]],T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:e.id,ids:i})))},M=(e,t)=>{let n=r.sections.find(e=>e.id===t);if(!n)return;let i=[...n.activities.map(e=>e.id),e];T.mutate(()=>B.put(`/courses/${r.id}/activities/order`,{sectionId:t,ids:i}))};return(0,Q.jsxs)(k,{className:L(`overflow-hidden`,!e.visible&&`border-dashed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 px-5 py-4`,children:[(0,Q.jsxs)(`button`,{onClick:()=>m(!p),className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-expanded":p,children:[(0,Q.jsx)(`span`,{className:L(`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full text-xs font-semibold`,a&&C.length>0&&w===C.length?`bg-success text-white`:`bg-muted text-muted-foreground`),children:a&&C.length>0&&w===C.length?(0,Q.jsx)(P,{className:`size-4`}):n+1}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-tight`,children:e.title}),!e.visible&&(0,Q.jsxs)(f,{variant:`outline`,children:[(0,Q.jsx)(y,{}),` Hidden`]})]}),e.summary&&(0,Q.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.summary})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[a&&C.length>0&&(0,Q.jsxs)(`span`,{className:`hidden items-center gap-2 text-xs text-muted-foreground sm:flex`,children:[(0,Q.jsx)(ce,{value:w/C.length*100,className:`w-16`,tone:w===C.length?`success`:`primary`}),w,`/`,C.length]}),i&&(0,Q.jsxs)(u,{children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(R,{variant:`ghost`,size:`icon-sm`,"aria-label":`Section actions`,children:(0,Q.jsx)(W,{})})}),(0,Q.jsxs)(t,{children:[(0,Q.jsx)(o,{children:`Section`}),(0,Q.jsxs)(g,{onSelect:()=>v(!0),children:[(0,Q.jsx)(G,{}),` Rename`]}),(0,Q.jsxs)(g,{onSelect:()=>A(-1),disabled:n===0,children:[(0,Q.jsx)(U,{}),` Move up`]}),(0,Q.jsxs)(g,{onSelect:()=>A(1),disabled:n===r.sections.length-1,children:[(0,Q.jsx)(H,{}),` Move down`]}),(0,Q.jsxs)(g,{onSelect:()=>T.mutate(()=>B.patch(`/courses/${r.id}/sections/${e.id}`,{visible:!e.visible})),children:[e.visible?(0,Q.jsx)(y,{}):(0,Q.jsx)(x,{}),` `,e.visible?`Hide section`:`Show section`]}),(0,Q.jsx)(h,{}),(0,Q.jsxs)(g,{destructive:!0,onSelect:async()=>{await S({title:`Delete “${e.title}”?`,description:`This also deletes its ${e.activities.length} activities and everything students submitted to them.`,confirmLabel:`Delete section`,destructive:!0})&&T.mutate(()=>B.delete(`/courses/${r.id}/sections/${e.id}`))},children:[(0,Q.jsx)(O,{}),` Delete`]})]})]}),(0,Q.jsx)(`button`,{onClick:()=>m(!p),className:`text-muted-foreground`,"aria-label":p?`Collapse section`:`Expand section`,children:(0,Q.jsx)(fe,{className:L(`size-4.5 transition-transform`,!p&&`-rotate-90`)})})]})]}),p&&(0,Q.jsxs)(Q.Fragment,{children:[e.activities.length>0?(0,Q.jsx)(`ul`,{className:`divide-y border-t`,children:e.activities.map(e=>(0,Q.jsx)(ge,{activity:e,course:r,editing:i,isStudent:a,onEdit:()=>c(e.id),onMove:t=>j(e.id,t),onMoveTo:t=>M(e.id,t)},e.id))}):!i&&(0,Q.jsx)(`p`,{className:`border-t px-5 py-4 text-sm text-muted-foreground`,children:`Nothing here yet.`}),i&&(0,Q.jsx)(`div`,{className:`border-t p-2`,children:(0,Q.jsxs)(`button`,{onClick:s,className:`flex w-full items-center justify-center gap-2 rounded-lg border border-dashed py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:bg-primary/[0.03] hover:text-primary`,children:[(0,Q.jsx)(E,{className:`size-4`}),` Add activity`]})})]}),_&&(0,Q.jsx)($,{open:_,onOpenChange:v,course:r,section:e})]})}function ve(){let{course:t,editing:n}=de(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),s=t.myRole===`student`,{data:c}=ne({queryKey:[`announcements`,t.id],queryFn:()=>B.get(`/courses/${t.id}/announcements`)}),l=t.sections.flatMap(e=>e.activities).filter(e=>e.dueAt&&!I(e.dueAt)&&e.visible).sort((e,t)=>e.dueAt.localeCompare(t.dueAt)).slice(0,4);return(0,Q.jsxs)(b,{children:[n&&(0,Q.jsxs)(`div`,{className:`mb-5 flex items-center gap-3 rounded-xl border border-primary/30 bg-primary/[0.05] px-4 py-3 text-sm`,children:[(0,Q.jsx)(G,{className:`size-4 text-primary`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Edit mode is on.`}),` Add, reorder, hide or delete sections and activities.`]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[t.sections.length===0&&(0,Q.jsx)(le,{icon:E,title:`This course is empty`,description:`Turn on edit mode to add the first section.`}),t.sections.map((e,r)=>(0,Q.jsx)(_e,{section:e,index:r,course:t,editing:n,isStudent:s,onAddActivity:()=>i({sectionId:e.id}),onEditActivity:e=>i({activityId:e})},e.id)),n&&(0,Q.jsxs)(R,{variant:`outline`,className:`w-full border-dashed`,size:`lg`,onClick:()=>o(!0),children:[(0,Q.jsx)(E,{}),` Add section`]})]}),(0,Q.jsxs)(`aside`,{className:`space-y-5 lg:sticky lg:top-32`,children:[l.length>0&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Coming up`,icon:(0,Q.jsx)(m,{className:`size-4.5`})}),(0,Q.jsx)(`div`,{className:`space-y-1 px-2 pb-3`,children:l.map(n=>(0,Q.jsxs)(e,{to:N(t.slug,n.id),className:`flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(M,{type:n.type,size:`sm`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:V(n.dueAt)})]})]},n.id))})]}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Latest news`,icon:(0,Q.jsx)(j,{className:`size-4.5`}),action:(0,Q.jsx)(e,{to:`/courses/${t.slug}/announcements`,className:`text-xs font-medium text-primary hover:underline`,children:`View all`})}),(0,Q.jsxs)(`div`,{className:`space-y-1 px-2 pb-3`,children:[(c??[]).slice(0,2).map(n=>(0,Q.jsxs)(e,{to:`/courses/${t.slug}/announcements`,className:`block rounded-lg px-3 py-2 hover:bg-accent/50`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:te(n.body)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:ee(n.createdAt)})]},n.id)),c?.length===0&&(0,Q.jsx)(`p`,{className:`px-3 pb-2 text-sm text-muted-foreground`,children:`No announcements yet.`})]})]}),t.description&&(0,Q.jsxs)(k,{children:[(0,Q.jsx)(T,{title:`Overview`}),(0,Q.jsx)(`div`,{className:`max-h-72 overflow-hidden px-5 pb-5 [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,Q.jsx)(ue,{source:t.description,className:`prose-sm`})})]})]})]}),r&&(0,Q.jsx)(se,{course:t,open:!!r,onOpenChange:e=>!e&&i(null),sectionId:r.sectionId,activityId:r.activityId}),a&&(0,Q.jsx)($,{open:a,onOpenChange:o,course:t})]})}export{ve as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,C as t,Ct as n,Dt as r,Et as i,Lt as a,M as o,Ot as s,Pt as c,Rt as l,St as u,et as d,g as f,jt as p,n as m,t as h,u as g,ut as _,v,w as y,x as b}from"./index-B29bTBiJ.js";import{H as x,N as S,_ as C,dt as w,ft as T,g as E,h as D,m as O,mt as k,p as A,r as j,u as M,w as N}from"./hooks-BBARn-DA.js";import{t as P}from"./key-round-B_KI-brR.js";import{t as F}from"./lock-BjbqwA_0.js";import{t as I}from"./pencil-p0GQmIMo.js";import{t as L}from"./settings-DRKWzSHN.js";import{T as R,c as z,n as B,o as V}from"./misc-DvgDEI3I.js";import{n as H}from"./markdown-ykrkPMbn.js";import U from"./NotFoundPage-BRquC7-l.js";import{a as W,i as G,n as K,t as q}from"./context-BLVW7NB7.js";var J={name:`calendar-range`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M17 13h-6`,key:`1qbiup`}],[`path`,{d:`M13 17H7`,key:`1x38vv`}],[`path`,{d:`M7 13h.01`,key:`1vezk1`}],[`path`,{d:`M17 17h.01`,key:`1sd3ek`}]]};J.node;var Y=x(J),X=k(T(),1),Z=w();function Q({course:e}){return(0,Z.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-white/85`,children:[e.teachers.length>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{users:e.teachers,max:3,size:`xs`}),e.teachers.map(e=>e.name).join(`, `)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(d,{className:`size-4`}),` `,S(e.studentCount,`student`)]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(i,{className:`size-4`}),` `,S(e.activityCount,`activity`,`activities`)]}),(e.startDate||e.endDate)&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Y,{className:`size-4`}),` `,N(e.startDate),` – `,N(e.endDate)]})]})}function $({course:t,editing:r,setEditing:i}){let a=t.capabilities.includes(`course:manageContent`),o=q(t).filter(e=>e.visible&&e.completion!==`none`),c=o.filter(e=>e.completed).length,l=t.myRole===`student`?K(t):null;return(0,Z.jsxs)(b,{color:t.coverColor,imageUrl:t.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-6 pb-8 sm:px-6 lg:px-8 lg:pt-8`,children:[(0,Z.jsxs)(`nav`,{className:`flex items-center gap-1.5 text-[13px] text-white/75`,children:[(0,Z.jsx)(e,{to:`/catalog`,className:`hover:text-white`,children:`Courses`}),t.categoryName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3.5`}),(0,Z.jsx)(e,{to:`/catalog?category=${t.categoryId}`,className:`hover:text-white`,children:t.categoryName})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-3xl min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[t.visibility!==`published`&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white px-2.5 py-0.5 text-xs font-semibold text-slate-900 capitalize`,children:t.visibility}),t.myRole&&(0,Z.jsx)(`span`,{className:`rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-medium backdrop-blur`,children:M[t.myRole]})]}),(0,Z.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-balance sm:text-4xl`,children:t.title}),t.summary&&(0,Z.jsx)(`p`,{className:`mt-2.5 max-w-2xl text-[15px] leading-relaxed text-white/85`,children:t.summary}),(0,Z.jsx)(Q,{course:t})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3`,children:[t.progress!=null&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-black/15 py-2.5 pr-4 pl-2.5 ring-1 ring-white/20 backdrop-blur-md`,children:[(0,Z.jsx)(V,{value:t.progress,size:46,className:`text-white`}),(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-semibold`,children:`Your progress`}),(0,Z.jsxs)(`p`,{className:`text-white/75`,children:[c,` of `,o.length,` done`]})]})]}),l&&(0,Z.jsx)(E,{asChild:!0,className:`bg-white text-slate-900 shadow-lg hover:bg-white/90 hover:brightness-100`,size:`lg`,children:(0,Z.jsxs)(e,{to:y(t.slug,l.id),children:[`Continue `,(0,Z.jsx)(s,{})]})}),a&&(0,Z.jsxs)(E,{size:`lg`,onClick:()=>i(!r),className:C(`hover:brightness-100`,r?`bg-white text-slate-900 hover:bg-white/90`:`bg-white/15 text-white ring-1 ring-white/25 backdrop-blur hover:bg-white/25`),children:[r?(0,Z.jsx)(n,{}):(0,Z.jsx)(I,{}),r?`Done editing`:`Edit course`]})]})]})]})]})}function ee({course:e}){let[n,r]=(0,X.useState)(``),i=W(),a=l({mutationFn:()=>O.post(`/courses/${e.id}/enrol`,e.hasEnrolmentKey?{key:n}:{}),onSuccess:async()=>{R.success(`You're enrolled in ${e.title}. Have fun!`),await i(e.slug)},onError:e=>R.error(D(e))});return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(b,{color:e.coverColor,imageUrl:e.coverImageUrl,className:`text-white`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/25 to-transparent`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto max-w-7xl px-4 pt-10 pb-12 sm:px-6 lg:px-8`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-white/75`,children:e.categoryName??`Course`}),(0,Z.jsx)(`h1`,{className:`mt-2 max-w-3xl text-3xl font-semibold tracking-tight sm:text-5xl`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-2xl text-base text-white/85`,children:e.summary}),(0,Z.jsx)(Q,{course:e})]})]}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-8`,children:[e.description&&(0,Z.jsx)(h,{className:`p-6`,children:(0,Z.jsx)(H,{source:e.description})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-lg font-semibold tracking-tight`,children:`Course outline`}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:e.sections.map((e,n)=>(0,Z.jsxs)(h,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-5 py-3.5`,children:[(0,Z.jsx)(`span`,{className:`grid size-6 place-items-center rounded-full bg-muted text-xs font-semibold`,children:n+1}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:S(e.activities.length,`activity`,`activities`)})]}),(0,Z.jsx)(`ul`,{className:`divide-y`,children:e.activities.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-2.5 text-sm`,children:[(0,Z.jsx)(v,{type:e.type,size:`sm`}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t[e.type].label}),(0,Z.jsx)(F,{className:`size-3.5 text-muted-foreground/60`})]},e.id))})]},e.id))})]})]}),(0,Z.jsxs)(h,{className:`sticky top-20`,children:[(0,Z.jsx)(m,{title:`Join this course`,description:e.canEnrol?`Get instant access to every lesson and activity.`:void 0}),(0,Z.jsx)(`div`,{className:`space-y-3 px-5 pb-5`,children:e.canEnrol?(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.mutate()},className:`space-y-3`,children:[e.hasEnrolmentKey&&(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(P,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(g,{value:n,onChange:e=>r(e.target.value),placeholder:`Enrolment key`,className:`pl-9`,"aria-label":`Enrolment key`})]}),(0,Z.jsx)(E,{type:`submit`,size:`lg`,className:`w-full`,loading:a.isPending,disabled:e.hasEnrolmentKey&&!n.trim(),children:`Enrol now`}),e.hasEnrolmentKey&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Your teacher gives you the key for this course.`})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This course is invite-only. Ask a teacher to add you.`})})]})]})})]})}function te(){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{className:`h-64 rounded-none`}),(0,Z.jsx)(f,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(z,{className:`h-40`}),(0,Z.jsx)(z,{className:`h-40`})]})})]})}function ne(){let{slug:e}=a(),{data:t,isLoading:n,error:o,refetch:s}=G(e),[l,u]=(0,X.useState)(!1);if(j(t?.title),n)return(0,Z.jsx)(te,{});if(o instanceof A&&o.status===404)return(0,Z.jsx)(U,{});if(o||!t)return(0,Z.jsx)(f,{children:(0,Z.jsx)(B,{error:o,onRetry:()=>s()})});if(t.outlineOnly)return(0,Z.jsx)(ee,{course:t});let m=e=>t.capabilities.includes(e),h=[{to:``,label:`Course`,icon:i,end:!0},{to:`announcements`,label:`Announcements`,icon:_},{to:`participants`,label:`Participants`,icon:d,show:m(`course:viewParticipants`)},{to:`grades`,label:`Grades`,icon:r},{to:`settings`,label:`Settings`,icon:L,show:m(`course:update`)}].filter(e=>e.show!==!1);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)($,{course:t,editing:l,setEditing:u}),(0,Z.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/85 backdrop-blur-lg`,children:(0,Z.jsx)(`nav`,{className:`ck-no-scrollbar mx-auto flex max-w-7xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8`,children:h.map(e=>(0,Z.jsxs)(p,{to:e.to?`/courses/${t.slug}/${e.to}`:`/courses/${t.slug}`,end:e.end,className:({isActive:e})=>C(`relative flex h-12 shrink-0 items-center gap-2 px-3 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground`,e&&`text-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-primary`),children:[(0,Z.jsx)(e.icon,{className:`size-4`}),e.label]},e.label))})}),(0,Z.jsx)(c,{context:{course:t,editing:l,setEditing:u,can:m}})]})}export{ne as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ct as e,Ft as t,I as n,N as r,Q as i,Rt as a,c as o,f as s,g as c,gt as l,l as u,m as d,rt as f,t as p,u as m}from"./index-B29bTBiJ.js";import{H as h,P as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,i as C,k as w,m as T,mt as E,r as D}from"./hooks-BBARn-DA.js";import{t as O}from"./key-round-B_KI-brR.js";import{T as k}from"./misc-DvgDEI3I.js";import{r as A}from"./constants-DLDWTvvN.js";import{r as j}from"./markdown-ykrkPMbn.js";import{a as M,r as N}from"./context-BLVW7NB7.js";var P={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};P.node;var F=h(P),I={name:`file-lock`,size:24,node:[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]],aliases:[`file-lock-2`]};I.node;var L=h(I),R={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};R.node;var z=h(R),B={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};B.node;var V=h(B),H=E(b(),1),U=y();function W({value:t,onChange:i}){return(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:A.map(a=>(0,U.jsx)(`button`,{type:`button`,title:r[a]?.label,onClick:()=>i(a),className:v(`grid size-10 place-items-center rounded-xl ring-offset-2 ring-offset-background transition-transform hover:scale-105`,t===a&&`ring-2 ring-foreground`),style:n(a),children:t===a&&(0,U.jsx)(e,{className:`size-4 text-white`,strokeWidth:3})},a))})}function G({title:e,description:t,children:n}){return(0,U.jsxs)(`div`,{className:`grid gap-6 border-b py-8 first:pt-0 last:border-0 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:e}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),(0,U.jsx)(`div`,{className:`space-y-5`,children:n})]})}function K(e){return{title:e.title,slug:e.slug,summary:e.summary,description:e.description,categoryId:e.categoryId??``,coverColor:e.coverColor,visibility:e.visibility,enrolment:e.enrolment,enrolmentKey:e.enrolmentKey??``,startDate:g(e.startDate),endDate:g(e.endDate)}}function q(){let{course:e}=N();D(`Settings · ${e.title}`);let n=t(),r=M(),h=i(),[g,v]=(0,H.useState)(()=>K(e)),y=JSON.stringify(K(e)),b=JSON.stringify(g)!==y;C(b);let{data:E}=_({queryKey:[`categories`],queryFn:()=>T.get(`/categories`)}),A=a({mutationFn:()=>T.patch(`/courses/${e.id}`,{...g,categoryId:g.categoryId||null,enrolmentKey:g.enrolment===`key`&&g.enrolmentKey.trim()||null,startDate:g.startDate?w(`${g.startDate}T00:00`):null,endDate:g.endDate?w(`${g.endDate}T23:59`):null}),onSuccess:async t=>{k.success(`Course settings saved`),await r(e.slug),t.slug!==e.slug&&n(`/courses/${t.slug}/settings`,{replace:!0})},onError:e=>k.error(S(e))}),P=a({mutationFn:()=>T.delete(`/courses/${e.id}`),onSuccess:async()=>{k.success(`Course deleted`),await r(e.slug),n(`/my-courses`)},onError:e=>k.error(S(e))}),I=(e,t)=>v(n=>({...n,[e]:t}));return(0,U.jsxs)(c,{children:[(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),A.mutate()},children:[(0,U.jsxs)(p,{className:`p-6 sm:p-8`,children:[(0,U.jsxs)(G,{title:`General`,description:`How the course appears in the catalog and on the dashboard.`,children:[(0,U.jsx)(u,{label:`Title`,children:e=>(0,U.jsx)(m,{...e,required:!0,value:g.title,onChange:e=>I(`title`,e.target.value)})}),(0,U.jsx)(u,{label:`Short summary`,hint:`One or two sentences shown on course cards.`,children:e=>(0,U.jsx)(d,{...e,rows:2,value:g.summary,onChange:e=>I(`summary`,e.target.value)})}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`URL`,hint:`${window.location.origin}/courses/${g.slug}`,children:e=>(0,U.jsx)(m,{...e,value:g.slug,onChange:e=>I(`slug`,e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`))})}),(0,U.jsx)(u,{label:`Category`,children:e=>(0,U.jsxs)(s,{...e,value:g.categoryId,onChange:e=>I(`categoryId`,e.target.value),children:[(0,U.jsx)(`option`,{value:``,children:`No category`}),E?.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,U.jsx)(u,{label:`Cover`,children:()=>(0,U.jsx)(W,{value:g.coverColor,onChange:e=>I(`coverColor`,e)})})]}),(0,U.jsx)(G,{title:`Description`,description:`The full course overview shown to people before and after they enrol.`,children:(0,U.jsx)(j,{value:g.description,onChange:e=>I(`description`,e),rows:10})}),(0,U.jsxs)(G,{title:`Availability`,description:`Drafts are only visible to teachers. Archived courses are read-only.`,children:[(0,U.jsx)(o,{value:g.visibility,onChange:e=>I(`visibility`,e),options:[{value:`draft`,label:`Draft`,description:`Hidden while you build it.`,icon:(0,U.jsx)(L,{className:`size-4`})},{value:`published`,label:`Published`,description:`Listed in the catalog.`,icon:(0,U.jsx)(z,{className:`size-4`})},{value:`archived`,label:`Archived`,description:`Read-only for students.`,icon:(0,U.jsx)(F,{className:`size-4`})}]}),(0,U.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,U.jsx)(u,{label:`Start date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.startDate,onChange:e=>I(`startDate`,e.target.value)})}),(0,U.jsx)(u,{label:`End date`,optional:!0,children:e=>(0,U.jsx)(m,{...e,type:`date`,value:g.endDate,onChange:e=>I(`endDate`,e.target.value)})})]})]}),(0,U.jsxs)(G,{title:`Enrolment`,description:`How students join the course.`,children:[(0,U.jsx)(o,{value:g.enrolment,onChange:e=>I(`enrolment`,e),options:[{value:`open`,label:`Open`,description:`Anyone can enrol themselves.`,icon:(0,U.jsx)(l,{className:`size-4`})},{value:`key`,label:`Enrolment key`,description:`Students need a secret key.`,icon:(0,U.jsx)(O,{className:`size-4`})},{value:`invite`,label:`Invite only`,description:`Teachers add students.`,icon:(0,U.jsx)(V,{className:`size-4`})}]}),g.enrolment===`key`&&(0,U.jsx)(u,{label:`Enrolment key`,hint:`Share this with your students.`,children:e=>(0,U.jsx)(m,{...e,value:g.enrolmentKey,onChange:e=>I(`enrolmentKey`,e.target.value),className:`sm:w-72`})})]})]}),(0,U.jsxs)(`div`,{className:`sticky bottom-4 z-10 mt-6 flex items-center justify-end gap-3 rounded-xl border bg-card/90 p-3 shadow-lg backdrop-blur`,children:[b&&(0,U.jsx)(`span`,{className:`mr-auto pl-2 text-sm text-muted-foreground`,children:`You have unsaved changes`}),(0,U.jsx)(x,{type:`button`,variant:`ghost`,disabled:!b,onClick:()=>v(K(e)),children:`Discard`}),(0,U.jsx)(x,{type:`submit`,loading:A.isPending,disabled:!b,children:`Save changes`})]})]}),(0,U.jsx)(p,{className:`mt-8 border-destructive/30 p-6`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`font-semibold`,children:`Delete this course`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Permanently removes the course with all activities, submissions, grades and posts.`})]}),(0,U.jsxs)(x,{variant:`destructive`,loading:P.isPending,onClick:async()=>{await h({title:`Delete “${e.title}”?`,description:`This cannot be undone. Everything in the course, including student work and grades, will be deleted.`,confirmLabel:`Delete course`,destructive:!0})&&P.mutate()},children:[(0,U.jsx)(f,{}),` Delete course`]})]})})]})}export{W as CoverPicker,q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ft as e,Nt as t,Ot as n,Rt as r,a as i,et as a,f as o,g as s,l as c,m as l,t as u,u as d,x as f}from"./index-B29bTBiJ.js";import{U as p,dt as m,f as h,ft as g,g as _,h as v,m as y,mt as b,r as x,s as S,ut as C}from"./hooks-BBARn-DA.js";import{T as w}from"./misc-DvgDEI3I.js";import{CoverPicker as T}from"./CourseSettingsPage-CReoPqOa.js";var E=b(g(),1),D=m();function O(){x(`New course`);let m=S(),g=e(),b=C(),[O,k]=(0,E.useState)({title:``,summary:``,categoryId:``,coverColor:`indigo`}),{data:A}=p({queryKey:[`categories`],queryFn:()=>y.get(`/categories`)}),j=r({mutationFn:()=>y.post(`/courses`,{...O,categoryId:O.categoryId||null}),onSuccess:async e=>{await b.invalidateQueries({queryKey:[`courses`]}),w.success(`Course created as a draft. Add your first activities!`),g(`/courses/${e.slug}`)},onError:e=>w.error(v(e))});return h(m?.role)?(0,D.jsxs)(s,{size:`narrow`,children:[(0,D.jsx)(i,{title:`Create a course`,description:`Start with the basics. You can change everything later in course settings.`}),(0,D.jsxs)(`div`,{className:`grid gap-6`,children:[(0,D.jsxs)(u,{className:`overflow-hidden`,children:[(0,D.jsx)(f,{color:O.coverColor,title:O.title||`New course`,className:`h-36`,children:(0,D.jsxs)(`div`,{className:`absolute inset-x-6 bottom-5 text-white`,children:[(0,D.jsx)(`p`,{className:`text-xs font-medium text-white/80`,children:A?.find(e=>e.id===O.categoryId)?.name??`Preview`}),(0,D.jsx)(`p`,{className:`mt-1 truncate text-2xl font-semibold tracking-tight`,children:O.title||`Your course title`})]})}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-3 text-xs text-muted-foreground`,children:[(0,D.jsx)(a,{className:`size-3.5`}),` You'll be the teacher. The course starts as a hidden draft.`]})]}),(0,D.jsx)(u,{className:`p-6`,children:(0,D.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),j.mutate()},children:[(0,D.jsx)(c,{label:`Course title`,children:e=>(0,D.jsx)(d,{...e,autoFocus:!0,required:!0,minLength:3,value:O.title,onChange:e=>k({...O,title:e.target.value}),placeholder:`e.g. Introduction to Psychology`})}),(0,D.jsx)(c,{label:`Short summary`,optional:!0,hint:`One or two sentences for the catalog.`,children:e=>(0,D.jsx)(l,{...e,rows:2,value:O.summary,onChange:e=>k({...O,summary:e.target.value})})}),(0,D.jsx)(c,{label:`Category`,optional:!0,children:e=>(0,D.jsxs)(o,{...e,value:O.categoryId,onChange:e=>k({...O,categoryId:e.target.value}),children:[(0,D.jsx)(`option`,{value:``,children:`No category`}),A?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(c,{label:`Cover`,children:()=>(0,D.jsx)(T,{value:O.coverColor,onChange:e=>k({...O,coverColor:e})})}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,D.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>g(-1),children:`Cancel`}),(0,D.jsxs)(_,{type:`submit`,loading:j.isPending,disabled:O.title.trim().length<3,children:[`Create course `,(0,D.jsx)(n,{})]})]})]})})]})]}):(0,D.jsx)(t,{to:`/`,replace:!0})}export{O as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Dt as t,J as n,Rt as r,S as i,X as a,Y as o,at as s,g as c,j as l,l as u,m as d,t as f,u as p,v as m,w as h}from"./index-B29bTBiJ.js";import{E as g,U as _,_ as v,dt as y,ft as b,g as x,h as S,m as C,mt as w,r as T,ut as E,w as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./message-square-text-fe24gbEU.js";import{T as A,a as j,c as M,n as N,o as P,t as F}from"./misc-DvgDEI3I.js";import{r as I}from"./context-BLVW7NB7.js";var L=w(b(),1),R=y();function z(e){return e==null?`text-muted-foreground`:e>=85?`text-emerald-600 dark:text-emerald-400`:e>=60?`text-foreground`:`text-red-600 dark:text-red-400`}function B({courseId:e,item:t,userId:i,score:s,feedback:c,editable:l}){let f=E(),[m,h]=(0,L.useState)(!1),[_,y]=(0,L.useState)(s?.toString()??``),[b,w]=(0,L.useState)(c??``),T=r({mutationFn:()=>C.put(`/courses/${e}/grades/${t.activityId}/${i}`,{score:_===``?null:Number(_),feedback:b.trim()||null}),onSuccess:async()=>{h(!1),A.success(`Grade saved`),await f.invalidateQueries({queryKey:[`grades`,e]})},onError:e=>A.error(S(e))}),D=s!=null&&t.maxGrade?s/t.maxGrade*100:null,O=(0,R.jsxs)(`span`,{className:v(`inline-flex items-center gap-1 tabular-nums`,z(D)),children:[s==null?(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`–`}):g(s),c&&(0,R.jsx)(k,{className:`size-3 text-muted-foreground`})]});return l?(0,R.jsxs)(n,{open:m,onOpenChange:e=>{h(e),e&&(y(s?.toString()??``),w(c??``))},children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{className:`w-full rounded-md px-2 py-1 text-right transition-colors hover:bg-accent`,children:O})}),(0,R.jsx)(o,{align:`end`,className:`w-72`,children:(0,R.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),T.mutate()},children:[(0,R.jsx)(`p`,{className:`text-sm font-semibold`,children:t.title}),(0,R.jsx)(u,{label:`Score (out of ${g(t.maxGrade)})`,children:e=>(0,R.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:t.maxGrade,autoFocus:!0,value:_,onChange:e=>y(e.target.value)})}),(0,R.jsx)(u,{label:`Feedback`,optional:!0,children:e=>(0,R.jsx)(d,{...e,rows:3,value:b,onChange:e=>w(e.target.value)})}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(x,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`}),(0,R.jsx)(x,{type:`submit`,size:`sm`,loading:T.isPending,children:`Save`})]})]})})]}):O}function V({book:n,courseId:r,courseSlug:i,editable:a}){let[o,c]=(0,L.useState)(``),u=(0,L.useMemo)(()=>{let e=o.trim().toLowerCase();return n.rows.filter(t=>!e||t.user.name.toLowerCase().includes(e)||t.user.email.toLowerCase().includes(e))},[n.rows,o]);return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`No graded activities yet`,description:`Assignments and quizzes appear here as soon as you add them.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,R.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,R.jsx)(s,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(p,{value:o,onChange:e=>c(e.target.value),placeholder:`Find a student`,className:`pl-9`,"aria-label":`Find a student`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-4 sm:ml-auto`,children:[(0,R.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Class average`,` `,(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]}),(0,R.jsx)(x,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`a`,{href:`/api/courses/${r}/grades/export.csv`,download:!0,children:[(0,R.jsx)(O,{}),` Export CSV`]})})]})]}),(0,R.jsx)(f,{className:`overflow-hidden`,children:(0,R.jsx)(`div`,{className:`ck-scrollbar overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:[(0,R.jsx)(`th`,{className:`sticky left-0 z-10 min-w-56 border-b bg-card px-5 py-3 font-medium`,children:`Student`}),n.items.map(t=>(0,R.jsx)(`th`,{className:`min-w-32 border-b px-3 py-3 text-right align-bottom font-medium`,children:(0,R.jsxs)(e,{to:h(i,t.activityId),className:`group inline-flex flex-col items-end gap-1.5`,children:[(0,R.jsx)(m,{type:t.type,size:`sm`}),(0,R.jsx)(`span`,{className:`line-clamp-2 max-w-32 text-foreground group-hover:text-primary`,children:t.title}),(0,R.jsxs)(`span`,{className:`font-normal`,children:[`/ `,g(t.maxGrade)]})]})},t.activityId)),(0,R.jsx)(`th`,{className:`min-w-28 border-b bg-muted/40 px-5 py-3 text-right align-bottom font-medium text-foreground`,children:`Total`})]})}),(0,R.jsx)(`tbody`,{children:u.map(e=>(0,R.jsxs)(`tr`,{className:`group`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 border-b bg-card px-5 py-2.5 group-hover:bg-accent`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{user:e.user,size:`sm`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-medium`,children:e.user.name}),(0,R.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.user.email})]})]})}),n.items.map(t=>(0,R.jsx)(`td`,{className:`border-b px-1.5 py-2 text-right group-hover:bg-accent/40`,children:(0,R.jsx)(B,{courseId:r,item:t,userId:e.user.id,score:e.cells[t.activityId]?.score??null,feedback:e.cells[t.activityId]?.feedback??null,editable:a})},t.activityId)),(0,R.jsxs)(`td`,{className:`border-b bg-muted/40 px-5 py-2.5 text-right`,children:[(0,R.jsx)(`span`,{className:v(`font-semibold tabular-nums`,z(e.percentage)),children:e.percentage==null?`–`:`${g(e.percentage)}%`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground tabular-nums`,children:[g(e.total),` / `,g(e.max)]})]})]},e.user.id))}),(0,R.jsx)(`tfoot`,{children:(0,R.jsxs)(`tr`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`td`,{className:`sticky left-0 z-10 bg-muted/60 px-5 py-3 font-medium text-foreground`,children:`Average`}),n.items.map(e=>(0,R.jsx)(`td`,{className:`bg-muted/60 px-3 py-3 text-right tabular-nums`,children:g(n.averages[e.activityId])},e.activityId)),(0,R.jsx)(`td`,{className:`bg-muted/60 px-5 py-3 text-right font-semibold text-foreground tabular-nums`,children:n.courseAverage==null?`–`:`${g(n.courseAverage)}%`})]})})]})})}),a&&(0,R.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Click any grade to change it or leave feedback. Students are notified when they receive a grade.`})]})}function H({grades:n,courseSlug:r}){return n.items.length===0?(0,R.jsx)(F,{icon:t,title:`Nothing graded yet`,description:`Grades for assignments and quizzes will show up here.`}):(0,R.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,R.jsx)(f,{className:`divide-y overflow-hidden`,children:n.items.map(t=>{let n=t.score!=null&&t.maxGrade?t.score/t.maxGrade*100:null;return(0,R.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(m,{type:t.type}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(e,{to:h(r,t.activityId),className:`truncate text-sm font-medium hover:text-primary`,children:t.title}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.gradedAt?`Graded ${D(t.gradedAt)}`:t.dueAt?`Due ${D(t.dueAt)}`:`Not graded yet`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsxs)(`p`,{className:v(`text-sm font-semibold tabular-nums`,z(n)),children:[t.score==null?`–`:g(t.score),` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`/ `,g(t.maxGrade)]})]}),n!=null&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[g(n),`%`]})]})]}),n!=null&&(0,R.jsx)(j,{value:n,className:`mt-3`,tone:n>=85?`success`:`primary`}),t.feedback&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-lg bg-muted/60 px-3.5 py-2.5 text-sm`,children:[(0,R.jsx)(`p`,{className:`mb-0.5 text-xs font-medium text-muted-foreground`,children:`Feedback`}),t.feedback]})]},t.activityId)})}),(0,R.jsxs)(f,{className:`p-5 text-center lg:sticky lg:top-32`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Course total`}),(0,R.jsx)(P,{value:n.percentage??0,size:120,stroke:9,className:`mx-auto mt-4 text-primary`,label:(0,R.jsx)(`span`,{className:`text-2xl font-semibold`,children:n.percentage==null?`–`:`${g(n.percentage)}%`})}),(0,R.jsxs)(`p`,{className:`mt-4 text-sm tabular-nums`,children:[g(n.total),` of `,g(n.max),` points`]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Based on graded work so far.`}),n.percentage!=null&&(0,R.jsx)(i,{variant:n.percentage>=85?`success`:n.percentage>=60?`info`:`warning`,className:`mt-3`,children:n.percentage>=85?`Excellent work`:n.percentage>=60?`On track`:`Needs attention`})]})]})}function U(){let{course:e,can:t}=I();T(`Grades · ${e.title}`);let{data:n,isLoading:r,error:i,refetch:a}=_({queryKey:[`grades`,e.id],queryFn:()=>C.get(`/courses/${e.id}/grades`)});return(0,R.jsx)(c,{size:`wide`,children:i?(0,R.jsx)(N,{error:i,onRetry:()=>a()}):r||!n?(0,R.jsx)(M,{className:`h-96`}):n.kind===`gradebook`?(0,R.jsx)(V,{book:n.gradebook,courseId:e.id,courseSlug:e.slug,editable:t(`grades:edit`)}):(0,R.jsx)(`div`,{className:`mx-auto max-w-5xl`,children:(0,R.jsx)(H,{grades:n.grades,courseSlug:e.slug})})})}export{U as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ft as e,Rt as t,_ as n,a as r,g as i,h as a,t as o}from"./index-B29bTBiJ.js";import{D as s,H as c,T as l,_ as u,dt as d,g as f,m as p,r as m,ut as h}from"./hooks-BBARn-DA.js";import{c as g,n as _,t as v}from"./misc-DvgDEI3I.js";var y={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};y.node;var b=c(y),x={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};x.node;var S=c(x),C=d();function w(){m(`Notifications`);let{data:c,isLoading:d,error:y,refetch:x}=n(),w=h(),T=e(),E=t({mutationFn:e=>p.post(`/notifications/read`,e?{ids:e}:{}),onSuccess:()=>w.invalidateQueries({queryKey:[`notifications`]})});return(0,C.jsxs)(i,{size:`narrow`,children:[(0,C.jsx)(r,{title:`Notifications`,description:`Grades, announcements and replies from your courses.`,actions:!!c?.unreadCount&&(0,C.jsxs)(f,{variant:`outline`,onClick:()=>E.mutate(void 0),loading:E.isPending,children:[(0,C.jsx)(S,{}),` Mark all as read`]})}),y?(0,C.jsx)(_,{error:y,onRetry:()=>x()}):d?(0,C.jsx)(g,{className:`h-96`}):c.items.length===0?(0,C.jsx)(v,{icon:b,title:`No notifications`,description:`You'll see updates from your courses here.`}):(0,C.jsx)(o,{className:`divide-y overflow-hidden`,children:c.items.map(e=>(0,C.jsxs)(`button`,{onClick:()=>{e.readAt||E.mutate([e.id]),e.link&&T(e.link)},className:u(`flex w-full gap-4 px-5 py-4 text-left transition-colors hover:bg-accent/40`,!e.readAt&&`bg-primary/[0.03]`),children:[(0,C.jsx)(a,{type:e.type}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:u(`block text-sm`,!e.readAt&&`font-semibold`),children:e.title}),e.body&&(0,C.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:e.body}),(0,C.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,title:l(e.createdAt),children:s(e.createdAt)})]}),!e.readAt&&(0,C.jsx)(`span`,{className:`mt-1.5 size-2.5 shrink-0 rounded-full bg-primary`,"aria-label":`Unread`})]},e.id))})]})}export{w as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,Ct as t,D as n,E as r,H as i,O as a,Q as o,R as s,Rt as c,S as l,T as u,U as d,V as f,at as p,et as ee,f as m,g as te,j as ne,k as h,l as g,m as _,q as re,t as v,tt as y,u as b,z as x}from"./index-B29bTBiJ.js";import{D as S,H as C,U as ie,dt as w,ft as T,g as E,h as D,m as O,mt as k,r as ae,s as oe,u as A,ut as se}from"./hooks-BBARn-DA.js";import{t as ce}from"./ban-D3Vsxg_g.js";import{t as j}from"./ellipsis-c2POIN-Y.js";import{T as M,a as N,c as P,n as F,s as I,t as L}from"./misc-DvgDEI3I.js";import{a as R,r as z}from"./context-BLVW7NB7.js";var B={name:`user-minus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};B.node;var V=C(B),H=k(T(),1),U=w(),W={teacher:`violet`,assistant:`info`,student:`neutral`};function le({open:e,onOpenChange:t,courseId:i,onDone:o}){let[s,l]=(0,H.useState)(``),[d,f]=(0,H.useState)(`student`),p=c({mutationFn:()=>O.post(`/courses/${i}/participants`,{emails:s.split(/[\s,;]+/).filter(Boolean),role:d}),onSuccess:e=>{e.added&&M.success(`Enrolled ${e.added} ${e.added===1?`person`:`people`}`),e.alreadyEnrolled.length&&M.info(`Already enrolled: ${e.alreadyEnrolled.join(`, `)}`),e.notFound.length&&M.warning(`No account found for: ${e.notFound.join(`, `)}`),l(``),o(),t(!1)},onError:e=>M.error(D(e))});return(0,U.jsx)(u,{open:e,onOpenChange:t,children:(0,U.jsx)(n,{children:(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p.mutate()},children:[(0,U.jsx)(h,{icon:(0,U.jsx)(y,{className:`size-5`}),title:`Enrol people`,description:`Add people who already have an account on this site.`}),(0,U.jsxs)(r,{className:`space-y-4`,children:[(0,U.jsx)(g,{label:`Email addresses`,hint:`Separate with commas, spaces or new lines.`,children:e=>(0,U.jsx)(_,{...e,rows:5,autoFocus:!0,value:s,onChange:e=>l(e.target.value),placeholder:`ada@school.edu, grace@school.edu`})}),(0,U.jsx)(g,{label:`Role`,children:e=>(0,U.jsxs)(m,{...e,value:d,onChange:e=>f(e.target.value),children:[(0,U.jsx)(`option`,{value:`student`,children:`Student`}),(0,U.jsx)(`option`,{value:`assistant`,children:`Teaching assistant`}),(0,U.jsx)(`option`,{value:`teacher`,children:`Teacher`})]})})]}),(0,U.jsxs)(a,{children:[(0,U.jsx)(E,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsx)(E,{type:`submit`,loading:p.isPending,disabled:!s.trim(),children:`Enrol`})]})]})})})}function G(){let{course:n,can:r}=z();ae(`Participants · ${n.title}`);let a=oe(),u=se(),m=R(),h=o(),g=r(`course:manageParticipants`),[_,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(`all`),[k,B]=(0,H.useState)(!1),G=[`participants`,n.id],{data:K,isLoading:ue,error:q,refetch:J}=ie({queryKey:G,queryFn:()=>O.get(`/courses/${n.id}/participants`)}),Y=()=>Promise.all([u.invalidateQueries({queryKey:G}),m(n.slug)]),X=c({mutationFn:({id:e,body:t})=>O.patch(`/courses/${n.id}/participants/${e}`,t),onSuccess:Y,onError:e=>M.error(D(e))}),de=c({mutationFn:e=>O.delete(`/courses/${n.id}/participants/${e}`),onSuccess:async()=>{await Y(),M.success(`Removed from the course`)},onError:e=>M.error(D(e))}),Z=(0,H.useMemo)(()=>{let e=_.trim().toLowerCase();return(K??[]).filter(t=>(w===`all`||t.role===w)&&(!e||t.user.name.toLowerCase().includes(e)||t.user.email?.toLowerCase().includes(e)))},[K,_,w]),Q=e=>(K??[]).filter(t=>t.role===e).length,$=!!K?.some(e=>e.user.email);return(0,U.jsxs)(te,{children:[(0,U.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,U.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,U.jsx)(p,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(b,{value:_,onChange:e=>C(e.target.value),placeholder:`Search participants`,className:`pl-9`,"aria-label":`Search participants`})]}),(0,U.jsx)(I,{value:w,onChange:T,options:[{value:`all`,label:`Everyone`,count:K?.length},{value:`teacher`,label:`Teachers`,count:Q(`teacher`)+Q(`assistant`)},{value:`student`,label:`Students`,count:Q(`student`)}]}),g&&(0,U.jsxs)(E,{className:`sm:ml-auto`,onClick:()=>B(!0),children:[(0,U.jsx)(y,{}),` Enrol people`]})]}),q?(0,U.jsx)(F,{error:q,onRetry:()=>J()}):ue?(0,U.jsx)(P,{className:`h-96`}):Z.length===0?(0,U.jsx)(L,{icon:ee,title:`No participants found`}):(0,U.jsx)(v,{className:`overflow-hidden`,children:(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{className:`border-b bg-muted/40 text-left text-xs font-medium text-muted-foreground`,children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,U.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Role`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium md:table-cell`,children:`Progress`}),$&&(0,U.jsx)(`th`,{className:`hidden px-3 py-3 font-medium whitespace-nowrap lg:table-cell`,children:`Last access`}),g&&(0,U.jsx)(`th`,{className:`w-12 px-3 py-3`})]})}),(0,U.jsx)(`tbody`,{className:`divide-y`,children:Z.map(n=>(0,U.jsxs)(`tr`,{className:`transition-colors hover:bg-accent/30`,children:[(0,U.jsx)(`td`,{className:`px-5 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(ne,{user:n.user,size:`sm`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`p`,{className:`truncate font-medium`,children:[n.user.name,n.user.id===a?.id&&(0,U.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`(you)`})]}),n.user.email&&(0,U.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.user.email})]})]})}),(0,U.jsx)(`td`,{className:`px-3 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(l,{variant:W[n.role],children:A[n.role]}),n.status===`suspended`&&(0,U.jsx)(l,{variant:`danger`,children:`Suspended`})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 md:table-cell`,children:n.progress==null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`–`}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(N,{value:n.progress,className:`w-24`,tone:n.progress===100?`success`:`primary`}),(0,U.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[n.progress,`%`]})]})}),$&&(0,U.jsx)(`td`,{className:`hidden px-3 py-3 whitespace-nowrap text-muted-foreground lg:table-cell`,children:n.lastAccessAt?S(n.lastAccessAt):`Never`}),g&&(0,U.jsx)(`td`,{className:`px-3 py-3 text-right`,children:n.user.id!==a?.id&&(0,U.jsxs)(s,{children:[(0,U.jsx)(re,{asChild:!0,children:(0,U.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${n.user.name}`,children:(0,U.jsx)(j,{})})}),(0,U.jsxs)(e,{children:[(0,U.jsx)(i,{children:`Role`}),[`student`,`assistant`,`teacher`].map(e=>(0,U.jsx)(x,{checked:n.role===e,onSelect:()=>X.mutate({id:n.enrolmentId,body:{role:e}}),children:A[e]},e)),(0,U.jsx)(d,{}),(0,U.jsxs)(f,{onSelect:()=>X.mutate({id:n.enrolmentId,body:{status:n.status===`active`?`suspended`:`active`}}),children:[n.status===`active`?(0,U.jsx)(ce,{}):(0,U.jsx)(t,{}),n.status===`active`?`Suspend enrolment`:`Reactivate enrolment`]}),(0,U.jsxs)(f,{destructive:!0,onSelect:async()=>{await h({title:`Remove ${n.user.name}?`,description:`They lose access to the course. Their grades are kept and come back if they re-enrol.`,confirmLabel:`Remove`,destructive:!0})&&de.mutate(n.enrolmentId)},children:[(0,U.jsx)(V,{}),` Remove from course`]})]})]})})]},n.enrolmentId))})]})})}),(0,U.jsx)(le,{open:k,onOpenChange:B,courseId:n.id,onDone:Y})]})}export{G as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as e,Rt as t,S as n,a as r,c as i,g as a,it as o,j as s,l as c,m as l,n as u,rt as d,st as f,t as p,u as m}from"./index-B29bTBiJ.js";import{H as h,d as g,dt as _,ft as v,g as y,h as b,l as x,m as S,mt as C,r as w,s as T,w as E}from"./hooks-BBARn-DA.js";import{t as D}from"./key-round-B_KI-brR.js";import{T as O}from"./misc-DvgDEI3I.js";var k={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};k.node;var A=h(k),j={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};j.node;var M=h(j),N=C(v(),1),P=_();function F(){w(`Profile`);let h=T(),_=x(),{theme:v,setTheme:C}=e(),k=(0,N.useRef)(null),[j,F]=(0,N.useState)(h.name),[I,L]=(0,N.useState)(h.bio??``),[R,z]=(0,N.useState)({currentPassword:``,newPassword:``}),B=t({mutationFn:e=>S.patch(`/auth/me`,e),onSuccess:e=>{_(e),O.success(`Profile updated`)},onError:e=>O.error(b(e))}),V=t({mutationFn:()=>S.post(`/auth/me/password`,R),onSuccess:()=>{z({currentPassword:``,newPassword:``}),O.success(`Password changed. Other devices have been signed out.`)},onError:e=>O.error(b(e))}),H=async e=>{try{let t=await S.upload(e,{context:`avatar`});B.mutate({avatarUrl:t.url})}catch(e){O.error(b(e))}};return(0,P.jsxs)(a,{size:`narrow`,children:[(0,P.jsx)(r,{title:`Profile`,description:`How you appear to teachers and classmates.`}),(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(p,{children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-5 p-6 sm:flex-row sm:items-center`,children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(s,{user:h,size:`xl`}),(0,P.jsx)(`button`,{onClick:()=>k.current?.click(),className:`absolute -right-1 -bottom-1 grid size-8 place-items-center rounded-full border bg-card shadow-sm transition-colors hover:bg-accent`,"aria-label":`Change photo`,children:(0,P.jsx)(A,{className:`size-4`})}),(0,P.jsx)(`input`,{ref:k,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&H(t),e.target.value=``}})]}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold`,children:h.name}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h.email}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(n,{variant:`default`,children:g[h.role]}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Member since `,E(h.createdAt,{year:`numeric`})]})]})]}),h.avatarUrl&&(0,P.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>B.mutate({avatarUrl:null}),children:[(0,P.jsx)(d,{}),` Remove photo`]})]}),(0,P.jsxs)(`form`,{className:`space-y-4 border-t p-6`,onSubmit:e=>{e.preventDefault(),B.mutate({name:j,bio:I.trim()||null})},children:[(0,P.jsx)(c,{label:`Full name`,children:e=>(0,P.jsx)(m,{...e,required:!0,value:j,onChange:e=>F(e.target.value)})}),(0,P.jsx)(c,{label:`About you`,optional:!0,hint:`A sentence or two for your classmates.`,children:e=>(0,P.jsx)(l,{...e,rows:3,value:I,onChange:e=>L(e.target.value)})}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(y,{type:`submit`,loading:B.isPending,disabled:j===h.name&&I===(h.bio??``),children:`Save profile`})})]})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Appearance`,description:`Choose how the site looks on this device.`}),(0,P.jsx)(`div`,{className:`px-5 pb-5`,children:(0,P.jsx)(i,{value:v,onChange:C,options:[{value:`light`,label:`Light`,icon:(0,P.jsx)(o,{className:`size-4`})},{value:`dark`,label:`Dark`,icon:(0,P.jsx)(f,{className:`size-4`})},{value:`system`,label:`System`,description:`Match your device`,icon:(0,P.jsx)(M,{className:`size-4`})}]})})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(u,{title:`Password`,description:`Changing your password signs you out on other devices.`,icon:(0,P.jsx)(D,{className:`size-4.5`})}),(0,P.jsxs)(`form`,{className:`grid gap-4 px-5 pb-5 sm:grid-cols-2`,onSubmit:e=>{e.preventDefault(),V.mutate()},children:[(0,P.jsx)(c,{label:`Current password`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`current-password`,value:R.currentPassword,onChange:e=>z({...R,currentPassword:e.target.value})})}),(0,P.jsx)(c,{label:`New password`,hint:`At least 8 characters.`,children:e=>(0,P.jsx)(m,{...e,type:`password`,autoComplete:`new-password`,value:R.newPassword,onChange:e=>z({...R,newPassword:e.target.value})})}),(0,P.jsx)(`div`,{className:`flex justify-end sm:col-span-2`,children:(0,P.jsx)(y,{type:`submit`,variant:`outline`,loading:V.isPending,disabled:R.newPassword.length<8,children:`Change password`})})]})]})]})]})}export{F as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,Ct as n,Lt as r,Q as i,Rt as a,S as o,g as s,kt as c,t as l,u,w as d,xt as f}from"./index-B29bTBiJ.js";import{E as p,H as m,T as h,U as g,V as ee,_,dt as v,ft as y,g as b,h as x,m as S,mt as C,n as w,p as te,r as T,ut as E}from"./hooks-BBARn-DA.js";import{n as D,t as O}from"./trophy-Cch2iF1m.js";import{t as k}from"./send-mxSHcdcD.js";import{T as A,c as j,n as ne,o as M}from"./misc-DvgDEI3I.js";import{n as N,t as P}from"./markdown-ykrkPMbn.js";import re from"./NotFoundPage-BRquC7-l.js";import{a as ie}from"./context-BLVW7NB7.js";var F={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};F.node;var ae=m(F),I={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};I.node;var L=m(I),R={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};R.node;var z=m(R),B={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};B.node;var V=m(B),H=C(y(),1),U=v(),W={single:`Choose one answer`,multiple:`Select all that apply`,truefalse:`True or false`,short:`Type your answer`,numeric:`Enter a number`};function G(e,t){return t?e.type===`short`||e.type===`numeric`?!!t.text?.trim():!!t.optionIds?.length:!1}function K({question:t,answer:r,onChange:i,review:a,disabled:o}){if(t.type===`short`||t.type===`numeric`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(u,{value:r?.text??``,disabled:o,inputMode:t.type===`numeric`?`decimal`:`text`,onChange:e=>i({text:e.target.value}),placeholder:t.type===`numeric`?`e.g. 42`:`Your answer`,className:`h-11 max-w-md text-[15px]`,"aria-label":`Your answer`}),a&&t.acceptedAnswers&&(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Accepted answer`,t.acceptedAnswers.length>1?`s`:``,`:`,` `,(0,U.jsxs)(`span`,{className:`font-medium text-foreground`,children:[t.acceptedAnswers.join(`, `),t.type===`numeric`&&t.tolerance?` (± ${t.tolerance})`:``]})]})]});let s=t.type===`multiple`,c=new Set(r?.optionIds??[]);return(0,U.jsx)(`div`,{className:`grid gap-2`,role:s?`group`:`radiogroup`,children:t.options.map((t,r)=>{let l=c.has(t.id),u=a?t.correct:void 0;return(0,U.jsxs)(`button`,{type:`button`,disabled:o,role:s?`checkbox`:`radio`,"aria-checked":l,onClick:()=>{if(s){let e=new Set(c);l?e.delete(t.id):e.add(t.id),i({optionIds:[...e]})}else i({optionIds:[t.id]})},className:_(`flex items-center gap-3 rounded-xl border bg-card px-4 py-3 text-left text-[15px] transition-all`,!o&&`hover:border-primary/50 hover:bg-primary/[0.02]`,l&&!a&&`border-primary bg-primary/[0.05] ring-3 ring-primary/10`,a&&u&&`border-emerald-500/50 bg-emerald-500/[0.07]`,a&&l&&!u&&`border-red-500/50 bg-red-500/[0.06]`,o&&`cursor-default`),children:[(0,U.jsx)(`span`,{className:_(`grid size-6 shrink-0 place-items-center border text-xs font-semibold text-muted-foreground`,s?`rounded-md`:`rounded-full`,l&&`border-primary bg-primary text-primary-foreground`,a&&u&&`border-emerald-600 bg-emerald-600 text-white`,a&&l&&!u&&`border-red-500 bg-red-500 text-white`),children:a&&u?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):a&&l?(0,U.jsx)(e,{className:`size-3.5`,strokeWidth:3}):l&&s?(0,U.jsx)(n,{className:`size-3.5`,strokeWidth:3}):String.fromCharCode(65+r)}),(0,U.jsx)(P,{source:t.text,className:`flex-1`}),a&&l&&(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Your answer`})]},t.id)})})}function q({deadline:e,onExpire:t}){let n=w(1e3),r=Math.max(0,new Date(e).getTime()-n),i=(0,H.useRef)(!1);(0,H.useEffect)(()=>{r===0&&!i.current&&(i.current=!0,t())},[r,t]);let a=Math.floor(r/6e4),o=Math.floor(r%6e4/1e3);return(0,U.jsxs)(`span`,{className:_(`flex items-center gap-1.5 rounded-lg px-2.5 py-1 font-mono text-sm font-semibold tabular-nums`,r<6e4?`bg-red-500/10 text-red-600`:r<3e5?`bg-amber-500/12 text-amber-600`:`bg-muted`),children:[(0,U.jsx)(D,{className:`size-4`}),String(a).padStart(2,`0`),`:`,String(o).padStart(2,`0`)]})}function J({attempt:e}){let n=e.maxScore?(e.score??0)/e.maxScore*100:0,r=e.passingPercent==null?null:n>=e.passingPercent,i=e.results?Object.values(e.results).filter(e=>e.correct).length:null;return(0,U.jsx)(l,{className:`mb-6 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-6 p-6 sm:flex-row`,children:[(0,U.jsx)(M,{value:n,size:112,stroke:9,className:_(r===!1?`text-red-500`:`text-primary`),label:(0,U.jsxs)(`span`,{className:`text-2xl font-semibold`,children:[Math.round(n),`%`]})}),(0,U.jsxs)(`div`,{className:`flex-1 text-center sm:text-left`,children:[(0,U.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-sm font-medium text-muted-foreground sm:justify-start`,children:[(0,U.jsx)(O,{className:`size-4`}),` Attempt `,e.attemptNumber,` · finished `,h(e.finishedAt)]}),(0,U.jsxs)(`p`,{className:`mt-1 text-3xl font-semibold tracking-tight tabular-nums`,children:[p(e.score),` `,(0,U.jsxs)(`span`,{className:`text-lg font-normal text-muted-foreground`,children:[`/ `,p(e.maxScore),` points`]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2 sm:justify-start`,children:[i!=null&&(0,U.jsxs)(o,{variant:`neutral`,children:[i,` of `,e.questions.length,` correct`]}),r!=null&&(0,U.jsx)(o,{variant:r?`success`:`danger`,children:r?`Passed`:`Below the ${e.passingPercent}% pass mark`}),!e.review&&(0,U.jsx)(o,{variant:`outline`,children:`Correct answers are hidden for now`})]})]}),(0,U.jsx)(b,{asChild:!0,variant:`outline`,children:(0,U.jsxs)(t,{to:d(e.course.slug,e.activityId),children:[(0,U.jsx)(c,{}),` Back to quiz`]})})]})})}function Y(){let{attemptId:e}=r(),n=E(),u=i(),m=ie(),h=[`attempt`,e],{data:v,isLoading:y,error:C,refetch:w}=g({queryKey:h,queryFn:()=>S.get(`/attempts/${e}`)});T(v?.quizTitle);let[D,O]=(0,H.useState)({}),[M,F]=(0,H.useState)(null),[I,R]=(0,H.useState)(`idle`),B=(0,H.useRef)(null),Y=(0,H.useRef)(D);Y.current=D,(0,H.useEffect)(()=>{v&&M!==v.id&&(O(v.answers),F(v.id))},[v,M]);let X=v?.status===`in_progress`,oe=(0,H.useCallback)(async()=>{B.current&&clearTimeout(B.current),B.current=null,R(`saving`);try{await S.put(`/attempts/${e}`,{answers:Y.current}),R(`saved`)}catch{R(`error`)}},[e]),se=(e,t)=>{O(n=>({...n,[e]:t})),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>void oe(),700)};(0,H.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]);let Z=a({mutationFn:()=>S.post(`/attempts/${e}/submit`,{answers:Y.current}),onSuccess:async e=>{B.current&&clearTimeout(B.current),n.setQueryData(h,e),window.scrollTo({top:0,behavior:`smooth`}),A.success(`Quiz submitted!`),await m(e.course.slug)},onError:e=>A.error(x(e))}),ce=(0,H.useCallback)(()=>{Z.isPending||(A.info(`Time's up! Submitting your answers.`),Z.mutate())},[Z]);if(y)return(0,U.jsxs)(s,{size:`narrow`,children:[(0,U.jsx)(j,{className:`mb-4 h-24`}),(0,U.jsx)(j,{className:`h-64`})]});if(C instanceof te&&C.status===404)return(0,U.jsx)(re,{});if(C||!v)return(0,U.jsx)(s,{children:(0,U.jsx)(ne,{error:C,onRetry:()=>w()})});let Q=v.questions.filter(e=>G(e,D[e.id])).length,$=async()=>{let e=v.questions.length-Q;await u({title:`Submit your answers?`,description:e?`You haven't answered ${e} question${e===1?``:`s`}. You can't change your answers after submitting.`:`You can't change your answers after submitting.`,confirmLabel:`Submit quiz`})&&Z.mutate()};return(0,U.jsxs)(`div`,{children:[X&&(0,U.jsx)(`div`,{className:`sticky top-14 z-20 border-b bg-background/90 backdrop-blur-lg`,children:(0,U.jsxs)(`div`,{className:`mx-auto flex max-w-5xl items-center gap-3 px-4 py-2.5 sm:px-6`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Q,` of `,v.questions.length,` answered`]})]}),(0,U.jsxs)(`span`,{className:`hidden items-center gap-1.5 text-xs text-muted-foreground sm:flex`,children:[I===`saving`?(0,U.jsx)(ee,{className:`size-3.5 animate-spin`}):I===`error`?(0,U.jsx)(L,{className:`size-3.5 text-destructive`}):(0,U.jsx)(z,{className:`size-3.5`}),I===`saving`?`Saving…`:I===`error`?`Not saved`:I===`saved`?`All changes saved`:`Autosave on`]}),v.deadlineAt&&(0,U.jsx)(q,{deadline:v.deadlineAt,onExpire:ce}),(0,U.jsxs)(b,{onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit`]})]})}),(0,U.jsxs)(s,{className:`max-w-5xl`,children:[!X&&(0,U.jsx)(J,{attempt:v}),X&&(0,U.jsxs)(`div`,{className:`mb-6`,children:[(0,U.jsxs)(t,{to:d(v.course.slug,v.activityId),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(c,{className:`size-4`}),` `,v.course.title]}),(0,U.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:v.quizTitle}),(0,U.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Attempt `,v.attemptNumber,`. Your answers save automatically as you go.`]})]}),(0,U.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_200px]`,children:[(0,U.jsxs)(`div`,{className:`space-y-4`,children:[v.questions.map((e,t)=>{let n=v.results?.[e.id];return(0,U.jsxs)(l,{id:`q-${e.id}`,className:_(`scroll-mt-32 p-5 sm:p-6`,n&&(n.correct?`border-emerald-500/40`:n.partial?`border-amber-500/40`:`border-red-500/30`)),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`p`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Question `,t+1,` · `,W[e.type]]}),n?(0,U.jsxs)(o,{variant:n.correct?`success`:n.partial?`warning`:`danger`,children:[n.correct?(0,U.jsx)(f,{}):(0,U.jsx)(ae,{}),p(n.points),` / `,p(n.maxPoints)]}):(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p(e.points),` point`,e.points===1?``:`s`]})]}),(0,U.jsx)(N,{source:e.prompt,className:`mb-4 text-[15px] font-medium [&_p]:my-0`}),(0,U.jsx)(K,{question:e,answer:D[e.id],onChange:t=>se(e.id,t),review:!!v.review,disabled:!X}),v.review&&e.explanation&&(0,U.jsxs)(`div`,{className:`mt-4 flex gap-3 rounded-lg bg-sky-500/[0.07] px-4 py-3 text-sm`,children:[(0,U.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-sky-600 dark:text-sky-400`}),(0,U.jsx)(P,{source:e.explanation})]})]},e.id)}),X&&(0,U.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,U.jsxs)(b,{size:`lg`,onClick:$,loading:Z.isPending,children:[(0,U.jsx)(k,{}),` Submit answers`]})})]}),(0,U.jsxs)(l,{className:`hidden p-4 lg:sticky lg:top-36 lg:block`,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs font-semibold text-muted-foreground`,children:`Questions`}),(0,U.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:v.questions.map((e,t)=>{let n=v.results?.[e.id],r=G(e,D[e.id]);return(0,U.jsx)(`a`,{href:`#q-${e.id}`,className:_(`grid aspect-square place-items-center rounded-md border text-xs font-semibold transition-colors hover:border-primary`,r&&!n&&`border-primary bg-primary text-primary-foreground`,n?.correct&&`border-emerald-600 bg-emerald-600 text-white`,n&&!n.correct&&n.partial&&`border-amber-500 bg-amber-500 text-white`,n&&!n.correct&&!n.partial&&`border-red-500 bg-red-500 text-white`),children:t+1},e.id)})})]})]})]})]})}export{Y as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,B as n,Ct as r,Lt as i,R as a,Rt as o,V as s,d as c,dt as l,f as u,g as d,kt as f,l as p,m,ot as h,q as g,rt as _,t as v,u as y,w as b}from"./index-B29bTBiJ.js";import{E as x,H as S,U as C,_ as w,dt as T,ft as E,g as D,h as O,i as k,m as A,mt as j,r as M,ut as N}from"./hooks-BBARn-DA.js";import{n as P,t as F}from"./arrow-up-LHDup5m4.js";import{t as I}from"./copy-Bxxjq6zo.js";import{T as L,c as R,n as z,t as B}from"./misc-DvgDEI3I.js";import{a as V}from"./context-BLVW7NB7.js";import{n as H}from"./frame-CGabirLa.js";var U={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};U.node;var W=S(U),G=j(E(),1),K=T(),q={single:`Multiple choice (one answer)`,multiple:`Multiple choice (several answers)`,truefalse:`True / false`,short:`Short answer`,numeric:`Numerical`},J=0,Y=()=>`k${Date.now().toString(36)}${J++}`,X=()=>Math.random().toString(36).slice(2,10);function Z(e){let t={key:Y(),id:``,type:e,prompt:``,points:e===`multiple`?2:1,options:[],acceptedAnswers:[],tolerance:null,explanation:null};return e===`single`||e===`multiple`?{...t,options:[0,1,2].map(e=>({id:X(),text:``,correct:e===0}))}:e===`truefalse`?{...t,options:[{id:X(),text:`True`,correct:!0},{id:X(),text:`False`,correct:!1}]}:t}function Q(e,t){let n=Z(t);if(t===e.type)return e;let r=(t===`single`||t===`multiple`)&&(e.type===`single`||e.type===`multiple`)&&e.options.length>=2;return{...n,key:e.key,id:e.id,prompt:e.prompt,explanation:e.explanation,options:r?e.options.map((n,r)=>({...n,correct:t===`single`?r===e.options.findIndex(e=>e.correct):n.correct})):n.options}}function ee({q:t,index:n,total:i,onChange:a,onMove:o,onDuplicate:s,onDelete:l}){let d=(e,n)=>{let r=t.options.map((r,i)=>t.type===`single`&&n.correct?i===e?{...r,...n}:{...r,correct:!1}:i===e?{...r,...n}:r);a({...t,options:r})};return(0,K.jsxs)(v,{className:`overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b bg-muted/30 px-5 py-3`,children:[(0,K.jsx)(`span`,{className:`grid size-7 place-items-center rounded-full bg-primary text-xs font-semibold text-primary-foreground`,children:n+1}),(0,K.jsx)(u,{value:t.type,onChange:e=>a(Q(t,e.target.value)),className:`h-8 w-auto min-w-56 text-[13px]`,"aria-label":`Question type`,children:Object.entries(q).map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`Points`,(0,K.jsx)(y,{type:`number`,min:0,step:`any`,value:t.points,onChange:e=>a({...t,points:Number(e.target.value)}),className:`h-8 w-20`})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(-1),disabled:n===0,"aria-label":`Move up`,children:(0,K.jsx)(F,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(1),disabled:n===i-1,"aria-label":`Move down`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:s,"aria-label":`Duplicate`,children:(0,K.jsx)(I,{})}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,onClick:l,"aria-label":`Delete question`,className:`hover:text-destructive`,children:(0,K.jsx)(_,{})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-5 p-5`,children:[(0,K.jsx)(p,{label:`Question`,children:e=>(0,K.jsx)(m,{...e,rows:2,value:t.prompt,onChange:e=>a({...t,prompt:e.target.value}),placeholder:"What would you like to ask? Markdown and `code` work here."})}),(t.type===`single`||t.type===`multiple`)&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(c,{children:[`Options`,` `,t.type===`multiple`?(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(tick every correct option)`}):(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(pick the correct one)`})]}),t.options.map((n,i)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(i,{correct:t.type===`single`||!n.correct}),className:w(`grid size-8 shrink-0 place-items-center border transition-colors`,t.type===`single`?`rounded-full`:`rounded-md`,n.correct?`border-emerald-600 bg-emerald-600 text-white`:`text-muted-foreground hover:border-emerald-600`),"aria-label":n.correct?`Correct answer`:`Mark as correct`,children:n.correct?(0,K.jsx)(r,{className:`size-4`,strokeWidth:3}):(0,K.jsx)(`span`,{className:`text-xs`,children:String.fromCharCode(65+i)})}),(0,K.jsx)(y,{value:n.text,onChange:e=>d(i,{text:e.target.value}),placeholder:`Option ${String.fromCharCode(65+i)}`}),(0,K.jsx)(D,{variant:`ghost`,size:`icon-sm`,disabled:t.options.length<=2,onClick:()=>a({...t,options:t.options.filter((e,t)=>t!==i)}),"aria-label":`Remove option`,children:(0,K.jsx)(e,{})})]},n.id)),t.options.length<10&&(0,K.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:()=>a({...t,options:[...t.options,{id:X(),text:``,correct:!1}]}),children:[(0,K.jsx)(h,{}),` Add option`]})]}),t.type===`truefalse`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(c,{children:`The statement is`}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:t.options.map((e,n)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a({...t,options:t.options.map((e,t)=>({...e,correct:t===n}))}),className:w(`flex h-10 items-center gap-2 rounded-lg border px-5 text-sm font-medium transition-colors`,e.correct?`border-emerald-600 bg-emerald-600 text-white`:`hover:border-emerald-600`),children:[e.correct&&(0,K.jsx)(r,{className:`size-4`}),e.text]},e.id))})]}),t.type===`short`&&(0,K.jsx)(p,{label:`Accepted answers`,hint:`One per line. Matching ignores case and extra spaces; use * as a wildcard (e.g. colou*r).`,children:e=>(0,K.jsx)(m,{...e,rows:3,value:(t.acceptedAnswers??[]).join(`
|
|
2
|
-
`),onChange:e=>a({...t,acceptedAnswers:e.target.value.split(`
|
|
3
|
-
`)}),className:`font-mono text-[13px]`})}),t.type===`numeric`&&(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,K.jsx)(p,{label:`Correct answer`,children:e=>(0,K.jsx)(y,{...e,inputMode:`decimal`,value:t.acceptedAnswers?.[0]??``,onChange:e=>a({...t,acceptedAnswers:[e.target.value]})})}),(0,K.jsx)(p,{label:`Allowed error (±)`,optional:!0,children:e=>(0,K.jsx)(y,{...e,type:`number`,min:0,step:`any`,value:t.tolerance??``,onChange:e=>a({...t,tolerance:e.target.value?Number(e.target.value):null})})})]}),(0,K.jsx)(p,{label:`Explanation`,optional:!0,hint:`Shown to students when they review their attempt.`,children:e=>(0,K.jsx)(m,{...e,rows:2,value:t.explanation??``,onChange:e=>a({...t,explanation:e.target.value||null})})})]})]})}function $({onAdd:e,variant:t=`outline`}){return(0,K.jsxs)(a,{children:[(0,K.jsx)(g,{asChild:!0,children:(0,K.jsxs)(D,{variant:t,children:[(0,K.jsx)(h,{}),` Add question`]})}),(0,K.jsx)(n,{align:`start`,className:`w-64`,children:Object.keys(q).map(t=>(0,K.jsx)(s,{onSelect:()=>e(t),children:q[t]},t))})]})}function te(){let{activityId:e}=i(),n=N(),r=V(),{data:a}=H(e);M(a?`Questions · ${a.title}`:`Questions`);let{data:s,isLoading:c,error:u,refetch:p}=C({queryKey:[`questions`,e],queryFn:()=>A.get(`/activities/${e}/questions`)}),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(``);(0,G.useEffect)(()=>{if(s&&m===null){let e=s.map(e=>({...e,key:Y()}));h(e),_(JSON.stringify(s))}},[s,m]);let v=e=>e.map(({key:e,...t})=>t),y=m!==null&&JSON.stringify(v(m))!==g;k(y);let S=o({mutationFn:()=>A.put(`/activities/${e}/questions`,{questions:v(m).map(e=>({...e,id:e.id||void 0,acceptedAnswers:(e.acceptedAnswers??[]).map(e=>e.trim()).filter(Boolean)}))}),onSuccess:async t=>{L.success(`Questions saved`),h(t.map(e=>({...e,key:Y()}))),_(JSON.stringify(t)),n.setQueryData([`questions`,e],t),await r(a?.course.slug)},onError:e=>L.error(O(e),{duration:8e3})}),w=(m??[]).reduce((e,t)=>e+(Number(t.points)||0),0),T=(e,t)=>h(n=>n.map((n,r)=>r===e?t:n)),E=(e,t)=>h(n=>{let r=[...n];return[r[e],r[e+t]]=[r[e+t],r[e]],r});return(0,K.jsxs)(d,{size:`narrow`,className:`pb-28`,children:[a&&(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(t,{to:b(a.course.slug,a.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(f,{className:`size-4`}),` `,a.title]}),(0,K.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Edit questions`}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Students see these questions when they attempt the quiz. Grading is automatic.`})]}),u?(0,K.jsx)(z,{error:u,onRetry:()=>p()}):c||!m?(0,K.jsx)(R,{className:`h-96`}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[m.length===0&&(0,K.jsx)(B,{icon:l,title:`No questions yet`,description:`Add your first question. Mix and match multiple choice, true/false, short answer and numerical questions.`,action:(0,K.jsx)($,{variant:`default`,onAdd:e=>h([Z(e)])})}),m.map((e,t)=>(0,K.jsx)(ee,{q:e,index:t,total:m.length,onChange:e=>T(t,e),onMove:e=>E(t,e),onDuplicate:()=>h(n=>{let r={...structuredClone(e),key:Y(),id:``,options:e.options.map(e=>({...e,id:X()}))};return[...n.slice(0,t+1),r,...n.slice(t+1)]}),onDelete:()=>h(e=>e.filter((e,n)=>n!==t))},e.key)),m.length>0&&(0,K.jsx)($,{onAdd:e=>h(t=>[...t,Z(e)])})]}),m&&(0,K.jsx)(`div`,{className:`fixed inset-x-0 bottom-0 z-30 border-t bg-card/90 backdrop-blur-lg lg:left-64`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-3 px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.length,` question`,m.length===1?``:`s`,` · `,x(w),` point`,w===1?``:`s`,y&&(0,K.jsx)(`span`,{className:`ml-2 font-medium text-amber-600 dark:text-amber-400`,children:`Unsaved changes`})]}),(0,K.jsxs)(D,{className:`ml-auto`,onClick:()=>S.mutate(),loading:S.isPending,disabled:!y,children:[(0,K.jsx)(W,{}),` Save questions`]})]})})]})}export{te as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Lt as t,Rt as n,S as r,St as i,bt as a,g as o,j as s,kt as c,l,m as u,r as d,t as f,u as p,w as m}from"./index-B29bTBiJ.js";import{D as h,E as g,H as _,T as ee,U as v,_ as y,dt as b,ft as x,g as S,h as C,m as w,mt as T,r as E,ut as D}from"./hooks-BBARn-DA.js";import{T as O,c as k,n as A,s as j,t as M}from"./misc-DvgDEI3I.js";import{n as te}from"./markdown-ykrkPMbn.js";import{n as N}from"./frame-CGabirLa.js";var P={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};P.node;var F=_(P),I=T(x(),1),L=b();function R(e){return e.needsGrading?{label:`Needs grading`,variant:`warning`}:e.grade?.score==null?{label:`Not submitted`,variant:`neutral`}:{label:`${g(e.grade.score)} / ${g(e.grade.maxGrade)}`,variant:`success`}}function z(){let{activityId:_}=t(),b=D(),{data:x}=N(_);E(x?`Submissions · ${x.title}`:`Submissions`);let T=[`submissions`,_],{data:P,isLoading:z,error:B,refetch:V}=v({queryKey:T,queryFn:()=>w.get(`/activities/${_}/submissions`)}),[H,U]=(0,I.useState)(`needs`),[W,G]=(0,I.useState)(null),[K,q]=(0,I.useState)(``),[J,Y]=(0,I.useState)(``),X=(0,I.useMemo)(()=>(P??[]).filter(e=>H===`needs`?e.needsGrading:H===`graded`?e.grade?.score!=null&&!e.needsGrading:H!==`missing`||!e.submission),[P,H]);(0,I.useEffect)(()=>{P&&P.length&&!P.some(e=>e.needsGrading)&&H===`needs`&&U(`all`)},[P,H]),(0,I.useEffect)(()=>{!W&&X[0]&&G(X[0].user.id)},[X,W]);let Z=P?.find(e=>e.user.id===W)??null;(0,I.useEffect)(()=>{q(Z?.grade?.score==null?``:String(Z.grade.score)),Y(Z?.grade?.feedback??``)},[Z?.user.id,Z?.grade?.score,Z?.grade?.feedback]);let Q=n({mutationFn:()=>w.put(`/activities/${_}/grades/${Z.user.id}`,{score:K===``?null:Number(K),feedback:J.trim()||null}),onSuccess:async()=>{O.success(`Saved grade for ${Z.user.name}`);let e=(P??[]).filter(e=>e.needsGrading&&e.user.id!==Z.user.id);await Promise.all([b.invalidateQueries({queryKey:T}),b.invalidateQueries({queryKey:[`activity`,_]}),b.invalidateQueries({queryKey:[`dashboard`]})]),e[0]&&G(e[0].user.id)},onError:e=>O.error(C(e))}),$=e=>(P??[]).filter(t=>e===`needs`?t.needsGrading:e===`graded`?t.grade?.score!=null&&!t.needsGrading:e!==`missing`||!t.submission).length;return(0,L.jsxs)(o,{size:`wide`,children:[x&&(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsxs)(e,{to:m(x.course.slug,x.id),className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,L.jsx)(c,{className:`size-4`}),` `,x.title]}),(0,L.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight`,children:`Grade submissions`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[x.course.title,` · out of `,g(x.maxGrade),` points`]})]}),B?(0,L.jsx)(A,{error:B,onRetry:()=>V()}):z||!P?(0,L.jsx)(k,{className:`h-[480px]`}):P.length===0?(0,L.jsx)(M,{icon:F,title:`No students yet`,description:`Students enrolled in this course will appear here.`}):(0,L.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,L.jsxs)(f,{className:`overflow-hidden lg:sticky lg:top-20`,children:[(0,L.jsx)(`div`,{className:`border-b p-3`,children:(0,L.jsx)(j,{value:H,onChange:e=>{U(e),G(null)},className:`w-full`,options:[{value:`needs`,label:`To grade`,count:$(`needs`)},{value:`graded`,label:`Graded`,count:$(`graded`)},{value:`missing`,label:`Missing`,count:$(`missing`)},{value:`all`,label:`All`}]})}),(0,L.jsxs)(`div`,{className:`ck-scrollbar max-h-[65vh] divide-y overflow-y-auto`,children:[X.length===0&&(0,L.jsx)(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Nothing here. 🎉`}),X.map(e=>{let t=R(e);return(0,L.jsxs)(`button`,{onClick:()=>G(e.user.id),className:y(`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/50`,W===e.user.id&&`bg-primary/[0.06]`),children:[(0,L.jsx)(s,{user:e.user,size:`sm`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.user.name}),(0,L.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.submission?`Submitted ${h(e.submission.submittedAt)}`:`No submission`})]}),(0,L.jsx)(r,{variant:t.variant,children:t.label}),(0,L.jsx)(i,{className:`size-4 text-muted-foreground/50`})]},e.user.id)})]})]}),Z?(0,L.jsxs)(`div`,{className:`space-y-5`,children:[(0,L.jsxs)(f,{className:`p-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(s,{user:Z.user,size:`lg`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`truncate font-semibold`,children:Z.user.name}),(0,L.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:Z.user.email})]}),Z.submission&&(0,L.jsxs)(`div`,{className:`shrink-0 text-right text-sm`,children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Submitted`}),(0,L.jsx)(`p`,{className:`font-medium`,children:ee(Z.submission.submittedAt)})]}),Z.submission?.late&&(0,L.jsx)(r,{variant:`warning`,children:`Late`})]}),(0,L.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[!Z.submission&&(0,L.jsx)(`p`,{className:`rounded-lg bg-muted/60 p-4 text-sm text-muted-foreground`,children:`This student hasn't submitted anything yet. You can still record a grade.`}),Z.submission?.text&&(0,L.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-5`,children:(0,L.jsx)(te,{source:Z.submission.text,className:`prose-sm`})}),Z.submission&&Z.submission.files.length>0&&(0,L.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:Z.submission.files.map(e=>(0,L.jsx)(d,{file:e},e.id))})]})]}),(0,L.jsx)(f,{className:`p-6`,children:(0,L.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Q.mutate()},children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,L.jsx)(a,{className:`size-4 text-primary`}),` Grade and feedback`]}),(0,L.jsx)(l,{label:`Score (out of ${g(x?.maxGrade??0)})`,className:`sm:w-56`,children:e=>(0,L.jsx)(p,{...e,type:`number`,step:`any`,min:0,max:x?.maxGrade??void 0,value:K,onChange:e=>q(e.target.value)})}),(0,L.jsx)(l,{label:`Feedback for the student`,optional:!0,children:e=>(0,L.jsx)(u,{...e,rows:5,value:J,onChange:e=>Y(e.target.value),placeholder:`What went well? What could be better?`})}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[Z.grade?.gradedAt?(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last graded `,h(Z.grade.gradedAt),Z.grade.gradedBy&&` by ${Z.grade.gradedBy.name}`]}):(0,L.jsx)(`span`,{}),(0,L.jsx)(S,{type:`submit`,loading:Q.isPending,disabled:K===``,children:`Save grade`})]})]})})]}):(0,L.jsx)(M,{icon:a,title:`Select a student`,description:`Pick someone from the list to review their work.`})]})]})}export{z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e}from"./hooks-BBARn-DA.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e,At as t,C as n,Ct as r,F as i,Ot as a,Rt as o,S as s,St as c,T as l,Tt as u,_t as d,g as f,kt as p,v as m,w as h,xt as g}from"./index-B29bTBiJ.js";import{H as _,M as v,U as y,_ as b,dt as x,ft as S,g as C,h as w,m as T,mt as E,x as D}from"./hooks-BBARn-DA.js";import{n as O,t as k}from"./ActivityEditor-BVSZUV8l.js";import{t as A}from"./pencil-p0GQmIMo.js";import{T as j,a as M}from"./misc-DvgDEI3I.js";import{a as N,i as P,t as F}from"./context-BLVW7NB7.js";var I={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};I.node;var L=_(I),R=E(S(),1),z=x();function B(e){return y({queryKey:[`activity`,e],queryFn:()=>T.get(`/activities/${e}`),enabled:!!e})}function V({course:e,currentId:r,onNavigate:a}){let o=F(e).filter(e=>e.visible&&e.completion!==`none`),s=o.filter(e=>e.completed).length;return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`border-b p-4`,children:[(0,z.jsxs)(t,{to:`/courses/${e.slug}`,onClick:a,className:`flex items-center gap-2.5 font-semibold hover:text-primary`,children:[(0,z.jsx)(`span`,{className:`size-3 shrink-0 rounded`,style:i(e.coverColor)}),(0,z.jsx)(`span`,{className:`truncate text-sm`,children:e.title})]}),e.progress!=null&&(0,z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,z.jsx)(M,{value:e.progress,tone:e.progress===100?`success`:`primary`}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s,` of `,o.length,` complete`]})]})]}),(0,z.jsx)(`nav`,{className:`ck-scrollbar flex-1 overflow-y-auto p-2`,children:e.sections.map((i,o)=>(0,z.jsxs)(`div`,{className:`mb-2`,children:[(0,z.jsxs)(`p`,{className:`px-2.5 pt-2 pb-1 text-[11px] font-semibold tracking-wider text-muted-foreground uppercase`,children:[o+1,`. `,i.title]}),i.activities.map(i=>{let o=i.id===r;return(0,z.jsxs)(t,{to:h(e.slug,i.id),onClick:a,className:b(`flex items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,o&&`bg-primary/10 font-medium text-primary hover:bg-primary/10 hover:text-primary`,!i.visible&&`opacity-60`),children:[e.myRole===`student`&&i.completion!==`none`?i.completed?(0,z.jsx)(g,{className:`size-4 shrink-0 text-success`}):(0,z.jsx)(O,{className:`size-4 shrink-0 opacity-40`}):(()=>{let e=n[i.type].icon;return(0,z.jsx)(e,{className:`size-4 shrink-0`})})(),(0,z.jsx)(`span`,{className:`truncate`,children:i.title})]},i.id)})]},i.id))})]})}function H({activity:e}){let t=N(),n=o({mutationFn:()=>e.completed?T.delete(`/activities/${e.id}/complete`):T.post(`/activities/${e.id}/complete`),onSuccess:async()=>{e.completed||j.success(`Nice work! Marked as done.`),await t(e.course.slug)},onError:e=>j.error(w(e))});return e.myRole!==`student`||e.completion!==`manual`?null:(0,z.jsxs)(C,{variant:e.completed?`outline`:`default`,onClick:()=>n.mutate(),loading:n.isPending,className:b(e.completed&&`border-success/40 text-success hover:bg-success/5`),children:[e.completed?(0,z.jsx)(g,{}):(0,z.jsx)(r,{}),e.completed?`Completed`:`Mark as done`]})}function U({activity:e}){if(!e.prev&&!e.next)return null;let n=(n,r)=>(0,z.jsxs)(t,{to:h(e.course.slug,n.id),className:b(`group flex items-center gap-3 rounded-xl border bg-card p-4 transition-all hover:border-primary/40 hover:shadow-md`,r===`next`&&`flex-row-reverse text-right`),children:[r===`prev`?(0,z.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}):(0,z.jsx)(a,{className:`size-4 shrink-0 text-muted-foreground group-hover:text-primary`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r===`prev`?`Previous`:`Next up`}),(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium group-hover:text-primary`,children:n.title})]})]});return(0,z.jsxs)(`div`,{className:`mt-10 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`div`,{children:e.prev&&n(e.prev,`prev`)}),(0,z.jsx)(`div`,{children:e.next&&n(e.next,`next`)})]})}function W({activity:e,actions:t}){let r=e.myRole===`student`;return(0,z.jsxs)(`div`,{className:`mb-7 flex flex-col gap-4 sm:flex-row sm:items-start`,children:[(0,z.jsx)(m,{type:e.type,size:`lg`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n[e.type].label,e.sectionTitle&&` · ${e.sectionTitle}`]}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-2xl font-semibold tracking-tight text-balance sm:text-[28px]`,children:e.title}),(0,z.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[e.dueAt&&(0,z.jsxs)(s,{variant:r&&v(e.dueAt)&&!e.completed?`danger`:`neutral`,children:[(0,z.jsx)(u,{}),` `,D(e.dueAt,!r||e.completed)]}),e.maxGrade!=null&&(0,z.jsxs)(s,{variant:`neutral`,children:[e.maxGrade,` points`]}),e.meta&&e.type!==`assignment`&&(0,z.jsx)(s,{variant:`neutral`,children:e.meta}),!e.visible&&(0,z.jsxs)(s,{variant:`warning`,children:[(0,z.jsx)(d,{}),` Hidden from students`]}),r&&e.completed&&(0,z.jsxs)(s,{variant:`success`,children:[(0,z.jsx)(g,{}),` Completed`]})]})]}),t&&(0,z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:t})]})}function G({activity:n,children:r,actions:a}){let{data:o}=P(n.course.slug),[s,u]=(0,R.useState)(!1),[d,p]=(0,R.useState)(!1),m=n.capabilities.includes(`course:manageContent`);return(0,z.jsxs)(`div`,{className:`flex`,children:[o&&(0,z.jsx)(`aside`,{className:`sticky top-14 hidden h-[calc(100dvh-3.5rem)] w-72 shrink-0 border-r bg-sidebar/50 xl:block`,children:(0,z.jsx)(V,{course:o,currentId:n.id})}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsxs)(f,{size:`default`,className:`max-w-5xl`,children:[(0,z.jsxs)(`nav`,{className:`mb-5 flex items-center gap-1.5 text-[13px] text-muted-foreground`,children:[o&&(0,z.jsx)(C,{variant:`ghost`,size:`icon-xs`,className:`mr-1 xl:hidden`,onClick:()=>u(!0),"aria-label":`Course outline`,children:(0,z.jsx)(L,{})}),(0,z.jsxs)(t,{to:`/courses/${n.course.slug}`,className:`flex min-w-0 items-center gap-1.5 hover:text-foreground`,children:[(0,z.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-[3px]`,style:i(n.course.coverColor)}),(0,z.jsx)(`span`,{className:`truncate`,children:n.course.title})]}),(0,z.jsx)(c,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate text-foreground`,children:n.title})]}),(0,z.jsx)(W,{activity:n,actions:(0,z.jsxs)(z.Fragment,{children:[a,m&&(0,z.jsxs)(C,{variant:`outline`,onClick:()=>p(!0),children:[(0,z.jsx)(A,{}),` Edit`]}),(0,z.jsx)(H,{activity:n})]})}),r,(0,z.jsx)(U,{activity:n})]})}),o&&(0,z.jsx)(l,{open:s,onOpenChange:u,children:(0,z.jsx)(e,{className:`w-80 bg-card`,children:(0,z.jsx)(V,{course:o,currentId:n.id,onNavigate:()=>u(!1)})})}),o&&d&&(0,z.jsx)(k,{course:o,open:d,onOpenChange:p,activityId:n.id})]})}export{B as n,G as t};
|