original_string: public function get_subscribe_options($courseid) {
          global $CFG;
  
          $url = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array(
              'courseid' => $courseid,
              'ruleid' => $this->id,
              'action' => 'subscribe',
              'sesskey' => sesskey()
          ));
  
          if (strpos($this->plugin, 'mod_') !== 0) {
              return $url;
  
          } else {
              // Single select when the plugin is an activity.
              $options = array();
              $options[0] = get_string('allmodules', 'tool_monitor');
  
              if ($courseid == 0) {
                  // They need to be in a course to select module instance.
                  return get_string('selectcourse', 'tool_monitor');
              }
  
              // Let them select an instance.
              $cms = get_fast_modinfo($courseid);
              $instances = $cms->get_instances_of(str_replace('mod_', '',  $this->plugin));
              foreach ($instances as $cminfo) {
                  // Don't list instances that are not visible or available to the user.
                  if ($cminfo->uservisible && $cminfo->available) {
                      $options[$cminfo->id] = $cminfo->get_formatted_name();
                  }
              }
  
              return new \single_select($url, 'cmid', $options);
          }
      }
code: public function get_subscribe_options($courseid) {
          global $CFG;
  
          $url = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array(
              'courseid' => $courseid,
              'ruleid' => $this->id,
              'action' => 'subscribe',
              'sesskey' => sesskey()
          ));
  
          if (strpos($this->plugin, 'mod_') !== 0) {
              return $url;
  
          } else {
              // Single select when the plugin is an activity.
              $options = array();
              $options[0] = get_string('allmodules', 'tool_monitor');
  
              if ($courseid == 0) {
                  // They need to be in a course to select module instance.
                  return get_string('selectcourse', 'tool_monitor');
              }
  
              // Let them select an instance.
              $cms = get_fast_modinfo($courseid);
              $instances = $cms->get_instances_of(str_replace('mod_', '',  $this->plugin));
              foreach ($instances as $cminfo) {
                  // Don't list instances that are not visible or available to the user.
                  if ($cminfo->uservisible && $cminfo->available) {
                      $options[$cminfo->id] = $cminfo->get_formatted_name();
                  }
              }
  
              return new \single_select($url, 'cmid', $options);
          }
      }
code_tokens: public function get_subscribe_options ( $ courseid ) { global $ CFG ; $ url = new \ moodle_url ( $ CFG -> wwwroot . '/admin/tool/monitor/index.php' , array ( 'courseid' => $ courseid , 'ruleid' => $ this -> id , 'action' => 'subscribe' , 'sesskey' => sesskey ( ) ) ) ; if ( strpos ( $ this -> plugin , 'mod_' ) !== 0 ) { return $ url ; } else { // Single select when the plugin is an activity. $ options = array ( ) ; $ options [ 0 ] = get_string ( 'allmodules' , 'tool_monitor' ) ; if ( $ courseid == 0 ) { // They need to be in a course to select module instance. return get_string ( 'selectcourse' , 'tool_monitor' ) ; } // Let them select an instance. $ cms = get_fast_modinfo ( $ courseid ) ; $ instances = $ cms -> get_instances_of ( str_replace ( 'mod_' , '' , $ this -> plugin ) ) ; foreach ( $ instances as $ cminfo ) { // Don't list instances that are not visible or available to the user. if ( $ cminfo -> uservisible && $ cminfo -> available ) { $ options [ $ cminfo -> id ] = $ cminfo -> get_formatted_name ( ) ; } } return new \ single_select ( $ url , 'cmid' , $ options ) ; } }
docstring: Gets the rule subscribe options for a given course and rule.
  
  Could be a select drop down with a list of possible module
  instances or a single link to subscribe if the rule plugin
  is not a module.
  
  @param int $courseid course id
  
  @return \single_select|\moodle_url|string
  @throws \coding_exception
docstring_tokens: Gets the rule subscribe options for a given course and rule .