Moodle
  1. Moodle
  2. MDL-9014

Improve display of block course_list

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.7, 1.8, 1.9, 2.0
    • Fix Version/s: None
    • Component/s: Blocks
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      3528

      Description

      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 }

        Issue Links

          Activity

          Hide
          Martin Dougiamas added a comment -

          I like the concept. Currently the sorting sucks because it ignores category completely.

          Really the categories should be sorted to match their real sortorder in the category listing, but this would add even more database load on top of what this already does.

          Can someone come up with a nice way to sort categories and courses? It has to be efficient too (one SQL would be nice).

          Show
          Martin Dougiamas added a comment - I like the concept. Currently the sorting sucks because it ignores category completely. Really the categories should be sorted to match their real sortorder in the category listing, but this would add even more database load on top of what this already does. Can someone come up with a nice way to sort categories and courses? It has to be efficient too (one SQL would be nice).

            People

            • Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated: