Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit d1f9ad57d5c9e7feff291c24513aed7db51a3dd7 1 parent 7e33460
stronk7 authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 filter/activitynames/filter.php
11 filter/activitynames/filter.php
View
@@ -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;
+ }
?>
Please sign in to comment.
Something went wrong with that request. Please try again.