API reference
Learning
Courses, enrolments, students and instructors.
Everything in utils/ is a pure function: it takes data and returns data, with no Vue and no global state. Pass the current date as now so results are deterministic. Each file has its unit tests in tests/unit/.
courseLessonCount()
Lessons of a course.
courseLessonCount(course: Pick<Course, 'modules'>): number
courseMinutes()
Minutes of a course.
courseMinutes(course: Pick<Course, 'modules'>): number
courseHours()
Hours of a course.
courseHours(course: Pick<Course, 'modules'>): number
moduleMinutes()
Minutes of a module.
moduleMinutes(module: Pick<CourseModule, 'lessons'>): number
courseRating()
Average rating from the star counts.
courseRating(course: Pick<Course, 'ratingCounts'>): number
courseReviewCount()
Number of reviews.
courseReviewCount(course: Pick<Course, 'ratingCounts'>): number
courseCompletion()
Completion rate.
courseCompletion(course: Pick<Course, 'students' | 'completed'>): number
isLowCompletion()
Whether completion is below the threshold.
isLowCompletion(course: Pick<Course, 'students' | 'completed'>): boolean
courseRevenue()
Revenue of a course.
courseRevenue(course: Pick<Course, 'students' | 'price'>): number
platformCompletion()
Average completion of the platform.
platformCompletion(courses: Pick<Course, 'students' | 'completed'>[]): number
matchesCourseView()
Whether a course belongs to a view.
matchesCourseView(course: Pick<Course, 'status'>, view: CourseView): boolean
courseViewCounts()
The count of every course view.
courseViewCounts(courses: Pick<Course, 'status'>[]): Record<CourseView, number>
sortCourses()
Sorts courses by students, rating, revenue or date.
sortCourses(courses: T[], sort: CourseSort): T[]
daysBetween()
Whole days between two dates.
daysBetween(from: string | Date, to: string | Date): number
enrollmentProgress()
Progress of an enrolment.
enrollmentProgress(enrollment: Enrollment, course: CourseOutline): number
isEnrollmentComplete()
Whether an enrolment is complete.
isEnrollmentComplete(enrollment: Enrollment, course: CourseOutline): boolean
enrollmentNextLesson()
The next lesson to take.
enrollmentNextLesson(enrollment: Enrollment, course: CourseOutline): { lesson: CourseLesson; module: CourseModule; moduleIndex: number; } | undefinedenrollmentModulesDone()
Modules completed.
enrollmentModulesDone(enrollment: Enrollment, course: CourseOutline): number
studentStatus()
Active, at risk or completed.
studentStatus(student: Pick<Student, 'enrollments' | 'activity' | 'joinedAt'>, courses: CourseLookup, now: Date): StudentStatus
studentProgress()
Overall progress of a student.
studentProgress(student: Pick<Student, 'enrollments'>, courses: CourseLookup): { done: number; total: number; percent: number; }donetotalpercentstudentLastActive()
The last activity date.
studentLastActive(student: Pick<Student, 'activity' | 'joinedAt'>): string
studentDaysInactive()
Days without activity.
studentDaysInactive(student: Pick<Student, 'activity' | 'joinedAt'>, now: Date): number
studentCertificates()
Certificates earned.
studentCertificates(student: Pick<Student, 'enrollments'>, courses: CourseLookup): number
studentQuizAverage()
Average quiz score.
studentQuizAverage(student: Pick<Student, 'activity'>): number | undefined
studentWeeklyMinutes()
Study minutes per week.
studentWeeklyMinutes(student: Pick<Student, 'activity'>, now: Date, weeks: number): number[]
studentStudyMinutes()
Total study minutes.
studentStudyMinutes(student: Pick<Student, 'activity'>): number
studentStreak()
Consecutive days of study.
studentStreak(student: Pick<Student, 'activity'>, now: Date): number
studentSpend()
What a student paid.
studentSpend(student: Pick<Student, 'enrollments'>, courses: CourseLookup): number
matchesStudentView()
Whether a status belongs to a view.
matchesStudentView(status: StudentStatus, view: StudentView): boolean
studentViewCounts()
The count of every student view.
studentViewCounts(statuses: StudentStatus[]): Record<StudentView, number>
instructorStats()
Students, rating, completion, revenue and payout of an instructor.
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;…coursespublisheddraftsstudentsnewThisMonthreviewsratingcompletionrevenuepayoutinvitationDaysLeft()
Days before an invitation expires.
invitationDaysLeft(invitedAt: string, now: Date): number
matchesInstructorView()
Whether an instructor belongs to a view.
matchesInstructorView(status: InstructorView, view: InstructorView): boolean
instructorViewCounts()
The count of every instructor view.
instructorViewCounts(statuses: InstructorView[]): Record<InstructorView, number>