\E)/
$1$idprefix$2$3$4/g;
+ $output=~
+ s/(\Q
)/$1$idprefix$2$3$4/g;
+ if ($nuploads) {
+ ($turninpaths{$prefix},$multiresps{$prefix}) =
+ &Apache::loncommon::get_turnedin_filepath($symb,$env{'user.name'},$env{'user.domain'});
+ if ($turninparent eq '') {
+ $turninparent = $turninpaths{$prefix};
+ $turninparent =~ s{(/[^/]+)$}{};
+ }
+ }
+ $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 ($plainsrc =~ /$LONCAPA::assess_re/) {
+ %Apache::lonhomework::history =
+ &Apache::lonnet::restore($symb,$courseid,$domain,$name);
+ my $type = 'problem';
+ if ($extension eq '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) {
- unless (($_=~/^http:\/\//i) ||
+ unless (($_=~/^https?\:\/\//i) ||
($_=~/^\//) ||
($_=~/^javascript:/i) ||
($_=~/^mailto:/i) ||
@@ -462,7 +520,7 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
$r->print(&Apache::loncommon::start_page(undef,undef,
- {'force_register' => 1,}));
+ {'force_register' => 1}));
$r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
$r->print('
'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').
&Apache::loncommon::end_page());
@@ -470,7 +528,7 @@ sub handler {
# ------------------------------------------------------------------ Build page
# ---------------------------------------------------------------- Send headers
- unless ($target eq 'tex') {
+ unless (($target eq 'tex') || ($target eq 'tex_answer')) {
if ($isxml) {
&Apache::loncommon::content_type($r,'text/xml');
} else {
@@ -484,28 +542,106 @@ sub handler {
$allscript.
"\n\n";
}
+ if (($nforms) && ($nuploads)) {
+ $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps).
+ '';
+ }
+ if (($nforms) && (&Apache::lonhtmlcommon::htmlareabrowser())) {
+ my %textarea_args = (
+ dragmath => 'math',
+ );
+ $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);
+ }
+ }
+ my $pagebuttonshide;
+ if (keys(%buttonshide)) {
+ my %uniquebuttonhide;
+ foreach my $item (values(%buttonshide)) {
+ if (exists($uniquebuttonhide{$item})) {
+ $uniquebuttonhide{$item} ++;
+ } else {
+ $uniquebuttonhide{$item} = 1;
+ }
+ }
+ if (keys(%uniquebuttonhide) == 1) {
+ if (lc((keys(%uniquebuttonhide))[0]) eq 'yes') {
+ $pagebuttonshide = 'yes';
+ }
+ }
+ }
# ------------------------------------------------------------------ Start body
$r->print(&Apache::loncommon::start_page(undef,$allscript,
{'force_register' => 1,
- 'bgcolor' => '#ffffff',}));
+ 'bgcolor' => '#ffffff',
+ 'hide_buttons' => $pagebuttonshide}));
# ------------------------------------------------------------------ Start form
if ($nforms) {
- $r->print('');
+ ''.
+ ''.
+ ''.
+ &mt('Processing your submission ...').' ');
}
- unless ($target eq 'tex') {
+ unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(&Apache::loncommon::end_page({'discussion'
=> 1,}));
} else {
@@ -630,11 +786,7 @@ sub handler {
}
sub get_buttons {
- my ($hash,$rid) = @_;
-
- # which icons do we use?
- my $extension='png';
- if ($env{'environment.icons'} eq 'classic') { $extension='gif'; }
+ my ($hash,$rid,$buttonshide,$hostname) = @_;
my $metainfo = '';
my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
@@ -642,25 +794,38 @@ sub get_buttons {
my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
$resid,
$hash->{'src_'.$rid});
+ unless ($env{'request.role.adv'}) {
+ if ($buttonshide->{$symb} eq 'yes') {
+ return;
+ }
+ }
if ($hash->{'encrypted_'.$rid}) {
$symb=&Apache::lonenc::encrypted($symb);
$esrc=&Apache::lonenc::encrypted($esrc);
}
if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
+ && $hash->{'src_'.$rid} !~ m{^https?://}
&& !$env{'request.enc'}
&& ($env{'request.role.adv'}
|| !$hash->{'encrypted_'.$rid})) {
$metainfo .=''.
''.
- ''.
+ ''.
+ '';
+ }
+ if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) &&
+ ($hash->{'src_'.$rid} !~ m{^https?://})) {
+ $metainfo .= ''.
+ ''.
'';
}
- $metainfo .= ''.
- ''.
- '';
- if (($hash->{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
+ if (($hash->{'src_'.$rid}=~/$LONCAPA::assess_re/) &&
($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {
if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
@@ -668,12 +833,16 @@ sub get_buttons {
''.
'&command=submission">'.
- ''.
+ ''.
''.
''.
'&command=gradingmenu">'.
- ''.
+ ''.
'';
}
if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
@@ -681,17 +850,204 @@ sub get_buttons {
''.
'" >'.
- ''.
+ ''.
'';
}
}
+ if ($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 $editbutton = '';
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ 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'},
+ $hostname));
+ if ($jscall) {
+ $editbutton = 1;
+ my $icon = 'pcstr.png';
+ my $label = &mt('Edit');
+ my $title = &mt('Edit this resource');
+ my $pic = '';
+ $metainfo .= ' '.$pic.'';
+ }
+ }
+ }
+ if ((!$editbutton) && ($file=~/$LONCAPA::assess_re/)) {
+ my $url = &Apache::lonnet::clutter($file);
+ my $viewsrcbutton;
+ if ((&Apache::lonnet::allowed('cre','/')) &&
+ (&Apache::lonnet::metadata($url,'sourceavail') eq 'open')) {
+ $viewsrcbutton = 1;
+ } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
+ if ($url =~ m{^\Q/res/$cdom/\E($LONCAPA::match_username)/}) {
+ my $auname = $1;
+ if (($env{'request.course.adhocsrcaccess'} ne '') &&
+ (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
+ $viewsrcbutton = 1;
+ }
+ }
+ }
+ if ($viewsrcbutton) {
+ my $icon = 'pcstr.png';
+ my $label = &mt('View Source');
+ my $title = &mt('View source code');
+ my $jsrid = $rid;
+ $jsrid =~ s/\./_/g;
+ my $showurl = &escape(&Apache::lonenc::check_encrypt($url));
+ my $pic = '';
+ $metainfo .= ' '.$pic.''."\n".
+ '\n";
+ }
+ }
+ }
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 = < |