--- loncom/homework/lonhomework.pm 2004/01/29 18:51:28 1.162 +++ loncom/homework/lonhomework.pm 2004/02/13 21:21:30 1.163 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.162 2004/01/29 18:51:28 albertel Exp $ +# $Id: lonhomework.pm,v 1.163 2004/02/13 21:21:30 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -204,61 +204,63 @@ sub check_access { &Apache::lonxml::debug("in construction ignoring dates"); $status='CAN_ANSWER'; $datemsg=&mt('is in under construction'); - return ($status,$datemsg); +# return ($status,$datemsg); } &Apache::lonxml::debug("checking for part :$id:"); &Apache::lonxml::debug("time:".time); - - my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); - if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { - $status='INVALID_ACCESS'; - $date=&mt("can not be accessed from your location."); - return($status,$date); - } - foreach $temp ("opendate","duedate","answerdate") { - $lastdate = $date; - $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)/) { - $status='UNAVAILABLE'; - $date=&mt("may open later."); + if ($ENV{'request.state'} ne "construct") { + my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); + if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { + $status='INVALID_ACCESS'; + $date=&mt("can not be accessed from your location."); return($status,$date); } - if ($thistype eq 'date_interval') { - if ($temp eq 'opendate') { - $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date; + + foreach $temp ("opendate","duedate","answerdate") { + $lastdate = $date; + $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)/) { + $status='UNAVAILABLE'; + $date=&mt("may open later."); + return($status,$date); + } + if ($thistype eq 'date_interval') { + if ($temp eq 'opendate') { + $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date; + } + if ($temp eq 'answerdate') { + $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date; + } } - if ($temp eq 'answerdate') { - $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date; + &Apache::lonxml::debug("found :$date: for :$temp:"); + if ($date eq '') { + $date = &mt("an unknown date"); $passed = 0; + } elsif ($date eq 'con_lost') { + $date = &mt("an indeterminate date"); $passed = 0; + } else { + if (time < $date) { $passed = 0; } else { $passed = 1; } + $date = localtime $date; } + if (!$passed) { $type=$temp; last; } } - &Apache::lonxml::debug("found :$date: for :$temp:"); - if ($date eq '') { - $date = &mt("an unknown date"); $passed = 0; - } elsif ($date eq 'con_lost') { - $date = &mt("an indeterminate date"); $passed = 0; - } else { - if (time < $date) { $passed = 0; } else { $passed = 1; } - $date = localtime $date; + &Apache::lonxml::debug("have :$type:$passed:"); + if ($passed) { + $status='SHOW_ANSWER'; + $datemsg=$date; + } elsif ($type eq 'opendate') { + $status='CLOSED'; + $datemsg = &mt("will open on")." $date"; + } elsif ($type eq 'duedate') { + $status='CAN_ANSWER'; + $datemsg = &mt("is due at")." $date"; + } elsif ($type eq 'answerdate') { + $status='CLOSED'; + $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; } - if (!$passed) { $type=$temp; last; } - } - &Apache::lonxml::debug("have :$type:$passed:"); - if ($passed) { - $status='SHOW_ANSWER'; - $datemsg=$date; - } elsif ($type eq 'opendate') { - $status='CLOSED'; - $datemsg = &mt("will open on")." $date"; - } elsif ($type eq 'duedate') { - $status='CAN_ANSWER'; - $datemsg = &mt("is due at")." $date"; - } elsif ($type eq 'answerdate') { - $status='CLOSED'; - $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; } if ($status eq 'CAN_ANSWER') { #check #tries, and if correct.