Modules
Courses
A course catalogue with curriculum, completion, ratings, students and a course page with tabs.
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.vue | The catalogue. |
pages/learning/courses/[id].vue | The course page. |
composables/useLearning.ts | findCourse, studentsOf, saveCourse, duplicateCourse, setCourseStatus, removeCourse. |
composables/useCourseForm.ts | The create and edit form. |
types/models/learning.ts | Courses, modules, lessons, students and instructors. |
config/learning.config.ts | Categories, lesson types, views, sorts and thresholds. |
utils/learning.ts | Pure 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.
const COURSE_CATEGORY_STYLES: Record<CourseCategory, { icon: string; color: string; }>LESSON_TYPE_STYLES
The icon of each lesson type.
const LESSON_TYPE_STYLES: Record<LessonType, { icon: string; color: string; }>COURSE_VIEWS
The views of the catalogue.
const COURSE_VIEWS: CourseView[]
COURSE_SORTS
The sorts of the grid.
const COURSE_SORTS: CourseSort[]
COURSE_DEFAULT_LAYOUT
grid or list; the choice persists in the courses-layout cookie.
const COURSE_DEFAULT_LAYOUT: CourseLayout
COURSE_LOW_COMPLETION
The completion rate below which a course is flagged.
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.
courseLessonCount(course: Pick<Course, 'modules'>): number
courseHours()
Hours.
courseHours(course: Pick<Course, 'modules'>): number
courseRating()
Rating.
courseRating(course: Pick<Course, 'ratingCounts'>): number
courseCompletion()
Completion.
courseCompletion(course: Pick<Course, 'students' | 'completed'>): number
sortCourses()
Sorting.
sortCourses(courses: T[], sort: CourseSort): T[]
How it works
- The catalogue is a
BaseDataTablewith views and a grid/list toggle asBaseToggleGroup compact fit, a sort menu in grid mode andLearningCourseCards 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 dividedstrip (completion against the platform average), tabs synced with?tab=(curriculum, students, reviews), aBaseRatingBreakdown, top students and the instructor.