In one of our Totara theme projects, we wanted to hide default breadcrumbs and show our own breadcrumbs on activity page like columns 1, columns 2 or columns 3. To get the activity details for a particular activity, we can write custom queries but as there were multiple activities like forum, assign, quiz etc and each activity corresponds to its unique table it is not recommended to write query for each possible activity. So to get this data just used Page API.
$var = $PAGE->activityrecord;
$var gives us an array which contains Course Id and activity name for that activity.
$courseid=$var->course; //course id $activityname=$var->name; //activity name
Note: Declare Global $PAGE before using this.
Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need LMS app development or any other software development assistance please contact us at firstname.lastname@example.org