Issue Details (XML | Word | Printable)

Key: MDL-14489
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Mathieu Petit-Clair
Reporter: Matt Gibson
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Tag cloud seems to have very uniform font sizes these days.

Created: 23/Apr/08 04:11 PM   Updated: 07/Oct/08 10:12 PM
Return to search
Component/s: Tags, Themes
Affects Version/s: 1.9
Fix Version/s: 1.9.3

File Attachments: None
Image Attachments:

1. tag search.jpg
(67 kB)

Participants: Mathieu Petit-Clair and Matt Gibson
Security Level: None
QA Assignee: Nicolas Connault
Resolved date: 24/Sep/08
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
Not sure when this happened, but it was a while ago - the tag cloud used to have a range of text sizes from very small to very large, but now it seems not to use the very small ones any more. The css in the theme goes from .tag_cloud /s1 to .tagcloud .s20, but for items with only one user and no other info, the tag is .s14.

Is this a deliberate change? It does make the block take up more than an entire screen height on a large LCD. If it is (accessibility?), then maybe a config option to re-enable the small sizes?

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Mathieu Petit-Clair added a comment - 24/Apr/08 09:49 AM
This is very theme-specific. You can (easily?) change the size of each of the 20 sizes to what you want by overriding the css for ".content .tag_cloud" (to specifiy the base font size) and ".tag_cloud .s??" (for each tag size). The default size range goes from 0.82em to 1.2em.

The default size might not be optimal, but I am really not the best one for this. I think the default size haven't really changed.. Though, both tag blocks have been made to use the same css styles, for consistency reasons (and to make it easier the day they get merged).

I'm adding Urs to this discussion, he'll have a better idea than me of what the default css should be like.


Matt Gibson added a comment - 24/Apr/08 05:31 PM
I was just about to change the theme css when i noticed that the system only gave me 6 of the 20 possible css tags to use.

This is because the tag in my block that should have been the smallest, with just one user, is marked as .s14 instead of .s1. Is there a logic to this, i.e. is a tag weighted more if its on a users interests page compared to if its been used for a singe blog entry? Or is the intention not to use more than 6 font sizes from noow on?


Mathieu Petit-Clair added a comment - 24/Apr/08 06:19 PM
There is a logic .. If the least common is marked .s14, there's a bug. http://moodle.org/tag/search.php is showing how it should be. It should assign .s1 to the least common tag, all the way up to .s20 to the most common.

I didn't code that part of the tag library, but the code is fairly small, you can have a look at http://cvs.moodle.org/moodle/tag/locallib.php?annotate=1.1.2.13#l18 to get an idea (my name is there, but that's because I moved the code around). I have the feeling it could be made more efficient, patches welcome.


Matt Gibson added a comment - 07/May/08 07:52 PM
Weird. I just looked at the moodle.org search cloud and it seemed fine, with tags down to s2. My own one (attached) shows nothing below s16. I'll have a poke about...

Matt Gibson added a comment - 07/May/08 08:11 PM
Seems to be that I have a couple of tags with extra things added, but lots with just one thing. This leads to a very flat hierarchy. The code currently starts at the biggest size and allocates smaller and smaller sizes to groups of tags with similar importance. My problem is that the lowest possible importance is reached after 4-5 iterations because tags are not used a lot yet. A better solution would be to either start the iteration at the smallest size or use a mor complicated algorithm to allocate based on proportion of total hierarchical levels. I will have a further poke about...

Matt Gibson added a comment - 07/May/08 11:30 PM
New version of tag_print_cloud(). The old one ranked all tags and allocated class based on position in the sequence so it was stuck for instances with only a small number of positions in the hierarchy. This one allocates based on (tag count / count of most used tag * 20), so it still works for a very flat hierarchy.

Sorry its not a proper patch!

function tag_print_cloud($nr_of_tags=150, $return=false) {

global $CFG;

$can_manage_tags = has_capability('moodle/tag:manage', get_context_instance(CONTEXT_SYSTEM));

if ( !$tagcloud = get_records_sql('SELECT tg.rawname, tg.id, tg.name, tg.tagtype, COUNT(ti.id) AS count, tg.flag '.
'FROM '. $CFG->prefix .'tag_instance ti INNER JOIN '. $CFG->prefix .'tag tg ON tg.id = ti.tagid '.
'WHERE ti.itemtype != \'tag\' '.
'GROUP BY tg.id, tg.rawname, tg.name, tg.flag, tg.tagtype '.
'ORDER BY count DESC, tg.name ASC', 0, $nr_of_tags) ) { $tagcloud = array(); }

$tagkeys = array_keys($tagcloud);
$firsttagkey = $tagkeys[0];
$maxcount = $tagcloud[$firsttagkey]->count;

$etags = array();

foreach ($tagcloud as $tag) { $size = ((int)((($tag->count) / $maxcount) * 20)); $tag->class = "$tag->tagtype s$size"; $etags[] = $tag; }

usort($etags, "tag_cloud_sort");
$output = '';
$output .= "\n<ul class='tag_cloud inline-list'>\n";
foreach ($etags as $tag) {
if ($tag->flag > 0 && $can_manage_tags) { $tagname = '<span class="flagged-tag">'. tag_display_name($tag) .'</span>'; } else { $tagname = tag_display_name($tag); }

$link = $CFG->wwwroot .'/tag/index.php?tag='. rawurlencode($tag->name);
$output .= '<li><a href="'. $link .'" class="'. $tag->class .'" '.
'title="'. get_string('numberofentries', 'blog', $tag->count) .'">'.
$tagname .'</a></li> ';
}
$output .= "\n</ul>\n";

if ($return) { return $output; } else { echo $output; }
}


Mathieu Petit-Clair added a comment - 24/Sep/08 04:07 PM
Thanks, I finally gave this a try and committed it.