--- loncom/interface/lonhtmlcommon.pm 2010/06/02 05:34:27 1.274
+++ loncom/interface/lonhtmlcommon.pm 2010/06/09 16:17:00 1.276
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.274 2010/06/02 05:34:27 droeschl Exp $
+# $Id: lonhtmlcommon.pm,v 1.276 2010/06/09 16:17:00 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -927,7 +927,7 @@ Returns: none
=item Increment_PrgWin
-Increment the count of items completed for the progress window by 1.
+Increment the count of items completed for the progress window by $step or 1 if no step is provided.
Inputs:
@@ -940,6 +940,8 @@ Inputs:
=item $extraInfo A description of the items being iterated over. Typically
'student'.
+=item $step (optional) counter step. Will be set to default 1 if ommited.
+
=back
Returns: none
@@ -1049,11 +1051,22 @@ sub Update_PrgWin {
# increment progress state
sub Increment_PrgWin {
- my ($r,$prog_state,$extraInfo)=@_;
- $$prog_state{'done'}++;
+ my ($r,$prog_state,$extraInfo,$step)=@_;
+ if ($step !~ /^\d+$/) {
+ $step = 1; # default
+ }
+ $$prog_state{'done'} += $step;
+
+ # Catch (max modulo step) <> 0
+ my $current = $$prog_state{'done'};
+ my $last = ($$prog_state{'max'} - $current);
+ if ($last <= 0) {
+ $last = 1;
+ $current = $$prog_state{'max'};
+ }
+
my $time_est= (&Time::HiRes::time() - $$prog_state{'firststart'})/
- $$prog_state{'done'} *
- ($$prog_state{'max'}-$$prog_state{'done'});
+ $current * $last;
$time_est = int($time_est);
#
my $min = int($time_est/60);
@@ -1100,7 +1113,7 @@ sub Increment_PrgWin {
$$prog_state{'window'}.'.document.'.
$$prog_state{'formname'}.'.'.
$$prog_state{'inputname'}.'.value="'.
- $$prog_state{'done'}.'/'.$$prog_state{'max'}.
+ $current.'/'.$$prog_state{'max'}.
': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'
));
$$prog_state{'laststart'}=&Time::HiRes::time();