original_string: public static function get_calendar_action_events_by_course(
          $courseid, $timesortfrom = null, $timesortto = null, $aftereventid = 0, $limitnum = 20) {
  
          global $PAGE, $USER;
  
          $user = null;
          $params = self::validate_parameters(
              self::get_calendar_action_events_by_course_parameters(),
              [
                  'courseid' => $courseid,
                  'timesortfrom' => $timesortfrom,
                  'timesortto' => $timesortto,
                  'aftereventid' => $aftereventid,
                  'limitnum' => $limitnum,
              ]
          );
          $context = \context_user::instance($USER->id);
          self::validate_context($context);
  
          if (empty($params['aftereventid'])) {
              $params['aftereventid'] = null;
          }
  
          $courses = enrol_get_my_courses('*', null, 0, [$courseid]);
          $courses = array_values($courses);
  
          if (empty($courses)) {
              return [];
          }
  
          $course = $courses[0];
          $renderer = $PAGE->get_renderer('core_calendar');
          $events = local_api::get_action_events_by_course(
              $course,
              $params['timesortfrom'],
              $params['timesortto'],
              $params['aftereventid'],
              $params['limitnum']
          );
  
          $exportercache = new events_related_objects_cache($events, $courses);
          $exporter = new events_exporter($events, ['cache' => $exportercache]);
  
          return $exporter->export($renderer);
      }
code: public static function get_calendar_action_events_by_course(
          $courseid, $timesortfrom = null, $timesortto = null, $aftereventid = 0, $limitnum = 20) {
  
          global $PAGE, $USER;
  
          $user = null;
          $params = self::validate_parameters(
              self::get_calendar_action_events_by_course_parameters(),
              [
                  'courseid' => $courseid,
                  'timesortfrom' => $timesortfrom,
                  'timesortto' => $timesortto,
                  'aftereventid' => $aftereventid,
                  'limitnum' => $limitnum,
              ]
          );
          $context = \context_user::instance($USER->id);
          self::validate_context($context);
  
          if (empty($params['aftereventid'])) {
              $params['aftereventid'] = null;
          }
  
          $courses = enrol_get_my_courses('*', null, 0, [$courseid]);
          $courses = array_values($courses);
  
          if (empty($courses)) {
              return [];
          }
  
          $course = $courses[0];
          $renderer = $PAGE->get_renderer('core_calendar');
          $events = local_api::get_action_events_by_course(
              $course,
              $params['timesortfrom'],
              $params['timesortto'],
              $params['aftereventid'],
              $params['limitnum']
          );
  
          $exportercache = new events_related_objects_cache($events, $courses);
          $exporter = new events_exporter($events, ['cache' => $exportercache]);
  
          return $exporter->export($renderer);
      }
code_tokens: public static function get_calendar_action_events_by_course ( $ courseid , $ timesortfrom = null , $ timesortto = null , $ aftereventid = 0 , $ limitnum = 20 ) { global $ PAGE , $ USER ; $ user = null ; $ params = self :: validate_parameters ( self :: get_calendar_action_events_by_course_parameters ( ) , [ 'courseid' => $ courseid , 'timesortfrom' => $ timesortfrom , 'timesortto' => $ timesortto , 'aftereventid' => $ aftereventid , 'limitnum' => $ limitnum , ] ) ; $ context = \ context_user :: instance ( $ USER -> id ) ; self :: validate_context ( $ context ) ; if ( empty ( $ params [ 'aftereventid' ] ) ) { $ params [ 'aftereventid' ] = null ; } $ courses = enrol_get_my_courses ( '*' , null , 0 , [ $ courseid ] ) ; $ courses = array_values ( $ courses ) ; if ( empty ( $ courses ) ) { return [ ] ; } $ course = $ courses [ 0 ] ; $ renderer = $ PAGE -> get_renderer ( 'core_calendar' ) ; $ events = local_api :: get_action_events_by_course ( $ course , $ params [ 'timesortfrom' ] , $ params [ 'timesortto' ] , $ params [ 'aftereventid' ] , $ params [ 'limitnum' ] ) ; $ exportercache = new events_related_objects_cache ( $ events , $ courses ) ; $ exporter = new events_exporter ( $ events , [ 'cache' => $ exportercache ] ) ; return $ exporter -> export ( $ renderer ) ; }
docstring: Get calendar action events for the given course.
  
  @since Moodle 3.3
  @param int $courseid Only events in this course
  @param null|int $timesortfrom Events after this time (inclusive)
  @param null|int $timesortto Events before this time (inclusive)
  @param null|int $aftereventid Get events with ids greater than this one
  @param int $limitnum Limit the number of results to this value
  @return array
docstring_tokens: Get calendar action events for the given course .