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

Improve display of block course_list

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Inactive
    • 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

      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 }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: