version 1.275, 2010/06/09 14:55:22
|
version 1.278, 2010/06/10 16:14:34
|
Line 927 Returns: none
|
Line 927 Returns: none
|
|
|
=item Increment_PrgWin |
=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: |
Inputs: |
|
|
Line 940 Inputs:
|
Line 940 Inputs:
|
=item $extraInfo A description of the items being iterated over. Typically |
=item $extraInfo A description of the items being iterated over. Typically |
'student'. |
'student'. |
|
|
|
=item $step (optional) counter step. Will be set to default 1 if ommited. |
|
|
=back |
=back |
|
|
Returns: none |
Returns: none |
Line 1050 sub Update_PrgWin {
|
Line 1052 sub Update_PrgWin {
|
# increment progress state |
# increment progress state |
sub Increment_PrgWin { |
sub Increment_PrgWin { |
my ($r,$prog_state,$extraInfo,$step)=@_; |
my ($r,$prog_state,$extraInfo,$step)=@_; |
if ($step !~ /^\d+$/) { |
if ( ($step == 0) || ($step !~ /^\d+(\.\d+)*$/) ) { |
$step = 1; # default |
$step = 1; # default |
} |
} |
$$prog_state{'done'} += $step; |
$$prog_state{'done'} += $step; |
Line 1069 sub Increment_PrgWin {
|
Line 1071 sub Increment_PrgWin {
|
# |
# |
my $min = int($time_est/60); |
my $min = int($time_est/60); |
my $sec = $time_est % 60; |
my $sec = $time_est % 60; |
# |
|
my $str; |
|
if ($min == 0 && $sec > 1) { |
|
$str = '[_1] seconds'; |
|
} elsif ($min == 1 && $sec > 1) { |
|
$str = '1 minute [_2] seconds'; |
|
} elsif ($min == 1 && $sec < 2) { |
|
$str = '1 minute'; |
|
} elsif ($min < 10 && $sec > 1) { |
|
$str = '[_1] minutes, [_2] seconds'; |
|
} elsif ($min >= 10 || $sec < 2) { |
|
$str = '[_1] minutes'; |
|
} |
|
$time_est = &mt($str,$min,$sec); |
|
# |
|
my $lasttime = &Time::HiRes::time()-$$prog_state{'laststart'}; |
my $lasttime = &Time::HiRes::time()-$$prog_state{'laststart'}; |
if ($lasttime > 9) { |
if ($lasttime > 9) { |
$lasttime = int($lasttime); |
$lasttime = int($lasttime); |
Line 1092 sub Increment_PrgWin {
|
Line 1080 sub Increment_PrgWin {
|
} else { |
} else { |
$lasttime = sprintf("%3.2f",$lasttime); |
$lasttime = sprintf("%3.2f",$lasttime); |
} |
} |
if ($lasttime == 1) { |
|
$lasttime = '('.$lasttime.' '.&mt('second for').' '.$extraInfo.')'; |
$sec = 0 if ($min >= 10); # Don't show seconds if remaining time >= 10 min. |
} else { |
$sec = 1 if ( ($min == 0) && ($sec == 0) ); # Little cheating: pretend to have 1 second remaining instead of 0 to have something to display |
$lasttime = '('.$lasttime.' '.&mt('seconds for').' '.$extraInfo.')'; |
|
} |
my $timeinfo = |
# |
&mt('[_1]/[_2]:' |
my $user_browser = $env{'browser.type'} if (exists($env{'browser.type'})); |
.' [quant,_3,minute,minutes,] [quant,_4,second ,seconds ,]remaining' |
my $user_os = $env{'browser.os'} if (exists($env{'browser.os'})); |
.' ([quant,_5,second] for '.$extraInfo.')', |
if (! defined($user_browser) || ! defined($user_os)) { |
$current, |
(undef,$user_browser,undef,undef,undef,$user_os) = |
$$prog_state{'max'}, |
&Apache::loncommon::decode_user_agent(); |
$min, |
} |
$sec, |
if ($user_browser eq 'explorer' && $user_os =~ 'mac') { |
$lasttime); |
$lasttime = ''; |
|
} |
|
&r_print($r,&Apache::lonhtmlcommon::scripttag( |
&r_print($r,&Apache::lonhtmlcommon::scripttag( |
$$prog_state{'window'}.'.document.'. |
$$prog_state{'window'}.'.document.'. |
$$prog_state{'formname'}.'.'. |
$$prog_state{'formname'}.'.'. |
$$prog_state{'inputname'}.'.value="'. |
$$prog_state{'inputname'}.'.value="'.$timeinfo.'";' |
$current.'/'.$$prog_state{'max'}. |
|
': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";' |
|
)); |
)); |
$$prog_state{'laststart'}=&Time::HiRes::time(); |
$$prog_state{'laststart'}=&Time::HiRes::time(); |
} |
} |