In the context of an activity, the $COURSE module has lots of details, including the course name and the id of the category it belongs to. But, I can't seem to figure out how to programatically identify the name of the course category from that ID. Any suggestions? Do I need to do a lookup with $DB?
General developer forum
Category Names using PHP
I found this post, which worked for me.
$category = $DB->get_record('course_categories',array('id'=>$COURSE->category));
Edit: I initially thought this wasn't working, but that was only due to displaying it incorrectly.