Modules

Courses

A course catalogue with curriculum, completion, ratings, students and a course page with tabs.

composables/useLearning.ts
View in the demo

Courses carry modules of lessons (video, reading or quiz, with minutes, questions and preview), students, completed, newThisMonth, ratingCounts (5 to 1 stars), reviews and updatedAt. Lessons, hours and rating are derived, never stored. Courses, students and instructors share useLearning().

Files

File
Role
pages/learning/courses/index.vueThe catalogue.
pages/learning/courses/[id].vueThe course page.
composables/useLearning.tsfindCourse, studentsOf, saveCourse, duplicateCourse, setCourseStatus, removeCourse.
composables/useCourseForm.tsThe create and edit form.
types/models/learning.tsCourses, modules, lessons, students and instructors.
config/learning.config.tsCategories, lesson types, views, sorts and thresholds.
utils/learning.tsPure rules, unit tested.
components/pages/learning/LearningCourseCard, LearningCourseQuickView, LearningCourseOutline, LearningCourseCompletion, LearningCourseRating, LearningCourseFormPanel, LearningCourseStudentsTable, LearningCourseRatingsCard, LearningCourseTopStudents, LearningCourseInstructorCard.

Data

useLearning() loads its data through a LearningProvider (types/models/learning.ts); the demo uses createLearningMockProvider(). Write a provider that calls your API and make it the default: the pages do not change. See Connect your API.

Permissions

Every learning page needs courses.view.

Configuration

COURSE_CATEGORY_STYLES

The icon and colour of each category.

config/learning.config.ts
const COURSE_CATEGORY_STYLES: Record<CourseCategory, { icon: string; color: string; }>

LESSON_TYPE_STYLES

The icon of each lesson type.

config/learning.config.ts
const LESSON_TYPE_STYLES: Record<LessonType, { icon: string; color: string; }>

COURSE_VIEWS

The views of the catalogue.

config/learning.config.ts
const COURSE_VIEWS: CourseView[]

COURSE_SORTS

The sorts of the grid.

config/learning.config.ts
const COURSE_SORTS: CourseSort[]

COURSE_DEFAULT_LAYOUT

grid or list; the choice persists in the courses-layout cookie.

config/learning.config.ts
const COURSE_DEFAULT_LAYOUT: CourseLayout

COURSE_LOW_COMPLETION

The completion rate below which a course is flagged.

config/learning.config.ts
const COURSE_LOW_COMPLETION: 55

Rules

Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.

courseLessonCount()

Lessons.

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

courseHours()

Hours.

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

courseRating()

Rating.

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

courseCompletion()

Completion.

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

sortCourses()

Sorting.

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

How it works

  • The catalogue is a BaseDataTable with views and a grid/list toggle as BaseToggleGroup compact fit, a sort menu in grid mode and LearningCourseCards rendered through #body. ?instructor= preselects the instructor filter.
  • Clicking a course opens LearningCourseQuickView: stats, a compact outline, the latest review, preview, publish, duplicate, delete and edit.
  • The course page has a BaseStatTiles divided strip (completion against the platform average), tabs synced with ?tab= (curriculum, students, reviews), a BaseRatingBreakdown, top students and the instructor.
© 2026 melsami UI.
Developer documentation for melsami UI.