Permalink
Browse files

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

  • Loading branch information...
stronk7
stronk7 committed Dec 13, 2004
1 parent b8b9329 commit 3a558dd9a8880598d6b5ab0b0e2daa89006b6fb9
Showing with 12 additions and 1 deletion.
  1. +12 −1 filter/activitynames/filter.php
@@ -1,4 +1,4 @@
<?PHP // $Id$
<?php // $Id$
//This function provides automatic linking to
//activities when its name (title) is found inside every Moodle text
//It's based in the glosssary filter by Williams Castillo
@@ -15,6 +15,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) {
@@ -111,4 +114,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 3a558dd

Please sign in to comment.