original_string: public function tagged_courses($tagid, $exclusivemode = true, $ctx = 0, $rec = true, $displayoptions = null) {
          global $CFG;
          if (empty($displayoptions)) {
              $displayoptions = array();
          }
          $showcategories = !core_course_category::is_simple_site();
          $displayoptions += array('limit' => $CFG->coursesperpage, 'offset' => 0);
          $chelper = new coursecat_helper();
          $searchcriteria = array('tagid' => $tagid, 'ctx' => $ctx, 'rec' => $rec);
          $chelper->set_show_courses($showcategories ? self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT :
                      self::COURSECAT_SHOW_COURSES_EXPANDED)->
                  set_search_criteria($searchcriteria)->
                  set_courses_display_options($displayoptions)->
                  set_attributes(array('class' => 'course-search-result course-search-result-tagid'));
                  // (we set the same css class as in search results by tagid)
          if ($totalcount = core_course_category::search_courses_count($searchcriteria)) {
              $courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
              if ($exclusivemode) {
                  return $this->coursecat_courses($chelper, $courses, $totalcount);
              } else {
                  $tagfeed = new core_tag\output\tagfeed();
                  $img = $this->output->pix_icon('i/course', '');
                  foreach ($courses as $course) {
                      $url = course_get_url($course);
                      $imgwithlink = html_writer::link($url, $img);
                      $coursename = html_writer::link($url, $course->get_formatted_name());
                      $details = '';
                      if ($showcategories && ($cat = core_course_category::get($course->category, IGNORE_MISSING))) {
                          $details = get_string('category').': '.
                                  html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
                                          $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
                      }
                      $tagfeed->add($imgwithlink, $coursename, $details);
                  }
                  return $this->output->render_from_template('core_tag/tagfeed', $tagfeed->export_for_template($this->output));
              }
          }
          return '';
      }
code: public function tagged_courses($tagid, $exclusivemode = true, $ctx = 0, $rec = true, $displayoptions = null) {
          global $CFG;
          if (empty($displayoptions)) {
              $displayoptions = array();
          }
          $showcategories = !core_course_category::is_simple_site();
          $displayoptions += array('limit' => $CFG->coursesperpage, 'offset' => 0);
          $chelper = new coursecat_helper();
          $searchcriteria = array('tagid' => $tagid, 'ctx' => $ctx, 'rec' => $rec);
          $chelper->set_show_courses($showcategories ? self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT :
                      self::COURSECAT_SHOW_COURSES_EXPANDED)->
                  set_search_criteria($searchcriteria)->
                  set_courses_display_options($displayoptions)->
                  set_attributes(array('class' => 'course-search-result course-search-result-tagid'));
                  // (we set the same css class as in search results by tagid)
          if ($totalcount = core_course_category::search_courses_count($searchcriteria)) {
              $courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
              if ($exclusivemode) {
                  return $this->coursecat_courses($chelper, $courses, $totalcount);
              } else {
                  $tagfeed = new core_tag\output\tagfeed();
                  $img = $this->output->pix_icon('i/course', '');
                  foreach ($courses as $course) {
                      $url = course_get_url($course);
                      $imgwithlink = html_writer::link($url, $img);
                      $coursename = html_writer::link($url, $course->get_formatted_name());
                      $details = '';
                      if ($showcategories && ($cat = core_course_category::get($course->category, IGNORE_MISSING))) {
                          $details = get_string('category').': '.
                                  html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
                                          $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
                      }
                      $tagfeed->add($imgwithlink, $coursename, $details);
                  }
                  return $this->output->render_from_template('core_tag/tagfeed', $tagfeed->export_for_template($this->output));
              }
          }
          return '';
      }
code_tokens: public function tagged_courses ( $ tagid , $ exclusivemode = true , $ ctx = 0 , $ rec = true , $ displayoptions = null ) { global $ CFG ; if ( empty ( $ displayoptions ) ) { $ displayoptions = array ( ) ; } $ showcategories = ! core_course_category :: is_simple_site ( ) ; $ displayoptions += array ( 'limit' => $ CFG -> coursesperpage , 'offset' => 0 ) ; $ chelper = new coursecat_helper ( ) ; $ searchcriteria = array ( 'tagid' => $ tagid , 'ctx' => $ ctx , 'rec' => $ rec ) ; $ chelper -> set_show_courses ( $ showcategories ? self :: COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT : self :: COURSECAT_SHOW_COURSES_EXPANDED ) -> set_search_criteria ( $ searchcriteria ) -> set_courses_display_options ( $ displayoptions ) -> set_attributes ( array ( 'class' => 'course-search-result course-search-result-tagid' ) ) ; // (we set the same css class as in search results by tagid) if ( $ totalcount = core_course_category :: search_courses_count ( $ searchcriteria ) ) { $ courses = core_course_category :: search_courses ( $ searchcriteria , $ chelper -> get_courses_display_options ( ) ) ; if ( $ exclusivemode ) { return $ this -> coursecat_courses ( $ chelper , $ courses , $ totalcount ) ; } else { $ tagfeed = new core_tag \ output \ tagfeed ( ) ; $ img = $ this -> output -> pix_icon ( 'i/course' , '' ) ; foreach ( $ courses as $ course ) { $ url = course_get_url ( $ course ) ; $ imgwithlink = html_writer :: link ( $ url , $ img ) ; $ coursename = html_writer :: link ( $ url , $ course -> get_formatted_name ( ) ) ; $ details = '' ; if ( $ showcategories && ( $ cat = core_course_category :: get ( $ course -> category , IGNORE_MISSING ) ) ) { $ details = get_string ( 'category' ) . ': ' . html_writer :: link ( new moodle_url ( '/course/index.php' , array ( 'categoryid' => $ cat -> id ) ) , $ cat -> get_formatted_name ( ) , array ( 'class' => $ cat -> visible ? '' : 'dimmed' ) ) ; } $ tagfeed -> add ( $ imgwithlink , $ coursename , $ details ) ; } return $ this -> output -> render_from_template ( 'core_tag/tagfeed' , $ tagfeed -> export_for_template ( $ this -> output ) ) ; } } return '' ; }
docstring: Renders html to print list of courses tagged with particular tag
  
  @param int $tagid id of the tag
  @param bool $exclusivemode if set to true it means that no other entities tagged with this tag
  are displayed on the page and the per-page limit may be bigger
  @param int $fromctx context id where the link was displayed, may be used by callbacks
  to display items in the same context first
  @param int $ctx context id where to search for records
  @param bool $rec search in subcontexts as well
  @param array $displayoptions
  @return string empty string if no courses are marked with this tag or rendered list of courses
docstring_tokens: Renders html to print list of courses tagged with particular tag