\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;
@@ -384,6 +468,102 @@ 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,$pagesymb);
+ 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'))) ||
+ (($status eq 'NOT_YET_VIEWED') && ($posthash{'markaccess'} eq 'yes'))) {
+ 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;
+ if ($interval[1] eq 'map') {
+ my $ignorecache;
+ if ($env{'form.'.$prefix.'markaccess'} eq 'yes') {
+ $ignorecache = 1;
+ }
+ $first_access=&Apache::lonnet::get_first_access($interval[1],undef,$pagesymb,$ignorecache);
+ if (($first_access) && (!$pagefirstaccess)) {
+ $pagefirstaccess = $first_access;
+ }
+ } else {
+ $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
+ }
+ if ($first_access > 0) {
+ my ($timelimit) = ($interval[0] =~ /^(\d+)/);
+ if ($timelimit) {
+ my $timeremains = $timelimit + $first_access - $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;
+ if ($pagefirstaccess) {
+ my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
+ ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
+ if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
+ $usesdone = 'done';
+ $donebuttontext = $1;
+ (undef,$proctor,$secret) = split(/_/,$2);
+ } elsif ($donesuffix =~ /^done(|_.+)$/) {
+ $donebuttontext = &mt('Done');
+ ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
+ }
+ if ($usesdone eq 'done') {
+ $donebutton{$symb} = $timelimit;
+ push(@{$buttonbytime{$timelimit}},$symb);
+ $donebtnextra{$symb} = {
+ text => $donebuttontext,
+ proctor => $proctor,
+ secret => $secret,
+ type => $interval[1],
+ };
+ }
+ }
+ } else {
+ $hastimeleft{$symb} = $slothastime;
+ }
+ } else {
+ $hastimeleft{$symb} = $duedate - $now;
+ $countdowndisp{$symb} = 'none';
+ }
+ unless ($donebutton{$symb}) {
+ $donebutton{$symb} = 0;
+ }
+ }
+ }
+ }
+ }
}
$thisdir=~s/\/[^\/]*$//;
foreach (@rlinks) {
@@ -440,6 +620,62 @@ 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 (scalar(keys(%uniquetimes)) == 1) {
+ my (%uniquedisplays,%uniquedones,$currdisp,$donebuttontime,
+ $donebuttonextras);
+ 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];
+ }
+ }
+ if (keys(%donebutton)) {
+ foreach my $item (values(%donebutton)) {
+ if (exists($uniquedones{$item})) {
+ $uniquedones{$item} ++;
+ } else {
+ $uniquedones{$item} = 1;
+ }
+ }
+ my @donebuttons = sort { $ <=> $b } (keys(%uniquedones));
+ if (scalar(@donebuttons) == 1) {
+ if ($donebuttons[0]) {
+ $donebuttontime = $donebuttons[0];
+ if (ref($buttonbytime{$donebuttontime}) eq 'ARRAY') {
+ $donebuttonextras = $donebtnextra{$buttonbytime{$donebuttontime}->[0]};
+ }
+ }
+ }
+ }
+ &add_countdown_timer($currdisp,$donebuttontime,$donebuttonextras);
+ }
+ }
# ------------------------------------------------------------------ Start body
$r->print(&Apache::loncommon::start_page(undef,$allscript,
{'force_register' => 1,
@@ -456,7 +692,7 @@ ENDEXT
}
$fmtag .= ' action="'.
&Apache::lonenc::check_encrypt($requrl)
- .'">';
+ .'" id="LC_page">';
$r->print($fmtag);
}
} elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
@@ -489,7 +725,6 @@ ENDEXT
my $avespan=$lcm/($#colcont+1);
for ($j=0;$j<=$#colcont;$j++) {
my $rid=$colcont[$j];
-
my $metainfo =&get_buttons(\%hash,$rid).' ';
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(' | 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 +804,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 +861,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);
@@ -667,9 +923,72 @@ sub get_buttons {
'';
}
}
+ if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $file=&Apache::lonnet::declutter($hash->{'src_'.$rid});
+ my ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb);
+ if ($cfile ne '') {
+ my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
+ $forceedit,1,$symb,undef,
+ &escape($env{'form.title'}));
+ if ($jscall) {
+ my $icon = 'pcstr.png';
+ my $label = &mt('Edit');
+ my $title = &mt('Edit this resource');
+ my $pic = '
';
+ $metainfo .= '
'.$pic.'';
+ }
+ }
+ }
return $metainfo;
}
+sub add_countdown_timer {
+ my ($currdisp,$donebuttontime,$donebuttonextras) = @_;
+ my ($collapse,$expand,$alttxt,$title,$donebutton);
+ if ($currdisp eq 'inline') {
+ $collapse = '► ';
+ } else {
+ $expand = '◄ ';
+ }
+ if ($donebuttontime) {
+ my ($type,$proctor,$donebuttontext);
+ if (ref($donebuttonextras) eq 'HASH') {
+ $proctor = $donebuttonextras->{'proctor'};
+ $donebuttontext = $donebuttonextras->{'text'};
+ $type = $donebuttonextras->{'type'};
+ } else {
+ $donebuttontext = &mt('Done');
+ $type = 'map';
+ }
+ $donebutton =
+ &Apache::lonmenu::done_button_js($type,'','',$proctor,$donebuttontext);
+ }
+ unless ($env{'environment.icons'} eq 'iconsonly') {
+ $alttxt = &mt('Timer');
+ $title = $alttxt.' ';
+ }
+ my $desc = &mt('Countdown to due date/time');
+ my $output = <