[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface londocs.pm

raeburn raeburn at source.lon-capa.org
Sat Aug 6 17:53:02 EDT 2016


raeburn		Sat Aug  6 21:53:02 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	londocs.pm 
  Log:
  - For 2.11
    - Backport 1.595 (part), 1.605 
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.63 loncom/interface/londocs.pm:1.484.2.64
--- loncom/interface/londocs.pm:1.484.2.63	Sat Aug  6 20:00:29 2016
+++ loncom/interface/londocs.pm	Sat Aug  6 21:53:02 2016
@@ -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 @@
                 '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 = '<p>'.&mt('Currently using [_1] of the [_2] available.',
+                              $percent.'%',$quota.' MB').'</p>';
+
 	my $fileupload=(<<FIUP);
+        $quotainfo
 	$lt{'file'}:<br />
 	<input type="file" name="uploaddoc" size="40" />
 FIUP




More information about the LON-CAPA-cvs mailing list