Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
/lib/ -> statslib.php (source)

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

(no description)

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1841 lines (69 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 27 functions


Functions that are not part of a class:

stats_progress($ident)   X-Ref
Print daily cron progress

param: string $ident

stats_run_query($sql, $parameters = array()   X-Ref
Execute individual daily statistics queries

return: boolean success
param: string $sql The query to run

stats_cron_daily($maxdays=1)   X-Ref
Execute daily statistics gathering

return: boolean success
param: int $maxdays maximum number of days to be processed

stats_cron_weekly()   X-Ref
Execute weekly statistics gathering

return: boolean success

stats_cron_monthly()   X-Ref
Execute monthly statistics gathering

return: boolean success

stats_get_start_from($str)   X-Ref
Return starting date of stats processing

return: int timestamp
param: string $str name of table - daily, weekly or monthly

stats_get_base_daily($time=0)   X-Ref
Start of day

return: int start of day
param: int $time timestamp

stats_get_base_weekly($time=0)   X-Ref
Start of week

return: int start of week
param: int $time timestamp

stats_get_base_monthly($time=0)   X-Ref
Start of month

return: int start of month
param: int $time timestamp

stats_get_next_day_start($time)   X-Ref
Start of next day

return: start of next day
param: int $time timestamp

stats_get_next_week_start($time)   X-Ref
Start of next week

return: start of next week
param: int $time timestamp

stats_get_next_month_start($time)   X-Ref
Start of next month

return: start of next month
param: int $time timestamp

stats_clean_old()   X-Ref
Remove old stats data


stats_get_parameters($time,$report,$courseid,$mode,$roleid=0)   X-Ref
No description

stats_get_view_actions()   X-Ref
No description

stats_get_post_actions()   X-Ref
No description

stats_get_action_names($str)   X-Ref
No description

stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth)   X-Ref
No description

stats_get_report_options($courseid,$mode)   X-Ref
No description

stats_fix_zeros($stats,$timeafter,$timestr,$line2=true,$line3=false)   X-Ref
Fix missing entries in the statistics.

This creates a dummy stat when nothing happened during a day/week/month.

return: array of fixed statistics.
param: array $stats array of statistics.
param: int $timeafter unused.
param: string $timestr type of statistics to generate (dayly, weekly, monthly).
param: boolean $line2
param: boolean $line3

stats_compare_times($a,$b)   X-Ref
No description

stats_check_uptodate($courseid=0)   X-Ref
No description

stats_temp_table_create()   X-Ref
Create temporary tables to speed up log generation


stats_temp_table_drop()   X-Ref
Deletes summary logs table for stats calculation


stats_temp_table_setup()   X-Ref
Fills the temporary stats tables with new data

This function is meant to be called once at the start of stats generation

return: bool success (true) or failure(false)
param: int timestart timestamp of the start time of logs view
param: int timeend timestamp of the end time of logs view

stats_temp_table_fill($timestart, $timeend)   X-Ref
Fills the temporary stats tables with new data

This function is meant to be called to get a new day of data

return: bool success (true) or failure(false)
param: int timestamp of the start time of logs view
param: int timestamp of the end time of logs view

stats_temp_table_clean()   X-Ref
Deletes summary logs table for stats calculation

return: bool success (true) or failure(false)