Modules
Instructors
An instructor directory with invitations, derived stats, revenue by course and a profile page.
composables/useLearning.ts
View in the demo
An instructor stores status (active or invited), joinedAt (the invitation date while invited) and revenueShare. Students, rating, completion, revenue and payout are derived by instructorStats() from their courses.
Files
File | Role |
|---|---|
pages/learning/instructors/index.vue | The directory. |
pages/learning/instructors/[id].vue | The profile. |
composables/useLearning.ts | findInstructor, coursesOf, statsOf, saveInstructor, removeInstructor. |
composables/useInstructorForm.ts | The invite and edit form. |
composables/useInstructorTiles.ts | The five tiles of the profile. |
components/pages/learning/ | LearningInstructorCard, LearningInstructorInviteCard, LearningInstructorQuickView, LearningInstructorFormPanel, LearningInstructorCoursesCard, LearningInstructorRevenueCard, LearningInstructorReviewsCard, LearningInstructorAboutCard. |
Configuration
INSTRUCTOR_VIEWS
The views: all, active and invited.
const INSTRUCTOR_VIEWS: InstructorView[]
INSTRUCTOR_SORTS
The sorts of the directory.
const INSTRUCTOR_SORTS: InstructorSort[]
INSTRUCTOR_INVITE_DAYS
Days before an invitation expires.
const INSTRUCTOR_INVITE_DAYS: 7
INSTRUCTOR_DEFAULT_SHARE
The default revenue share.
const INSTRUCTOR_DEFAULT_SHARE: 0.7
Rules
Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.
instructorStats()
The derived stats.
instructorStats(instructor: { id: string; revenueShare: number }, courses: InstructorCourse[]): { courses: number; published: number; drafts: number; students: number; newThisMonth: number; reviews: number; rating: number; completion: number; revenue: number; payout: number;…Returns
coursespublisheddraftsstudentsnewThisMonthreviewsratingcompletionrevenuepayoutinvitationDaysLeft()
Days left on an invitation.
invitationDaysLeft(invitedAt: string, now: Date): number
instructorViewCounts()
The count of every view.
instructorViewCounts(statuses: InstructorView[]): Record<InstructorView, number>
How it works
- The directory has views, a sort menu and search above
LearningInstructorCards (aBaseStatTiles divided compactstrip) andLearningInstructorInviteCards (resend and cancel). Clicking a card opensLearningInstructorQuickView. - The profile shows the five tiles from
useInstructorTiles(), a coursesBaseDataTable, revenue by course as aBaseSegmentBarwith a legend, recent reviews and the facts. - An instructor with courses cannot be removed.