by Trinh Nguyen.
From the Moodle version 2.5.1 onwards, you can use these following function to get course(s):
- Get a specific course with ID:
$course = get_course($course_id);
- Get all courses:
$courses = get_courses();
Read the Moodle's Data Manipulation API for more information: