Moodle plugins directory: Timestat | Moodle.org
Timestat
This block measure time of real activity done by Moodle users.
Installation
Install block in standard way (copy it to '/moodle/blocks' folder and click 'Notifications' in admin panel) or install it directly from the Admin panel.
Usage
The block only counts the time on the pages to which it has been added, so you need to add the block on the pages where you want to count the time. If you want to add the block on the course page and on all activity pages at once, please refer to the following documentation: https://docs.moodle.org/400/en/Block_settings#Making_a_block_sticky_throughout_a_course
The block accounts for student inactivity, identified by no interactions such as clicks or scrolling. To prevent counting time during periods of inactivity, the tracking feature automatically pauses when a student is inactive for an extended period. You can customize the maximum inactivity time in the settings. It's also possible to adjust how often the recorded time is saved.
The block offers a visual time counter, visible to users with specific permissions (block/timestat:viewtimer) or to all users enrolled in the course, if enabled in the settings. Time is tracked even if the block or counter isn't visible to a student. Additionally, the block includes a link to a detailed report on time spent, with filters for course, activity, and user. Initially, only roles such as editing teachers, teachers, course creators, managers, and admins can access this report. The 'block/timestat:viewreport' capability allows extending access to other roles.
To use the block within the Quiz attempt page, configure the quiz settings to 'Show blocks during the attempt' by going to Quiz > Edit Settings > Appearance > Show more.
You can access the plugin settings from Site Administration > Plugins > Blocks > Timestat.
More information
The version of the plugin for Moodle 2.9 and earlier was developed by: Barbara Dębska Łukasz Musiał Łukasz Sanokowski
Upgrade from Moodle 1.9 to Moodle 2.5 version was made thanks to contribution of: Classroom Revolution Lib Ertea Mart van der Niet Joseph Thibault
Upgrade from Moodle 3.11 to Moodle 4.2 version was made thanks to contribution of: Institut Obert de Catalunya (IOC)
License
Licensed under the GNU GPL License.
Many thanks for sharing this plugin with the Moodle community.
Please review the validation results and fix all of the issues mentioned. These changes are typically pretty easy to make but if you have any question just le us know.
Validation warnings:
Maturity information ($plugin->maturity) not found in version.php
Release name ($plugin->release) not found in version.php
Moodle requirements ($plugin->requires) not found in version.php
I also noticed some PHP notices when adding the block to a course:
Notice: Undefined index: datefrom in /var/www/m26/blocks/timestat/index.php on line 40
Notice: Use of undefined constant year - assumed 'year' in /var/www/m26/blocks/timestat/index.php on line 43
Notice: Use of undefined constant month - assumed 'month' in /var/www/m26/blocks/timestat/index.php on line 44
Notice: Use of undefined constant day - assumed 'day' in /var/www/m26/blocks/timestat/index.php on line 45
Notice: Use of undefined constant hour - assumed 'hour' in /var/www/m26/blocks/timestat/index.php on line 46
Notice: Use of undefined constant minute - assumed 'minute' in /var/www/m26/blocks/timestat/index.php on line 47
Notice: Undefined index: dateto in /var/www/m26/blocks/timestat/index.php on line 52
Notice: Use of undefined constant year - assumed 'year' in /var/www/m26/blocks/timestat/index.php on line 55
Notice: Use of undefined constant month - assumed 'month' in /var/www/m26/blocks/timestat/index.php on line 56
Notice: Use of undefined constant day - assumed 'day' in /var/www/m26/blocks/timestat/index.php on line 57
Notice: Use of undefined constant hour - assumed 'hour' in /var/www/m26/blocks/timestat/index.php on line 58
Notice: Use of undefined constant minute - assumed 'minute' in /var/www/m26/blocks/timestat/index.php on line 59
Notice: Use of undefined constant userid - assumed 'userid' in /var/www/m26/blocks/timestat/locallib.php on line 828
Please review http://docs.moodle.org/dev/Plugin_validation#Recommended_URLs and then edit the plugin entry to provide the source, tracker, and documentation URLs that will enable others in the community to more actively participate in using and maintaining this plugin. Please consider adding a screenshot of your plugin to help folks get an idea of what it looks like when installed.
I noticed that he recommended boilerplate was not used in the version.php file. The boilerplate is recommended at the beginning of each file and makes explicit the GP Llicense. You may want to review http:/docs.moole.org/dev/Coding_style#Files to learn more about the boilerplate comments.
For now, I am going to mark this plugin as needing more wok until we get thse issueresolved. Thanks for your patience with he review and approval process.
make many people really happy once it's approved and published here. It won't happen now though. When trying to test your block
functionality, I realized it fails badly on my PostgreSQL based site due to MySQLism used in queries ("column must appear in the
GROUP BY clause or be used in an aggregate function"). Queries like that are the first thing than one should unlearn from MySQL,
it is really malicious.
I really don't like that your block is modifying one of the core's database tables. If your plugin needs a database table, it
should create its own. You silently modify Moodle core datbase schema without even a notice in README and the plugin description
page. Plugins that do such things are going to be explicitly marked as potentially dangerous in this directory. I don't think it
is worth of it in your case. Also note, the 'log' table you rely on became obsolete with Moodle 2.7 so you would have to deal with
it sooner or later anyway.
It's a pitty that your current version requires hacking /lib/outputrenderers.php to make it work. Is that really necessary? I
believe that would discourage many people from even giving it a try. Let me recommend to convert your Javascript code into
a YUI3 module provided by the block and then either load the tracking JS via a block instance (so it would track only those
courses/activities where the block is created - which can easily be done globally by so called sticky block setup) or eventually
by putting the needed Javascript via the way described at http://docs.moodle.org/26/en/Header_and_footer. If it was me, I would
prefer the ability to track only selected areas - if nothing else than because of performance and privacy related reasons.
Please check for the AJAX_SCRIPT constant usage in Moodle code and see the recommended way to implement server-side scripts for
your AJAX requests (such as your lib/timestatlib.php). And again, using YUI wrappers instead of low level XMLHttpRequest() or
ActiveXObject() is strongly encouraged for multiple reasons.
As Anthony mentioned above, your code still throws PHP notices here and there. Better to avoid them. In Moodle core itself, there
is zero tolerance for them and are considered as a real bug.
Please refer to the DML API for the expected way of custom SQL queries. We do not use $CFG->prefix any more and parameters binding
(via ? or :named placeholders) is more than recommended.
I noticed that you create functions in the global PHP scope without the valid frankenstyle prefix. This is strongly discouraged in
order to prevent collisions with (current and/or future) core code or some other plugin. See
http://docs.moodle.org/dev/Coding_style#Functions_and_Methods for details.
Please avoid using the closing ?> PHP tag at the end of files. They are not needed and they may cause troubles.
It is encouraged to follow Moodle’s coding style as outlined in: http://docs.moodle.org/dev/Coding_style and
http://docs.moodle.org/dev/Coding The code checker plugin can be quite helpful in fine tuning your code and can be found at:
https://moodle.org/plugins/view.php?plugin=local_codechecker You may wish to consider using that tool to further improve your
plugin.
For now, I am going to mark this plugin as needing more work until we get at least the functionality blockers resolved. Thanks for
your patience with the review and approval process.
There is hardcoded condition that applies to your own environment only: if ($USER->id == 2 || $USER->id == 7 || $USER->id == 73) in the get_content() method. Please fix that as soon as possible to avoid unexpected behaviour on sites using your plugin.
I admit I was having issues with trying to test the functionality of the plugin as the gained reports did not reflect what I was expecting. Further and broader testing is probably required.
I am going to approve the plugin now to give a chance to receive further feedback from the Moodle community. I really like the idea, although I would probably try to implement it in slightly different way. Said that, you are cleared to land. Welcome to the Plugins directory.
Your pluging is working only when legacy log enabled? Is it in plans to use standard log in 2.7+?
Thank you in advance.
Hack in moodle/lib/outputrenderers.php:
public function standard_end_of_body_html() {
// This function is normally called from a layout.php file in {@link core_renderer::header()}
// but some of the content won't be known until later, so we return a placeholder
// for now. This will be replaced with the real content in {@link core_renderer::footer()}.
global $CFG;
return $this->unique_end_html_token;
require_once($CFG->dirroot.'/blocks/timestat/lib/timestatlib.php');
return $output;
}
Thanks
I manage quite a few moodle installations for several educational institutions at the secondary and college level.
Timestat is used by all faculty, across the board. It is the plugin that gets everybody on board and allows the tracking that makes flipping the classroom successful.
In my installations, together with iframe plugins (yeah.. I know. trusted content woud do the same ... but I like to give educators short codes), faculty can use internal and external resources tracking in detail what students do, and that seems to be a key element for all educators.
I was the one who contacted Joseph Thibault at Moodle News to organize the crowd funding that would allow Lukasz to put together a version for Moodle 2.X [Thank you Joseph and Lukasz]
As far as I a concerned this plugin should be part of Moodle core, from a purely educational point of view ,and quite frankly I hope I can get something going to make it happen.
I understand the coding objections, concerns, and suggestions raised above, my request is can we help Lukasz overcome some of the minor problems so this has a shot at becoming core?
As for the JS concerns, let me just say, that I love having the opportunity to hack the JS code to enhance or customize the tracking to allow for new and future devices and functionality. In fact I have customized several versions of the plugin based on the tracking needs of various departments and even individual educators.
Overall this plugin perform exceptionally well and I a willing to discuss its uses in details with anybody who is interested. I a also wiling to share some of the ways the JS can be customized to change the way activities are tracked.
1) Most of the issues raised above seem to have been resolved
2) Running PHP 5.4 and with Developer Mode debug I got not a single warning or notice with the plugin running and tested in different ways on v2.5 and v2.6
3) I have contacted David Mudrák to see what needs to happen in order to consider Timestat for inclusion in Moodle core [that would eliminate the need of a core or template hack]
In my case, Timestat for Moodle 2.x made it possible to finally move all of my installations to 2.6 for now and soon to 2.7 as soon as I complete additional tests.