--- loncom/interface/londocs.pm 2016/08/06 20:00:29 1.484.2.63 +++ loncom/interface/londocs.pm 2016/08/06 21:53:02 1.484.2.64 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.63 2016/08/06 20:00:29 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.64 2016/08/06 21:53:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4905,7 +4905,39 @@ sub handler { 'webctce4' => 'WebCT 4 Campus Edition', ); # ----------------------------------------------------------------------------- + # Calculate free quota space for a user or course. + my $quotatype = 'unofficial'; + if ($crstype eq 'Community') { + $quotatype = 'community'; + } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { + $quotatype = 'official'; + } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { + $quotatype = 'textbook'; + } + my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom, + 'course',$quotatype); # expressed in MB + my $current_disk_usage = 0; + foreach my $subdir ('docs','supplemental') { + $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum, + "userfiles/$subdir",1); # expressed in kB + } + my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage); + my $usage = $current_disk_usage/1024; # in MB + my $quota = $disk_quota; + my $percent; + if ($disk_quota == 0) { + $percent = 100.0; + } else { + $percent = 100*($current_disk_usage/$disk_quota); + } + $usage = sprintf("%.2f",$usage); + $quota = sprintf("%.2f",$quota); + $percent = sprintf("%.0f",$percent); + my $quotainfo = '

'.&mt('Currently using [_1] of the [_2] available.', + $percent.'%',$quota.' MB').'

'; + my $fileupload=(< FIUP