Skip to content

Commit

Permalink
Now activity names are sorted by name length to avoid Bug 2282
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Dec 13, 2004
1 parent 7e33460 commit d1f9ad5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions filter/activitynames/filter.php
Expand Up @@ -17,6 +17,9 @@ function activitynames_filter($courseid, $text) {
$course = get_record("course","id",$courseid); $course = get_record("course","id",$courseid);
$modinfo = unserialize($course->modinfo); $modinfo = unserialize($course->modinfo);


//Sort modinfo by name lenght
usort($modinfo,'comparemodulenamesbylenght');

if (!empty($modinfo)) { if (!empty($modinfo)) {
$cm = ''; $cm = '';
foreach ($modinfo as $activity) { foreach ($modinfo as $activity) {
Expand Down Expand Up @@ -113,4 +116,12 @@ function activity_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>")
} }
return $text; 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.