From 3a558dd9a8880598d6b5ab0b0e2daa89006b6fb9 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 13 Dec 2004 01:25:23 +0000 Subject: [PATCH] Now activity names are sorted by name length to avoid Bug 2282 (http://moodle.org/bugs/bug.php?op=show&bugid=2282) Merged from MOODLE_14_STABLE --- filter/activitynames/filter.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/filter/activitynames/filter.php b/filter/activitynames/filter.php index 5c5e6cc0be..8d222901a5 100644 --- a/filter/activitynames/filter.php +++ b/filter/activitynames/filter.php @@ -1,4 +1,4 @@ -modinfo); + //Sort modinfo by name lenght + usort($modinfo,'comparemodulenamesbylenght'); + if (!empty($modinfo)) { $cm = ''; foreach ($modinfo as $activity) { @@ -111,4 +114,12 @@ } 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; + } ?> -- 2.39.5