--- loncom/homework/structuretags.pm 2012/05/28 13:09:22 1.506 +++ loncom/homework/structuretags.pm 2012/09/12 05:14:09 1.508 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.506 2012/05/28 13:09:22 raeburn Exp $ +# $Id: structuretags.pm,v 1.508 2012/09/12 05:14:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1160,6 +1160,7 @@ sub start_problem { &Apache::run::run($expression,$safeeval); my $status; my $accessmsg; + my $resource_due; my $name= &get_resource_name($parstack,$safeeval); my ($result,$form_tag_start,$slot_name,$slot); @@ -1189,14 +1190,6 @@ sub start_problem { if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { - if ($status eq 'CAN_ANSWER') { - my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'}); - my $time_left = $resource_due - time(); - if ($resource_due && ($time_left > 0) && ($target eq 'web')) { - $result .= &Apache::lonhtmlcommon::set_due_date($resource_due); - } - } - #handle rand seed in construction space my $rndseed=&setup_rndseed($safeeval,$target); my ($symb)=&Apache::lonnet::whichuser(); @@ -1305,13 +1298,35 @@ sub start_problem { 'problem'); } } elsif ($target eq 'web') { - if ($status eq 'CAN_ANSWER' - && $slot_name ne '' - && $Apache::lonhomework::history{'resource.0.checkedin'} eq '') { - # unproctored slot access, self checkin - &Apache::bridgetask::check_in('problem',undef,undef, - $slot_name); - } + if ($status eq 'CAN_ANSWER') { + $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'}); + if ($slot_name ne '') { + my $checked_in = + $Apache::lonhomework::history{'resource.0.checkedin'}; + if ($checked_in eq '') { + # unproctored slot access, self checkin + &Apache::bridgetask::check_in('problem',undef,undef, + $slot_name); + $checked_in = + $Apache::lonhomework::results{"resource.0.checkedin"}; + } + if ((ref($slot) eq 'HASH') && ($checked_in ne '')) { + if ($slot->{'starttime'} < time()) { + if (!$resource_due) { + $resource_due = $slot->{'endtime'}; + } elsif ($slot->{'endtime'} < $resource_due) { + $resource_due = $slot->{'endtime'}; + } + } + } + } + if ($resource_due) { + my $time_left = $resource_due - time(); + if ($resource_due && ($time_left > 0) && ($target eq 'web')) { + $result .= &Apache::lonhtmlcommon::set_due_date($resource_due); + } + } + } $result.="\n $form_tag_start \t". ''; # create a page header and exit @@ -1497,7 +1512,13 @@ sub end_problem { $result.=""; } if ($target eq 'web') { - $result.= &Apache::loncommon::end_page({'discussion' => 1}); + # + # Closing not added by end_page(). + # Added separately at end of this routine, after added + # so document will be valid xhtml. + # + $result.= &Apache::loncommon::end_page({'discussion' => 1, + 'notbody' => 1}); } elsif ($target eq 'tex') { my $endminipage = ''; if (not $env{'form.problem_split'}=~/yes/) { @@ -1555,6 +1576,11 @@ sub end_problem { # if ($target eq 'web') { $result .= &Apache::lonhtmlcommon::set_compute_end_time(); + # + # Closing tags delayed so any tags + # not in head can appear inside body, for valid xhtml. + # + $result .= "\n"; } return $result; }