coursekit-lms 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/dist/cli/index.js +8 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/server/index.js +8 -4
- package/dist/server/index.js.map +1 -1
- package/dist/types/server/config.d.ts +9 -9
- package/dist/types/server/context.d.ts +1 -1
- package/dist/types/server/db/index.d.ts +2 -4
- package/dist/types/server/db/types.d.ts +4 -0
- package/dist/types/server/index.d.ts +10 -4
- package/dist/types/server/seed/demo.d.ts +3 -3
- package/dist/types/server/services/access.d.ts +1 -1
- package/dist/types/server/services/courses.d.ts +1 -1
- package/dist/types/server/services/notify.d.ts +1 -1
- package/dist/types/server/services/progress.d.ts +1 -1
- package/dist/types/server/services/quiz.d.ts +1 -1
- package/dist/types/server/services/settings.d.ts +1 -1
- package/dist/types/server/services/users.d.ts +5 -5
- package/dist/web/assets/{ActivityEditor-LKK0d5Mb.js → ActivityEditor-BVSZUV8l.js} +1 -1
- package/dist/web/assets/{ActivityPage-BhRtXLwW.js → ActivityPage-DPmSV_mU.js} +1 -1
- package/dist/web/assets/{AdminCoursesPage-BT9AQTuZ.js → AdminCoursesPage-uaSHNtzf.js} +1 -1
- package/dist/web/assets/{AdminLayout-ChXLxrl_.js → AdminLayout-DqoShZGn.js} +1 -1
- package/dist/web/assets/{AdminOverviewPage-BGsUzMXN.js → AdminOverviewPage-DnTrdGbr.js} +1 -1
- package/dist/web/assets/{AdminSettingsPage-B4ZeIbVO.js → AdminSettingsPage-B82cX8xU.js} +1 -1
- package/dist/web/assets/{AdminUsersPage-BmBSnct8.js → AdminUsersPage-3d2F9AEl.js} +1 -1
- package/dist/web/assets/{AnnouncementsPage-KJUA3o7v.js → AnnouncementsPage-BKW30k0Z.js} +1 -1
- package/dist/web/assets/{CalendarPage-DQdBEQN-.js → CalendarPage-CLRWyTNT.js} +1 -1
- package/dist/web/assets/{CatalogPage-CIFyefBY.js → CatalogPage-BiMgSSBR.js} +1 -1
- package/dist/web/assets/{CourseContentPage-CZEP3VMH.js → CourseContentPage-BIDH0UbG.js} +1 -1
- package/dist/web/assets/{CourseLayout-CwpWuS7V.js → CourseLayout-ql01LEmj.js} +1 -1
- package/dist/web/assets/{CourseSettingsPage-DwEIXO2s.js → CourseSettingsPage-CReoPqOa.js} +1 -1
- package/dist/web/assets/{CreateCoursePage-BDfIRStx.js → CreateCoursePage-DFCHlq5M.js} +1 -1
- package/dist/web/assets/{DiscussionPage-Dyt0qgUe.js → DiscussionPage-CWwVpFQV.js} +1 -1
- package/dist/web/assets/{GradesPage-Brj-Wqu1.js → GradesPage-Bu5vphcG.js} +1 -1
- package/dist/web/assets/{MyCoursesPage-GCdSHlYs.js → MyCoursesPage-Dd-Oaygv.js} +1 -1
- package/dist/web/assets/{NotFoundPage-CJIpDg1F.js → NotFoundPage-BRquC7-l.js} +1 -1
- package/dist/web/assets/{NotificationsPage-Y3shIm5z.js → NotificationsPage-LJvqb6Dj.js} +1 -1
- package/dist/web/assets/{ParticipantsPage-OHnKj_8Z.js → ParticipantsPage-wFxiphna.js} +1 -1
- package/dist/web/assets/{ProfilePage-Dgj-HYPS.js → ProfilePage-CzfhacAX.js} +1 -1
- package/dist/web/assets/{QuizAttemptPage-CiW3E3K0.js → QuizAttemptPage-CEAV6wAL.js} +1 -1
- package/dist/web/assets/{QuizEditorPage-bT0jpSFE.js → QuizEditorPage-DS_czQVM.js} +1 -1
- package/dist/web/assets/{SubmissionsPage-DXZGSqup.js → SubmissionsPage-CQjcx09G.js} +1 -1
- package/dist/web/assets/{context-B5ZaAO90.js → context-BLVW7NB7.js} +1 -1
- package/dist/web/assets/{frame-BjgJqbS9.js → frame-CGabirLa.js} +1 -1
- package/dist/web/assets/{index-DkBZ18Ts.js → index-B29bTBiJ.js} +2 -2
- package/dist/web/assets/{markdown-C1oaAmMK.js → markdown-ykrkPMbn.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +8 -5
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export interface CoursekitOptions {
|
|
2
2
|
/** `sqlite://./data/coursekit.db` (default), `sqlite::memory:` or a `postgres://` URL. */
|
|
3
|
-
databaseUrl?: string;
|
|
3
|
+
databaseUrl?: string | undefined;
|
|
4
4
|
/** Folder for uploaded files and the default SQLite database. Defaults to `./data`. */
|
|
5
|
-
dataDir?: string;
|
|
6
|
-
port?: number;
|
|
7
|
-
host?: string;
|
|
5
|
+
dataDir?: string | undefined;
|
|
6
|
+
port?: number | undefined;
|
|
7
|
+
host?: string | undefined;
|
|
8
8
|
/** Public URL of the site. An https URL turns on secure cookies. */
|
|
9
|
-
publicUrl?: string;
|
|
9
|
+
publicUrl?: string | undefined;
|
|
10
10
|
/** Maximum upload size in megabytes. Defaults to 50. */
|
|
11
|
-
maxUploadMb?: number;
|
|
11
|
+
maxUploadMb?: number | undefined;
|
|
12
12
|
/** Folder with the built web UI. `false` serves the API only. */
|
|
13
|
-
webDir?: string | false;
|
|
13
|
+
webDir?: string | false | undefined;
|
|
14
14
|
/** Run pending database migrations on startup. Defaults to true. */
|
|
15
|
-
migrate?: boolean;
|
|
15
|
+
migrate?: boolean | undefined;
|
|
16
16
|
/** Log each request to the console. */
|
|
17
|
-
logRequests?: boolean;
|
|
17
|
+
logRequests?: boolean | undefined;
|
|
18
18
|
}
|
|
19
19
|
export interface ResolvedConfig {
|
|
20
20
|
databaseUrl: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
2
|
import type { ResolvedConfig } from './config.js';
|
|
3
|
-
import type { DB, DatabaseKind } from './db/
|
|
3
|
+
import type { DB, DatabaseKind } from './db/types.js';
|
|
4
4
|
import type { SessionRow, UserRow } from './db/schema.js';
|
|
5
5
|
import type { EventBus } from './lib/events.js';
|
|
6
6
|
import type { FileStorage } from './lib/storage.js';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Kysely } from 'kysely';
|
|
2
1
|
import { type Migration, type MigrationResult } from 'kysely/migration';
|
|
3
|
-
import type {
|
|
4
|
-
export type DB
|
|
5
|
-
export type DatabaseKind = 'sqlite' | 'postgres';
|
|
2
|
+
import type { DB, DatabaseKind } from './types.js';
|
|
3
|
+
export type { DB, DatabaseKind } from './types.js';
|
|
6
4
|
/** Migrations are registered in code so they survive bundling. Append new ones; never edit old ones. */
|
|
7
5
|
export declare const migrations: Record<string, Migration>;
|
|
8
6
|
export declare function createDatabase(url: string): Promise<{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" preserve="true" />
|
|
1
2
|
/**
|
|
2
3
|
* Coursekit: an open-source learning management system for Node.js.
|
|
3
4
|
*
|
|
@@ -13,15 +14,15 @@ import type { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
|
13
14
|
import type { Hono } from 'hono';
|
|
14
15
|
import { type CoursekitOptions, type ResolvedConfig } from './config.js';
|
|
15
16
|
import type { AppEnv } from './context.js';
|
|
16
|
-
import {
|
|
17
|
-
import type {
|
|
17
|
+
import type { DB, DatabaseKind } from './db/types.js';
|
|
18
|
+
import type { User } from '../shared/types.js';
|
|
18
19
|
import { EventBus } from './lib/events.js';
|
|
19
20
|
import { type FileStorage } from './lib/storage.js';
|
|
20
21
|
import { type SeedDemoOptions, type SeedDemoResult } from './seed/demo.js';
|
|
21
22
|
import { type CreateUserInput } from './services/users.js';
|
|
22
23
|
export interface CreateCoursekitOptions extends CoursekitOptions {
|
|
23
24
|
/** Custom file storage (S3, R2, ...). Defaults to `<dataDir>/uploads` on disk. */
|
|
24
|
-
storage?: FileStorage;
|
|
25
|
+
storage?: FileStorage | undefined;
|
|
25
26
|
}
|
|
26
27
|
export interface Coursekit {
|
|
27
28
|
/** The Hono app. Mount it in another Hono app with `app.route('/', lms.app)`. */
|
|
@@ -43,7 +44,8 @@ export interface Coursekit {
|
|
|
43
44
|
url: string;
|
|
44
45
|
}>;
|
|
45
46
|
migrate(): Promise<void>;
|
|
46
|
-
|
|
47
|
+
/** Creates an account. Returns the public user (never the password hash). */
|
|
48
|
+
createUser(input: CreateUserInput): Promise<User>;
|
|
47
49
|
seedDemo(options?: SeedDemoOptions): Promise<SeedDemoResult>;
|
|
48
50
|
close(): Promise<void>;
|
|
49
51
|
}
|
|
@@ -54,5 +56,9 @@ export { EventBus, type CoursekitEvents, type EventName } from './lib/events.js'
|
|
|
54
56
|
export { createLocalStorage, type FileStorage } from './lib/storage.js';
|
|
55
57
|
export { activityTypes, type ActivityTypeDefinition } from './services/activity-types.js';
|
|
56
58
|
export type { Database } from './db/schema.js';
|
|
59
|
+
export type { DB, DatabaseKind } from './db/types.js';
|
|
60
|
+
export type { AppDeps, AppEnv } from './context.js';
|
|
61
|
+
export type { CreateUserInput } from './services/users.js';
|
|
62
|
+
export type { SeedDemoOptions, SeedDemoResult } from './seed/demo.js';
|
|
57
63
|
export type * from '../shared/types.js';
|
|
58
64
|
export { COURSE_CAPABILITIES, ROLE_CAPABILITIES, getCourseCapabilities, type CourseCapability } from '../shared/permissions.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AppDeps } from '../context.js';
|
|
2
2
|
import type { UserRow } from '../db/schema.js';
|
|
3
3
|
export interface SeedDemoOptions {
|
|
4
|
-
/**
|
|
5
|
-
admin?: UserRow;
|
|
4
|
+
/** An existing administrator for the demo. If omitted, the first admin is used (or one is created). */
|
|
5
|
+
admin?: Pick<UserRow, 'id'> | undefined;
|
|
6
6
|
/** Password for all demo accounts. Defaults to a random one (admins can still use "Log in as"). */
|
|
7
|
-
password?: string;
|
|
7
|
+
password?: string | undefined;
|
|
8
8
|
}
|
|
9
9
|
export interface SeedDemoResult {
|
|
10
10
|
created: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CourseCapability } from '../../shared/permissions.js';
|
|
2
2
|
import type { CourseRole } from '../../shared/types.js';
|
|
3
|
-
import type { DB } from '../db/
|
|
3
|
+
import type { DB } from '../db/types.js';
|
|
4
4
|
import type { ActivityRow, CourseRow, EnrolmentRow, UserRow } from '../db/schema.js';
|
|
5
5
|
export interface CourseAccess {
|
|
6
6
|
course: CourseRow;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CourseSummary } from '../../shared/types.js';
|
|
2
|
-
import type { DB } from '../db/
|
|
2
|
+
import type { DB } from '../db/types.js';
|
|
3
3
|
import type { CourseRow, UserRow } from '../db/schema.js';
|
|
4
4
|
/** Builds catalog/dashboard cards for a list of courses, as seen by `user`. */
|
|
5
5
|
export declare function summarizeCourses(db: DB, user: UserRow | null, courses: CourseRow[]): Promise<CourseSummary[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppDeps } from '../context.js';
|
|
2
|
-
import type { DB } from '../db/
|
|
2
|
+
import type { DB } from '../db/types.js';
|
|
3
3
|
import type { ActivityRow } from '../db/schema.js';
|
|
4
4
|
/** Progress (0-100) of one user in several courses. */
|
|
5
5
|
export declare function progressByCourse(db: DB, userId: string, courseIds: string[]): Promise<Map<string, number>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AttemptAnswer, Question, QuestionResult, QuizAttempt, QuizSettings } from '../../shared/types.js';
|
|
2
2
|
import type { AppDeps } from '../context.js';
|
|
3
|
-
import type { DB } from '../db/
|
|
3
|
+
import type { DB } from '../db/types.js';
|
|
4
4
|
import type { ActivityRow, CourseRow, QuestionRow, QuizAttemptRow } from '../db/schema.js';
|
|
5
5
|
export interface StoredOption {
|
|
6
6
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SiteSettings } from '../../shared/types.js';
|
|
2
|
-
import type { DB } from '../db/
|
|
2
|
+
import type { DB } from '../db/types.js';
|
|
3
3
|
export declare const DEFAULT_SITE_SETTINGS: SiteSettings;
|
|
4
4
|
export declare function getSiteSettings(db: DB): Promise<SiteSettings>;
|
|
5
5
|
export declare function updateSiteSettings(db: DB, patch: Partial<SiteSettings>): Promise<SiteSettings>;
|
|
@@ -4,12 +4,12 @@ import type { UserRow } from '../db/schema.js';
|
|
|
4
4
|
export interface CreateUserInput {
|
|
5
5
|
name: string;
|
|
6
6
|
email: string;
|
|
7
|
-
password?: string | null;
|
|
7
|
+
password?: string | null | undefined;
|
|
8
8
|
/** Pre-computed hash, e.g. when seeding many users with the same password. */
|
|
9
|
-
passwordHash?: string | null;
|
|
10
|
-
role?: SiteRole;
|
|
11
|
-
bio?: string | null;
|
|
12
|
-
avatarUrl?: string | null;
|
|
9
|
+
passwordHash?: string | null | undefined;
|
|
10
|
+
role?: SiteRole | undefined;
|
|
11
|
+
bio?: string | null | undefined;
|
|
12
|
+
avatarUrl?: string | null | undefined;
|
|
13
13
|
}
|
|
14
14
|
export declare function normalizeEmail(email: string): string;
|
|
15
15
|
export declare function createUser(deps: Pick<AppDeps, 'db' | 'events'>, input: CreateUserInput): Promise<UserRow>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{F as e,H as t,U as n,dt as r,ft as i,g as a,h as o,k as s,m as c,mt as l}from"./hooks-BBARn-DA.js";import{T as u,i as d}from"./misc-DvgDEI3I.js";import{r as f}from"./markdown-
|
|
1
|
+
import{F as e,H as t,U as n,dt as r,ft as i,g as a,h as o,k as s,m as c,mt as l}from"./hooks-BBARn-DA.js";import{T as u,i as d}from"./misc-DvgDEI3I.js";import{r as f}from"./markdown-ykrkPMbn.js";import{C as p,D as m,E as h,Ft as g,O as _,Rt as v,T as y,c as b,d as x,f as S,i as C,k as w,kt as T,l as E,p as D,r as O,s as k,u as A,v as j,w as M}from"./index-B29bTBiJ.js";import{a as N}from"./context-BLVW7NB7.js";import{a as P,i as F,n as I,t as L}from"./constants-DLDWTvvN.js";var R={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};R.node;var z=t(R),B=l(i(),1),V=r(),H={lesson:`When the lesson is opened`,resource:`When the resource is opened`,assignment:`When work is submitted`,quiz:`When an attempt is finished (and passed, if a pass mark is set)`,forum:`When the student posts`};function U(e){return{type:e,title:``,description:``,visible:!0,completion:F[e],dueAt:``,maxGrade:e===`assignment`?`100`:``,settings:structuredClone(P[e])}}function W({onPick:e}){return(0,V.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:I.map(t=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>e(t),className:`flex items-start gap-3 rounded-xl border bg-card p-4 text-left transition-all hover:-translate-y-px hover:border-primary/40 hover:shadow-md`,children:[(0,V.jsx)(j,{type:t,size:`lg`}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`block text-sm font-semibold`,children:p[t].label}),(0,V.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-muted-foreground`,children:L[t]})]})]},t))})}function G({form:e,setForm:t,course:n}){let r=(n,r)=>t({...e,[n]:r}),i=n=>t({...e,settings:{...e.settings,...n}}),[a,o]=(0,B.useState)(null);switch(e.type){case`lesson`:{let t=e.settings;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(E,{label:`Lesson content`,children:e=>(0,V.jsx)(f,{id:e.id,value:t.body,onChange:e=>i({body:e}),rows:14,placeholder:`# Lesson title
|
|
2
2
|
|
|
3
3
|
Write your lesson here…`})}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[1fr_180px]`,children:[(0,V.jsx)(E,{label:`Video URL`,optional:!0,hint:`YouTube, Vimeo or a direct .mp4 link.`,children:e=>(0,V.jsx)(A,{...e,value:t.videoUrl??``,onChange:e=>i({videoUrl:e.target.value||null}),placeholder:`https://www.youtube.com/watch?v=…`})}),(0,V.jsx)(E,{label:`Duration (minutes)`,optional:!0,children:e=>(0,V.jsx)(A,{...e,type:`number`,min:1,value:t.estimatedMinutes??``,onChange:e=>i({estimatedMinutes:e.target.value?Number(e.target.value):null})})})]})]})}case`resource`:{let r=e.settings;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(b,{columns:2,value:r.kind,onChange:e=>i({kind:e}),options:[{value:`link`,label:`Link`,description:`Point to a web page or document.`},{value:`file`,label:`File`,description:`Upload a PDF, slides, a dataset…`}]}),r.kind===`link`?(0,V.jsx)(E,{label:`URL`,children:e=>(0,V.jsx)(A,{...e,value:r.url??``,onChange:e=>i({url:e.target.value}),placeholder:`https://`})}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(x,{children:`File`}),r.fileId&&a?(0,V.jsx)(O,{file:a,onRemove:()=>{o(null),i({fileId:null})}}):r.fileId?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`A file is attached.`,` `,(0,V.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>i({fileId:null}),children:`Replace it`})]}):(0,V.jsx)(C,{context:`activity`,courseId:n.id,onUploaded:n=>{o(n),t({...e,title:e.title||n.name.replace(/\.[^.]+$/,``),settings:{...r,fileId:n.id}})}})]})]})}case`assignment`:{let t=e.settings,n=(e,n)=>{let r=n?[...new Set([...t.submissionTypes,e])]:t.submissionTypes.filter(t=>t!==e);r.length&&i({submissionTypes:r})};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)(E,{label:`Due date`,optional:!0,children:t=>(0,V.jsx)(A,{...t,type:`datetime-local`,value:e.dueAt,onChange:e=>r(`dueAt`,e.target.value)})}),(0,V.jsx)(E,{label:`Maximum points`,children:t=>(0,V.jsx)(A,{...t,type:`number`,min:0,value:e.maxGrade,onChange:e=>r(`maxGrade`,e.target.value)})})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(x,{children:`Students can submit`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-5`,children:[`text`,`file`].map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(k,{checked:t.submissionTypes.includes(e),onCheckedChange:t=>n(e,t===!0)}),e===`text`?`Online text`:`File uploads`]},e))})]}),t.submissionTypes.includes(`file`)&&(0,V.jsx)(E,{label:`Maximum files`,className:`sm:w-48`,children:e=>(0,V.jsx)(A,{...e,type:`number`,min:1,max:20,value:t.maxFiles,onChange:e=>i({maxFiles:Number(e.target.value)||1})})}),(0,V.jsx)(D,{label:`Accept late submissions`,description:`Students can still submit after the due date; late work is flagged.`,checked:t.allowLate,onCheckedChange:e=>i({allowLate:e})})]})}case`quiz`:{let t=e.settings;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsx)(E,{label:`Closes`,optional:!0,hint:`Students can't start attempts after this.`,children:t=>(0,V.jsx)(A,{...t,type:`datetime-local`,value:e.dueAt,onChange:e=>r(`dueAt`,e.target.value)})}),(0,V.jsx)(E,{label:`Time limit (minutes)`,optional:!0,children:e=>(0,V.jsx)(A,{...e,type:`number`,min:1,value:t.timeLimitMinutes??``,onChange:e=>i({timeLimitMinutes:e.target.value?Number(e.target.value):null}),placeholder:`No limit`})}),(0,V.jsx)(E,{label:`Attempts allowed`,children:e=>(0,V.jsxs)(S,{...e,value:t.attemptsAllowed,onChange:e=>i({attemptsAllowed:Number(e.target.value)}),children:[(0,V.jsx)(`option`,{value:0,children:`Unlimited`}),[1,2,3,4,5,10].map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})}),(0,V.jsx)(E,{label:`Grade to keep`,children:e=>(0,V.jsxs)(S,{...e,value:t.gradingMethod,onChange:e=>i({gradingMethod:e.target.value}),children:[(0,V.jsx)(`option`,{value:`highest`,children:`Highest attempt`}),(0,V.jsx)(`option`,{value:`last`,children:`Last attempt`}),(0,V.jsx)(`option`,{value:`average`,children:`Average of attempts`})]})}),(0,V.jsx)(E,{label:`Show correct answers`,children:e=>(0,V.jsxs)(S,{...e,value:t.reviewMode,onChange:e=>i({reviewMode:e.target.value}),children:[(0,V.jsx)(`option`,{value:`immediate`,children:`Right after each attempt`}),(0,V.jsx)(`option`,{value:`after_due`,children:`After the quiz closes`}),(0,V.jsx)(`option`,{value:`score_only`,children:`Never (score only)`})]})}),(0,V.jsx)(E,{label:`Pass mark (%)`,optional:!0,children:e=>(0,V.jsx)(A,{...e,type:`number`,min:0,max:100,value:t.passingPercent??``,onChange:e=>i({passingPercent:e.target.value?Number(e.target.value):null}),placeholder:`None`})})]}),(0,V.jsx)(D,{label:`Shuffle questions`,description:`Each attempt gets the questions in a random order.`,checked:t.shuffleQuestions,onCheckedChange:e=>i({shuffleQuestions:e})})]})}case`forum`:{let t=e.settings;return(0,V.jsx)(D,{label:`Students can start discussions`,description:`Turn off for a teacher-led forum where students only reply.`,checked:t.studentsCanStartDiscussions,onCheckedChange:e=>i({studentsCanStartDiscussions:e})})}}}function K({course:t,open:r,onOpenChange:i,sectionId:l,activityId:b}){let x=g(),C=N(),O=!!b,[k,P]=(0,B.useState)(null),{data:F,isLoading:I}=n({queryKey:[`activity`,b],queryFn:()=>c.get(`/activities/${b}`),enabled:r&&O});(0,B.useEffect)(()=>{r||P(null)},[r]),(0,B.useEffect)(()=>{r&&O&&F&&!k&&P({type:F.type,title:F.title,description:F.description,visible:F.visible,completion:F.completion,dueAt:e(F.dueAt),maxGrade:F.maxGrade==null?``:String(F.maxGrade),settings:F.settings})},[r,O,F,k]);let R=v({mutationFn:async()=>{if(!k)return null;let e={title:k.title,description:k.description,visible:k.visible,completion:k.completion,settings:k.settings,...k.type===`assignment`||k.type===`quiz`?{dueAt:s(k.dueAt)}:{},...k.type===`assignment`&&k.maxGrade!==``?{maxGrade:Number(k.maxGrade)}:{}};return O?(await c.patch(`/activities/${b}`,e),{id:b}):c.post(`/courses/${t.id}/activities`,{...e,type:k.type,sectionId:l})},onSuccess:async e=>{await C(t.slug),i(!1),!O&&e&&k?.type===`quiz`?(u.success(`Quiz created. Now add some questions.`),x(`${M(t.slug,e.id)}/questions`)):u.success(O?`Changes saved`:`${p[k.type].label} added`)},onError:e=>u.error(o(e))}),z=k?.type===`assignment`?`Instructions`:k?.type===`quiz`?`Introduction`:`Description`;return(0,V.jsx)(y,{open:r,onOpenChange:i,children:(0,V.jsx)(m,{size:k?`lg`:`md`,children:k?(0,V.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),R.mutate()},children:[(0,V.jsx)(w,{icon:(0,V.jsx)(j,{type:k.type,className:`size-10 bg-transparent`}),title:O?`Edit ${p[k.type].label.toLowerCase()}`:`New ${p[k.type].label.toLowerCase()}`,description:L[k.type]}),(0,V.jsxs)(h,{className:`space-y-5 pb-4`,children:[(0,V.jsx)(E,{label:`Title`,children:e=>(0,V.jsx)(A,{...e,autoFocus:!0,required:!0,value:k.title,onChange:e=>P({...k,title:e.target.value})})}),k.type!==`lesson`&&(0,V.jsx)(E,{label:z,optional:k.type!==`assignment`,children:e=>(0,V.jsx)(f,{id:e.id,value:k.description,onChange:e=>P({...k,description:e}),rows:k.type===`assignment`?8:4})}),(0,V.jsx)(G,{form:k,setForm:P,course:t}),(0,V.jsxs)(`div`,{className:`grid gap-4 border-t pt-5 sm:grid-cols-2`,children:[(0,V.jsx)(E,{label:`Completion tracking`,children:e=>(0,V.jsxs)(S,{...e,value:k.completion,onChange:e=>P({...k,completion:e.target.value}),children:[(0,V.jsx)(`option`,{value:`none`,children:`Don't track`}),(0,V.jsx)(`option`,{value:`manual`,children:`Students mark it as done`}),(0,V.jsx)(`option`,{value:`auto`,children:H[k.type]})]})}),(0,V.jsx)(`div`,{className:`sm:pt-6`,children:(0,V.jsx)(D,{label:`Visible to students`,checked:k.visible,onCheckedChange:e=>P({...k,visible:e})})})]})]}),(0,V.jsxs)(_,{className:`border-t`,children:[!O&&(0,V.jsxs)(a,{type:`button`,variant:`ghost`,className:`sm:mr-auto`,onClick:()=>P(null),children:[(0,V.jsx)(T,{}),` Change type`]}),(0,V.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,V.jsx)(a,{type:`submit`,loading:R.isPending,children:O?`Save changes`:k.type===`quiz`?`Create and add questions`:`Add ${p[k.type].label.toLowerCase()}`})]})]}):O?I?(0,V.jsx)(d,{}):(0,V.jsx)(w,{title:`Loading…`}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(w,{title:`Add an activity`,description:`Choose what you'd like to add to this section.`}),(0,V.jsx)(h,{className:`pb-6`,children:(0,V.jsx)(W,{onPick:e=>P(U(e))})})]})})})}export{z as n,K as t};
|
|
@@ -1 +1 @@
|
|
|
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-DkBZ18Ts.js";import{i as pe,n as I,r as L}from"./markdown-C1oaAmMK.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-CJIpDg1F.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-B5ZaAO90.js";import{n as ye,t as W}from"./frame-BjgJqbS9.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
|
+
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 +1 @@
|
|
|
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-
|
|
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 +1 @@
|
|
|
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-
|
|
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 +1 @@
|
|
|
1
|
-
import{D as e,H as t,U as n,_ as r,d as i,dt as a,ft as o,m as s,mt as c,r as l,w as u}from"./hooks-BBARn-DA.js";import{At as d,Et as f,F as p,S as m,ct as h,et as g,j as _,mt as v,n as y,nt as b,o as x,t as S}from"./index-
|
|
1
|
+
import{D as e,H as t,U as n,_ as r,d as i,dt as a,ft as o,m as s,mt as c,r as l,w as u}from"./hooks-BBARn-DA.js";import{At as d,Et as f,F as p,S as m,ct as h,et as g,j as _,mt as v,n as y,nt as b,o as x,t as S}from"./index-B29bTBiJ.js";import{c as C,n as w}from"./misc-DvgDEI3I.js";var T={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};T.node;var E=t(T),D=c(o(),1),O=a();function k(e){if(e<=4)return Math.max(1,e);let t=10**Math.floor(Math.log10(e)),n=[1,2,2.5,5,10].find(n=>n*t>=e/2)*t;return Math.ceil(e/n)*n}function A({data:e}){let[t,n]=(0,D.useState)(null),i=k(Math.max(0,...e.map(e=>e.count))),a=i<=4?Array.from({length:i+1},(e,t)=>t):[0,i/2,i],o=e.reduce((e,t)=>e+t.count,0),s=e=>u(`${e.date}T12:00:00Z`,{month:`short`,day:`numeric`});return(0,O.jsxs)(S,{children:[(0,O.jsx)(y,{title:`New sign-ups`,description:`Last 30 days · ${o} total`}),(0,O.jsxs)(`div`,{className:`px-5 pb-5`,children:[(0,O.jsxs)(`div`,{className:`relative flex h-48 gap-3`,children:[(0,O.jsx)(`div`,{className:`flex flex-col-reverse justify-between pb-6 text-right text-[11px] text-muted-foreground tabular-nums`,"aria-hidden":!0,children:a.map(e=>(0,O.jsx)(`span`,{className:`-translate-y-1/2 leading-none first:translate-y-1/2`,children:e},e))}),(0,O.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`absolute inset-x-0 top-0 bottom-6 flex flex-col-reverse justify-between`,"aria-hidden":!0,children:a.map(e=>(0,O.jsx)(`div`,{className:`h-px bg-border`},e))}),(0,O.jsx)(`div`,{className:`absolute inset-x-0 top-0 bottom-6 flex items-end gap-[2px]`,role:`img`,"aria-label":`Sign-ups per day for the last 30 days, ${o} in total`,children:e.map((e,a)=>(0,O.jsxs)(`button`,{type:`button`,className:`group relative flex h-full flex-1 items-end justify-center outline-none`,onPointerEnter:()=>n(a),onPointerLeave:()=>n(null),onFocus:()=>n(a),onBlur:()=>n(null),"aria-label":`${s(e)}: ${e.count} sign-up${e.count===1?``:`s`}`,children:[e.count>0&&(0,O.jsx)(`span`,{className:r(`w-[70%] max-w-6 rounded-t-[4px] bg-primary transition-[filter]`,t===a&&`brightness-110`),style:{height:`${e.count/i*100}%`}}),t===a&&(0,O.jsxs)(`span`,{className:`pointer-events-none absolute bottom-full z-10 mb-1.5 rounded-lg border bg-popover px-2.5 py-1.5 text-left whitespace-nowrap shadow-lg`,children:[(0,O.jsxs)(`span`,{className:`block text-sm font-semibold`,children:[e.count,` sign-up`,e.count===1?``:`s`]}),(0,O.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(e)})]})]},e.date))}),(0,O.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 flex justify-between text-[11px] text-muted-foreground`,"aria-hidden":!0,children:[(0,O.jsx)(`span`,{children:s(e[0])}),(0,O.jsx)(`span`,{children:s(e[Math.floor(e.length/2)])}),(0,O.jsx)(`span`,{children:s(e[e.length-1])})]})]})]}),(0,O.jsxs)(`table`,{className:`sr-only`,children:[(0,O.jsx)(`caption`,{children:`Sign-ups per day`}),(0,O.jsx)(`thead`,{children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{children:`Date`}),(0,O.jsx)(`th`,{children:`Sign-ups`})]})}),(0,O.jsx)(`tbody`,{children:e.map(e=>(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`td`,{children:s(e)}),(0,O.jsx)(`td`,{children:e.count})]},e.date))})]})]})]})}function j(){l(`Administration`);let{data:t,isLoading:r,error:a,refetch:o}=n({queryKey:[`admin`,`overview`],queryFn:()=>s.get(`/admin/overview`)});if(a)return(0,O.jsx)(w,{error:a,onRetry:()=>o()});if(r||!t)return(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(C,{className:`h-[104px]`},e))}),(0,O.jsx)(C,{className:`h-72`})]});let c=Math.max(1,...t.topCourses.map(e=>e.students));return(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,O.jsx)(x,{icon:g,label:`People`,value:t.counts.users.toLocaleString(),tone:`primary`}),(0,O.jsx)(x,{icon:f,label:`Courses`,value:t.counts.courses.toLocaleString(),tone:`sky`}),(0,O.jsx)(x,{icon:v,label:`Enrolments`,value:t.counts.enrolments.toLocaleString(),tone:`violet`}),(0,O.jsx)(x,{icon:b,label:`Submissions`,value:t.counts.submissions.toLocaleString(),hint:`${t.counts.posts.toLocaleString()} forum posts`,tone:`emerald`})]}),(0,O.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`,children:[(0,O.jsx)(A,{data:t.signups}),(0,O.jsxs)(S,{children:[(0,O.jsx)(y,{title:`Most popular courses`,description:`Active student enrolments`}),(0,O.jsxs)(`div`,{className:`space-y-3.5 px-5 pb-5`,children:[t.topCourses.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No courses yet.`}),t.topCourses.map(e=>(0,O.jsxs)(d,{to:`/courses/${e.slug}`,className:`group block`,children:[(0,O.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`size-2.5 shrink-0 rounded-[3px]`,style:p(e.coverColor)}),(0,O.jsx)(`span`,{className:`truncate font-medium group-hover:text-primary`,children:e.title}),(0,O.jsx)(`span`,{className:`ml-auto text-muted-foreground tabular-nums`,children:e.students})]}),(0,O.jsx)(`div`,{className:`h-2 rounded-r-[4px] bg-transparent`,children:(0,O.jsx)(`div`,{className:`h-2 rounded-r-[4px] bg-primary`,style:{width:`${Math.max(2,e.students/c*100)}%`}})})]},e.id))]})]})]}),(0,O.jsxs)(`div`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`,children:[(0,O.jsxs)(S,{children:[(0,O.jsx)(y,{title:`Newest people`,action:(0,O.jsx)(d,{to:`/admin/users`,className:`text-xs font-medium text-primary hover:underline`,children:`Manage users`})}),(0,O.jsx)(`div`,{className:`divide-y border-t`,children:t.recentUsers.map(t=>(0,O.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3`,children:[(0,O.jsx)(_,{user:t,size:`sm`}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium`,children:t.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:t.email})]}),(0,O.jsx)(m,{variant:t.role===`admin`?`violet`:t.role===`instructor`?`info`:`neutral`,children:i[t.role]}),(0,O.jsx)(`span`,{className:`hidden w-24 text-right text-xs text-muted-foreground sm:block`,children:e(t.createdAt)})]},t.id))})]}),(0,O.jsxs)(S,{children:[(0,O.jsx)(y,{title:`System`,icon:(0,O.jsx)(E,{className:`size-4.5`})}),(0,O.jsxs)(`dl`,{className:`space-y-3 px-5 pb-5 text-sm`,children:[[[`Version`,`Coursekit ${t.version}`],[`Database`,t.database],[`Activities`,t.counts.activities.toLocaleString()],[`Forum posts`,t.counts.posts.toLocaleString()]].map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,O.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,O.jsx)(`dd`,{className:`font-medium`,children:t})]},e)),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-muted/60 px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,O.jsx)(h,{className:`size-3.5`}),` Coursekit is open source. Contributions welcome!`]})]})]})]})]})}export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ct as e,Rt as t,l as n,m as r,mt as i,n as a,p as o,t as s,u as c}from"./index-
|
|
1
|
+
import{Ct as e,Rt as t,l as n,m as r,mt as i,n as a,p as o,t as s,u as c}from"./index-B29bTBiJ.js";import{U as l,_ as u,b as d,dt as f,ft as p,g as m,h,m as g,mt as _,r as v,ut as y,y as b}from"./hooks-BBARn-DA.js";import{T as x,c as S}from"./misc-DvgDEI3I.js";var C=_(p(),1),w=f(),T=[`#4f46e5`,`#2563eb`,`#0891b2`,`#059669`,`#16a34a`,`#d97706`,`#ea580c`,`#dc2626`,`#db2777`,`#9333ea`,`#0f172a`];function E(){v(`Site settings`);let f=y(),{data:p}=l({queryKey:[`admin`,`settings`],queryFn:()=>g.get(`/admin/settings`)}),[_,E]=(0,C.useState)(null);(0,C.useEffect)(()=>{p&&!_&&E(p)},[p,_]);let D=t({mutationFn:()=>g.put(`/admin/settings`,_),onSuccess:async e=>{E(e),x.success(`Site settings saved`),await f.invalidateQueries({queryKey:[`session`]}),await f.invalidateQueries({queryKey:[`admin`,`settings`]})},onError:e=>x.error(h(e))});if(!_)return(0,w.jsx)(S,{className:`h-96`});let O=JSON.stringify(_)!==JSON.stringify(p),k=/^#[0-9a-fA-F]{6}$/.test(_.brandColor);return(0,w.jsxs)(`form`,{className:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_340px]`,onSubmit:e=>{e.preventDefault(),D.mutate()},children:[(0,w.jsxs)(`div`,{className:`space-y-6`,children:[(0,w.jsxs)(s,{children:[(0,w.jsx)(a,{title:`Identity`,description:`Your site's name and messaging.`}),(0,w.jsxs)(`div`,{className:`space-y-4 px-5 pb-5`,children:[(0,w.jsx)(n,{label:`Site name`,children:e=>(0,w.jsx)(c,{...e,required:!0,value:_.name,onChange:e=>E({..._,name:e.target.value})})}),(0,w.jsx)(n,{label:`Tagline`,hint:`Shown on the sign-in page.`,children:e=>(0,w.jsx)(c,{...e,value:_.tagline,onChange:e=>E({..._,tagline:e.target.value})})}),(0,w.jsx)(n,{label:`Dashboard welcome message`,children:e=>(0,w.jsx)(r,{...e,rows:2,value:_.welcomeMessage,onChange:e=>E({..._,welcomeMessage:e.target.value})})})]})]}),(0,w.jsxs)(s,{children:[(0,w.jsx)(a,{title:`Brand colour`,description:`Used for buttons, links and highlights across the site.`}),(0,w.jsxs)(`div`,{className:`space-y-4 px-5 pb-5`,children:[(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(t=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>E({..._,brandColor:t}),className:u(`grid size-9 place-items-center rounded-full ring-offset-2 ring-offset-card transition-transform hover:scale-110`,_.brandColor.toLowerCase()===t&&`ring-2 ring-foreground`),style:{background:t},"aria-label":`Use ${t}`,children:_.brandColor.toLowerCase()===t&&(0,w.jsx)(e,{className:`size-4`,style:{color:d(t)},strokeWidth:3})},t))}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`input`,{type:`color`,value:k?_.brandColor:`#4f46e5`,onChange:e=>E({..._,brandColor:e.target.value}),className:`size-9 cursor-pointer rounded-lg border bg-card p-1`,"aria-label":`Custom colour`}),(0,w.jsx)(c,{value:_.brandColor,onChange:e=>E({..._,brandColor:e.target.value}),className:`w-32 font-mono`,"aria-label":`Hex colour`}),!k&&(0,w.jsx)(`span`,{className:`text-xs text-destructive`,children:`Use a 6-digit hex colour`})]}),k&&b(_.brandColor,`#ffffff`)<4.5&&(0,w.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-300`,children:[`This colour is light for text on white (`,b(_.brandColor,`#ffffff`).toFixed(1),`:1). Links and labels may be hard to read; a darker shade is more accessible.`]})]})]}),(0,w.jsxs)(s,{children:[(0,w.jsx)(a,{title:`Access`}),(0,w.jsx)(`div`,{className:`px-5 pb-5`,children:(0,w.jsx)(o,{label:`Allow self-registration`,description:`Anyone can create a student account from the sign-in page. Turn off to add people yourself.`,checked:_.allowSignup,onCheckedChange:e=>E({..._,allowSignup:e})})})]})]}),(0,w.jsxs)(`div`,{className:`space-y-4 lg:sticky lg:top-20`,children:[(0,w.jsxs)(s,{className:`overflow-hidden`,children:[(0,w.jsx)(`p`,{className:`border-b px-5 py-3 text-xs font-medium text-muted-foreground`,children:`Preview`}),(0,w.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,w.jsx)(`span`,{className:`grid size-8 place-items-center rounded-[10px] text-white`,style:{background:k?_.brandColor:void 0,color:k?d(_.brandColor):void 0},children:(0,w.jsx)(i,{className:`size-[18px]`})}),(0,w.jsx)(`span`,{className:`font-semibold`,children:_.name||`Your site`})]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_.tagline}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`rounded-lg px-4 py-2 text-sm font-medium`,style:{background:k?_.brandColor:void 0,color:k?d(_.brandColor):void 0},children:`Primary button`}),(0,w.jsx)(`span`,{className:`rounded-lg px-4 py-2 text-sm font-medium`,style:{color:k?_.brandColor:void 0,background:k?`${_.brandColor}1a`:void 0},children:`Soft`})]})]})]}),(0,w.jsx)(m,{type:`submit`,className:`w-full`,loading:D.isPending,disabled:!O||!k,children:`Save settings`})]})]})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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 +1 @@
|
|
|
1
|
-
import{Q as e,Rt as t,g as n,j as r,rt as i,t as a,u as o,ut as s}from"./index-
|
|
1
|
+
import{Q as e,Rt as t,g as n,j as r,rt as i,t as a,u as o,ut as s}from"./index-B29bTBiJ.js";import{D as c,T as l,U as u,dt as d,ft as f,g as p,h as m,m as h,mt as g,r as _,ut as v}from"./hooks-BBARn-DA.js";import{t as y}from"./send-mxSHcdcD.js";import{T as b,c as x,n as S,t as C}from"./misc-DvgDEI3I.js";import{n as w,r as T}from"./markdown-ykrkPMbn.js";import{r as E}from"./context-BLVW7NB7.js";var D=g(f(),1),O=d();function k(){let{course:d,can:f}=E();_(`Announcements · ${d.title}`);let g=v(),k=e(),[A,j]=(0,D.useState)(``),[M,N]=(0,D.useState)(``),P=[`announcements`,d.id],{data:F,isLoading:I,error:L,refetch:R}=u({queryKey:P,queryFn:()=>h.get(`/courses/${d.id}/announcements`)}),z=t({mutationFn:()=>h.post(`/courses/${d.id}/announcements`,{title:A,body:M}),onSuccess:async()=>{j(``),N(``),b.success(`Announcement posted. Everyone in the course has been notified.`),await g.invalidateQueries({queryKey:P})},onError:e=>b.error(m(e))}),B=t({mutationFn:e=>h.delete(`/courses/${d.id}/announcements/${e}`),onSuccess:()=>g.invalidateQueries({queryKey:P})});return(0,O.jsxs)(n,{size:`narrow`,children:[f(`announcement:post`)&&(0,O.jsx)(a,{className:`mb-8 p-5`,children:(0,O.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),z.mutate()},children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,O.jsx)(s,{className:`size-4 text-primary`}),` New announcement`]}),(0,O.jsx)(o,{value:A,onChange:e=>j(e.target.value),placeholder:`Title`,required:!0,"aria-label":`Announcement title`}),(0,O.jsx)(T,{value:M,onChange:N,rows:4,placeholder:`Write your message to the class…`}),(0,O.jsx)(`div`,{className:`flex justify-end`,children:(0,O.jsxs)(p,{type:`submit`,loading:z.isPending,disabled:!A.trim()||!M.trim(),children:[(0,O.jsx)(y,{}),` Post announcement`]})})]})}),L?(0,O.jsx)(S,{error:L,onRetry:()=>R()}):I?(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsx)(x,{className:`h-36`}),(0,O.jsx)(x,{className:`h-36`})]}):F.length===0?(0,O.jsx)(C,{icon:s,title:`No announcements yet`,description:`Course news from your teachers will show up here.`}):(0,O.jsx)(`ol`,{className:`relative space-y-6 border-l pl-6`,children:F.map(e=>(0,O.jsxs)(`li`,{className:`relative`,children:[(0,O.jsx)(`span`,{className:`absolute top-5 -left-[31px] size-2.5 rounded-full bg-primary ring-4 ring-background`}),(0,O.jsxs)(a,{className:`p-5`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(r,{user:e.author,size:`sm`}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:e.author.name}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,title:l(e.createdAt),children:c(e.createdAt)})]}),f(`announcement:post`)&&(0,O.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete announcement`,onClick:async()=>{await k({title:`Delete this announcement?`,confirmLabel:`Delete`,destructive:!0})&&B.mutate(e.id)},children:(0,O.jsx)(i,{})})]}),(0,O.jsx)(`h2`,{className:`mt-4 text-lg font-semibold tracking-tight`,children:e.title}),(0,O.jsx)(w,{source:e.body,className:`mt-2 prose-sm`})]})]},e.id))})]})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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 +1 @@
|
|
|
1
|
-
import{Q as e,U as t,_ as n,dt as r,f as i,ft as a,g as o,m as s,mt as c,r as l,s as u,t as d}from"./hooks-BBARn-DA.js";import{t as f}from"./chevron-left-D6IMQD6N.js";import{At as p,Mt as m,St as h,a as g,at as _,b as v,g as y,ot as b,u as x,vt as S,y as C}from"./index-
|
|
1
|
+
import{Q as e,U as t,_ as n,dt as r,f as i,ft as a,g as o,m as s,mt as c,r as l,s as u,t as d}from"./hooks-BBARn-DA.js";import{t as f}from"./chevron-left-D6IMQD6N.js";import{At as p,Mt as m,St as h,a as g,at as _,b as v,g as y,ot as b,u as x,vt as S,y as C}from"./index-B29bTBiJ.js";import{n as w,s as T,t as E}from"./misc-DvgDEI3I.js";var D=c(a(),1),O=r(),k=12;function A(){l(`Explore courses`);let r=u(),[a,c]=m(),A=a.get(`category`)??``,j=Number(a.get(`page`)??1),[M,N]=(0,D.useState)(a.get(`q`)??``),P=d(M.trim(),300);(0,D.useEffect)(()=>{c(e=>(P?e.set(`q`,P):e.delete(`q`),e.delete(`page`),e),{replace:!0})},[P,c]);let{data:F}=t({queryKey:[`categories`],queryFn:()=>s.get(`/categories`)}),{data:I,isLoading:L,error:R,refetch:z}=t({queryKey:[`catalog`,P,A,j],queryFn:()=>s.get(`/courses?${new URLSearchParams({...P?{q:P}:{},...A?{category:A}:{},page:String(j),pageSize:String(k)})}`),placeholderData:e}),B=e=>c(t=>(e?t.set(`category`,e):t.delete(`category`),t.delete(`page`),t)),V=e=>c(t=>(t.set(`page`,String(e)),t)),H=I?Math.max(1,Math.ceil(I.total/k)):1;return(0,O.jsxs)(y,{children:[(0,O.jsx)(g,{title:`Explore courses`,description:`Find your next course. Enrol in open courses instantly, or use an enrolment key from your teacher.`,actions:i(r?.role)&&(0,O.jsx)(o,{asChild:!0,children:(0,O.jsxs)(p,{to:`/courses/new`,children:[(0,O.jsx)(b,{}),` New course`]})})}),(0,O.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,O.jsxs)(`div`,{className:`relative lg:w-80`,children:[(0,O.jsx)(_,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,O.jsx)(x,{value:M,onChange:e=>N(e.target.value),placeholder:`Search by title or topic`,className:`h-10 pl-9`,"aria-label":`Search courses`})]}),(0,O.jsx)(T,{value:A,onChange:B,className:`lg:ml-auto`,options:[{value:``,label:`All`},...(F??[]).filter(e=>e.courseCount>0).map(e=>({value:e.id,label:e.name,count:e.courseCount}))]})]}),R?(0,O.jsx)(w,{error:R,onRetry:()=>z()}):L||!I?(0,O.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,children:Array.from({length:8},(e,t)=>(0,O.jsx)(v,{},t))}):I.items.length===0?(0,O.jsx)(E,{icon:S,title:P||A?`No courses match your search`:`No courses yet`,description:P||A?`Try a different keyword or category.`:`Published courses will appear here.`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:n(`grid gap-5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`),children:I.items.map(e=>(0,O.jsx)(C,{course:e,showProgress:e.myRole===`student`},e.id))}),H>1&&(0,O.jsxs)(`div`,{className:`mt-8 flex items-center justify-center gap-3`,children:[(0,O.jsxs)(o,{variant:`outline`,size:`sm`,disabled:j<=1,onClick:()=>V(j-1),children:[(0,O.jsx)(f,{}),` Previous`]}),(0,O.jsxs)(`span`,{className:`text-sm text-muted-foreground tabular-nums`,children:[`Page `,j,` of `,H]}),(0,O.jsxs)(o,{variant:`outline`,size:`sm`,disabled:j>=H,onClick:()=>V(j+1),children:[`Next `,(0,O.jsx)(h,{})]})]})]})]})}export{A as default};
|