Commit 2516af1d authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge "Bug 1802386: Ability to list/sort the quota used for users"

parents 2ac68757 98223757
......@@ -1197,6 +1197,7 @@ $string['selectednusers'] = array(
1 => '%s users selected',
);
$string['remoteuser'] = 'Remote username';
$string['quotapercent'] = 'Quota used';
$string['userreports'] = 'User reports';
$string['userreportsdescription'] = 'View or download information about the users you selected on the search page.';
$string['unabletodeleteself1'] = 'You are not allowed to delete yourself.';
......
......@@ -547,6 +547,12 @@ function userdetails_statistics_headers($extra, $urllink) {
'class' => format_class($extra, 'remotename'),
'link' => format_goto($urllink . '&sort=remotename', $extra, array('sort'), 'remotename')
),
array(
'id' => 'quotapercent',
'name' => get_string('quotapercent', 'admin'),
'class' => format_class($extra, 'quotapercent'),
'link' => format_goto($urllink . '&sort=quotapercent', $extra, array('sort'), 'quotapercent')
),
array(
'id' => 'lastlogin',
'name' => get_string('lastlogin', 'admin'),
......@@ -634,6 +640,7 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
case "username":
case "email":
case "remotename":
case "quotapercent":
case "studentid":
$orderby = " " . $sorttype . " " . (!empty($extra['sortdesc']) ? 'DESC' : 'ASC') . ", CONCAT (u.firstname, ' ', u.lastname)";
break;
......@@ -647,7 +654,8 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
$sql = "SELECT u.id, u.firstname, u.lastname, u.username, u.preferredname AS displayname,
u.lastlogin, u.email, u.studentid, u.ctime,
(SELECT remoteusername FROM {auth_remote_user} aru WHERE aru.localusr = u.id LIMIT 1) AS remotename
(SELECT remoteusername FROM {auth_remote_user} aru WHERE aru.localusr = u.id LIMIT 1) AS remotename,
((u.quotaused * 1.0)/ u.quota) AS quotapercent, u.quota, u.quotaused
" . $fromsql . $wheresql . "
ORDER BY " . $orderby;
if (empty($extra['csvdownload'])) {
......@@ -660,10 +668,13 @@ function userdetails_stats_table($limit, $offset, $extra, $institution, $urllink
foreach ($data as $item) {
$item->profileurl = profile_url($item->id);
$item->lastlogin = $item->lastlogin ? format_date(strtotime($item->lastlogin)) : ' ';
$item->quotapercent_format = round($item->quotapercent * 100);
$item->quota_format = display_size($item->quota);
$item->quotaused_format = !empty($item->quotaused) ? display_size($item->quotaused) : 0;
}
if (!empty($extra['csvdownload'])) {
$csvfields = array('firstname', 'lastname', 'email', 'studentid',
'displayname', 'username', 'remotename', 'lastlogin');
'displayname', 'username', 'remotename', 'quotapercent_format', 'lastlogin');
$USER->set_download_file(generate_csv($data, $csvfields), $institution . 'userdetailsstatistics.csv', 'text/csv');
}
$result['csv'] = true;
......
......@@ -8,6 +8,7 @@
{if $columns.displayname}<td><a href="{$item->profileurl}">{$item->displayname}</a></td>{/if}
{if $columns.username}<td><a href="{$item->profileurl}">{$item->username}</a></td>{/if}
{if $columns.remotename}<td>{$item->remotename}</td>{/if}
{if $columns.quotapercent}<td>{$item->quotapercent_format}% <span class="text-small text-midtone">({$item->quotaused_format}/{$item->quota_format})</span></td>{/if}
{if $columns.lastlogin}<td>{$item->lastlogin}</td>{/if}
</tr>
{/foreach}
......@@ -2,25 +2,36 @@
Feature: Institution statistics are displayed correctly
In order to view information about an institution
As an admin
So I can benefit from seeing the current state and history of an institution
So I can benefit from seeing the current user detail state of an institution
Background:
Given the following "institutions" exist:
| name | displayname | registerallowed | registerconfirm |
| instone | Institution One | ON | ON |
| insttwo | Institution Two | ON | ON |
And the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | mahara | internal | member |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | instone | internal | member |
| UserB | Kupuh1pa! | UserB@example.org | Bob | User | instone | internal | member |
| UserC | Kupuh1pa! | UserC@example.org | Cecilia | User | mahara | internal | member |
| UserC | Kupuh1pa! | UserC@example.org | Cecilia | User | instone | internal | member |
Scenario: Viewing user details statistics
Given I log in as "UserA" with password "Kupuh1pa!"
And I choose "Files" in "Create" from main menu
And I attach the file "Image1.jpg" to "File"
And I attach the file "Image1.jpg" to "File"
And I attach the file "Image1.jpg" to "File"
And I log out
Scenario: Viewing user statistics
Given I log in as "admin" with password "Kupuh1pa!"
# Users without an institution
When I choose "Reports" from administration menu
And I press "Configure report"
And I set the select2 value "Institution One" for "reportconfigform_institution"
And I set the select2 value "People overview" for "reportconfigform_typesubtype"
And I set the select2 value "User details" for "reportconfigform_typesubtype"
And I fill in "To:" with "+1 day" date in the format "Y/m/d"
And I expand the section "Columns"
And I check "Quota used"
And I press "Submit"
Then I should see "People overview | Institution One"
Then I should see "User details | Institution One"
And I should see "8%" in the "Angela" row
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment