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.

utils/learning.ts
courseLessonCount(course: Pick<Course, 'modules'>): number

courseMinutes()

Minutes of a course.

utils/learning.ts
courseMinutes(course: Pick<Course, 'modules'>): number

courseHours()

Hours of a course.

utils/learning.ts
courseHours(course: Pick<Course, 'modules'>): number

moduleMinutes()

Minutes of a module.

utils/learning.ts
moduleMinutes(module: Pick<CourseModule, 'lessons'>): number

courseRating()

Average rating from the star counts.

utils/learning.ts
courseRating(course: Pick<Course, 'ratingCounts'>): number

courseReviewCount()

Number of reviews.

utils/learning.ts
courseReviewCount(course: Pick<Course, 'ratingCounts'>): number

courseCompletion()

Completion rate.

utils/learning.ts
courseCompletion(course: Pick<Course, 'students' | 'completed'>): number

isLowCompletion()

Whether completion is below the threshold.

utils/learning.ts
isLowCompletion(course: Pick<Course, 'students' | 'completed'>): boolean

courseRevenue()

Revenue of a course.

utils/learning.ts
courseRevenue(course: Pick<Course, 'students' | 'price'>): number

platformCompletion()

Average completion of the platform.

utils/learning.ts
platformCompletion(courses: Pick<Course, 'students' | 'completed'>[]): number

matchesCourseView()

Whether a course belongs to a view.

utils/learning.ts
matchesCourseView(course: Pick<Course, 'status'>, view: CourseView): boolean

courseViewCounts()

The count of every course view.

utils/learning.ts
courseViewCounts(courses: Pick<Course, 'status'>[]): Record<CourseView, number>

sortCourses()

Sorts courses by students, rating, revenue or date.

utils/learning.ts
sortCourses(courses: T[], sort: CourseSort): T[]

daysBetween()

Whole days between two dates.

utils/learning.ts
daysBetween(from: string | Date, to: string | Date): number

enrollmentProgress()

Progress of an enrolment.

utils/learning.ts
enrollmentProgress(enrollment: Enrollment, course: CourseOutline): number

isEnrollmentComplete()

Whether an enrolment is complete.

utils/learning.ts
isEnrollmentComplete(enrollment: Enrollment, course: CourseOutline): boolean

enrollmentNextLesson()

The next lesson to take.

utils/learning.ts
enrollmentNextLesson(enrollment: Enrollment, course: CourseOutline): { lesson: CourseLesson; module: CourseModule; moduleIndex: number; } | undefined

enrollmentModulesDone()

Modules completed.

utils/learning.ts
enrollmentModulesDone(enrollment: Enrollment, course: CourseOutline): number

studentStatus()

Active, at risk or completed.

utils/learning.ts
studentStatus(student: Pick<Student, 'enrollments' | 'activity' | 'joinedAt'>, courses: CourseLookup, now: Date): StudentStatus

studentProgress()

Overall progress of a student.

utils/learning.ts
studentProgress(student: Pick<Student, 'enrollments'>, courses: CourseLookup): { done: number; total: number; percent: number; }
Returnsdonetotalpercent

studentLastActive()

The last activity date.

utils/learning.ts
studentLastActive(student: Pick<Student, 'activity' | 'joinedAt'>): string

studentDaysInactive()

Days without activity.

utils/learning.ts
studentDaysInactive(student: Pick<Student, 'activity' | 'joinedAt'>, now: Date): number

studentCertificates()

Certificates earned.

utils/learning.ts
studentCertificates(student: Pick<Student, 'enrollments'>, courses: CourseLookup): number

studentQuizAverage()

Average quiz score.

utils/learning.ts
studentQuizAverage(student: Pick<Student, 'activity'>): number | undefined

studentWeeklyMinutes()

Study minutes per week.

utils/learning.ts
studentWeeklyMinutes(student: Pick<Student, 'activity'>, now: Date, weeks: number): number[]

studentStudyMinutes()

Total study minutes.

utils/learning.ts
studentStudyMinutes(student: Pick<Student, 'activity'>): number

studentStreak()

Consecutive days of study.

utils/learning.ts
studentStreak(student: Pick<Student, 'activity'>, now: Date): number

studentSpend()

What a student paid.

utils/learning.ts
studentSpend(student: Pick<Student, 'enrollments'>, courses: CourseLookup): number

matchesStudentView()

Whether a status belongs to a view.

utils/learning.ts
matchesStudentView(status: StudentStatus, view: StudentView): boolean

studentViewCounts()

The count of every student view.

utils/learning.ts
studentViewCounts(statuses: StudentStatus[]): Record<StudentView, number>

instructorStats()

Students, rating, completion, revenue and payout of an instructor.

utils/learning.ts
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;…
ReturnscoursespublisheddraftsstudentsnewThisMonthreviewsratingcompletionrevenuepayout

invitationDaysLeft()

Days before an invitation expires.

utils/learning.ts
invitationDaysLeft(invitedAt: string, now: Date): number

matchesInstructorView()

Whether an instructor belongs to a view.

utils/learning.ts
matchesInstructorView(status: InstructorView, view: InstructorView): boolean

instructorViewCounts()

The count of every instructor view.

utils/learning.ts
instructorViewCounts(statuses: InstructorView[]): Record<InstructorView, number>
© 2026 melsami UI.
Developer documentation for melsami UI.