\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;
+ ($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 ($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'))) ||
+ (($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) {
- unless (($_=~/^http:\/\//i) ||
+ unless (($_=~/^https?\:\/\//i) ||
($_=~/^\//) ||
($_=~/^javascript:/i) ||
($_=~/^mailto:/i) ||
@@ -470,7 +597,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 +611,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 (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,
'bgcolor' => '#ffffff',}));
# ------------------------------------------------------------------ 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 {
@@ -632,35 +855,44 @@ 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 $metainfo = '';
my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
my ($mapid,$resid)=split(/\./,$rid);
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);
}
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 +900,16 @@ sub get_buttons {
''.
'&command=submission">'.
- ''.
+ ''.
''.
''.
'&command=gradingmenu">'.
- ''.
+ ''.
'';
}
if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
@@ -681,17 +917,180 @@ 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 = < |