Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Now activity names are sorted by name length to avoid Bug 2282

  • Loading branch information...
commit d1f9ad57d5c9e7feff291c24513aed7db51a3dd7 1 parent 7e33460
stronk7 authored

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. +11 0 filter/activitynames/filter.php
11 filter/activitynames/filter.php
@@ -17,6 +17,9 @@ function activitynames_filter($courseid, $text) {
17 17 $course = get_record("course","id",$courseid);
18 18 $modinfo = unserialize($course->modinfo);
19 19
  20 + //Sort modinfo by name lenght
  21 + usort($modinfo,'comparemodulenamesbylenght');
  22 +
20 23 if (!empty($modinfo)) {
21 24 $cm = '';
22 25 foreach ($modinfo as $activity) {
@@ -113,4 +116,12 @@ function activity_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>")
113 116 }
114 117 return $text;
115 118 }
  119 +
  120 + //This function is used to order module names from longer to shorter
  121 + function comparemodulenamesbylenght($a, $b) {
  122 + if (strlen($a->name) == strlen($b->name)) {
  123 + return 0;
  124 + }
  125 + return (strlen($a->name) < strlen($b->name)) ? 1 : -1;
  126 + }
116 127 ?>

0 comments on commit d1f9ad5

Please sign in to comment.
Something went wrong with that request. Please try again.