Permalink
Browse files

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

  • Loading branch information...
1 parent 7e33460 commit d1f9ad57d5c9e7feff291c24513aed7db51a3dd7 stronk7 committed Dec 13, 2004
Showing with 11 additions and 0 deletions.
  1. +11 −0 filter/activitynames/filter.php
View
11 filter/activitynames/filter.php
@@ -17,6 +17,9 @@ function activitynames_filter($courseid, $text) {
$course = get_record("course","id",$courseid);
$modinfo = unserialize($course->modinfo);
+ //Sort modinfo by name lenght
+ usort($modinfo,'comparemodulenamesbylenght');
+
if (!empty($modinfo)) {
$cm = '';
foreach ($modinfo as $activity) {
@@ -113,4 +116,12 @@ function activity_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>")
}
return $text;
}
+
+ //This function is used to order module names from longer to shorter
+ function comparemodulenamesbylenght($a, $b) {
+ if (strlen($a->name) == strlen($b->name)) {
+ return 0;
+ }
+ return (strlen($a->name) < strlen($b->name)) ? 1 : -1;
+ }
?>

0 comments on commit d1f9ad5

Please sign in to comment.