--- loncom/homework/lonhomework.pm 2006/05/12 01:20:44 1.245 +++ loncom/homework/lonhomework.pm 2006/05/16 21:21:32 1.248 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.245 2006/05/12 01:20:44 albertel Exp $ +# $Id: lonhomework.pm,v 1.248 2006/05/16 21:21:32 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -161,6 +161,8 @@ sub proctor_checked_in { my ($slot_name,$slot,$type)=@_; my @possible_proctors=split(",",$slot->{'proctor'}); + return 1 if (!@possible_proctors); + my $key; if ($type eq 'Task') { my $version=$Apache::lonhomework::history{'resource.0.version'}; @@ -383,7 +385,12 @@ sub check_access { foreach my $temp ("opendate","duedate","answerdate") { $lastdate = $date; - $date = &Apache::lonnet::EXT("resource.$id.$temp"); + if ($temp eq 'duedate') { + $date = &due_date($id); + } else { + $date = &Apache::lonnet::EXT("resource.$id.$temp"); + } + my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type"); if ($thistype =~ /^(con_lost|no_such_host)/ || $date =~ /^(con_lost|no_such_host)/) { @@ -451,18 +458,12 @@ sub check_access { &Apache::lonxml::debug("looking for accesstime $first_access"); if (!$first_access) { $status='NOT_YET_VIEWED'; - $datemsg=&seconds_to_human_length($interval); - } else { - my $newdate=localtime($first_access+$interval); - if (time > ($first_access+$interval)) { - $status='CLOSED'; - $datemsg = &mt("was due on")." $newdate".&mt(", and answers will be available on")." $date"; - } else { - $datemsg = &mt("is due at")." $newdate"; - } + my $due_date = &due_date($id); + $datemsg=&seconds_to_human_length($due_date-time); } } } + #if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && # (!$Apache::lonhomework::history{"resource.0.outtoken"})) { # return ('UNCHECKEDOUT','needs to be checked out'); @@ -478,6 +479,27 @@ sub check_access { return ($status,$datemsg); } +# this should work exactly like the copy in lonnavmaps.pm +sub due_date { + my ($part_id,$symb)=@_; + my $date; + my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb); + &Apache::lonxml::debug("looking for interval $part_id $symb $interval"); + my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb); + &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); + if (defined($interval)) { + my $first_access=&Apache::lonnet::get_first_access('map',$symb); + if (defined($first_access)) { + $interval = $first_access+$interval; + $date = ($interval < $due_date)? $interval : $due_date; + } else { + $date = $due_date; + } + } else { + $date = $due_date; + } + return $date +} sub seconds_to_human_length { my ($length)=@_;