\E)/
$1$idprefix$2$3$4/g;
+ $output=~
+ s/(\Q
)/$1$idprefix$2$3$4/g;
if ($nuploads) {
$output=~
s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi;
@@ -385,6 +428,61 @@ ENDEXT
}
$output=~
s/\<((?:input|select)[^\>]+\Qjavascript:setSubmittedPart\E)\(\s*[\'\"]([^\'\"]+)[\'\"]*\s*\)/\<$1('$2','$prefix')/gsi;
+ $output=~
+ s/\<(input[^\>]+\Qonfocus=\"javascript:disableAutoComplete\E)\(\'([^\']+)\'\)(;\")/\<$1('$idprefix$2')$3/gsi;
+ unless ($hastimer) {
+ if ($src =~ /$LONCAPA::assess_re/) {
+ %Apache::lonhomework::history =
+ &Apache::lonnet::restore($symb,$courseid,$domain,$name);
+ my $type = 'problem';
+ if ($src =~ /\.task$/) {
+ $type = 'Task';
+ }
+ my ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0',$type,$symb);
+ undef(%Apache::lonhomework::history);
+ my $probstatus = &Apache::lonnet::EXT("resource.0.problemstatus",$symb);
+ if (($status eq 'CAN_ANSWER') || (($status eq 'CANNOT_ANSWER') &&
+ (($probstatus eq 'no') || ($probstatus eq 'no_feedback_ever')))) {
+ my ($slothastime,$timerhastime);
+ if ($slot_name ne '') {
+ if (ref($slot) eq 'HASH') {
+ if (($slot->{'starttime'} < $now) &&
+ ($slot->{'endtime'} > $now)) {
+ $slothastime = $now - $slot->{'endtime'};
+ }
+ }
+ }
+ my $duedate = &Apache::lonnet::EXT("resource.0.duedate",$symb);
+ my @interval=&Apache::lonnet::EXT("resource.0.interval",$symb);
+ if (@interval > 1) {
+ my $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
+ if ($first_access > 0) {
+ my $timeremains = $first_access+$interval[0] - $now;
+ if ($timeremains > 0) {
+ $timerhastime = $timeremains;
+ }
+ }
+ }
+ if (($duedate && $duedate > $now) ||
+ (!$duedate && $timerhastime > 0) ||
+ ($slot_name ne '' && $slothastime)) {
+ if ((@interval > 1 && $timerhastime) ||
+ ($type eq 'Task' && $slothastime)) {
+ $countdowndisp{$symb} = 'inline';
+ if ((@interval > 1) && ($timerhastime)) {
+ $hastimeleft{$symb} = $timerhastime;
+ } else {
+ $hastimeleft{$symb} = $slothastime;
+ }
+ } else {
+ $hastimeleft{$symb} = $duedate - $now;
+ $countdowndisp{$symb} = 'none';
+ }
+ }
+ }
+ }
+ }
}
$thisdir=~s/\/[^\/]*$//;
foreach (@rlinks) {
@@ -441,6 +539,43 @@ ENDEXT
);
$allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
}
+ if ($ntimers) {
+ $allscript .= '\n";
+ }
+ if (keys(%hastimeleft)) {
+ my (%uniquetimes,%uniquedisplays);
+ foreach my $item (values(%hastimeleft)) {
+ if (exists($uniquetimes{$item})) {
+ $uniquetimes{$item} ++;
+ } else {
+ $uniquetimes{$item} = 1;
+ }
+ }
+ if (keys(%uniquetimes) == 1) {
+ my (%uniquedisplays,%uniquedones,$currdisp);
+ if (keys(%countdowndisp)) {
+ foreach my $item (values(%countdowndisp)) {
+ if (exists($uniquedisplays{$item})) {
+ $uniquedisplays{$item} ++;
+ } else {
+ $uniquedisplays{$item} = 1;
+ }
+ }
+ my @countdowndisplay = keys(%uniquedisplays);
+ if (scalar(@countdowndisplay) == 1) {
+ $currdisp = $countdowndisplay[0];
+ }
+ }
+ &add_countdown_timer($currdisp);
+ }
+ }
# ------------------------------------------------------------------ Start body
$r->print(&Apache::loncommon::start_page(undef,$allscript,
{'force_register' => 1,
@@ -457,7 +592,7 @@ ENDEXT
}
$fmtag .= ' action="'.
&Apache::lonenc::check_encrypt($requrl)
- .'">';
+ .'" id="LC_page">';
$r->print($fmtag);
}
} elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
@@ -537,9 +672,15 @@ ENDEXT
$r->print('>'.$metainfo.'');
} elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
- $r->print($metainfo.''.$hash{'title_'.$rid}.' '.
- &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').''.
- &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).' ');
+ $r->print($metainfo.''.$hash{'title_'.$rid}.' ');
+ unless ($cellemb{$rid} eq 'wrp') {
+ $r->print(&mt('It is recommended that you use an up-to-date virus scanner before handling this file.'));
+ }
+ $r->print(''.
+ &Apache::londocs::entryline(0,
+ &mt("Click to download or use your browser's Save Link function"),
+ '/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).
+ ' ');
}
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(' | ');
@@ -563,9 +704,19 @@ ENDEXT
}
# ---------------------------------------------------------------- Submit, etc.
if ($nforms) {
+ my $class;
+ if ($nforms > 1) {
+ $class = ' class="LC_hwk_submit"';
+ if ($ntimers) {
+ $nforms = 1;
+ $class = '';
+ }
+ }
$r->print(
- '
');
+ '
'.
+ '
'.
+ &mt('Processing your submission ...').'
');
}
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(&Apache::loncommon::end_page({'discussion'
@@ -610,6 +761,11 @@ sub get_buttons {
my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
$resid,
$hash->{'src_'.$rid});
+ unless ($env{'request.role.adv'}) {
+ if (&Apache::lonnet::EXT('resource.0.buttonshide',$symb)) {
+ return;
+ }
+ }
if ($hash->{'encrypted_'.$rid}) {
$symb=&Apache::lonenc::encrypted($symb);
$esrc=&Apache::lonenc::encrypted($esrc);
@@ -690,6 +846,35 @@ sub get_buttons {
return $metainfo;
}
+sub add_countdown_timer {
+ my ($currdisp) = @_;
+ my ($collapse,$expand,$alttxt,$title);
+ if ($currdisp eq 'inline') {
+ $collapse = '► ';
+ } else {
+ $expand = '◄ ';
+ }
+ unless ($env{'environment.icons'} eq 'iconsonly') {
+ $alttxt = &mt('Timer');
+ $title = $alttxt.' ';
+ }
+ my $desc = &mt('Countdown to due date/time');
+ my $output = <