version 1.4, 2014/07/31 15:45:31
|
version 1.5, 2014/07/31 15:57:24
|
Line 93 sub main {
|
Line 93 sub main {
|
# (b) value of domain item in query string |
# (b) value of domain item in query string |
# (c) default login domain for current server |
# (c) default login domain for current server |
# |
# |
|
|
if (($Apache::lonnet::env{'user.name'}) && ($Apache::lonnet::env{'user.domain'})) { |
if (($Apache::lonnet::env{'user.name'}) && ($Apache::lonnet::env{'user.domain'})) { |
my $q = CGI->new; |
my $q = CGI->new; |
%params = $q->Vars; |
%params = $q->Vars; |
Line 101 sub main {
|
Line 100 sub main {
|
if ($params{'type'} eq 'Community') { |
if ($params{'type'} eq 'Community') { |
$crstype = $params{'type'}; |
$crstype = $params{'type'}; |
} |
} |
if ($params{'fixeddom'}) { |
if ($params{'fixeddom'}) { $reqdom = $params{'fixeddom'} } |
$reqdom = $params{'fixeddom'}; |
|
} |
|
} |
} |
if (($reqdom eq '') && ($ENV{'QUERY_STRING'})) { |
if (($reqdom eq '') && ($ENV{'QUERY_STRING'})) { |
&LONCAPA::loncgi::cgi_getitems($ENV{'QUERY_STRING'},\%gets); |
&LONCAPA::loncgi::cgi_getitems($ENV{'QUERY_STRING'},\%gets); |
Line 125 sub main {
|
Line 122 sub main {
|
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>$script."?domain=$reqdom", |
({href=>$script."?domain=$reqdom", |
text=>"Content disk usage"}); |
text=>"Content disk usage"}); |
if ($params{'gosearch'}) { |
if ( ($params{'gosearch'}) || ($params{'sortby'}) ) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>$script."?domain=$reqdom", |
({href=>$script."?domain=$reqdom", |
text=>"Result"}); |
text=>"Result"}); |
Line 138 sub main {
|
Line 135 sub main {
|
&Apache::lonhtmlcommon::breadcrumbs('Course/Community status'). |
&Apache::lonhtmlcommon::breadcrumbs('Course/Community status'). |
'<h2>'.&Apache::lonlocal::mt('Quotas for uploaded course content').'</h2>'. |
'<h2>'.&Apache::lonlocal::mt('Quotas for uploaded course content').'</h2>'. |
'<h3>'.$domdesc.'</h3>'); |
'<h3>'.$domdesc.'</h3>'); |
|
my $changejs = <<"ENDSCRIPT"; |
|
<script> |
|
function changeSort(sortby) { |
|
document.filterpicker.sortby.value = sortby; |
|
if (('$params{'sortby'}' == sortby) && ('$params{'sortorder'}' != 'rev')) { |
|
document.filterpicker.sortorder.value = 'rev'; |
|
} |
|
document.filterpicker.submit(); |
|
} |
|
</script> |
|
ENDSCRIPT |
|
|
|
print($changejs); |
|
|
# |
# |
# If this is for an authenticated user (i.e., not IP-based access) |
# If this is for an authenticated user (i.e., not IP-based access) |
Line 166 sub main {
|
Line 176 sub main {
|
$script,\$numtitles, |
$script,\$numtitles, |
'quotacheck',undef,undef,undef, |
'quotacheck',undef,undef,undef, |
\@codetitles,$reqdom,'quotacheck',$reqdom)); |
\@codetitles,$reqdom,'quotacheck',$reqdom)); |
if ($params{'gosearch'}) { |
if ( ($params{'gosearch'}) || ($params{'sortby'}) ) { |
if ($params{'official'} eq 'on') { |
if ($params{'official'} eq 'on') { |
$Apache::lonnet::env{'form.state'} = $params{'state'}; |
$Apache::lonnet::env{'form.state'} = $params{'state'}; |
} |
} |
|
# Sort by course title (cdesc) as default, not reversed |
|
my $sortby = $params{'sortby'}; |
|
unless ($sortby =~ m{^(quota|current_disk_usage|percent|quotatype|instcode)$}) { |
|
$sortby = 'cdesc'; |
|
} |
|
my $sortorder; |
|
if ($params{'sortorder'} eq 'rev') { $sortorder = 'rev'; } |
|
|
my %courses = &Apache::loncommon::search_courses($reqdom,$crstype,$filter,$numtitles, |
my %courses = &Apache::loncommon::search_courses($reqdom,$crstype,$filter,$numtitles, |
undef,undef,undef,\@codetitles); |
undef,undef,undef,\@codetitles); |
my @showcourses = keys(%courses); |
my @showcourses = keys(%courses); |
&print_usage($lonhost,$reqdom,\@showcourses); |
&print_usage($lonhost,$reqdom,\@showcourses,$sortby,$sortorder); |
} |
} |
|
|
print(&Apache::loncommon::end_page()); |
print(&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
Line 184 sub main {
|
Line 203 sub main {
|
} |
} |
|
|
sub print_usage { |
sub print_usage { |
my ($lonhost,$dom,$courses) = @_; |
my ($lonhost,$dom,$courses,$sortby,$sortorder) = @_; |
my @domains = &Apache::lonnet::current_machine_domains(); |
my @domains = &Apache::lonnet::current_machine_domains(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
my $domain = &Apache::lonnet::host_domain($lonhost); |
my $domain = &Apache::lonnet::host_domain($lonhost); |
Line 225 sub print_usage {
|
Line 244 sub print_usage {
|
@showcourses = keys(%courseshash); |
@showcourses = keys(%courseshash); |
} |
} |
} |
} |
|
|
if (@showcourses) { |
if (@showcourses) { |
print(&Apache::loncommon::start_data_table(). |
print(&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row() |
'<th>'.&Apache::lonlocal::mt('Course Type').'</th>'. |
.'<th><a href="javascript:changeSort('."'quotatype'".')">' |
'<th>'.&Apache::lonlocal::mt('Course Title').'</th>'. |
.&Apache::lonlocal::mt('Course Type') |
'<th>'.&Apache::lonlocal::mt('Institutional Code').'</th>'. |
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
'<th>'.&Apache::lonlocal::mt('Quota (MB)').'</th>'. |
.'<th><a href="javascript:changeSort('."'cdesc'".')">' |
'<th>'.&Apache::lonlocal::mt('Usage (MB)').'</th>'. |
.&Apache::lonlocal::mt('Course Title') |
'<th>'.&Apache::lonlocal::mt('Percent usage').'</th>'. |
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
&Apache::loncommon::end_data_table_header_row()); |
.'<th><a href="javascript:changeSort('."'instcode'".')">' |
|
.&Apache::lonlocal::mt('Institutional Code') |
|
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
|
.'<th><a href="javascript:changeSort('."'quota'".')">' |
|
.&Apache::lonlocal::mt('Quota (MB)') |
|
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
|
.'<th><a href="javascript:changeSort('."'current_disk_usage'".')">' |
|
.&Apache::lonlocal::mt('Usage (MB)') |
|
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
|
.'<th><a href="javascript:changeSort('."'percent'".')">' |
|
.&Apache::lonlocal::mt('Percent usage') |
|
.'<span class="LC_fontsize_small"> ▼</span></a></th>' |
|
.&Apache::loncommon::end_data_table_header_row()); |
|
|
|
my $usagehash = {}; # Sortable hash of courses |
foreach my $cid (@showcourses) { |
foreach my $cid (@showcourses) { |
my %courseinfo=&Apache::lonnet::coursedescription($cid,{'one_time' => '1'}); |
my %courseinfo=&Apache::lonnet::coursedescription($cid,{'one_time' => '1'}); |
my $cdesc = $courseinfo{'description'}; |
my $cdesc = $courseinfo{'description'}; |
Line 285 sub print_usage {
|
Line 319 sub print_usage {
|
foreach my $subdir ('docs','supplemental') { |
foreach my $subdir ('docs','supplemental') { |
$current_disk_usage += &Apache::lonnet::diskusage($dom,$cnum,"userfiles/$subdir",1); |
$current_disk_usage += &Apache::lonnet::diskusage($dom,$cnum,"userfiles/$subdir",1); |
} |
} |
$current_disk_usage=int($current_disk_usage/1024); |
|
} |
} |
my $percent; |
my $percent; |
if (($quota == 0) || ($quota =~ /[^\d\.]/)) { |
if (($quota == 0) || ($quota =~ /[^\d\.]/)) { |
Line 296 sub print_usage {
|
Line 329 sub print_usage {
|
$current_disk_usage = sprintf("%.0f",$current_disk_usage); |
$current_disk_usage = sprintf("%.0f",$current_disk_usage); |
$quota = sprintf("%.0f",$quota); |
$quota = sprintf("%.0f",$quota); |
$percent = sprintf("%.0f",$percent); |
$percent = sprintf("%.0f",$percent); |
|
|
|
# Enter sortable data into hash |
|
$usagehash->{ $cid } = { |
|
"quotatype" => $quotatype, |
|
"cdesc" => $cdesc, |
|
"instcode" => $instcode, |
|
"quota" => $quota, |
|
"current_disk_usage" => $current_disk_usage, |
|
"percent" => $percent, |
|
}; |
|
} |
|
|
|
# Sort courses by $sortby. "cdesc" is the default. |
|
my @sorted_courses; |
|
if ($sortby =~ m{^(quota|current_disk_usage|percent)$}) { |
|
# Numerical fields |
|
if ($sortorder eq "rev") { |
|
@sorted_courses = sort { |
|
$usagehash->{$a}->{$sortby} <=> $usagehash->{$b}->{$sortby} |
|
or |
|
uc($usagehash->{$a}->{"cdesc"}) cmp uc($usagehash->{$b}->{"cdesc"}) |
|
} (keys(%{$usagehash})); |
|
} else { |
|
@sorted_courses = sort { |
|
$usagehash->{$b}->{$sortby} <=> $usagehash->{$a}->{$sortby} |
|
or |
|
uc($usagehash->{$a}->{"cdesc"}) cmp uc($usagehash->{$b}->{"cdesc"}) |
|
} (keys(%{$usagehash})); |
|
} |
|
} elsif ($sortby =~ m{^(cdesc|quotatype|instcode)$}) { |
|
# String fields |
|
if ($sortorder eq "rev") { |
|
@sorted_courses = sort { |
|
uc($usagehash->{$b}->{$sortby}) cmp uc($usagehash->{$a}->{$sortby}) |
|
or |
|
uc($usagehash->{$a}->{"cdesc"}) cmp uc($usagehash->{$b}->{"cdesc"}) |
|
} (keys(%{$usagehash})); |
|
} else { |
|
@sorted_courses = sort { |
|
uc($usagehash->{$a}->{$sortby}) cmp uc($usagehash->{$b}->{$sortby}) |
|
or |
|
uc($usagehash->{$a}->{"cdesc"}) cmp uc($usagehash->{$b}->{"cdesc"}) |
|
} (keys(%{$usagehash})); |
|
} |
|
} |
|
|
|
# Print data for each course. |
|
foreach my $course (@sorted_courses) { |
print(&Apache::loncommon::start_data_table_row(). |
print(&Apache::loncommon::start_data_table_row(). |
'<td>'.$quotatype.'</td>'. |
'<td>'.$usagehash->{$course}->{"quotatype"}.'</td>'. |
'<td>'.$cdesc.'</td>'. |
'<td>'.$usagehash->{$course}->{"cdesc"}.'</td>'. |
'<td>'.$instcode.'</td>'. |
'<td>'.$usagehash->{$course}->{"instcode"}.'</td>'. |
'<td>'.$quota.'</td>'. |
'<td>'.$usagehash->{$course}->{"quota"}.'</td>'. |
'<td>'.$current_disk_usage.'</td>'. |
'<td>'.$usagehash->{$course}->{"current_disk_usage"}.'</td>'. |
'<td>'.$percent.'</td>'. |
'<td>'.$usagehash->{$course}->{"percent"}.'</td>'. |
&Apache::loncommon::end_data_table_row() |
&Apache::loncommon::end_data_table_row() |
); |
); |
} |
} |