patch to make logs more readable and usable

patch to make logs more readable and usable

by Ne Nashev -
Number of replies: 20
In logs table (/course/user.php?mode=alllogs...) too hard to see when user was started working, when hi was done, how long hi was working and how long they was away.

I have idea: if interval between two log records more then one hour, we can write session separator! It can be with some information about displayed working session and about founded interval.

And this idea in result here as simple patch (in base of v1.5.3+), which i would like to be injected into main moodle branch. General developers, please, look at this and add into CSV!


to file /course/lib.php add two piece of code

1) Inside loop by log records add
        $log->url  = str_replace('&', '&', $log->url); /// XHTML compatibility

// <<-- start of addition 1
if (isset($PrevTime) and (($PrevTime - $log->time) > 1*60*60)) {
echo '<tr class="r'.$row.'"><td colspan=6>';
echo get_string('log_work_time').': ';
$diff = (floor($BeginTime / 60) - floor($PrevTime / 60)) * 60;
echo $diff==0?'0':format_time($diff);
unset($BeginTime);
echo '<hr>'.get_string('log_interval').': ';
echo format_time((floor($PrevTime / 60) - floor($log->time / 60)) * 60);
echo '<br><hr></td></tr>';
}
$PrevTime = $log->time;
if (!isset($BeginTime)) {
$BeginTime = $log->time;
}
// -->> finish of addition 1
2) just after cicle:
    }
// <<-- start of addition 2
if (isset($PrevTime) and isset($BeginTime)) {
echo '<tr class="r'.$row.'"><td colspan=6>';
echo get_string('log_work_time').': ';
$diff = (floor($BeginTime / 60) - floor($PrevTime / 60)) * 60;
echo $diff==0?'0':format_time($diff);
echo '</td></tr>';
}
// -->> finish of addition 2
echo '</table>';
And (optional Улыбка) into lang/en/moodle.php add two strings - 'log_work_time' and 'log_interval' with some interpretation.
Average of ratings: -
In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Jeremy B -
Hello,

This is an excellent patch.  I've tested it on my systems and it works perfectly.  My clients find this additional information in the logs very useful.

Thanks again for putting your time into this.

JB
In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Julian Ridden -
Very nice addition. I have included a screencap for those who want to see exactly what this does.
Attachment Picture_2.png
In reply to Julian Ridden

Re: patch to make logs more readable and usable

by Faren Heit -
Hi Julian,
Ive added this snippet of code to my lib.php but theres no change?
Am i missing something obvious?
In reply to Julian Ridden

Urgent !!! Re: patch to make logs more readable and usable

by Hajjej Mohamed Ala Eddine -

Hello,
I try to add these codes in the page / course / lib.php but the patch does not work is that you can tell me exactly where to add the code
Please find the original file lib.php  and the file  lib.php after modification is that I have insert the code
Thank you in advance

In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Good idea, though shouldn't this only be applied to one-person logs?

If you had 20 people using Moodle at the same time does it make sense to call it a session?  mixed
In reply to Martin Dougiamas

in multi-person logs it look fine too

by Ne Nashev -
i'd try to find multi-user logs to see this there - and found
/course/log.php?id=1&chooselog=1&user=0&date=0&modid=&modaction=&group=-1&perpage=100&page=3

As result can say: in my site it looks as nice moodle-wide activity sessions information smile
In reply to Ne Nashev

Re: in multi-person logs it look fine too

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Can you show a screenshot?  One with many people accessing Moodle at the same time.  I don't think sessions makes sense in that case.
In reply to Martin Dougiamas

Re: in multi-person logs it look fine too

by Ne Nashev -
In sites with single time zone users it will be day from day separations - in logs it useful.

In multi time zone sites it will be only display holes in user activity - it useful for site admin to make in this times some site-wide manipulations.

Main here - to position this feature as is - as displaying log holes more then one hour, but not as "user work sessions".

I am in my russian interface translate work time as "Итого" (it is like footer "Summ" in last line of financial tables) and interval as "Перерыв в работе:" (it like "Break in works") - sorry my English

P.S.: in my site now much less then 20 active users, but here screenshot for you:
Attachment full_logs.jpg
In reply to Martin Dougiamas

Re: in multi-person logs it look fine too

by Juan David Martínez Pavony -

Hello.

My screenshot shows concurrent access with Ne Nashev's proposal.

So, I think it (the patch) can be taken as a SITE tool. Do not you think?

Attachment 1.JPG
In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Bernard Boucher -
Hi Ne,
very good addition.

I use a small "stats line" before details:

.

For 1 user ( Admin ) at that semester, 1146 differents activities, 12485 events, 357 hours total, 290 hours in school ( Cegep ) , 66 hours outside.

Another example for 1 user all activities for one 45 hours course:

.

1 activity and 1 group it give at least then number of users that did the activity:

.

It is sure that the totals for many users are less meaningfull that the totals of one user.

Maybe it should be good to integrate the two hacks?

I hope it may help,

Bernard





In reply to Ne Nashev

Re: patch to make logs more readable and usable

by N Hansen -
I'd like something that would allow me to track users by their IP. Sometimes people start off as guests but then register at some point later, but that can only be tracked through the IP. Some people may regularly visit the site as a guest unless they want to post something, and again, that could be tracked by IP. It won't work for all users, especially ones on AOL, but it would in some cases be a better alternative for tracking behavior.
In reply to N Hansen

Re: patch to make logs more readable and usable - IP tracking

by David Delgado -

And... what about dynamic IP systems? I think they are most common nowadays. Each time you connect, you are assigned a different IP (not in my case wink).

You can also go directly to the Apache logs and track IP's by copying the log file and filtering it with grep utility (show only that IP hits). Anyway, it is quite an advanced feature to implement in Moodle web interface, isn't it?

In reply to David Delgado

Re: patch to make logs more readable and usable - IP tracking

by Ne Nashev -
it may be interesting, if with "no user" and "Guest user" become displaying (in grey or by popup hint) list of users, which anywhen was logged from same IP!
In reply to Ne Nashev

Re: patch to make logs more readable and usable - IP tracking

by Mark Little -
Hi,

On what line do u add this coding?

Thanks
In reply to Mark Little

Re: patch to make logs more readable and usable - IP tracking

by Ne Nashev -
this - it is You about path to make more readable? in this case first block just after after line " $log->url = str_replace('&', '&', $log->url); /// XHTML compatibility" and second - before line with printing </table> that just after loop.

if you about IP tracking - i hav'nt code for that feature, but i think it is simple to make it and locate place for them
In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Tatiana Reis -
Good morning to all of Brazil and I am not a PHP programmer, despite having seen several prints of paintings and wonderful reports could not do this, personal staff a little patience but we are many lay people, need the things explained well, I put the code in several places but does not work, I do not declare variables at the end and asking how they are optional, my version is 1.9. Please help me.

Thanks
In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Rahim Ahmad -

for moodle 1.9.10 version is the same code for time tracker..why i use this code in moodle 1.9.10 cannot run..please help me..

In reply to Ne Nashev

Re: patch to make logs more readable and usable

by Hajjej Mohamed Ala Eddine -

Hello,
I try to add these codes in the page / course / lib.php but the patch does not work is that you can tell me exactly where to add the code
Thank you in advance