[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 11 Jan 2005 19:38:53 -0000


albertel		Tue Jan 11 14:38:53 2005 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm 
  Log:
  - BUG#3799 stop sayin you have 1800 seconds.
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.191 loncom/homework/lonhomework.pm:1.192
--- loncom/homework/lonhomework.pm:1.191	Wed Dec 22 17:08:17 2004
+++ loncom/homework/lonhomework.pm	Tue Jan 11 14:38:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.191 2004/12/22 22:08:17 albertel Exp $
+# $Id: lonhomework.pm,v 1.192 2005/01/11 19:38:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -320,7 +320,7 @@
 	    &Apache::lonxml::debug("looking for accesstime $first_access");
 	    if (!$first_access) {
 		$status='NOT_YET_VIEWED';
-		$datemsg=' '.$interval.' seconds';
+		$datemsg=&seconds_to_human_length($interval);
 	    } else {
 		my $newdate=localtime($first_access+$interval);
 		if (time > ($first_access+$interval)) {
@@ -348,6 +348,25 @@
     return ($status,$datemsg);
 }
 
+sub seconds_to_human_length {
+    my ($length)=@_;
+
+    my $seconds=$length%60; $length=int($length/60);
+    my $minutes=$length%60; $length=int($length/60);
+    my $hours=$length%24;   $length=int($length/24);
+    my $days=$length;
+
+    my $timestr;
+    if ($days > 0) { $timestr.=&mt('[quant,_1,day]',$days); }
+    if ($hours > 0) { $timestr.=($timestr?", ":"").
+			  &mt('[quant,_1,hour]',$hours); }
+    if ($minutes > 0) { $timestr.=($timestr?", ":"").
+			    &mt('[quant,_1,minute]',$minutes); }
+    if ($seconds > 0) { $timestr.=($timestr?", ":"").
+			    &mt('[quant,_1,second]',$seconds); }
+    return $timestr;
+}
+
 sub showhash {
     my (%hash) = @_;
     &showhashsubset(\%hash,'.');