Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/lib/ -> statslib.php (source)

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

(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: 2 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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
return: array of fixed statistics.

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

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

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

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

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

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