General developer forum

Moodle Functions: Get course details from courseid

 
Picture of Phil Nichols
Moodle Functions: Get course details from courseid
 
Hi

Given a courseid, is there a moodle function that will return the course's full name?
 
Average of ratings: -
Volcano
Re: Moodle Functions: Get course details from courseid
Core developers
Phil:

The courseid number is an index into the course table in Moodle. That table contains both the shortname and fullname of the course and many other items.

If $courseid is the course number, use this code to get either or both names:

$course = get_record('course','id', $courseid);
echo ($course->fullname);
echo ($course->shortname);


Take care,

--Gary
 
Average of ratings: Useful (1)
Picture of Phil Nichols
Re: Moodle Functions: Get course details from courseid
 
thankyou!
 
Average of ratings: -
Picture of Ann Adamcik
Re: Moodle Functions: Get course details from courseid
Core developers
You can also use the print_object() function to see everything in the course table -

print_object($course);
 
Average of ratings: -
Picture of Dan Tovar
Re: Moodle Functions: Get course details from courseid
 

Update for Moodle 3.0


$course = $DB->get_record('course', array('id' => $courseid));

 
Average of ratings: -