Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-9014

Improve display of block course_list

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Inactive
    • Icon: Minor Minor
    • None
    • 1.7, 1.8, 1.9, 2.0
    • Blocks
    • None
    • Any
    • MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Why: This few modifications to this block make it easier for those users that are enroled in many courses to find them using this block.

      How: It adds an extra line with the category name which the course belongs to, sorting them alphabetically inside.

      Code:
      /blocks/course_list/block_course_list.php:

      37 if (empty($CFG->disablemycourses) and
      38 !empty($USER->id) and
      39 !(has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) and $adminseesall) and
      40 !isguest()) { // Just print My Courses
      41 if ($courses = get_my_courses($USER->id,'category ASC, fullname ASC')) { //mu: Get courses sorted by category
      42 foreach ($courses as $course) {
      43 if ($course->id == SITEID)

      { 44 continue; 45 }

      46 if($cat == $course->category)

      { //mu: If I'm inside the same category, don't print category's name 47 $linkcss = $course->visible ? "" : " class=\"dimmed\" "; 48 $this->content->items[]="<a $linkcss title=\"$course->shortname\" ". 49 "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>"; 50 $this->content->icons[]=$icon; 51 continue; 52 }

      53 $cat = $course->category;
      54 $catname = get_record('course_categories', 'id', $cat);
      55 $this->content->items[] = "<strong>".$catname->name."</strong>";
      56 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
      57 $this->content->icons[]='';
      58 $this->content->items[]="<a $linkcss title=\"$course->shortname\" ".
      59 "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
      60 $this->content->icons[]=$icon;
      61 }
      62 $this->title = get_string('mycourses');
      63 $this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
      64 if ($this->content->items)

      { // make sure we don't return an empty list 65 return $this->content; 66 }

      67 }
      68 }

            Unassigned Unassigned
            petcheverry Pablo Etcheverry
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.