Skip to content

Commit

Permalink
MDL-67752 course: Provide the active user stats during the registration
Browse files Browse the repository at this point in the history
These new stats provide better insight as they only consider recently
active users and active enrolments only.
  • Loading branch information
mudrd8mz committed Feb 27, 2020
1 parent c268c1b commit 4e907e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lang/en/hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['activeparticipantnumberaverage'] = 'Average number of recently active participants ({$a})';
$string['activeusersnumber'] = 'Number of recently active users ({$a})';
$string['analyticsactions'] = 'Number of actions taken on generated predictions ({$a})';
$string['analyticsactionsnotuseful'] = 'Number of actions marking a prediction as not useful ({$a})';
$string['analyticsenabledmodels'] = 'Number of enabled prediction models ({$a})';
Expand Down
7 changes: 7 additions & 0 deletions lib/classes/hub/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class registration {
],
// Analytics stats added in Moodle 3.7.
2019022200 => ['analyticsenabledmodels', 'analyticspredictions', 'analyticsactions', 'analyticsactionsnotuseful'],
// Active users stats added in Moodle 3.9.
2020022600 => ['activeusers', 'activeparticipantnumberaverage'],
];

/** @var Site privacy: not displayed */
Expand Down Expand Up @@ -168,13 +170,15 @@ public static function get_site_info($defaults = []) {
// Statistical data.
$siteinfo['courses'] = $DB->count_records('course') - 1;
$siteinfo['users'] = $DB->count_records('user', array('deleted' => 0));
$siteinfo['activeusers'] = $DB->count_records_select('user', 'deleted = ? AND lastlogin > ?', [0, time() - DAYSECS * 30]);
$siteinfo['enrolments'] = $DB->count_records('role_assignments');
$siteinfo['posts'] = $DB->count_records('forum_posts');
$siteinfo['questions'] = $DB->count_records('question');
$siteinfo['resources'] = $DB->count_records('resource');
$siteinfo['badges'] = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
$siteinfo['issuedbadges'] = $DB->count_records('badge_issued');
$siteinfo['participantnumberaverage'] = average_number_of_participants();
$siteinfo['activeparticipantnumberaverage'] = average_number_of_participants(true, time() - DAYSECS * 30);
$siteinfo['modulenumberaverage'] = average_number_of_courses_modules();

// Version and url.
Expand Down Expand Up @@ -229,6 +233,7 @@ public static function get_stats_summary($siteinfo) {
'moodlerelease' => get_string('sitereleasenum', 'hub', $moodlerelease),
'courses' => get_string('coursesnumber', 'hub', $siteinfo['courses']),
'users' => get_string('usersnumber', 'hub', $siteinfo['users']),
'activeusers' => get_string('activeusersnumber', 'hub', $siteinfo['activeusers']),
'enrolments' => get_string('roleassignmentsnumber', 'hub', $siteinfo['enrolments']),
'posts' => get_string('postsnumber', 'hub', $siteinfo['posts']),
'questions' => get_string('questionsnumber', 'hub', $siteinfo['questions']),
Expand All @@ -237,6 +242,8 @@ public static function get_stats_summary($siteinfo) {
'issuedbadges' => get_string('issuedbadgesnumber', 'hub', $siteinfo['issuedbadges']),
'participantnumberaverage' => get_string('participantnumberaverage', 'hub',
format_float($siteinfo['participantnumberaverage'], 2)),
'activeparticipantnumberaverage' => get_string('activeparticipantnumberaverage', 'hub',
format_float($siteinfo['activeparticipantnumberaverage'], 2)),
'modulenumberaverage' => get_string('modulenumberaverage', 'hub',
format_float($siteinfo['modulenumberaverage'], 2)),
'mobileservicesenabled' => get_string('mobileservicesenabled', 'hub', $mobileservicesenabled),
Expand Down

0 comments on commit 4e907e7

Please sign in to comment.