I would like to test if the logged in user is enrolled on a course that is being displayed on the frontpage of available courses of Adaptable theme. If the user is enrolled, I will display "View" button. Otherwise, I will display "Enroll"button. However, when I added this code inside the renderers.php of the Adaptable theme, I am getting an incorrect result. It displays a common enrolled button to all courses which is not anyway. I am also not getting the correct courseid. I declared the variables: global $USER, $COURSE inside the function coursecat_coursebox_content().
- $context = context_course::instance($COURSE->id);
- $enrolled = is_enrolled($context, $USER->id, '', true);
- $content .= "<br />Userid: ".$USER->id." Enrolled: ".$enrolled." Courseid: ".$COURSE->id;