Flicking icons

Flicking icons

by Joan Codina Filba -
Number of replies: 5
The course view allows a side-block indicating the recent activity, but this is text and maybe does not focus attention enough and is an extra element in the screen.
Here there is a simple update (10 lines of php) that highlight the new activities set in a course by cahnging the icon, you can view a sample at this address:

http://www.tecn.upf.es/~jcodina/sample_new_icon.php


the changes to perfom are very simple:
a. in file config.php add this line

$CFG->newicontime=(3600*72); //number of seconds the new Icon must appear, the sample is 72 hours

b. modify the file modle/course/lib.php
find this line: "} else { // Normal activity"
and add after this line this code

if (isset($modinfo[$modnumber]->timemodified)) {
if (time()-$modinfo[$modnumber]->timemodified<$CFG->newicontime ) {
if (file_exists("$CFG->dirroot/mod/$mod->modname/new.gif")){
$icon = "$CFG->modpixpath/$mod->modname/new.gif";
} else {
$icon = "$CFG->modpixpath/new.gif";
}
}
}


Uncompress the attached zip file with the flicking icons new.gif

The change works in version 1.5 but also in 1.4 (the line number then it will be different)

(Editado por Eloy Lafuente (stronk7) - sábado, 18 de junio de 2005, 18:57)
Average of ratings: -
In reply to Joan Codina Filba

Re: Flicking icons

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Joan,

first of all, I've edited you post to show the code properly (some > chars were breaking it a bit).

Second, I think it's a good idea, because it provides some visual and useful information without adding "processing costs" to the display of the course page. Anybody has anything against it?

Anyway, some minor modifications could, in my opinion, improve things a bit:

- To save a bit of process, perhaps you could check, at the beginning, if $CFG->newicontime is empty to avoid all the rest of code.
- By moving time() calls outside the whole loop will help a bit too (being extreme! wink).
- Those animated incons (although personally, I love them, about likes there is nothing written wink), I think they aren't ok for Moodle. Perhaps rounding the originals with some red border or whatever you want. Or perhaps better, why not to show such activities using some style like "activity-new xxxx" (where xxxx is the activity name) and then define such CSS class (or classes) with your preferred style (icon, bold, color...). Perhaps this alternative (gently donated by a cold-man some minutes ago tongueout) would be more 1.5 compliant?

+1 to add this to future releases...

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Flicking icons

by Darren Smith -

Anybody has anything against it?

Yes and no big grin

No because I can see it's value and it would be a great addition to mainstream moodle.

Yes because a lot of my courses are week based and I may add 1 or 2 things just before that week comes online and I don't want the new things to have more importance than the stuff I have been working on for months!

An option in the course settings? approve

In reply to Darren Smith

Re: Flicking icons

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
An option in the course settings?

That sound good too. cool What about one global setting to enable/disable the feature sitewide and one setting inside every course (displayed only if the global flag is enabled) where teachers can disable it or specify the amount of time to be new?

Ciao smile

In reply to Eloy Lafuente (stronk7)

Re: Flicking icons

by Joan Codina Filba -
First, thanks for the retouch of my post, I noticed it, but I didn't knew how to arrange it, and even now, as an administrator of a Moodle site, i don't know how to modify posts of my students.

Secondly... the feature and the icon.... I must say that I proposed this change to my students in order to evaluate the cost. And I did this solution to show them that a solution sometimes can be very simple. Of course it can be as complicated as we want, but then it needs to add data to databases making the change more difficult to maintain if its not accepted as an interesting change for the next release, so a very localized code was a plus.... that was the lesson.
I accept that the icon's design wasn't very accurate, it could be just flicking, a border,...
Some of the drawbacks explained by Darren are also true for the "recent activity block" and i think that the question is if we do it automatically using some time stored in the system or if the teacher, indicates which elements to highlight and for how many time.
If we do it automatically (as the solution proposed) then there is nothing to do... when we modify something it will be highlighted, and we can put parameters by course, activity type or student, but we lose control.
If we do it manually then we can add a parameter to each activity, maybe called "end time to highlight", this is set by default N days after the activity is created (or modified) but it can be changed by the teacher. Of course, this means that all the activities need to change its editing page.
Why to indicate the "end time to highlight"? because is clear, simple and flexible. If think that this is better than to have a boolean for each activity and moving up and down modifying it. This solution is not automatic but almost, as the default value does the job if we don't modify it. Cost... well the cost is to change the databases, adding a new field to table module and all the activities need to modify its editing page....
Difficult to maintain or distribute, nice if embedded in the new version....
In reply to Joan Codina Filba

Re: Flicking icons

by Joan Codina Filba -
There is one error in the code and I also forgot another change in course/lib.php

The error
if (time()-$modinfo[$modnumber]->timemodifiednewicontime ) {

should be
if (time()-$modinfo[$modnumber]->timemodified>$CFG->newicontime ) {

The change is: Locate this lines ...

$mod[$seq]->cm = $rawmods[$seq]->id;
$mod[$seq]->mod = $rawmods[$seq]->modname;
$mod[$seq]->section = $section->section;
$mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
$mod[$seq]->visible = $rawmods[$seq]->visible;
$mod[$seq]->extra = "";

add this line, after name and before visible.

$mod[$seq]->timemodified = (string)get_field($rawmods[$seq]->modname, "timemodified", "id", $rawmods[$seq]->instance);

You can test it at:
http://parles.upf.edu/TEST
username teacher password teacher.