Menu
Coddy logo textTech

E-Learning Platform

Part of the Object Oriented Programming section of Coddy's Dart journey — lesson 107 of 110.

challenge icon

Challenge

Easy

Let's build an E-Learning Platform that brings together all the OOP concepts you've mastered throughout this course. You'll create a system that manages users, courses, and enrollments using abstract classes, inheritance, mixins, and encapsulation.

Your platform will be organized across five files:

  • user.dart: Create an abstract User class with private fields for _id (String) and _name (String), with public getters. Include an abstract method String getRole() that subclasses must implement. Override toString() to return [role] name (id) where role comes from getRole().
  • student.dart: Create a Student class that extends User. Students should use a ProgressTracking mixin (defined in this file) that provides a private _completedLessons integer (starting at 0) with a getter, and methods completeLesson() to increment it and getProgressReport() that returns Completed X lessons. The Student class should implement getRole() to return Student.
  • instructor.dart: Create an Instructor class that extends User. Instructors have a private list _coursesCreated (list of Strings representing course titles). Include a method createCourse(String title) that adds the title to the list and returns the title. Implement getRole() to return Instructor. Add a getter courseCount that returns the number of courses created.
  • enrollment.dart: Create an Enrollment class that tracks a student's enrollment in a course. It should have a studentId (String), courseName (String), and a private _isCompleted boolean (defaults to false) with a getter. Include a method markComplete() that sets completion to true. Override toString() to return studentId enrolled in "courseName" - Status: Completed or Status: In Progress based on completion status.
  • main.dart: Bring everything together. Create an instructor (I001, Dr. Smith) and have them create two courses: Dart Fundamentals and Advanced OOP. Print the instructor and their course count as Courses created: X. Create a student (S001, Alice), print them, then have them complete 3 lessons and print their progress report. Create an enrollment for Alice in Dart Fundamentals, print it, mark it complete, and print it again.

Expected output:

[Instructor] Dr. Smith (I001)
Courses created: 2
[Student] Alice (S001)
Completed 3 lessons
S001 enrolled in "Dart Fundamentals" - Status: In Progress
S001 enrolled in "Dart Fundamentals" - Status: Completed

Try it yourself

import 'user.dart';
import 'student.dart';
import 'instructor.dart';
import 'enrollment.dart';

void main() {
  // TODO: Create an instructor with id "I001" and name "Dr. Smith"
  
  // TODO: Have the instructor create two courses: "Dart Fundamentals" and "Advanced OOP"
  
  // TODO: Print the instructor (uses toString())
  
  // TODO: Print "Courses created: X" where X is the courseCount
  
  // TODO: Create a student with id "S001" and name "Alice"
  
  // TODO: Print the student
  
  // TODO: Have the student complete 3 lessons (call completeLesson() 3 times)
  
  // TODO: Print the student's progress report
  
  // TODO: Create an enrollment for Alice (S001) in "Dart Fundamentals"
  
  // TODO: Print the enrollment
  
  // TODO: Mark the enrollment as complete
  
  // TODO: Print the enrollment again
}

All lessons in Object Oriented Programming